Kaydet (Commit) 51bacc6a authored tarafından David Tardon's avatar David Tardon

impl. Clone for all subclasses of SdrPage

Change-Id: Ie370161e51ff83cb605bc57d317ff945404e5611
üst 9638e620
......@@ -46,9 +46,20 @@ DlgEdPage::~DlgEdPage()
SdrPage* DlgEdPage::Clone() const
{
return Clone(0);
}
SdrPage* DlgEdPage::Clone(SdrModel* const pNewModel) const
{
DlgEdPage* const pNewPage = new DlgEdPage( *this );
pNewPage->lateInit( *this );
DlgEdModel* pDlgEdModel = 0;
if ( pNewModel )
{
pDlgEdModel = dynamic_cast<DlgEdModel*>( pNewModel );
assert(pDlgEdModel);
}
pNewPage->lateInit( *this, pDlgEdModel );
return pNewPage;
}
......
......@@ -45,8 +45,8 @@ public:
DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false );
virtual ~DlgEdPage();
using SdrPage::Clone;
virtual SdrPage* Clone() const SAL_OVERRIDE;
virtual SdrPage* Clone( SdrModel* pNewModel ) const SAL_OVERRIDE;
void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; }
DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; }
......
......@@ -55,8 +55,7 @@ public:
virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
virtual SdrPage* Clone() const SAL_OVERRIDE;
// TODO: Uh huh, how is this supposed to work? Creating a SdrPage from FmFormPage?
using SdrPage::Clone;
virtual SdrPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE;
virtual void InsertObject(SdrObject* pObj, size_t nPos = SAL_MAX_SIZE,
const SdrInsertReason* pReason=NULL) SAL_OVERRIDE;
......@@ -79,7 +78,7 @@ public:
protected:
FmFormPage(const FmFormPage& rPage);
void lateInit(const FmFormPage& rPage);
void lateInit(const FmFormPage& rPage, FmFormModel* pNewModel = 0);
};
#endif // INCLUDED_SVX_FMPAGE_HXX
......
......@@ -486,7 +486,7 @@ protected:
// classes that needs access to the page objects must be deferred to lateInit. And it must
// call lateInit() of its parent class.
SdrPage(const SdrPage& rSrcPage);
void lateInit(const SdrPage& rSrcPage);
void lateInit(const SdrPage& rSrcPage, SdrModel* pNewModel = 0);
public:
TYPEINFO_OVERRIDE();
......@@ -575,6 +575,9 @@ public:
bool bEdit );
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private:
void impl_setModelForLayerAdmin(SdrModel* pNewModel);
};
typedef tools::WeakReference< SdrPage > SdrPageWeakRef;
......
......@@ -60,7 +60,7 @@ public:
virtual SdrPage* Clone() const SAL_OVERRIDE;
using SdrPage::Clone;
virtual SdrPage* Clone( SdrModel* pNewModel ) const SAL_OVERRIDE;
virtual void NbcInsertObject(SdrObject* pObj, size_t nPos, const SdrInsertReason* pReason) SAL_OVERRIDE;
virtual SdrObject* RemoveObject(size_t nObjNum) SAL_OVERRIDE;
......
......@@ -60,9 +60,20 @@ OReportPage::~OReportPage()
SdrPage* OReportPage::Clone() const
{
return Clone(0);
}
SdrPage* OReportPage::Clone( SdrModel* const pNewModel ) const
{
OReportPage *const pNewPage = new OReportPage( *this );
pNewPage->lateInit( *this );
OReportModel* pReportModel = 0;
if ( pNewModel )
{
pReportModel = dynamic_cast<OReportModel*>( pNewModel );
assert( pReportModel );
}
pNewPage->lateInit( *this, pReportModel );
return pNewPage;
}
......
......@@ -26,14 +26,19 @@ class ScDrawLayer;
class ScDrawPage: public FmFormPage
{
ScDrawPage(const ScDrawPage&) SAL_DELETED_FUNCTION;
ScDrawPage& operator=(const ScDrawPage&) SAL_DELETED_FUNCTION;
public:
ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage = false);
virtual ~ScDrawPage();
virtual ScDrawPage* Clone() const SAL_OVERRIDE;
virtual ScDrawPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage() SAL_OVERRIDE;
private:
ScDrawPage(const ScDrawPage& rSrcPage);
};
#endif
......
......@@ -32,10 +32,33 @@ ScDrawPage::ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage) :
SetSize( Size( LONG_MAX, LONG_MAX ) );
}
ScDrawPage::ScDrawPage(const ScDrawPage& rSrcPage)
: FmFormPage(rSrcPage)
{
}
ScDrawPage::~ScDrawPage()
{
}
ScDrawPage* ScDrawPage::Clone() const
{
return Clone(0);
}
ScDrawPage* ScDrawPage::Clone(SdrModel* const pNewModel) const
{
ScDrawPage* const pNewPage = new ScDrawPage(*this);
FmFormModel* pScDrawModel = 0;
if (pNewModel)
{
pScDrawModel = dynamic_cast<FmFormModel*>(pNewModel);
assert(pScDrawModel);
}
pNewPage->lateInit(*this, pScDrawModel);
return pNewPage;
}
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ScDrawPage::createUnoPage()
{
return static_cast<cppu::OWeakObject*>( new ScPageObj( this ) );
......
......@@ -68,9 +68,9 @@ FmFormPage::FmFormPage(const FmFormPage& rPage)
{
}
void FmFormPage::lateInit(const FmFormPage& rPage)
void FmFormPage::lateInit(const FmFormPage& rPage, FmFormModel* const pNewModel)
{
SdrPage::lateInit( rPage );
SdrPage::lateInit( rPage, pNewModel );
m_pImpl->initFrom( rPage.GetImpl() );
m_sPageName = rPage.m_sPageName;
......@@ -118,9 +118,20 @@ void FmFormPage::SetModel(SdrModel* pNewModel)
SdrPage* FmFormPage::Clone() const
{
return Clone(0);
}
SdrPage* FmFormPage::Clone(SdrModel* const pNewModel) const
{
FmFormPage* const pNewPage = new FmFormPage(*this);
pNewPage->lateInit(*this);
FmFormModel* pFormModel = 0;
if (pNewModel)
{
pFormModel = dynamic_cast<FmFormModel*>(pNewModel);
assert(pFormModel);
}
pNewPage->lateInit(*this, pFormModel);
return pNewPage;
}
......
......@@ -1302,10 +1302,17 @@ SdrPage::~SdrPage()
}
void SdrPage::lateInit(const SdrPage& rSrcPage)
void SdrPage::lateInit(const SdrPage& rSrcPage, SdrModel* const pNewModel)
{
assert(!mpViewContact);
assert(!mpSdrPageProperties);
assert(!mxUnoPage.is());
if (pNewModel && (pNewModel != pModel))
{
pModel = pNewModel;
impl_setModelForLayerAdmin(pNewModel);
}
// copy all the local parameters to make this instance
// a valid copy of source page before copying and inserting
......@@ -1512,18 +1519,24 @@ sal_Int32 SdrPage::GetLwrBorder() const
return nBordLwr;
}
void SdrPage::impl_setModelForLayerAdmin(SdrModel* const pNewModel)
{
if (pNewModel!=NULL) {
pLayerAdmin->SetParent(&pNewModel->GetLayerAdmin());
} else {
pLayerAdmin->SetParent(NULL);
}
pLayerAdmin->SetModel(pNewModel);
}
void SdrPage::SetModel(SdrModel* pNewModel)
{
SdrModel* pOldModel=pModel;
SdrObjList::SetModel(pNewModel);
if (pNewModel!=pOldModel)
{
if (pNewModel!=NULL) {
pLayerAdmin->SetParent(&pNewModel->GetLayerAdmin());
} else {
pLayerAdmin->SetParent(NULL);
}
pLayerAdmin->SetModel(pNewModel);
impl_setModelForLayerAdmin( pNewModel );
// create new SdrPageProperties with new model (due to SfxItemSet there)
// and copy ItemSet and StyleSheet
......
......@@ -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
......
......@@ -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();
......
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