2 Replies Latest reply on Aug 9, 2011 1:25 AM by Pierre-RAFFA

    set TextFrame.properties when its contents has wordwrap

    Pierre-RAFFA Level 1

      Hi,

      I set PageItem.properties with a HostObject using eval(str) in jsx.

       

      That works properly except if PageItem is TextFrame.

      The crash message is "Error: Unterminated string constant".

       

      I did differents tests to be more precise in the problem and this bug comes when TextFrame has a contents property, containing a word wrap.

       

      Just for info the string passed to eval() is:

       

      ({transparencySettings:resolve("/document[@id=1]//text-frame[@id=376]/@transparency-settin gs"), strokeTransparencySettings:resolve("/document[@id=1]//text-frame[@id=376]/@stroke-transpa rency-settings"), fillTransparencySettings:resolve("/document[@id=1]//text-frame[@id=376]/@fill-transparenc y-settings"), contentTransparencySettings:resolve("/document[@id=1]//text-frame[@id=376]/@content-trans parency-settings"), textFramePreferences:resolve("/document[@id=1]//text-frame[@id=376]/@text-frame-preferenc es"), baselineFrameGridOptions:resolve("/document[@id=1]//text-frame[@id=376]/@baseline-frame-g rid-options"), anchoredObjectSettings:resolve("/document[@id=1]//text-frame[@id=376]/@anchored-object-se ttings"), geometricBounds:[190.00000000001, 518.000000000013, 549.000000000022, 746.000000000013], visibleBounds:[190.00000000001, 518.000000000013, 549.000000000022, 746.000000000013], parentStory:resolve("/document[@id=1]//story[@id=358]"), startTextFrame:resolve("/document[@id=1]//text-frame[@id=376]"), endTextFrame:resolve("/document[@id=1]//text-frame[@id=376]"), textFrameIndex:0, overflows:false, previousTextFrame:null, nextTextFrame:null, contents:"a
      ", textWrapPreferences:resolve("/document[@id=1]//text-frame[@id=376]/@text-wrap-preferences "), contentType:({}), gridData:resolve("/document[@id=1]//text-frame[@id=376]/@grid-data"), associatedXMLElement:null, overridden:false, overriddenMasterPageItem:null, fillColor:resolve("/document[@id=1]//swatch[@id=14]"), fillTint:-1, strokeWeight:0, miterLimit:4, endCap:({}), endJoin:({}), strokeType:resolve("/document[@id=1]/stroke-style[@id=23081]"), leftLineEnd:({}), rightLineEnd:({}), strokeColor:resolve("/document[@id=1]//swatch[@id=14]"), strokeTint:-1, gradientFillStart:[518.000000000013, 549.000000000022], gradientFillLength:228, gradientFillAngle:0, gradientStrokeStart:[518.000000000013, 549.000000000022], gradientStrokeLength:228, gradientStrokeAngle:0, gapColor:resolve("/document[@id=1]//swatch[@id=14]"), gapTint:-1, strokeAlignment:({}), nonprinting:false, itemLayer:resolve("/document[@id=1]//layer[@id=182]"), locked:false, localDisplaySetting:({}), allPageItems:[], allGraphics:[], rotationAngle:0, shearAngle:0, horizontalScale:100, verticalScale:100, absoluteRotationAngle:0, absoluteShearAngle:0, absoluteHorizontalScale:100, absoluteVerticalScale:100, appliedObjectStyle:resolve("/document[@id=1]//object-style[@id=134]"), flip:({}), absoluteFlip:({}), parentPage:resolve("/document[@id=1]//page[@id=190]"), visible:true, name:"", topLeftCornerOption:({}), topRightCornerOption:({}), bottomLeftCornerOption:({}), bottomRightCornerOption:({}), topLeftCornerRadius:12, topRightCornerRadius:12, bottomLeftCornerRadius:12, bottomRightCornerRadius:12, animationSettings:resolve("/document[@id=1]//text-frame[@id=376]/@animation-settings"), timingSettings:resolve("/document[@id=1]//text-frame[@id=376]/@timing-settings"), id:376, label:"", parent:resolve("/document[@id=1]//spread[@id=185]"), index:0})

       

      and you can  see:

      contents:"a

      ",

       

       

      Is there any issue ?

      Thanks.

       

      Pierre RAFFA

      Aquafadas.

        • 1. Re: set TextFrame.properties when its contents has wordwrap
          [Jongware] Most Valuable Participant

          Where did you ever learn to set properties that way?

           

          The error seems to be where you already think it appears: regardless of how you are (force) feeding this to your document, you still need to adhere to common Javascript string notation. That is, don't insert literal hard returns in your strings but use '\r'.

          • 2. Re: set TextFrame.properties when its contents has wordwrap
            Pierre-RAFFA Level 1

            I'am not the author of this string .... it has been created by javascript with PageItem.properties.toSource().

            I thought to replace returns by \r ..Thanks to confirm this method

             

            Where did you ever learn to set properties that way?

            I set PageItem.properties that way because i have to change pageItem state ( geometric...etc ), so i store states of PageItem by saving PageItem.properties.toSource() with PageItem.insertLabel("state1" , PageItem.properties.toSource() )

            And i can switch PageItem states easyly.

            Have you got a better method to switch states without using Object States panel ?