tdf#134734 svx,sd: BackgroundFullSize

There is already a boolean SdPage::mbBackgroundFullSize, UNO property
and ODF import/export, but curiously no trace of it ever doing anything.

There is some mystery handling of SID_ATTR_PAGE_EXT2 there but in the
dialog that is only handled for SVX_PAGE_MODE_CENTER from Calc
for a completely different purpose.

Move mbBackgroundFullSize to base class SdrPage so that
ViewContactOfMasterPageDescriptor can access it to paint.

There's an oddity in the handling of the property where the dialog works
on the master page and not on the current slide, not sure why it was
implemented this way.

Change-Id: If6e1329e3f77e0a1a7226d5e51ceb221ea86c401
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112783
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/cui/uiconfig/ui/pageformatpage.ui b/cui/uiconfig/ui/pageformatpage.ui
index 9332ebb..b6974ee 100644
--- a/cui/uiconfig/ui/pageformatpage.ui
+++ b/cui/uiconfig/ui/pageformatpage.ui
@@ -643,7 +643,7 @@
                    <property name="draw_indicator">True</property>
                  </object>
                  <packing>
                    <property name="left_attach">0</property>
                    <property name="left_attach">1</property>
                    <property name="top_attach">6</property>
                    <property name="width">2</property>
                  </packing>
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 8ac47f2..ff936bd 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -409,6 +409,7 @@ private:
    sal_Int32 mnBorderUpper; // top page margin
    sal_Int32 mnBorderRight; // right page margin
    sal_Int32 mnBorderLower; // bottom page margin
    bool mbBackgroundFullSize = false; ///< Background object to represent the whole page.

    std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
    std::unique_ptr<SdrPageProperties> mpSdrPageProperties;
@@ -479,6 +480,8 @@ public:
    sal_Int32 GetUpperBorder() const;
    sal_Int32 GetRightBorder() const;
    sal_Int32 GetLowerBorder() const;
    void    SetBackgroundFullSize(bool bIn);
    bool    IsBackgroundFullSize() const;

    // New MasterPage interface
    bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); }
diff --git a/offapi/com/sun/star/drawing/GenericDrawPage.idl b/offapi/com/sun/star/drawing/GenericDrawPage.idl
index e78d94b..05073de 100644
--- a/offapi/com/sun/star/drawing/GenericDrawPage.idl
+++ b/offapi/com/sun/star/drawing/GenericDrawPage.idl
@@ -148,6 +148,14 @@ published service GenericDrawPage
        making the z-order the default navigation order for top level shapes.
    */
    [optional, property] com::sun::star::container::XIndexAccess NavigationOrder;

    /** does the background cover the full page or only inside the
        margins?

        @since LibreOffice 7.2
     */
    [optional, property] boolean BackgroundFullSize;

};


diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index d1662ee..ae97ff0 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -119,7 +119,6 @@ friend class sd::UndoAttrObject;
    OUString    maFileName;               ///< file name.
    OUString    maBookmarkName;           ///< Bookmark name.
    bool    mbScaleObjects;           ///< Objects should be scaled
    bool    mbBackgroundFullSize;     ///< Background object to represent the whole page.
    rtl_TextEncoding meCharSet;           ///< Text encoding
    sal_uInt16  mnPaperBin;               ///< PaperBin
    SdPageLink* mpPageLink;               ///< Page link (at left sides only)
@@ -275,9 +274,6 @@ public:
                                  bool bReverseOrder = false);
    void            EndListenOutlineText();

    void    SetBackgroundFullSize( bool bIn );
    bool    IsBackgroundFullSize() const { return mbBackgroundFullSize; }

    void    SetPaperBin(sal_uInt16 nBin) { mnPaperBin = nBin; }
    sal_uInt16  GetPaperBin() const { return mnPaperBin; }
    virtual void        SetOrientation(Orientation eOrient) override;
diff --git a/sd/qa/unit/data/odp/background.odp b/sd/qa/unit/data/odp/background.odp
new file mode 100644
index 0000000..f96785d
--- /dev/null
+++ b/sd/qa/unit/data/odp/background.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 7320118..42e5814 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -25,8 +25,11 @@
#include <unotools/mediadescriptor.hxx>
#include <rtl/ustring.hxx>

#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
@@ -82,6 +85,7 @@ public:
    void testRhbz1870501();
    void testTdf128550();
    void testTdf140714();
    void testMasterPageBackgroundFullSize();

    CPPUNIT_TEST_SUITE(SdExportTest);

@@ -122,6 +126,7 @@ public:
    CPPUNIT_TEST(testRhbz1870501);
    CPPUNIT_TEST(testTdf128550);
    CPPUNIT_TEST(testTdf140714);
    CPPUNIT_TEST(testMasterPageBackgroundFullSize);

    CPPUNIT_TEST_SUITE_END();

@@ -1367,6 +1372,149 @@ void SdExportTest::testTdf140714()
    xDocShRef->DoClose();
}

void SdExportTest::testMasterPageBackgroundFullSize()
{
    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/background.odp"), ODP);

    // BackgroundFullSize exists on master pages only
    // (note: this document can't be created with the UI because UI keeps
    //  page margins and the flag synchronized across all master pages)
    uno::Reference<drawing::XMasterPagesSupplier> xMPS(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
    uno::Reference<drawing::XDrawPages> xMPs(xMPS->getMasterPages());
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(0), uno::UNO_QUERY);
        CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0x729fcf), xBackgroundProps->getPropertyValue("FillColor").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(1), uno::UNO_QUERY);
        CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0x729fcf), xBackgroundProps->getPropertyValue("FillColor").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(2), uno::UNO_QUERY);
        CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH, xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(3), uno::UNO_QUERY);
        CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH, xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }

    utl::TempFile tempFile;
    xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);

    xMPS.set(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
    xMPs.set(xMPS->getMasterPages());
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(0), uno::UNO_QUERY);
        CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0x729fcf), xBackgroundProps->getPropertyValue("FillColor").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(1), uno::UNO_QUERY);
        CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0x729fcf), xBackgroundProps->getPropertyValue("FillColor").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(2), uno::UNO_QUERY);
        CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH, xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }
    {
        uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(3), uno::UNO_QUERY);
        CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
        CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
        uno::Reference<beans::XPropertySet> xBackgroundProps(
            xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
        CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
        CPPUNIT_ASSERT_EQUAL(drawing::BitmapMode_STRETCH, xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
        CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
    }

    xDocShRef->DoClose();

    xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "styles.xml");
    assertXPath(pXmlDoc,
        "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
        "/office:document-styles/office:master-styles/style:master-page[@style:name='Default']/attribute::draw:style-name"
        "]/style:drawing-page-properties", "background-size", "border");
    assertXPath(pXmlDoc,
        "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
        "/office:document-styles/office:master-styles/style:master-page[@style:name='Default_20_3']/attribute::draw:style-name"
        "]/style:drawing-page-properties", "background-size", "full");
    assertXPath(pXmlDoc,
        "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
        "/office:document-styles/office:master-styles/style:master-page[@style:name='Default_20_2']/attribute::draw:style-name"
        "]/style:drawing-page-properties", "background-size", "border");
    assertXPath(pXmlDoc,
        "/office:document-styles/office:automatic-styles/style:style[@style:family='drawing-page' and @style:name = "
        "/office:document-styles/office:master-styles/style:master-page[@style:name='Default_20_1']/attribute::draw:style-name"
        "]/style:drawing-page-properties", "background-size", "full");

    tempFile.EnableKillingFile();
}

CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);

CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 2be8b85..aaf209a 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -114,7 +114,6 @@ SdPage::SdPage(SdDrawDocument& rNewDoc, bool bMasterPage)
,   mbLoopSound(false)
,   mbStopSound(false)
,   mbScaleObjects(true)
,   mbBackgroundFullSize( false )
,   meCharSet(osl_getThreadTextEncoding())
,   mnPaperBin(PAPERBIN_PRINTER_SETTINGS)
,   mpPageLink(nullptr)
@@ -1797,20 +1796,6 @@ void SdPage::SetLowerBorder(sal_Int32 nBorder)

/*************************************************************************
|*
|* Sets BackgroundFullSize and then calls AdjustBackground
|*
\************************************************************************/

void SdPage::SetBackgroundFullSize( bool bIn )
{
    if( bIn != mbBackgroundFullSize )
    {
        mbBackgroundFullSize = bIn;
    }
}

/*************************************************************************
|*
|* Adjust all objects to new page size.
|*
|* bScaleAllObj: all objects are scaled into the new area within the page
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 2719f3d..1277d12 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -361,7 +361,6 @@ void SdPage::lateInit(const SdPage& rSrcPage)
    maFileName = rSrcPage.maFileName;
    maBookmarkName = rSrcPage.maBookmarkName;
    mbScaleObjects = rSrcPage.mbScaleObjects;
    mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
    meCharSet = rSrcPage.meCharSet;
    mnPaperBin = rSrcPage.mnPaperBin;
    mpPageLink = nullptr;    // is set when inserting via ConnectLink()
@@ -542,7 +541,7 @@ bool SdPage::Equals(const SdPage& rOtherPage) const
        mbStopSound != rOtherPage.mbStopSound ||
        maBookmarkName != rOtherPage.maBookmarkName ||
        mbScaleObjects != rOtherPage.mbScaleObjects ||
        mbBackgroundFullSize != rOtherPage.mbBackgroundFullSize ||
        IsBackgroundFullSize() != rOtherPage.IsBackgroundFullSize() || // ???
        meCharSet != rOtherPage.meCharSet ||
        mnPaperBin != rOtherPage.mnPaperBin ||
        mnTransitionType != rOtherPage.mnTransitionType ||
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 6d44b70..6df50ea 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -25,6 +25,7 @@
#include <svx/pageitem.hxx>
#include <svx/svxids.hrc>
#include <svl/itempool.hxx>
#include <svl/grabbagitem.hxx>
#include <sfx2/request.hxx>
#include <vcl/prntypes.hxx>
#include <vcl/graphicfilter.hxx>
@@ -207,6 +208,7 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
                        {SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_OUTER},
                        {SID_ATTR_BORDER_SHADOW, SID_ATTR_BORDER_SHADOW},
                        {XATTR_FILL_FIRST, XATTR_FILL_LAST},
                        {SID_ATTR_CHAR_GRABBAG, SID_ATTR_CHAR_GRABBAG},
                        {SID_ATTR_PAGE_COLOR,SID_ATTR_PAGE_FILLSTYLE},
                        {EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR}});

@@ -256,7 +258,9 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
    bool bFullSize = mpPage->IsMasterPage() ?
        mpPage->IsBackgroundFullSize() : static_cast<SdPage&>(mpPage->TRG_GetMasterPage()).IsBackgroundFullSize();

    aNewAttr.Put( SfxBoolItem( SID_ATTR_PAGE_EXT2, bFullSize ) );
    SfxGrabBagItem grabBag(SID_ATTR_CHAR_GRABBAG);
    grabBag.GetGrabBag()["BackgroundFullSize"] <<= bFullSize;
    aNewAttr.Put(grabBag);

    // Merge ItemSet for dialog

@@ -538,12 +542,16 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
        bScaleAll = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();
    }

    if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_PAGE_EXT2), true, &pPoolItem) == SfxItemState::SET )
    if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_CHAR_GRABBAG, true, &pPoolItem))
    {
        bFullSize = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue();

        if(pMasterPage->IsBackgroundFullSize() != bFullSize )
            bSetPageSizeAndBorder = true;
        SfxGrabBagItem const*const pGrabBag(static_cast<SfxGrabBagItem const*>(pPoolItem));
        if (pGrabBag->GetGrabBag().find("BackgroundFullSize")->second >>= bFullSize)
        {
            if (pMasterPage->IsBackgroundFullSize() != bFullSize)
            {
                bSetPageSizeAndBorder = true;
            }
        }
    }

    // Paper Bin
diff --git a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx
index ab26e2d..563022c 100644
--- a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx
+++ b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx
@@ -57,10 +57,15 @@ namespace sdr::contact
                    rOwnerPage.GetLeftBorder(), rOwnerPage.GetUpperBorder(),
                    rOwnerPage.GetWidth() - rOwnerPage.GetRightBorder(),
                    rOwnerPage.GetHeight() - rOwnerPage.GetLowerBorder());
                const basegfx::B2DPolygon aInnerPolgon(basegfx::utils::createPolygonFromRect(aInnerRange));
                const basegfx::B2DRange aOuterRange(
                    0, 0, rOwnerPage.GetWidth(), rOwnerPage.GetHeight());
                // ??? somehow only the master page's bit is used
                bool const isFullSize(GetMasterPageDescriptor().GetUsedPage().IsBackgroundFullSize());
                const basegfx::B2DPolygon aFillPolygon(
                    basegfx::utils::createPolygonFromRect(isFullSize ? aOuterRange : aInnerRange));
                const drawinglayer::primitive2d::Primitive2DReference xReference(
                    drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
                        basegfx::B2DPolyPolygon(aInnerPolgon),
                        basegfx::B2DPolyPolygon(aFillPolygon),
                        aFill,
                        drawinglayer::attribute::FillGradientAttribute()));

diff --git a/svx/source/sdr/contact/viewcontactofsdrpage.cxx b/svx/source/sdr/contact/viewcontactofsdrpage.cxx
index 80d6ba0..19911ed 100644
--- a/svx/source/sdr/contact/viewcontactofsdrpage.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrpage.cxx
@@ -206,13 +206,17 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfMasterPage::createV
            if(!aFill.isDefault())
            {
                // direct model data is the page size, get and use it
                const basegfx::B2DRange aOuterRange(
                    0, 0, rPage.GetWidth(), rPage.GetHeight());
                const basegfx::B2DRange aInnerRange(
                    rPage.GetLeftBorder(), rPage.GetUpperBorder(),
                    rPage.GetWidth() - rPage.GetRightBorder(), rPage.GetHeight() - rPage.GetLowerBorder());
                const basegfx::B2DPolygon aInnerPolgon(basegfx::utils::createPolygonFromRect(aInnerRange));
                bool const isFullSize(rPage.IsBackgroundFullSize());
                const basegfx::B2DPolygon aFillPolygon(
                    basegfx::utils::createPolygonFromRect(isFullSize ? aOuterRange : aInnerRange));
                const drawinglayer::primitive2d::Primitive2DReference xReference(
                    drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
                        basegfx::B2DPolyPolygon(aInnerPolgon),
                        basegfx::B2DPolyPolygon(aFillPolygon),
                        aFill,
                        drawinglayer::attribute::FillGradientAttribute()));

diff --git a/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
index d27093e..0efa4c01 100644
--- a/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
@@ -62,9 +62,14 @@ namespace sdr::contact

            // used range (retval) is fixed here, it's the MasterPage fill range
            const SdrPage& rOwnerPage = rDescriptor.GetOwnerPage();
            const basegfx::B2DRange aPageFillRange(
            const basegfx::B2DRange aInnerRange(
                rOwnerPage.GetLeftBorder(), rOwnerPage.GetUpperBorder(),
                rOwnerPage.GetWidth() - rOwnerPage.GetRightBorder(), rOwnerPage.GetHeight() - rOwnerPage.GetLowerBorder());
            const basegfx::B2DRange aOuterRange(
                0, 0, rOwnerPage.GetWidth(), rOwnerPage.GetHeight());
            // ??? somehow only the master page's bit is used
            bool const isFullSize(rDescriptor.GetUsedPage().IsBackgroundFullSize());
            basegfx::B2DRange const& rPageFillRange(isFullSize ? aOuterRange : aInnerRange);

            // Modify DisplayInfo for MasterPageContent collection; remember original layers and
            // set combined SdrLayerIDSet; set MasterPagePaint flag
@@ -105,15 +110,15 @@ namespace sdr::contact
                const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
                const basegfx::B2DRange aSubHierarchyRange(xMasterPageSequence.getB2DRange(rViewInformation2D));

                if(aPageFillRange.isInside(aSubHierarchyRange))
                if (rPageFillRange.isInside(aSubHierarchyRange))
                {
                    // completely inside, just render MasterPage content. Add to target
                    xRetval.append(xMasterPageSequence);
                }
                else if(aPageFillRange.overlaps(aSubHierarchyRange))
                else if (rPageFillRange.overlaps(aSubHierarchyRange))
                {
                    // overlapping, compute common area
                    basegfx::B2DRange aCommonArea(aPageFillRange);
                    basegfx::B2DRange aCommonArea(rPageFillRange);
                    aCommonArea.intersect(aSubHierarchyRange);

                    // need to create a clip primitive, add clipped list to target
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 91080e9..02a891f 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1308,6 +1308,7 @@ void SdrPage::lateInit(const SdrPage& rSrcPage)
    mnBorderUpper = rSrcPage.mnBorderUpper;
    mnBorderRight = rSrcPage.mnBorderRight;
    mnBorderLower = rSrcPage.mnBorderLower;
    mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
    nPageNum = rSrcPage.nPageNum;

    if(rSrcPage.TRG_HasMasterPage())
@@ -1495,6 +1496,20 @@ sal_Int32 SdrPage::GetLowerBorder() const
    return mnBorderLower;
}

void SdrPage::SetBackgroundFullSize(bool const bIn)
{
    if (bIn != mbBackgroundFullSize)
    {
        mbBackgroundFullSize = bIn;
        SetChanged();
    }
}

bool SdrPage::IsBackgroundFullSize() const
{
    return mbBackgroundFullSize;
}

// #i68775# React on PageNum changes (from Model in most cases)
void SdrPage::SetPageNum(sal_uInt16 nNew)
{