Hi!

Thank you for your answer. I tried to update the toc but this does not solve 
the problem. I add my code to this mail perhaps I do something else wrong.

***********************************************************+
call bsf.import "com.sun.star.text.ControlCharacter", "ctlChar"
call bsf.import "com.sun.star.style.NumberingType", "numTypes"
say "ROMAN_UPPER="pp(.numTypes~roman_upper)
say "---"

/* Retrieve the Desktop object, we need its XComponentLoader interface to load 
a new document*/
oDesktop         = UNO.createDesktop()    -- get the UNO Desktop service object
xComponentLoader = oDesktop~XDesktop~XComponentLoader  -- get componentLoader 
interface
/* open the blank file */
url = "private:factory/swriter"
xWriterComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, 
.UNO~noProps)

xDMsf = xWriterComponent~XMultiServiceFactory
xTextDocument = xWriterComponent~XTextDocument
xText = xTextDocument~getText()
xTextCursor = xText~createTextCursor()
xPropertySet = xTextCursor~xPropertySet

short3=box("short", 3)     -- Java Short object representing the value "3"

  -- TOC
contentInd = xDMsf~createInstance("com.sun.star.text.ContentIndex")
contentProps = contentInd~XPropertySet

xFamiliesSupplier = xTextDocument~XStyleFamiliesSupplier
xParaStyleFamily = 
xFamiliesSupplier~getStyleFamilies~getByName("ParagraphStyles")~XNameContainer

  -- change the paragraph style
call ParaStyle "ParaStyleHeading", contentProps,xParaStyleFamily, 14, "Verdana"
call ParaStyle "ParaStyleLevel1", contentProps,xParaStyleFamily, 12, "Verdana"
call ParaStyle "ParaStyleLevel2", contentProps,xParaStyleFamily, 10 , "Verdana"
call ParaStyle "ParaStyleLevel3", contentProps,xParaStyleFamily, 8 , "Verdana"

contentProps~setPropertyValue("CreateFromOutline", box("Boolean", .true))
contentProps~setPropertyValue("IsProtected",       box("Boolean", .false))
contentProps~setPropertyValue("Level",             short3)
contentProps~setPropertyValue("Title",             "Table Of Content")

contentTextContent = contentInd~xTextContent()
contentIndProps    = contentTextContent~XPropertySet

  /* create two-dimensional array of type PropertyValue */
propsToc = bsf.createArray(.UNO~PropertyValue, 5, 3)

  /* now set the property values */
propsToc[1,1]=uno.createProperty("TokenType",           "TokenHyperlinkStart")
propsToc[1,2]=uno.createProperty("CharacterStyleName",  "")

propsToc[2,1]=uno.createProperty("TokenType",           "TokenEntryText")
propsToc[2,2]=uno.createProperty("CharacterStyleName",  "")

propsToc[3,1]=uno.createProperty("TokenType",           "TokenHyperlinkEnd")
propsToc[3,2]=uno.createProperty("CharacterStyleName",  "")

propsToc[4,1]=uno.createProperty("TokenType",           "TokenTabStop")
propsToc[4,2]=uno.createProperty("TabStopRightAligned", box("Boolean", .true))
propsToc[4,3]=uno.createProperty("TabStopFillCharacter",".")

propsToc[5,1]=uno.createProperty("TokenType",           "TokenPageNumber")
propsToc[5,2]=uno.createProperty("CharacterStyleName",  "")

  -- set the level of the Toc
contentIndProps~setPropertyValue("Level",               short3)
  -- set the format with the above specified properties of the 3 levels
LevelFormat = contentProps~getPropertyValue("LevelFormat")
LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(1, propsToc)
LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(2, propsToc)
LevelFormat~xIndexAccess~xIndexReplace~replaceByIndex(3, propsToc)

  -- insert TOC
xText~insertTextContent(xText, contentTextContent, .false )

xChapterNumberingSupplier = xTextDocument~XChapterNumberingSupplier
xChapterNumberingRules = xChapterNumberingSupplier~getChapterNumberingRules()

--  we need to use a Java array of type PropertyValue for three property values
aChapterNumberingArray=bsf.createArray(.uno~propertyValue,3)

aChapterNumberingArray[1]=uno.createProperty("HeadingStyleName", "Heading 1")
numberingType=.numTypes~roman_upper
aChapterNumberingArray[2]=uno.createProperty("NumberingType",    
box("short",numberingType))
aChapterNumberingArray[3]=uno.createProperty("Suffix",           ". ")
xChapterNumberingRules~xIndexAccess~xIndexReplace~replaceByIndex(0,aChapterNumberingArray)

aChapterNumberingArray[1]=uno.createProperty("HeadingStyleName", "Heading 2")
numberingType=.numTypes~roman_upper
aChapterNumberingArray[2]=uno.createProperty("NumberingType",    
box("short",numberingType))
aChapterNumberingArray[3]=uno.createProperty("Suffix",           ". ")

xChapterNumberingRules~xIndexAccess~xIndexReplace~replaceByIndex(1,aChapterNumberingArray)

aChapterNumberingArray[1]=uno.createProperty("HeadingStyleName", "Heading 3")
numberingType=.numTypes~roman_upper
aChapterNumberingArray[2]=uno.createProperty("NumberingType",    
box("short",numberingType))
aChapterNumberingArray[3]=uno.createProperty("Suffix",           ". ")
xChapterNumberingRules~xIndexAccess~xIndexReplace~replaceByIndex(2,aChapterNumberingArray)


  -- insert headlines
xText~insertControlCharacter(xText~getEnd, .CtlChar~paragraph_break, .false)

xPropertySet~setPropertyValue("ParaStyleName","Heading 1")
xPropertySet~setPropertyValue("ParaBackColor", box("int", "CECEF6"x ~c2d))
xText~insertString(xText~getEnd, "Headline1",.true)
xText~insertControlCharacter(xText~getEnd, .CtlChar~paragraph_break, .false)
xPropertySet~setPropertyValue("ParaStyleName","Heading 2")
xText~insertString(xText~getEnd, "Headline2",.true)
xText~insertControlCharacter(xText~getEnd, .CtlChar~paragraph_break, .false)
xPropertySet~setPropertyValue("ParaStyleName","Heading 3")
xText~insertString(xText~getEnd, "Headline3",.true)


  -- update table of content
contentTextContent~XDocumentIndex~update()

::requires UNO.cls

  -- routine for setting the paragraph style
::routine ParaStyle
  use arg HeadingStyle, contentProps, xParaStyleFamily, paraCharHeight, font
   sParaStyleHeading = contentProps~getPropertyValue(HeadingStyle)
   xHeadingStyleProps = 
xParaStyleFamily~getByName(sParaStyleHeading)~xPropertySet
   xHeadingStyleProps~setPropertyValue("CharFontName", font)
   xHeadingStyleProps~setPropertyValue("CharHeight", box("integer", 
paraCharHeight))

::routine makeArray4numbering
  use strict arg list

  nr=list~items                     -- get number of list objects
  if nr=0 then return .uno~noProps  -- empty ooRexx list, return an empty Java 
array

  jarray=bsf.createArray(.uno~PropertyValue,nr,2) -- create Java array object 
of needed size
  i=0
  do prop over list
     i=i+1
     do k=1 to 2
        jarray[i,k]=prop[1,k]
     end
  end
  return jarray
***********************************************************************

Regards 
Nicole


-------- Original-Nachricht --------
> Datum: Sun, 21 Sep 2008 02:44:08 -0300
> Von: Ariel Constenla-Haile <[EMAIL PROTECTED]>
> An: dev@api.openoffice.org
> Betreff: Re: [api-dev] automatic chapter numbering

> Hi Nicole,
> 
> Nicole Scholz escribió:
> > Hi!
> > 
> > Thank you for the example. It helped me a lot to implement the chapter
> numbering. Unfortunately the chapter numbering is not shown in the table of
> contents. Do I have to set a property or something that it is shown?
> 
> I suppose you followed the example where the needed property is set to
> true:
> 
> xContentIndexProps.setPropertyValue("CreateFromOutline", Boolean.TRUE);
> 
> 
> If so, the only reason I can think is that you are creating *first* the 
> index, and *then* changing the outline numbering.
> If that's the case, you'll need to update the index in order to show the 
> chapter numbering.
> 
> The base service for indexes, css.text.BaseIndex, implements
> css.text.XDocumentIndex, which has a method update() that will update
> the document index
> [http://api.openoffice.org/docs/common/ref/com/sun/star/text/XDocumentIndex.html#update]
> 
> Look in the example, it already uses this interface, and sure you also 
> used it right after inserting the index.
> 
> Hope this solves the problem; if not, then let me know.
> 
> Regards
> Ariel.
> 
> -- 
> Ariel Constenla-Haile
> La Plata, Argentina
> 
> [EMAIL PROTECTED]
> http://www.ArielConstenlaHaile.com.ar/ooo/
> 
> 
> 
> "Aus der Kriegsschule des Lebens
>               - Was mich nicht umbringt,
>       macht mich härter."
>               Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!
Jetzt dabei sein: http://www.shortview.de/[EMAIL PROTECTED]

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

Reply via email to