Re: Change column property in XTextTable
Hi, On Thu, Sep 19, 2013 at 11:32:50PM +0300, K.Misha wrote: > Code in attached file makes TextTable like this: > > > > > > But how i can make table like this: The answer is in the code snippet in the API documentation: http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/TextTable.html Set the HoriOrient property to NONE and then set the LeftMargin and RightMargin; or try other combinations, like in the attached example. Regards -- Ariel Constenla-Haile La Plata, Argentina #include #include #include /** === begin UNO includes === **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** === end UNO includes === **/ /** === begin UNO using === **/ using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::chart::XChartData; using ::com::sun::star::chart::XChartDataArray; using ::com::sun::star::chart::XChartDocument; using ::com::sun::star::document::XEmbeddedObjectSupplier; using ::com::sun::star::frame::XComponentLoader; using ::com::sun::star::lang::XComponent; using ::com::sun::star::lang::XMultiComponentFactory; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::sheet::XCellRangeData; using ::com::sun::star::sheet::XCellRangeData; using ::com::sun::star::table::XCell; using ::com::sun::star::table::XTableRows; using ::com::sun::star::text::TableColumnSeparator; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextCursor; using ::com::sun::star::text::XTextDocument; using ::com::sun::star::text::XTextTable; using ::com::sun::star::text::XTextTableCursor; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::makeAny; /** === end UNO using === **/ using namespace std; using rtl::OUString; namespace ControlCharacter = ::com::sun::star::text::ControlCharacter; int SAL_CALL main( int argc, char *argv[] ) { try { // bootstrap the office Reference< XComponentContext > rContext ( ::cppu::bootstrap() ); Reference< XMultiComponentFactory > rMCF( rContext->getServiceManager() ); // instantiate the Desktop and get a reference to XComponentLoader Reference < XComponentLoader > rComponentLoader( rMCF->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), rContext ), UNO_QUERY_THROW ); // load a new empty OOo Writer document Reference< XTextDocument > rTextDocument ( rComponentLoader->loadComponentFromURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/swriter" ) ), OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0, Sequence < ::com::sun::star::beans::PropertyValue >() ), UNO_QUERY_THROW ); // get the XText interface Reference< XText > rText = rTextDocument->getText(); // create a text cursor Reference< XTextCursor > rTextCursor = rText->createTextCursor(); rTextCursor->gotoStart( sal_False ); rText->insertString( rTextCursor.get(), OUString( RTL_CONSTASCII_USTRINGPARAM( "Default table:" ) ), sal_False ); // insert a paragraph break rText->insertControlCharacter( rTextCursor.get(), ControlCharacter::PARAGRAPH_BREAK, sal_False ); // get the document's factory Reference< XMultiServiceFactory > rDocFactory( rTextDocument, UNO_QUERY_THROW ); // create a text table Reference< XTextTable > rTextTable ( rDocFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextTable" ) ) ), UNO_QUERY_THROW ); // initalize it with 5 rows and 6 columns rTextTable->initialize( sal_Int32( 5 ), sal_Int32( 6 ) ); // insert it in the document rText->insertTextContent( rTextCursor.get(), rTextTable.get() , sal_False ); //-- rText->insertString( rTextCursor.get(), OUString( RTL_CONSTASCII_USTRINGPARAM( "Table: center alignment, 80 % relative width" ) ), sal_False ); // insert a paragraph break rText->insertControlCharacter( rTextCursor.get(), ControlCharacter::PARAGRAPH_BREAK, sal_False ); rText
Change column property in XTextTable
Code in attached file makes TextTable like this: But how i can make table like this: Thanks. <><> #include #include #include /** === begin UNO includes === **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** === end UNO includes === **/ /** === begin UNO using === **/ using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::chart::XChartData; using ::com::sun::star::chart::XChartDataArray; using ::com::sun::star::chart::XChartDocument; using ::com::sun::star::document::XEmbeddedObjectSupplier; using ::com::sun::star::frame::XComponentLoader; using ::com::sun::star::lang::XComponent; using ::com::sun::star::lang::XMultiComponentFactory; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::sheet::XCellRangeData; using ::com::sun::star::sheet::XCellRangeData; using ::com::sun::star::table::XCell; using ::com::sun::star::table::XTableRows; using ::com::sun::star::text::TableColumnSeparator; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextCursor; using ::com::sun::star::text::XTextDocument; using ::com::sun::star::text::XTextTable; using ::com::sun::star::text::XTextTableCursor; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::makeAny; /** === end UNO using === **/ using namespace std; using rtl::OUString; namespace ControlCharacter = ::com::sun::star::text::ControlCharacter; int SAL_CALL main( int argc, char *argv[] ) { try { // bootstrap the office Reference< XComponentContext > rContext ( ::cppu::bootstrap() ); Reference< XMultiComponentFactory > rMCF = rContext->getServiceManager(); // instantiate the Desktop and get a reference to XComponentLoader Reference < XComponentLoader > rComponentLoader( rMCF->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), rContext ), UNO_QUERY_THROW ); // load a new empty OOo Writer document Reference< XTextDocument > rTextDocument ( rComponentLoader->loadComponentFromURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/swriter" ) ), OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0, Sequence < ::com::sun::star::beans::PropertyValue >() ), UNO_QUERY_THROW ); // get the XText interface Reference< XText > rText = rTextDocument->getText(); // create a text cursor Reference< XTextCursor > rTextCursor = rText->createTextCursor(); rTextCursor->gotoStart( sal_False ); // insert a paragraph brake rText->insertControlCharacter( rTextCursor->getEnd(), ControlCharacter::PARAGRAPH_BREAK, sal_False ); // get the document's factory Reference< XMultiServiceFactory > rDocFactory ( rTextDocument, UNO_QUERY_THROW ); // create a text table Reference< XTextTable > rTextTable ( rDocFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextTable" ) ) ), UNO_QUERY_THROW ); // initalize it with 5 rows and 6 columns rTextTable->initialize( sal_Int32( 5 ), sal_Int32( 6 ) ); // insert it in the document rText->insertTextContent( rTextCursor->getEnd(), ( Reference< XTextContent > & ) rTextTable , sal_False ); // data OUString ustrJan ( RTL_CONSTASCII_USTRINGPARAM( "January" ) ); OUString ustrFeb ( RTL_CONSTASCII_USTRINGPARAM( "February" ) ); OUString ustrMar ( RTL_CONSTASCII_USTRINGPARAM( "March" ) ); OUString ustrApr ( RTL_CONSTASCII_USTRINGPARAM( "April" ) ); OUString ustrMay ( RTL_CONSTASCII_USTRINGPARAM( "May" ) ); OUString ustrJohn ( RTL_CONSTASCII_USTRINGPARAM( "John" ) ); OUString ustrPaula ( RTL_CONSTASCII_USTRINGPARAM( "Paula" ) ); OUString ustrAlan ( RTL_CONSTASCII_USTRINGPARAM( "Alan" ) ); OUString ustrDean ( RTL_CONSTASCII_USTRINGPARAM( "Dean" ) ); Any aRow0[6] = { Any(), makeAny( ustrJan ), makeAny( ustrFeb ), makeAny( ustrMar ), makeAny( ustrApr ), makeAny( ustrMay ) }; Any aRow1[6] = { makeAny( ustrJohn ), makeAny( 5.4 ), makeAny( 6.4 ), makeAny( 3.4 ), makeAny( 5.6 ), makeAny( 9.4 ) }; Any aRow2[6] = { makeAny(
inserting images in writer
Hello! Can you send me some examples of using images in writer? p.s.: *.cxx if you can. Thanks!
Re: Change column property in XTextTable
Hi, On Thu, Sep 19, 2013 at 02:36:24PM +0300, K.Misha wrote: > Can you help me with changing column properties in text table? The columns width is handled by the property TableColumnSeparators of the table, see http://wiki.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Table_Properties An example, assuming that you have a 6 columns table, each column will have by default the same with, 16.6 %; we want the first column to be only the 10%, and the other columns have the same width; the following code snippet does this: Reference< XPropertySet > rTablePropertySet ( rTextTable, UNO_QUERY_THROW ); sal_Int16 nReltativeSum( 0 ); rTablePropertySet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableColumnRelativeSum" ) ) ) >>= nReltativeSum; // by default, every column has the same width // with 6 columns, every column is 16.6 % of the column relative sum // make the first column a 10 % sal_Int16 nFirstColumn( nReltativeSum / 10 ); sal_Int16 nOtherCols( ( nReltativeSum - nFirstColumn ) / 5 ); sal_Int16 nPosition( nFirstColumn ); // in general, you get the sequence from the table's TableColumnSeparators // but as we've just created the table and know the column count, // there is no need to do so Sequence< TableColumnSeparator > aColSeparators( 5 ); aColSeparators[0].Position = nPosition; aColSeparators[0].IsVisible = sal_True; aColSeparators[1].Position = nPosition += nOtherCols; aColSeparators[1].IsVisible = sal_True; aColSeparators[2].Position = nPosition += nOtherCols; aColSeparators[2].IsVisible = sal_True; aColSeparators[3].Position = nPosition += nOtherCols; aColSeparators[3].IsVisible = sal_True; aColSeparators[4].Position = nPosition += nOtherCols; aColSeparators[4].IsVisible = sal_True; rTablePropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableColumnSeparators" ) ), makeAny( aColSeparators ) ); The full example is attached. Regards -- Ariel Constenla-Haile La Plata, Argentina #include #include #include /** === begin UNO includes === **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** === end UNO includes === **/ /** === begin UNO using === **/ using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::chart::XChartData; using ::com::sun::star::chart::XChartDataArray; using ::com::sun::star::chart::XChartDocument; using ::com::sun::star::document::XEmbeddedObjectSupplier; using ::com::sun::star::frame::XComponentLoader; using ::com::sun::star::lang::XComponent; using ::com::sun::star::lang::XMultiComponentFactory; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::sheet::XCellRangeData; using ::com::sun::star::sheet::XCellRangeData; using ::com::sun::star::table::XCell; using ::com::sun::star::table::XTableRows; using ::com::sun::star::text::TableColumnSeparator; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextCursor; using ::com::sun::star::text::XTextDocument; using ::com::sun::star::text::XTextTable; using ::com::sun::star::text::XTextTableCursor; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::makeAny; /** === end UNO using === **/ using namespace std; using rtl::OUString; namespace ControlCharacter = ::com::sun::star::text::ControlCharacter; int SAL_CALL main( int argc, char *argv[] ) { try { // bootstrap the office Reference< XComponentContext > rContext ( ::cppu::bootstrap() ); Reference< XMultiComponentFactory > rMCF = rContext->getServiceManager(); // instantiate the Desktop and get a reference to XComponentLoader Reference < XComponentLoader > rComponentLoader( rMCF->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), rContext ), UNO_QUERY_THROW ); // load a new empty OOo Writer document Reference< XTextDocument > rTextDocument ( rComponentLoader->loadComponentFromURL( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/swriter" ) ), OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0, Sequence < ::com::sun::star::beans::PropertyValue >() ), UNO_QUERY_THROW ); // get the XText interface Reference< XText > rText = rTextDocument->getText(); // create a text cursor
Re: Change column property in XTextTable
Hi, Am 19.09.2013 13:36, schrieb K.Misha: Hello! I have this code: Reference < XTextDocument > xTextDocument (xWriterComponent,UNO_QUERY); Reference< XModel > aDrawDoc (xTextDocument, UNO_QUERY); Reference aFact(aDrawDoc,UNO_QUERY); Reference< XTextTable > xTextTable( aFact->createInstance(OUString::createFromAscii("com.sun.star.text.TextTable ")), UNO_QUERY); xTextTable->initialize(4,4); Reference xText = xTextDocument->getText(); Reference xTextRange = xText->getStart(); Reference xTextContent(xTextTable, UNO_QUERY); xText->insertTextContent( xTextRange, xTextContent, 0 ); Reference xTableColumns = xTextTable->getColumns(); Any rCol = xTableColumns->getByIndex(0); Reference< XPropertySet > xPropSet2(rCol, UNO_QUERY); Any mPropVal1 <<= makeAny((unsigned short)150); But here i have an error: xPropSet2->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), mPropVal1); Can you help me with changing column properties in text table? you have to use the com.sun.star.text.TableColumnSeparator. In Java this can look like this: XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, xTextDocument); XTextTable xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, xTablesSupplier.getTextTables().getByName("Table1")); XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextTable); com.sun.star.text.TableColumnSeparator[] sep = (TableColumnSeparator[]) xPropertySet.getPropertyValue("TableColumnSeparators"); sep[0].Position = 1000; xPropertySet.setPropertyValue("TableColumnSeparators", sep); Regards Peter - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
RE: Change column property in XTextTable
Thanks!<неи<неи-Original Message-<неиFrom: Peter Eberlein [mailto:pet@refofd.verwalt-berlin.de] <неиSent: Thursday, September 19, 2013 5:24 PM<неиTo: api@openoffice.apache.org<неиSubject: Re: Change column property in XTextTable<неи<неиHi,<неиAm 19.09.2013 13:36, schrieb K.Misha:<неи> Hello!<неи><неи><неи><неи> I have this code:<неи><неи><неи><неи> Reference < XTextDocument > xTextDocument (xWriterComponent,UNO_QUERY);<неи><неи> Reference< XModel > aDrawDoc (xTextDocument, UNO_QUERY);<неи><неи> Reference aFact(aDrawDoc,UNO_QUERY);<неи><неи> Reference< XTextTable > xTextTable(<неи> aFact->createInstance(OUString::createFromAscii("com.sun.star.text.TextTable <неи> ")), UNO_QUERY);<неи><неи><неи><неи> xTextTable->initialize(4,4);<неи><неи><неи><неи> Reference xText = xTextDocument->getText();<неи><неи> Reference xTextRange = xText->getStart();<неи><неи> Reference xTextContent(xTextTable, UNO_QUERY);<неи><неи><неи><неи> xText->insertTextContent( xTextRange, xTextContent, 0 );<неи><неи><неи><неи> Reference xTableColumns = xTextTable->getColumns();<неи><неи> Any rCol = xTableColumns->getByIndex(0);<неи><неи><неи><неи> Reference< XPropertySet > xPropSet2(rCol, UNO_QUERY);<неи><неи> Any mPropVal1 <<= makeAny((unsigned short)150);<неи><неи><неи><неи> But here i have an error:<неи><неи> xPropSet2->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Width")),< неи> mPropVal1);<неи><неи><неи><неи> Can you help me with changing column properties in text table?<неи><неи<неиyou have to use the com.sun.star.text.TableColumnSeparator.<неи<неиIn Java this can look like this:<неи<неиXTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) <неиUnoRuntime.queryInterface(XTextTablesSupplier.class, xTextDocument);<неиXTextTable xTextTable = (XTextTable) <неиUnoRuntime.queryInterface(XTextTable.class, <неиxTablesSupplier.getTextTables().getByName("Table1"));<неиXPropertySet xPropertySet = (XPropertySet) <неиUnoRuntime.queryInterface(XPropertySet.class, xTextTable);<неиcom.sun.star.text.TableColumnSeparator[] sep = (TableColumnSeparator[]) <неиxPropertySet.getPropertyValue("TableColumnSeparators");<неиsep[0].Positi on = 1000;<неиxPropertySet.setPropertyValue("TableColumnSeparators", sep);<неи<неиRegards<неи<неиPeter<неи<неи--- --<неиTo unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org<неиFor additional commands, e-mail: api-h...@openoffice.apache.org<неи<неи - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Change column property in XTextTable
Hello! I have this code: Reference < XTextDocument > xTextDocument (xWriterComponent,UNO_QUERY); Reference< XModel > aDrawDoc (xTextDocument, UNO_QUERY); Reference aFact(aDrawDoc,UNO_QUERY); Reference< XTextTable > xTextTable( aFact->createInstance(OUString::createFromAscii("com.sun.star.text.TextTable ")), UNO_QUERY); xTextTable->initialize(4,4); Reference xText = xTextDocument->getText(); Reference xTextRange = xText->getStart(); Reference xTextContent(xTextTable, UNO_QUERY); xText->insertTextContent( xTextRange, xTextContent, 0 ); Reference xTableColumns = xTextTable->getColumns(); Any rCol = xTableColumns->getByIndex(0); Reference< XPropertySet > xPropSet2(rCol, UNO_QUERY); Any mPropVal1 <<= makeAny((unsigned short)150); But here i have an error: xPropSet2->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), mPropVal1); Can you help me with changing column properties in text table? Thanks!
Re: cppu::bootstrap() does not work with OpenOffice 4.0.0
On 9/19/13 12:14 PM, Ariel Constenla-Haile wrote: > Hi, > > On Thu, Sep 19, 2013 at 01:46:16PM +0800, Wei Min Teo wrote: >> Hi all, Thanks for all replies. The OS that I tested on is >> Windows XP. The reason why I started a openoffice process in >> listening mode is to run an invisible instance that runs in the >> background for automated tasks. Ariel Constenla-Haile have >> tested that the simple bootstrap example from the SDK. Anything >> else I can try? Are there alternate methods to bootstrap? > > Yes. If the simple bootstrap mechanism is broken, you have to use > the old method of first starting the office listening for > interprocess connections. > > Documentation: > http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/UNO_Interprocess_Connections > > http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/Establishing_Interprocess_Connections > > Sample code: - in the SDK installation, C++ examples using the > com.sun.star.bridge.UnoUrlResolver > > examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx > examples/cpp/DocumentLoader/DocumentLoader.cxx > > - there is a C++ "connection aware client" in > http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/ConnectionAwareClient/ > > or setting the UNO_PATH variable to specify exactly which office should be used. In case of testing this should be used anyway. Otherwise the default office on the system is used but probably not wanted for the test. The fix for the bootstrap problem is available. Juergen - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: cppu::bootstrap() does not work with OpenOffice 4.0.0
Hi, On Thu, Sep 19, 2013 at 01:46:16PM +0800, Wei Min Teo wrote: > Hi all, Thanks for all replies. The OS that I tested on is Windows > XP. The reason why I started a openoffice process in listening mode is > to run an invisible instance that runs in the background for automated > tasks. Ariel Constenla-Haile have tested that the simple bootstrap > example from the SDK. Anything else I can try? Are there alternate > methods to bootstrap? Yes. If the simple bootstrap mechanism is broken, you have to use the old method of first starting the office listening for interprocess connections. Documentation: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/UNO_Interprocess_Connections http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/Establishing_Interprocess_Connections Sample code: - in the SDK installation, C++ examples using the com.sun.star.bridge.UnoUrlResolver examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx examples/cpp/DocumentLoader/DocumentLoader.cxx - there is a C++ "connection aware client" in http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/ConnectionAwareClient/ Regards -- Ariel Constenla-Haile La Plata, Argentina pgpGH7RRSvdw5.pgp Description: PGP signature