summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2014-12-04 21:39:43 +0100
committerDavid Tardon <dtardon@redhat.com>2014-12-04 23:10:25 +0100
commit51bacc6a065f380a26b8cc2e5c18ff0ab4162ac3 (patch)
treeb42a463a134ff18ddac578dc88066d282268c4eb /sw
parent9638e6207c7fc48712b1b238177462c00f5011e8 (diff)
impl. Clone for all subclasses of SdrPage
Change-Id: Ie370161e51ff83cb605bc57d317ff945404e5611
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/dpage.hxx12
-rw-r--r--sw/source/core/draw/dpage.cxx54
2 files changed, 61 insertions, 5 deletions
diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx
index 8284f6e458e7..82078ce9c9a2 100644
--- a/sw/inc/dpage.hxx
+++ b/sw/inc/dpage.hxx
@@ -28,16 +28,18 @@ class SwDoc;
class SwDPage : public FmFormPage, public SdrObjUserCall
{
- SwDPage(const SwDPage&) SAL_DELETED_FUNCTION;
SwDPage &operator=(const SwDPage&) SAL_DELETED_FUNCTION;
SdrPageGridFrameList* pGridLst;
- SwDoc& rDoc;
+ SwDoc* pDoc;
public:
SwDPage(SwDrawModel& rNewModel, bool bMasterPage=false);
virtual ~SwDPage();
+ virtual SwDPage* Clone() const SAL_OVERRIDE;
+ virtual SwDPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE;
+
// #i3694#
// This GetOffset() method is not needed anymore, it even leads to errors.
// virtual Point GetOffset() const;
@@ -49,6 +51,12 @@ public:
bool RequestHelp( vcl::Window* pWindow, SdrView* pView, const HelpEvent& rEvt );
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage() SAL_OVERRIDE;
+
+protected:
+ void lateInit(const SwDPage& rPage, SwDrawModel* pNewModel = 0);
+
+private:
+ SwDPage(const SwDPage& rSrcPage);
};
#endif // INCLUDED_SW_INC_DPAGE_HXX
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index 048394c4f2d3..df6f577e1a3e 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -52,15 +52,59 @@ using namespace ::com::sun::star::frame;
SwDPage::SwDPage(SwDrawModel& rNewModel, bool bMasterPage) :
FmFormPage(rNewModel, bMasterPage),
pGridLst( 0 ),
- rDoc(rNewModel.GetDoc())
+ pDoc(&rNewModel.GetDoc())
{
}
+SwDPage::SwDPage(const SwDPage& rSrcPage) :
+ FmFormPage( rSrcPage ),
+ pGridLst( 0 ),
+ pDoc( 0 )
+{
+ if ( rSrcPage.pGridLst )
+ {
+ pGridLst = new SdrPageGridFrameList;
+ for ( sal_uInt16 i = 0; i != rSrcPage.pGridLst->GetCount(); ++i )
+ pGridLst->Insert( ( *rSrcPage.pGridLst )[ i ] );
+ }
+}
+
SwDPage::~SwDPage()
{
delete pGridLst;
}
+void SwDPage::lateInit(const SwDPage& rPage, SwDrawModel* const pNewModel)
+{
+ FmFormPage::lateInit( rPage, pNewModel );
+
+ SwDrawModel* pSwDrawModel = pNewModel;
+ if ( !pModel )
+ {
+ pSwDrawModel = dynamic_cast< SwDrawModel* >( GetModel() );
+ assert( pSwDrawModel );
+ }
+ pDoc = &pSwDrawModel->GetDoc();
+}
+
+SwDPage* SwDPage::Clone() const
+{
+ return Clone( 0 );
+}
+
+SwDPage* SwDPage::Clone(SdrModel* const pNewModel) const
+{
+ SwDPage* const pNewPage = new SwDPage( *this );
+ SwDrawModel* pSwDrawModel = 0;
+ if ( pNewModel )
+ {
+ pSwDrawModel = dynamic_cast< SwDrawModel* >( pNewModel );
+ assert( pSwDrawModel );
+ }
+ pNewPage->lateInit( *this, pSwDrawModel );
+ return pNewPage;
+}
+
SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, size_t nObjNum )
{
SdrObject *pOld = GetObj( nObjNum );
@@ -122,6 +166,8 @@ const SdrPageGridFrameList* SwDPage::GetGridFrameList(
bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
const HelpEvent& rEvt )
{
+ assert( pDoc );
+
bool bContinue = true;
if( rEvt.GetMode() & ( HelpEventMode::QUICK | HelpEventMode::BALLOON ))
@@ -173,7 +219,7 @@ bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
if ( !sTxt.isEmpty() )
{
// #i80029#
- bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly();
+ bool bExecHyperlinks = pDoc->GetDocShell()->IsReadOnly();
if ( !bExecHyperlinks )
{
SvtSecurityOptions aSecOpts;
@@ -208,8 +254,10 @@ bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
Reference< XInterface > SwDPage::createUnoPage()
{
+ assert( pDoc );
+
Reference < XInterface > xRet;
- SwDocShell* pDocShell = rDoc.GetDocShell();
+ SwDocShell* pDocShell = pDoc->GetDocShell();
if ( pDocShell )
{
Reference<XModel> xModel = pDocShell->GetBaseModel();