diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-03-18 17:43:13 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-03-25 11:11:53 +0100 |
commit | dda83832529fd8c7d02bdf14890faf84a3512112 (patch) | |
tree | 646112ff54839d6bb993ace539dcd2682c58698e /sd | |
parent | ad5a9d3414b9001b3508b9a5d0c8f7947a58250e (diff) |
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>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/inc/sdpage.hxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/background.odp | bin | 0 -> 14126 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 148 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 15 | ||||
-rw-r--r-- | sd/source/core/sdpage2.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/func/fupage.cxx | 20 |
6 files changed, 163 insertions, 27 deletions
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx index d1662ee43308..ae97ff0b18e1 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 Binary files differnew file mode 100644 index 000000000000..f96785dd2fd1 --- /dev/null +++ b/sd/qa/unit/data/odp/background.odp diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 73201189ab81..42e58143f900 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 2be8b854a23c..aaf209a63fe8 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 2719f3dea8f7..1277d1297cb0 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 6d44b70d5a9d..6df50eafbe82 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 |