Bug 137664 - Can't change slide.Background.FillBitmapMode with Macro (Basic or python PyUno)
Summary: Can't change slide.Background.FillBitmapMode with Macro (Basic or python PyUno)
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.2.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Slide-Background
  Show dependency treegraph
 
Reported: 2020-10-21 18:18 UTC by Pablo
Modified: 2025-12-30 17:09 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
ODP with slide background set to tiled bitmap (69.94 KB, application/vnd.oasis.opendocument.presentation)
2020-10-21 18:18 UTC, Pablo
Details
ODP with master background set to tiled bitmap (70.00 KB, application/vnd.oasis.opendocument.presentation)
2020-10-21 18:19 UTC, Pablo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pablo 2020-10-21 18:18:00 UTC
Description:
The attached slide-bitmap.odp has slide background set to Tiled Bitmap.
The slide.Background.FillBitmapMode is com.sun.star.drawing.BitmapMode.REPEAT
It's not possible to change the FillBitmapMode to STRETCH.

The attached master-bitmap.odp has the same background set on the Master slide. Changing the FillBitmapMode of the Master background is possible.

Steps to Reproduce:
A)
1. Open slide-bitmap.odp
2. Press Alt+F11 to open the Macro editor and click Edit.
3. Paste the following code and run it:
Sub Main
    Dim doc as Object
    doc = ThisComponent
    Dim slide as Object
    slide = doc.getDrawPages().getByIndex(0)
    
    Print slide.Background.FillBitmapMode
    slide.Background.FillBitmapMode = com.sun.star.drawing.BitmapMode.STRETCH
    Print slide.Background.FillBitmapMode 
End Sub
4. Check that the FillBitmapMode hasn't change.

B)
1. Open master-bitmap.odp
2. Press Alt+F11 to open the Macro editor and click Edit.
3. Paste the following code and run it:
Sub Main
    Dim doc as Object
    doc = ThisComponent
    Dim slide as Object
    slide = doc.getDrawPages().getByIndex(0)
    
    Print slide.MasterPage.Background.FillBitmapMode
    slide.MasterPage.Background.FillBitmapMode = com.sun.star.drawing.BitmapMode.STRETCH
    Print slide.MasterPage.Background.FillBitmapMode
End Sub
4. Check that the FillBitmapMode changed.

Actual Results:
The slide.Background.FillBitmap mode hasn't changed.


Expected Results:
The slide.Background.FillBitmap mode should change to STRETCH.


Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.1.0.0.alpha0+
Build ID: 75030b3a2d4336c494fbe799fb809a37ed7e582f
CPU threads: 1; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_IL); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2020-10-08_21:40:22
Calc: threaded
Comment 1 Pablo 2020-10-21 18:18:41 UTC
Created attachment 166598 [details]
ODP with slide background set to tiled bitmap
Comment 2 Pablo 2020-10-21 18:19:20 UTC
Created attachment 166599 [details]
ODP with master background set to tiled bitmap
Comment 3 Pablo 2020-10-21 18:20:31 UTC
I also can't change slide.Background.BitmapFillMode with PyUno. Not sure if the Macro fix will also fix PyUno.
Comment 4 Kevin Suo 2020-11-08 13:54:15 UTC
I can reproduce this on master build.

I used the following python code:

---
import uno

from com.sun.star.drawing.BitmapMode import STRETCH
from com.sun.star.drawing.BitmapMode import REPEAT

def change_bg():
    desktop = XSCRIPTCONTEXT.getDesktop()
    doc = desktop.getCurrentComponent()
    slide = doc.getDrawPages().getByIndex(0)
    
    slide.Background.FillBitmapMode = STRETCH
    # slide.Background.FillBitmapMode = REPEAT
---

The macro can be run without error, but the background bitmap mode has no effect.
Comment 5 Aron Budea 2021-08-07 15:45:18 UTC
Already in 5.2.0.4.
Comment 6 QA Administrators 2023-08-08 03:12:14 UTC Comment hidden (obsolete)
Comment 7 QA Administrators 2025-08-08 03:11:13 UTC Comment hidden (obsolete)
Comment 8 Neil Roberts 2025-12-30 17:09:05 UTC
It looks like whenever you access slide.Background LibreOffice creates a new background object with a copy of the values from the slide. Modifying it only affects the copy and not the original slide’s background. If you want the changes to actually take affect you have set the Background property with the modified background object like this:

Sub Main
    Dim doc as Object
    doc = ThisComponent
    Dim slide as Object
    slide = doc.getDrawPages().getByIndex(0)
    
    Print slide.Background.FillBitmapMode
    Dim bg as Object
    bg = slide.Background
    bg.FillBitmapMode = com.sun.star.drawing.BitmapMode.STRETCH
    slide.Background = bg
    Print slide.Background.FillBitmapMode 
End Sub

I’m not sure if this should be considered a bug or whether it’s an intentional design of the API.

On the other hand when you call slide.MasterPage.Background it looks like it does return the page’s original background object. See SdMasterPage::getBackground. I wonder if this is a mistake because in that function if IsImpressDocument is false it will instead create a new background. It seems to sometimes create a new object and sometimes return the original one.