Beispiel #1
0
 public XTextCursor setXTextRange(XTextCursor xTextCursor, XTextRange start, XTextRange end)
 {
     if (xTextCursor != null && start != null && end != null)
     {
         xTextCursor.gotoRange(start.getStart(), false);
         xTextCursor.gotoRange(end.getEnd(), true);
     }
     return(xTextCursor);
 }
Beispiel #2
0
        public void AddTextToFrame(ref XTextFrame textFrame, String text, int charWeight = 100, int charHeight = 12)
        {
            if (textFrame != null)
            {
                XText       xText            = ((XTextFrame)textFrame).getText();
                XTextCursor xFrameTextCurser = xText.createTextCursor();
                xFrameTextCurser.gotoEnd(false);
                OoUtils.SetProperty(xFrameTextCurser, "CharWeight", charWeight);
                OoUtils.SetProperty(xFrameTextCurser, "CharHeight", charHeight);

                xText.insertString(xFrameTextCurser, text, false);
            }
        }
Beispiel #3
0
        public void AddTextToFrameAndNewParagraph(ref XTextFrame textFrame, String text, int charWeight = 100, int charHeight = 12)
        {
            if (textFrame != null)
            {
                XText       xText            = ((XTextFrame)textFrame).getText();
                XTextCursor xFrameTextCurser = xText.createTextCursor();
                xFrameTextCurser.gotoEnd(false);
                OoUtils.SetProperty(xFrameTextCurser, "CharWeight", charWeight);
                OoUtils.SetProperty(xFrameTextCurser, "CharHeight", charHeight);

                xText.insertString(xFrameTextCurser, text, false);
                xText.insertControlCharacter(xFrameTextCurser, ControlCharacter.PARAGRAPH_BREAK, false);
            }
        }
Beispiel #4
0
        public XTextTable AddTableToFrame(ref XTextFrame textFrame, int col, int rows)
        {
            var Table = this.xMcFactory.createInstanceWithContext(OO.Services.TEXT_TEXT_TABLE, xContext);

            if (Table != null)
            {
                if (Table is XTextTable)
                {
                    ((XTextTable)Table).initialize(rows, col);
                }
                XText       xText            = ((XTextFrame)textFrame).getText();
                XTextCursor xFrameTextCurser = xText.createTextCursor();
                xFrameTextCurser.gotoEnd(false);
                xText.insertTextContent(xFrameTextCurser, Table as XTextContent, false);
                xText.insertControlCharacter(xFrameTextCurser, ControlCharacter.PARAGRAPH_BREAK, false);
            }
            return(Table as XTextTable);
        }
 public XTextCursor setXTextRange(XTextCursor xTextCursor, XTextRange start, XTextRange end)
 {
     if (xTextCursor != null && start != null && end != null)
     {
         xTextCursor.gotoRange(start.getStart(), false);
         xTextCursor.gotoRange(end.getEnd(), true);
     }
     return xTextCursor;
 }
Beispiel #6
0
        static void Main()
        {
            XComponentContext
                localContext = uno.util.Bootstrap.bootstrap();

            XMultiServiceFactory
                ServiceManager = (XMultiServiceFactory)localContext.getServiceManager();

            XComponentLoader
                Desktop = (XComponentLoader)ServiceManager.createInstance("com.sun.star.frame.Desktop");

            XComponent
                Document = Desktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, new unoidl.com.sun.star.beans.PropertyValue[0]);

            XText
                Text = ((XTextDocument)Document).getText();

            Text.setString("Hello I'm the first text!");

            XTextCursor
                Cursor = Text.createTextCursor();

            Text.insertString(Cursor, "Line# 1\n", false);
            Text.insertString(Cursor, "Line# 2", false);

            XTextTable
                Table;

            if ((Table = (XTextTable)((XMultiServiceFactory)Document).createInstance("com.sun.star.text.TextTable")) != null)
            {
                Table.initialize(2, 2);
                Text.insertTextContent(Text.getEnd(), Table, false);
            }


            unoidl.com.sun.star.beans.PropertyValue[]
            Params = new unoidl.com.sun.star.beans.PropertyValue[2];

            unoidl.com.sun.star.beans.PropertyValue
                Param = new unoidl.com.sun.star.beans.PropertyValue();

            Param.Name  = "FilterName";
            Param.Value = new uno.Any("writer_pdf_Export");
            Params[0]   = Param;

            Param       = new unoidl.com.sun.star.beans.PropertyValue();
            Param.Name  = "CompressionMode";
            Param.Value = new uno.Any("1");
            Params[1]   = Param;

            string
                CurrentDirectory = System.IO.Directory.GetCurrentDirectory(),
                DocumentDestName;

            CurrentDirectory = CurrentDirectory.Substring(0, CurrentDirectory.LastIndexOf("bin", CurrentDirectory.Length - 1));

            if (File.Exists(DocumentDestName = (CurrentDirectory + "test_out.pdf")))
            {
                File.Delete(DocumentDestName);
            }

            DocumentDestName = DocumentDestName.Replace(Path.DirectorySeparatorChar, '/').Replace("#", "%23");

            ((XStorable)Document).storeToURL("file:///" + DocumentDestName, Params);
            ((XCloseable)Document).close(true);
        }