Pyuno: Headers
Pyuno: Headers
I need to implement a header Program wise which has to start at
an Specific Page on the Document and needs to go on over the rest of the document.
This needs to be done by the program.
Im using Python for this.
I found something but it seem like it is not implemented in Pyuno.
Any help?
an Specific Page on the Document and needs to go on over the rest of the document.
This needs to be done by the program.
Im using Python for this.
I found something but it seem like it is not implemented in Pyuno.
Any help?
Last edited by imr_lor on Tue Oct 27, 2015 11:12 am, edited 5 times in total.
OpenOffice 3.1 on LinuxMint 17.1
Re: Pyuno
Here is the beginning of doing this. I created a page style and added it to the document but it would be better if a style already existed.
Code: Select all
from com.sun.star.style.BreakType import PAGE_BEFORE
def AddHeaderAtPageThree():
oDoc = XSCRIPTCONTEXT.getDocument()
StyleFam = oDoc.StyleFamilies
PageStyles = StyleFam.getByName("PageStyles")
NewStyle = oDoc.createInstance("com.sun.star.style.PageStyle")
PageStyles.insertByName("MyNewStyle", NewStyle)
NewStyle.HeaderIsOn = True
NewStyle.HeaderText.String = "The New Header Text"
oVC = oDoc.CurrentController.ViewCursor
oVC.jumpToPage(3)
oVC.BreakType = PAGE_BEFORE
oVC.PageDescName = "MyNewStyle"OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Pyuno: Headers
Thank you very much. I have two questions left:
I already have an page Style so how can I modify it?
How can I import XSCRIPTCONTEXT?
I already have an page Style so how can I modify it?
How can I import XSCRIPTCONTEXT?
OpenOffice 3.1 on LinuxMint 17.1
Re: Pyuno: Headers
You cannot import it, because its a global Variable in Python if you run it through|from inside soffice.imr_lor wrote: How can I import XSCRIPTCONTEXT?
If your running python independetly from soffice, you need first some other preparations to connect the soffice-process:
Code: Select all
####_server.py this Script runs sOffice in Pipe-mode with an pipe named `abraxas`
from subprocess import Popen
officepath = 'soffice'
pipe = "--accept=pipe,name=abraxas;urp;StarOffice.Servicemanager"
Popen([officepath, pipe])
Code: Select all
#
import uno
from pythonscript import ScriptContext
local = uno.getComponentContext()
resolver = local.ServiceManager.createInstance("com.sun.star.bridge.UnoUrlResolver")
client = resolver.resolve("uno:pipe,"
"name=abraxas;"
"urp;"
"StarOffice.ComponentContext")
XSCRIPTCONTEXT = ScriptContext(client, None, None) Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Re: Pyuno: Headers
I have some Problems importing
it returns the error ImportError: No module named 'pythonscript' (or 'pythonscript.ScriptContext' is unknown)
Update:
I found this( https://docs.libreoffice.org/scripting/ ... ource.html ) but i dont know how to implement it
Code: Select all
from pythonscript import ScriptContextUpdate:
I found this( https://docs.libreoffice.org/scripting/ ... ource.html ) but i dont know how to implement it
OpenOffice 3.1 on LinuxMint 17.1
Re: Pyuno: Headers
Hallo
Actually we have a problem: we know nothing about your Environment, and (it seems) you know less than that
Your Signatur states: OO3.1 @ Linux Mint 17.1
Really that outdated Version of OpenOffice on an almost actual 17.1
Linux Mint 17.1 normally comes out of the box with LibreOffice 4.x, but unfortuneatly without pythonscript ( in this case search for libreoffice-script-provider-python in your Package-manager and install it.)
Actually we have a problem: we know nothing about your Environment, and (it seems) you know less than that
Your Signatur states: OO3.1 @ Linux Mint 17.1
Really that outdated Version of OpenOffice on an almost actual 17.1
Linux Mint 17.1 normally comes out of the box with LibreOffice 4.x, but unfortuneatly without pythonscript ( in this case search for libreoffice-script-provider-python in your Package-manager and install it.)
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Re: Pyuno: Headers
Ok I managed to implement it and it works. Thanks so far.
How do I applie this for an certain Page Style(which is already defined) in the whole document(and the header needs to be centered)?
How do I applie this for an certain Page Style(which is already defined) in the whole document(and the header needs to be centered)?
OpenOffice 3.1 on LinuxMint 17.1
Re: Pyuno: Headers
You open your document template for editing and change the page style. Why all this macro bullshit for the most trivial tasks?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Pyuno: Headers
Im working on Linux Mint 17.1 with LibreOffice 4.2.8.2karolus wrote:Hallo
Actually we have a problem: we know nothing about your Environment, and (it seems) you know less than that![]()
Your Signatur states: OO3.1 @ Linux Mint 17.1
Really that outdated Version of OpenOffice on an almost actual 17.1
Linux Mint 17.1 normally comes out of the box with LibreOffice 4.x, but unfortuneatly without pythonscript ( in this case search for libreoffice-script-provider-python in your Package-manager and install it.)
Im using Python 3.4.0.
This Project wasnt originally programmed by me but I have to update it and to implement various new functions.
The main Problem is that this Programm is poorly documented
But after implementing those Headers I can finally move on to an new Project.
So thank you for understanding that im not very into programming with UNO.
OpenOffice 3.1 on LinuxMint 17.1
Re: Pyuno: Headers
Firstival as mentioned in a Post viewtopic.php?f=20&t=79728before This is not a makro!Villeroy wrote:You open your document template for editing and change the page style. Why all this macro bullshit for the most trivial tasks?
And the other reason is that this programm processes given Information into an document.
OpenOffice 3.1 on LinuxMint 17.1
Re: Pyuno: Headers
You know MRI? No? You should. [Tutorial] Introduction into object inspection with MRI
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Pyuno: Headers
Seems interesting but its definitely not the thing I am looking for.
As mentioned above the only thing i still need to do is to apply this header to all pages of a certain pagestyle.
As mentioned above the only thing i still need to do is to apply this header to all pages of a certain pagestyle.
OpenOffice 3.1 on LinuxMint 17.1