summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdpage.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/svdraw/svdpage.cxx')
-rw-r--r--svx/source/svdraw/svdpage.cxx215
1 files changed, 158 insertions, 57 deletions
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index e9eeb1428ba8..6dd816d429da 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -66,6 +66,7 @@
#include <svx/sdr/contact/viewobjectcontact.hxx>
#include <svx/sdr/contact/displayinfo.hxx>
#include <algorithm>
+#include <svl/smplhint.hxx>
using namespace ::com::sun::star;
@@ -1165,7 +1166,8 @@ sdr::contact::ViewContact& SdrPage::GetViewContact() const
{
if(!mpViewContact)
{
- ((SdrPage*)this)->mpViewContact = ((SdrPage*)this)->CreateObjectSpecificViewContact();
+ const_cast< SdrPage* >(this)->mpViewContact =
+ const_cast< SdrPage* >(this)->CreateObjectSpecificViewContact();
}
return *mpViewContact;
@@ -1173,6 +1175,140 @@ sdr::contact::ViewContact& SdrPage::GetViewContact() const
////////////////////////////////////////////////////////////////////////////////////////////////////
+void SdrPageProperties::ImpRemoveStyleSheet()
+{
+ if(mpStyleSheet)
+ {
+ EndListening(*mpStyleSheet);
+ mpProperties->SetParent(0);
+ mpStyleSheet = 0;
+ }
+}
+
+void SdrPageProperties::ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet)
+{
+ if(mpStyleSheet != &rNewStyleSheet)
+ {
+ ImpRemoveStyleSheet();
+ mpStyleSheet = &rNewStyleSheet;
+ StartListening(rNewStyleSheet);
+ mpProperties->SetParent(&rNewStyleSheet.GetItemSet());
+ }
+}
+
+void ImpPageChange(SdrPage& rSdrPage)
+{
+ rSdrPage.ActionChanged();
+
+ if(rSdrPage.GetModel())
+ {
+ rSdrPage.GetModel()->SetChanged(true);
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(&rSdrPage);
+ rSdrPage.GetModel()->Broadcast(aHint);
+ }
+}
+
+SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
+: SfxListener(),
+ mpSdrPage(&rSdrPage),
+ mpStyleSheet(0),
+ mpProperties(new SfxItemSet(mpSdrPage->GetModel()->GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST))
+{
+ if(!rSdrPage.IsMasterPage())
+ {
+ mpProperties->Put(XFillStyleItem(XFILL_NONE));
+ }
+}
+
+SdrPageProperties::SdrPageProperties(const SdrPageProperties& rCandidate)
+: SfxListener(),
+ mpSdrPage(rCandidate.mpSdrPage),
+ mpStyleSheet(0),
+ mpProperties(new SfxItemSet(*rCandidate.mpProperties))
+{
+ if(rCandidate.GetStyleSheet())
+ {
+ ImpAddStyleSheet(*rCandidate.GetStyleSheet());
+ }
+}
+
+SdrPageProperties::~SdrPageProperties()
+{
+ ImpRemoveStyleSheet();
+ delete mpProperties;
+}
+
+void SdrPageProperties::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ const SfxSimpleHint* pSimpleHint = dynamic_cast< const SfxSimpleHint* >(&rHint);
+
+ if(pSimpleHint)
+ {
+ switch(pSimpleHint->GetId())
+ {
+ case SFX_HINT_DATACHANGED :
+ {
+ // notify change, broadcast
+ ImpPageChange(*mpSdrPage);
+ break;
+ }
+ case SFX_HINT_DYING :
+ {
+ // Style needs to be forgotten
+ ImpRemoveStyleSheet();
+ break;
+ }
+ }
+ }
+}
+
+const SfxItemSet& SdrPageProperties::GetItemSet() const
+{
+ return *mpProperties;
+}
+
+void SdrPageProperties::PutItemSet(const SfxItemSet& rSet)
+{
+ OSL_ENSURE(!mpSdrPage->IsMasterPage(), "Item set at MasterPage Attributes (!)");
+ mpProperties->Put(rSet);
+ ImpPageChange(*mpSdrPage);
+}
+
+void SdrPageProperties::PutItem(const SfxPoolItem& rItem)
+{
+ OSL_ENSURE(!mpSdrPage->IsMasterPage(), "Item set at MasterPage Attributes (!)");
+ mpProperties->Put(rItem);
+ ImpPageChange(*mpSdrPage);
+}
+
+void SdrPageProperties::ClearItem(const sal_uInt16 nWhich)
+{
+ mpProperties->ClearItem(nWhich);
+ ImpPageChange(*mpSdrPage);
+}
+
+void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet)
+{
+ if(pStyleSheet)
+ {
+ ImpAddStyleSheet(*pStyleSheet);
+ }
+ else
+ {
+ ImpRemoveStyleSheet();
+ }
+
+ ImpPageChange(*mpSdrPage);
+}
+
+SfxStyleSheet* SdrPageProperties::GetStyleSheet() const
+{
+ return mpStyleSheet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
TYPEINIT1(SdrPage,SdrObjList);
DBG_NAME(SdrPage)
SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
@@ -1185,7 +1321,7 @@ SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
nBordRgt(0L),
nBordLwr(0L),
pLayerAdmin(new SdrLayerAdmin(&rNewModel.GetLayerAdmin())),
- pBackgroundObj(0L),
+ mpSdrPageProperties(0),
mpMasterPageDescriptor(0L),
nPageNum(0L),
mbMaster(bMasterPage),
@@ -1197,6 +1333,8 @@ SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
DBG_CTOR(SdrPage,NULL);
aPrefVisiLayers.SetAll();
eListKind = (bMasterPage) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
+
+ mpSdrPageProperties = new SdrPageProperties(*this);
}
SdrPage::SdrPage(const SdrPage& rSrcPage)
@@ -1210,7 +1348,7 @@ SdrPage::SdrPage(const SdrPage& rSrcPage)
nBordRgt(rSrcPage.nBordRgt),
nBordLwr(rSrcPage.nBordLwr),
pLayerAdmin(new SdrLayerAdmin(rSrcPage.pModel->GetLayerAdmin())),
- pBackgroundObj(0L),
+ mpSdrPageProperties(0),
mpMasterPageDescriptor(0L),
nPageNum(rSrcPage.nPageNum),
mbMaster(rSrcPage.mbMaster),
@@ -1244,6 +1382,8 @@ SdrPage::SdrPage(const SdrPage& rSrcPage)
mxUnoPage = NULL;
xComponent->dispose();
}
+
+ mpSdrPageProperties = new SdrPageProperties(rSrcPage.getSdrPageProperties());
}
SdrPage::~SdrPage()
@@ -1277,7 +1417,6 @@ SdrPage::~SdrPage()
// when they get called from PageInDestruction().
maPageUsers.clear();
- SdrObject::Free( pBackgroundObj );
delete pLayerAdmin;
TRG_ClearMasterPage();
@@ -1289,6 +1428,11 @@ SdrPage::~SdrPage()
mpViewContact = 0L;
}
+ {
+ delete mpSdrPageProperties;
+ mpSdrPageProperties = 0;
+ }
+
DBG_DTOR(SdrPage,NULL);
}
@@ -1300,8 +1444,6 @@ void SdrPage::operator=(const SdrPage& rSrcPage)
mpViewContact = 0L;
}
- SdrObject::Free( pBackgroundObj );
-
// Joe also sets some parameters for the class this one
// is derived from. SdrObjList does the same bad handling of
// copy constructor and operator=, so i better let it stand here.
@@ -1335,14 +1477,9 @@ void SdrPage::operator=(const SdrPage& rSrcPage)
mbObjectsNotPersistent = rSrcPage.mbObjectsNotPersistent;
- if(rSrcPage.pBackgroundObj)
{
- pBackgroundObj = rSrcPage.pBackgroundObj->Clone();
- pBackgroundObj->SetPage( this );
- pBackgroundObj->SetModel( pModel );
-
- // #i62000# for single-page MPBGO, force no line
- pBackgroundObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ delete mpSdrPageProperties;
+ mpSdrPageProperties = new SdrPageProperties(rSrcPage.getSdrPageProperties());
}
// Now copy the contained obejcts (by cloning them)
@@ -1522,8 +1659,9 @@ void SdrPage::SetModel(SdrModel* pNewModel)
}
pLayerAdmin->SetModel(pNewModel);
- if( pBackgroundObj )
- pBackgroundObj->SetModel( pNewModel );
+ SdrPageProperties *pNew = new SdrPageProperties(getSdrPageProperties());
+ delete mpSdrPageProperties;
+ mpSdrPageProperties = pNew;
}
// update listeners at possible api wrapper object
@@ -1657,22 +1795,6 @@ XubString SdrPage::GetLayoutName() const
return String();
}
-void SdrPage::SetBackgroundObj( SdrObject* pObj )
-{
- if ( pObj )
- {
- pObj->SetPage( this );
- pObj->SetModel( pModel );
- pObj->SetLayer( 1 ); // Nothing known about the backgroundlayer...
-
- // #i62000# for single-page MPBGO, force no line
- pObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
- }
-
- SdrObject::Free( pBackgroundObj );
- pBackgroundObj = pObj;
-}
-
void SdrPage::SetInserted( bool bIns )
{
if( mbInserted != bIns )
@@ -1746,38 +1868,17 @@ Color SdrPage::GetPageBackgroundColor( SdrPageView* pView, bool bScreenDisplay )
aColor = pView->GetApplicationDocumentColor();
}
- // first, see if we have a background object
- SdrObject* pBackgroundObj2 = NULL;
-
+ const SfxItemSet* pBackgroundFill = &getSdrPageProperties().GetItemSet();
- if( IsMasterPage() )
- {
- if( GetObjCount() )
- pBackgroundObj2 = GetObj( 0 );
- }
- else
+ if(!IsMasterPage() && TRG_HasMasterPage())
{
- pBackgroundObj2 = GetBackgroundObj();
- if( NULL == pBackgroundObj2 )
+ if(XFILL_NONE == ((const XFillStyleItem&)pBackgroundFill->Get(XATTR_FILLSTYLE)).GetValue())
{
- // if not, see if we have a masterpage and get that background object
- if(TRG_HasMasterPage())
- {
- SdrPage& rMasterPage = TRG_GetMasterPage();
-
- if(rMasterPage.GetObjCount())
- {
- pBackgroundObj2 = rMasterPage.GetObj( 0 );
- }
- }
+ pBackgroundFill = &TRG_GetMasterPage().getSdrPageProperties().GetItemSet();
}
}
- if( pBackgroundObj2 )
- {
- const SfxItemSet& rSet = pBackgroundObj2->GetMergedItemSet();
- GetDraftFillColor( rSet, aColor );
- }
+ GetDraftFillColor(*pBackgroundFill, aColor);
return aColor;
}