Look up enumeration values

This script replaces enumeration values with their textual representation.

Usage

// DESCRIPTION: Display a dialog with enumeration values resolved. #target "InDesign" #include "/www.ixta.com/scripts/utilities/pretty.jsx" var n = "app.wordRTFImportPreferences"; alert(n+"\n"+pretty(eval(n)));

The Script

// DESCRIPTION: Look up enumeration values. // Copyright ©2009 Dirk Becker, http://www.ixta.de // This software is provided "as is", with absolutely no warranty. // Permission to install and use the software is hereby granted without fee. // Redistribution by any means is expressly prohibited. function pretty(o) { if( !pretty.lookup ) { pretty.lookup = {}; for( var en in $.global ) { try { var eo = $.global[en]; if( eo ) if( eo.constructor.name=="Enumeration" ) { for( var vn in eo ) if( /^[A-Z_]+$/.test(vn) ) pretty.lookup[eo[vn]] = en+"."+vn; } } catch( ex ) {}; } } return o.properties.toSource().slice(1,-1). replace(/,/g,",\n\t"). replace(/:[1-9][0-9]+,/g,function (str) { var num = str.slice(1,-1); var val = pretty.lookup[num]; return val ? ": "+val+"," : str; }); }; // "touch" the enumeration classes to make them available in $.global StoryTypes; StoryDirectionOptions; ImportFormat; NestedStyleDelimiters; RuleWidth; Justification; SingleWordJustification; StartParagraph; HorizontalOrVertical; TabStopAlignment; FirstBaseline; VerticalJustification; Leading; OTFFigureStyle; Capitalization; Position; TextFrameContents; SpecialCharacters; ChangecaseMode; BindingOptions; PageOrientation; RulerOrigin; MeasurementUnits; PageBindingOptions; BaselineGridRelativeOption; PageSideOptions; WhenScalingOptions; EPSColorSpace; PreviewTypes; FontEmbedding; ScaleModes; PrintLayerOptions; GlobalClashResolutionStrategyForMasterPage; ClippingPathType; UpdateLinkOptions; IconSizes; PanelLayoutResize; PDFContentToEmbed; PDFColorSpace; AcrobatCompatibility; ICCProfiles; BitmapCompression; CompressionQuality; MonoBitmapCompression; PDFMarkWeight; Sampling; ExportPresetFormat; PDFCrop; PDFCompressionType; PDFProfileSelector; PDFXStandards; ExportLayerOptions; ConvertShapeOptions; CoordinateSpaces; MatrixContent; BoundingBoxLimits; ResizeConstraints; ResizeMethods; EmptyFrameFittingOptions; CornerOptions; ContentType; EndCap; EndJoin; StrokeCornerAdjustment; ArrowHead; DisplaySettingOptions; FitOptions; StrokeAlignment; ContourOptionsTypes; TextWrapSideOptions; TextWrapModes; FontStatus; FontTypes; OpenTypeFeature; ComposeUsing; PageNumberStyle; GradientType; JoinOptions; PathType; PointType; CreateProxy; ImportedPageCropOptions; StrokeFillProxyOptions; StrokeFillTargetOptions; LocationOptions; UIColors; NothingEnum; AutoEnum; EventPhases; ExportFormat; PlacedVectorProfilePolicy; ColorSettingsPolicy; DefaultRenderingIntent; ProofingType; ChangeConditionsModes; SearchModes; ObjectTypes; LibraryPanelViews; SortAssets; LinkStatus; AssetType; ChangeTypes; TextPathEffects; TextTypeAlignments; PathTypeAlignments; FlipValues; XMLElementLocation; XMLElementPosition; XMLImportStyles; XMLFileEncoding; ImageConversion; GIFOptionsPalette; JPEGOptionsQuality; JPEGOptionsFormat; XMLExportUntaggedTablesFormat; XMLTransformFile; AnchorPosition; HorizontalAlignment; VerticalAlignment; AnchoredRelativeTo; BalanceLinesStyle; VerticallyRelativeTo; PositionalForms; TextStrokeAlign; OutlineJoin; BaselineFrameGridRelativeOption; FootnoteFirstBaseline; FootnoteRestarting; FootnotePrefixSuffix; FootnoteNumberingStyle; FootnoteMarkerPositioning; OverrideType; GlobalClashResolutionStrategy; StoryHorizontalOrVertical; AddPageOptions; VariableTypes; VariableScopes; VariableNumberingStyles; SearchStrategies; ChangeCaseOptions; InCopyUIColors; CursorTypes; AntiAliasType; LineSpacingType; RepaginateOption; BookContentStatus; SmartMatchOptions; RowTypes; HeaderFooterBreakTypes; AlternatingFillsTypes; StrokeOrderTypes; DisplayOrderOptions; FlattenerLevel; BlendingSpace; BlendMode; ShadowMode; FeatherMode; FeatherCornerType; SpreadFlattenerLevel; GlowTechnique; InnerGlowSource; BevelAndEmbossStyle; BevelAndEmbossTechnique; BevelAndEmbossDirection; FollowShapeModeOptions; PageNumberPosition; NumberedParagraphsOptions; TextImportCharacterSet; ImportPlatform; ConvertPageBreaks; TagTextExportCharacterSet; TagTextForm; StyleConflict; TextExportCharacterSet; ConvertTablesOptions; TableFormattingOptions; AlignmentStyleOptions; ResolveStyleClash; ContainerType; CopyrightStatus; IndexCapitalizationOptions; IndexFormat; CrossReferenceType; PageReferenceType; HeaderTypes; TagTransparency; TagVector; TagRaster; HyperlinkAppearanceHighlight; HyperlinkAppearanceWidth; HyperlinkAppearanceStyle; HyperlinkDestinationPageSetting; BuildingBlockTypes; PreflightRuleFlag; RuleDataType; PreflightScopeOptions; PreflightLayerOptions; PreflightProfileOptions; StateTypes; VisibilityInPdf; FloatingWindowPosition; FloatingWindowSize; PlayMode; MoviePosterTypes; SoundPosterTypes; BehaviorEvents; GoToZoomOptions; PlayOperations; ViewZoomStyle; VersionState; EditingState; VersionCueSyncStatus; SyncConflictResolution; UserInteractionLevels; Locale; ScriptLanguage; FeatureSetOptions; UndoModes; SaveOptions; ZoomOptions; ViewDisplaySettings; AnchorPoint; ColorModel; ColorSpace; ScreenModeOptions; PageNumberingOptions; ToolTipOptions; SelectionOptions; SelectAll; PreviewSizeOptions; ToolsPanelOptions; RenderingIntent; MarkLineWeight; MarkTypes; ColorOutputModes; DataFormat; Flip; FontDownloading; PagePositions; PostScriptLevels; PrintPageOrientation; ImageDataTypes; Sequences; SourceSpaces; ThumbsPerPage; TilingTypes; Trapping; InkTypes; PrinterPresetTypes; ColorRenderingDictionary; PageRange; PaperSize; PPDValues; Profile; Screeening; PaperSizes; Printer; TrapImagePlacementTypes; TrapEndTypes; EPSImageData; BookletTypeOptions; SignatureSizeOptions; DocumentPrintUiOptions; NoteBackgrounds; NoteColorChoices; LockStateValues; ExportRangeOrAllPages; SnippetExportFormats; RecordSelection; ArrangeBy; RecordsPerPage; Fitting; SourceFieldType; ListType; BulletCharacterType; NumberingStyle; RestartPolicy; ListAlignment; ChapterNumberSources; AssignmentExportOptions; AssignmentStatus; PanningTypes; AlignDistributeBounds; AlignOptions; DistributeOptions; PerformanceMetricOptions; XFLRasterizeFormatOptions; PageTransitionTypeOptions; PageTransitionDirectionOptions; RasterCompressionOptions; DynamicDocumentsJPEGQualityOptions; DynamicDocumentsTextExportPolicy; FitMethodSettings; FitDimension; PageTransitionDurationOptions; SWFCurveQualityValue; ConditionIndicatorMethod; ConditionUnderlineIndicatorAppearance; ConditionIndicatorMode; ParagraphDirectionOptions; ParagraphJustificationOptions; CharacterDirectionOptions; DigitsTypeOptions; KashidasOptions; DiacriticPositionOptions; TableDirectionOptions;