https://bugs.documentfoundation.org/show_bug.cgi?id=164874

Buovjaga <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[FORMATTING]                |Python scripting: setting
                   |                            |IsLandscape to true doesn't
                   |                            |swap page width and height
                 CC|                            |ilmari.lauhakangas@libreoff
                   |                            |ice.org

--- Comment #2 from Buovjaga <[email protected]> ---
I reproduce the result, but looking at the style in the UI, it has created a
"User" paper size out of it. So it's just considering it as a new kind of paper
with the same old width and height, but marked as "Landscape". To get what you
want, you need to also set the width and height property values explicitly.

Here IsLandscape is being used together with width and height via BASIC in
Calc: https://wiki.documentfoundation.org/Documentation/BASIC_Guide#Page_Format

I think it might not be available via Python scripting right now, but I see in
the SDK guide a way that might work for intuitively swapping between portrait
and landscape:
https://wiki.documentfoundation.org/Documentation/SDKGuide/Printing#5.1._Printing_a_Text_Document

Ie. I don't see a way to use XPagePrintable and getPagePrintSettings() in
Python, I saw some discussions about it.

Steps I used to reproduce:

1. Run `/path/to/soffice --accept='socket,host=localhost,port=2021;urp;'`
2. Run python in a terminal and run the below code, using some existing blank
Calc document:

import uno

local_context = uno.getComponentContext()
resolver = local_context.ServiceManager.createInstanceWithContext(
                "com.sun.star.bridge.UnoUrlResolver", local_context
)
context = resolver.resolve(
    f"uno:socket,host=localhost,port=2021;urp;StarOffice.ComponentContext"
)

# Get the Desktop instance
desktop = context.ServiceManager.createInstanceWithContext(
                "com.sun.star.frame.Desktop", context
            )
document = desktop.loadComponentFromURL(
                    "file:///home/user/libobugs/blank.ods", "_blank", 0,
tuple()
                )


style_familes = document.getStyleFamilies()
for style_name in style_familes.PageStyles:
    page_style = style_familes.PageStyles.getByName(style_name.Name)
    page_style.setPropertyValue("IsLandscape", True)

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to