summaryrefslogtreecommitdiff
path: root/svx/source/svdraw
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r--svx/source/svdraw/svdcrtv.cxx21
-rw-r--r--svx/source/svdraw/svddrgv.cxx6
-rw-r--r--svx/source/svdraw/svdedtv.cxx7
-rw-r--r--svx/source/svdraw/svdedtv2.cxx28
-rw-r--r--svx/source/svdraw/svdedxv.cxx23
-rw-r--r--svx/source/svdraw/svdetc.cxx6
-rw-r--r--svx/source/svdraw/svdfmtf.cxx126
-rw-r--r--svx/source/svdraw/svdglev.cxx8
-rw-r--r--svx/source/svdraw/svdhdl.cxx12
-rw-r--r--svx/source/svdraw/svdmodel.cxx45
-rw-r--r--svx/source/svdraw/svdmrkv.cxx8
-rw-r--r--svx/source/svdraw/svdoashp.cxx37
-rw-r--r--svx/source/svdraw/svdoattr.cxx22
-rw-r--r--svx/source/svdraw/svdobj.cxx504
-rw-r--r--svx/source/svdraw/svdocapt.cxx45
-rw-r--r--svx/source/svdraw/svdocirc.cxx43
-rw-r--r--svx/source/svdraw/svdoedge.cxx17
-rw-r--r--svx/source/svdraw/svdograf.cxx296
-rw-r--r--svx/source/svdraw/svdogrp.cxx195
-rw-r--r--svx/source/svdraw/svdomeas.cxx190
-rw-r--r--svx/source/svdraw/svdomedia.cxx48
-rw-r--r--svx/source/svdraw/svdoole2.cxx348
-rw-r--r--svx/source/svdraw/svdopage.cxx20
-rw-r--r--svx/source/svdraw/svdopath.cxx43
-rw-r--r--svx/source/svdraw/svdorect.cxx58
-rw-r--r--svx/source/svdraw/svdotext.cxx123
-rw-r--r--svx/source/svdraw/svdotextdecomposition.cxx5
-rw-r--r--svx/source/svdraw/svdotxat.cxx8
-rw-r--r--svx/source/svdraw/svdotxed.cxx10
-rw-r--r--svx/source/svdraw/svdotxln.cxx9
-rw-r--r--svx/source/svdraw/svdotxtr.cxx45
-rw-r--r--svx/source/svdraw/svdouno.cxx53
-rw-r--r--svx/source/svdraw/svdovirt.cxx59
-rw-r--r--svx/source/svdraw/svdpage.cxx313
-rw-r--r--svx/source/svdraw/svdpagv.cxx26
-rw-r--r--svx/source/svdraw/svdpntv.cxx11
-rw-r--r--svx/source/svdraw/svdpoev.cxx6
-rw-r--r--svx/source/svdraw/svdsnpv.cxx49
-rw-r--r--svx/source/svdraw/svdtext.cxx90
-rw-r--r--svx/source/svdraw/svdundo.cxx30
-rw-r--r--svx/source/svdraw/svdview.cxx8
-rw-r--r--svx/source/svdraw/svdviter.cxx4
-rw-r--r--svx/source/svdraw/svdxcgv.cxx150
43 files changed, 1657 insertions, 1498 deletions
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index f2d739e76612..33cf4eb9b3c2 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -197,10 +197,8 @@ void SdrCreateView::ImpClearVars()
ImpClearConnectMarker();
}
-SdrCreateView::SdrCreateView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrDragView(rSdrModel, pOut),
+SdrCreateView::SdrCreateView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrDragView(pModel1,pOut),
mpCoMaOverlay(nullptr),
mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
{
@@ -350,10 +348,7 @@ void SdrCreateView::SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent)
nCurrentInvent=nInvent;
nCurrentIdent=nIdent;
SdrObject * pObj = (nIdent == OBJ_NONE) ? nullptr :
- SdrObjFactory::MakeNewObject(
- *GetModel(),
- nInvent,
- nIdent);
+ SdrObjFactory::MakeNewObject(nInvent, nIdent, nullptr);
if(pObj)
{
@@ -412,14 +407,14 @@ bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, sal_uInt16 nIdent, cons
{
pCurrentCreate->SetPage(pCreatePV->GetPage());
}
+ else if (mpModel)
+ {
+ pCurrentCreate->SetModel(mpModel);
+ }
}
else
{
- pCurrentCreate = SdrObjFactory::MakeNewObject(
- *mpModel,
- nInvent,
- nIdent,
- pCreatePV->GetPage());
+ pCurrentCreate = SdrObjFactory::MakeNewObject(nInvent, nIdent, pCreatePV->GetPage(), mpModel);
}
Point aPnt(rPnt);
diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
index 5d18d6840d27..b13383b27a32 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -71,10 +71,8 @@ void SdrDragView::ImpClearVars()
mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate();
}
-SdrDragView::SdrDragView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrExchangeView(rSdrModel, pOut)
+SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrExchangeView(pModel1,pOut)
{
ImpClearVars();
}
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index ce620ae67e41..c373caac480f 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -88,10 +88,8 @@ void SdrEditView::ImpClearVars()
bPossibilitiesDirty=true; // << Purify didn't like this
}
-SdrEditView::SdrEditView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrMarkView(rSdrModel, pOut)
+SdrEditView::SdrEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrMarkView(pModel1,pOut)
{
ImpClearVars();
}
@@ -100,6 +98,7 @@ SdrEditView::~SdrEditView()
{
}
+
void SdrEditView::InsertNewLayer(const OUString& rName, sal_uInt16 nPos)
{
SdrLayerAdmin& rLA=mpModel->GetLayerAdmin();
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index ef63499a1eb8..01820c63bc34 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -1126,7 +1126,7 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
// #i73441# check insert list before taking actions
if(pInsOL)
{
- SdrPathObj* pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), OBJ_PATHFILL, aMergePolyPolygonA);
+ SdrPathObj* pPath = new SdrPathObj(OBJ_PATHFILL, aMergePolyPolygonA);
ImpCopyAttributes(pAttrObj, pPath);
pInsOL->InsertObject(pPath, nInsPos);
if( bUndo )
@@ -1134,7 +1134,7 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
// #i124760# To have a correct selection with only the new object it is necessary to
// unmark all objects first. If not doing so, there may remain invalid pointers to objects
- // TTTT:Not needed for aw080 (!)
+ //TTTT:Not needed for aw080 (!)
UnmarkAllObj(pInsPV);
MarkObj(pPath, pInsPV, false, true);
@@ -1355,7 +1355,7 @@ void SdrEditView::CombineMarkedObjects(bool bNoPolyPoly)
}
}
- SdrPathObj* pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), eKind, aPolyPolygon);
+ SdrPathObj* pPath = new SdrPathObj(eKind,aPolyPolygon);
// attributes of the lowest object
ImpCopyAttributes(pAttrObj, pPath);
@@ -1522,10 +1522,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(!bMakeLines || nPointCount < 2)
{
- SdrPathObj* pPath = new SdrPathObj(
- pSrcPath->getSdrModelFromSdrObject(),
- static_cast<SdrObjKind>(pSrcPath->GetObjIdentifier()),
- basegfx::B2DPolyPolygon(rCandidate));
+ SdrPathObj* pPath = new SdrPathObj(static_cast<SdrObjKind>(pSrcPath->GetObjIdentifier()), basegfx::B2DPolyPolygon(rCandidate));
ImpCopyAttributes(pSrcPath, pPath);
pLast = pPath;
rOL.InsertObject(pPath, rPos);
@@ -1559,10 +1556,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
aNewPolygon.append(rCandidate.getB2DPoint(nNextIndex));
}
- SdrPathObj* pPath = new SdrPathObj(
- pSrcPath->getSdrModelFromSdrObject(),
- eKind,
- basegfx::B2DPolyPolygon(aNewPolygon));
+ SdrPathObj* pPath = new SdrPathObj(eKind, basegfx::B2DPolyPolygon(aNewPolygon));
ImpCopyAttributes(pSrcPath, pPath);
pLast = pPath;
rOL.InsertObject(pPath, rPos);
@@ -1590,6 +1584,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
{
SdrObject* pCandidate = pReplacement->Clone();
DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
+ pCandidate->SetModel(pCustomShape->GetModel());
if(pCustomShape->GetMergedItem(SDRATTR_SHADOW).GetValue())
{
@@ -1608,9 +1603,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
{
// #i37011# also create a text object and add at rPos + 1
SdrObject* pTextObj = SdrObjFactory::MakeNewObject(
- pCustomShape->getSdrModelFromSdrObject(),
- pCustomShape->GetObjInventor(),
- OBJ_TEXT);
+ pCustomShape->GetObjInventor(), OBJ_TEXT, nullptr, pCustomShape->GetModel());
// Copy text content
OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject();
@@ -1761,13 +1754,14 @@ void SdrEditView::GroupMarked()
SdrMark* pM=GetSdrMarkByIndex(nm);
if (pM->GetPageView()==pPV)
{
- SdrObject* pObj=pM->GetMarkedSdrObj();
- if (nullptr==pGrp)
+ if (pGrp==nullptr)
{
- pGrp = new SdrObjGroup(pObj->getSdrModelFromSdrObject());
+ if (pGrp==nullptr)
+ pGrp=new SdrObjGroup;
pDstLst=pGrp->GetSubList();
DBG_ASSERT(pDstLst!=nullptr,"Alleged group object doesn't return object list.");
}
+ SdrObject* pObj=pM->GetMarkedSdrObj();
pSrcLst=pObj->GetObjList();
if (pSrcLst!=pSrcLst0)
{
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index d03a55fe4b11..51ef80fb46b6 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -88,10 +88,8 @@ void SdrObjEditView::ImpClearVars()
bTextEditOnlyOneView=false;
}
-SdrObjEditView::SdrObjEditView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrGlueEditView(rSdrModel, pOut),
+SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrGlueEditView(pModel1,pOut),
mpOldTextEditUndoManager(nullptr)
{
ImpClearVars();
@@ -1091,7 +1089,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
mxTextEditObj.reset( pObj );
pTextEditOutliner=pGivenOutliner;
if (pTextEditOutliner==nullptr)
- pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, mxTextEditObj->getSdrModelFromSdrObject() );
+ pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, *mxTextEditObj->GetModel() );
{
SvtAccessibilityOptions aOptions;
@@ -1590,7 +1588,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
}
if( pTEObj &&
- !pTEObj->getSdrModelFromSdrObject().isLocked() &&
+ pTEObj->GetModel() &&
+ !pTEObj->GetModel()->isLocked() &&
pTEObj->GetBroadcaster())
{
SdrHint aHint(SdrHintKind::EndEdit, *pTEObj);
@@ -2409,17 +2408,11 @@ void SdrObjEditView::MarkListHasChanged()
const SdrMarkList& rMarkList=GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
{
- const SdrObject* pObj(rMarkList.GetMark(0)->GetMarkedSdrObj());
- SdrView* pView(dynamic_cast< SdrView* >(this));
-
+ const SdrObject* pObj= rMarkList.GetMark(0)->GetMarkedSdrObj();
// check for table
- if(pObj && pView && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == OBJ_TABLE))
+ if( pObj && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
{
- mxSelectionController = sdr::table::CreateTableController(
- *pView,
- static_cast<const sdr::table::SdrTableObj&>(*pObj),
- mxLastSelectionController);
-
+ mxSelectionController = sdr::table::CreateTableController( this, static_cast<sdr::table::SdrTableObj const *>(pObj), mxLastSelectionController );
if( mxSelectionController.is() )
{
mxLastSelectionController.clear();
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 24479d6e8a06..4b29e2c53efe 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -531,6 +531,9 @@ namespace
const SdrLayerIDSet& rVisLayers,
Color& rCol)
{
+ if(!rList.GetModel())
+ return false;
+
bool bRet(false);
bool bMaster(rList.GetPage() && rList.GetPage()->IsMasterPage());
@@ -573,6 +576,9 @@ namespace
Color& rCol,
bool bSkipBackgroundShape)
{
+ if(!rPage.GetModel())
+ return false;
+
bool bRet(impGetSdrObjListFillColor(rPage, rPnt, rTextEditPV, rVisLayers, rCol));
if(!bRet && !rPage.IsMasterPage())
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index 3f3a93565979..f3806362aba6 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -557,7 +557,6 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
if(!aNewRange.isEmpty())
{
pObj = new SdrPathObj(
- *mpModel,
aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
aNewPoly);
@@ -687,10 +686,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct)
if(bCreateLineObject)
{
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_LINE,
- basegfx::B2DPolyPolygon(aLine));
+ SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
mnLineWidth = nNewLineWidth;
maLineJoin = rLineInfo.GetLineJoin();
maLineCap = rLineInfo.GetLineCap();
@@ -709,18 +705,14 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct)
void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction const & rAct)
{
- SdrRectObj* pRect = new SdrRectObj(
- *mpModel,
- rAct.GetRect());
+ SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
SetAttributes(pRect);
InsertObj(pRect);
}
void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction const & rAct)
{
- SdrRectObj* pRect = new SdrRectObj(
- *mpModel,
- rAct.GetRect());
+ SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
SetAttributes(pRect);
long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
if (nRad!=0) {
@@ -733,10 +725,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction const & rAct)
void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction const & rAct)
{
- SdrCircObj* pCirc=new SdrCircObj(
- *mpModel,
- OBJ_CIRC,
- rAct.GetRect());
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -746,10 +735,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction const & rAct)
Point aCenter(rAct.GetRect().Center());
long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc = new SdrCircObj(
- *mpModel,
- OBJ_CARC,
- rAct.GetRect(),nStart,nEnd);
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -759,12 +745,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction const & rAct)
Point aCenter(rAct.GetRect().Center());
long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc = new SdrCircObj(
- *mpModel,
- OBJ_SECT,
- rAct.GetRect(),
- nStart,
- nEnd);
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -774,12 +755,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction const & rAct)
Point aCenter(rAct.GetRect().Center());
long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc = new SdrCircObj(
- *mpModel,
- OBJ_CCUT,
- rAct.GetRect(),
- nStart,
- nEnd);
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -935,7 +911,6 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction const & rAct )
if(bCreateLineObject)
{
SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
basegfx::B2DPolyPolygon(aSource));
mnLineWidth = nNewLineWidth;
@@ -967,10 +942,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction const & rAct )
{
// #i73407# make sure polygon is closed, it's a filled primitive
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_POLY,
- basegfx::B2DPolyPolygon(aSource));
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
SetAttributes(pPath);
InsertObj(pPath, false);
}
@@ -991,10 +963,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction const & rAct)
{
// #i73407# make sure polygon is closed, it's a filled primitive
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_POLY,
- aSource);
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
SetAttributes(pPath);
InsertObj(pPath, false);
}
@@ -1021,10 +990,7 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
aPos.AdjustY( -nTextHeight );
tools::Rectangle aTextRect( aPos, aSize );
- SdrRectObj* pText = new SdrRectObj(
- *mpModel,
- OBJ_TEXT,
- aTextRect);
+ SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
pText->SetMergedItem ( makeSdrTextUpperDistItem (0));
pText->SetMergedItem ( makeSdrTextLowerDistItem (0));
@@ -1043,6 +1009,7 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
pText->SetMergedItem( makeSdrTextAutoGrowWidthItem( true ) );
}
+ pText->SetModel(mpModel);
pText->SetLayer(mnLayer);
pText->NbcSetText( rStr );
SetAttributes( pText, true );
@@ -1092,10 +1059,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- Graphic(rAct.GetBitmap()),
- aRect);
+ SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1107,10 +1071,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- Graphic(rAct.GetBitmap()),
- aRect);
+ SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1122,10 +1083,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- rAct.GetBitmapEx(),
- aRect);
+ SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1137,10 +1095,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- rAct.GetBitmapEx(),
- aRect);
+ SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1162,10 +1117,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction const & rAct )
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Hatch& rHatch = rAct.GetHatch();
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_POLY,
- aSource);
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
// #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
css::drawing::HatchStyle eStyle;
@@ -1255,10 +1207,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction const & rAct, GDIMetaF
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Gradient& rGrad = pAct->GetGradient();
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_POLY,
- aSource);
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
// #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aGradAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
XGradient aXGradient;
@@ -1326,10 +1275,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction const & rAct)
aRect.AdjustRight( 1 );
aRect.AdjustBottom( 1 );
aBitmap.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- aBitmap,
- aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1345,10 +1291,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction const & rAct)
aRect.AdjustRight( 1 );
aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- aBitmapEx,
- aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1362,10 +1305,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction const & rAct)
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- aBitmapEx,
- aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1379,10 +1319,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction const & rAct)
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- aBitmapEx,
- aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1397,10 +1334,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction const & rAct)
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- aBitmapEx,
- aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1447,7 +1381,6 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction const & rAct)
aRange.transform(aTransform);
const Gradient& rGradient = rAct.GetGradient();
SdrRectObj* pRect = new SdrRectObj(
- *mpModel,
tools::Rectangle(
floor(aRange.getMinX()),
floor(aRange.getMinY()),
@@ -1487,10 +1420,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction const & rAct)
aSource.transform(aTransform);
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_POLY,
- aSource);
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
SetAttributes(pPath);
pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
InsertObj(pPath, false);
@@ -1509,10 +1439,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct)
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Gradient& rGradient = rAct.GetGradient();
- SdrPathObj* pPath = new SdrPathObj(
- *mpModel,
- OBJ_POLY,
- aSource);
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
// #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
const css::awt::GradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
@@ -1636,10 +1563,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct)
}
// create and add object
- SdrGrafObj* pGraf = new SdrGrafObj(
- *mpModel,
- aBitmapEx,
- aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
// for MetaFloatTransparentAction, do not use SetAttributes(...)
// since these metafile content is not used to draw line/fill
diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx
index 3bbd461923fd..64da87b646ab 100644
--- a/svx/source/svdraw/svdglev.cxx
+++ b/svx/source/svdraw/svdglev.cxx
@@ -29,10 +29,9 @@
#include <svx/svdtrans.hxx>
#include <svx/svdobj.hxx>
-SdrGlueEditView::SdrGlueEditView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrPolyEditView(rSdrModel, pOut)
+
+SdrGlueEditView::SdrGlueEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrPolyEditView(pModel1,pOut)
{
}
@@ -40,6 +39,7 @@ SdrGlueEditView::~SdrGlueEditView()
{
}
+
void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, bool bConst, const void* p1, const void* p2, const void* p3, const void* p4)
{
const size_t nMarkCount=GetMarkedObjectCount();
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index b00b9671ece4..711a96e1dfff 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1351,8 +1351,8 @@ void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, bool bSetItemOnObject, bool
if(bSetItemOnObject)
{
- SdrModel& rModel(_pObj->getSdrModelFromSdrObject());
- SfxItemSet aNewSet(rModel.GetItemPool());
+ SdrModel* pModel = _pObj->GetModel();
+ SfxItemSet aNewSet(pModel->GetItemPool());
if(IsGradient())
{
@@ -1367,11 +1367,11 @@ void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, bool bSetItemOnObject, bool
aNewSet.Put(aNewTransItem);
}
- if(bUndo && rModel.IsUndoEnabled())
+ if(bUndo && pModel->IsUndoEnabled())
{
- rModel.BegUndo(SvxResId(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
- rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
- rModel.EndUndo();
+ pModel->BegUndo(SvxResId(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
+ pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
+ pModel->EndUndo();
}
pObj->SetMergedItemSetAndBroadcast(aNewSet);
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index bb237ba756cf..04d0f701247e 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1323,7 +1323,7 @@ void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
PageListChanged();
pPage->SetInserted();
pPage->SetPageNum(nPos);
-
+ pPage->SetModel(this);
if (nPos<nCount) bPagNumsDirty=true;
SetChanged();
SdrHint aHint(SdrHintKind::PageOrderChange, pPage);
@@ -1372,11 +1372,10 @@ void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
MasterPageListChanged();
pPage->SetInserted();
pPage->SetPageNum(nPos);
-
+ pPage->SetModel(this);
if (nPos<nCount) {
bMPgNumsDirty=true;
}
-
SetChanged();
SdrHint aHint(SdrHintKind::PageOrderChange, pPage);
Broadcast(aHint);
@@ -1477,10 +1476,7 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
if (!bMoveNoCopy)
{
const SdrPage* pPg1=GetPage(nPageNum2);
-
- // Clone to local model
pPg=pPg1->Clone();
-
InsertPage(pPg,nDestNum);
if (bUndo)
AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
@@ -1581,18 +1577,14 @@ void SdrModel::Merge(SdrModel& rSourceModel,
if (pMasterMap && pMasterNeed && nMasterNeed!=0) {
for (sal_uInt16 i=nSrcMasterPageCnt; i>0;) {
i--;
- if (pMasterNeed[i])
- {
- // Always Clone to new model
- const SdrPage* pPg1(rSourceModel.GetMasterPage(i));
- SdrPage* pPg(pPg1->Clone(this));
-
- if(!bTreadSourceAsConst)
- {
- // if requested, delete original/modify original model
- delete rSourceModel.RemoveMasterPage(i);
+ if (pMasterNeed[i]) {
+ SdrPage* pPg=nullptr;
+ if (bTreadSourceAsConst) {
+ const SdrPage* pPg1=rSourceModel.GetMasterPage(i);
+ pPg=pPg1->Clone();
+ } else {
+ pPg=rSourceModel.RemoveMasterPage(i);
}
-
if (pPg!=nullptr) {
// Now append all of them to the end of the DstModel.
// Don't use InsertMasterPage(), because everything is
@@ -1600,6 +1592,7 @@ void SdrModel::Merge(SdrModel& rSourceModel,
maMaPag.insert(maMaPag.begin()+nDstMasterPageCnt, pPg);
MasterPageListChanged();
pPg->SetInserted();
+ pPg->SetModel(this);
bMPgNumsDirty=true;
if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
} else {
@@ -1614,18 +1607,14 @@ void SdrModel::Merge(SdrModel& rSourceModel,
sal_uInt16 nSourcePos=nFirstPageNum;
sal_uInt16 nMergeCount=sal_uInt16(std::abs(static_cast<long>(static_cast<long>(nFirstPageNum)-nLastPageNum))+1);
if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
- while (nMergeCount>0)
- {
- // Always Clone to new model
- const SdrPage* pPg1(rSourceModel.GetPage(nSourcePos));
- SdrPage* pPg(pPg1->Clone(this));
-
- if(!bTreadSourceAsConst)
- {
- // if requested, delete original/modify original model
- delete rSourceModel.RemovePage(nSourcePos);
+ while (nMergeCount>0) {
+ SdrPage* pPg=nullptr;
+ if (bTreadSourceAsConst) {
+ const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos);
+ pPg=pPg1->Clone();
+ } else {
+ pPg=rSourceModel.RemovePage(nSourcePos);
}
-
if (pPg!=nullptr) {
InsertPage(pPg,nDestPos);
if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 07a5b2876361..985b415ca3b6 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -144,17 +144,15 @@ void SdrMarkView::ImpClearVars()
BrkMarkGluePoints();
}
-SdrMarkView::SdrMarkView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrSnapView(rSdrModel, pOut),
+SdrMarkView::SdrMarkView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrSnapView(pModel1,pOut),
mpMarkObjOverlay(nullptr),
mpMarkPointsOverlay(nullptr),
mpMarkGluePointsOverlay(nullptr),
maHdlList(this)
{
ImpClearVars();
- StartListening(rSdrModel);
+ StartListening(*pModel1);
}
SdrMarkView::~SdrMarkView()
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 783c5e9b5b58..70c9faf7978b 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -810,8 +810,8 @@ sdr::properties::BaseProperties* SdrObjCustomShape::CreateObjectSpecificProperti
return new sdr::properties::CustomShapeProperties(*this);
}
-SdrObjCustomShape::SdrObjCustomShape(SdrModel& rSdrModel)
-: SdrTextObj(rSdrModel)
+SdrObjCustomShape::SdrObjCustomShape()
+ : SdrTextObj()
, fObjectRotation(0.0)
, mbAdjustingTextFrameWidthAndHeight(false)
, mpLastShadowGeometry(nullptr)
@@ -1346,16 +1346,23 @@ void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
}
}
+void SdrObjCustomShape::SetModel(SdrModel* pNewModel)
+{
+ SdrTextObj::SetModel(pNewModel);
+ mXRenderedCustomShape.clear();
+}
+
sal_uInt16 SdrObjCustomShape::GetObjIdentifier() const
{
return sal_uInt16(OBJ_CUSTOMSHAPE);
}
+
// #115391# This implementation is based on the TextFrame size of the CustomShape and the
// state of the ResizeShapeToFitText flag to correctly set TextMinFrameWidth/Height
void SdrObjCustomShape::AdaptTextMinSize()
{
- if (!getSdrModelFromSdrObject().IsCreatingDataObj() && !getSdrModelFromSdrObject().IsPasteResize())
+ if (!pModel || (!pModel->IsCreatingDataObj() && !pModel->IsPasteResize()))
{
const bool bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue());
SfxItemSet aSet(
@@ -2225,7 +2232,7 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool
{
// Either we have text or the application has native text and suggested its size to us.
bool bHasText = HasText() || (m_aSuggestedTextFrameSize.Width() != 0 && m_aSuggestedTextFrameSize.Height() != 0);
- if ( bHasText && !rR.IsEmpty() )
+ if ( pModel && bHasText && !rR.IsEmpty() )
{
bool bWdtGrow=bWdt && IsAutoGrowWidth();
bool bHgtGrow=bHgt && IsAutoGrowHeight();
@@ -2236,7 +2243,7 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool
long nWdt=0,nMinWdt=0,nMaxWdt=0;
Size aSiz(rR.GetSize()); aSiz.AdjustWidth( -1 ); aSiz.AdjustHeight( -1 );
Size aMaxSiz(100000,100000);
- Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
+ Size aTmpSiz(pModel->GetMaxObjSize());
if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
if (bWdtGrow)
@@ -2492,8 +2499,8 @@ void SdrObjCustomShape::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools
Size aAnkSiz(aViewInit.GetSize());
aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() adds 1
Size aMaxSiz(1000000,1000000);
- {
- Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
+ if (pModel!=nullptr) {
+ Size aTmpSiz(pModel->GetMaxObjSize());
if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
}
@@ -2639,9 +2646,11 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle&
if (pPara)
{
- bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
- const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+ bool bHitTest = false;
+ if( pModel )
+ bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
+ const SdrTextObj* pTestObj = rOutliner.GetTextObj();
if( !pTestObj || !bHitTest || pTestObj != this ||
pTestObj->GetOutlinerParaObject() != GetOutlinerParaObject() )
{
@@ -2737,9 +2746,9 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject
InvalidateRenderGeometry();
}
-SdrObjCustomShape* SdrObjCustomShape::Clone(SdrModel* pTargetModel) const
+SdrObjCustomShape* SdrObjCustomShape::Clone() const
{
- return CloneHelper< SdrObjCustomShape >(pTargetModel);
+ return CloneHelper< SdrObjCustomShape >();
}
SdrObjCustomShape& SdrObjCustomShape::operator=(const SdrObjCustomShape& rObj)
@@ -2806,9 +2815,9 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
if ( pRenderedCustomShape )
{
- // Clone to same SdrModel
SdrObject* pCandidate = pRenderedCustomShape->Clone();
DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
+ pCandidate->SetModel(GetModel());
pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
SdrObject::Free( pCandidate );
@@ -2939,7 +2948,7 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix,
}
// if anchor is used, make position relative to it
- if(getSdrModelFromSdrObject().IsWriter())
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -3056,7 +3065,7 @@ bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position may be relative to anchorpos, convert
- if(getSdrModelFromSdrObject().IsWriter())
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
diff --git a/svx/source/svdraw/svdoattr.cxx b/svx/source/svdraw/svdoattr.cxx
index f33a47e63ee5..1f118f838f84 100644
--- a/svx/source/svdraw/svdoattr.cxx
+++ b/svx/source/svdraw/svdoattr.cxx
@@ -80,8 +80,7 @@ sdr::properties::BaseProperties* SdrAttrObj::CreateObjectSpecificProperties()
}
-SdrAttrObj::SdrAttrObj(SdrModel& rSdrModel)
-: SdrObject(rSdrModel)
+SdrAttrObj::SdrAttrObj()
{
}
@@ -100,7 +99,26 @@ const tools::Rectangle& SdrAttrObj::GetSnapRect() const
return maSnapRect;
}
+void SdrAttrObj::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel = pModel;
+
+ // test for correct pool in ItemSet; move to new pool if necessary
+ if(pNewModel && &GetObjectItemPool() != &pNewModel->GetItemPool())
+ {
+ MigrateItemPool(&GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
+ }
+
+ // call parent
+ SdrObject::SetModel(pNewModel);
+
+ // modify properties
+ GetProperties().SetModel(pOldModel, pNewModel);
+}
+
+
// syntactical sugar for ItemSet accesses
+
void SdrAttrObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
{
bool bDataChg(SfxHintId::DataChanged == rHint.GetId());
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 29b66b5cdf92..6726c2eafda3 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -226,10 +226,6 @@ sdr::properties::BaseProperties& SdrObject::GetProperties() const
{
if(!mpProperties)
{
- // CAUTION(!) Do *not* call this during SdrObject construction,
- // that will lead to wrong type-casts (dependent on costructor-level)
- // and thus eventually create the wrong sdr::properties (!). Is there
- // a way to check if on the stack is a SdrObject-constructor (?)
const_cast< SdrObject* >(this)->mpProperties.reset(
const_cast< SdrObject* >(this)->CreateObjectSpecificProperties() );
}
@@ -288,10 +284,10 @@ void SdrObject::SetBoundRectDirty()
}
-SdrObject::SdrObject(SdrModel& rSdrModel)
-: mpFillGeometryDefiningShape(nullptr)
- ,mrSdrModelFromSdrObject(rSdrModel)
+SdrObject::SdrObject() :
+ mpFillGeometryDefiningShape(nullptr)
,pPage(nullptr)
+ ,pModel(nullptr)
,pUserCall(nullptr)
,pPlusData(nullptr)
,mpImpl(new Impl)
@@ -347,7 +343,22 @@ SdrObject::~SdrObject()
// when they get called from ObjectInDestruction().
mpImpl->maObjectUsers.clear();
- // UserCall
+ try
+ {
+ SvxShape* pSvxShape = getSvxShape();
+ if ( pSvxShape )
+ {
+ OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
+ pSvxShape->InvalidateSdrObject();
+ uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW );
+ xShapeComp->dispose();
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("svx");
+ }
+
SendUserCall(SdrUserCallType::Delete, GetLastBoundRect());
o3tl::reset_preserve_ptr_during(pPlusData);
@@ -359,38 +370,14 @@ SdrObject::~SdrObject()
void SdrObject::Free( SdrObject*& _rpObject )
{
SdrObject* pObject = _rpObject; _rpObject = nullptr;
-
- if(nullptr == pObject)
- {
+ if ( pObject == nullptr )
// nothing to do
return;
- }
-
- SvxShape* pShape(pObject->getSvxShape());
- if(pShape)
- {
- if(pShape->HasSdrObjectOwnership())
- {
- // only the SvxShape is allowed to delete me, and will reset
- // the ownership before doing so
- return;
- }
- else
- {
- // not only delete pObject, but also need to dispose uno shape
- try
- {
- pShape->InvalidateSdrObject();
- uno::Reference< lang::XComponent > xShapeComp( pObject->getWeakUnoShape(), uno::UNO_QUERY_THROW );
- xShapeComp->dispose();
- }
- catch( const uno::Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("svx");
- }
- }
- }
+ SvxShape* pShape = pObject->getSvxShape();
+ if ( pShape && pShape->HasSdrObjectOwnership() )
+ // only the shape is allowed to delete me, and will reset the ownership before doing so
+ return;
delete pObject;
}
@@ -406,6 +393,28 @@ void SdrObject::SetRectsDirty(bool bNotMyself)
}
}
+void SdrObject::SetModel(SdrModel* pNewModel)
+{
+ if(pNewModel && pPage)
+ {
+ if(pPage->GetModel() != pNewModel)
+ {
+ pPage = nullptr;
+ }
+ }
+
+ // update listeners at possible API wrapper object
+ if( pModel != pNewModel )
+ {
+ SvxShape* pShape = getSvxShape();
+ if( pShape )
+ pShape->ChangeModel( pNewModel );
+ }
+
+ pModel = pNewModel;
+}
+
+
void SdrObject::SetObjList(SdrObjList* pNewObjList)
{
pObjList=pNewObjList;
@@ -414,23 +423,16 @@ void SdrObject::SetObjList(SdrObjList* pNewObjList)
void SdrObject::SetPage(SdrPage* pNewPage)
{
- SdrModel* pOldModel(&getSdrModelFromSdrObject());
- SdrPage* pOldPage(pPage);
-
- pPage = pNewPage;
+ SdrModel* pOldModel = pModel;
+ SdrPage* pOldPage = pPage;
- // TTTT Possibility here to add a warning for the future -> SdrModel
- // of SdrObject (this) and SdrPage it it added to *have* to have the
- // same SdrModel
- // if(nullptr != pPage)
- // {
- // SdrModel* pMod(&pPage->getSdrModelFromSdrPage());
- //
- // if(pMod != &getSdrModelFromSdrObject())
- // {
- // SetModel(pMod);
- // }
- // }
+ pPage=pNewPage;
+ if (pPage!=nullptr)
+ {
+ SdrModel* pMod=pPage->GetModel();
+ if (pMod!=pModel && pMod!=nullptr)
+ SetModel(pMod);
+ }
// The creation of the UNO shape in SdrObject::getUnoShape is influenced
// by pPage, so when the page changes we need to discard the cached UNO
@@ -438,14 +440,7 @@ void SdrObject::SetPage(SdrPage* pNewPage)
// If the page is changing to another page with the same model, we
// assume they create compatible UNO shape objects so we shouldn't have
// to invalidate.
- // TTTT: This causes quite some problems in SvxDrawPage::add when used
- // e.g. from Writer - the SdrObject may be cloned to target model, and
- // the xShape was added to it by purpose (see there). Thus it will be
- // good to think about if this is really needed - it *seems* to be intended
- // for a xShape being a on-demand-creatable resource - wit hthe argument that
- // the SdrPage/UnoPage used influences the SvxShape creation. This uses
- // ressources and would be nice to get rid of anyways.
- if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == &getSdrModelFromSdrObject()))
+ if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == pModel))
{
SvxShape* const pShape(getSvxShape());
if (pShape && !pShape->HasSdrObjectOwnership())
@@ -517,9 +512,13 @@ sal_Int16 SdrObject::GetRelativeHeightRelation() const
return mpImpl->meRelativeHeightRelation;
}
-SfxItemPool& SdrObject::GetObjectItemPool() const
+SfxItemPool & SdrObject::GetObjectItemPool() const
{
- return getSdrModelFromSdrObject().GetItemPool();
+ if(pModel)
+ return pModel->GetItemPool();
+
+ // use a static global default pool
+ return SdrObject::GetGlobalDrawObjectItemPool();
}
SdrInventor SdrObject::GetObjInventor() const
@@ -637,7 +636,7 @@ void SdrObject::SetName(const OUString& rStr)
{
// Undo/Redo for setting object's name (#i73249#)
bool bUndo( false );
- if ( getSdrModelFromSdrObject().IsUndoEnabled() )
+ if ( GetModel() && GetModel()->IsUndoEnabled() )
{
bUndo = true;
SdrUndoAction* pUndoAction =
@@ -646,14 +645,14 @@ void SdrObject::SetName(const OUString& rStr)
SdrUndoObjStrAttr::ObjStrAttrType::Name,
GetName(),
rStr );
- getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() );
- getSdrModelFromSdrObject().AddUndo( pUndoAction );
+ GetModel()->BegUndo( pUndoAction->GetComment() );
+ GetModel()->AddUndo( pUndoAction );
}
pPlusData->aObjName = rStr;
// Undo/Redo for setting object's name (#i73249#)
if ( bUndo )
{
- getSdrModelFromSdrObject().EndUndo();
+ GetModel()->EndUndo();
}
SetChanged();
BroadcastObjectChange();
@@ -681,7 +680,7 @@ void SdrObject::SetTitle(const OUString& rStr)
{
// Undo/Redo for setting object's title (#i73249#)
bool bUndo( false );
- if ( getSdrModelFromSdrObject().IsUndoEnabled() )
+ if ( GetModel() && GetModel()->IsUndoEnabled() )
{
bUndo = true;
SdrUndoAction* pUndoAction =
@@ -690,14 +689,14 @@ void SdrObject::SetTitle(const OUString& rStr)
SdrUndoObjStrAttr::ObjStrAttrType::Title,
GetTitle(),
rStr );
- getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() );
- getSdrModelFromSdrObject().AddUndo( pUndoAction );
+ GetModel()->BegUndo( pUndoAction->GetComment() );
+ GetModel()->AddUndo( pUndoAction );
}
pPlusData->aObjTitle = rStr;
// Undo/Redo for setting object's title (#i73249#)
if ( bUndo )
{
- getSdrModelFromSdrObject().EndUndo();
+ GetModel()->EndUndo();
}
SetChanged();
BroadcastObjectChange();
@@ -725,7 +724,7 @@ void SdrObject::SetDescription(const OUString& rStr)
{
// Undo/Redo for setting object's description (#i73249#)
bool bUndo( false );
- if ( getSdrModelFromSdrObject().IsUndoEnabled() )
+ if ( GetModel() && GetModel()->IsUndoEnabled() )
{
bUndo = true;
SdrUndoAction* pUndoAction =
@@ -734,14 +733,14 @@ void SdrObject::SetDescription(const OUString& rStr)
SdrUndoObjStrAttr::ObjStrAttrType::Description,
GetDescription(),
rStr );
- getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() );
- getSdrModelFromSdrObject().AddUndo( pUndoAction );
+ GetModel()->BegUndo( pUndoAction->GetComment() );
+ GetModel()->AddUndo( pUndoAction );
}
pPlusData->aObjDescription = rStr;
// Undo/Redo for setting object's description (#i73249#)
if ( bUndo )
{
- getSdrModelFromSdrObject().EndUndo();
+ GetModel()->EndUndo();
}
SetChanged();
BroadcastObjectChange();
@@ -836,7 +835,7 @@ const tools::Rectangle& SdrObject::GetLastBoundRect() const
void SdrObject::RecalcBoundRect()
{
// #i101680# suppress BoundRect calculations on import(s)
- if ((getSdrModelFromSdrObject().isLocked()) || utl::ConfigManager::IsFuzzing())
+ if ((pModel && pModel->isLocked()) || utl::ConfigManager::IsFuzzing())
return;
// central new method which will calculate the BoundRect using primitive geometry
@@ -866,7 +865,7 @@ void SdrObject::RecalcBoundRect()
void SdrObject::BroadcastObjectChange() const
{
- if ((getSdrModelFromSdrObject().isLocked()) || utl::ConfigManager::IsFuzzing())
+ if ((pModel && pModel->isLocked()) || utl::ConfigManager::IsFuzzing())
return;
if (mbDelayBroadcastObjectChange)
@@ -876,7 +875,7 @@ void SdrObject::BroadcastObjectChange() const
}
bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast);
- bool bObjectChange(IsInserted());
+ bool bObjectChange(IsInserted() && pModel);
if(bPlusDataBroadcast || bObjectChange)
{
@@ -889,7 +888,7 @@ void SdrObject::BroadcastObjectChange() const
if(bObjectChange)
{
- getSdrModelFromSdrObject().Broadcast(aHint);
+ pModel->Broadcast(aHint);
}
}
}
@@ -900,13 +899,9 @@ void SdrObject::SetChanged()
// notification now.
ActionChanged();
- // TTTT Need to check meaning/usage of IsInserted in one
- // of the next changes. It should not mean to have a SdrModel
- // set (this is guaranteed now), but should be connected to
- // being added to a SdrPage (?)
- if(IsInserted())
+ if(IsInserted() && pModel)
{
- getSdrModelFromSdrObject().SetChanged();
+ pModel->SetChanged();
}
}
@@ -934,9 +929,9 @@ bool SdrObject::HasLimitedRotation() const
return false;
}
-SdrObject* SdrObject::Clone(SdrModel* pTargetModel) const
+SdrObject* SdrObject::Clone() const
{
- return CloneHelper< SdrObject >(pTargetModel);
+ return CloneHelper< SdrObject >();
}
SdrObject& SdrObject::operator=(const SdrObject& rObj)
@@ -952,6 +947,7 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
// draw object, an SdrObject needs to be provided, as in the normal constructor.
mpProperties.reset( &rObj.GetProperties().Clone(*this) );
+ pModel =rObj.pModel;
pPage = rObj.pPage;
aOutRect=rObj.aOutRect;
mnLayerID = rObj.mnLayerID;
@@ -1025,9 +1021,19 @@ void SdrObject::ImpForcePlusData()
pPlusData.reset( new SdrObjPlusData );
}
+OUString SdrObject::GetAngleStr(long nAngle) const
+{
+ if (pModel!=nullptr)
+ return SdrModel::GetAngleString(nAngle);
+
+ return OUString();
+}
+
OUString SdrObject::GetMetrStr(long nVal) const
{
- return getSdrModelFromSdrObject().GetMetricString(nVal);
+ if (pModel!=nullptr)
+ return pModel->GetMetricString(nVal);
+ return OUString();
}
basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
@@ -2048,16 +2054,16 @@ void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
if (rAttr.GetItemState(SDRATTR_LAYERID,true,&pPoolItem)==SfxItemState::SET) {
nLayer=static_cast<const SdrLayerIdItem*>(pPoolItem)->GetValue();
}
- if (rAttr.GetItemState(SDRATTR_LAYERNAME,true,&pPoolItem)==SfxItemState::SET)
- {
- OUString aLayerName = static_cast<const SdrLayerNameItem*>(pPoolItem)->GetValue();
- const SdrLayerAdmin& rLayAd(nullptr != pPage ? pPage->GetLayerAdmin() : getSdrModelFromSdrObject().GetLayerAdmin());
- const SdrLayer* pLayer = rLayAd.GetLayer(aLayerName);
-
- if(nullptr != pLayer)
- {
- nLayer=pLayer->GetID();
+ if (rAttr.GetItemState(SDRATTR_LAYERNAME,true,&pPoolItem)==SfxItemState::SET && pModel!=nullptr) {
+ OUString aLayerName=static_cast<const SdrLayerNameItem*>(pPoolItem)->GetValue();
+ const SdrLayerAdmin* pLayAd=pPage!=nullptr ? &pPage->GetLayerAdmin() : pModel!=nullptr ? &pModel->GetLayerAdmin() : nullptr;
+ if (pLayAd!=nullptr) {
+ const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName);
+ if (pLayer!=nullptr) {
+ nLayer=pLayer->GetID();
+ }
}
+
}
if (nLayer!=SDRLAYER_NOTFOUND) {
NbcSetLayer(nLayer);
@@ -2120,11 +2126,12 @@ void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr) const
}
rAttr.Put(SdrLayerIdItem(GetLayer()));
- const SdrLayerAdmin& rLayAd(nullptr != pPage ? pPage->GetLayerAdmin() : getSdrModelFromSdrObject().GetLayerAdmin());
- const SdrLayer* pLayer = rLayAd.GetLayerPerID(GetLayer());
- if(nullptr != pLayer)
- {
- rAttr.Put(SdrLayerNameItem(pLayer->GetName()));
+ const SdrLayerAdmin* pLayAd=pPage!=nullptr ? &pPage->GetLayerAdmin() : pModel!=nullptr ? &pModel->GetLayerAdmin() : nullptr;
+ if (pLayAd!=nullptr) {
+ const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
+ if (pLayer!=nullptr) {
+ rAttr.Put(SdrLayerNameItem(pLayer->GetName()));
+ }
}
Point aRef1(rSnap.Center());
Point aRef2(aRef1); aRef2.AdjustY( 1 );
@@ -2302,15 +2309,15 @@ void extractLineContourFromPrimitive2DSequence(
}
-SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
+SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
{
- SdrObject* pRetval(nullptr);
+ bool bNoChange(true);
- if(LineGeometryUsageIsNecessary())
+ if(pRet->LineGeometryUsageIsNecessary())
{
basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
- const drawinglayer::primitive2d::Primitive2DContainer xSequence(GetViewContact().getViewIndependentPrimitive2DContainer());
+ const drawinglayer::primitive2d::Primitive2DContainer xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DContainer());
if(!xSequence.empty())
{
@@ -2338,7 +2345,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
{
- SfxItemSet aSet(GetMergedItemSet());
+ SfxItemSet aSet(pRet->GetMergedItemSet());
drawing::FillStyle eOldFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue();
SdrPathObj* aLinePolygonPart = nullptr;
SdrPathObj* aLineHairlinePart = nullptr;
@@ -2347,10 +2354,8 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
if(aMergedLineFillPolyPolygon.count())
{
// create SdrObject for filled line geometry
- aLinePolygonPart = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHFILL,
- aMergedLineFillPolyPolygon);
+ aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
+ aLinePolygonPart->SetModel(pRet->GetModel());
// correct item properties
aSet.Put(XLineWidthItem(0));
@@ -2370,10 +2375,8 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
// OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
// to get a non-filled object. If the poly is closed, the PathObj takes care for
// the correct closed state.
- aLineHairlinePart = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aMergedHairlinePolyPolygon);
+ aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
+ aLineHairlinePart->SetModel(pRet->GetModel());
aSet.Put(XLineWidthItem(0));
aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
@@ -2393,7 +2396,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
// check if original geometry should be added (e.g. filled and closed)
bool bAddOriginalGeometry(false);
- SdrPathObj* pPath = dynamic_cast<SdrPathObj*>(this);
+ SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pRet );
if(pPath && pPath->IsClosed())
{
@@ -2406,17 +2409,20 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
// do we need a group?
if(bBuildGroup || bAddOriginalGeometry)
{
- SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ SdrObject* pGroup = new SdrObjGroup;
+ pGroup->SetModel(pRet->GetModel());
if(bAddOriginalGeometry)
{
// Add a clone of the original geometry.
aSet.ClearItem();
- aSet.Put(GetMergedItemSet());
+ aSet.Put(pRet->GetMergedItemSet());
aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
aSet.Put(XLineWidthItem(0));
- SdrObject* pClone = Clone();
+ SdrObject* pClone = pRet->Clone();
+
+ pClone->SetModel(pRet->GetModel());
pClone->SetMergedItemSet(aSet);
pGroup->GetSubList()->NbcInsertObject(pClone);
@@ -2432,30 +2438,38 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
}
- pRetval = pGroup;
+ pRet = pGroup;
+
+ // be more careful with the state describing bool
+ bNoChange = false;
}
else
{
if(aLinePolygonPart)
{
- pRetval = aLinePolygonPart;
+ pRet = aLinePolygonPart;
+ // be more careful with the state describing bool
+ bNoChange = false;
}
else if(aLineHairlinePart)
{
- pRetval = aLineHairlinePart;
+ pRet = aLineHairlinePart;
+ // be more careful with the state describing bool
+ bNoChange = false;
}
}
}
}
- if(nullptr == pRetval)
+ if(bNoChange)
{
// due to current method usage, create and return a clone when nothing has changed
- SdrObject* pClone = Clone();
- pRetval = pClone;
+ SdrObject* pClone = pRet->Clone();
+ pClone->SetModel(pRet->GetModel());
+ pRet = pClone;
}
- return pRetval;
+ return pRet;
}
@@ -2483,7 +2497,8 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
if(dynamic_cast<const SdrObjGroup*>( pRet) != nullptr)
{
SdrObjList* pObjList2 = pRet->GetSubList();
- SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ SdrObject* pGroup = new SdrObjGroup;
+ pGroup->SetModel(pRet->GetModel());
for(size_t a=0; a<pObjList2->GetObjCount(); ++a)
{
@@ -2503,7 +2518,7 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
pPathObj->SetPathPoly(basegfx::utils::simplifyCurveSegments(pPathObj->GetPathPoly()));
}
- pRet = pRet->ImpConvertToContourObj(bForceLineDash);
+ pRet = ImpConvertToContourObj(pRet, bForceLineDash);
}
// #i73441# preserve LayerID
@@ -2586,10 +2601,10 @@ void SdrObject::SetPrintable(bool bPrn)
{
bNoPrint=!bPrn;
SetChanged();
- if (IsInserted())
+ if (IsInserted() && pModel!=nullptr)
{
SdrHint aHint(SdrHintKind::ObjectChange, *this);
- getSdrModelFromSdrObject().Broadcast(aHint);
+ pModel->Broadcast(aHint);
}
}
}
@@ -2600,10 +2615,10 @@ void SdrObject::SetVisible(bool bVisible)
{
mbVisible = bVisible;
SetChanged();
- if (IsInserted())
+ if (IsInserted() && pModel!=nullptr)
{
SdrHint aHint(SdrHintKind::ObjectChange, *this);
- getSdrModelFromSdrObject().Broadcast(aHint);
+ pModel->Broadcast(aHint);
}
}
}
@@ -2729,6 +2744,15 @@ void SdrObject::SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle&
}
}
+// change ItemPool for this object
+void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
+{
+ if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
+ {
+ GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
+ }
+}
+
void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
{
const uno::Reference< uno::XInterface>& xOldUnoShape( maWeakUnoShape );
@@ -2858,7 +2882,7 @@ bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPo
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position maybe relative to anchorpos, convert
- if(getSdrModelFromSdrObject().IsWriter())
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -2942,7 +2966,7 @@ void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const ba
}
// if anchor is used, make position relative to it
- if(getSdrModelFromSdrObject().IsWriter())
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -2961,7 +2985,9 @@ void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const ba
// Give info if object is in destruction
bool SdrObject::IsInDestruction() const
{
- return getSdrModelFromSdrObject().IsInDestruction();
+ if(pModel)
+ return pModel->IsInDestruction();
+ return false;
}
// return if fill is != drawing::FillStyle_NONE
@@ -3030,9 +3056,9 @@ SdrDelayBroadcastObjectChange::~SdrDelayBroadcastObjectChange()
}
-SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, sal_uInt16 nObjIdentifier)
+SdrObject* SdrObjFactory::CreateObjectFromFactory( SdrInventor nInventor, sal_uInt16 nObjIdentifier )
{
- SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel };
+ SdrObjCreatorParams aParams { nInventor, nObjIdentifier };
for (const auto & i : ImpGetUserMakeObjHdl()) {
SdrObject* pObj = i.Call(aParams);
if (pObj) {
@@ -3042,15 +3068,78 @@ SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInvent
return nullptr;
}
+SdrObject* SdrObjFactory::MakeNewObject(SdrInventor nInvent, sal_uInt16 nIdent, SdrPage* pPage, SdrModel* pModel)
+{
+ if (!pModel && pPage)
+ pModel = pPage->GetModel();
+
+ SdrObject* pObj = nullptr;
+
+ if (nInvent == SdrInventor::Default)
+ {
+ switch (nIdent)
+ {
+ case sal_uInt16(OBJ_NONE ): pObj=new SdrObject; break;
+ case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup; break;
+ case sal_uInt16(OBJ_LINE ): pObj=new SdrPathObj(OBJ_LINE ); break;
+ case sal_uInt16(OBJ_POLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
+ case sal_uInt16(OBJ_PLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
+ case sal_uInt16(OBJ_PATHLINE ): pObj=new SdrPathObj(OBJ_PATHLINE ); break;
+ case sal_uInt16(OBJ_PATHFILL ): pObj=new SdrPathObj(OBJ_PATHFILL ); break;
+ case sal_uInt16(OBJ_FREELINE ): pObj=new SdrPathObj(OBJ_FREELINE ); break;
+ case sal_uInt16(OBJ_FREEFILL ): pObj=new SdrPathObj(OBJ_FREEFILL ); break;
+ case sal_uInt16(OBJ_PATHPOLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
+ case sal_uInt16(OBJ_PATHPLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
+ case sal_uInt16(OBJ_EDGE ): pObj=new SdrEdgeObj; break;
+ case sal_uInt16(OBJ_RECT ): pObj=new SdrRectObj; break;
+ case sal_uInt16(OBJ_CIRC ): pObj=new SdrCircObj(OBJ_CIRC ); break;
+ case sal_uInt16(OBJ_SECT ): pObj=new SdrCircObj(OBJ_SECT ); break;
+ case sal_uInt16(OBJ_CARC ): pObj=new SdrCircObj(OBJ_CARC ); break;
+ case sal_uInt16(OBJ_CCUT ): pObj=new SdrCircObj(OBJ_CCUT ); break;
+ case sal_uInt16(OBJ_TEXT ): pObj=new SdrRectObj(OBJ_TEXT ); break;
+ case sal_uInt16(OBJ_TEXTEXT ): pObj=new SdrRectObj(OBJ_TEXTEXT ); break;
+ case sal_uInt16(OBJ_TITLETEXT ): pObj=new SdrRectObj(OBJ_TITLETEXT ); break;
+ case sal_uInt16(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
+ case sal_uInt16(OBJ_MEASURE ): pObj=new SdrMeasureObj; break;
+ case sal_uInt16(OBJ_GRAF ): pObj=new SdrGrafObj; break;
+ case sal_uInt16(OBJ_OLE2 ): pObj=new SdrOle2Obj; break;
+ case sal_uInt16(OBJ_FRAME ): pObj=new SdrOle2Obj(true); break;
+ case sal_uInt16(OBJ_CAPTION ): pObj=new SdrCaptionObj; break;
+ case sal_uInt16(OBJ_PAGE ): pObj=new SdrPageObj; break;
+ case sal_uInt16(OBJ_UNO ): pObj=new SdrUnoObj(OUString()); break;
+ case sal_uInt16(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(); break;
+#if HAVE_FEATURE_AVMEDIA
+ case sal_uInt16(OBJ_MEDIA ): pObj=new SdrMediaObj(); break;
+#endif
+ case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(pModel); break;
+ }
+ }
+
+ if (!pObj)
+ pObj = CreateObjectFromFactory(nInvent, nIdent);
+
+ if (!pObj)
+ {
+ // Well, if no one wants it...
+ return nullptr;
+ }
+
+ if (pPage)
+ pObj->SetPage(pPage);
+ else if (pModel)
+ pObj->SetModel(pModel);
+
+ return pObj;
+}
+
SdrObject* SdrObjFactory::MakeNewObject(
- SdrModel& rSdrModel,
- SdrInventor nInventor,
- sal_uInt16 nIdentifier,
- SdrPage* pPage,
- const tools::Rectangle* pSnapRect)
+ SdrInventor nInventor, sal_uInt16 nIdentifier, const tools::Rectangle& rSnapRect, SdrPage* pPage )
{
- SdrObject* pObj(nullptr);
- bool bSetSnapRect(nullptr != pSnapRect);
+ SdrModel* pModel = pPage ? pPage->GetModel() : nullptr;
+
+ SdrObject* pObj = nullptr;
+
+ bool bSetSnapRect = true;
if (nInventor == SdrInventor::Default)
{
@@ -3058,44 +3147,15 @@ SdrObject* SdrObjFactory::MakeNewObject(
{
case OBJ_MEASURE:
{
- if(nullptr != pSnapRect)
- {
- pObj = new SdrMeasureObj(
- rSdrModel,
- pSnapRect->TopLeft(),
- pSnapRect->BottomRight());
- }
- else
- {
- pObj = new SdrMeasureObj(rSdrModel);
- }
+ pObj = new SdrMeasureObj(rSnapRect.TopLeft(), rSnapRect.BottomRight());
}
break;
case OBJ_LINE:
{
- if(nullptr != pSnapRect)
- {
- basegfx::B2DPolygon aPoly;
-
- aPoly.append(
- basegfx::B2DPoint(
- pSnapRect->Left(),
- pSnapRect->Top()));
- aPoly.append(
- basegfx::B2DPoint(
- pSnapRect->Right(),
- pSnapRect->Bottom()));
- pObj = new SdrPathObj(
- rSdrModel,
- OBJ_LINE,
- basegfx::B2DPolyPolygon(aPoly));
- }
- else
- {
- pObj = new SdrPathObj(
- rSdrModel,
- OBJ_LINE);
- }
+ basegfx::B2DPolygon aPoly;
+ aPoly.append(basegfx::B2DPoint(rSnapRect.Left(), rSnapRect.Top()));
+ aPoly.append(basegfx::B2DPoint(rSnapRect.Right(), rSnapRect.Bottom()));
+ pObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
}
break;
case OBJ_TEXT:
@@ -3103,20 +3163,8 @@ SdrObject* SdrObjFactory::MakeNewObject(
case OBJ_TITLETEXT:
case OBJ_OUTLINETEXT:
{
- if(nullptr != pSnapRect)
- {
- pObj = new SdrRectObj(
- rSdrModel,
- static_cast<SdrObjKind>(nIdentifier),
- *pSnapRect);
- bSetSnapRect = false;
- }
- else
- {
- pObj = new SdrRectObj(
- rSdrModel,
- static_cast<SdrObjKind>(nIdentifier));
- }
+ pObj = new SdrRectObj(static_cast<SdrObjKind>(nIdentifier), rSnapRect);
+ bSetSnapRect = false;
}
break;
case OBJ_CIRC:
@@ -3124,52 +3172,38 @@ SdrObject* SdrObjFactory::MakeNewObject(
case OBJ_CARC:
case OBJ_CCUT:
{
- if(nullptr != pSnapRect)
- {
- pObj = new SdrCircObj(
- rSdrModel,
- static_cast<SdrObjKind>(nIdentifier),
- *pSnapRect);
- bSetSnapRect = false;
- }
- else
- {
- pObj = new SdrCircObj(
- rSdrModel,
- static_cast<SdrObjKind>(nIdentifier));
- }
+ pObj = new SdrCircObj(static_cast<SdrObjKind>(nIdentifier), rSnapRect);
+ bSetSnapRect = false;
}
break;
- case sal_uInt16(OBJ_NONE ): pObj=new SdrObject(rSdrModel); break;
- case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup(rSdrModel); break;
- case sal_uInt16(OBJ_POLY ): pObj=new SdrPathObj(rSdrModel, OBJ_POLY ); break;
- case sal_uInt16(OBJ_PLIN ): pObj=new SdrPathObj(rSdrModel, OBJ_PLIN ); break;
- case sal_uInt16(OBJ_PATHLINE ): pObj=new SdrPathObj(rSdrModel, OBJ_PATHLINE ); break;
- case sal_uInt16(OBJ_PATHFILL ): pObj=new SdrPathObj(rSdrModel, OBJ_PATHFILL ); break;
- case sal_uInt16(OBJ_FREELINE ): pObj=new SdrPathObj(rSdrModel, OBJ_FREELINE ); break;
- case sal_uInt16(OBJ_FREEFILL ): pObj=new SdrPathObj(rSdrModel, OBJ_FREEFILL ); break;
- case sal_uInt16(OBJ_PATHPOLY ): pObj=new SdrPathObj(rSdrModel, OBJ_POLY ); break;
- case sal_uInt16(OBJ_PATHPLIN ): pObj=new SdrPathObj(rSdrModel, OBJ_PLIN ); break;
- case sal_uInt16(OBJ_EDGE ): pObj=new SdrEdgeObj(rSdrModel); break;
- case sal_uInt16(OBJ_RECT ): pObj=new SdrRectObj(rSdrModel); break;
- case sal_uInt16(OBJ_GRAF ): pObj=new SdrGrafObj(rSdrModel); break;
- case sal_uInt16(OBJ_OLE2 ): pObj=new SdrOle2Obj(rSdrModel); break;
- case sal_uInt16(OBJ_FRAME ): pObj=new SdrOle2Obj(rSdrModel, true); break;
- case sal_uInt16(OBJ_CAPTION ): pObj=new SdrCaptionObj(rSdrModel); break;
- case sal_uInt16(OBJ_PAGE ): pObj=new SdrPageObj(rSdrModel); break;
- case sal_uInt16(OBJ_UNO ): pObj=new SdrUnoObj(rSdrModel, OUString()); break;
- case sal_uInt16(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(rSdrModel); break;
+ case sal_uInt16(OBJ_NONE ): pObj=new SdrObject; break;
+ case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup; break;
+ case sal_uInt16(OBJ_POLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
+ case sal_uInt16(OBJ_PLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
+ case sal_uInt16(OBJ_PATHLINE ): pObj=new SdrPathObj(OBJ_PATHLINE ); break;
+ case sal_uInt16(OBJ_PATHFILL ): pObj=new SdrPathObj(OBJ_PATHFILL ); break;
+ case sal_uInt16(OBJ_FREELINE ): pObj=new SdrPathObj(OBJ_FREELINE ); break;
+ case sal_uInt16(OBJ_FREEFILL ): pObj=new SdrPathObj(OBJ_FREEFILL ); break;
+ case sal_uInt16(OBJ_PATHPOLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
+ case sal_uInt16(OBJ_PATHPLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
+ case sal_uInt16(OBJ_EDGE ): pObj=new SdrEdgeObj; break;
+ case sal_uInt16(OBJ_RECT ): pObj=new SdrRectObj; break;
+ case sal_uInt16(OBJ_GRAF ): pObj=new SdrGrafObj; break;
+ case sal_uInt16(OBJ_OLE2 ): pObj=new SdrOle2Obj; break;
+ case sal_uInt16(OBJ_FRAME ): pObj=new SdrOle2Obj(true); break;
+ case sal_uInt16(OBJ_CAPTION ): pObj=new SdrCaptionObj; break;
+ case sal_uInt16(OBJ_PAGE ): pObj=new SdrPageObj; break;
+ case sal_uInt16(OBJ_UNO ): pObj=new SdrUnoObj(OUString()); break;
+ case sal_uInt16(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(); break;
#if HAVE_FEATURE_AVMEDIA
- case sal_uInt16(OBJ_MEDIA ): pObj=new SdrMediaObj(rSdrModel); break;
+ case sal_uInt16(OBJ_MEDIA ): pObj=new SdrMediaObj(); break;
#endif
- case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(rSdrModel); break;
+ case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(pModel); break;
}
}
if (!pObj)
- {
- pObj = CreateObjectFromFactory(rSdrModel, nInventor, nIdentifier);
- }
+ pObj = CreateObjectFromFactory(nInventor, nIdentifier);
if (!pObj)
{
@@ -3177,15 +3211,11 @@ SdrObject* SdrObjFactory::MakeNewObject(
return nullptr;
}
- if(nullptr != pPage)
- {
+ if (pPage)
pObj->SetPage(pPage);
- }
- if(bSetSnapRect && nullptr != pSnapRect)
- {
- pObj->SetSnapRect(*pSnapRect);
- }
+ if (bSetSnapRect)
+ pObj->SetSnapRect(rSnapRect);
return pObj;
}
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index cd688f348842..00cb7ded37ab 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -189,19 +189,16 @@ sdr::contact::ViewContact* SdrCaptionObj::CreateObjectSpecificViewContact()
}
-SdrCaptionObj::SdrCaptionObj(SdrModel& rSdrModel)
-: SdrRectObj(rSdrModel, OBJ_TEXT),
+SdrCaptionObj::SdrCaptionObj():
+ SdrRectObj(OBJ_TEXT),
aTailPoly(3), // default size: 3 points = 2 lines
mbSpecialTextBoxShadow(false),
mbFixedTail(false)
{
}
-SdrCaptionObj::SdrCaptionObj(
- SdrModel& rSdrModel,
- const tools::Rectangle& rRect,
- const Point& rTail)
-: SdrRectObj(rSdrModel, OBJ_TEXT,rRect),
+SdrCaptionObj::SdrCaptionObj(const tools::Rectangle& rRect, const Point& rTail):
+ SdrRectObj(OBJ_TEXT,rRect),
aTailPoly(3), // default size: 3 points = 2 lines
mbSpecialTextBoxShadow(false),
mbFixedTail(false)
@@ -235,23 +232,9 @@ sal_uInt16 SdrCaptionObj::GetObjIdentifier() const
return sal_uInt16(OBJ_CAPTION);
}
-SdrCaptionObj* SdrCaptionObj::Clone(SdrModel* pTargetModel) const
+SdrCaptionObj* SdrCaptionObj::Clone() const
{
- return CloneHelper< SdrCaptionObj >(pTargetModel);
-}
-
-SdrCaptionObj& SdrCaptionObj::operator=(const SdrCaptionObj& rObj)
-{
- if( this == &rObj )
- return *this;
- SdrRectObj::operator=(rObj);
-
- aTailPoly = rObj.aTailPoly;
- mbSpecialTextBoxShadow = rObj.mbSpecialTextBoxShadow;
- mbFixedTail = rObj.mbFixedTail;
- maFixedTailPos = rObj.maFixedTailPos;
-
- return *this;
+ return CloneHelper< SdrCaptionObj >();
}
OUString SdrCaptionObj::TakeObjNameSingul() const
@@ -680,6 +663,12 @@ Point SdrCaptionObj::GetSnapPoint(sal_uInt32 /*i*/) const
return Point(0,0);
}
+void SdrCaptionObj::SetModel(SdrModel* pNewModel)
+{
+ SdrRectObj::SetModel(pNewModel);
+ ImpRecalcTail();
+}
+
void SdrCaptionObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
{
SdrRectObj::Notify(rBC,rHint);
@@ -717,9 +706,8 @@ SdrObject* SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
if (pOL!=nullptr) { pRet=pRect; bInsTail = false; }
if (pOL==nullptr) pOL=pRect->GetSubList();
if (pOL!=nullptr) { pRet=pRect; bInsRect = false; }
- if (pOL==nullptr)
- {
- SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
+ if (pOL==nullptr) {
+ SdrObjGroup* pGrp=new SdrObjGroup;
pOL=pGrp->GetSubList();
pRet=pGrp;
}
@@ -759,8 +747,7 @@ void SdrCaptionObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
handleNegativeScale(aScale, &fRotate);
// force metric to pool metric
- MapUnit eMapUnit(getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
-
+ MapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -785,7 +772,7 @@ void SdrCaptionObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
}
// if anchor is used, make position relative to it
- if(getSdrModelFromSdrObject().IsWriter())
+ if( pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 1dc049f07d17..dc87f9a5de9a 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -104,10 +104,8 @@ sdr::contact::ViewContact* SdrCircObj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfSdrCircObj(*this);
}
-SdrCircObj::SdrCircObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewKind)
-: SdrRectObj(rSdrModel)
+
+SdrCircObj::SdrCircObj(SdrObjKind eNewKind)
{
nStartAngle=0;
nEndAngle=36000;
@@ -115,11 +113,8 @@ SdrCircObj::SdrCircObj(
bClosedObj=eNewKind!=OBJ_CARC;
}
-SdrCircObj::SdrCircObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewKind,
- const tools::Rectangle& rRect)
-: SdrRectObj(rSdrModel, rRect)
+SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect):
+ SdrRectObj(rRect)
{
nStartAngle=0;
nEndAngle=36000;
@@ -127,13 +122,8 @@ SdrCircObj::SdrCircObj(
bClosedObj=eNewKind!=OBJ_CARC;
}
-SdrCircObj::SdrCircObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewKind,
- const tools::Rectangle& rRect,
- long nNewStartWink,
- long nNewEndWink)
-: SdrRectObj(rSdrModel, rRect)
+SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect, long nNewStartWink, long nNewEndWink):
+ SdrRectObj(rRect)
{
long nAngleDif=nNewEndWink-nNewStartWink;
nStartAngle=NormAngle360(nNewStartWink);
@@ -348,22 +338,9 @@ OUString SdrCircObj::TakeObjNamePlural() const
return ImpGetResStr(pID);
}
-SdrCircObj* SdrCircObj::Clone(SdrModel* pTargetModel) const
-{
- return CloneHelper< SdrCircObj >(pTargetModel);
-}
-
-SdrCircObj& SdrCircObj::operator=(const SdrCircObj& rObj)
+SdrCircObj* SdrCircObj::Clone() const
{
- if( this == &rObj )
- return *this;
- SdrRectObj::operator=(rObj);
-
- meCircleKind = rObj.meCircleKind;
- nStartAngle = rObj.nStartAngle;
- nEndAngle = rObj.nEndAngle;
-
- return *this;
+ return CloneHelper< SdrCircObj >();
}
basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const
@@ -599,7 +576,7 @@ OUString SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const
nAngle = pU->nEnd;
}
- aBuf.append(SdrModel::GetAngleString(nAngle));
+ aBuf.append(GetAngleStr(nAngle));
aBuf.append(')');
}
@@ -617,7 +594,7 @@ OUString SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const
ImpTakeDescriptionStr(STR_DragCircAngle, aStr);
OUStringBuffer aBuf(aStr);
aBuf.append(" (");
- aBuf.append(SdrModel::GetAngleString(nAngle));
+ aBuf.append(GetAngleStr(nAngle));
aBuf.append(')');
return aBuf.makeStringAndClear();
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index ce5a636a5e03..45203c3d63cf 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -161,8 +161,8 @@ sdr::contact::ViewContact* SdrEdgeObj::CreateObjectSpecificViewContact()
}
-SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel)
-: SdrTextObj(rSdrModel),
+SdrEdgeObj::SdrEdgeObj()
+: SdrTextObj(),
nNotifyingCount(0),
bEdgeTrackDirty(false),
bEdgeTrackUserDefined(false),
@@ -520,14 +520,13 @@ void SdrEdgeObj::ImpSetTailPoint(bool bTail1, const Point& rPt)
void SdrEdgeObj::ImpDirtyEdgeTrack()
{
- if ( !bEdgeTrackUserDefined || !getSdrModelFromSdrObject().isLocked() )
+ if ( !bEdgeTrackUserDefined || !(GetModel() && GetModel()->isLocked()) )
bEdgeTrackDirty = true;
}
void SdrEdgeObj::ImpUndirtyEdgeTrack()
{
- if (bEdgeTrackDirty && getSdrModelFromSdrObject().isLocked())
- {
+ if (bEdgeTrackDirty && (GetModel() && GetModel()->isLocked()) ) {
ImpRecalcEdgeTrack();
}
}
@@ -541,7 +540,7 @@ void SdrEdgeObj::ImpRecalcEdgeTrack()
}
// #i120437# also not when model locked during import, but remember
- if(getSdrModelFromSdrObject().isLocked())
+ if(!GetModel() || GetModel()->isLocked())
{
mbSuppressed = true;
return;
@@ -1616,9 +1615,9 @@ void SdrEdgeObj::Reformat()
}
}
-SdrEdgeObj* SdrEdgeObj::Clone(SdrModel* pTargetModel) const
+SdrEdgeObj* SdrEdgeObj::Clone() const
{
- return CloneHelper< SdrEdgeObj >(pTargetModel);
+ return CloneHelper< SdrEdgeObj >();
}
SdrEdgeObj& SdrEdgeObj::operator=(const SdrEdgeObj& rObj)
@@ -2248,7 +2247,7 @@ void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const F
ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact);
// if resize is not from paste, forget user distances
- if (!getSdrModelFromSdrObject().IsPasteResize())
+ if (!GetModel() || !GetModel()->IsPasteResize())
{
aEdgeInfo.aObj1Line2 = Point();
aEdgeInfo.aObj1Line3 = Point();
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index e61a09da8e2b..1a00716fa088 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -216,8 +216,8 @@ void SdrGraphicLink::RemoveGraphicUpdater()
::sfx2::SvBaseLink::UpdateResult SdrGraphicLink::DataChanged(
const OUString& rMimeType, const css::uno::Any & rValue )
{
- SdrModel& rModel(rGrafObj.getSdrModelFromSdrObject());
- sfx2::LinkManager* pLinkManager(rModel.GetLinkManager());
+ SdrModel* pModel = rGrafObj.GetModel();
+ sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : nullptr;
if( pLinkManager && rValue.hasValue() )
{
@@ -325,14 +325,15 @@ void SdrGrafObj::onGraphicChanged()
}
}
-SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel)
-: SdrRectObj(rSdrModel)
- ,mpGraphicObject(new GraphicObject)
- ,pGraphicLink(nullptr)
- ,bMirrored(false)
- ,mbIsSignatureLine(false)
- ,mbIsSignatureLineShowSignDate(true)
- ,mbIsSignatureLineCanAddComment(false)
+
+SdrGrafObj::SdrGrafObj()
+ : SdrRectObj()
+ , mpGraphicObject(new GraphicObject)
+ , pGraphicLink(nullptr)
+ , bMirrored(false)
+ , mbIsSignatureLine(false)
+ , mbIsSignatureLineShowSignDate(true)
+ , mbIsSignatureLineCanAddComment(false)
{
mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
@@ -351,17 +352,14 @@ SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel)
mbSupportTextIndentingOnLineWidthChange = false;
}
-SdrGrafObj::SdrGrafObj(
- SdrModel& rSdrModel,
- const Graphic& rGraphic,
- const tools::Rectangle& rRect)
-: SdrRectObj(rSdrModel, rRect)
- ,mpGraphicObject(new GraphicObject(rGraphic))
- ,pGraphicLink(nullptr)
- ,bMirrored(false)
- ,mbIsSignatureLine(false)
- ,mbIsSignatureLineShowSignDate(true)
- ,mbIsSignatureLineCanAddComment(false)
+SdrGrafObj::SdrGrafObj(const Graphic& rGraphic, const tools::Rectangle& rRect)
+ : SdrRectObj(rRect)
+ , mpGraphicObject(new GraphicObject(rGraphic))
+ , pGraphicLink(nullptr)
+ , bMirrored(false)
+ , mbIsSignatureLine(false)
+ , mbIsSignatureLineShowSignDate(true)
+ , mbIsSignatureLineCanAddComment(false)
{
mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
@@ -380,16 +378,14 @@ SdrGrafObj::SdrGrafObj(
mbSupportTextIndentingOnLineWidthChange = false;
}
-SdrGrafObj::SdrGrafObj(
- SdrModel& rSdrModel,
- const Graphic& rGraphic)
-: SdrRectObj(rSdrModel)
- ,mpGraphicObject(new GraphicObject(rGraphic))
- ,pGraphicLink(nullptr)
- ,bMirrored(false)
- ,mbIsSignatureLine(false)
- ,mbIsSignatureLineShowSignDate(true)
- ,mbIsSignatureLineCanAddComment(false)
+SdrGrafObj::SdrGrafObj(const Graphic& rGraphic)
+ : SdrRectObj()
+ , mpGraphicObject(new GraphicObject(rGraphic))
+ , pGraphicLink(nullptr)
+ , bMirrored(false)
+ , mbIsSignatureLine(false)
+ , mbIsSignatureLineShowSignDate(true)
+ , mbIsSignatureLineCanAddComment(false)
{
mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
@@ -485,12 +481,10 @@ Graphic SdrGrafObj::GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformF
{
// Refactored most of the code to GraphicObject, where
// everybody can use e.g. the cropping functionality
- MapMode aDestMap(
- getSdrModelFromSdrObject().GetScaleUnit(),
- Point(),
- getSdrModelFromSdrObject().GetScaleFraction(),
- getSdrModelFromSdrObject().GetScaleFraction());
- const Size aDestSize( GetLogicRect().GetSize() );
+
+ MapMode aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() );
+ const Size aDestSize( GetLogicRect().GetSize() );
+
GraphicAttr aActAttr = GetGraphicAttr(nTransformFlags);
// Delegate to moved code in GraphicObject
@@ -565,12 +559,11 @@ const Size& SdrGrafObj::GetGrafPrefSize() const
void SdrGrafObj::SetGrafStreamURL( const OUString& rGraphicStreamURL )
{
mbIsPreview = false;
-
if( rGraphicStreamURL.isEmpty() )
{
mpGraphicObject->SetUserData();
}
- else if(getSdrModelFromSdrObject().IsSwapGraphics() )
+ else if( pModel->IsSwapGraphics() )
{
mpGraphicObject->SetUserData( rGraphicStreamURL );
}
@@ -587,20 +580,21 @@ Size SdrGrafObj::getOriginalSize() const
if (aGrafInfo.IsCropped())
{
- const long aCroppedTop(OutputDevice::LogicToLogic(aGrafInfo.GetTopCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
- const long aCroppedBottom(OutputDevice::LogicToLogic(aGrafInfo.GetBottomCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
- const long aCroppedLeft(OutputDevice::LogicToLogic(aGrafInfo.GetLeftCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
- const long aCroppedRight(OutputDevice::LogicToLogic(aGrafInfo.GetRightCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
- const long aCroppedWidth(aSize.getWidth() - aCroppedLeft + aCroppedRight);
- const long aCroppedHeight(aSize.getHeight() - aCroppedTop + aCroppedBottom);
+ long aCroppedTop = OutputDevice::LogicToLogic( aGrafInfo.GetTopCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+ long aCroppedBottom = OutputDevice::LogicToLogic( aGrafInfo.GetBottomCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+ long aCroppedLeft = OutputDevice::LogicToLogic( aGrafInfo.GetLeftCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+ long aCroppedRight = OutputDevice::LogicToLogic( aGrafInfo.GetRightCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
+
+ long aCroppedWidth = aSize.getWidth() - aCroppedLeft + aCroppedRight;
+ long aCroppedHeight = aSize.getHeight() - aCroppedTop + aCroppedBottom;
aSize = Size ( aCroppedWidth, aCroppedHeight);
}
if ( GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
- aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
+ aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapMode(GetModel()->GetScaleUnit()));
else
- aSize = OutputDevice::LogicToLogic(aSize, GetGrafPrefMapMode(), MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
+ aSize = OutputDevice::LogicToLogic(aSize, GetGrafPrefMapMode(), MapMode(GetModel()->GetScaleUnit()));
return aSize;
}
@@ -635,7 +629,7 @@ void SdrGrafObj::ForceSwapIn() const
void SdrGrafObj::ImpRegisterLink()
{
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+ sfx2::LinkManager* pLinkManager = pModel != nullptr ? pModel->GetLinkManager() : nullptr;
if( pLinkManager != nullptr && pGraphicLink == nullptr )
{
@@ -651,7 +645,7 @@ void SdrGrafObj::ImpRegisterLink()
void SdrGrafObj::ImpDeregisterLink()
{
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+ sfx2::LinkManager* pLinkManager = pModel != nullptr ? pModel->GetLinkManager() : nullptr;
if( pLinkManager != nullptr && pGraphicLink!=nullptr)
{
@@ -736,11 +730,11 @@ bool SdrGrafObj::ImpUpdateGraphicLink( bool bAsynchron ) const
void SdrGrafObj::ImpSetLinkedGraphic( const Graphic& rGraphic )
{
- const bool bIsChanged(getSdrModelFromSdrObject().IsChanged());
+ const bool bIsChanged = GetModel()->IsChanged();
NbcSetGraphic( rGraphic );
ActionChanged();
BroadcastObjectChange();
- getSdrModelFromSdrObject().SetChanged(bIsChanged);
+ GetModel()->SetChanged( bIsChanged );
}
OUString SdrGrafObj::TakeObjNameSingul() const
@@ -900,9 +894,9 @@ SdrObject* SdrGrafObj::getFullDragClone() const
return pRetval;
}
-SdrGrafObj* SdrGrafObj::Clone(SdrModel* pTargetModel) const
+SdrGrafObj* SdrGrafObj::Clone() const
{
- return CloneHelper< SdrGrafObj >(pTargetModel);
+ return CloneHelper< SdrGrafObj >();
}
SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj )
@@ -1022,14 +1016,14 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage )
ImpDeregisterLink();
}
- if(!GetStyleSheet() && pNewPage)
+ if(!pModel && !GetStyleSheet() && pNewPage && pNewPage->GetModel())
{
// #i119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This
// needs to be done before the style 'Default' is set from the :SetModel() call which is triggered
// from the following :SetPage().
// TTTT: Needs to be moved in branch aw080 due to having a SdrModel from the beginning, is at this
// place for convenience currently (works in both versions, is not in the way)
- SfxStyleSheet* pSheet(pNewPage->getSdrModelFromSdrPage().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj());
+ SfxStyleSheet* pSheet = pNewPage->GetModel()->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
if(pSheet)
{
@@ -1048,6 +1042,28 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage )
ImpRegisterLink();
}
+void SdrGrafObj::SetModel( SdrModel* pNewModel )
+{
+ bool bChg = pNewModel != pModel;
+
+ if( bChg )
+ {
+ if( mpGraphicObject->HasUserData() )
+ {
+ ForceSwapIn();
+ }
+
+ if( pGraphicLink != nullptr )
+ ImpDeregisterLink();
+ }
+
+ // realize model
+ SdrRectObj::SetModel(pNewModel);
+
+ if (bChg && !aFileName.isEmpty())
+ ImpRegisterLink();
+}
+
void SdrGrafObj::StartAnimation()
{
SetGrafAnimationAllowed(true);
@@ -1067,15 +1083,11 @@ GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedVectorGraphicData() const
{
GDIMetaFile aRetval;
- if(isEmbeddedVectorGraphicData())
+ if(isEmbeddedVectorGraphicData() && GetModel())
{
ScopedVclPtrInstance< VirtualDevice > pOut;
const tools::Rectangle aBoundRect(GetCurrentBoundRect());
- const MapMode aMap(
- getSdrModelFromSdrObject().GetScaleUnit(),
- Point(),
- getSdrModelFromSdrObject().GetScaleFraction(),
- getSdrModelFromSdrObject().GetScaleFraction());
+ const MapMode aMap(GetModel()->GetScaleUnit(), Point(), GetModel()->GetScaleFraction(), GetModel()->GetScaleFraction());
pOut->EnableOutput(false);
pOut->SetMapMode(aMap);
@@ -1120,11 +1132,8 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
case GraphicType::GdiMetafile:
{
// Sort into group and return ONLY those objects that can be created from the MetaFile.
- ImpSdrGDIMetaFileImport aFilter(
- getSdrModelFromSdrObject(),
- GetLayer(),
- maRect);
- SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
+ ImpSdrGDIMetaFileImport aFilter(*GetModel(), GetLayer(), maRect);
+ SdrObjGroup* pGrp = new SdrObjGroup();
if(aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0))
{
@@ -1147,6 +1156,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
pRetval = pGrp;
pGrp->NbcSetLayer(GetLayer());
+ pGrp->SetModel(GetModel());
if(bAddText)
{
@@ -1188,8 +1198,10 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
if(!pGrp)
{
- pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
+ pGrp = new SdrObjGroup();
+
pGrp->NbcSetLayer(GetLayer());
+ pGrp->SetModel(GetModel());
pGrp->GetSubList()->NbcInsertObject(pRetval);
}
@@ -1323,7 +1335,7 @@ IMPL_LINK(SdrGrafObj, ReplacementSwapHdl, const GraphicObject*, pO, SvStream*)
// replacement image is always swapped
if (pO->IsInSwapOut())
{
- SdrSwapGraphicsMode const nSwapMode(getSdrModelFromSdrObject().GetSwapGraphicsMode());
+ SdrSwapGraphicsMode const nSwapMode(pModel->GetSwapGraphicsMode());
if (nSwapMode & SdrSwapGraphicsMode::TEMP)
{
return GRFMGR_AUTOSWAPSTREAM_TEMP;
@@ -1347,13 +1359,13 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
if( pO->IsInSwapOut() )
{
- if( !mbIsPreview && getSdrModelFromSdrObject().IsSwapGraphics() && mpGraphicObject->GetSizeBytes() > 20480 )
+ if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && mpGraphicObject->GetSizeBytes() > 20480 )
{
// test if this object is visualized from someone
// ## test only if there are VOCs other than the preview renderer
if(!GetViewContact().HasViewObjectContacts())
{
- const SdrSwapGraphicsMode nSwapMode = getSdrModelFromSdrObject().GetSwapGraphicsMode();
+ const SdrSwapGraphicsMode nSwapMode = pModel->GetSwapGraphicsMode();
if( ( pGraphicLink ) &&
( nSwapMode & SdrSwapGraphicsMode::PURGE ) )
@@ -1379,73 +1391,78 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
else if( pO->IsInSwapIn() )
{
// can be loaded from the original document stream later
- if(mpGraphicObject->HasUserData())
+ if( pModel != nullptr )
{
- ::comphelper::LifecycleProxy proxy;
- OUString aUserData = mpGraphicObject->GetUserData();
- uno::Reference<io::XInputStream> const xStream(
- getSdrModelFromSdrObject().GetDocumentStream(aUserData, proxy));
-
- std::unique_ptr<SvStream> const pStream( (xStream.is())
- ? ::utl::UcbStreamHelper::CreateStream(xStream)
- : nullptr );
-
- if( pStream != nullptr )
+ if(mpGraphicObject->HasUserData())
{
- Graphic aGraphic;
+ ::comphelper::LifecycleProxy proxy;
+ OUString aUserData = mpGraphicObject->GetUserData();
+ uno::Reference<io::XInputStream> const xStream(
+ pModel->GetDocumentStream(aUserData, proxy));
- std::unique_ptr<css::uno::Sequence< css::beans::PropertyValue > > pFilterData;
+ std::unique_ptr<SvStream> const pStream( (xStream.is())
+ ? ::utl::UcbStreamHelper::CreateStream(xStream)
+ : nullptr );
- if(mbInsidePaint && !GetViewContact().HasViewObjectContacts())
+ if( pStream != nullptr )
{
- pFilterData.reset(new css::uno::Sequence< css::beans::PropertyValue >( 3 ));
-
- const css::awt::Size aPreviewSizeHint( 64, 64 );
- const bool bAllowPartialStreamRead = true;
- // create <GfxLink> instance also for previews in order to avoid that its corresponding
- // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data
- const bool bCreateNativeLink = true;
- (*pFilterData)[ 0 ].Name = "PreviewSizeHint";
- (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
- (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead";
- (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
- (*pFilterData)[ 2 ].Name = "CreateNativeLink";
- (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
-
- mbIsPreview = true;
- }
+ Graphic aGraphic;
- if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
- aGraphic, aUserData, *pStream,
- GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pFilterData.get()))
- {
- const OUString aNewUserData( mpGraphicObject->GetUserData() );
- mpGraphicObject->SetGraphic( aGraphic );
- if( mbIsPreview )
+ std::unique_ptr<css::uno::Sequence< css::beans::PropertyValue > > pFilterData;
+
+ if(mbInsidePaint && !GetViewContact().HasViewObjectContacts())
{
- mpGraphicObject->SetUserData(aNewUserData);
+ pFilterData.reset(new css::uno::Sequence< css::beans::PropertyValue >( 3 ));
+
+ const css::awt::Size aPreviewSizeHint( 64, 64 );
+ const bool bAllowPartialStreamRead = true;
+ // create <GfxLink> instance also for previews in order to avoid that its corresponding
+ // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data
+ const bool bCreateNativeLink = true;
+ (*pFilterData)[ 0 ].Name = "PreviewSizeHint";
+ (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
+ (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead";
+ (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
+ (*pFilterData)[ 2 ].Name = "CreateNativeLink";
+ (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
+
+ mbIsPreview = true;
}
- else
+
+ if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
+ aGraphic, aUserData, *pStream,
+ GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pFilterData.get()))
{
- mpGraphicObject->SetUserData();
+ const OUString aNewUserData( mpGraphicObject->GetUserData() );
+ mpGraphicObject->SetGraphic( aGraphic );
+ if( mbIsPreview )
+ {
+ mpGraphicObject->SetUserData(aNewUserData);
+ }
+ else
+ {
+ mpGraphicObject->SetUserData();
+ }
+
+ // Graphic successfully swapped in.
+ pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
}
+ pFilterData.reset();
- // Graphic successfully swapped in.
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ pStream->ResetError();
}
- pFilterData.reset();
-
- pStream->ResetError();
}
- }
- else if( !ImpUpdateGraphicLink( false ) )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
+ else if( !ImpUpdateGraphicLink( false ) )
+ {
+ pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
+ }
+ else
+ {
+ pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ }
}
else
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
- }
+ pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
}
return pRet;
@@ -1464,27 +1481,30 @@ Reference< XInputStream > SdrGrafObj::getInputStream()
{
Reference< XInputStream > xStream;
- if (mpGraphicObject && GetGraphic().IsLink())
+ if( pModel )
{
- Graphic aGraphic( GetGraphic() );
- GfxLink aLink( aGraphic.GetLink() );
- sal_uInt32 nSize = aLink.GetDataSize();
- const void* pSourceData = static_cast<const void*>(aLink.GetData());
- if( nSize && pSourceData )
+ if (mpGraphicObject && GetGraphic().IsLink())
{
- sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
- memcpy( pBuffer, pSourceData, nSize );
+ Graphic aGraphic( GetGraphic() );
+ GfxLink aLink( aGraphic.GetLink() );
+ sal_uInt32 nSize = aLink.GetDataSize();
+ const void* pSourceData = static_cast<const void*>(aLink.GetData());
+ if( nSize && pSourceData )
+ {
+ sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
+ memcpy( pBuffer, pSourceData, nSize );
- SvMemoryStream* pStream = new SvMemoryStream( static_cast<void*>(pBuffer), static_cast<std::size_t>(nSize), StreamMode::READ );
- pStream->ObjectOwnsMemory( true );
- xStream.set( new utl::OInputStreamWrapper( pStream, true ) );
+ SvMemoryStream* pStream = new SvMemoryStream( static_cast<void*>(pBuffer), static_cast<std::size_t>(nSize), StreamMode::READ );
+ pStream->ObjectOwnsMemory( true );
+ xStream.set( new utl::OInputStreamWrapper( pStream, true ) );
+ }
}
- }
- if (!xStream.is() && !aFileName.isEmpty())
- {
- SvFileStream* pStream = new SvFileStream( aFileName, StreamMode::READ );
- xStream.set( new utl::OInputStreamWrapper( pStream ) );
+ if (!xStream.is() && !aFileName.isEmpty())
+ {
+ SvFileStream* pStream = new SvFileStream( aFileName, StreamMode::READ );
+ xStream.set( new utl::OInputStreamWrapper( pStream ) );
+ }
}
return xStream;
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index 6311106c4e2f..d2151f14f4e4 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -50,28 +50,32 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <libxml/xmlwriter.h>
+
// BaseProperties section
+
sdr::properties::BaseProperties* SdrObjGroup::CreateObjectSpecificProperties()
{
return new sdr::properties::GroupProperties(*this);
}
+
// DrawContact section
+
sdr::contact::ViewContact* SdrObjGroup::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfGroup(*this);
}
-SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel)
-: SdrObject(rSdrModel),
- maSdrObjList(),
- aRefPoint(0, 0)
+
+SdrObjGroup::SdrObjGroup()
{
- maSdrObjList.SetOwnerObj(this);
- maSdrObjList.SetListKind(SdrObjListKind::GroupObj);
+ pSub.reset( new SdrObjList(nullptr,nullptr) );
+ pSub->SetOwnerObj(this);
+ pSub->SetListKind(SdrObjListKind::GroupObj);
bClosedObj=false;
}
+
SdrObjGroup::~SdrObjGroup()
{
}
@@ -79,9 +83,10 @@ SdrObjGroup::~SdrObjGroup()
void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
{
rInfo.bNoContortion=false;
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
SdrObjTransformInfoRec aInfo;
pObj->TakeObjInfo(aInfo);
if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =false;
@@ -140,9 +145,10 @@ SdrLayerID SdrObjGroup::GetLayer() const
{
bool b1st = true;
SdrLayerID nLay = SdrObject::GetLayer();
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrLayerID nLay1=maSdrObjList.GetObj(i)->GetLayer();
+ SdrLayerID nLay1=pOL->GetObj(i)->GetLayer();
if (b1st) { nLay=nLay1; b1st = false; }
else if (nLay1!=nLay) return SdrLayerID(0);
}
@@ -153,9 +159,10 @@ SdrLayerID SdrObjGroup::GetLayer() const
void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
{
SdrObject::NbcSetLayer(nLayer);
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- maSdrObjList.GetObj(i)->NbcSetLayer(nLayer);
+ pOL->GetObj(i)->NbcSetLayer(nLayer);
}
}
@@ -163,27 +170,58 @@ void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
void SdrObjGroup::SetObjList(SdrObjList* pNewObjList)
{
SdrObject::SetObjList(pNewObjList);
- maSdrObjList.SetUpList(pNewObjList);
+ pSub->SetUpList(pNewObjList);
}
void SdrObjGroup::SetPage(SdrPage* pNewPage)
{
SdrObject::SetPage(pNewPage);
- maSdrObjList.SetPage(pNewPage);
+ pSub->SetPage(pNewPage);
+}
+
+
+void SdrObjGroup::SetModel(SdrModel* pNewModel)
+{
+ if(pNewModel!=pModel)
+ {
+ // #i30648#
+ // This method also needs to migrate the used ItemSet
+ // when the destination model uses a different pool
+ // than the current one. Else it is possible to create
+ // SdrObjGroups which reference the old pool which might
+ // be destroyed (as the bug shows).
+ SdrModel* pOldModel = pModel;
+
+ // test for correct pool in ItemSet; move to new pool if necessary
+ if(pNewModel && &GetObjectItemPool() != &pNewModel->GetItemPool())
+ {
+ MigrateItemPool(&GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
+ }
+
+ // call parent
+ SdrObject::SetModel(pNewModel);
+
+ // set new model at content
+ pSub->SetModel(pNewModel);
+
+ // modify properties
+ GetProperties().SetModel(pOldModel, pNewModel);
+ }
}
+
SdrObjList* SdrObjGroup::GetSubList() const
{
- return const_cast< SdrObjList* >(&maSdrObjList);
+ return pSub.get();
}
const tools::Rectangle& SdrObjGroup::GetCurrentBoundRect() const
{
// <aOutRect> has to contain the bounding rectangle
- if ( maSdrObjList.GetObjCount()!=0 )
+ if ( pSub->GetObjCount()!=0 )
{
- const_cast<SdrObjGroup*>(this)->aOutRect = maSdrObjList.GetAllObjBoundRect();
+ const_cast<SdrObjGroup*>(this)->aOutRect = pSub->GetAllObjBoundRect();
}
return aOutRect;
@@ -192,9 +230,9 @@ const tools::Rectangle& SdrObjGroup::GetCurrentBoundRect() const
const tools::Rectangle& SdrObjGroup::GetSnapRect() const
{
// <aOutRect> has to contain the bounding rectangle
- if ( maSdrObjList.GetObjCount()!=0 )
+ if ( pSub->GetObjCount()!=0 )
{
- return maSdrObjList.GetAllObjSnapRect();
+ return pSub->GetAllObjSnapRect();
}
else
{
@@ -202,24 +240,24 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const
}
}
-SdrObjGroup* SdrObjGroup::Clone(SdrModel* pTargetModel) const
+SdrObjGroup* SdrObjGroup::Clone() const
{
- return CloneHelper< SdrObjGroup >(pTargetModel);
+ return CloneHelper< SdrObjGroup >();
}
SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
{
if( this == &rObj )
return *this;
-
// copy SdrObject stuff
SdrObject::operator=(rObj);
// #i36404#
// copy SubList, init model and page first
SdrObjList& rSourceSubList = *rObj.GetSubList();
- maSdrObjList.SetPage(rSourceSubList.GetPage());
- maSdrObjList.CopyObjects(*rObj.GetSubList());
+ pSub->SetPage(rSourceSubList.GetPage());
+ pSub->SetModel(rSourceSubList.GetModel());
+ pSub->CopyObjects(*rObj.GetSubList());
// copy local parameters
aRefPoint = rObj.aRefPoint;
@@ -231,7 +269,7 @@ OUString SdrObjGroup::TakeObjNameSingul() const
{
OUStringBuffer sName;
- if(!maSdrObjList.GetObjCount())
+ if(!pSub->GetObjCount())
{
sName.append(ImpGetResStr(STR_ObjNameSingulGRUPEMPTY));
}
@@ -256,7 +294,7 @@ OUString SdrObjGroup::TakeObjNameSingul() const
OUString SdrObjGroup::TakeObjNamePlural() const
{
- if (maSdrObjList.GetObjCount()==0)
+ if (pSub->GetObjCount()==0)
return ImpGetResStr(STR_ObjNamePluralGRUPEMPTY);
return ImpGetResStr(STR_ObjNamePluralGRUP);
}
@@ -270,11 +308,11 @@ void SdrObjGroup::RecalcSnapRect()
basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const
{
basegfx::B2DPolyPolygon aRetval;
- const size_t nObjCount(maSdrObjList.GetObjCount());
+ const size_t nObjCount(pSub->GetObjCount());
for(size_t a = 0; a < nObjCount; ++a)
{
- SdrObject* pObj = maSdrObjList.GetObj(a);
+ SdrObject* pObj = pSub->GetObj(a);
aRetval.append(pObj->TakeXorPoly());
}
@@ -303,9 +341,9 @@ long SdrObjGroup::GetRotateAngle() const
{
long nRetval(0);
- if(maSdrObjList.GetObjCount())
+ if(pSub->GetObjCount())
{
- SdrObject* pObj = maSdrObjList.GetObj(0);
+ SdrObject* pObj = pSub->GetObj(0);
nRetval = pObj->GetRotateAngle();
}
@@ -318,9 +356,9 @@ long SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
{
long nRetval(0);
- if(maSdrObjList.GetObjCount())
+ if(pSub->GetObjCount())
{
- SdrObject* pObj = maSdrObjList.GetObj(0);
+ SdrObject* pObj = pSub->GetObj(0);
nRetval = pObj->GetShearAngle();
}
@@ -358,10 +396,11 @@ void SdrObjGroup::NbcSetLogicRect(const tools::Rectangle& rRect)
void SdrObjGroup::NbcMove(const Size& rSiz)
{
aRefPoint.Move(rSiz);
- if (maSdrObjList.GetObjCount()!=0) {
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ if (pSub->GetObjCount()!=0) {
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
pObj->NbcMove(rSiz);
}
} else {
@@ -389,10 +428,11 @@ void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Frac
}
}
ResizePoint(aRefPoint,rRef,xFact,yFact);
- if (maSdrObjList.GetObjCount()!=0) {
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ if (pSub->GetObjCount()!=0) {
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
pObj->NbcResize(rRef,xFact,yFact);
}
} else {
@@ -406,9 +446,10 @@ void SdrObjGroup::NbcRotate(const Point& rRef, long nAngle, double sn, double cs
{
SetGlueReallyAbsolute(true);
RotatePoint(aRefPoint,rRef,sn,cs);
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
pObj->NbcRotate(rRef,nAngle,sn,cs);
}
NbcRotateGluePoints(rRef,nAngle,sn,cs);
@@ -420,9 +461,10 @@ void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
{
SetGlueReallyAbsolute(true);
MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
pObj->NbcMirror(rRef1,rRef2);
}
NbcMirrorGluePoints(rRef1,rRef2);
@@ -434,9 +476,10 @@ void SdrObjGroup::NbcShear(const Point& rRef, long nAngle, double tn, bool bVShe
{
SetGlueReallyAbsolute(true);
ShearPoint(aRefPoint,rRef,tn);
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
pObj->NbcShear(rRef,nAngle,tn,bVShear);
}
NbcShearGluePoints(rRef,tn,bVShear);
@@ -449,9 +492,10 @@ void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
aAnchor=rPnt;
Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
aRefPoint.Move(aSiz);
- const size_t nObjCount=maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount=pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
pObj->NbcSetAnchorPos(rPnt);
}
}
@@ -493,15 +537,16 @@ void SdrObjGroup::Move(const Size& rSiz)
if (rSiz.Width()!=0 || rSiz.Height()!=0) {
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
aRefPoint.Move(rSiz);
- if (maSdrObjList.GetObjCount()!=0) {
+ if (pSub->GetObjCount()!=0) {
// first move the connectors, then everything else
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (pObj->IsEdgeObj()) pObj->Move(rSiz);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Move(rSiz);
}
} else {
@@ -536,15 +581,16 @@ void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fractio
}
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
ResizePoint(aRefPoint,rRef,xFact,yFact);
- if (maSdrObjList.GetObjCount()!=0) {
+ if (pSub->GetObjCount()!=0) {
// move the connectors first, everything else afterwards
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
}
} else {
@@ -568,13 +614,14 @@ void SdrObjGroup::Rotate(const Point& rRef, long nAngle, double sn, double cs)
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
RotatePoint(aRefPoint,rRef,sn,cs);
// move the connectors first, everything else afterwards
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (pObj->IsEdgeObj()) pObj->Rotate(rRef,nAngle,sn,cs);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Rotate(rRef,nAngle,sn,cs);
}
NbcRotateGluePoints(rRef,nAngle,sn,cs);
@@ -591,13 +638,14 @@ void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
// move the connectors first, everything else afterwards
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
}
NbcMirrorGluePoints(rRef1,rRef2);
@@ -617,13 +665,14 @@ void SdrObjGroup::Shear(const Point& rRef, long nAngle, double tn, bool bVShear)
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
ShearPoint(aRefPoint,rRef,tn);
// move the connectors first, everything else afterwards
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (pObj->IsEdgeObj()) pObj->Shear(rRef,nAngle,tn,bVShear);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Shear(rRef,nAngle,tn,bVShear);
}
NbcShearGluePoints(rRef,tn,bVShear);
@@ -643,13 +692,14 @@ void SdrObjGroup::SetAnchorPos(const Point& rPnt)
Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
aRefPoint.Move(aSiz);
// move the connectors first, everything else afterwards
- const size_t nObjCount = maSdrObjList.GetObjCount();
+ SdrObjList* pOL=pSub.get();
+ const size_t nObjCount = pOL->GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=maSdrObjList.GetObj(i);
+ SdrObject* pObj=pOL->GetObj(i);
if (pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj = maSdrObjList.GetObj(i);
+ SdrObject* pObj = pOL->GetObj(i);
if (!pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
}
if (bChg) {
@@ -676,21 +726,22 @@ void SdrObjGroup::SetRelativePos(const Point& rPnt)
void SdrObjGroup::NbcReformatText()
{
- maSdrObjList.NbcReformatAllTextObjects();
+ pSub->NbcReformatAllTextObjects();
}
void SdrObjGroup::ReformatText()
{
- maSdrObjList.ReformatAllTextObjects();
+ pSub->ReformatAllTextObjects();
}
SdrObject* SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
- SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ SdrObject* pGroup = new SdrObjGroup;
+ pGroup->SetModel(GetModel());
- for(size_t a=0; a<maSdrObjList.GetObjCount(); ++a)
+ for(size_t a=0; a<pSub->GetObjCount(); ++a)
{
- SdrObject* pIterObj = maSdrObjList.GetObj(a);
+ SdrObject* pIterObj = pSub->GetObj(a);
SdrObject* pResult = pIterObj->DoConvertToPolyObj(bBezier, bAddText);
// pResult can be NULL e.g. for empty objects
@@ -708,7 +759,7 @@ void SdrObjGroup::dumpAsXml(xmlTextWriterPtr pWriter) const
SdrObject::dumpAsXml(pWriter);
- maSdrObjList.dumpAsXml(pWriter);
+ pSub->dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 9c1f6550f66d..63f33c6cbbce 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -94,63 +94,71 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind
{
case SdrMeasureFieldKind::Value:
{
- eModUIUnit = getSdrModelFromSdrObject().GetUIUnit();
-
- if(eMeasureUnit == FUNIT_NONE)
- eMeasureUnit = eModUIUnit;
-
- sal_Int32 nLen(GetLen(aPt2 - aPt1));
- Fraction aFact(1,1);
-
- if(eMeasureUnit != eModUIUnit)
+ if(pModel)
{
- // for the unit conversion
- aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X();
- }
-
- if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator())
- {
- aFact *= aMeasureScale;
- }
+ eModUIUnit = pModel->GetUIUnit();
- if(aFact.GetNumerator() != aFact.GetDenominator())
- {
- // scale via BigInt, to avoid overruns
- nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
- }
+ if(eMeasureUnit == FUNIT_NONE)
+ eMeasureUnit = eModUIUnit;
- if(!aFact.IsValid())
- {
- aStr = "?";
- }
- else
- {
- aStr = getSdrModelFromSdrObject().GetMetricString(nLen, true, nNumDigits);
- }
+ sal_Int32 nLen(GetLen(aPt2 - aPt1));
+ Fraction aFact(1,1);
- SvtSysLocale aSysLocale;
- const LocaleDataWrapper& rLocaleDataWrapper = aSysLocale.GetLocaleData();
- sal_Unicode cDec(rLocaleDataWrapper.getNumDecimalSep()[0]);
- sal_Unicode cDecAlt(rLocaleDataWrapper.getNumDecimalSepAlt().toChar());
+ if(eMeasureUnit != eModUIUnit)
+ {
+ // for the unit conversion
+ aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X();
+ }
- if(aStr.indexOf(cDec) != -1 || (cDecAlt && aStr.indexOf(cDecAlt) != -1))
- {
- sal_Int32 nLen2(aStr.getLength() - 1);
+ if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator())
+ {
+ aFact *= aMeasureScale;
+ }
- while(aStr[nLen2] == '0')
+ if(aFact.GetNumerator() != aFact.GetDenominator())
{
- aStr = aStr.copy(0, nLen2);
- nLen2--;
+ // scale via BigInt, to avoid overruns
+ nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
}
- if(aStr[nLen2] == cDec || (cDecAlt && aStr[nLen2] == cDecAlt))
+ if(!aFact.IsValid())
+ {
+ aStr = "?";
+ }
+ else
{
- aStr = aStr.copy(0, nLen2);
- nLen2--;
+ aStr = pModel->GetMetricString(nLen, true, nNumDigits);
}
- if(aStr.isEmpty())
- aStr += "0";
+ SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rLocaleDataWrapper = aSysLocale.GetLocaleData();
+ sal_Unicode cDec(rLocaleDataWrapper.getNumDecimalSep()[0]);
+ sal_Unicode cDecAlt(rLocaleDataWrapper.getNumDecimalSepAlt().toChar());
+
+ if(aStr.indexOf(cDec) != -1 || (cDecAlt && aStr.indexOf(cDecAlt) != -1))
+ {
+ sal_Int32 nLen2(aStr.getLength() - 1);
+
+ while(aStr[nLen2] == '0')
+ {
+ aStr = aStr.copy(0, nLen2);
+ nLen2--;
+ }
+
+ if(aStr[nLen2] == cDec || (cDecAlt && aStr[nLen2] == cDecAlt))
+ {
+ aStr = aStr.copy(0, nLen2);
+ nLen2--;
+ }
+
+ if(aStr.isEmpty())
+ aStr += "0";
+ }
+ }
+ else
+ {
+ // if there's no Model ... (e. g. preview in dialog)
+ aStr = "4711";
}
break;
@@ -159,13 +167,16 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind
{
if(bShowUnit)
{
- eModUIUnit = getSdrModelFromSdrObject().GetUIUnit();
+ if(pModel)
+ {
+ eModUIUnit = pModel->GetUIUnit();
- if(eMeasureUnit == FUNIT_NONE)
- eMeasureUnit = eModUIUnit;
+ if(eMeasureUnit == FUNIT_NONE)
+ eMeasureUnit = eModUIUnit;
- if(bShowUnit)
- aStr = SdrModel::GetUnitString(eMeasureUnit);
+ if(bShowUnit)
+ aStr = SdrModel::GetUnitString(eMeasureUnit);
+ }
}
break;
@@ -200,19 +211,14 @@ sdr::contact::ViewContact* SdrMeasureObj::CreateObjectSpecificViewContact()
}
-SdrMeasureObj::SdrMeasureObj(SdrModel& rSdrModel)
-: SdrTextObj(rSdrModel),
+SdrMeasureObj::SdrMeasureObj():
bTextDirty(false)
{
// #i25616#
mbSupportTextIndentingOnLineWidthChange = false;
}
-SdrMeasureObj::SdrMeasureObj(
- SdrModel& rSdrModel,
- const Point& rPt1,
- const Point& rPt2)
-: SdrTextObj(rSdrModel),
+SdrMeasureObj::SdrMeasureObj(const Point& rPt1, const Point& rPt2):
aPt1(rPt1),
aPt2(rPt2),
bTextDirty(false)
@@ -702,22 +708,9 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
}
}
-SdrMeasureObj* SdrMeasureObj::Clone(SdrModel* pTargetModel) const
-{
- return CloneHelper< SdrMeasureObj >(pTargetModel);
-}
-
-SdrMeasureObj& SdrMeasureObj::operator=(const SdrMeasureObj& rObj)
+SdrMeasureObj* SdrMeasureObj::Clone() const
{
- if( this == &rObj )
- return *this;
- SdrTextObj::operator=(rObj);
-
- aPt1 = rObj.aPt1;
- aPt2 = rObj.aPt2;
- bTextDirty = rObj.bTextDirty;
-
- return *this;
+ return CloneHelper< SdrMeasureObj >();
}
OUString SdrMeasureObj::TakeObjNameSingul() const
@@ -1145,7 +1138,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
SfxStyleSheet* pStyleSheet = GetStyleSheet();
// prepare group
- SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ SdrObjGroup* pGroup = new SdrObjGroup;
+ pGroup->SetModel(GetModel());
// prepare parameters
basegfx::B2DPolyPolygon aPolyPoly;
@@ -1159,11 +1153,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
- pPath = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPoly);
-
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
pGroup->GetSubList()->NbcInsertObject(pPath);
@@ -1180,11 +1171,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
- pPath = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPoly);
-
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1195,11 +1183,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
- pPath = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPoly);
-
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1217,11 +1202,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
- pPath = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPoly);
-
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1232,11 +1214,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
- pPath = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPoly);
-
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1250,11 +1229,8 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[nLoopStart].getB2DPolygon());
- pPath = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPoly);
-
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1385,7 +1361,7 @@ bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B
basegfx::B2DTuple aTranslate(aRange.getMinimum());
// position maybe relative to anchor position, convert
- if( getSdrModelFromSdrObject().IsWriter() )
+ if( pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -1394,7 +1370,7 @@ bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B
}
// force MapUnit to 100th mm
- MapUnit eMapUnit = getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
+ MapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -1431,7 +1407,7 @@ void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
basegfx::B2DPoint aPosB(rMatrix * basegfx::B2DPoint(1.0, 0.0));
// force metric to pool metric
- MapUnit eMapUnit = getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
+ MapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -1453,7 +1429,7 @@ void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
}
}
- if( getSdrModelFromSdrObject().IsWriter() )
+ if( pModel->IsWriter() )
{
// if anchor is used, make position relative to it
if(GetAnchorPos().X() || GetAnchorPos().Y())
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 012dc1d35879..4c41e76e6dc3 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -65,17 +65,16 @@ struct SdrMediaObj::Impl
OUString m_LastFailedPkgURL;
};
-SdrMediaObj::SdrMediaObj(SdrModel& rSdrModel)
-: SdrRectObj(rSdrModel)
- ,m_xImpl( new Impl )
+
+SdrMediaObj::SdrMediaObj()
+ : SdrRectObj()
+ , m_xImpl( new Impl )
{
}
-SdrMediaObj::SdrMediaObj(
- SdrModel& rSdrModel,
- const tools::Rectangle& rRect)
-: SdrRectObj(rSdrModel, rRect)
- ,m_xImpl( new Impl )
+SdrMediaObj::SdrMediaObj( const tools::Rectangle& rRect )
+ : SdrRectObj( rRect )
+ , m_xImpl( new Impl )
{
}
@@ -142,9 +141,9 @@ OUString SdrMediaObj::TakeObjNamePlural() const
return ImpGetResStr(STR_ObjNamePluralMEDIA);
}
-SdrMediaObj* SdrMediaObj::Clone(SdrModel* pTargetModel) const
+SdrMediaObj* SdrMediaObj::Clone() const
{
- return CloneHelper< SdrMediaObj >(pTargetModel);
+ return CloneHelper< SdrMediaObj >();
}
SdrMediaObj& SdrMediaObj::operator=(const SdrMediaObj& rObj)
@@ -316,14 +315,8 @@ void SdrMediaObj::SetInputStream(uno::Reference<io::XInputStream> const& xStream
SAL_WARN("svx", "this is only intended for embedded media");
return;
}
-
OUString tempFileURL;
- const bool bSuccess(
- lcl_CopyToTempFile(
- xStream,
- tempFileURL,
- ""));
-
+ bool const bSuccess = lcl_CopyToTempFile(xStream, tempFileURL, "");
if (bSuccess)
{
m_xImpl->m_pTempFile.reset(new MediaTempFile(tempFileURL));
@@ -338,14 +331,19 @@ void SdrMediaObj::SetInputStream(uno::Reference<io::XInputStream> const& xStream
/// copy a stream from XStorage to temp file
#if HAVE_FEATURE_AVMEDIA
static bool lcl_HandlePackageURL(
- OUString const & rURL,
- const SdrModel& rModel,
- OUString & o_rTempFileURL)
+ OUString const & rURL,
+ SdrModel const *const pModel,
+ OUString & o_rTempFileURL)
{
+ if (!pModel)
+ {
+ SAL_WARN("svx", "no model");
+ return false;
+ }
::comphelper::LifecycleProxy sourceProxy;
uno::Reference<io::XInputStream> xInStream;
try {
- xInStream = rModel.GetDocumentStream(rURL, sourceProxy);
+ xInStream = pModel->GetDocumentStream(rURL, sourceProxy);
}
catch (container::NoSuchElementException const&)
{
@@ -396,12 +394,8 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
rNewProperties.getTempURL()))
{
OUString tempFileURL;
- const bool bSuccess(
- lcl_HandlePackageURL(
- url,
- getSdrModelFromSdrObject(),
- tempFileURL));
-
+ bool bSuccess;
+ bSuccess = lcl_HandlePackageURL(url, GetModel(), tempFileURL);
if (bSuccess)
{
m_xImpl->m_pTempFile.reset(
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 50595c5766df..8a264270bddf 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -663,42 +663,13 @@ sdr::contact::ViewContact* SdrOle2Obj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfSdrOle2Obj(*this);
}
-void SdrOle2Obj::Init()
-{
- // Stuff that was done from old SetModel:
- // #i43086# #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
- // so maybe the ImpSetVisAreaSize call can be removed here completely
- // Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
- if(!getSdrModelFromSdrObject().isLocked() && !IsChart())
- {
- ImpSetVisAreaSize();
- }
-
- ::comphelper::IEmbeddedHelper* pDestPers(getSdrModelFromSdrObject().GetPersist());
- if(pDestPers && !IsEmptyPresObj())
- {
- // object wasn't connected, now it should be
- Connect_Impl();
- }
-
- AddListeners_Impl();
-}
-
-SdrOle2Obj::SdrOle2Obj(
- SdrModel& rSdrModel,
- bool bFrame_)
-: SdrRectObj(rSdrModel),
+SdrOle2Obj::SdrOle2Obj( bool bFrame_ ) :
mpImpl(new SdrOle2ObjImpl(bFrame_))
{
- Init();
}
-SdrOle2Obj::SdrOle2Obj(
- SdrModel& rSdrModel,
- const svt::EmbeddedObjectRef& rNewObjRef,
- const OUString& rNewObjName,
- const tools::Rectangle& rNewRect)
-: SdrRectObj(rSdrModel, rNewRect),
+SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const OUString& rNewObjName, const tools::Rectangle& rNewRect) :
+ SdrRectObj(rNewRect),
mpImpl(new SdrOle2ObjImpl(false/*bFrame_*/, rNewObjRef))
{
mpImpl->aPersistName = rNewObjName;
@@ -708,8 +679,6 @@ SdrOle2Obj::SdrOle2Obj(
// For math objects, set closed state to transparent
SetClosedObj(!ImplIsMathObj( mpImpl->mxObjRef.GetObject() ));
-
- Init();
}
OUString SdrOle2Obj::GetStyleString()
@@ -812,8 +781,7 @@ bool SdrOle2Obj::UpdateLinkURL_Impl()
if ( mpImpl->mpObjectLink )
{
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
-
+ sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : nullptr;
if ( pLinkManager )
{
OUString aNewLinkURL;
@@ -863,7 +831,9 @@ bool SdrOle2Obj::UpdateLinkURL_Impl()
void SdrOle2Obj::BreakFileLink_Impl()
{
- uno::Reference<document::XStorageBasedDocument> xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY);
+ uno::Reference<document::XStorageBasedDocument> xDoc;
+ if ( pModel )
+ xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
if ( xDoc.is() )
{
@@ -888,8 +858,7 @@ void SdrOle2Obj::BreakFileLink_Impl()
void SdrOle2Obj::DisconnectFileLink_Impl()
{
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
-
+ sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : nullptr;
if ( pLinkManager && mpImpl->mpObjectLink )
{
pLinkManager->Remove( mpImpl->mpObjectLink );
@@ -899,21 +868,18 @@ void SdrOle2Obj::DisconnectFileLink_Impl()
void SdrOle2Obj::CheckFileLink_Impl()
{
- if (mpImpl->mxObjRef.GetObject().is() && !mpImpl->mpObjectLink)
+ if (pModel && mpImpl->mxObjRef.GetObject().is() && !mpImpl->mpObjectLink)
{
try
{
uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
-
if ( xLinkSupport.is() && xLinkSupport->isLink() )
{
OUString aLinkURL = xLinkSupport->getLinkURL();
-
if ( !aLinkURL.isEmpty() )
{
// this is a file link so the model link manager should handle it
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
-
+ sfx2::LinkManager* pLinkManager = pModel->GetLinkManager();
if ( pLinkManager )
{
mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
@@ -939,16 +905,14 @@ void SdrOle2Obj::Reconnect_Impl()
void SdrOle2Obj::Connect_Impl()
{
- if(!mpImpl->aPersistName.isEmpty() )
+ if( pModel && !mpImpl->aPersistName.isEmpty() )
{
try
{
- ::comphelper::IEmbeddedHelper* pPers(getSdrModelFromSdrObject().GetPersist());
-
+ ::comphelper::IEmbeddedHelper* pPers = pModel->GetPersist();
if ( pPers )
{
comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer();
-
if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
|| ( mpImpl->mxObjRef.is() && !rContainer.HasEmbeddedObject( mpImpl->mxObjRef.GetObject() ) ) )
{
@@ -993,9 +957,9 @@ void SdrOle2Obj::Connect_Impl()
uno::Reference< container::XChild > xChild( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
if( xChild.is() )
{
- uno::Reference< uno::XInterface > xParent( getSdrModelFromSdrObject().getUnoModel());
+ uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
if( xParent.is())
- xChild->setParent( getSdrModelFromSdrObject().getUnoModel() );
+ xChild->setParent( pModel->getUnoModel() );
}
}
@@ -1076,9 +1040,9 @@ void SdrOle2Obj::Disconnect_Impl()
{
try
{
- if ( !mpImpl->aPersistName.isEmpty() )
+ if ( pModel && !mpImpl->aPersistName.isEmpty() )
{
- if( getSdrModelFromSdrObject().IsInDestruction() )
+ if( pModel->IsInDestruction() )
{
// TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
// remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
@@ -1114,7 +1078,7 @@ void SdrOle2Obj::Disconnect_Impl()
}
else if ( mpImpl->mxObjRef.is() )
{
- if ( getSdrModelFromSdrObject().getUnoModel().is() )
+ if ( pModel->getUnoModel().is() )
{
// remove object, but don't close it (that's up to someone else)
comphelper::EmbeddedObjectContainer* pContainer = mpImpl->mxObjRef.GetContainer();
@@ -1158,9 +1122,8 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
if(pOLEGraphic)
{
// #i118485# allow creating a SdrGrafObj representation
- SdrGrafObj* pClone = new SdrGrafObj(
- getSdrModelFromSdrObject(),
- *pOLEGraphic);
+ SdrGrafObj* pClone = new SdrGrafObj(*pOLEGraphic);
+ pClone->SetModel(GetModel());
// copy transformation
basegfx::B2DHomMatrix aMatrix;
@@ -1178,7 +1141,7 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
// #i118485# copy text (Caution! Model needed, as guaranteed in aw080)
OutlinerParaObject* pOPO = GetOutlinerParaObject();
- if(pOPO)
+ if(pOPO && GetModel())
{
pClone->NbcSetOutlinerParaObject(new OutlinerParaObject(*pOPO));
}
@@ -1190,9 +1153,8 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
{
// #i100710# pOLEGraphic may be zero (no visualisation available),
// so we need to use the OLE replacement graphic
- SdrRectObj* pClone = new SdrRectObj(
- getSdrModelFromSdrObject(),
- GetSnapRect());
+ SdrRectObj* pClone = new SdrRectObj(GetSnapRect());
+ pClone->SetModel(GetModel());
// gray outline
pClone->SetMergedItem(XLineStyleItem(css::drawing::LineStyle_SOLID));
@@ -1213,19 +1175,92 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
SdrObject* SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
// #i118485# missing converter added
- SdrObject* pRetval = createSdrGrafObjReplacement(true);
-
- if(pRetval)
+ if(GetModel())
{
- SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
- SdrObject::Free(pRetval);
+ SdrObject* pRetval = createSdrGrafObjReplacement(true);
+
+ if(pRetval)
+ {
+ SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
+ SdrObject::Free(pRetval);
- return pRetval2;
+ return pRetval2;
+ }
}
return nullptr;
}
+void SdrOle2Obj::SetModel(SdrModel* pNewModel)
+{
+ ::comphelper::IEmbeddedHelper* pDestPers = pNewModel ? pNewModel->GetPersist() : nullptr;
+ ::comphelper::IEmbeddedHelper* pSrcPers = pModel ? pModel->GetPersist() : nullptr;
+
+ if ( pNewModel == pModel )
+ {
+ // don't know if this is necessary or if it will ever happen, but who knows?!
+ SdrRectObj::SetModel( pNewModel );
+ return;
+ }
+
+ // assignment to model has changed
+ DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
+
+ DBG_ASSERT( pDestPers, "The destination model must have a persistence! Please submit an issue!" );
+ DBG_ASSERT( pDestPers != pSrcPers, "The source and the destination models should have different persistences! Problems are possible!" );
+
+ // this is a bug if the target model has no persistence
+ // no error handling is possible so just do nothing in this method
+ if ( !pDestPers )
+ return;
+
+ RemoveListeners_Impl();
+
+ if( pDestPers && pSrcPers && !IsEmptyPresObj() )
+ {
+ try
+ {
+ // move the object's storage; ObjectRef remains the same, but PersistName may change
+ OUString aTmp;
+ comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
+ uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
+ DBG_ASSERT( !mpImpl->mxObjRef.is() || mpImpl->mxObjRef.GetObject() == xObj, "Wrong object identity!" );
+ if ( xObj.is() )
+ {
+ pDestPers->getEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
+ mpImpl->aPersistName = aTmp;
+ mpImpl->mxObjRef.AssignToContainer( &pDestPers->getEmbeddedObjectContainer(), aTmp );
+ }
+ DBG_ASSERT( !aTmp.isEmpty(), "Copying embedded object failed!" );
+ }
+ catch( css::uno::Exception& )
+ {
+ SAL_WARN( "svx", "SdrOle2Obj::SetModel(), exception caught: "
+ << comphelper::anyToString( cppu::getCaughtException() ) );
+ }
+ }
+
+ SdrRectObj::SetModel( pNewModel );
+
+ // #i43086#
+ // #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
+ //so maybe the ImpSetVisAreaSize call can be removed here completely
+ //Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
+ if( pModel && !pModel->isLocked() && !IsChart() )
+ ImpSetVisAreaSize();
+
+ if( pDestPers && !IsEmptyPresObj() )
+ {
+ if ( !pSrcPers || IsEmptyPresObj() )
+ // object wasn't connected, now it should be
+ Connect_Impl();
+ else
+ Reconnect_Impl();
+ }
+
+ AddListeners_Impl();
+}
+
void SdrOle2Obj::SetPage(SdrPage* pNewPage)
{
bool bRemove=pNewPage==nullptr && pPage!=nullptr;
@@ -1234,14 +1269,14 @@ void SdrOle2Obj::SetPage(SdrPage* pNewPage)
if (bRemove && mpImpl->mbConnected )
Disconnect();
- if(!GetStyleSheet() && pNewPage)
+ if(!pModel && !GetStyleSheet() && pNewPage && pNewPage->GetModel())
{
// #i119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This
// needs to be done before the style 'Default' is set from the :SetModel() call which is triggered
// from the following :SetPage().
// TTTT: Needs to be moved in branch aw080 due to having a SdrModel from the beginning, is at this
// place for convenience currently (works in both versions, is not in the way)
- SfxStyleSheet* pSheet = pNewPage->getSdrModelFromSdrPage().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
+ SfxStyleSheet* pSheet = pNewPage->GetModel()->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
if(pSheet)
{
@@ -1379,70 +1414,67 @@ OUString SdrOle2Obj::TakeObjNamePlural() const
return ImpGetResStr(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
}
-SdrOle2Obj* SdrOle2Obj::Clone(SdrModel* pTargetModel) const
+SdrOle2Obj* SdrOle2Obj::Clone() const
{
- return CloneHelper< SdrOle2Obj >(pTargetModel);
-}
-
-SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
-{
- return assignFrom(rObj);
+ return CloneHelper< SdrOle2Obj >();
}
SdrOle2Obj& SdrOle2Obj::assignFrom(const SdrOle2Obj& rObj)
{
//TODO/LATER: who takes over control of my old object?!
- if( &rObj == this )
+ if( &rObj != this )
{
- return *this;
- }
-
- // ImpAssign( rObj );
- const SdrOle2Obj& rOle2Obj = rObj;
+ // ImpAssign( rObj );
+ const SdrOle2Obj& rOle2Obj = rObj;
- if( mpImpl->mbConnected )
- Disconnect();
+ if( pModel && mpImpl->mbConnected )
+ Disconnect();
- SdrRectObj::operator=( rObj );
+ SdrRectObj::operator=( rObj );
- // Manually copying bClosedObj attribute
- SetClosedObj( rObj.IsClosedObj() );
+ // Manually copying bClosedObj attribute
+ SetClosedObj( rObj.IsClosedObj() );
- mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
- mpImpl->maProgName = rOle2Obj.mpImpl->maProgName;
- mpImpl->mbFrame = rOle2Obj.mpImpl->mbFrame;
+ mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
+ mpImpl->maProgName = rOle2Obj.mpImpl->maProgName;
+ mpImpl->mbFrame = rOle2Obj.mpImpl->mbFrame;
- if (rOle2Obj.mpImpl->mxGraphic)
- {
- mpImpl->mxGraphic.reset(new Graphic(*rOle2Obj.mpImpl->mxGraphic));
- }
+ if (rOle2Obj.mpImpl->mxGraphic)
+ {
+ mpImpl->mxGraphic.reset(new Graphic(*rOle2Obj.mpImpl->mxGraphic));
+ }
- if( !IsEmptyPresObj() )
- {
- ::comphelper::IEmbeddedHelper* pDestPers(getSdrModelFromSdrObject().GetPersist());
- ::comphelper::IEmbeddedHelper* pSrcPers(rObj.getSdrModelFromSdrObject().GetPersist());
- if( pDestPers && pSrcPers )
+ if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
{
- DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" );
- comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
- uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
- if ( xObj.is() )
+ ::comphelper::IEmbeddedHelper* pDestPers = pModel->GetPersist();
+ ::comphelper::IEmbeddedHelper* pSrcPers = rObj.GetModel()->GetPersist();
+ if( pDestPers && pSrcPers )
{
- OUString aTmp;
- mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
- rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rOle2Obj.GetAspect());
- mpImpl->mbTypeAsked = false;
- mpImpl->aPersistName = aTmp;
- CheckFileLink_Impl();
- }
+ DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" );
+ comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
+ uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
+ if ( xObj.is() )
+ {
+ OUString aTmp;
+ mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
+ rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rOle2Obj.GetAspect());
+ mpImpl->mbTypeAsked = false;
+ mpImpl->aPersistName = aTmp;
+ CheckFileLink_Impl();
+ }
- Connect();
+ Connect();
+ }
}
}
-
return *this;
}
+SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
+{
+ return assignFrom(rObj);
+}
+
void SdrOle2Obj::ImpSetVisAreaSize()
{
// #i118524# do not again set VisAreaSize when the call comes from OLE client (e.g. ObjectAreaChanged)
@@ -1458,17 +1490,14 @@ void SdrOle2Obj::ImpSetVisAreaSize()
GetObjRef();
if (mpImpl->mxObjRef.is())
{
+ OSL_ASSERT( pModel );
sal_Int64 nMiscStatus = mpImpl->mxObjRef->getStatus( GetAspect() );
// the client is required to get access to scaling
- SfxInPlaceClient* pClient(
- SfxInPlaceClient::GetClient(
- dynamic_cast<SfxObjectShell*>(
- getSdrModelFromSdrObject().GetPersist()),
- mpImpl->mxObjRef.GetObject()));
- const bool bHasOwnClient(
- mpImpl->mxLightClient.is() &&
- mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) );
+ SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() );
+ bool bHasOwnClient =
+ ( mpImpl->mxLightClient.is()
+ && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) );
if ( pClient || bHasOwnClient )
{
@@ -1500,10 +1529,7 @@ void SdrOle2Obj::ImpSetVisAreaSize()
Size aVisSize( static_cast<long>( Fraction( maRect.GetWidth() ) / aScaleWidth ),
static_cast<long>( Fraction( maRect.GetHeight() ) / aScaleHeight ) );
- aVisSize = OutputDevice::LogicToLogic(
- aVisSize,
- MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
- MapMode(aMapUnit));
+ aVisSize = OutputDevice::LogicToLogic(aVisSize, MapMode(pModel->GetScaleUnit()), MapMode(aMapUnit));
awt::Size aSz;
aSz.Width = aVisSize.Width();
aSz.Height = aVisSize.Height();
@@ -1524,11 +1550,7 @@ void SdrOle2Obj::ImpSetVisAreaSize()
// server changed VisArea to its liking and the VisArea is different than the suggested one
// store the new value as given by the object
MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
- maRect.SetSize(
- OutputDevice::LogicToLogic(
- aAcceptedVisArea.GetSize(),
- MapMode(aNewMapUnit),
- MapMode(getSdrModelFromSdrObject().GetScaleUnit())));
+ maRect.SetSize(OutputDevice::LogicToLogic(aAcceptedVisArea.GetSize(), MapMode(aNewMapUnit), MapMode(pModel->GetScaleUnit())));
}
// make the new object area known to the client
@@ -1574,30 +1596,13 @@ void SdrOle2Obj::ImpSetVisAreaSize()
uno::Reference< embed::XVisualObject > xVisualObject( getXModel(), uno::UNO_QUERY );
if( xVisualObject.is() )
{
- const MapUnit aMapUnit(
- VCLUnoHelper::UnoEmbed2VCLMapUnit(
- mpImpl->mxObjRef->getMapUnit(GetAspect())));
- const Point aTL( maRect.TopLeft() );
- const Point aBR( maRect.BottomRight() );
- const Point aTL2(
- OutputDevice::LogicToLogic(
- aTL,
- MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
- MapMode(aMapUnit)));
- const Point aBR2(
- OutputDevice::LogicToLogic(
- aBR,
- MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
- MapMode(aMapUnit)));
- const tools::Rectangle aNewRect(
- aTL2,
- aBR2);
-
- xVisualObject->setVisualAreaSize(
- GetAspect(),
- awt::Size(
- aNewRect.GetWidth(),
- aNewRect.GetHeight()));
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
+ Point aTL( maRect.TopLeft() );
+ Point aBR( maRect.BottomRight() );
+ Point aTL2(OutputDevice::LogicToLogic(aTL, MapMode(pModel->GetScaleUnit()), MapMode(aMapUnit)));
+ Point aBR2(OutputDevice::LogicToLogic(aBR, MapMode(pModel->GetScaleUnit()), MapMode(aMapUnit)));
+ tools::Rectangle aNewRect( aTL2, aBR2 );
+ xVisualObject->setVisualAreaSize( GetAspect(), awt::Size( aNewRect.GetWidth(), aNewRect.GetHeight() ) );
}
}
}
@@ -1605,10 +1610,9 @@ void SdrOle2Obj::ImpSetVisAreaSize()
void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
- if(!getSdrModelFromSdrObject().isLocked())
+ if( pModel && !pModel->isLocked() )
{
GetObjRef();
-
if ( mpImpl->mxObjRef.is() && ( mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
{
// if the object needs recompose on resize
@@ -1619,8 +1623,7 @@ void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
}
SdrRectObj::NbcResize(rRef,xFact,yFact);
-
- if( !getSdrModelFromSdrObject().isLocked() )
+ if( pModel && !pModel->isLocked() )
ImpSetVisAreaSize();
}
@@ -1628,7 +1631,7 @@ void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
{
SdrRectObj::SetGeoData(rGeo);
- if( !getSdrModelFromSdrObject().isLocked() )
+ if( pModel && !pModel->isLocked() )
ImpSetVisAreaSize();
}
@@ -1636,7 +1639,7 @@ void SdrOle2Obj::NbcSetSnapRect(const tools::Rectangle& rRect)
{
SdrRectObj::NbcSetSnapRect(rRect);
- if( !getSdrModelFromSdrObject().isLocked() )
+ if( pModel && !pModel->isLocked() )
ImpSetVisAreaSize();
if ( mpImpl->mxObjRef.is() && IsChart() )
@@ -1652,7 +1655,7 @@ void SdrOle2Obj::NbcSetLogicRect(const tools::Rectangle& rRect)
{
SdrRectObj::NbcSetLogicRect(rRect);
- if( !getSdrModelFromSdrObject().isLocked() )
+ if( pModel && !pModel->isLocked() )
ImpSetVisAreaSize();
}
@@ -1683,7 +1686,7 @@ void SdrOle2Obj::NbcMove(const Size& rSize)
{
SdrRectObj::NbcMove(rSize);
- if( !getSdrModelFromSdrObject().isLocked() )
+ if( pModel && !pModel->isLocked() )
ImpSetVisAreaSize();
}
@@ -1755,8 +1758,7 @@ bool SdrOle2Obj::Unload()
return true;
bool bUnloaded = false;
-
- if ( mpImpl->mxObjRef.is() )
+ if ( pModel && mpImpl->mxObjRef.is() )
{
bUnloaded = Unload( mpImpl->mxObjRef.GetObject(), GetAspect() );
}
@@ -1766,14 +1768,12 @@ bool SdrOle2Obj::Unload()
void SdrOle2Obj::GetObjRef_Impl()
{
- if ( !mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty() && getSdrModelFromSdrObject().GetPersist() )
+ if ( !mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty() && pModel && pModel->GetPersist() )
{
// Only try loading if it did not went wrong up to now
if(!mpImpl->mbLoadingOLEObjectFailed)
{
- mpImpl->mxObjRef.Assign(
- getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject(mpImpl->aPersistName),
- GetAspect());
+ mpImpl->mxObjRef.Assign( pModel->GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
mpImpl->mbTypeAsked = false;
CheckFileLink_Impl();
@@ -1793,7 +1793,7 @@ void SdrOle2Obj::GetObjRef_Impl()
if( !IsEmptyPresObj() )
{
// remember modified status of model
- const bool bWasChanged(getSdrModelFromSdrObject().IsChanged());
+ const bool bWasChanged = pModel && pModel->IsChanged();
// perhaps preview not valid anymore
// This line changes the modified state of the model
@@ -1802,9 +1802,9 @@ void SdrOle2Obj::GetObjRef_Impl()
// if status was not set before, force it back
// to not set, so that SetGraphic(0) above does not
// set the modified state of the model.
- if(!bWasChanged && getSdrModelFromSdrObject().IsChanged())
+ if(!bWasChanged && pModel && pModel->IsChanged())
{
- getSdrModelFromSdrObject().SetChanged( false );
+ pModel->SetChanged( false );
}
}
}
@@ -1889,7 +1889,9 @@ bool SdrOle2Obj::IsCalc() const
uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
{
- uno::Reference< frame::XModel > xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY);
+ uno::Reference< frame::XModel > xDoc;
+ if ( pModel )
+ xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
return xDoc;
}
@@ -1897,10 +1899,10 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei
{
// TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
// If we don't cache it for own objects also we must load the object here
- if (!mpImpl->mxObjRef.is())
+ if ( !mpImpl->mxObjRef.is() || !pModel )
return false;
- MapMode aMapMode(getSdrModelFromSdrObject().GetScaleUnit());
+ MapMode aMapMode( pModel->GetScaleUnit() );
aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode );
Size aSize = maRect.GetSize();
@@ -1917,7 +1919,7 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei
bool SdrOle2Obj::AddOwnLightClient()
{
// The Own Light Client must be registered in object only using this method!
- if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(getSdrModelFromSdrObject().GetPersist()), mpImpl->mxObjRef.GetObject() )
+ if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() )
&& !( mpImpl->mxLightClient.is() && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) ) )
{
Connect();
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
index af38237fa632..a2a6592037ee 100644
--- a/svx/source/svdraw/svdopage.cxx
+++ b/svx/source/svdraw/svdopage.cxx
@@ -64,11 +64,9 @@ void SdrPageObj::PageInDestruction(const SdrPage& rPage)
}
}
-SdrPageObj::SdrPageObj(
- SdrModel& rSdrModel,
- SdrPage* pNewPage)
-: SdrObject(rSdrModel),
- mpShownPage(pNewPage)
+
+SdrPageObj::SdrPageObj(SdrPage* pNewPage)
+: mpShownPage(pNewPage)
{
if(mpShownPage)
{
@@ -76,12 +74,8 @@ SdrPageObj::SdrPageObj(
}
}
-SdrPageObj::SdrPageObj(
- SdrModel& rSdrModel,
- const tools::Rectangle& rRect,
- SdrPage* pNewPage)
-: SdrObject(rSdrModel),
- mpShownPage(pNewPage)
+SdrPageObj::SdrPageObj(const tools::Rectangle& rRect, SdrPage* pNewPage)
+: mpShownPage(pNewPage)
{
if(mpShownPage)
{
@@ -150,9 +144,9 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
rInfo.bCanConvToPolyLineToArea=false;
}
-SdrPageObj* SdrPageObj::Clone(SdrModel* pTargetModel) const
+SdrPageObj* SdrPageObj::Clone() const
{
- return CloneHelper< SdrPageObj >(pTargetModel);
+ return CloneHelper< SdrPageObj >();
}
SdrPageObj& SdrPageObj::operator=(const SdrPageObj& rObj)
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index fc991ab478c3..5cf8dd58c115 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -941,27 +941,27 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
{
aStr += SdrModel::GetAngleString(std::abs(pU->nCircRelAngle))
+ " r="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(pU->nCircRadius, true);
+ + mrSdrPathObject.GetModel()->GetMetricString(pU->nCircRadius, true);
}
aStr += "dx="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.X(), true)
+ + mrSdrPathObject.GetModel()->GetMetricString(aNow.X(), true)
+ " dy="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.Y(), true);
+ + mrSdrPathObject.GetModel()->GetMetricString(aNow.Y(), true);
if(!IsFreeHand(meObjectKind))
{
sal_Int32 nLen(GetLen(aNow));
sal_Int32 nAngle(GetAngle(aNow));
aStr += " l="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
aStr += ")";
}
- else if(!pHdl)
+ else if(!mrSdrPathObject.GetModel() || !pHdl)
{
// #i103058# fallback when no model and/or Handle, both needed
// for else-path
@@ -1011,9 +1011,9 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
aStr.clear();
aStr += "dx="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.X() - aBeg.X(), true)
+ + mrSdrPathObject.GetModel()->GetMetricString(aNow.X() - aBeg.X(), true)
+ " dy="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.Y() - aBeg.Y(), true);
+ + mrSdrPathObject.GetModel()->GetMetricString(aNow.Y() - aBeg.Y(), true);
if(!pDragData->IsMultiPointDrag())
{
@@ -1040,7 +1040,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
sal_Int32 nLen(GetLen(aNow));
sal_Int32 nAngle(GetAngle(aNow));
aStr += " l="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
@@ -1083,7 +1083,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
sal_Int32 nLen(GetLen(aPt));
sal_Int32 nAngle(GetAngle(aPt));
aStr += " l="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
@@ -1101,7 +1101,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
sal_Int32 nLen(GetLen(aPt));
sal_Int32 nAngle(GetAngle(aPt));
aStr += "l="
- + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
@@ -1628,21 +1628,14 @@ sdr::contact::ViewContact* SdrPathObj::CreateObjectSpecificViewContact()
}
-SdrPathObj::SdrPathObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewKind)
-: SdrTextObj(rSdrModel),
- meKind(eNewKind)
+SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
+: meKind(eNewKind)
{
bClosedObj = IsClosed();
}
-SdrPathObj::SdrPathObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewKind,
- const basegfx::B2DPolyPolygon& rPathPoly)
-: SdrTextObj(rSdrModel),
- maPathPolygon(rPathPoly),
+SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly)
+: maPathPolygon(rPathPoly),
meKind(eNewKind)
{
bClosedObj = IsClosed();
@@ -1828,9 +1821,9 @@ sal_uInt16 SdrPathObj::GetObjIdentifier() const
return sal_uInt16(meKind);
}
-SdrPathObj* SdrPathObj::Clone(SdrModel* pTargetModel) const
+SdrPathObj* SdrPathObj::Clone() const
{
- return CloneHelper< SdrPathObj >(pTargetModel);
+ return CloneHelper< SdrPathObj >();
}
SdrPathObj& SdrPathObj::operator=(const SdrPathObj& rObj)
@@ -2886,7 +2879,7 @@ bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DP
}
// position maybe relative to anchorpos, convert
- if( getSdrModelFromSdrObject().IsWriter() )
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -2995,7 +2988,7 @@ void SdrPathObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
}
}
- if( getSdrModelFromSdrObject().IsWriter() )
+ if( pModel && pModel->IsWriter() )
{
// if anchor is used, make position relative to it
if(GetAnchorPos().X() || GetAnchorPos().Y())
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index e68b38ce3205..7f85da4b71a8 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -62,26 +62,21 @@ sdr::contact::ViewContact* SdrRectObj::CreateObjectSpecificViewContact()
}
-SdrRectObj::SdrRectObj(SdrModel& rSdrModel)
-: SdrTextObj(rSdrModel),
- mpXPoly(nullptr)
+SdrRectObj::SdrRectObj()
+: mpXPoly(nullptr)
{
bClosedObj=true;
}
-SdrRectObj::SdrRectObj(
- SdrModel& rSdrModel,
- const tools::Rectangle& rRect)
-: SdrTextObj(rSdrModel, rRect),
+SdrRectObj::SdrRectObj(const tools::Rectangle& rRect)
+: SdrTextObj(rRect),
mpXPoly(nullptr)
{
bClosedObj=true;
}
-SdrRectObj::SdrRectObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewTextKind)
-: SdrTextObj(rSdrModel, eNewTextKind),
+SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind)
+: SdrTextObj(eNewTextKind),
mpXPoly(nullptr)
{
DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
@@ -90,11 +85,8 @@ SdrRectObj::SdrRectObj(
bClosedObj=true;
}
-SdrRectObj::SdrRectObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewTextKind,
- const tools::Rectangle& rRect)
-: SdrTextObj(rSdrModel, eNewTextKind, rRect),
+SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const tools::Rectangle& rRect)
+: SdrTextObj(eNewTextKind,rRect),
mpXPoly(nullptr)
{
DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
@@ -107,6 +99,21 @@ SdrRectObj::~SdrRectObj()
{
}
+SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
+{
+ if ( this == &rCopy )
+ return *this;
+
+ SdrTextObj::operator=( rCopy );
+
+ if ( rCopy.mpXPoly )
+ mpXPoly.reset( new XPolygon( *rCopy.mpXPoly ) );
+ else
+ mpXPoly.reset();
+
+ return *this;
+}
+
void SdrRectObj::SetXPolyDirty()
{
mpXPoly.reset();
@@ -259,24 +266,9 @@ OUString SdrRectObj::TakeObjNamePlural() const
return ImpGetResStr(pResId);
}
-SdrRectObj* SdrRectObj::Clone(SdrModel* pTargetModel) const
+SdrRectObj* SdrRectObj::Clone() const
{
- return CloneHelper< SdrRectObj >(pTargetModel);
-}
-
-SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
-{
- if ( this == &rCopy )
- return *this;
-
- SdrTextObj::operator=( rCopy );
-
- if ( rCopy.mpXPoly )
- mpXPoly.reset( new XPolygon( *rCopy.mpXPoly ) );
- else
- mpXPoly.reset();
-
- return *this;
+ return CloneHelper< SdrRectObj >();
}
basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 63ca33f850fc..cf4448fac249 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -64,20 +64,25 @@
using namespace com::sun::star;
+
// BaseProperties section
+
sdr::properties::BaseProperties* SdrTextObj::CreateObjectSpecificProperties()
{
return new sdr::properties::TextProperties(*this);
}
+
// DrawContact section
+
sdr::contact::ViewContact* SdrTextObj::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfTextObj(*this);
}
-SdrTextObj::SdrTextObj(SdrModel& rSdrModel)
-: SdrAttrObj(rSdrModel),
+
+SdrTextObj::SdrTextObj()
+: SdrAttrObj(),
mpText(nullptr),
pEdtOutl(nullptr),
eTextKind(OBJ_TEXT)
@@ -97,10 +102,8 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel)
mbInDownScale = false;
}
-SdrTextObj::SdrTextObj(
- SdrModel& rSdrModel,
- const tools::Rectangle& rNewRect)
-: SdrAttrObj(rSdrModel),
+SdrTextObj::SdrTextObj(const tools::Rectangle& rNewRect)
+: SdrAttrObj(),
maRect(rNewRect),
mpText(nullptr),
pEdtOutl(nullptr),
@@ -122,10 +125,8 @@ SdrTextObj::SdrTextObj(
mbSupportTextIndentingOnLineWidthChange = true;
}
-SdrTextObj::SdrTextObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewTextKind)
-: SdrAttrObj(rSdrModel),
+SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
+: SdrAttrObj(),
mpText(nullptr),
pEdtOutl(nullptr),
eTextKind(eNewTextKind)
@@ -145,11 +146,8 @@ SdrTextObj::SdrTextObj(
mbSupportTextIndentingOnLineWidthChange = true;
}
-SdrTextObj::SdrTextObj(
- SdrModel& rSdrModel,
- SdrObjKind eNewTextKind,
- const tools::Rectangle& rNewRect)
-: SdrAttrObj(rSdrModel),
+SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect)
+: SdrAttrObj(),
maRect(rNewRect),
mpText(nullptr),
pEdtOutl(nullptr),
@@ -173,19 +171,25 @@ SdrTextObj::SdrTextObj(
SdrTextObj::~SdrTextObj()
{
- SdrOutliner& rOutl(getSdrModelFromSdrObject().GetHitTestOutliner());
- if( rOutl.GetTextObj() == this )
- rOutl.SetTextObj( nullptr );
+ if( pModel )
+ {
+ SdrOutliner& rOutl = pModel->GetHitTestOutliner();
+ if( rOutl.GetTextObj() == this )
+ rOutl.SetTextObj( nullptr );
+ }
+
mpText.reset();
+
ImpDeregisterLink();
}
void SdrTextObj::FitFrameToTextSize()
{
+ DBG_ASSERT(pModel!=nullptr,"SdrTextObj::FitFrameToTextSize(): pModel=NULL!");
ImpJustifyRect(maRect);
SdrText* pText = getActiveText();
- if(pText==nullptr || !pText->GetOutlinerParaObject())
+ if( pText==nullptr || !pText->GetOutlinerParaObject() || pModel==nullptr)
return;
SdrOutliner& rOutliner=ImpGetDrawOutliner();
@@ -474,6 +478,39 @@ void SdrTextObj::SetPage(SdrPage* pNewPage)
}
}
+void SdrTextObj::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel=pModel;
+ bool bLinked=IsLinkedText();
+ bool bChg=pNewModel!=pModel;
+
+ if (bLinked && bChg)
+ {
+ ImpDeregisterLink();
+ }
+
+ SdrAttrObj::SetModel(pNewModel);
+
+ if( bChg )
+ {
+ if( pNewModel != nullptr && pOldModel != nullptr )
+ SetTextSizeDirty();
+
+ sal_Int32 nCount = getTextCount();
+ for( sal_Int32 nText = 0; nText < nCount; nText++ )
+ {
+ SdrText* pText = getText( nText );
+ if( pText )
+ pText->SetModel( pNewModel );
+ }
+ }
+
+ if (bLinked && bChg)
+ {
+ ImpRegisterLink();
+ }
+}
+
void SdrTextObj::NbcSetEckenradius(long nRad)
{
SetObjectItem(makeSdrEckenradiusItem(nRad));
@@ -487,7 +524,7 @@ void SdrTextObj::AdaptTextMinSize()
// Only do this for text frame.
return;
- if (getSdrModelFromSdrObject().IsPasteResize())
+ if (pModel && pModel->IsPasteResize())
// Don't do this during paste resize.
return;
@@ -717,9 +754,11 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRe
if (pPara)
{
- const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
- const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+ bool bHitTest = false;
+ if( pModel )
+ bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
+ const SdrTextObj* pTestObj = rOutliner.GetTextObj();
if( !pTestObj || !bHitTest || pTestObj != this ||
pTestObj->GetOutlinerParaObject() != pOutlinerParaObject )
{
@@ -1010,9 +1049,9 @@ OUString SdrTextObj::TakeObjNamePlural() const
return sName;
}
-SdrTextObj* SdrTextObj::Clone(SdrModel* pTargetModel) const
+SdrTextObj* SdrTextObj::Clone() const
{
- return CloneHelper< SdrTextObj >(pTargetModel);
+ return CloneHelper< SdrTextObj >();
}
SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj)
@@ -1072,7 +1111,7 @@ basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const
basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour());
// and now add the BoundRect of the text, if necessary
- if ( GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
+ if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
{
// using Clone()-Paint() strategy inside TakeContour() leaves a destroyed
// SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner
@@ -1174,7 +1213,7 @@ void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const
SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const
{
- SdrOutliner& rOutl(getSdrModelFromSdrObject().GetDrawOutliner(this));
+ SdrOutliner& rOutl=pModel->GetDrawOutliner(this);
// Code extracted to ImpInitDrawOutliner()
ImpInitDrawOutliner( rOutl );
@@ -1222,7 +1261,7 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame,
double SdrTextObj::GetFontScaleY() const
{
SdrText* pText = getActiveText();
- if (pText == nullptr || !pText->GetOutlinerParaObject())
+ if (pText == nullptr || !pText->GetOutlinerParaObject() || pModel == nullptr)
return 1.0;
SdrOutliner& rOutliner = ImpGetDrawOutliner();
@@ -1364,21 +1403,17 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, tools::Rectangle&
tools::Rectangle aAnchorRect;
Fraction aFitXCorrection(1,1);
- const bool bContourFrame(IsContourTextFrame());
- const MapMode aMapMode(
- getSdrModelFromSdrObject().GetScaleUnit(),
- Point(0,0),
- getSdrModelFromSdrObject().GetScaleFraction(),
- getSdrModelFromSdrObject().GetScaleFraction());
+ bool bContourFrame=IsContourTextFrame();
+
+ if( GetModel() )
+ {
+ MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0),
+ GetModel()->GetScaleFraction(),
+ GetModel()->GetScaleFraction());
+ rOutl.SetRefMapMode(aMapMode);
+ }
- rOutl.SetRefMapMode(aMapMode);
- ImpSetupDrawOutlinerForPaint(
- bContourFrame,
- rOutl,
- aTextRect,
- aAnchorRect,
- rPaintRect,
- aFitXCorrection);
+ ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXCorrection );
}
@@ -1526,7 +1561,7 @@ TextChain *SdrTextObj::GetTextChain() const
//if (!IsChainable())
// return NULL;
- return getSdrModelFromSdrObject().GetTextChain();
+ return pModel->GetTextChain();
}
bool SdrTextObj::IsVerticalWriting() const
@@ -1635,7 +1670,7 @@ bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DP
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position maybe relative to anchorpos, convert
- if( getSdrModelFromSdrObject().IsWriter() )
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -1734,7 +1769,7 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
}
// if anchor is used, make position relative to it
- if( getSdrModelFromSdrObject().IsWriter() )
+ if( pModel && pModel->IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index b50736972d35..af6977fc3cbe 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -973,9 +973,8 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
// Usual processing - always grow in one of directions
bool bAllowGrowVertical = !bVerticalWriting;
bool bAllowGrowHorizontal = bVerticalWriting;
-
// Compatibility mode for tdf#99729
- if (getSdrModelFromSdrObject().IsAnchoredTextOverflowLegacy())
+ if (pModel->IsAnchoredTextOverflowLegacy())
{
bAllowGrowVertical = bHorizontalIsBlock;
bAllowGrowHorizontal = bVerticalIsBlock;
@@ -1467,7 +1466,7 @@ void SdrTextObj::impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutlin
if (bIsOverflow && !IsInEditMode()) {
// Initialize Chaining Outliner
- SdrOutliner &rChainingOutl(getSdrModelFromSdrObject().GetChainingOutliner(this));
+ SdrOutliner &rChainingOutl = pModel->GetChainingOutliner(this);
ImpInitDrawOutliner( rChainingOutl );
rChainingOutl.SetUpdateMode(true);
// We must pass the chaining outliner otherwise we would mess up decomposition
diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx
index e88e55519930..f4c9528d4125 100644
--- a/svx/source/svdraw/svdotxat.cxx
+++ b/svx/source/svdraw/svdotxat.cxx
@@ -62,6 +62,10 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight( tools::Rectangle& rR, bool bHgt,
// Not a text frame. Bail out.
return false;
+ if (!pModel)
+ // Model doesn't exist. Bail out.
+ return false;
+
if (rR.IsEmpty())
// Empty rectangle.
return false;
@@ -91,7 +95,7 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight( tools::Rectangle& rR, bool bHgt,
aNewSize.AdjustWidth( -1 ); aNewSize.AdjustHeight( -1 );
Size aMaxSiz(100000, 100000);
- Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
+ Size aTmpSiz = pModel->GetMaxObjSize();
if (aTmpSiz.Width())
aMaxSiz.setWidth( aTmpSiz.Width() );
@@ -308,7 +312,7 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight()
void SdrTextObj::ImpSetTextStyleSheetListeners()
{
- SfxStyleSheetBasePool* pStylePool(getSdrModelFromSdrObject().GetStyleSheetPool());
+ SfxStyleSheetBasePool* pStylePool=pModel!=nullptr ? pModel->GetStyleSheetPool() : nullptr;
if (pStylePool!=nullptr)
{
std::vector<OUString> aStyleNames;
diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx
index bb3e60d9291b..3290435144b1 100644
--- a/svx/source/svdraw/svdotxed.cxx
+++ b/svx/source/svdraw/svdotxed.cxx
@@ -49,7 +49,7 @@ bool SdrTextObj::BegTextEdit(SdrOutliner& rOutl)
if ( !IsOutlText() )
nOutlinerMode = OutlinerMode::TextObject;
rOutl.Init( nOutlinerMode );
- rOutl.SetRefDevice(getSdrModelFromSdrObject().GetRefDevice());
+ rOutl.SetRefDevice( pModel->GetRefDevice() );
bool bFitToSize(IsFitToSize());
bool bContourFrame=IsContourTextFrame();
@@ -146,9 +146,11 @@ void SdrTextObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Recta
Size aAnkSiz(aViewInit.GetSize());
aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() adds 1
Size aMaxSiz(1000000,1000000);
- Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
- if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
- if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
+ if (pModel!=nullptr) {
+ Size aTmpSiz(pModel->GetMaxObjSize());
+ if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
+ if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
+ }
// Done earlier since used in else tree below
SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust());
diff --git a/svx/source/svdraw/svdotxln.cxx b/svx/source/svdraw/svdotxln.cxx
index 27d4b9679da8..75964d95d60b 100644
--- a/svx/source/svdraw/svdotxln.cxx
+++ b/svx/source/svdraw/svdotxln.cxx
@@ -67,9 +67,8 @@ void ImpSdrObjTextLink::Closed()
const OUString& /*rMimeType*/, const css::uno::Any & /*rValue */)
{
bool bForceReload = false;
- SdrModel* pModel(pSdrObj ? &pSdrObj->getSdrModelFromSdrObject() : nullptr);
- sfx2::LinkManager* pLinkManager(pModel ? pModel->GetLinkManager() : nullptr);
-
+ SdrModel* pModel = pSdrObj ? pSdrObj->GetModel() : nullptr;
+ sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : nullptr;
if( pLinkManager )
{
ImpSdrObjTextLinkUserData* pData=pSdrObj->GetLinkUserData();
@@ -255,7 +254,7 @@ ImpSdrObjTextLinkUserData* SdrTextObj::GetLinkUserData() const
void SdrTextObj::ImpRegisterLink()
{
ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+ sfx2::LinkManager* pLinkManager=pModel!=nullptr ? pModel->GetLinkManager() : nullptr;
if (pLinkManager!=nullptr && pData!=nullptr && pData->pLink==nullptr) { // don't register twice
pData->pLink = new ImpSdrObjTextLink(this);
pLinkManager->InsertFileLink(*pData->pLink,OBJECT_CLIENT_FILE,pData->aFileName,
@@ -267,7 +266,7 @@ void SdrTextObj::ImpRegisterLink()
void SdrTextObj::ImpDeregisterLink()
{
ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
- sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+ sfx2::LinkManager* pLinkManager=pModel!=nullptr ? pModel->GetLinkManager() : nullptr;
if (pLinkManager!=nullptr && pData!=nullptr && pData->pLink!=nullptr) { // don't register twice
// when doing Remove, *pLink is deleted implicitly
pLinkManager->Remove( pData->pLink.get() );
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 1a6d4a50a358..40eca1077e38 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -175,7 +175,7 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
AdaptTextMinSize();
- if(bTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
+ if(bTextFrame && (!pModel || !pModel->IsPasteResize()))
{
NbcAdjustTextFrameWidthAndHeight();
}
@@ -313,7 +313,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
if(nResultCount)
{
// prepare own target
- SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+ SdrObjGroup* pGroup = new SdrObjGroup();
SdrObjList* pObjectList = pGroup->GetSubList();
// process results
@@ -355,10 +355,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
aAttributeSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
// create filled SdrPathObj
- pPathObj = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHFILL,
- aPolyPolygon);
+ pPathObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
}
else
{
@@ -369,16 +366,18 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
aAttributeSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
// create line SdrPathObj
- pPathObj = new SdrPathObj(
- getSdrModelFromSdrObject(),
- OBJ_PATHLINE,
- aPolyPolygon);
+ pPathObj = new SdrPathObj(OBJ_PATHLINE, aPolyPolygon);
}
// copy basic information from original
pPathObj->ImpSetAnchorPos(GetAnchorPos());
pPathObj->NbcSetLayer(GetLayer());
- pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
+
+ if(GetModel())
+ {
+ pPathObj->SetModel(GetModel());
+ pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
+ }
// apply prepared ItemSet and add to target
pPathObj->SetMergedItemSet(aAttributeSet);
@@ -434,10 +433,7 @@ SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPol
ePathKind = bClosed ? OBJ_POLY : OBJ_PLIN;
}
- SdrPathObj* pPathObj = new SdrPathObj(
- getSdrModelFromSdrObject(),
- ePathKind,
- aB2DPolyPolygon);
+ SdrPathObj* pPathObj = new SdrPathObj(ePathKind, aB2DPolyPolygon);
if(bBezier)
{
@@ -447,11 +443,18 @@ SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPol
pPathObj->ImpSetAnchorPos(aAnchor);
pPathObj->NbcSetLayer(GetLayer());
- sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
- pPathObj->ClearMergedItem();
- pPathObj->SetMergedItemSet(GetObjectItemSet());
- pPathObj->GetProperties().BroadcastItemChange(aC);
- pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
+
+ if(pModel)
+ {
+ pPathObj->SetModel(pModel);
+
+ sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
+
+ pPathObj->ClearMergedItem();
+ pPathObj->SetMergedItemSet(GetObjectItemSet());
+ pPathObj->GetProperties().BroadcastItemChange(aC);
+ pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
+ }
return pPathObj;
}
@@ -486,7 +489,7 @@ SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, bool bBezier) const
else
{
// not yet a group, create one and add partial and new shapes
- SdrObjGroup* pGrp=new SdrObjGroup(getSdrModelFromSdrObject());
+ SdrObjGroup* pGrp=new SdrObjGroup;
SdrObjList* pOL=pGrp->GetSubList();
pOL->InsertObject(pObj);
pOL->InsertObject(pText);
diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx
index 4a0e071ca8b9..6e364c33ade1 100644
--- a/svx/source/svdraw/svdouno.cxx
+++ b/svx/source/svdraw/svdouno.cxx
@@ -145,11 +145,9 @@ namespace
}
}
-SdrUnoObj::SdrUnoObj(
- SdrModel& rSdrModel,
- const OUString& rModelName)
-: SdrRectObj(rSdrModel),
- m_pImpl( new SdrUnoObjDataHolder )
+
+SdrUnoObj::SdrUnoObj(const OUString& rModelName)
+: m_pImpl( new SdrUnoObjDataHolder )
{
bIsUnoObj = true;
@@ -160,12 +158,9 @@ SdrUnoObj::SdrUnoObj(
CreateUnoControlModel(rModelName);
}
-SdrUnoObj::SdrUnoObj(
- SdrModel& rSdrModel,
- const OUString& rModelName,
- const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
-: SdrRectObj(rSdrModel),
- m_pImpl( new SdrUnoObjDataHolder )
+SdrUnoObj::SdrUnoObj(const OUString& rModelName,
+ const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
+: m_pImpl( new SdrUnoObjDataHolder )
{
bIsUnoObj = true;
@@ -255,9 +250,9 @@ OUString SdrUnoObj::TakeObjNamePlural() const
return ImpGetResStr(STR_ObjNamePluralUno);
}
-SdrUnoObj* SdrUnoObj::Clone(SdrModel* pTargetModel) const
+SdrUnoObj* SdrUnoObj::Clone() const
{
- return CloneHelper< SdrUnoObj >(pTargetModel);
+ return CloneHelper< SdrUnoObj >();
}
SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj)
@@ -333,6 +328,38 @@ bool SdrUnoObj::hasSpecialDrag() const
return false;
}
+bool SdrUnoObj::supportsFullDrag() const
+{
+ // override to have the possibility to enable/disable in debug and
+ // to check some things out. Current solution is working, so default is
+ // enabled
+ static bool bDoSupportFullDrag(true);
+
+ return bDoSupportFullDrag;
+}
+
+SdrObject* SdrUnoObj::getFullDragClone() const
+{
+ SdrObject* pRetval = nullptr;
+ static bool bHandleSpecial(false);
+
+ if(bHandleSpecial)
+ {
+ // special handling for SdrUnoObj (FormControl). Create a SdrGrafObj
+ // for drag containing the graphical representation. This does not work too
+ // well, so the default is to simply clone
+ pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
+ }
+ else
+ {
+ // call parent (simply clone)
+ pRetval = SdrRectObj::getFullDragClone();
+ }
+
+ return pRetval;
+}
+
+
void SdrUnoObj::NbcSetLayer( SdrLayerID _nLayer )
{
if ( GetLayer() == _nLayer )
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
index 4306ecd577fa..2ffcdc313473 100644
--- a/svx/source/svdraw/svdovirt.cxx
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -42,10 +42,8 @@ sdr::contact::ViewContact* SdrVirtObj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfVirtObj(*this);
}
-SdrVirtObj::SdrVirtObj(
- SdrModel& rSdrModel,
- SdrObject& rNewObj)
-: SdrObject(rSdrModel),
+
+SdrVirtObj::SdrVirtObj(SdrObject& rNewObj):
rRefObj(rNewObj)
{
bVirtObj=true; // this is only a virtual object
@@ -58,6 +56,7 @@ SdrVirtObj::~SdrVirtObj()
rRefObj.DelReference(*this);
}
+
const SdrObject& SdrVirtObj::GetReferencedObj() const
{
return rRefObj;
@@ -82,6 +81,13 @@ void SdrVirtObj::NbcSetAnchorPos(const Point& rAnchorPos)
aAnchor=rAnchorPos;
}
+
+void SdrVirtObj::SetModel(SdrModel* pNewModel)
+{
+ SdrObject::SetModel(pNewModel);
+ rRefObj.SetModel(pNewModel);
+}
+
void SdrVirtObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
{
rRefObj.TakeObjInfo(rInfo);
@@ -122,29 +128,15 @@ void SdrVirtObj::RecalcBoundRect()
aOutRect+=aAnchor;
}
-SdrVirtObj* SdrVirtObj::Clone(SdrModel* pTargetModel) const
+SdrVirtObj* SdrVirtObj::Clone() const
{
- return CloneHelper< SdrVirtObj >(pTargetModel);
- // TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject
- // create an object wit correct rRefObj (?) OTOH VirtObj probably needs not
- // to be cloned ever - only used in Writer for multiple instances e.g. Header/Footer
- // return new SdrVirtObj(
- // getSdrModelFromSdrObject(),
- // rRefObj); // only a further reference
+ return new SdrVirtObj(rRefObj); // only a further reference
}
SdrVirtObj& SdrVirtObj::operator=(const SdrVirtObj& rObj)
-{
+{ // reference different object??
SdrObject::operator=(rObj);
-
- // reference different object?? TTTT -> yes!
- rRefObj.DelReference(*this);
- rRefObj = rObj.rRefObj;
- rRefObj.AddReference(*this);
-
- aSnapRect = rObj.aSnapRect;
- aAnchor = rObj.aAnchor;
-
+ aAnchor=rObj.aAnchor;
return *this;
}
@@ -274,11 +266,24 @@ bool SdrVirtObj::supportsFullDrag() const
SdrObject* SdrVirtObj::getFullDragClone() const
{
- SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj();
- return new SdrGrafObj(
- getSdrModelFromSdrObject(),
- SdrDragView::GetObjGraphic(rReferencedObject),
- GetLogicRect());
+ static bool bSpecialHandling(false);
+ SdrObject* pRetval = nullptr;
+
+ if(bSpecialHandling)
+ {
+ // special handling for VirtObj. Do not create another
+ // reference to rRefObj, this would allow to change that
+ // one on drag. Instead, create a SdrGrafObj for drag containing
+ // the graphical representation
+ pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
+ }
+ else
+ {
+ SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj();
+ pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), &rReferencedObject), GetLogicRect());
+ }
+
+ return pRetval;
}
bool SdrVirtObj::beginSpecialDrag(SdrDragStat& rDrag) const
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 2dff0a900148..7ff4129691ff 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -70,12 +70,13 @@ public:
static const sal_Int32 InitialObjectContainerCapacity (64);
-SdrObjList::SdrObjList(SdrPage* pNewPage)
-: maList(),
+SdrObjList::SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage):
+ maList(),
mxNavigationOrder(),
mbIsNavigationOrderDirty(false)
{
maList.reserve(InitialObjectContainerCapacity);
+ pModel=pNewModel;
pPage=pNewPage;
pUpList=nullptr;
bObjOrdNumsDirty=false;
@@ -84,46 +85,58 @@ SdrObjList::SdrObjList(SdrPage* pNewPage)
eListKind=SdrObjListKind::Unknown;
}
-SdrObjList::~SdrObjList()
+SdrObjList::SdrObjList():
+ maList(),
+ mxNavigationOrder(),
+ mbIsNavigationOrderDirty(false)
{
- Clear(); // delete contents of container
+ maList.reserve(InitialObjectContainerCapacity);
+ pModel=nullptr;
+ pPage=nullptr;
+ pUpList=nullptr;
+ bObjOrdNumsDirty=false;
+ bRectsDirty=false;
+ pOwnerObj=nullptr;
+ eListKind=SdrObjListKind::Unknown;
}
-SdrObjList* SdrObjList::CloneSdrObjList(SdrModel* pNewModel) const
+SdrObjList::~SdrObjList()
{
- SdrObjList* pObjList = new SdrObjList();
- pObjList->lateInitSdrObjList(*this, pNewModel);
- return pObjList;
+
+ // To avoid that the Clear() method will broadcast changes when in destruction
+ // which would call virtual method (not allowed in destructor), the model is set
+ // to NULL here.
+ pModel = nullptr;
+
+ Clear(); // delete contents of container
}
-void SdrObjList::lateInitSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModel)
+void SdrObjList::lateInit(const SdrObjList& rSrcList)
{
// this function is only supposed to be called once, right after construction
assert(maList.empty());
+
eListKind=rSrcList.eListKind;
- CopyObjects(rSrcList, pNewModel);
+ CopyObjects(rSrcList);
}
-void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModel)
+void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
{
Clear();
- bObjOrdNumsDirty = false;
- bRectsDirty = false;
- size_t nCloneErrCnt(0);
- const size_t nCount(rSrcList.GetObjCount());
+ bObjOrdNumsDirty=false;
+ bRectsDirty =false;
+ size_t nCloneErrCnt = 0;
+ const size_t nCount = rSrcList.GetObjCount();
+ for (size_t no=0; no<nCount; ++no) {
+ SdrObject* pSO=rSrcList.GetObj(no);
- for (size_t no(0); no < nCount; ++no)
- {
- SdrObject* pSO(rSrcList.GetObj(no));
- SdrObject* pDO(pSO->Clone(pNewModel));
+ SdrObject* pDO = pSO->Clone();
- if(nullptr != pDO)
- {
+ if (pDO!=nullptr) {
+ pDO->SetModel(pModel);
pDO->SetPage(pPage);
NbcInsertObject(pDO, SAL_MAX_SIZE);
- }
- else
- {
+ } else {
nCloneErrCnt++;
}
}
@@ -196,9 +209,9 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModel)
void SdrObjList::Clear()
{
- SdrModel* pSdrModelFromRemovedSdrObject(nullptr);
+ bool bObjectsRemoved(false);
- while(!maList.empty())
+ while( ! maList.empty())
{
// remove last object from list
SdrObject* pObj = maList.back();
@@ -208,22 +221,22 @@ void SdrObjList::Clear()
// to delete the object and thus refresh visualisations
pObj->GetViewContact().flushViewObjectContacts();
- if(nullptr == pSdrModelFromRemovedSdrObject)
- {
- pSdrModelFromRemovedSdrObject = &pObj->getSdrModelFromSdrObject();
- }
+ bObjectsRemoved = true;
// sent remove hint (after removal, see RemoveObject())
- SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, pPage);
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ if(pModel)
+ {
+ SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, pPage);
+ pModel->Broadcast(aHint);
+ }
// delete the object itself
SdrObject::Free( pObj );
}
- if(nullptr != pSdrModelFromRemovedSdrObject)
+ if(pModel && bObjectsRemoved)
{
- pSdrModelFromRemovedSdrObject->SetChanged();
+ pModel->SetChanged();
}
}
@@ -244,6 +257,23 @@ void SdrObjList::SetPage(SdrPage* pNewPage)
}
}
+SdrModel* SdrObjList::GetModel() const
+{
+ return pModel;
+}
+
+void SdrObjList::SetModel(SdrModel* pNewModel)
+{
+ if (pModel!=pNewModel) {
+ pModel=pNewModel;
+ const size_t nCount = GetObjCount();
+ for (size_t i=0; i<nCount; ++i) {
+ SdrObject* pObj=GetObj(i);
+ pObj->SetModel(pModel);
+ }
+ }
+}
+
void SdrObjList::RecalcObjOrdNums()
{
const size_t nCount = GetObjCount();
@@ -339,15 +369,18 @@ void SdrObjList::InsertObject(SdrObject* pObj, size_t nPos)
pOwnerObj->ActionChanged();
}
- // TODO: We need a different broadcast here!
- // Repaint from object number ... (heads-up: GroupObj)
- if(pObj->GetPage())
+ if(pModel)
{
- SdrHint aHint(SdrHintKind::ObjectInserted, *pObj);
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
- }
+ // TODO: We need a different broadcast here!
+ // Repaint from object number ... (heads-up: GroupObj)
+ if(pObj->GetPage())
+ {
+ SdrHint aHint(SdrHintKind::ObjectInserted, *pObj);
+ pModel->Broadcast(aHint);
+ }
- pObj->getSdrModelFromSdrObject().SetChanged();
+ pModel->SetChanged();
+ }
}
}
@@ -399,17 +432,16 @@ SdrObject* SdrObjList::RemoveObject(size_t nObjNum)
{
// flushViewObjectContacts() clears the VOC's and those invalidate
pObj->GetViewContact().flushViewObjectContacts();
- DBG_ASSERT(pObj->IsInserted(),"The object does not have the status Inserted.");
- // TODO: We need a different broadcast here.
- if (pObj->GetPage()!=nullptr)
- {
- SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ DBG_ASSERT(pObj->IsInserted(),"The object does not have the status Inserted.");
+ if (pModel!=nullptr) {
+ // TODO: We need a different broadcast here.
+ if (pObj->GetPage()!=nullptr) {
+ SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
+ pModel->Broadcast(aHint);
+ }
+ pModel->SetChanged();
}
-
- pObj->getSdrModelFromSdrObject().SetChanged();
-
pObj->SetInserted(false); // calls, among other things, the UserCall
pObj->SetObjList(nullptr);
pObj->SetPage(nullptr);
@@ -482,14 +514,13 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
DBG_ASSERT(pObj!=nullptr,"SdrObjList::ReplaceObject: Could not find object to remove.");
if (pObj!=nullptr) {
DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: the object does not have status Inserted.");
-
- // TODO: We need a different broadcast here.
- if (pObj->GetPage()!=nullptr)
- {
- SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ if (pModel!=nullptr) {
+ // TODO: We need a different broadcast here.
+ if (pObj->GetPage()!=nullptr) {
+ SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
+ pModel->Broadcast(aHint);
+ }
}
-
pObj->SetInserted(false);
pObj->SetObjList(nullptr);
pObj->SetPage(nullptr);
@@ -507,15 +538,14 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
impChildInserted(*pNewObj);
pNewObj->SetInserted(true);
-
- // TODO: We need a different broadcast here.
- if (pNewObj->GetPage()!=nullptr) {
- SdrHint aHint(SdrHintKind::ObjectInserted, *pNewObj);
- pNewObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ if (pModel!=nullptr) {
+ // TODO: We need a different broadcast here.
+ if (pNewObj->GetPage()!=nullptr) {
+ SdrHint aHint(SdrHintKind::ObjectInserted, *pNewObj);
+ pModel->Broadcast(aHint);
+ }
+ pModel->SetChanged();
}
-
- pNewObj->getSdrModelFromSdrObject().SetChanged();
-
SetRectsDirty();
}
return pObj;
@@ -544,11 +574,13 @@ SdrObject* SdrObjList::SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
pObj->SetOrdNum(nNewObjNum);
bObjOrdNumsDirty=true;
-
- // TODO: We need a different broadcast here.
- if (pObj->GetPage()!=nullptr)
- pObj->getSdrModelFromSdrObject().Broadcast(SdrHint(SdrHintKind::ObjectChange, *pObj));
- pObj->getSdrModelFromSdrObject().SetChanged();
+ if (pModel!=nullptr)
+ {
+ // TODO: We need a different broadcast here.
+ if (pObj->GetPage()!=nullptr)
+ pModel->Broadcast(SdrHint(SdrHintKind::ObjectChange, *pObj));
+ pModel->SetChanged();
+ }
}
return pObj;
}
@@ -749,7 +781,8 @@ void SdrObjList::SetObjectNavigationPosition (
mbIsNavigationOrderDirty = true;
// The navigation order is written out to file so mark the model as modified.
- rObject.getSdrModelFromSdrObject().SetChanged();
+ if (pModel != nullptr)
+ pModel->SetChanged();
}
}
@@ -1015,18 +1048,20 @@ void SdrPageProperties::ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet)
void ImpPageChange(SdrPage& rSdrPage)
{
rSdrPage.ActionChanged();
- rSdrPage.getSdrModelFromSdrPage().SetChanged();
- SdrHint aHint(SdrHintKind::PageOrderChange, &rSdrPage);
- rSdrPage.getSdrModelFromSdrPage().Broadcast(aHint);
+
+ if(rSdrPage.GetModel())
+ {
+ rSdrPage.GetModel()->SetChanged();
+ SdrHint aHint(SdrHintKind::PageOrderChange, &rSdrPage);
+ rSdrPage.GetModel()->Broadcast(aHint);
+ }
}
SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
: SfxListener(),
mpSdrPage(&rSdrPage),
mpStyleSheet(nullptr),
- maProperties(
- mpSdrPage->getSdrModelFromSdrPage().GetItemPool(),
- svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{})
+ maProperties(mpSdrPage->GetModel()->GetItemPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{})
{
if(!rSdrPage.IsMasterPage())
{
@@ -1101,23 +1136,18 @@ void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet)
}
-SdrPage::SdrPage(SdrModel& rModel, bool bMasterPage)
-: tools::WeakBase(),
- SdrObjList(this),
- maPageUsers(),
+SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
+: SdrObjList(&rNewModel, this),
mpViewContact(nullptr),
- mrSdrModelFromSdrPage(rModel),
mnWidth(10),
mnHeight(10),
mnBorderLeft(0),
mnBorderUpper(0),
mnBorderRight(0),
mnBorderLower(0),
- mpLayerAdmin(new SdrLayerAdmin(&rModel.GetLayerAdmin())),
+ mpLayerAdmin(new SdrLayerAdmin(&rNewModel.GetLayerAdmin())),
mpSdrPageProperties(nullptr),
- mxUnoPage(),
mpMasterPageDescriptor(nullptr),
- aPrefVisiLayers(),
nPageNum(0),
mbMaster(bMasterPage),
mbInserted(false),
@@ -1130,6 +1160,27 @@ SdrPage::SdrPage(SdrModel& rModel, bool bMasterPage)
mpSdrPageProperties.reset(new SdrPageProperties(*this));
}
+SdrPage::SdrPage(const SdrPage& rSrcPage)
+: SdrObjList(rSrcPage.pModel, this),
+ mpViewContact(nullptr),
+ mnWidth(rSrcPage.mnWidth),
+ mnHeight(rSrcPage.mnHeight),
+ mnBorderLeft(rSrcPage.mnBorderLeft),
+ mnBorderUpper(rSrcPage.mnBorderUpper),
+ mnBorderRight(rSrcPage.mnBorderRight),
+ mnBorderLower(rSrcPage.mnBorderLower),
+ mpLayerAdmin(new SdrLayerAdmin(rSrcPage.pModel->GetLayerAdmin())),
+ mpSdrPageProperties(nullptr),
+ mpMasterPageDescriptor(nullptr),
+ nPageNum(rSrcPage.nPageNum),
+ mbMaster(rSrcPage.mbMaster),
+ mbInserted(false),
+ mbObjectsNotPersistent(rSrcPage.mbObjectsNotPersistent),
+ mbPageBorderOnlyLeftRight(rSrcPage.mbPageBorderOnlyLeftRight)
+{
+ aPrefVisiLayers.SetAll();
+}
+
SdrPage::~SdrPage()
{
if( mxUnoPage.is() ) try
@@ -1167,13 +1218,18 @@ SdrPage::~SdrPage()
mpSdrPageProperties.reset();
}
-void SdrPage::lateInit(const SdrPage& rSrcPage)
+void SdrPage::lateInit(const SdrPage& rSrcPage, SdrModel* const pNewModel)
{
assert(!mpViewContact);
- // SdrPageProperties get set by SdrPage::SdrPage already, so do not assert anymore
- // assert(!mpSdrPageProperties);
+ 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
// the contained objects
@@ -1212,18 +1268,24 @@ void SdrPage::lateInit(const SdrPage& rSrcPage)
}
// Now copy the contained objects
- SdrObjList::lateInitSdrObjList(rSrcPage, &getSdrModelFromSdrPage());
+ SdrObjList::lateInit(rSrcPage);
// be careful and correct eListKind, a member of SdrObjList which
// will be changed by the SdrObjList::lateInit before...
eListKind = (mbMaster) ? SdrObjListKind::MasterPage : SdrObjListKind::DrawPage;
}
+SdrPage* SdrPage::Clone() const
+{
+ return Clone(nullptr);
+}
+
SdrPage* SdrPage::Clone(SdrModel* pNewModel) const
{
- SdrPage* pClonedPage(new SdrPage(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
- pClonedPage->lateInit(*this);
- return pClonedPage;
+ if (pNewModel==nullptr) pNewModel=pModel;
+ SdrPage* pPage2=new SdrPage(*pNewModel);
+ pPage2->lateInit(*this);
+ return pPage2;
}
void SdrPage::SetSize(const Size& aSiz)
@@ -1373,6 +1435,59 @@ sal_Int32 SdrPage::GetLowerBorder() const
return mnBorderLower;
}
+void SdrPage::impl_setModelForLayerAdmin(SdrModel* const pNewModel)
+{
+ if (pNewModel!=nullptr) {
+ mpLayerAdmin->SetParent(&pNewModel->GetLayerAdmin());
+ } else {
+ mpLayerAdmin->SetParent(nullptr);
+ }
+ mpLayerAdmin->SetModel(pNewModel);
+}
+
+void SdrPage::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel=pModel;
+ SdrObjList::SetModel(pNewModel);
+
+ if (pNewModel!=pOldModel)
+ {
+ impl_setModelForLayerAdmin( pNewModel );
+
+ // create new SdrPageProperties with new model (due to SfxItemSet there)
+ // and copy ItemSet and StyleSheet
+ std::unique_ptr<SdrPageProperties> pNew(new SdrPageProperties(*this));
+
+ if(!IsMasterPage())
+ {
+ const SfxItemSet& rOldSet = getSdrPageProperties().GetItemSet();
+ SfxItemSet* pNewSet = rOldSet.Clone(false, &pNewModel->GetItemPool());
+ //ensure checkForUniqueItem is called so new pages which have e.g.
+ //XFillBitmapItem set, do not conflict with an existing XFillBitmapItem
+ //with the same name but different properties
+ SdrModel::MigrateItemSet(&rOldSet, pNewSet, pNewModel);
+ pNew->PutItemSet(*pNewSet);
+ delete pNewSet;
+ }
+
+ pNew->SetStyleSheet(getSdrPageProperties().GetStyleSheet());
+
+ mpSdrPageProperties = std::move(pNew);
+ }
+
+ // update listeners at possible API wrapper object
+ if( pOldModel != pNewModel )
+ {
+ if( mxUnoPage.is() )
+ {
+ SvxDrawPage* pPage2 = SvxDrawPage::getImplementation( mxUnoPage );
+ if( pPage2 )
+ pPage2->ChangeModel( pNewModel );
+ }
+ }
+}
+
+
// #i68775# React on PageNum changes (from Model in most cases)
void SdrPage::SetPageNum(sal_uInt16 nNew)
{
@@ -1392,11 +1507,11 @@ sal_uInt16 SdrPage::GetPageNum() const
return 0;
if (mbMaster) {
- if (getSdrModelFromSdrPage().IsMPgNumsDirty())
- getSdrModelFromSdrPage().RecalcPageNums(true);
+ if (pModel && pModel->IsMPgNumsDirty())
+ pModel->RecalcPageNums(true);
} else {
- if (getSdrModelFromSdrPage().IsPagNumsDirty())
- getSdrModelFromSdrPage().RecalcPageNums(false);
+ if (pModel && pModel->IsPagNumsDirty())
+ pModel->RecalcPageNums(false);
}
return nPageNum;
}
@@ -1406,7 +1521,11 @@ void SdrPage::SetChanged()
// For test purposes, use the new ViewContact for change
// notification now.
ActionChanged();
- getSdrModelFromSdrPage().SetChanged();
+
+ if( pModel )
+ {
+ pModel->SetChanged();
+ }
}
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index ff6349894259..da88ec5907f3 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -898,25 +898,15 @@ sal_uInt16 SdrPageView::GetEnteredLevel() const
void SdrPageView::CheckAktGroup()
{
- SdrObject* pGrp(GetAktGroup());
-
- while(nullptr != pGrp &&
- (!pGrp->IsInserted() || nullptr == pGrp->GetObjList() || nullptr == pGrp->GetPage()))
- {
- // anything outside of the borders?
- pGrp = pGrp->GetUpGroup();
+ SdrObject* pGrp=GetAktGroup();
+ while (pGrp!=nullptr &&
+ (!pGrp->IsInserted() || pGrp->GetObjList()==nullptr ||
+ pGrp->GetPage()==nullptr || pGrp->GetModel()==nullptr)) { // anything outside of the borders?
+ pGrp=pGrp->GetUpGroup();
}
-
- if(pGrp != GetAktGroup())
- {
- if(nullptr != pGrp)
- {
- EnterGroup(pGrp);
- }
- else
- {
- LeaveAllGroup();
- }
+ if (pGrp!=GetAktGroup()) {
+ if (pGrp!=nullptr) EnterGroup(pGrp);
+ else LeaveAllGroup();
}
}
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index ba0e252da346..48c971d61792 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -181,12 +181,9 @@ void SdrPaintView::ImpClearVars()
maGridColor = COL_BLACK;
}
-SdrPaintView::SdrPaintView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: mrSdrModelFromSdrView(rSdrModel),
- mpPageView(nullptr),
- maDefaultAttr(rSdrModel.GetItemPool()),
+SdrPaintView::SdrPaintView(SdrModel* pModel, OutputDevice* pOut)
+: mpPageView(nullptr),
+ maDefaultAttr(pModel->GetItemPool()),
mbBufferedOutputAllowed(false),
mbBufferedOverlayAllowed(false),
mbPagePaintingAllowed(true),
@@ -195,7 +192,7 @@ SdrPaintView::SdrPaintView(
mbHideDraw(false),
mbHideFormControl(false)
{
- mpModel=&rSdrModel;
+ mpModel=pModel;
ImpClearVars();
if(pOut)
diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx
index 56e32865e012..509eb112dd96 100644
--- a/svx/source/svdraw/svdpoev.cxx
+++ b/svx/source/svdraw/svdpoev.cxx
@@ -44,10 +44,8 @@ void SdrPolyEditView::ImpResetPolyPossibilityFlags()
bSetMarkedSegmentsKindPossible=false;
}
-SdrPolyEditView::SdrPolyEditView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrEditView(rSdrModel, pOut)
+SdrPolyEditView::SdrPolyEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrEditView(pModel1,pOut)
{
ImpResetPolyPossibilityFlags();
}
diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx
index 10aacc3f87fd..94f1f5affc00 100644
--- a/svx/source/svdraw/svdsnpv.cxx
+++ b/svx/source/svdraw/svdsnpv.cxx
@@ -165,31 +165,30 @@ void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
}
}
-SdrSnapView::SdrSnapView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrPaintView(rSdrModel, pOut)
- ,mpPageOriginOverlay(nullptr)
- ,mpHelpLineOverlay(nullptr)
- ,nMagnSizPix(4)
- ,nSnapAngle(1500)
- ,nEliminatePolyPointLimitAngle(0)
- ,eCrookMode(SdrCrookMode::Rotate)
- ,bSnapEnab(true)
- ,bGridSnap(true)
- ,bBordSnap(true)
- ,bHlplSnap(true)
- ,bOFrmSnap(true)
- ,bOPntSnap(false)
- ,bOConSnap(true)
- ,bMoveSnapOnlyTopLeft(false)
- ,bOrtho(false)
- ,bBigOrtho(true)
- ,bAngleSnapEnab(false)
- ,bMoveOnlyDragging(false)
- ,bSlantButShear(false)
- ,bCrookNoContortion(false)
- ,bEliminatePolyPoints(false)
+
+SdrSnapView::SdrSnapView(SdrModel* pModel1, OutputDevice* pOut)
+ : SdrPaintView(pModel1,pOut)
+ , mpPageOriginOverlay(nullptr)
+ , mpHelpLineOverlay(nullptr)
+ , nMagnSizPix(4)
+ , nSnapAngle(1500)
+ , nEliminatePolyPointLimitAngle(0)
+ , eCrookMode(SdrCrookMode::Rotate)
+ , bSnapEnab(true)
+ , bGridSnap(true)
+ , bBordSnap(true)
+ , bHlplSnap(true)
+ , bOFrmSnap(true)
+ , bOPntSnap(false)
+ , bOConSnap(true)
+ , bMoveSnapOnlyTopLeft(false)
+ , bOrtho(false)
+ , bBigOrtho(true)
+ , bAngleSnapEnab(false)
+ , bMoveOnlyDragging(false)
+ , bSlantButShear(false)
+ , bCrookNoContortion(false)
+ , bEliminatePolyPoints(false)
{
}
diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx
index 549578832885..159f863cb54c 100644
--- a/svx/source/svdraw/svdtext.cxx
+++ b/svx/source/svdraw/svdtext.cxx
@@ -31,6 +31,7 @@
SdrText::SdrText( SdrTextObj& rObject )
: mpOutlinerParaObject( nullptr )
, mrObject( rObject )
+, mpModel( rObject.GetModel() )
, mbPortionInfoChecked( false )
{
OSL_ENSURE(&mrObject, "SdrText created without SdrTextObj (!)");
@@ -47,12 +48,11 @@ void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
{
// #i102062# no action when the Outliner is the HitTestOutliner,
// this will remove WrongList info at the OPO
- if(&rOutliner == &mrObject.getSdrModelFromSdrObject().GetHitTestOutliner())
+ if(mpModel && &rOutliner == &mpModel->GetHitTestOutliner())
return;
// TODO: optimization: we could create a BigTextObject
mbPortionInfoChecked=true;
-
if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject())
{
// #i102062# MemoryLeak closed
@@ -76,15 +76,16 @@ void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
{
if( mpOutlinerParaObject.get() != pTextObject )
{
- // Update HitTestOutliner
- const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
-
- if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
+ if( mpModel )
{
- mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get() )
+ mpModel->GetHitTestOutliner().SetTextObj( nullptr );
}
mpOutlinerParaObject.reset(pTextObject);
+
mbPortionInfoChecked = false;
}
}
@@ -97,33 +98,82 @@ OutlinerParaObject* SdrText::GetOutlinerParaObject() const
/** returns the current OutlinerParaObject and removes it from this instance */
OutlinerParaObject* SdrText::RemoveOutlinerParaObject()
{
- // Update HitTestOutliner
- const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
-
- if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
+ if( mpModel )
{
- mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get() )
+ mpModel->GetHitTestOutliner().SetTextObj( nullptr );
}
OutlinerParaObject* pOPO = mpOutlinerParaObject.release();
+
mbPortionInfoChecked = false;
return pOPO;
}
-void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode )
+void SdrText::SetModel( SdrModel* pNewModel )
{
- if(!mpOutlinerParaObject)
+ if( pNewModel == mpModel )
+ return;
+
+ SdrModel* pOldModel = mpModel;
+ mpModel = pNewModel;
+
+ if( !mpOutlinerParaObject || pOldModel==nullptr || pNewModel==nullptr)
+ return;
+
+ bool bHgtSet = GetObjectItemSet().GetItemState(EE_CHAR_FONTHEIGHT) == SfxItemState::SET;
+
+ MapUnit aOldUnit(pOldModel->GetScaleUnit());
+ MapUnit aNewUnit(pNewModel->GetScaleUnit());
+ bool bScaleUnitChanged=aNewUnit!=aOldUnit;
+ // Now move the OutlinerParaObject into a new Pool.
+ // TODO: We should compare the DefTab and RefDevice of both Models to
+ // see whether we need to use AutoGrow!
+ sal_Int32 nOldFontHgt=pOldModel->GetDefaultFontHeight();
+ sal_Int32 nNewFontHgt=pNewModel->GetDefaultFontHeight();
+ bool bDefHgtChanged=nNewFontHgt!=nOldFontHgt;
+ bool bSetHgtItem=bDefHgtChanged && !bHgtSet;
+ if (bSetHgtItem)
{
- std::unique_ptr<Outliner> pOutliner(
- SdrMakeOutliner(
- nOutlMode,
- mrObject.getSdrModelFromSdrObject()));
+ // fix the value of HeightItem, so
+ // 1. it remains and
+ // 2. DoStretchChars gets the right value
+ SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
+ }
+ // now use the Outliner, etc. so the above SetAttr can work at all
+ SdrOutliner& rOutliner = mrObject.ImpGetDrawOutliner();
+ rOutliner.SetText(*mpOutlinerParaObject);
+ mpOutlinerParaObject.reset();
+ if (bScaleUnitChanged)
+ {
+ Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X();
- if(pOutliner)
+ if (bSetHgtItem)
{
- Outliner& aDrawOutliner(mrObject.getSdrModelFromSdrObject().GetDrawOutliner());
+ // Now correct the frame attribute
+ nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.GetNumerator(),aMetricFactor.GetDenominator());
+ SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
+ }
+ }
+ SetOutlinerParaObject(rOutliner.CreateParaObject());
+ mpOutlinerParaObject->ClearPortionInfo();
+ mbPortionInfoChecked=false;
+ rOutliner.Clear();
+}
+
+void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode )
+{
+ if( mpModel && !mpOutlinerParaObject )
+ {
+ std::unique_ptr<Outliner> pOutliner(SdrMakeOutliner(nOutlMode, *mpModel));
+ if( pOutliner )
+ {
+ Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
+
pOutliner->SetStyleSheet( 0, GetStyleSheet());
OutlinerParaObject* pOutlinerParaObject = pOutliner->CreateParaObject();
SetOutlinerParaObject( pOutlinerParaObject );
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 22720cfb4ca4..1c6ec236f34b 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -209,8 +209,8 @@ OUString SdrUndoGroup::GetSdrRepeatComment(SdrView& /*rView*/) const
}
SdrUndoObj::SdrUndoObj(SdrObject& rNewObj)
-: SdrUndoAction(rNewObj.getSdrModelFromSdrObject())
- ,pObj(&rNewObj)
+ : SdrUndoAction(*rNewObj.GetModel())
+ , pObj(&rNewObj)
{
}
@@ -237,10 +237,10 @@ void SdrUndoObj::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr,
// common call method for possible change of the page when UNDO/REDO is triggered
void SdrUndoObj::ImpShowPageOfThisObject()
{
- if(pObj && pObj->IsInserted() && pObj->GetPage())
+ if(pObj && pObj->IsInserted() && pObj->GetPage() && pObj->GetModel())
{
SdrHint aHint(SdrHintKind::SwitchToPage, *pObj, pObj->GetPage());
- pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+ pObj->GetModel()->Broadcast(aHint);
}
}
@@ -275,7 +275,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
if(bIsGroup)
{
// it's a group object!
- pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
+ pUndoGroup.reset( new SdrUndoGroup(*pObj->GetModel()) );
const size_t nObjCount(pOL->GetObjCount());
for(size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum)
@@ -343,9 +343,9 @@ void SdrUndoAttrObj::Undo()
mxRedoStyleSheet = pObj->GetStyleSheet();
SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxUndoStyleSheet.get());
- if(pSheet && pObj->getSdrModelFromSdrObject().GetStyleSheetPool())
+ if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool())
{
- ensureStyleSheetInStyleSheetPool(*pObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
+ ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet);
pObj->SetStyleSheet(pSheet, true);
}
else
@@ -426,9 +426,9 @@ void SdrUndoAttrObj::Redo()
mxUndoStyleSheet = pObj->GetStyleSheet();
SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxRedoStyleSheet.get());
- if(pSheet && pObj->getSdrModelFromSdrObject().GetStyleSheetPool())
+ if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool())
{
- ensureStyleSheetInStyleSheetPool(*pObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
+ ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet);
pObj->SetStyleSheet(pSheet, true);
}
else
@@ -581,7 +581,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
// this is a group object!
// If this were 3D scene, we'd only add an Undo for the scene itself
// (which we do elsewhere).
- pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
+ pUndoGroup.reset(new SdrUndoGroup(*pObj->GetModel()));
const size_t nObjCount = pOL->GetObjCount();
for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum) {
pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum)));
@@ -1335,8 +1335,8 @@ OUString SdrUndoMoveLayer::GetComment() const
SdrUndoPage::SdrUndoPage(SdrPage& rNewPg)
-: SdrUndoAction(rNewPg.getSdrModelFromSdrPage())
- ,mrPage(rNewPg)
+ : SdrUndoAction(*rNewPg.GetModel())
+ , mrPage(rNewPg)
{
}
@@ -1657,7 +1657,7 @@ void SdrUndoPageRemoveMasterPage::Undo()
{
if(mbOldHadMasterPage)
{
- mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrPage().GetMasterPage(maOldMasterPageNumber));
+ mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
}
}
@@ -1695,7 +1695,7 @@ void SdrUndoPageChangeMasterPage::Undo()
if(mbOldHadMasterPage)
{
mrPage.TRG_ClearMasterPage();
- mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrPage().GetMasterPage(maOldMasterPageNumber));
+ mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
}
}
@@ -1706,7 +1706,7 @@ void SdrUndoPageChangeMasterPage::Redo()
if(mbNewHadMasterPage)
{
mrPage.TRG_ClearMasterPage();
- mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrPage().GetMasterPage(maNewMasterPageNumber));
+ mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maNewMasterPageNumber));
mrPage.TRG_SetMasterPageVisibleLayers(maNewSet);
}
}
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index d9eb52432957..db460ea89d45 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -146,15 +146,15 @@ SdrDropMarkerOverlay::~SdrDropMarkerOverlay()
// OverlayManager and deletes them.
}
-SdrView::SdrView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrCreateView(rSdrModel, pOut),
+
+SdrView::SdrView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrCreateView(pModel1,pOut),
bNoExtendedMouseDispatcher(false),
bNoExtendedKeyDispatcher(false),
mbMasterPagePaintCaching(false)
{
maAccessibilityOptions.AddListener(this);
+
onAccessibilityOptionsChanged();
}
diff --git a/svx/source/svdraw/svdviter.cxx b/svx/source/svdraw/svdviter.cxx
index 044526e6e638..2dbd8b5f3bb2 100644
--- a/svx/source/svdraw/svdviter.cxx
+++ b/svx/source/svdraw/svdviter.cxx
@@ -38,7 +38,7 @@ void SdrViewIter::ImpInitVars()
SdrViewIter::SdrViewIter(const SdrPage* pPage)
{
mpPage = pPage;
- mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
+ mpModel = pPage ? pPage->GetModel() : nullptr;
mpObject = nullptr;
mbNoMasterPage = false;
ImpInitVars();
@@ -48,7 +48,7 @@ SdrViewIter::SdrViewIter(const SdrPage* pPage)
SdrViewIter::SdrViewIter(const SdrObject* pObject)
{
mpObject = pObject;
- mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
+ mpModel = pObject ? pObject->GetModel() : nullptr;
mpPage = pObject ? pObject->GetPage() : nullptr;
mbNoMasterPage = false;
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 58fc73351181..1011c8a11e87 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -57,10 +57,8 @@
using namespace com::sun::star;
-SdrExchangeView::SdrExchangeView(
- SdrModel& rSdrModel,
- OutputDevice* pOut)
-: SdrObjEditView(rSdrModel, pOut)
+SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrObjEditView(pModel1,pOut)
{
}
@@ -145,11 +143,8 @@ bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList*
if (pPage!=nullptr) {
aTextRect.SetSize(pPage->GetSize());
}
- SdrRectObj* pObj = new SdrRectObj(
- getSdrModelFromSdrView(),
- OBJ_TEXT,
- aTextRect);
-
+ SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
+ pObj->SetModel(mpModel);
pObj->SetLayer(nLayer);
pObj->NbcSetText(rStr); // SetText before SetAttr, else SetAttr doesn't work!
if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
@@ -185,11 +180,8 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
if (pPage!=nullptr) {
aTextRect.SetSize(pPage->GetSize());
}
- SdrRectObj* pObj = new SdrRectObj(
- getSdrModelFromSdrView(),
- OBJ_TEXT,
- aTextRect);
-
+ SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
+ pObj->SetModel(mpModel);
pObj->SetLayer(nLayer);
if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
@@ -209,9 +201,9 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
// b4967543
- if(pObj->GetOutlinerParaObject())
+ if(pObj->GetModel() && pObj->GetOutlinerParaObject())
{
- SdrOutliner& rOutliner = pObj->getSdrModelFromSdrObject().GetHitTestOutliner();
+ SdrOutliner& rOutliner = pObj->GetModel()->GetHitTestOutliner();
rOutliner.SetText(*pObj->GetOutlinerParaObject());
if(1 == rOutliner.GetParagraphCount())
@@ -220,7 +212,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
if(pCandidate)
{
- if(pObj->getSdrModelFromSdrObject().GetStyleSheetPool() == &pCandidate->GetPool())
+ if(pObj->GetModel()->GetStyleSheetPool() == &pCandidate->GetPool())
{
pObj->NbcSetStyleSheet(pCandidate, true);
}
@@ -313,13 +305,15 @@ bool SdrExchangeView::Paste(
{
if(bResize)
{
- pNewObj->getSdrModelFromSdrObject().SetPasteResize(true);
+ pNewObj->GetModel()->SetPasteResize(true);
pNewObj->NbcResize(aPt0,aXResize,aYResize);
- pNewObj->getSdrModelFromSdrObject().SetPasteResize(false);
+ pNewObj->GetModel()->SetPasteResize(false);
}
// #i39861#
+ pNewObj->SetModel(pDstLst->GetModel());
pNewObj->SetPage(pDstLst->GetPage());
+
pNewObj->NbcMove(aSiz);
const SdrPage* pPg = pDstLst->GetPage();
@@ -351,7 +345,7 @@ bool SdrExchangeView::Paste(
pDstLst->InsertObject(pNewObj, SAL_MAX_SIZE);
if( bUndo )
- AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
if (bMark) {
// Don't already set Markhandles!
@@ -420,7 +414,7 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
rLst.InsertObject(pObj, SAL_MAX_SIZE);
if( IsUndoEnabled() )
- AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
SdrPageView* pMarkPV=nullptr;
SdrPageView* pPV = GetSdrPageView();
@@ -585,7 +579,7 @@ Graphic SdrExchangeView::GetAllMarkedGraphic() const
if( AreObjectsMarked() )
{
if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
- aRet = SdrExchangeView::GetObjGraphic(*GetMarkedObjectByIndex(0));
+ aRet = SdrExchangeView::GetObjGraphic( mpModel, GetMarkedObjectByIndex( 0 ) );
else
aRet = GetMarkedObjMetaFile();
}
@@ -594,68 +588,68 @@ Graphic SdrExchangeView::GetAllMarkedGraphic() const
}
-Graphic SdrExchangeView::GetObjGraphic(const SdrObject& rSdrObject)
+Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj )
{
Graphic aRet;
- // try to get a graphic from the object first
- const SdrGrafObj* pSdrGrafObj(dynamic_cast< const SdrGrafObj* >(&rSdrObject));
- const SdrOle2Obj* pSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(&rSdrObject));
-
- if(pSdrGrafObj)
+ if( pModel && pObj )
{
- if(pSdrGrafObj->isEmbeddedVectorGraphicData())
- {
- // get Metafile for Svg content
- aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
- }
- else
+ // try to get a graphic from the object first
+ const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
+ const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
+
+ if(pSdrGrafObj)
{
- // Make behaviour coherent with metafile
- // recording below (which of course also takes
- // view-transformed objects)
- aRet = pSdrGrafObj->GetTransformedGraphic();
+ if(pSdrGrafObj->isEmbeddedVectorGraphicData())
+ {
+ // get Metafile for Svg content
+ aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
+ }
+ else
+ {
+ // Make behaviour coherent with metafile
+ // recording below (which of course also takes
+ // view-transformed objects)
+ aRet = pSdrGrafObj->GetTransformedGraphic();
+ }
}
- }
- else if(pSdrOle2Obj)
- {
- if(pSdrOle2Obj->GetGraphic())
+ else if(pSdrOle2Obj)
{
- aRet = *pSdrOle2Obj->GetGraphic();
+ if ( pSdrOle2Obj->GetGraphic() )
+ aRet = *pSdrOle2Obj->GetGraphic();
}
- }
- // if graphic could not be retrieved => go the hard way and create a MetaFile
- if((GraphicType::NONE == aRet.GetType()) || (GraphicType::Default == aRet.GetType()))
- {
- ScopedVclPtrInstance< VirtualDevice > pOut;
- GDIMetaFile aMtf;
- const tools::Rectangle aBoundRect(rSdrObject.GetCurrentBoundRect());
- const MapMode aMap(rSdrObject.getSdrModelFromSdrObject().GetScaleUnit(),
- Point(),
- rSdrObject.getSdrModelFromSdrObject().GetScaleFraction(),
- rSdrObject.getSdrModelFromSdrObject().GetScaleFraction());
-
- pOut->EnableOutput(false);
- pOut->SetMapMode(aMap);
- aMtf.Record(pOut);
- rSdrObject.SingleObjectPainter(*pOut.get());
- aMtf.Stop();
- aMtf.WindStart();
-
- // #i99268# replace the original offset from using XOutDev's SetOffset
- // NOT (as tried with #i92760#) with another MapMode which gets recorded
- // by the Metafile itself (what always leads to problems), but by
- // moving the result directly
- aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
- aMtf.SetPrefMapMode(aMap);
- aMtf.SetPrefSize(aBoundRect.GetSize());
-
- if(aMtf.GetActionSize())
+ // if graphic could not be retrieved => go the hard way and create a MetaFile
+ if( ( GraphicType::NONE == aRet.GetType() ) || ( GraphicType::Default == aRet.GetType() ) )
{
- aRet = aMtf;
+ ScopedVclPtrInstance< VirtualDevice > pOut;
+ GDIMetaFile aMtf;
+ const tools::Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
+ const MapMode aMap( pModel->GetScaleUnit(),
+ Point(),
+ pModel->GetScaleFraction(),
+ pModel->GetScaleFraction() );
+
+ pOut->EnableOutput( false );
+ pOut->SetMapMode( aMap );
+ aMtf.Record( pOut );
+ pObj->SingleObjectPainter( *pOut.get() );
+ aMtf.Stop();
+ aMtf.WindStart();
+
+ // #i99268# replace the original offset from using XOutDev's SetOffset
+ // NOT (as tried with #i92760#) with another MapMode which gets recorded
+ // by the Metafile itself (what always leads to problems), but by
+ // moving the result directly
+ aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
+
+ aMtf.SetPrefMapMode( aMap );
+ aMtf.SetPrefSize( aBoundRect.GetSize() );
+
+ if( aMtf.GetActionSize() )
+ aRet = aMtf;
}
- }
+ }
return aRet;
}
@@ -709,6 +703,7 @@ void SdrExchangeView::DrawMarkedObj(OutputDevice& rOut) const
}
}
+
SdrModel* SdrExchangeView::GetMarkedObjModel() const
{
// Sorting the MarkList here might be problematic in the future, so
@@ -734,16 +729,15 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const
{
// convert SdrPageObj's to a graphic representation, because
// virtual connection to referenced page gets lost in new model
- pNewObj = new SdrGrafObj(
- *pNeuMod,
- GetObjGraphic(*pObj),
- pObj->GetLogicRect());
+ pNewObj = new SdrGrafObj( GetObjGraphic( mpModel, pObj ), pObj->GetLogicRect() );
pNewObj->SetPage( pNeuPag );
+ pNewObj->SetModel( pNeuMod );
}
else
{
pNewObj = pObj->Clone();
pNewObj->SetPage( pNeuPag );
+ pNewObj->SetModel( pNeuMod );
}
pNeuPag->InsertObject(pNewObj, SAL_MAX_SIZE);
@@ -756,8 +750,8 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const
// New mechanism to re-create the connections of cloned connectors
aCloneList.CopyConnections();
}
-
return pNeuMod;
}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */