TableSample.py (28e51104) | TableSample.py (d47d317b) |
---|---|
1# ************************************************************* | 1# ************************************************************* |
2# | 2# |
3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at | 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at |
10# | 10# |
11# http://www.apache.org/licenses/LICENSE-2.0 | 11# http://www.apache.org/licenses/LICENSE-2.0 |
12# | 12# |
13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. | 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. |
19# | 19# |
20# ************************************************************* 21 22import uno 23 24# a UNO struct later needed to create a document 25from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK 26from com.sun.star.text.TextContentAnchorType import AS_CHARACTER 27from com.sun.star.awt import Size --- 14 unchanged lines hidden (view full) --- 42 desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx) 43 44 # open a writer document 45 doc = desktop.loadComponentFromURL( "private:factory/swriter","_blank", 0, () ) 46 47 text = doc.Text 48 cursor = text.createTextCursor() 49 text.insertString( cursor, "The first line in the newly created text document.\n", 0 ) | 20# ************************************************************* 21 22import uno 23 24# a UNO struct later needed to create a document 25from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK 26from com.sun.star.text.TextContentAnchorType import AS_CHARACTER 27from com.sun.star.awt import Size --- 14 unchanged lines hidden (view full) --- 42 desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx) 43 44 # open a writer document 45 doc = desktop.loadComponentFromURL( "private:factory/swriter","_blank", 0, () ) 46 47 text = doc.Text 48 cursor = text.createTextCursor() 49 text.insertString( cursor, "The first line in the newly created text document.\n", 0 ) |
50 text.insertString( cursor, "Now we are in the second line\n" , 0 ) | 50 text.insertString( cursor, "Now we are in the second line.\n" , 0 ) |
51 52 # create a text table 53 table = doc.createInstance( "com.sun.star.text.TextTable" ) 54 55 # with 4 rows and 4 columns 56 table.initialize( 4,4) 57 58 text.insertTextContent( cursor, table, 0 ) --- 30 unchanged lines hidden (view full) --- 89 table.getCellByName("C4").setValue(415.7) 90 table.getCellByName("D4").setFormula("sum <A4:C4>") 91 92 93 cursor.setPropertyValue( "CharColor", 255 ) 94 cursor.setPropertyValue( "CharShadowed", uno.Bool(1) ) 95 96 text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 ) | 51 52 # create a text table 53 table = doc.createInstance( "com.sun.star.text.TextTable" ) 54 55 # with 4 rows and 4 columns 56 table.initialize( 4,4) 57 58 text.insertTextContent( cursor, table, 0 ) --- 30 unchanged lines hidden (view full) --- 89 table.getCellByName("C4").setValue(415.7) 90 table.getCellByName("D4").setFormula("sum <A4:C4>") 91 92 93 cursor.setPropertyValue( "CharColor", 255 ) 94 cursor.setPropertyValue( "CharShadowed", uno.Bool(1) ) 95 96 text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 ) |
97 text.insertString( cursor, " This is a colored Text - blue with shadow\n" , 0 ) | 97 text.insertString( cursor, " This is a colored text - blue with shadow\n" , 0 ) |
98 text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 ) 99 100 textFrame = doc.createInstance( "com.sun.star.text.TextFrame" ) 101 textFrame.setSize( Size(15000,400)) 102 textFrame.setPropertyValue( "AnchorType" , AS_CHARACTER ) 103 104 text.insertTextContent( cursor, textFrame, 0 ) 105 106 textInTextFrame = textFrame.getText() 107 cursorInTextFrame = textInTextFrame.createTextCursor() 108 textInTextFrame.insertString( cursorInTextFrame, "The first line in the newly created text frame.", 0 ) | 98 text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 ) 99 100 textFrame = doc.createInstance( "com.sun.star.text.TextFrame" ) 101 textFrame.setSize( Size(15000,400)) 102 textFrame.setPropertyValue( "AnchorType" , AS_CHARACTER ) 103 104 text.insertTextContent( cursor, textFrame, 0 ) 105 106 textInTextFrame = textFrame.getText() 107 cursorInTextFrame = textInTextFrame.createTextCursor() 108 textInTextFrame.insertString( cursorInTextFrame, "The first line in the newly created text frame.", 0 ) |
109 textInTextFrame.insertString( cursorInTextFrame, "\nWith this second line the height of the rame raises.",0) | 109 textInTextFrame.insertString( cursorInTextFrame, "\nWith this second line the height of the frame raises.",0) |
110 text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 ) 111 112 cursor.setPropertyValue( "CharColor", 65536 ) 113 cursor.setPropertyValue( "CharShadowed", uno.Bool(0) ) 114 | 110 text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 ) 111 112 cursor.setPropertyValue( "CharColor", 65536 ) 113 cursor.setPropertyValue( "CharShadowed", uno.Bool(0) ) 114 |
115 text.insertString( cursor, " That's all for now !!" , 0 ) | 115 text.insertString( cursor, " That's all for now!" , 0 ) |
116 117g_exportedScripts = createTable, | 116 117g_exportedScripts = createTable, |