1 Reply Latest reply on Oct 7, 2015 11:33 AM by Liphou

    [JS] Toc to crossReferenceFormats

    Liphou Level 1

      Hello,
      I want to retrieve the "separator" in the definition of TDM to use it in the creation of the cross-reference style.
      laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK,cus tomText:leStyle.separator,appliedCharacterStyle: app.activeDocument.characterStyles.item (leStyle.separatorStyle.name)});
      BUT I must edited defining the separator to comprise (ex: Tab).
      code runs in realization:

      ------------------------------

      Bonjour,

       

      Je veux récupère le "separateur" dans la définition de TDM pour m'en servir à la cration du style de reference croisés.

       

      laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK,cus tomText:leStyle.separator,appliedCharacterStyle: app.activeDocument.characterStyles.item (leStyle.separatorStyle.name)});

       

      MAIS je doit édité la définition pour qu'il comprenne le separateur (ex: la tabulation).

       

      code en coure de réalisation:

       

      function purCreationRefFormat (leDoc,leName,leStyle) {
             var laRefFmt = null;
            laRefFmt = leDoc.crossReferenceFormats.item(leName);
      
              if (laRefFmt != null) { // if 01
              
                      $.writeln ( 'Lestyle existe déjà : ' + leName + ' (je test ???)');
                      
                      return (false);
              
                  } else {
                      laRefFmt = leDoc.crossReferenceFormats.add({name:leName});
                      if (leStyle.parent.numberedParagraphs == NumberedParagraphsOptions.INCLUDE_FULL_PARAGRAPH) { // if 02
                          if (leStyle.pageNumberPosition == PageNumberPosition.AFTER_ENTRY) { // if 03
                              // num aprés
                              $.writeln ( 'num aprés');
                                         laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.FULL_PARAGRAPH_BUILDING_BLOCK});
                                         laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK,
                                                                                      customText:leStyle.separator, 
                                                                                      appliedCharacterStyle: app.activeDocument.characterStyles.item (leStyle.separatorStyle.name)});
                                         laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.PAGE_NUMBER_BUILDING_BLOCK, appliedCharacterStyle: app.activeDocument.characterStyles.item (leStyle.pageNumberStyle.name)});
                           } else if (leStyle.pageNumberPosition == PageNumberPosition.BEFORE_ENTRY) {
                               // num avant
                              $.writeln ('num avant')
                                      laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.PAGE_NUMBER_BUILDING_BLOCK, appliedCharacterStyle: app.activeDocument.characterStyles.item (leStyle.pageNumberStyle.name)});
                                      laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.CUSTOM_STRING_BUILDING_BLOCK,
                                                                                          customText:leStyle.separator,
                                                                                          appliedCharacterStyle: app.activeDocument.characterStyles.item (leStyle.separatorStyle.name)});
                                      laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.FULL_PARAGRAPH_BUILDING_BLOCK});
                           } else if (leStyle.pageNumberPosition == PageNumberPosition.NONE) {
                               //  seule le texte
                                 $.writeln ('seule le texte')
                                         laRefFmt.buildingBlocks.add({blockType:BuildingBlockTypes.FULL_PARAGRAPH_BUILDING_BLOCK});
      
                           } // fin uf 03
                  } // fin du IF 02
              return (laRefFmt);
          } // fin du IF 01
      //  
       }//