Resolves: tdf#101711 problems with attempt to remove unused bg images

only do the save, unset (and possibly restore) of a bg image on the
stylesheet if it has one owner, this continue to make the original
scenario function without (so far anyway) the various reported problems

Change-Id: I73382961973b1c53bf2ceff205615727dd378c77
This commit is contained in:
Caolán McNamara
2016-09-30 12:45:03 +01:00
parent 9e1ee599e0
commit 1c1d9867b0
6 changed files with 18 additions and 34 deletions

View File

@@ -590,10 +590,9 @@ class SVX_DLLPUBLIC SdrUndoDelPage : public SdrUndoPageList
SdrUndoGroup* pUndoGroup; SdrUndoGroup* pUndoGroup;
std::unique_ptr<SfxPoolItem> mpFillBitmapItem; std::unique_ptr<SfxPoolItem> mpFillBitmapItem;
bool mbHasFillBitmap; bool mbHasFillBitmap;
bool mbSoleOwnerOfFillBitmapProps;
public: public:
SdrUndoDelPage(SdrPage& rNewPg, bool bSoleOwnerOfFillBitmapProps); SdrUndoDelPage(SdrPage& rNewPg);
virtual ~SdrUndoDelPage() override; virtual ~SdrUndoDelPage() override;
virtual void Undo() override; virtual void Undo() override;
@@ -765,7 +764,7 @@ public:
virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1); virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1);
// Page // Page
virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps = true); virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage);
virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage); virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage);
virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage); virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage);
virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1); virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1);

View File

@@ -59,7 +59,7 @@ namespace rptui
virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1) override; virtual SdrUndoAction* CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1) override;
// page // page
virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps = true) override; virtual SdrUndoAction* CreateUndoDeletePage(SdrPage& rPage) override;
virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage) override; virtual SdrUndoAction* CreateUndoNewPage(SdrPage& rPage) override;
virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage) override; virtual SdrUndoAction* CreateUndoCopyPage(SdrPage& rPage) override;
virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) override; virtual SdrUndoAction* CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) override;

View File

@@ -133,9 +133,9 @@ SdrUndoAction* OReportUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, Sdr
} }
// page // page
SdrUndoAction* OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps) SdrUndoAction* OReportUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
{ {
return m_pUndoFactory->CreateUndoDeletePage(rPage, bSoleOwnerOfFillBitmapProps); return m_pUndoFactory->CreateUndoDeletePage(rPage);
} }
SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage) SdrUndoAction* OReportUndoFactory::CreateUndoNewPage(SdrPage& rPage)

View File

@@ -412,7 +412,7 @@ void ScDrawLayer::ScRemovePage( SCTAB nTab )
if (bRecording) if (bRecording)
{ {
SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab)); SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab));
AddCalcUndo(new SdrUndoDelPage(*pPage, true)); // Undo-Action becomes the page owner AddCalcUndo(new SdrUndoDelPage(*pPage)); // Undo-Action becomes the page owner
RemovePage( static_cast<sal_uInt16>(nTab) ); // just deliver, not deleting RemovePage( static_cast<sal_uInt16>(nTab) ); // just deliver, not deleting
} }
else else

View File

@@ -797,16 +797,7 @@ bool SdDrawDocument::InsertBookmarkAsPage(
eKind == pTest->GetPageKind() ) eKind == pTest->GetPageKind() )
{ {
if( bUndo ) if( bUndo )
{ AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage));
bool bSoleOwnerOfStyleSheet = true;
if (pRefPage->IsMasterPage())
{
const SfxStyleSheet* pRefSheet = pRefPage->getSdrPageProperties().GetStyleSheet();
const SfxStyleSheet* pTestSheet = pTest->getSdrPageProperties().GetStyleSheet();
bSoleOwnerOfStyleSheet = pRefSheet != pTestSheet;
}
AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage, bSoleOwnerOfStyleSheet));
}
RemoveMasterPage(nPage); RemoveMasterPage(nPage);
@@ -1243,7 +1234,6 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, bool bOnl
{ {
// Do not delete master pages that have their precious flag set // Do not delete master pages that have their precious flag set
bool bDeleteMaster = !pMaster->IsPrecious(); bool bDeleteMaster = !pMaster->IsPrecious();
bool bSoleOwnerOfStyleSheet = true;
OUString aLayoutName = pMaster->GetLayoutName(); OUString aLayoutName = pMaster->GetLayoutName();
if(bOnlyDuplicatePages ) if(bOnlyDuplicatePages )
@@ -1258,10 +1248,6 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, bool bOnl
{ {
// duplicate page found -> remove it // duplicate page found -> remove it
bDeleteMaster = true; bDeleteMaster = true;
const SfxStyleSheet* pRefSheet = pMaster->getSdrPageProperties().GetStyleSheet();
const SfxStyleSheet* pTestSheet = pMPg->getSdrPageProperties().GetStyleSheet();
bSoleOwnerOfStyleSheet = pRefSheet != pTestSheet;
} }
} }
} }
@@ -1295,7 +1281,7 @@ void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, bool bOnl
delete pNotesMaster; delete pNotesMaster;
if( bUndo ) if( bUndo )
AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pMaster, bSoleOwnerOfStyleSheet)); AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pMaster));
RemoveMasterPage( pMaster->GetPageNum() ); RemoveMasterPage( pMaster->GetPageNum() );

View File

@@ -1451,11 +1451,10 @@ SdrUndoPageList::~SdrUndoPageList()
} }
SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg, bool bSoleOwnerOfFillBitmapProps) SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg)
: SdrUndoPageList(rNewPg) : SdrUndoPageList(rNewPg)
, pUndoGroup(nullptr) , pUndoGroup(nullptr)
, mbHasFillBitmap(false) , mbHasFillBitmap(false)
, mbSoleOwnerOfFillBitmapProps(bSoleOwnerOfFillBitmapProps)
{ {
bItsMine = true; bItsMine = true;
@@ -1564,11 +1563,11 @@ void SdrUndoDelPage::queryFillBitmap(const SfxItemSet& rItemSet)
void SdrUndoDelPage::clearFillBitmap() void SdrUndoDelPage::clearFillBitmap()
{ {
if (mrPage.IsMasterPage()) if (mrPage.IsMasterPage())
{
if (mbSoleOwnerOfFillBitmapProps)
{ {
SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet(); SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet();
assert(bool(pStyleSheet)); // who took away my stylesheet? assert(bool(pStyleSheet)); // who took away my stylesheet?
if (pStyleSheet->GetListenerCount() == 1)
{
SfxItemSet& rItemSet = pStyleSheet->GetItemSet(); SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
rItemSet.ClearItem(XATTR_FILLBITMAP); rItemSet.ClearItem(XATTR_FILLBITMAP);
if (mbHasFillBitmap) if (mbHasFillBitmap)
@@ -1587,11 +1586,11 @@ void SdrUndoDelPage::clearFillBitmap()
void SdrUndoDelPage::restoreFillBitmap() void SdrUndoDelPage::restoreFillBitmap()
{ {
if (mrPage.IsMasterPage()) if (mrPage.IsMasterPage())
{
if (mbSoleOwnerOfFillBitmapProps)
{ {
SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet(); SfxStyleSheet* const pStyleSheet = mrPage.getSdrPageProperties().GetStyleSheet();
assert(bool(pStyleSheet)); // who took away my stylesheet? assert(bool(pStyleSheet)); // who took away my stylesheet?
if (pStyleSheet->GetListenerCount() == 1)
{
SfxItemSet& rItemSet = pStyleSheet->GetItemSet(); SfxItemSet& rItemSet = pStyleSheet->GetItemSet();
rItemSet.Put(*mpFillBitmapItem); rItemSet.Put(*mpFillBitmapItem);
if (mbHasFillBitmap) if (mbHasFillBitmap)
@@ -1853,9 +1852,9 @@ SdrUndoAction* SdrUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLaye
} }
// page // page
SdrUndoAction* SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage, bool bSoleOwnerOfFillBitmapProps) SdrUndoAction* SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
{ {
return new SdrUndoDelPage(rPage, bSoleOwnerOfFillBitmapProps); return new SdrUndoDelPage(rPage);
} }
SdrUndoAction* SdrUndoFactory::CreateUndoNewPage(SdrPage& rPage) SdrUndoAction* SdrUndoFactory::CreateUndoNewPage(SdrPage& rPage)