66bd0b5
From de4908eb4d2f1f2ce38a37eea18a9efc4a0073b1 Mon Sep 17 00:00:00 2001
66bd0b5
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
66bd0b5
Date: Wed, 6 Jul 2016 10:10:27 +0100
66bd0b5
Subject: [PATCH] Resolves: rhbz#1353069 don't clear XATTR_FILL* from
66bd0b5
 stylesheet if...
66bd0b5
66bd0b5
the master page is not the sole owner. Which happens when copying
66bd0b5
and pasting slides which bring along a duplicate master page to
66bd0b5
an already existing one, and the attempt to remove the duplicate
66bd0b5
strips the fill properties from the shared stylesheet in use by
66bd0b5
the other
66bd0b5
66bd0b5
regression from...
66bd0b5
66bd0b5
commit b876bbe2cacce8af379b10d82da6c7e7d229b361
66bd0b5
Author: David Tardon <dtardon@redhat.com>
66bd0b5
Date:   Tue Apr 26 09:17:11 2016 +0200
66bd0b5
66bd0b5
    rbhz#1326602 avoid exp. bg bitmaps from deleted slides
66bd0b5
66bd0b5
Change-Id: I91fb8f622a0e35741ecc37cef14fc93199bb730b
66bd0b5
---
66bd0b5
 include/svx/svdundo.hxx                            |  5 +--
66bd0b5
 reportdesign/source/core/inc/ReportUndoFactory.hxx |  2 +-
66bd0b5
 reportdesign/source/core/sdr/ReportUndoFactory.cxx |  4 +--
66bd0b5
 sc/source/core/data/drwlayer.cxx                   |  2 +-
66bd0b5
 sd/source/core/drawdoc3.cxx                        | 13 ++++++--
66bd0b5
 svx/source/svdraw/svdundo.cxx                      | 37 +++++++++++++---------
66bd0b5
 6 files changed, 40 insertions(+), 23 deletions(-)
66bd0b5
66bd0b5
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
66bd0b5
index dc09f22..9d63557 100644
66bd0b5
--- a/include/svx/svdundo.hxx
66bd0b5
+++ b/include/svx/svdundo.hxx
66bd0b5
@@ -588,9 +588,10 @@ class SVX_DLLPUBLIC SdrUndoDelPage : public SdrUndoPageList
66bd0b5
     SdrUndoGroup*               pUndoGroup;
66bd0b5
     std::unique_ptr<SfxPoolItem> mpFillBitmapItem;
66bd0b5
     bool mbHasFillBitmap;
66bd0b5
+    bool mbSoleOwnerOfFillBitmapProps;
66bd0b5
 
66bd0b5
 public:
66bd0b5
-    SdrUndoDelPage(SdrPage& rNewPg);
66bd0b5
+    SdrUndoDelPage(SdrPage& rNewPg, bool bSoleOwnerOfFillBitmapProps);
66bd0b5
     virtual ~SdrUndoDelPage();
66bd0b5
 
66bd0b5
     virtual void Undo() override;
66bd0b5
@@ -762,7 +763,7 @@ public:
66bd0b5
     virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1);
66bd0b5
 
66bd0b5
     // Page
66bd0b5
-    virtual SdrUndoAction*  CreateUndoDeletePage(SdrPage& rPage);
66bd0b5
+    virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps = true);
66bd0b5
     virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage);
66bd0b5
     virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage);
66bd0b5
     virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1);
66bd0b5
diff --git a/reportdesign/source/core/inc/ReportUndoFactory.hxx b/reportdesign/source/core/inc/ReportUndoFactory.hxx
66bd0b5
index 88d0024..1839f1f 100644
66bd0b5
--- a/reportdesign/source/core/inc/ReportUndoFactory.hxx
66bd0b5
+++ b/reportdesign/source/core/inc/ReportUndoFactory.hxx
66bd0b5
@@ -59,7 +59,7 @@ namespace rptui
66bd0b5
         virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1) override;
66bd0b5
 
66bd0b5
         // page
66bd0b5
-        virtual SdrUndoAction*  CreateUndoDeletePage(SdrPage& rPage) override;
66bd0b5
+        virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps = true) override;
66bd0b5
         virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage) override;
66bd0b5
         virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage) override;
66bd0b5
         virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) override;
66bd0b5
diff --git a/reportdesign/source/core/sdr/ReportUndoFactory.cxx b/reportdesign/source/core/sdr/ReportUndoFactory.cxx
66bd0b5
index cbb5a8a..566400c 100644
66bd0b5
--- a/reportdesign/source/core/sdr/ReportUndoFactory.cxx
66bd0b5
+++ b/reportdesign/source/core/sdr/ReportUndoFactory.cxx
66bd0b5
@@ -133,9 +133,9 @@ SdrUndoAction* OReportUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, Sdr
66bd0b5
 }
66bd0b5
 
66bd0b5
 // page
66bd0b5
-SdrUndoAction*  OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
66bd0b5
+SdrUndoAction*  OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps)
66bd0b5
 {
66bd0b5
-    return m_pUndoFactory->CreateUndoDeletePage( rPage );
66bd0b5
+    return m_pUndoFactory->CreateUndoDeletePage(rPage, bSoleOwnerOfFillBitmapProps);
66bd0b5
 }
66bd0b5
 
66bd0b5
 SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)
66bd0b5
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
66bd0b5
index 7ea6758..b2c7ab9 100644
66bd0b5
--- a/sc/source/core/data/drwlayer.cxx
66bd0b5
+++ b/sc/source/core/data/drwlayer.cxx
66bd0b5
@@ -412,7 +412,7 @@ void ScDrawLayer::ScRemovePage( SCTAB nTab )
66bd0b5
     if (bRecording)
66bd0b5
     {
66bd0b5
         SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
66bd0b5
-        AddCalcUndo(new SdrUndoDelPage(*pPage));        // Undo-Action becomes the page owner
66bd0b5
+        AddCalcUndo(new SdrUndoDelPage(*pPage, true));  // Undo-Action becomes the page owner
66bd0b5
         RemovePage( static_cast<sal_uInt16>(nTab) );    // just deliver, not deleting
66bd0b5
     }
66bd0b5
     else
66bd0b5
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
66bd0b5
index cf01895..d857b38 100644
66bd0b5
--- a/sd/source/core/drawdoc3.cxx
66bd0b5
+++ b/sd/source/core/drawdoc3.cxx
66bd0b5
@@ -792,8 +792,17 @@ bool SdDrawDocument::InsertBookmarkAsPage(
66bd0b5
                  aTest == aMPLayout &&
66bd0b5
                  eKind == pTest->GetPageKind() )
66bd0b5
             {
66bd0b5
-                if( bUndo )
66bd0b5
-                    AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
66bd0b5
+                if (bUndo)
66bd0b5
+                {
66bd0b5
+                    bool bSoleOwnerOfStyleSheet = true;
66bd0b5
+                    if (pRefPage->IsMasterPage())
66bd0b5
+                    {
66bd0b5
+                        const SfxStyleSheet* pRefSheet = pRefPage->getSdrPageProperties().GetStyleSheet();
66bd0b5
+                        const SfxStyleSheet* pTestSheet = pTest->getSdrPageProperties().GetStyleSheet();
66bd0b5
+                        bSoleOwnerOfStyleSheet = pRefSheet != pTestSheet;
66bd0b5
+                    }
66bd0b5
+                    AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage, bSoleOwnerOfStyleSheet));
66bd0b5
+                }
66bd0b5
 
66bd0b5
                 RemoveMasterPage(nPage);
66bd0b5
 
66bd0b5
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
66bd0b5
index abc459f..ec5f2fe 100644
66bd0b5
--- a/svx/source/svdraw/svdundo.cxx
66bd0b5
+++ b/svx/source/svdraw/svdundo.cxx
66bd0b5
@@ -1444,10 +1444,11 @@ SdrUndoPageList::~SdrUndoPageList()
66bd0b5
 }
66bd0b5
 
66bd0b5
 
66bd0b5
-SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg)
66bd0b5
+SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg, bool bSoleOwnerOfFillBitmapProps)
66bd0b5
     : SdrUndoPageList(rNewPg)
66bd0b5
     , pUndoGroup(nullptr)
66bd0b5
     , mbHasFillBitmap(false)
66bd0b5
+    , mbSoleOwnerOfFillBitmapProps(bSoleOwnerOfFillBitmapProps)
66bd0b5
 {
66bd0b5
     bItsMine = true;
66bd0b5
 
66bd0b5
@@ -1557,12 +1558,15 @@ void SdrUndoDelPage::clearFillBitmap()
66bd0b5
 {
66bd0b5
     if (mrPage.IsMasterPage())
66bd0b5
     {
66bd0b5
-        SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet();
66bd0b5
-        assert(bool(pStyleSheet)); // who took away my stylesheet?
66bd0b5
-        SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
66bd0b5
-        rItemSet.ClearItem(XATTR_FILLBITMAP);
66bd0b5
-        if (mbHasFillBitmap)
66bd0b5
-            rItemSet.ClearItem(XATTR_FILLSTYLE);
66bd0b5
+        if (mbSoleOwnerOfFillBitmapProps)
66bd0b5
+        {
66bd0b5
+            SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet();
66bd0b5
+            assert(bool(pStyleSheet)); // who took away my stylesheet?
66bd0b5
+            SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
66bd0b5
+            rItemSet.ClearItem(XATTR_FILLBITMAP);
66bd0b5
+            if (mbHasFillBitmap)
66bd0b5
+                rItemSet.ClearItem(XATTR_FILLSTYLE);
66bd0b5
+        }
66bd0b5
     }
66bd0b5
     else
66bd0b5
     {
66bd0b5
@@ -1577,12 +1581,15 @@ void SdrUndoDelPage::restoreFillBitmap()
66bd0b5
 {
66bd0b5
     if (mrPage.IsMasterPage())
66bd0b5
     {
66bd0b5
-        SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet();
66bd0b5
-        assert(bool(pStyleSheet)); // who took away my stylesheet?
66bd0b5
-        SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
66bd0b5
-        rItemSet.Put(*mpFillBitmapItem);
66bd0b5
-        if (mbHasFillBitmap)
66bd0b5
-            rItemSet.Put(XFillStyleItem(css::drawing::FillStyle_BITMAP));
66bd0b5
+        if (mbSoleOwnerOfFillBitmapProps)
66bd0b5
+        {
66bd0b5
+            SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet();
66bd0b5
+            assert(bool(pStyleSheet)); // who took away my stylesheet?
66bd0b5
+            SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
66bd0b5
+            rItemSet.Put(*mpFillBitmapItem);
66bd0b5
+            if (mbHasFillBitmap)
66bd0b5
+                rItemSet.Put(XFillStyleItem(css::drawing::FillStyle_BITMAP));
66bd0b5
+        }
66bd0b5
     }
66bd0b5
     else
66bd0b5
     {
66bd0b5
@@ -1839,9 +1846,9 @@ SdrUndoAction* SdrUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLaye
66bd0b5
 }
66bd0b5
 
66bd0b5
 // page
66bd0b5
-SdrUndoAction*  SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
66bd0b5
+SdrUndoAction*  SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps)
66bd0b5
 {
66bd0b5
-    return new SdrUndoDelPage( rPage );
66bd0b5
+    return new SdrUndoDelPage(rPage, bSoleOwnerOfFillBitmapProps);
66bd0b5
 }
66bd0b5
 
66bd0b5
 SdrUndoAction* SdrUndoFactory::CreateUndoNewPage(SdrPage& rPage)
66bd0b5
-- 
66bd0b5
2.7.4
66bd0b5