internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { FixedMediaSizeOption option = baseOption as FixedMediaSizeOption; bool complete = false; // All PageMediaSize options must have an option name if (option._optionName == null) { return(complete); } int enumValue = PrintSchemaMapper.SchemaNameToEnumValueWithArray( PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeNames, PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeEnums, option._optionName); // We only support standard Print Schema options if (enumValue > 0) { option._value = (PageMediaSizeName)enumValue; if ((option._mediaSizeWidth > 0) || (option._mediaSizeHeight > 0)) { this.FixedMediaSizes.Add(option); complete = true; } } return(complete); }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { NUpOption option = baseOption as NUpOption; bool handled = false; // we are only handling scored property here if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.NUpKeys.PagesPerSheet) { try { option._pagesPerSheet = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } handled = true; } } return(handled); }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool added = false; InputBinOption option = baseOption as InputBinOption; // Validate the option is complete before adding it to the collection if (option._optionName != null) { int enumValue = PrintSchemaMapper.SchemaNameToEnumValueWithArray( PrintSchemaTags.Keywords.InputBinKeys.InputBinNames, PrintSchemaTags.Keywords.InputBinKeys.InputBinEnums, option._optionName); if (enumValue > 0) { // We require the InputBin option to have an option name option._value = (InputBin)enumValue; this.InputBins.Add(option); added = true; } } return(added); }
/// <summary> /// Generic processing of option-element XML attributes /// </summary> /// <exception>none</exception> public void OptionAttributeGenericHandler(PrintCapabilityOption option) { // Currently we support these option-element attributes: // "name" // Handle the "name" XML attribute option._optionName = this.CurrentElementNameAttrValue; }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool added = false; NUpOption option = baseOption as NUpOption; // validate the option is complete before adding it to the collection if (option.PagesPerSheet > 0) { this.NUps.Add(option); added = true; } return(added); }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool added = false; ResolutionOption option = baseOption as ResolutionOption; // Validate the option is complete before adding it to the collection // QualitativeResolution is NOT required if ((option.ResolutionX > 0) && (option.ResolutionY > 0)) { this.Resolutions.Add(option); added = true; } return(added); }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool added = false; TrueTypeFontModeOption option = baseOption as TrueTypeFontModeOption; // validate the option is complete before adding it to the collection if (option._optionName != null) { int enumValue = PrintSchemaMapper.SchemaNameToEnumValueWithArray( PrintSchemaTags.Keywords.PageTrueTypeFontModeKeys.ModeNames, PrintSchemaTags.Keywords.PageTrueTypeFontModeKeys.ModeEnums, option._optionName); if (enumValue > 0) { option._value = (TrueTypeFontMode)enumValue; this.TrueTypeFontModes.Add(option); added = true; } } return(added); }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool added = false; NUpPresentationDirectionOption option = baseOption as NUpPresentationDirectionOption; // validate the option is complete before adding it to the collection if (option._optionName != null) { int enumValue = PrintSchemaMapper.SchemaNameToEnumValueWithArray( PrintSchemaTags.Keywords.NUpKeys.DirectionNames, PrintSchemaTags.Keywords.NUpKeys.DirectionEnums, option._optionName); if (enumValue > 0) { option._value = (PagesPerSheetDirection)enumValue; this.PresentationDirections.Add(option); added = true; } } return(added); }
internal override sealed bool OptionPropCallback(PrintCapabilityOption option, XmlPrintCapReader reader) { // no option property to handle return(false); }
internal override sealed void OptionAttrCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { // no option attribute to handle return; }
/// <summary> /// Standard PrintCapabilities feature option-attribute callback. /// </summary> internal abstract void OptionAttrCallback(PrintCapabilityOption option, XmlPrintCapReader reader);
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { FixedMediaSizeOption option = baseOption as FixedMediaSizeOption; bool handled = false; if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { handled = true; string sPropertyName = reader.CurrentElementNameAttrValue; if ((sPropertyName == PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeWidth) || (sPropertyName == PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeHeight)) { if (reader.MoveToNextSchemaElement(reader.CurrentElementDepth + 1, PrintSchemaNodeTypes.ScoredPropertyLevelTypes)) { if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.Value) { // Child property is Value for fixed media size int intValue = 0; bool convertOK = false; try { intValue = XmlConvertHelper.ConvertStringToInt32(reader.CurrentElementTextValue); convertOK = true; } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- Invalid int value '" + reader.CurrentElementTextValue + "' at line number " + reader._xmlReader.LineNumber + ", line position " + reader._xmlReader.LinePosition + ": " + e.Message); #endif } if (convertOK) { if (sPropertyName == PrintSchemaTags.Keywords.PageMediaSizeKeys.MediaSizeWidth) { option._mediaSizeWidth = intValue; } else { option._mediaSizeHeight = intValue; } } } } else { #if _DEBUG Trace.WriteLine("-Error- Missing required Value or ParameterRef child-element at line number " + reader._xmlReader.LineNumber + ", line position " + reader._xmlReader.LinePosition); #endif } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown ScoredProperty '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } return(handled); }
/// <summary> /// Standard PrintCapabilities feature option-property callback. /// </summary> internal abstract bool OptionPropCallback(PrintCapabilityOption option, XmlPrintCapReader reader);
// derived types must implement following abstract methods /// <summary> /// Standard PrintCapabilities feature add-new-option callback. /// </summary> internal abstract bool AddOptionCallback(PrintCapabilityOption option);
/// <summary> /// Builds a single feature instance and populates its state /// </summary> /// <exception cref="XmlException">XML is not well-formed.</exception> private void BuildFeature(InternalPrintCapabilities printCap, PrintCapabilityFeature parentFeature) { int featureIndex = LookupFeatureIndex(_reader.CurrentElementNameAttrValue, (parentFeature != null)); // Skip if the feature is unknown to us if (featureIndex < 0) { #if _DEBUG Trace.WriteLine("-Warning- Skip unknown feature '" + _reader.CurrentElementNameAttrValue + "'"); #endif return; } // So it's a known standard feature we want to handle NewFeatureHandler newFeatureCallback; // Get all the callback functions of this feature. // None of the callback functions should throw FormatException. Throwing XmlException // (from XmlTextReader) is OK. LookupFeatureCallbacks(_reader.CurrentElementNameAttrValue, (parentFeature != null), out newFeatureCallback); // New-feature callback returns a new, empty feature object derived from PrintCapabilityFeature PrintCapabilityFeature newFeature = newFeatureCallback(printCap); // Reader can handle generic feature element XML attributes // _reader.FeatureAttributeGenericHandler(newFeature); // We assume there is no feature level non-generic XML attribute that // needs us calling into feature-specific callback. int optionDepth = _reader.CurrentElementDepth + 1; PrintSchemaNodeTypes typeFilterFlags; if (newFeature.HasSubFeature) { typeFilterFlags = PrintSchemaNodeTypes.FeatureLevelTypesWithSubFeature; } else { typeFilterFlags = PrintSchemaNodeTypes.FeatureLevelTypesWithoutSubFeature; } // This "while" loops over immediate children of the feature element while (_reader.MoveToNextSchemaElement(optionDepth, typeFilterFlags)) { if (_reader.CurrentElementNodeType == PrintSchemaNodeTypes.Property) { // Process feature property bool handled = false; // call feature-specific callback handled = newFeature.FeaturePropCallback(newFeature, _reader); if (!handled) { #if _DEBUG Trace.WriteLine("-Warning- Skip feature's unknown " + _reader.CurrentElementNodeType + " '" + _reader.CurrentElementNameAttrValue + "'" + " at line " + _reader._xmlReader.LineNumber + ", position " + _reader._xmlReader.LinePosition); #endif } } else if (_reader.CurrentElementNodeType == PrintSchemaNodeTypes.Option) { // Process feature option // New-option callback returns a new, empty option object derived from PrintCapabilityOption PrintCapabilityOption newOption = newFeature.NewOptionCallback(newFeature); // Reader can handle generic option element XML attributes _reader.OptionAttributeGenericHandler(newOption); // Specific feature may also have unique XML attributes to process newFeature.OptionAttrCallback(newOption, _reader); // Go one level deeper if the option is non-empty since it could have // properties as sub-elements. if (!_reader.CurrentElementIsEmpty) { int optionPropertyDepth = optionDepth + 1; // This "while" loops over immediate children of the option element while (_reader.MoveToNextSchemaElement(optionPropertyDepth, PrintSchemaNodeTypes.OptionLevelTypes)) { bool handled = false; // If it's not generic property, use feature-specific callback handled = newFeature.OptionPropCallback(newOption, _reader); if (!handled) { #if _DEBUG Trace.WriteLine("-Warning- Skip option's unknown " + _reader.CurrentElementNodeType + " at line " + _reader._xmlReader.LineNumber + ", position " + _reader._xmlReader.LinePosition); #endif } } } // Finished reading and building this option, so add it to the option collection. // The capability-specific AddOption() function will have logic to check // the completeness of the newOption and based on that decide whether or not to // add the option to the option collection. if (!newFeature.AddOptionCallback(newOption)) { #if _DEBUG Trace.WriteLine("-Warning- skip unknown or incomplete option (name='" + newOption._optionName + "') at line " + _reader._xmlReader.LineNumber + ", position " + _reader._xmlReader.LinePosition + ": " + newOption); #endif } } else if (_reader.CurrentElementNodeType == PrintSchemaNodeTypes.Feature) { #if _DEBUG Trace.Assert(newFeature.HasSubFeature, "THIS SHOULD NOT HAPPEN: BuildFeature() hits sub-feature " + _reader.CurrentElementNameAttrValue); #endif // Recursively builds the sub-feature BuildFeature(printCap, newFeature); } else { #if _DEBUG Trace.Assert(false, "THIS SHOULD NOT HAPPEN: BuildFeature() hits " + _reader.CurrentElementNodeType + " node " + _reader.CurrentElementNameAttrValue); #endif } } // Accept the new feature only if it has valid state if (newFeature.IsValid) { if (parentFeature != null) { parentFeature.AddSubFeatureCallback(newFeature); } else { printCap._pcRootFeatures[featureIndex] = newFeature; } } else { #if _DEBUG Trace.WriteLine("-Warning- skip invalid or incomplete feature " + newFeature.FeatureName); #endif } }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { bool handled = false; ScalingOption option = baseOption as ScalingOption; if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { handled = true; string sPropertyName = reader.CurrentElementNameAttrValue; if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleWidth) || (sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleHeight) || (sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomSquareScale)) { // custom or custom square scaling properties try { string paramRefName = reader.GetCurrentPropertyParamRefNameWithException(); if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleWidth) && (paramRefName == PrintSchemaTags.Keywords.ParameterDefs.PageScalingScaleWidth)) { option._scaleWIndex = (int)PrintSchemaLocalParameterDefs.PageScalingScaleWidth; // Mark the local parameter-def as required option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleWIndex, true); } else if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomScaleHeight) && (paramRefName == PrintSchemaTags.Keywords.ParameterDefs.PageScalingScaleHeight)) { option._scaleHIndex = (int)PrintSchemaLocalParameterDefs.PageScalingScaleHeight; // Mark the local parameter-def as required option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleHIndex, true); } else if ((sPropertyName == PrintSchemaTags.Keywords.PageScalingKeys.CustomSquareScale) && (paramRefName == PrintSchemaTags.Keywords.ParameterDefs.PageSquareScalingScale)) { option._squareScaleIndex = (int)PrintSchemaLocalParameterDefs.PageSquareScalingScale; // Mark the local parameter-def as required option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._squareScaleIndex, true); } else { #if _DEBUG Trace.WriteLine("-Warning- skip unknown ParameterRef " + paramRefName + "' at line number " + reader._xmlReader.LineNumber + ", line position " + reader._xmlReader.LinePosition); #endif } } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown ScoredProperty '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } return(handled); }
internal override sealed bool AddOptionCallback(PrintCapabilityOption baseOption) { bool complete = false; ScalingOption option = baseOption as ScalingOption; if (option._optionName != null) { int enumValue = PrintSchemaMapper.SchemaNameToEnumValueWithArray( PrintSchemaTags.Keywords.PageScalingKeys.ScalingNames, PrintSchemaTags.Keywords.PageScalingKeys.ScalingEnums, option._optionName); if (enumValue > 0) { option._value = (PageScaling)enumValue; } } if (option.Value != PageScaling.Unspecified) { if (option.Value == PageScaling.None) { // Non-custom scaling option doesn't need any ParameterRefs complete = true; } else if (option.Value == PageScaling.Custom) { // Custom scaling option must have the 2 scale ParameterRefs if ((option._scaleWIndex >= 0) && (option._scaleHIndex >= 0)) { complete = true; } else { // Need to reset the local parameter required flag since we are // ignoring the custom scaling option if (option._scaleWIndex >= 0) { option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleWIndex, false); } if (option._scaleHIndex >= 0) { option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._scaleHIndex, false); } } } else if (option.Value == PageScaling.CustomSquare) { // Custom square scaling option must have the scale ParameterRef if (option._squareScaleIndex >= 0) { complete = true; } else { // Need to reset the local parameter required flag since we are // ignoring the custom scaling option if (option._squareScaleIndex >= 0) { option.OwnerFeature.OwnerPrintCap.SetLocalParameterDefAsRequired(option._squareScaleIndex, false); } } } } if (complete) { this.ScalingOptions.Add(option); } return(complete); }
/// <exception cref="XmlException">XML is not well-formed.</exception> internal override sealed bool OptionPropCallback(PrintCapabilityOption baseOption, XmlPrintCapReader reader) { ResolutionOption option = baseOption as ResolutionOption; bool handled = false; if (reader.CurrentElementNodeType == PrintSchemaNodeTypes.ScoredProperty) { handled = true; if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageResolutionKeys.ResolutionX) { try { option._resolutionX = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageResolutionKeys.ResolutionY) { try { option._resolutionY = reader.GetCurrentPropertyIntValueWithException(); } // We want to catch internal FormatException to skip recoverable XML content syntax error #pragma warning suppress 56502 #if _DEBUG catch (FormatException e) #else catch (FormatException) #endif { #if _DEBUG Trace.WriteLine("-Error- " + e.Message); #endif } } else if (reader.CurrentElementNameAttrValue == PrintSchemaTags.Keywords.PageResolutionKeys.QualitativeResolution) { int enumValue; if (PrintSchemaMapper.CurrentPropertyQValueToEnumValue(reader, PrintSchemaTags.Keywords.PageResolutionKeys.QualityNames, PrintSchemaTags.Keywords.PageResolutionKeys.QualityEnums, out enumValue)) { option._qualityValue = (PageQualitativeResolution)enumValue; } } else { handled = false; #if _DEBUG Trace.WriteLine("-Warning- skip unknown ScoredProperty '" + reader.CurrentElementNameAttrValue + "' at line " + reader._xmlReader.LineNumber + ", position " + reader._xmlReader.LinePosition); #endif } } return(handled); }