Hi,

thank you for your detailed answer. I have included your hints into the program 
and now it works. The error occured because I didn't make a 2 dimensional 
array. After changing the array it works.

Here is the code for my Table of content now:

xText = xTextDocument~getText()
xTextCursor = xText~createTextCursor()
xPropertySet = xTextCursor~xPropertySet

  -- some text with Heading 1 style so the text is shown in the TOC
xPropertySet~setPropertyValue("ParaStyleName","Heading 1")  
xText~insertString(xTextCursor,"Headline",.false)
xDMsf = xTextDocument~XMultiServiceFactory

 -- TOC
 contentInd = xDMsf~createInstance("com.sun.star.text.ContentIndex")
 contentProps = contentInd~XPropertySet
 
    m1=5   /* three PropertyValue pairs */
    m2=2   /* two PropertyValues        */
       /* create two-dimensional array of type PropertyValue */
    propsToc = bsf.createArray(.UNO~PropertyValue, m1, m2)
    do i1=1 to m1
       do i2=1 to m2
          propsToc[i1,i2]=.uno~propertyValue~new /* create an assign 
PropertyValue object */

          if i2=2 then  /* set companion PropertyValue to default value */
          do
             propsToc[i1,2]~name="CharacterStyleName"
             propsToc[i1,2]~value=""
          end
       end
    end

      /* now set the property values */
    propsToc[1,1]~name="TokenType"
    propsToc[1,1]~value = "TokenHyperlinkStart"
    propsToc[2,1]~name="TokenType"
    propsToc[2,1]~value = "TokenEntryText"
    propsToc[3,1]~name="TokenType"
    propsToc[3,1]~value = "TokenHyperlinkEnd"
    propsToc[4,1]~name="TokenType"
    propsToc[4,1]~value = "TokenTabStop"   
    propsToc[4,2]~name = "TabStopRightAligned"  
    propsToc[4,2]~value = box("boolean", .true)
    propsToc[5,1]~name="TokenType"
    propsToc[5,1]~value = "TokenPageNumber"

  
   contentProps~setPropertyValue("CreateFromOutline",box("boolean", .true))
   contentProps~setPropertyValue("Level",box("short", 2))
   contentProps~setPropertyValue("Title","Table of Content")
   contentProps~setPropertyValue("IsProtected",box("boolean", .false))
   LevelFormat = contentProps~getPropertyValue("LevelFormat")
   
   LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(1, propsToc)  
   -- TEXT CONTENT auf TOC setzen und formatieren
   contentTextContent = contentInd~xTextContent()
   contentIndProps = contentTextContent~XPropertySet
   contentIndProps~setPropertyValue("Level",box("short", 2))
   
   -- TOC setzen  
   xText~insertTextContent(xText, contentTextContent, .false )
   -- TOC UPDATEN 
   contentTextContent~XDocumentIndex~update()

Thanks.
Regards
Nicole


-------- Original-Nachricht --------
> Datum: Thu, 17 Jul 2008 16:21:10 +0200
> Von: "Rony G. Flatscher" <[EMAIL PROTECTED]>
> An: [email protected]
> Betreff: Re: [api-dev] Table of Content Hyperlink problem

> Hi,
> 
> not having heard of you yet, but having been able to research a little 
> bit (sitting in meetings since 8:30 in the morning), here is what I did 
> and found out, as it may be of interest of "lurkers" who are interested 
> how one could approach the problem using the ooRexx-support for UNO/OOo.
> 
> >> I changed the replacement statement to:          
> >> LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(1, propsToc) 
> >> but unfortunately I get this error:
> >> method [REPLACEBYINDEX], method not found or error (exception) 
> >> executing method!
> >>
> >> Perhaps I have forgotten to link this statement to an interface, 
> >> service or something?
> This indicates that an argument is in error (missing, wrong type, etc.). 
> So the next step was to find out of what type the argument should be.
> 
> 
> >>>>  -- TOC
> >>>>    contentInd =
> xDMsf~createInstance("com.sun.star.text.ContentIndex")
> Adding the statements:say "contentInd~uno.getDefinition:"
> 
>     say "contentInd~uno.getDefinition:"
>     say ppd(contentInd~uno.getDefinition)
>     say "---"
> 
> yielded the following output:
> 
>     contentInd~uno.getDefinition:
>    
> UNO_SERVICE|com.sun.star.text.BaseIndex+com.sun.star.text.ContentIndex|SwXDocumentIndex
>            
> com.sun.star.text.XDocumentIndex|UNO_INTERFACE||com.sun.star.text.BaseIndex
>            
> Title|UNO_PROPERTY||java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> IsProtected|UNO_PROPERTY||java.lang.Boolean:UNO_BOOLEAN::|com.sun.star.text.BaseIndex
>            
> ParaStyleHeading|UNO_PROPERTY||java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel1|UNO_PROPERTY||java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel2|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel3|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel4|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel5|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel6|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel7|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel8|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel9|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleLevel10|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> ParaStyleSeparator|UNO_PROPERTY|OPTIONAL|java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> TextColumns|UNO_PROPERTY||com.sun.star.text.XTextColumns:UNO_INTERFACE::|com.sun.star.text.BaseIndex
>            
> BackGraphicURL|UNO_PROPERTY||java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> BackGraphicFilter|UNO_PROPERTY||java.lang.String:UNO_STRING::|com.sun.star.text.BaseIndex
>            
> BackGraphicLocation|UNO_PROPERTY||com.sun.star.style.GraphicLocation:UNO_ENUM::|com.sun.star.text.BaseIndex
>            
> BackColor|UNO_PROPERTY||com.sun.star.util.Color:UNO_TYPEDEF:int:UNO_LONG|com.sun.star.text.BaseIndex
>            
> BackTransparent|UNO_PROPERTY||java.lang.Boolean:UNO_BOOLEAN::|com.sun.star.text.BaseIndex
>            
> *LevelFormat*|*UNO_PROPERTY*|OPTIONAL|com.sun.star.container.XIndexReplace:UNO_INTERFACE::|*com.sun.star.text.BaseIndex*
>            
> CreateFromChapter|UNO_PROPERTY|OPTIONAL|java.lang.Boolean:UNO_BOOLEAN::|com.sun.star.text.BaseIndex
>            
> ContentSection|UNO_PROPERTY||com.sun.star.text.XTextSection:UNO_INTERFACE::|com.sun.star.text.BaseIndex
>            
> HeaderSection|UNO_PROPERTY||com.sun.star.text.XTextSection:UNO_INTERFACE::|com.sun.star.text.BaseIndex
>            
> com.sun.star.text.BaseIndex|UNO_SERVICE||com.sun.star.text.ContentIndex
>            
> Level|UNO_PROPERTY|OPTIONAL|java.lang.Short:UNO_SHORT::|com.sun.star.text.ContentIndex
>            
> CreateFromOutline|UNO_PROPERTY|OPTIONAL|java.lang.Boolean:UNO_BOOLEAN::|com.sun.star.text.ContentIndex
>            
> LevelParagraphStyles|UNO_PROPERTY|OPTIONAL|com.sun.star.container.XIndexReplace:UNO_INTERFACE::|com.sun.star.text.ContentIndex
>            
> CreateFromMarks|UNO_PROPERTY|OPTIONAL|java.lang.Boolean:UNO_BOOLEAN::|com.sun.star.text.ContentIndex
>     ---
>       
> 
> The property "LevelFormat" is defined in the service 
> "com.sun.star.text.BaseIndex". The online documentation is located at 
> <http://api.openoffice.org/docs/common/ref/com/sun/star/text/BaseIndex.html>,
> but misses to document the "LevelFormat" property!
> :(
> 
> So the next approach is to get at the definition of the LevelFormat 
> attribute (see below).
> 
> 
> >>>>    contentProps = contentInd~XPropertySet
> >>>>
> >>>>   propsToc = bsf.createArray(.UNO~PropertyValue, 1)
> >>>>   propsToc[1] = .UNO~PropertyValue~new
> >>>>   propsToc[1]~name="TokenType"
> >>>>   propsToc[1]~value = "TokenHyperlinkStart"
> >>>>   propsToc[1]~name="TokenType"
> >>>>   propsToc[1]~value = "TokenText"
> >>>>   propsToc[1]~name="TokenType"
> >>>>   propsToc[1]~value = "TokenHyperlinkEnd"
> >>>>
> >>>>   
> >>>> contentProps~setPropertyValue("CreateFromOutline",box("boolean",   
> >>>> .true)) 
> >>>>   contentProps~setPropertyValue("Level",box("short", 2))
> >>>>   contentProps~setPropertyValue("Title","Table of Content")
> >>>>   contentProps~setPropertyValue("IsProtected",box("boolean", .false))
> >>>>
> >>>> Then I have to get the LevelFormat and replace it with my properties.
> >>>>       
> >>> But here I get the error that the method replaceByIndex does not 
> >>> exist or
> >>> there is an exception.
> >>>    
> >>>>   LevelFormat = contentProps~getPropertyValue("LevelFormat")
> Having access to the LevelFormat property, adding the statements:
> 
>     say "levelFormat~uno.getDefinition:"
>     say ppd(levelFormat~uno.getDefinition)
>     say "---"
>       
> 
> yielded the following output:
> 
>     levelFormat~uno.getDefinition:
>    
> UNO_SERVICE|com.sun.star.text.DocumentIndexLevelFormat|SwXIndexTokenAccess_Impl
>            
> *com.sun.star.container.XIndexReplace*|UNO_INTERFACE||*com.sun.star.text.DocumentIndexLevelFormat*
>     ---
>       
> 
> This reveals that the property gets defined by the 
> "com.sun.star.text.DocumentIndexLevelFormat" service. Looking up the 
> documentation 
> <http://api.openoffice.org/docs/common/ref/com/sun/star/text/DocumentIndexLevelFormat.html>
> reveals an incomplete description.
> 
> Learning that it is a sequence of PropertyValues, but still assigning a 
> sequence (array) of PropertyValues, the next step was to analyze the 
> individual entries, just to learn, that each entry in that array is a 
> two dimensional array of PropertyValues !
> 
> 
> >>>>   LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(box("long", 
> >>>> 1), propsToc)   
> This yields an invalid argument error, as the value should be a sequence 
> of a sequence of PropertyValue (a two-dimensional array of type 
> PropertyValue), whereas you are creating and supplying a one-dimensional 
> array of PropertyValue.
>  
> >>>> Can someone give me a hint where I have the mistake?  
> >>> The replacement statement (the very last statement) should probably 
> >>> read:
> >>>
> >>>       LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(1, 
> >>> propsToc)      
> >>> [Boxing of arguments is only needed in the case of property values, 
> >>> if you need to use a primitive type (boolean, byte, char, short, 
> >>> int, long, float, double).]
> In the next step I listed all current settings of this two-dimensional 
> array and learned that in the second dimension there was a single entry 
> "CharacterStyleName" (except for the TokenType property named 
> "TokenTabStop" which has instead a property named 
> "TabStopRightAligned"), which was initially set to an empty string.
> 
> Here the statements for setting up the two-dimensional array of type 
> PropertyValue.
> 
>       m1=3   /* three PropertyValue pairs */
>       m2=2   /* two PropertyValues        */
>          /* create two-dimensional array of type PropertyValue */
>       propsToc = bsf.createArray(.UNO~PropertyValue, m1, m2)
>       do i1=1 to m1
>          do i2=1 to m2
>             propsToc[i1,i2]=.uno~propertyValue~new /* create an assign
> PropertyValue object */
> 
>             if i2=2 then  /* set companion PropertyValue to default value
> */
>             do
>                propsToc[i1,2]~name="CharacterStyleName"
>                propsToc[i1,2]~value=""
>             end
>          end
>       end
> 
>         /* now set the property values */
>       propsToc[1,1]~name="TokenType"
>       propsToc[1,1]~value = "TokenHyperlinkStart"
>       propsToc[2,1]~name="TokenType"
>       propsToc[2,1]~value = "TokenText"
>       propsToc[3,1]~name="TokenType"
>       propsToc[3,1]~value = "TokenHyperlinkEnd"
>       
> 
> HTH,
> 
> ---rony
> 

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to