질문하기

raspberry's profile - activity

2018-05-30 21:10:50 +0200 받은 배지  정리의 달인
2013-08-22 01:07:40 +0200 받은 배지  주목할 만한 질문 (source)
2013-08-22 01:07:40 +0200 받은 배지  유명한 질문 (source)
2013-02-20 05:54:43 +0200 받은 배지  선생님 (source)
2013-02-20 05:54:43 +0200 받은 배지  자기 주도 학습자 (source)
2013-02-20 05:54:41 +0200 받은 배지  학생 (source)
2013-02-19 23:44:35 +0200 받은 배지  인기있는 질문 (source)
2012-07-16 23:22:00 +0200 질문에 답변하였습니다 create styles in writer using vb.net

Here is additional information (I hope it is not too much...):

The following code is from http://api.libreoffice.org/examples/examples.html#CLI_examples.

This code is VB.Net It shows how to open a Writer doc from VB.Net, add text, add a table and do other items. It does not show how to create and apply styles. Below is the portion that opens and connects to a new Writer doc.

    Dim xContext As XComponentContext
    xContext = Bootstrap.bootstrap()

    Dim xFactory As XMultiServiceFactory
    xFactory = DirectCast(xContext.getServiceManager(), XMultiServiceFactory)

    'Create the Desktop
    Dim xDesktop As unoidl.com.sun.star.frame.XDesktop
    xDesktop = DirectCast(xFactory.createInstance("com.sun.star.frame.Desktop"),  _
        unoidl.com.sun.star.frame.XDesktop)

    'Open a new empty writer document
    Dim xComponentLoader As unoidl.com.sun.star.frame.XComponentLoader
    xComponentLoader = DirectCast(xDesktop, unoidl.com.sun.star.frame.XComponentLoader)

    Dim arProps() As unoidl.com.sun.star.beans.PropertyValue = New unoidl.com.sun.star.beans.PropertyValue() {}
    Dim xComponent As unoidl.com.sun.star.lang.XComponent
    xComponent = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, arProps)

    Dim xTextDocument As unoidl.com.sun.star.text.XTextDocument
    xTextDocument = DirectCast(xComponent, unoidl.com.sun.star.text.XTextDocument)

    'Create a text object
    Dim xText As unoidl.com.sun.star.text.XText
    xText = xTextDocument.getText()

    Dim xSimpleText As unoidl.com.sun.star.text.XSimpleText
    xSimpleText = DirectCast(xText, unoidl.com.sun.star.text.XSimpleText)

    'Create a cursor object
    Dim xCursor As unoidl.com.sun.star.text.XTextCursor
    xCursor = xSimpleText.createTextCursor()

I also have a code snippet in Java that creates styles in Writer, but I do not know Java and I have not been able to translate from Java to VB.Net. This is from http://api.libreoffice.org/examples/DevelopersGuide/examples.html#FirstSteps.

   // Create a new style from the document's factory
        XStyle xStyle = (XStyle) UnoRuntime.queryInterface(
            XStyle.class, mxDocFactory.createInstance(
                "com.sun.star.style.ParagraphStyle" ) );

        // Access the XPropertySet interface of the new style
        XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(
            XPropertySet.class, xStyle );

        // Give the new style a light blue background
        xStyleProps.setPropertyValue ( "ParaBackColor", new Integer (13421823));

        // Get the StyleFamiliesSupplier interface of the document
        XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
            UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, mxDoc);

        // Use the StyleFamiliesSupplier interface to get the XNameAccess
        // interface of the actual style families
        XNameAccess xFamilies = ( XNameAccess ) UnoRuntime.queryInterface (
            XNameAccess.class, xSupplier.getStyleFamilies() );

        // Access the 'ParagraphStyles' Family
        XNameContainer xFamily = (XNameContainer ) UnoRuntime.queryInterface (
                    XNameContainer.class,
                    xFamilies.getByName ( "ParagraphStyles" ) );

        // Insert the newly created style into the ParagraphStyles family ...
(more)
2012-07-16 23:03:06 +0200 질문에 댓글을 달았습니다 create styles in writer using vb.net

No. I would like to use Microsoft's Visual Basic.Net to automate Writer.

2012-07-16 18:33:37 +0200 질문하였습니다 create styles in writer using vb.net

I would like to be able to use VB.Net to create and apply character styles in writer. Can anyone supply a code snippet or point me to a location that has code I can look at. Thanks...