summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdotext.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/svdraw/svdotext.cxx')
-rw-r--r--svx/source/svdraw/svdotext.cxx123
1 files changed, 44 insertions, 79 deletions
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index cf4448fac249..63ca33f850fc 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -64,25 +64,20 @@
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()
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(SdrModel& rSdrModel)
+: SdrAttrObj(rSdrModel),
mpText(nullptr),
pEdtOutl(nullptr),
eTextKind(OBJ_TEXT)
@@ -102,8 +97,10 @@ SdrTextObj::SdrTextObj()
mbInDownScale = false;
}
-SdrTextObj::SdrTextObj(const tools::Rectangle& rNewRect)
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(
+ SdrModel& rSdrModel,
+ const tools::Rectangle& rNewRect)
+: SdrAttrObj(rSdrModel),
maRect(rNewRect),
mpText(nullptr),
pEdtOutl(nullptr),
@@ -125,8 +122,10 @@ SdrTextObj::SdrTextObj(const tools::Rectangle& rNewRect)
mbSupportTextIndentingOnLineWidthChange = true;
}
-SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewTextKind)
+: SdrAttrObj(rSdrModel),
mpText(nullptr),
pEdtOutl(nullptr),
eTextKind(eNewTextKind)
@@ -146,8 +145,11 @@ SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
mbSupportTextIndentingOnLineWidthChange = true;
}
-SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect)
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewTextKind,
+ const tools::Rectangle& rNewRect)
+: SdrAttrObj(rSdrModel),
maRect(rNewRect),
mpText(nullptr),
pEdtOutl(nullptr),
@@ -171,25 +173,19 @@ SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect
SdrTextObj::~SdrTextObj()
{
- if( pModel )
- {
- SdrOutliner& rOutl = pModel->GetHitTestOutliner();
- if( rOutl.GetTextObj() == this )
- rOutl.SetTextObj( nullptr );
- }
-
+ SdrOutliner& rOutl(getSdrModelFromSdrObject().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() || pModel==nullptr)
+ if(pText==nullptr || !pText->GetOutlinerParaObject())
return;
SdrOutliner& rOutliner=ImpGetDrawOutliner();
@@ -478,39 +474,6 @@ 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));
@@ -524,7 +487,7 @@ void SdrTextObj::AdaptTextMinSize()
// Only do this for text frame.
return;
- if (pModel && pModel->IsPasteResize())
+ if (getSdrModelFromSdrObject().IsPasteResize())
// Don't do this during paste resize.
return;
@@ -754,11 +717,9 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRe
if (pPara)
{
- bool bHitTest = false;
- if( pModel )
- bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
-
+ const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+
if( !pTestObj || !bHitTest || pTestObj != this ||
pTestObj->GetOutlinerParaObject() != pOutlinerParaObject )
{
@@ -1049,9 +1010,9 @@ OUString SdrTextObj::TakeObjNamePlural() const
return sName;
}
-SdrTextObj* SdrTextObj::Clone() const
+SdrTextObj* SdrTextObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrTextObj >();
+ return CloneHelper< SdrTextObj >(pTargetModel);
}
SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj)
@@ -1111,7 +1072,7 @@ basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const
basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour());
// and now add the BoundRect of the text, if necessary
- if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
+ if ( GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
{
// using Clone()-Paint() strategy inside TakeContour() leaves a destroyed
// SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner
@@ -1213,7 +1174,7 @@ void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const
SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const
{
- SdrOutliner& rOutl=pModel->GetDrawOutliner(this);
+ SdrOutliner& rOutl(getSdrModelFromSdrObject().GetDrawOutliner(this));
// Code extracted to ImpInitDrawOutliner()
ImpInitDrawOutliner( rOutl );
@@ -1261,7 +1222,7 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame,
double SdrTextObj::GetFontScaleY() const
{
SdrText* pText = getActiveText();
- if (pText == nullptr || !pText->GetOutlinerParaObject() || pModel == nullptr)
+ if (pText == nullptr || !pText->GetOutlinerParaObject())
return 1.0;
SdrOutliner& rOutliner = ImpGetDrawOutliner();
@@ -1403,17 +1364,21 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, tools::Rectangle&
tools::Rectangle aAnchorRect;
Fraction aFitXCorrection(1,1);
- bool bContourFrame=IsContourTextFrame();
-
- if( GetModel() )
- {
- MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0),
- GetModel()->GetScaleFraction(),
- GetModel()->GetScaleFraction());
- rOutl.SetRefMapMode(aMapMode);
- }
+ const bool bContourFrame(IsContourTextFrame());
+ const MapMode aMapMode(
+ getSdrModelFromSdrObject().GetScaleUnit(),
+ Point(0,0),
+ getSdrModelFromSdrObject().GetScaleFraction(),
+ getSdrModelFromSdrObject().GetScaleFraction());
- ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXCorrection );
+ rOutl.SetRefMapMode(aMapMode);
+ ImpSetupDrawOutlinerForPaint(
+ bContourFrame,
+ rOutl,
+ aTextRect,
+ aAnchorRect,
+ rPaintRect,
+ aFitXCorrection);
}
@@ -1561,7 +1526,7 @@ TextChain *SdrTextObj::GetTextChain() const
//if (!IsChainable())
// return NULL;
- return pModel->GetTextChain();
+ return getSdrModelFromSdrObject().GetTextChain();
}
bool SdrTextObj::IsVerticalWriting() const
@@ -1670,7 +1635,7 @@ bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DP
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position maybe relative to anchorpos, convert
- if( pModel && pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -1769,7 +1734,7 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
}
// if anchor is used, make position relative to it
- if( pModel && pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{