Kaydet (Commit) 6b575298 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Kohei Yoshida

Use std::unique_ptr for mpViewContact member instance of SdrPage.

And fix some const-incorrect-ness while at it.

Change-Id: I0314c8e5b73f1a7edce040b2a57fbc5d1081d70c
Reviewed-on: https://gerrit.libreoffice.org/20815Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
Tested-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst c1aca008
...@@ -34,7 +34,7 @@ class SVX_DLLPUBLIC ObjectContactPainter : public ObjectContact ...@@ -34,7 +34,7 @@ class SVX_DLLPUBLIC ObjectContactPainter : public ObjectContact
protected: protected:
// Hierarchy access methods // Hierarchy access methods
virtual sal_uInt32 GetPaintObjectCount() const = 0; virtual sal_uInt32 GetPaintObjectCount() const = 0;
virtual ViewContact& GetPaintObjectViewContact(sal_uInt32 nIndex) const = 0; virtual ViewContact& GetPaintObjectViewContact(sal_uInt32 nIndex) = 0;
public: public:
// basic constructor/destructor // basic constructor/destructor
...@@ -59,7 +59,7 @@ protected: ...@@ -59,7 +59,7 @@ protected:
// Hierarchy access methods // Hierarchy access methods
virtual sal_uInt32 GetPaintObjectCount() const override; virtual sal_uInt32 GetPaintObjectCount() const override;
virtual ViewContact& GetPaintObjectViewContact(sal_uInt32 nIndex) const override; virtual ViewContact& GetPaintObjectViewContact(sal_uInt32 nIndex) override;
public: public:
// basic constructor/destructor // basic constructor/destructor
...@@ -95,7 +95,7 @@ protected: ...@@ -95,7 +95,7 @@ protected:
// Hierarchy access methods // Hierarchy access methods
virtual sal_uInt32 GetPaintObjectCount() const override; virtual sal_uInt32 GetPaintObjectCount() const override;
virtual ViewContact& GetPaintObjectViewContact(sal_uInt32 nIndex) const override; virtual ViewContact& GetPaintObjectViewContact(sal_uInt32 nIndex) override;
public: public:
// basic constructor // basic constructor
...@@ -107,6 +107,7 @@ public: ...@@ -107,6 +107,7 @@ public:
// set another page // set another page
void SetStartPage(const SdrPage* pPage); void SetStartPage(const SdrPage* pPage);
const SdrPage* GetStartPage() const { return mxStartPage.get(); } const SdrPage* GetStartPage() const { return mxStartPage.get(); }
SdrPage* GetStartPage() { return mxStartPage.get(); }
virtual OutputDevice* TryToGetOutputDevice() const override; virtual OutputDevice* TryToGetOutputDevice() const override;
}; };
......
...@@ -375,6 +375,14 @@ public: ...@@ -375,6 +375,14 @@ public:
*/ */
class SVX_DLLPUBLIC SdrPage : public SdrObjList, public tools::WeakBase< SdrPage > class SVX_DLLPUBLIC SdrPage : public SdrObjList, public tools::WeakBase< SdrPage >
{ {
// #i9076#
friend class SdrModel;
friend class SvxUnoDrawPagesAccess;
// this class uses its own UNO wrapper
// and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
friend class reportdesign::OSection;
SdrPage& operator=(const SdrPage& rSrcPage) = delete; SdrPage& operator=(const SdrPage& rSrcPage) = delete;
// start PageUser section // start PageUser section
...@@ -382,32 +390,20 @@ private: ...@@ -382,32 +390,20 @@ private:
// #111111# PageUser section // #111111# PageUser section
sdr::PageUserVector maPageUsers; sdr::PageUserVector maPageUsers;
std::unique_ptr<sdr::contact::ViewContact> mpViewContact;
public: public:
void AddPageUser(sdr::PageUser& rNewUser); void AddPageUser(sdr::PageUser& rNewUser);
void RemovePageUser(sdr::PageUser& rOldUser); void RemovePageUser(sdr::PageUser& rOldUser);
// end PageUser section
// #110094# DrawContact section
private:
sdr::contact::ViewContact* mpViewContact;
protected: protected:
sdr::contact::ViewContact* CreateObjectSpecificViewContact(); sdr::contact::ViewContact* CreateObjectSpecificViewContact();
public: public:
sdr::contact::ViewContact& GetViewContact() const; const sdr::contact::ViewContact& GetViewContact() const;
sdr::contact::ViewContact& GetViewContact();
// #110094# DrawContact support: Methods for handling Page changes // #110094# DrawContact support: Methods for handling Page changes
void ActionChanged() const; void ActionChanged();
// #i9076#
friend class SdrModel;
friend class SvxUnoDrawPagesAccess;
// this class uses its own UNO wrapper
// and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
friend class reportdesign::OSection;
sal_Int32 nWdt; // Seitengroesse sal_Int32 nWdt; // Seitengroesse
sal_Int32 nHgt; // Seitengroesse sal_Int32 nHgt; // Seitengroesse
......
...@@ -45,7 +45,7 @@ sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const ...@@ -45,7 +45,7 @@ sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
return maStartObjects.size(); return maStartObjects.size();
} }
ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex)
{ {
const SdrObject* pObj = maStartObjects[nIndex]; const SdrObject* pObj = maStartObjects[nIndex];
DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)"); DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
...@@ -157,7 +157,7 @@ sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const ...@@ -157,7 +157,7 @@ sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const
return (GetStartPage() ? 1L : 0L); return (GetStartPage() ? 1L : 0L);
} }
ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/)
{ {
DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)"); DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
return GetStartPage()->GetViewContact(); return GetStartPage()->GetViewContact();
......
...@@ -120,7 +120,7 @@ void PagePrimitiveExtractor::Invoke() ...@@ -120,7 +120,7 @@ void PagePrimitiveExtractor::Invoke()
drawinglayer::primitive2d::Primitive2DContainer PagePrimitiveExtractor::createPrimitive2DSequenceForPage(const DisplayInfo& /*rDisplayInfo*/) drawinglayer::primitive2d::Primitive2DContainer PagePrimitiveExtractor::createPrimitive2DSequenceForPage(const DisplayInfo& /*rDisplayInfo*/)
{ {
drawinglayer::primitive2d::Primitive2DContainer xRetval; drawinglayer::primitive2d::Primitive2DContainer xRetval;
const SdrPage* pStartPage = GetStartPage(); SdrPage* pStartPage = GetStartPage();
if(pStartPage) if(pStartPage)
{ {
......
...@@ -1061,18 +1061,22 @@ sdr::contact::ViewContact* SdrPage::CreateObjectSpecificViewContact() ...@@ -1061,18 +1061,22 @@ sdr::contact::ViewContact* SdrPage::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfSdrPage(*this); return new sdr::contact::ViewContactOfSdrPage(*this);
} }
sdr::contact::ViewContact& SdrPage::GetViewContact() const const sdr::contact::ViewContact& SdrPage::GetViewContact() const
{ {
if(!mpViewContact) if (!mpViewContact)
{ const_cast<SdrPage*>(this)->mpViewContact.reset(
const_cast< SdrPage* >(this)->mpViewContact = const_cast<SdrPage*>(this)->CreateObjectSpecificViewContact());
const_cast< SdrPage* >(this)->CreateObjectSpecificViewContact();
}
return *mpViewContact; return *mpViewContact;
} }
sdr::contact::ViewContact& SdrPage::GetViewContact()
{
if (!mpViewContact)
mpViewContact.reset(CreateObjectSpecificViewContact());
return *mpViewContact;
}
void SdrPageProperties::ImpRemoveStyleSheet() void SdrPageProperties::ImpRemoveStyleSheet()
{ {
...@@ -1273,11 +1277,7 @@ SdrPage::~SdrPage() ...@@ -1273,11 +1277,7 @@ SdrPage::~SdrPage()
TRG_ClearMasterPage(); TRG_ClearMasterPage();
if(mpViewContact) mpViewContact.reset();
{
delete mpViewContact;
mpViewContact = nullptr;
}
{ {
delete mpSdrPageProperties; delete mpSdrPageProperties;
...@@ -1780,7 +1780,7 @@ bool SdrPage::checkVisibility( ...@@ -1780,7 +1780,7 @@ bool SdrPage::checkVisibility(
} }
// DrawContact support: Methods for handling Page changes // DrawContact support: Methods for handling Page changes
void SdrPage::ActionChanged() const void SdrPage::ActionChanged()
{ {
// Do necessary ViewContact actions // Do necessary ViewContact actions
GetViewContact().ActionChanged(); GetViewContact().ActionChanged();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment