질문하기

reuben's profile - activity

2019-04-26 19:43:57 +0200 받은 배지  유명한 질문 (source)
2019-02-13 18:59:33 +0200 받은 배지  주목할 만한 질문 (source)
2018-12-09 14:19:15 +0200 받은 배지  개근상
2018-12-08 18:37:56 +0200 받은 배지  인기있는 질문 (source)
2018-12-08 02:14:16 +0200 질문하였습니다 Connect to Postgres database using Writer without creating Base file

Connect to Postgres database using Writer without creating Base file I would like to add a Data Source to my LibreOffice

2018-10-10 04:01:39 +0200 받은 배지  유명한 질문 (source)
2018-04-15 04:12:10 +0200 받은 배지  유명한 질문 (source)
2017-12-19 22:27:17 +0200 받은 배지  주목할 만한 질문 (source)
2017-12-13 19:15:18 +0200 받은 배지  학생 (source)
2017-12-11 21:30:38 +0200 받은 배지  조력자 (source)
2017-12-11 18:10:21 +0200 코멘트달린 답변 Set image to original size with Python macro

@Ratslinger That's fine. Your answer pointed me in the right direction. Thanks again.

2017-12-11 17:05:28 +0200 받은 배지  인기있는 질문 (source)
2017-12-11 14:17:53 +0200 으뜸 답변으로 표시됨 Set image to original size with Python macro

I am embedding an image in a writer document using Python3. I just can't figure out how to set the image to the original size.

import uno
import unohelper


# a UNO struct later needed to create a document
from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
from com.sun.star.awt import Size

localContext = uno.getComponentContext()

resolver = localContext.ServiceManager.createInstanceWithContext(
                "com.sun.star.bridge.UnoUrlResolver", localContext )

smgr = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager" )
remoteContext = smgr.getPropertyValue( "DefaultContext" )

desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",remoteContext)

# open a writer document
doc = desktop.loadComponentFromURL( "private:factory/swriter","_blank", 0, () )

text = doc.Text
cursor = text.createTextCursor()
text.insertString( cursor, "The first line in the newly created text document.\n", 0 )
text.insertString( cursor, "Now we are in the second line\n" , 0 )

# create a text table
table = doc.createInstance( "com.sun.star.text.TextTable" )

# with 4 rows and 4 columns
table.initialize( 4,4)

text.insertTextContent( cursor, table, 0 )
rows = table.Rows

img = doc.createInstance('com.sun.star.text.TextGraphicObject') 
img.GraphicURL = 'file:///home/reuben/reuben.jpg' 
tableText = table.getCellByName( "C2" )
cursor = tableText.createTextCursor()
tableText.insertTextContent(cursor, img, False)
img.setPropertyValue('AnchorType', AS_CHARACTER)
img.setSize(????)

Any suggestions? Thanks.

[Edit] LO skews the image size sometimes, and I want it to be the original size. The problem is I don't know what the original size was.

2017-12-11 14:17:42 +0200 코멘트달린 답변 Set image to original size with Python macro

This is what I was looking for: w = img.ActualSize.Width h = img.ActualSize.Height size = Size (w, h) img.setSize (size

2017-12-11 12:41:03 +0200 코멘트달린 답변 Set image to original size with Python macro

Thanks, your answer was the other thing I was confused about. But anyway, I want to set the image to the original size.

2017-12-11 12:40:35 +0200 받은 배지  편집자 (source)
2017-12-11 12:40:35 +0200 질문을 편집했습니다 Set image to original size with Python macro

Set image to original size with Python macro I am embedding an image in a writer document using Python3. I just can't fi

2017-12-11 12:30:48 +0200 코멘트달린 답변 Set image to original size with Python macro

Thanks, your answer was the other thing I was confused about. But anyway, I want to set the image to the original size.

2017-12-11 12:30:41 +0200 질문을 편집했습니다 Set image to original size with Python macro

Set image to original size with Python macro I am embedding an image in a writer document using Python3. I just can't fi

2017-12-11 04:13:39 +0200 질문하였습니다 Set image to original size with Python macro

Set image to original size with Python macro I am embedding an image in a writer document using Python3. I just can't fi

2017-12-11 03:22:30 +0200 코멘트달린 답변 Launching a Writer document from Python

Ok, got it. I was baffled by the lack of doc.show() or similar. Vastly different from Gtk, anyway.

2017-12-11 03:20:59 +0200 으뜸 답변으로 표시됨 Launching a Writer document from Python

I would like to open a Writer document from a Python script that I can close reliably. Subprocess.call() opens the document fine, but I cannot close it. The basic idea is to pop open a window with a file generated from a template. When the user regenerates the file, Python closes the window and opens the new file. Is this possible?

Thanks Reuben

2017-12-11 03:20:59 +0200 받은 배지  학자 (source)
2017-09-30 05:30:22 +0200 받은 배지  주목할 만한 질문 (source)
2017-09-22 19:02:10 +0200 받은 배지  인기있는 질문 (source)
2017-09-22 18:22:11 +0200 질문에 댓글을 달았습니다 Launching a Writer document from Python

subprocess.call() simply does not have a reliable pid or anything. Mostly because the soffice.bin might be running alrea

2017-09-22 18:15:47 +0200 코멘트달린 답변 Launching a Writer document from Python

Could you give me a small example that opens/shows the file '/home/reuben/test.odt' , waits three seconds, and then clos

2017-09-22 14:32:36 +0200 질문하였습니다 Launching a Writer document from Python

Launching a Writer document from Python I would like to open a Writer document from a Python script that I can close rel