17 Replies Latest reply on Jul 28, 2016 7:03 AM by Trevorׅ

    Search document for SpecialCharacters Enumerator

    TᴀW Adobe Community Professional & MVP

      Hi,

       

      I've placed a Word document that has loads of irritating Unicode markers

      (left-to-right etc.)

       

      There is no way that I can see of using the UI to search and delete

      these characters.

       

      The unicode value of these markers is: 0x200E as it appears from the

      Info palette, but that Unicode value is shared by various things.

       

      Selecting a marker and get its contents (app.selection[0].contents)

      returns the number: 1399616109. This is in fact the number for

      SpecialCharacters.LEFT_TO_RIGHT_MARK.

       

      To cut a long story short and make a specific question general:

       

      How do you search for a SpecialCharacter that doesn't have an escape

      code in the GREP find/replace?

       

      What I've done so far is looped through all the characters in the

      document and compared their contents to 1399616109. But this is very

      slow, and is also causing InDesign to crash.

       

      Is there a better way?

       

      Thanks,

      Ariel

       

        • 1. Re: Search document for SpecialCharacters Enumerator
          Marc Autret Level 4

          Hi Ariel,

           

          Use the Unicode code point in the GREP F/R field this way:

          \x{200E}

           

          See also:

          http://www.indiscripts.com/post/2009/07/idcs4-special-characters

           

          @+

          Marc

          • 2. Re: Search document for SpecialCharacters Enumerator
            TᴀW Adobe Community Professional & MVP

            Hi Marc,

             

            Thank you. I couldn't find that documented anywhere.

             

            Ariel

            • 3. Re: Search document for SpecialCharacters Enumerator
              Marc Autret Level 4

              To complete my previous post:

               

              1) Given a Character myChar whose contents property returns a SpecialCharacter enumerator, you can still retrieve the Unicode codepoint using myChar.texts[0].contents instead of myChar.contents:

               

              alert( myChar.texts[0].contents.charCodeAt(0).toString(16) ); // => Unicode CP (hexa)
              

               

               

              2) Since ID CS5 the Enumeration objects (Locale, SpecialCharacters, etc.) describe a set of Enumerator objects rather than a set of numbers. An Enumerator is a special native object which converts itself into either a String or a Number depending on the context:

               

              // ID CS5+
              alert( SpecialCharacters.emDash ); // => EM_DASH (string)
              alert( +SpecialCharacters.emDash ); // => 1397058884 (number)
              

               

              In fact, these respectively correspond to myEnumerator.toString() and myEnumerator.valueOf():

               

              // ID CS5+
              
              var myEnumerator = SpecialCharacters.emDash;
              
              alert( myEnumerator.toString() ); // => EM_DASH (string)
              alert( myEnumerator.valueOf() ); // => 1397058884 (number)
              

               

              But every Enumerator has its == and === operators overriden so as we can still compare it with a number:

               

              alert( SpecialCharacters.emDash==1397058884 ); // => true
              alert( SpecialCharacters.emDash===1397058884 ); // => true
              

               

              Also, an Enumeration object see both the camelcase and the uppercase name of an enumerator as a regular own property:

               

              // ID CS5+
              alert( SpecialCharacters.hasOwnProperty('emDash') ); // => true
              alert( SpecialCharacters.hasOwnProperty('EM_DASH') ); // => true
              

               

              Both are [[enumerable]] but the for-in loop only collects the uppercase forms ('EM_DASH', etc.).

               

              @+

              Marc

              • 4. Re: Search document for SpecialCharacters Enumerator
                Trevorׅ Adobe Community Professional

                Hi Marc or anybody else who knows

                 

                Is there a way of getting the full Enumeration string, i.e. SpecialCharacters.EM_DASH and not just EM_DASH ?

                 

                Regards

                 

                Trevor

                • 5. Re: Search document for SpecialCharacters Enumerator
                  Harbs. Adobe Community Professional & MVP

                  Huh?

                  I'm not sure what you are asking...

                  • 6. Re: Search document for SpecialCharacters Enumerator
                    Trevorׅ Adobe Community Professional

                    Hi Harbs

                     

                    If I want to get the Enumeration value for an object I could use for example.

                    app.selection[0].appliedParagraphStyle .diacriticPosition*1

                    I would get back the value for example 1685090164

                    To get the string of the enumaration I can use

                    app.selection[0].appliedParagraphStyle .diacriticPosition.toString()

                    this will return OPENTYPE_POSITION (will also return this without the toString but the toString prevents it revering back to a numeric)

                     

                    If I were to enter app.selection[0].appliedParagraphStyle .diacriticPosition = 1685090164 that's going to work

                    but if I enter app.selection[0].appliedParagraphStyle .diacriticPosition = OPENTYPE_POSITION that's not going to work.

                    In this non-numeric form I need to enter app.selection[0].appliedParagraphStyle .diacriticPosition = DiacriticPositionOptions.OPENTYPE_POSITION

                    Is there a way of "Extracting" this term DiacriticPositionOptions ?

                     

                    I hope that's clear (have my doubts) if still not clear I have a script that I can post that should make it clear.

                     

                    Trevor

                    • 7. Re: Search document for SpecialCharacters Enumerator
                      Trevorׅ Adobe Community Professional

                      I think it might be useful to include this script.

                       

                      I preduces a "manual" of how to set the properties of a selected object (between 40 to 100 pages of properties).

                      The script is not finished but works quite nicely.

                       

                      Select an object / text / something and then run the script. Takes about 30 seconds to run.

                       

                      If I say so myself it's quite a nice not script

                       

                      Let me know if all clear.

                       

                       

                      #target "indesign"
                      #targetengine "main"
                      
                      myDoc = app.activeDocument;
                      
                      mySelection=app.selection[0]
                      
                      pl=""
                          myProperties=mySelection;
                          myPropertiesString="app.selection[0]";
                      //mo = new Object
                      //mo = {a:4, b:5, c:{q:5, w:8, ss:"foo", fred:{we:5,fh:65}}, d:10};
                      s=""
                      ss=0;
                      myObjConstructor=myProperties.constructor.name.toString();
                      n = (myObjConstructor[0]=="A" ||myObjConstructor[0]=="E" ||myObjConstructor[0]=="I" ||myObjConstructor[0]=="O" ||myObjConstructor[0]=="U") ?
                      "n ": " ";
                      s="* "+myPropertiesString+" is a"+n+myObjConstructor+" *\r\r";
                      elem(myProperties,myPropertiesString)
                      function elem(obj, subObj)
                      {
                      var oldSubObj = subObj;    
                      var p=0
                      var y=[]
                      var z = []
                      for (x in obj)
                      { ++p
                          y[p]=x
                      ss++;
                      try { (obj[x]!=null) ? z[p]=obj[x] : z[p]="nullnulllnull";} catch (notApplicable) {z[p]="null"}
                      try {zz= z[p].properties} catch (np) {zz=z[p].constructor.name; /*alert(z[p])*/};
                      zzz=z[p].constructor.name;
                      szp=(zzz=="Enumerator") ? z[p].toString() + " or ":"";
                      if (z[p]!=null) 
                          { if     (zz=="[object Object]" )
                          {
                              if( y[p] !="parent"&& y[p] !="parentStory" 
                              && y[p] !="startTextFrame"  && y[p] !="endTextFrame"
                              && y[p] !="nextTextFrame"  && y[p] !="previousTextFrame"
                              && y[p]!="nextStyle" && y[p]!="previousStyle"
                              && y[p]!="pageStart" && y[p]!="pageEnd" 
                              && y[p]!="index" && y[p]!="index")  
                          {
                              var sz=(subObj+"."+y[p].toString())
                              s+=subObj+" ."+y[p]+" = "+z[p]+"\t"+zz+"\t"+zzz+" *\r";
                      
                      
                           
                            eval("elem("+sz+",'"+sz+"');");
                              
                          }}
                        else   {s+=subObj+" ."+y[p]+" = "+szp+z[p]+"\t"+zz+"\t"+zzz+"\r";subObj = oldSubObj ;}
                      } else  {s+=subObj+" ."+y[p]+" = "+szp+z[p]+"\t"+zz+"\t"+zzz+"\r"; subObj = oldSubObj ;}
                        
                      subObj = oldSubObj ;
                      }  }
                      myContents=s;
                      
                      myDoc = app.documents.add();
                      app.activeDocument.layoutWindows[0].screenMode = ScreenModeOptions.PRESENTATION_PREVIEW;
                      oldUnits=app.scriptPreferences.measurementUnit;
                      app.scriptPreferences.measurementUnit=MeasurementUnits.MILLIMETERS;
                      myDoc.documentPreferences.properties =
                      {facingPages:0, intent:DocumentIntentOptions.PRINT_INTENT, pageHeight:210,
                         pageWidth:297, pageOrientation:PageOrientation.LANDSCAPE}
                      setUpStyles();
                      mastertextFrames = myDoc.masterSpreads.item("A-Master").textFrames.add
                      ({geometricBounds: [200,0,210,297], contents:SpecialCharacters.AUTO_PAGE_NUMBER}); 
                      mastertextFrames.parentStory.paragraphs[0].justification=Justification.CENTER_ALIGN
                      mastertextFrames.duplicate([297,200])
                       myTextFrame = app.activeWindow.activePage.textFrames.add({geometricBounds:[12, 12, 198, 285], strokeWeight:0, strokeColor:"None"});
                      myTextFrame.parentStory.appliedParagraphStyle=mps
                      myTextFrame.parentStory.contents=myContents
                      while (myTextFrame.overflows) {addPage(myTextFrame)}
                      
                      
                      
                      
                      function addPage(prevTextFrame)
                      {
                          myPage = myDoc.pages.add();
                          myTextFrame = myPage.textFrames.add({geometricBounds:[12, 12, 198, 285], strokeWeight:0, strokeColor:"None"});
                          myTextFrame.previousTextFrame = prevTextFrame;
                      }
                      
                      function setUpStyles()
                      {
                          mcs=myDoc.characterStyles.add({name:"Value", fillColor:"Black", appliedFont:"Minion Pro", fontStyle:"Bold"});
                          mcs2=myDoc.characterStyles.add({name:"Properties", fillColor:"Black", appliedFont:"Minion Pro", fontStyle:"Bold Cond"});
                          mcs3=myDoc.characterStyles.add({name:"Property", fillColor:"Black", appliedFont:"Minion Pro", fontStyle:"Bold Italic", horizontalScale:115});
                          mcs4=myDoc.characterStyles.add({name:"Object", pointSize:6, underline:1});
                          
                          
                          mps=myDoc.paragraphStyles.add({name:"main", pointSize:3.5, fillColor:"C=0 M=100 Y=0 K=0", appliedFont:"Minion Pro", fontStyle:"Medium", justification:Justification.LEFT_ALIGN,
                          paragraphDirection:ParagraphDirectionOptions.LEFT_TO_RIGHT_DIRECTION, digitsType:DigitsTypeOptions.ARABIC_DIGITS})
                      mps.nestedGrepStyles.add({appliedCharacterStyle:mcs4, grepExpression:".+?\\*$"});
                      mps.nestedGrepStyles.add({appliedCharacterStyle:mcs, grepExpression:"(?<=\=).+?\\t"});
                      mps.nestedGrepStyles.add({appliedCharacterStyle:mcs2, grepExpression:"^\\S+"});
                      mps.nestedGrepStyles.add({appliedCharacterStyle:mcs3, grepExpression:"(?<=\s).+? \="});
                          
                      }    
                      app.activeWindow.activePage = app.activeDocument.pages[0];
                      
                      • 8. Re: Search document for SpecialCharacters Enumerator
                        Harbs. Adobe Community Professional & MVP

                        You can use Enum.valueOf() to get the numeric value.

                        • 9. Re: Search document for SpecialCharacters Enumerator
                          Trevorׅ Adobe Community Professional

                          But I don't want the numeric value I want the full enumaration string i.e.

                          DiacriticPositionOptions.OPENTYPE_POSITION as apposed to just OPENTYPE_POSITION

                           

                          Did you run the script?

                          • 10. Re: Search document for SpecialCharacters Enumerator
                            Laubender Adobe Community Professional & MVP

                            Trevorׅ wrote:

                            But I don't want the numeric value I want the full enumaration string i.e.

                            DiacriticPositionOptions.OPENTYPE_POSITION as apposed to just OPENTYPE_POSITION

                             

                             

                            Hi Trevor,
                            I know that this thread is more than four years old, but today Marc Autret linked to it.


                            To answer your question—if it is not answered yet—I think, you should study Dirk Becker's enumToSource.jsx script:

                            enumToSource.jsx script for Adobe InDesign

                             

                            Best,
                            Uwe

                            • 11. Re: Search document for SpecialCharacters Enumerator
                              Trevorׅ Adobe Community Professional

                              Hi Uwe

                               

                              I did get the answer a few years back.

                              I wrote the below myself before seeing Dirks version (not nicked).

                              From what I remember my version has some plus points, I think that Dirk's breaks if the Enum was removed from InDesign and my one doesn't but I really don't remember well.

                               

                              Thanks either way

                               

                              Trevor

                               

                              // script to show most of the selection properties by Trevor
                              // Creative-Scripts.Com (Still not ready!) available (sometimes) for custom scripts $$$
                              // scripts {at} Creative-Scripts [dot] Com
                              $.level = 0; // set debug mode to allow try catch (not read only as stated in manual);
                              var e;
                              $.writeln(getEnum(app.wordRTFImportPreferences.resolveCharacterStyleClash));
                              
                              function getEnum(prop) {
                                  var p, n, c, i;
                                  getEnum.enums = getEnum.enums || {
                                      AcrobatCompatibility: true,
                                      AddPageOptions: true,
                                      AdornmentOverprint: true,
                                      AlignDistributeBounds: true,
                                      AlignOptions: true,
                                      AlignmentStyleOptions: true,
                                      AlternateGlyphForms: true,
                                      AlternatingFillsTypes: true,
                                      AnchorPoint: true,
                                      AnchorPosition: true,
                                      AnchoredRelativeTo: true,
                                      AnimationEaseOptions: true,
                                      AnimationPlayOperations: true,
                                      AntiAliasType: true,
                                      ArrangeBy: true,
                                      ArrowHead: true,
                                      AssetType: true,
                                      AssignmentExportOptions: true,
                                      AssignmentStatus: true,
                                      AutoEnum: true,
                                      AutoSizingReferenceEnum: true,
                                      AutoSizingTypeEnum: true,
                                      BalanceLinesStyle: true,
                                      BaselineFrameGridRelativeOption: true,
                                      BaselineGridRelativeOption: true,
                                      BehaviorEvents: true,
                                      BevelAndEmbossDirection: true,
                                      BevelAndEmbossStyle: true,
                                      BevelAndEmbossTechnique: true,
                                      BindingOptions: true,
                                      BitmapCompression: true,
                                      BlendMode: true,
                                      BlendingSpace: true,
                                      BookContentStatus: true,
                                      BookletTypeOptions: true,
                                      BoundingBoxLimits: true,
                                      BuildingBlockTypes: true,
                                      BulletCharacterType: true,
                                      BulletListExportOption: true,
                                      Capitalization: true,
                                      ChangeBackgroundColorChoices: true,
                                      ChangeCaseOptions: true,
                                      ChangeConditionsModes: true,
                                      ChangeMarkings: true,
                                      ChangeTextColorChoices: true,
                                      ChangeTypes: true,
                                      ChangebarLocations: true,
                                      ChangecaseMode: true,
                                      ChapterNumberSources: true,
                                      CharacterAlignment: true,
                                      CharacterCountLocation: true,
                                      CharacterDirectionOptions: true,
                                      ClippingPathType: true,
                                      ColorModel: true,
                                      ColorOutputModes: true,
                                      ColorRenderingDictionary: true,
                                      ColorSettingsPolicy: true,
                                      ColorSpace: true,
                                      ComposeUsing: true,
                                      CompressionQuality: true,
                                      ConditionIndicatorMethod: true,
                                      ConditionIndicatorMode: true,
                                      ConditionUnderlineIndicatorAppearance: true,
                                      ContainerType: true,
                                      ContentType: true,
                                      ContourOptionsTypes: true,
                                      ConvertPageBreaks: true,
                                      ConvertShapeOptions: true,
                                      ConvertTablesOptions: true,
                                      CoordinateSpaces: true,
                                      CopyrightStatus: true,
                                      CornerOptions: true,
                                      CreateProxy: true,
                                      CrossReferenceType: true,
                                      CursorTypes: true,
                                      CustomLayoutTypeEnum: true,
                                      DataFormat: true,
                                      DefaultRenderingIntent: true,
                                      DesignOptions: true,
                                      DiacriticPositionOptions: true,
                                      DigitsTypeOptions: true,
                                      DimensionsConstraints: true,
                                      DisplayOrderOptions: true,
                                      DisplaySettingOptions: true,
                                      DistributeOptions: true,
                                      DocumentIntentOptions: true,
                                      DocumentPrintUiOptions: true,
                                      DynamicDocumentsJPEGQualityOptions: true,
                                      DynamicDocumentsTextExportPolicy: true,
                                      DynamicMediaHandlingOptions: true,
                                      DynamicTriggerEvents: true,
                                      EPSColorSpace: true,
                                      EPSImageData: true,
                                      EditingState: true,
                                      EmptyFrameFittingOptions: true,
                                      EndCap: true,
                                      EndJoin: true,
                                      EpubCover: true,
                                      EpubVersion: true,
                                      EventPhases: true,
                                      ExportFormat: true,
                                      ExportLayerOptions: true,
                                      ExportOrder: true,
                                      ExportPresetFormat: true,
                                      ExportRangeOrAllPages: true,
                                      FeatherCornerType: true,
                                      FeatherMode: true,
                                      FeatureSetOptions: true,
                                      FindChangeTransliterateCharacterTypes: true,
                                      FirstBaseline: true,
                                      FitDimension: true,
                                      FitMethodSettings: true,
                                      FitOptions: true,
                                      Fitting: true,
                                      FlattenerLevel: true,
                                      Flip: true,
                                      FlipValues: true,
                                      FloatingWindowPosition: true,
                                      FloatingWindowSize: true,
                                      FollowShapeModeOptions: true,
                                      FontDownloading: true,
                                      FontEmbedding: true,
                                      FontStatus: true,
                                      FontTypes: true,
                                      FootnoteFirstBaseline: true,
                                      FootnoteMarkerPositioning: true,
                                      FootnoteNumberingStyle: true,
                                      FootnotePrefixSuffix: true,
                                      FootnoteRestarting: true,
                                      GIFOptionsPalette: true,
                                      GlobalClashResolutionStrategy: true,
                                      GlobalClashResolutionStrategyForMasterPage: true,
                                      GlowTechnique: true,
                                      GoToZoomOptions: true,
                                      GradientType: true,
                                      GridAlignment: true,
                                      GridViewSettings: true,
                                      GuideTypeOptions: true,
                                      HeaderFooterBreakTypes: true,
                                      HeaderTypes: true,
                                      HorizontalAlignment: true,
                                      HorizontalOrVertical: true,
                                      HyperlinkAppearanceHighlight: true,
                                      HyperlinkAppearanceStyle: true,
                                      HyperlinkAppearanceWidth: true,
                                      HyperlinkDestinationPageSetting: true,
                                      ICCProfiles: true,
                                      IconSizes: true,
                                      ImageAlignmentType: true,
                                      ImageConversion: true,
                                      ImageDataTypes: true,
                                      ImageExportOption: true,
                                      ImageFormat: true,
                                      ImagePageBreakType: true,
                                      ImageResolution: true,
                                      ImageSizeOption: true,
                                      ImportFormat: true,
                                      ImportPlatform: true,
                                      ImportedPageCropOptions: true,
                                      InCopyUIColors: true,
                                      IndexCapitalizationOptions: true,
                                      IndexFormat: true,
                                      InkTypes: true,
                                      InnerGlowSource: true,
                                      InteractiveElementsOptions: true,
                                      InteractivePDFInteractiveElementsOptions: true,
                                      JPEGOptionsFormat: true,
                                      JPEGOptionsQuality: true,
                                      JoinOptions: true,
                                      JpegColorSpaceEnum: true,
                                      Justification: true,
                                      KashidasOptions: true,
                                      KentenAlignment: true,
                                      KentenCharacter: true,
                                      KentenCharacterSet: true,
                                      KinsokuHangTypes: true,
                                      KinsokuSet: true,
                                      KinsokuType: true,
                                      LanguageAndRegion: true,
                                      LayoutRuleOptions: true,
                                      Leading: true,
                                      LeadingModel: true,
                                      LibraryPanelViews: true,
                                      LineAlignment: true,
                                      LineSpacingType: true,
                                      LinkStatus: true,
                                      ListAlignment: true,
                                      ListType: true,
                                      LiveDrawingOptions: true,
                                      Locale: true,
                                      LocationOptions: true,
                                      LockStateValues: true,
                                      MapType: true,
                                      MarkLineWeight: true,
                                      MarkTypes: true,
                                      MatrixContent: true,
                                      MeasurementUnits: true,
                                      MojikumiTableDefaults: true,
                                      MonoBitmapCompression: true,
                                      MoviePlayOperations: true,
                                      MoviePosterTypes: true,
                                      NestedStyleDelimiters: true,
                                      NoteBackgrounds: true,
                                      NoteColorChoices: true,
                                      NothingEnum: true,
                                      NumberedListExportOption: true,
                                      NumberedParagraphsOptions: true,
                                      NumberingStyle: true,
                                      OTFFigureStyle: true,
                                      ObjectTypes: true,
                                      OpenOptions: true,
                                      OpenTypeFeature: true,
                                      OutlineJoin: true,
                                      OverrideType: true,
                                      PDFColorSpace: true,
                                      PDFCompressionType: true,
                                      PDFCrop: true,
                                      PDFJPEGQualityOptions: true,
                                      PDFMarkWeight: true,
                                      PDFProfileSelector: true,
                                      PDFRasterCompressionOptions: true,
                                      PDFXStandards: true,
                                      PNGColorSpaceEnum: true,
                                      PNGExportRangeEnum: true,
                                      PNGQualityEnum: true,
                                      PPDValues: true,
                                      PageBindingOptions: true,
                                      PageColorOptions: true,
                                      PageLayoutOptions: true,
                                      PageNumberPosition: true,
                                      PageNumberStyle: true,
                                      PageNumberingOptions: true,
                                      PageOrientation: true,
                                      PagePositions: true,
                                      PageRange: true,
                                      PageReferenceType: true,
                                      PageSideOptions: true,
                                      PageTransitionDirectionOptions: true,
                                      PageTransitionDurationOptions: true,
                                      PageTransitionOverrideOptions: true,
                                      PageTransitionTypeOptions: true,
                                      PageViewOptions: true,
                                      PaginationOption: true,
                                      PanelLayoutResize: true,
                                      PanningTypes: true,
                                      PaperSize: true,
                                      PaperSizes: true,
                                      ParagraphDirectionOptions: true,
                                      ParagraphJustificationOptions: true,
                                      PathType: true,
                                      PathTypeAlignments: true,
                                      PdfMagnificationOptions: true,
                                      PerformanceMetricOptions: true,
                                      PlacedVectorProfilePolicy: true,
                                      PlayOperations: true,
                                      PointType: true,
                                      Position: true,
                                      PositionalForms: true,
                                      PostScriptLevels: true,
                                      PreflightLayerOptions: true,
                                      PreflightProfileOptions: true,
                                      PreflightRuleFlag: true,
                                      PreflightScopeOptions: true,
                                      PreviewPagesOptions: true,
                                      PreviewSizeOptions: true,
                                      PreviewTypes: true,
                                      PrintLayerOptions: true,
                                      PrintPageOrientation: true,
                                      Printer: true,
                                      PrinterPresetTypes: true,
                                      Profile: true,
                                      ProofingType: true,
                                      RangeSortOrder: true,
                                      RasterCompressionOptions: true,
                                      RasterResolutionOptions: true,
                                      RecordSelection: true,
                                      RecordsPerPage: true,
                                      RenderingIntent: true,
                                      RepaginateOption: true,
                                      ResizeConstraints: true,
                                      ResizeMethods: true,
                                      ResolveStyleClash: true,
                                      RestartPolicy: true,
                                      RotationDirection: true,
                                      RowTypes: true,
                                      RubyAlignments: true,
                                      RubyKentenPosition: true,
                                      RubyOverhang: true,
                                      RubyParentSpacing: true,
                                      RubyTypes: true,
                                      RuleDataType: true,
                                      RuleWidth: true,
                                      RulerOrigin: true,
                                      SWFBackgroundOptions: true,
                                      SWFCurveQualityValue: true,
                                      Sampling: true,
                                      SaveOptions: true,
                                      ScaleModes: true,
                                      Screeening: true,
                                      ScreenModeOptions: true,
                                      ScriptLanguage: true,
                                      SearchModes: true,
                                      SearchStrategies: true,
                                      SelectAll: true,
                                      SelectionOptions: true,
                                      Sequences: true,
                                      ShadowMode: true,
                                      SignatureSizeOptions: true,
                                      SingleWordJustification: true,
                                      SmartMatchOptions: true,
                                      SnapshotBlendingModes: true,
                                      SortAssets: true,
                                      SoundPosterTypes: true,
                                      SourceFieldType: true,
                                      SourceSpaces: true,
                                      SourceType: true,
                                      SpanColumnCountOptions: true,
                                      SpanColumnTypeOptions: true,
                                      SpecialCharacters: true,
                                      SpreadFlattenerLevel: true,
                                      StartParagraph: true,
                                      StateTypes: true,
                                      StaticAlignmentOptions: true,
                                      StoryDirectionOptions: true,
                                      StoryHorizontalOrVertical: true,
                                      StoryTypes: true,
                                      StrokeAlignment: true,
                                      StrokeCornerAdjustment: true,
                                      StrokeFillProxyOptions: true,
                                      StrokeFillTargetOptions: true,
                                      StrokeOrderTypes: true,
                                      StyleConflict: true,
                                      StyleSheetExportOption: true,
                                      SyncConflictResolution: true,
                                      TabStopAlignment: true,
                                      TableDirectionOptions: true,
                                      TableFormattingOptions: true,
                                      TagRaster: true,
                                      TagTextExportCharacterSet: true,
                                      TagTextForm: true,
                                      TagTransparency: true,
                                      TagType: true,
                                      TagVector: true,
                                      TaggedPDFStructureOrderOptions: true,
                                      TaskAlertType: true,
                                      TaskState: true,
                                      TextExportCharacterSet: true,
                                      TextFrameContents: true,
                                      TextImportCharacterSet: true,
                                      TextPathEffects: true,
                                      TextStrokeAlign: true,
                                      TextTypeAlignments: true,
                                      TextWrapModes: true,
                                      TextWrapSideOptions: true,
                                      ThumbsPerPage: true,
                                      TilingTypes: true,
                                      ToolTipOptions: true,
                                      ToolsPanelOptions: true,
                                      TrapEndTypes: true,
                                      TrapImagePlacementTypes: true,
                                      Trapping: true,
                                      UIColors: true,
                                      UITools: true,
                                      UndoModes: true,
                                      UpdateLinkOptions: true,
                                      UserInteractionLevels: true,
                                      VariableNumberingStyles: true,
                                      VariableScopes: true,
                                      VariableTypes: true,
                                      VersionCueSyncStatus: true,
                                      VersionState: true,
                                      VerticalAlignment: true,
                                      VerticalJustification: true,
                                      VerticallyRelativeTo: true,
                                      ViewDisplaySettings: true,
                                      ViewZoomStyle: true,
                                      WarichuAlignment: true,
                                      WatermarkHorizontalPositionEnum: true,
                                      WatermarkVerticalPositionEnum: true,
                                      WhenScalingOptions: true,
                                      XFLRasterizeFormatOptions: true,
                                      XMLElementLocation: true,
                                      XMLElementPosition: true,
                                      XMLExportUntaggedTablesFormat: true,
                                      XMLFileEncoding: true,
                                      XMLImportStyles: true,
                                      XMLTransformFile: true,
                                      ZoomOptions: true,
                                  };
                                  getEnum.nnums = getEnum.nnums || {};
                                  if (getEnum.nnums[+prop] !== undefined) return getEnum.nnums[+prop];
                              
                                  for (n in getEnum.enums) {
                                      try {
                                          if ((p = $.global[n]) && p.constructor.name === "Enumeration") {
                                              for (i in p) {
                                                  c = +p[i];
                                                  getEnum.nnums[c] = n + "." + i;
                                              }
                                          }
                                      } catch (e) {}
                                  }
                                  if (getEnum.nnums[+prop] !== undefined) return getEnum.nnums[+prop];
                                  return "Enumerator UNKNOWN";
                              }
                              
                              • 12. Re: Search document for SpecialCharacters Enumerator
                                Marc Autret Level 4

                                Hi Uwe and Trevor,

                                 

                                Thanks a lot!

                                 

                                Dirk's code sounds definitely brilliant to me, as it only relies on parsing the $.dictionary database (meaning that it properly reflects the current DOM in use), and most importantly it fixes Enumerator's prototype in a way that makes toSource() both effective and verbose, including when you invoke toSource() from a parent DOM object properties that may contain enumerators. Also, the code only instantiates NothingEnum in the global scope (in order to wake up the Enumerator constructor—a live object entity) so one can consider it very 'non-polluting' when included in a larger project or framework.

                                 

                                Anyway, I had fun in writing a (slightly) different implementation which (slightly) increases the verbosity. Numbers are now formatted in 0xHEXA form and the Adobe 4-char tag is shown too. Here it is:

                                 

                                // Repair toSource() for enumerations [alternative version]
                                // for InDesign CS5 and later
                                // -------------------------------------
                                // Based on Dirk Becker's 2014 original code at
                                // http://ixta.com/scripts/utilities/enumToSource.html
                                // -------------------------------------
                                // Output either the format
                                // 
                                //     <Enumeration>.<Enumerator> /* <Hexa> [<Tag>] */
                                //     if <Enumeration> is the unique parent for that value,
                                //     e.g: AnchorPosition.INLINE_POSITION /* 414F5069 [AOPi] */
                                //     
                                // or
                                // 
                                //     0x<Hexa> /* <Enumerator> [<Tag>] */
                                //     if Enumerator's value belongs to multiple parents,
                                //     e.g: 0x74787466 /* TEXT_FRAME [txtf] */
                                // -------------------------------------
                                // TIP: You can access the whole 'database' (cache)
                                //      browsing the following object
                                //      NothingEnum.NOTHING.__proto__.toSource.Q
                                // -------------------------------------
                                (function(P)
                                {
                                    P.toSource = function F(){ return F.Q[this] || "({})" };
                                
                                    (function(/*obj&*/Q,  n,i,a,s,x,t,k,v)
                                    {
                                        const DIC = $.dictionary;
                                        const CHR = String.fromCharCode;
                                
                                        const FMT = $.global.localize;
                                        const REGULAR_PATTERN = "%1.%2 /*\xA0%3\xA0[%4]\xA0*/";
                                        const SPECIAL_PATTERN = "0x%3 /*\xA0%2\xA0[%4]\xA0*/";
                                
                                        for( a=DIC.getClasses(), n=a.length, i=-1 ; ++i < n ; )
                                        {
                                            x = DIC.getClass(s=a[i]).toXML();
                                            if( 'true' != x.@enumeration ) continue;
                                            x = x.elements.property;
                                
                                            for each( t in x )
                                            {
                                                k = String(t.@name);
                                                v = Number(t..value);
                                                
                                                Q[k] = FMT(
                                                    Q.hasOwnProperty(k) ? SPECIAL_PATTERN : REGULAR_PATTERN,
                                                    // %1 :: Enumeration class name
                                                    s,
                                                    // %2 :: Enumerator key
                                                    k,
                                                    // %3 :: Hexa representation
                                                    v.toString(16).toUpperCase(),
                                                    // %4 :: Adobe 4-char tag
                                                    CHR(0xFF&(v>>>24),0xFF&(v>>>16),0xFF&(v>>>8),0xFF&(v>>>0))
                                                );
                                            }
                                        }
                                    })( P.toSource.Q={} );
                                
                                })(NothingEnum.NOTHING.__proto__);
                                
                                
                                // Sample test:
                                // ---
                                
                                alert( Locale.frenchLocale.toSource() );
                                // => Locale.FRENCH_LOCALE /* 4C434672 [LCFr] */
                                

                                 

                                 

                                @+

                                Marc

                                2 people found this helpful
                                • 13. Re: Search document for SpecialCharacters Enumerator
                                  Dirk Becker Level 4

                                  Trevor is probably referring to the previous version that touched every enum.

                                  http://www.ixta.com/scripts/utilities/pretty.html

                                   

                                  Regards,

                                  Dirk

                                  2 people found this helpful
                                  • 14. Re: Search document for SpecialCharacters Enumerator
                                    Trevorׅ Adobe Community Professional

                                    Hi all

                                     

                                    Yes, Dirk, spot on, I was referring to the previous version I didn't see your new post until you pointed that out.

                                     

                                    Very nice implementations both yours and Marc's, looks like a real improvement on both our older versions.

                                    I now understand why Marc complimented your version above mine.

                                     

                                    Thanks and well done!

                                     

                                    Trevor

                                    • 15. Re: Search document for SpecialCharacters Enumerator
                                      Dirk Becker Level 4

                                      Here a few notes about Marc's version:

                                       

                                      By using the closure, you probably introduce some memory leaks. The toString() method assigned from within the closure will keep it around forever. My site has another utility based on $.summary that can point out such leaks, at http://ixta.com/scripts/utilities/summaryDifference.html - the leaks should be a workspace object (the closure) plus the outer anonymous function.

                                       

                                      Ages ago I was warned to not use __proto__, it is not equivalent to my .prototype approach. The ExtendScript engine makes some assumptions about that object. Unfortunately I only found an old email from 2006 where I mentioned that info, but not the original quote from Michael Däumling.

                                       

                                      Dirk

                                      • 16. Re: Search document for SpecialCharacters Enumerator
                                        Marc Autret Level 4

                                        Hi Dirk,

                                         

                                        Taking into account your informed opinion, here is an upgrade of my code safe of (workspace) leaks and using the regular constructor.prototype path. According to your great $.summary.difference() utility, its cost is now:

                                         

                                        1 Dictionary

                                        12 Function

                                        1 Math

                                        1 Enumeration

                                        1 Enumerator

                                        3 Object

                                        1 Reflection

                                         

                                        New code:

                                         

                                        // Repair toSource() for enumerations [alternative version]
                                        // for InDesign CS5 and later -- v.2.0
                                        // -------------------------------------
                                        // Based on Dirk Becker's 2014 original code at
                                        // http://ixta.com/scripts/utilities/enumToSource.html
                                        // -------------------------------------
                                        // Output either the format
                                        // 
                                        //     <Enumeration>.<Enumerator> /* <Hexa> [<Tag>] */
                                        //     if <Enumeration> is the unique parent for that value,
                                        //     e.g: AnchorPosition.INLINE_POSITION /* 414F5069 [AOPi] */
                                        //     
                                        // or
                                        // 
                                        //     0x<Hexa> /* <Enumerator> [<Tag>] */
                                        //     if Enumerator's value belongs to multiple parents,
                                        //     e.g: 0x74787466 /* TEXT_FRAME [txtf] */
                                        // -------------------------------------
                                        // TIP: You can access the whole 'database' (cache)
                                        //      browsing the following object
                                        //      NothingEnum.NOTHING.__proto__.toSource.Q
                                        // -------------------------------------
                                        (function(/*obj&*/Q,  n,i,a,s,x,t,k,v)
                                        {
                                            const DIC = $.dictionary;
                                            const CHR = String.fromCharCode;
                                        
                                            const FMT = $.global.localize;
                                            const REGULAR_PATTERN = "%1.%2 /*\xA0%3\xA0[%4]\xA0*/";
                                            const SPECIAL_PATTERN = "0x%3 /*\xA0%2\xA0[%4]\xA0*/";
                                        
                                            for( a=DIC.getClasses(), n=a.length, i=-1 ; ++i < n ; )
                                            {
                                                x = DIC.getClass(s=a[i]).toXML();
                                                if( 'true' != x.@enumeration ) continue;
                                                x = x.elements.property;
                                        
                                                for each( t in x )
                                                {
                                                    k = String(t.@name);
                                                    v = Number(t..value);
                                                    
                                                    Q[k] = FMT(
                                                        Q.hasOwnProperty(k) ? SPECIAL_PATTERN : REGULAR_PATTERN,
                                                        // %1 :: Enumeration class name
                                                        s,
                                                        // %2 :: Enumerator key
                                                        k,
                                                        // %3 :: Hexa representation
                                                        v.toString(16).toUpperCase(),
                                                        // %4 :: Adobe 4-char tag
                                                        CHR(0xFF&(v>>>24),0xFF&(v>>>16),0xFF&(v>>>8),0xFF&(v>>>0))
                                                    );
                                                }
                                            }
                                        })( (NothingEnum.NOTHING.constructor.prototype.toSource=function F(){ return F.Q[this] || "({})" }).Q={} );
                                        

                                         

                                        Best,

                                        Marc

                                        • 17. Re: Search document for SpecialCharacters Enumerator
                                          Trevorׅ Adobe Community Professional

                                          Ok my turn now

                                           

                                          DISCLAIMERS

                                           

                                          I did not test for memory leakages.

                                          I did not really test for anything much at all

                                          No fancy features like returning hex values

                                           

                                          But for a simple answer to my question of how to get the "ColorModel" part of the "ColorModel.PROCESS" enum the below method should work even if multiple enums had the property "PROCESS" to them.

                                           

                                          function getEnum(_enum) {
                                              if (getEnum.dataBase) {
                                                  return getEnum.dataBase[_enum] || "Enumerator Unknown";
                                              }
                                              var dic, _Class, n, l, en;
                                              getEnum.dataBase = {};
                                              dic = $.dictionary.getClasses();
                                              for (_Class in dic) {
                                                  en = dic[_Class];
                                                  if (!$.global[en]) continue;
                                                  reflection = $.global[en].reflect.properties;
                                                  l = reflection.length - 1;
                                                  for (n = 0; n < l; n++) {
                                                      getEnum.dataBase[$.global[en][reflection[n]]] = en + '.' + reflection[n];
                                                  }
                                              }
                                              return getEnum.dataBase[_enum] || "Enumerator Unknown";
                                          }
                                          
                                          /*** USAGE ***/
                                          var doc, rect, m;
                                          doc = app.documents.add();
                                          rect = doc.rectangles.add({ fillColor: doc.colors.itemByName("Cyan") });
                                          m = [
                                              'Using getEnum method',
                                              getEnum(rect.fillColor.space),
                                              getEnum(rect.fillColor.model),
                                              'Not using getEnum method',
                                              rect.fillColor.space,
                                              rect.fillColor.model
                                          ].join('\n');
                                          
                                          alert(m);
                                          /********************************
                                              Alerts
                                              Using getEnum method
                                              JpegColorSpaceEnum.CMYK
                                              ColorModel.PROCESS
                                              Not using getEnum method
                                              CMYK
                                              PROCESS
                                          ********************************/