whichopk.blogg.se

Python libreoffice writer
Python libreoffice writer




setPropertyValue ( "BackColor", 13421823 ) setPropertyValue ( "BackTransparent", uno. createInstance ( ".TextTable" ) # with 4 rows and 4 columns insertString ( cursor, "Now we are in the second line \n", 0 ) # create a text table insertString ( cursor, "The first line in the newly created text document. loadComponentFromURL ( "private:factory/swriter", "_blank", 0, ( ) ) createInstanceWithContext ( ".Desktop" ,ctx ) # open a writer documentĭoc = desktop. """creates a new writer document and inserts a table with some data (also known as the SWriter sample)"""ĭesktop = smgr. TextContentAnchorType import AS_CHARACTERĭef insertTextIntoCell ( table, cellName, text, color ): ControlCharacter import PARAGRAPH_BREAKįrom com. # a UNO struct later needed to create a document from com. The document and content is under the createTable(), while insertTextIntoCell() will handle the positioning within the table. The first step is to get the functions for generating the document, and the other for manipulating the content. Since we using the UNO module we have to import what we need straight from the path. We also use nested modules from Text, AWT, and LANG. On this script we abandon the XSCRIPTCONTEXT and use the UNO module. G_exportedScripts = capitalisePython, TableSample.py Can be omitted, if # all functions shall be visible, however here getNewString shall be suppressed select (xTextRange ) # lists the scripts, that shall be visible inside OOo. NewString = getNewString ( theString ) if newString: NewString = getNewString (theString ) if newString : createTextCursorByRange (xTextRange ) if not xWordCursor. # sadly we can have a selection where nothing is selected # in this case we get the XWordCursor and make a selection! getByIndex (i ) #print "string: " + xTextRange.getString() getCurrentController ( ) #see section 7.5.1 of developers' guide getDocument ( ) #the writer controller impl supports the interface """Change the case of a selection, or current word from uppercase, to first char uppercase, to all lowercase to uppercase.""" # The context variable is of type XScriptContext and is available to # all BeanShell scripts executed by the Script Framework upper ( ) return newString def capitalisePython ( ): # first two chars are UC => first UC, rest LC isupper ( ) and len (theString ) >= 2 and theString. Return "" # should we tokenize on "."? if theString.

python libreoffice writer

If not theString or len (theString ) = 0 :

python libreoffice writer

# helper function def getNewString ( theString ) :






Python libreoffice writer