diff options
author | David Tardon <dtardon@redhat.com> | 2016-04-26 09:17:11 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2016-05-02 06:54:30 +0200 |
commit | b876bbe2cacce8af379b10d82da6c7e7d229b361 (patch) | |
tree | 455fab6400a107149e6136f0bef995f115da17e0 /sd | |
parent | 859c00663f79d81b28f08a7c24a7aebddd8b7ffe (diff) |
rbhz#1326602 avoid exp. bg bitmaps from deleted slides
ODF export uses SvxUnoBitmapTable (impl. of
com.sun.star.drawing.BitmapTable) to create fill bitmap styles. That
returns all XATTR_FILLBITMAP items that are in the document's pool. So
we ensure that bitmaps that are only used on deleted (either explicitly
or by undoing their insertion) slides are not in the pool.
Change-Id: I54c594a94989158f22b156fe660c1e716b988b3e
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/func/undoback.cxx | 43 | ||||
-rw-r--r-- | sd/source/ui/inc/undoback.hxx | 6 |
2 files changed, 47 insertions, 2 deletions
diff --git a/sd/source/ui/func/undoback.cxx b/sd/source/ui/func/undoback.cxx index 126101fba2be..704b551c7469 100644 --- a/sd/source/ui/func/undoback.cxx +++ b/sd/source/ui/func/undoback.cxx @@ -21,8 +21,14 @@ #include "sdpage.hxx" #include "sdresid.hxx" #include "strings.hrc" + +#include <com/sun/star/drawing/FillStyle.hpp> + +#include <o3tl/make_unique.hxx> + #include <svl/itemset.hxx> +#include <svx/xfillit0.hxx> SdBackgroundObjUndoAction::SdBackgroundObjUndoAction( SdDrawDocument& rDoc, @@ -30,10 +36,12 @@ SdBackgroundObjUndoAction::SdBackgroundObjUndoAction( const SfxItemSet& rItenSet) : SdUndoAction(&rDoc), mrPage(rPage), - mpItemSet(new SfxItemSet(rItenSet)) + mpItemSet(new SfxItemSet(rItenSet)), + mbHasFillBitmap(false) { OUString aString( SdResId( STR_UNDO_CHANGE_PAGEFORMAT ) ); SetComment( aString ); + saveFillBitmap(*mpItemSet); } SdBackgroundObjUndoAction::~SdBackgroundObjUndoAction() @@ -45,9 +53,14 @@ void SdBackgroundObjUndoAction::ImplRestoreBackgroundObj() { SfxItemSet* pNew = new SfxItemSet(mrPage.getSdrPageProperties().GetItemSet()); mrPage.getSdrPageProperties().ClearItem(); + if (bool(mpFillBitmapItem)) + restoreFillBitmap(*mpItemSet); + mpFillBitmapItem.reset(); + mbHasFillBitmap = false; mrPage.getSdrPageProperties().PutItemSet(*mpItemSet); delete mpItemSet; mpItemSet = pNew; + saveFillBitmap(*mpItemSet); // tell the page that it's visualization has changed mrPage.ActionChanged(); @@ -65,7 +78,33 @@ void SdBackgroundObjUndoAction::Redo() SdUndoAction* SdBackgroundObjUndoAction::Clone() const { - return new SdBackgroundObjUndoAction(*mpDoc, mrPage, *mpItemSet); + std::unique_ptr<SdBackgroundObjUndoAction> pCopy = o3tl::make_unique<SdBackgroundObjUndoAction>(*mpDoc, mrPage, *mpItemSet); + if (mpFillBitmapItem) + pCopy->mpFillBitmapItem.reset(mpFillBitmapItem->Clone()); + pCopy->mbHasFillBitmap = mbHasFillBitmap; + return pCopy.release(); +} + +void SdBackgroundObjUndoAction::saveFillBitmap(SfxItemSet &rItemSet) +{ + const SfxPoolItem *pItem = nullptr; + if (rItemSet.GetItemState(XATTR_FILLBITMAP, false, &pItem) == SfxItemState::SET) + mpFillBitmapItem.reset(pItem->Clone()); + if (bool(mpFillBitmapItem)) + { + if (rItemSet.GetItemState(XATTR_FILLSTYLE, false, &pItem) == SfxItemState::SET) + mbHasFillBitmap = static_cast<const XFillStyleItem*>(pItem)->GetValue() == css::drawing::FillStyle_BITMAP; + rItemSet.ClearItem(XATTR_FILLBITMAP); + if (mbHasFillBitmap) + rItemSet.ClearItem(XATTR_FILLSTYLE); + } +} + +void SdBackgroundObjUndoAction::restoreFillBitmap(SfxItemSet &rItemSet) +{ + rItemSet.Put(*mpFillBitmapItem); + if (mbHasFillBitmap) + rItemSet.Put(XFillStyleItem(css::drawing::FillStyle_BITMAP)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/undoback.hxx b/sd/source/ui/inc/undoback.hxx index 3b1553b4d239..35370ca01627 100644 --- a/sd/source/ui/inc/undoback.hxx +++ b/sd/source/ui/inc/undoback.hxx @@ -20,11 +20,13 @@ #ifndef INCLUDED_SD_SOURCE_UI_INC_UNDOBACK_HXX #define INCLUDED_SD_SOURCE_UI_INC_UNDOBACK_HXX +#include <memory> #include "sdundo.hxx" class SdDrawDocument; class SdPage; class SfxItemSet; +class SfxPoolItem; // SdBackgroundObjUndoAction class SdBackgroundObjUndoAction : public SdUndoAction @@ -33,8 +35,12 @@ private: SdPage& mrPage; SfxItemSet* mpItemSet; + std::unique_ptr<SfxPoolItem> mpFillBitmapItem; + bool mbHasFillBitmap; void ImplRestoreBackgroundObj(); + void saveFillBitmap(SfxItemSet &rItemSet); + void restoreFillBitmap(SfxItemSet &rItemSet); public: |