summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdotext.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-03-01 15:54:32 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-04-07 00:28:30 +0200
commitdfefe448c41921f2f1e54d3f69b8b9e89031d055 (patch)
tree1aace31054b5740e2faffcbc5de66a791be27f7d /svx/source/svdraw/svdotext.cxx
parenteba4d5b2b76cefde90cb3d6638c736f435023a45 (diff)
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects Added need for SdrModel& in constructors of SdrModel, SdrPage, SdrView and SdrObjList. Builds, not finished. SOSAW080: removed and replaced old SdrModel Removed and replaced GetModel()/SetModel() in all using classes (SdrObject, SdrPage, SdrView), added accessors to new referenced SdrModel, adapted all accessing places. Refactored/Extended ::Clone and ::operator== for these classes to allow cloning objects to a target SdrModel. Adapted places where this is done AFAP. Added quite some comments (tagged with 'TTTT') where possible further work is needed. Builds completely, thus checking in. This does not mean that this change is done yet. SOSAW080: Adapted SdrPage/SdrModel relationship Also needed to work on copy-construction of SdrPage and hierarchy, quite some stuff removed, no copy-constructor anymore, no MigrateItemPool stuff. Builds well, test stuck, will need some cleanup/finetunung SOSAW080: Smaller corrections/includes adapted SOSAW080: Smaller corrections/includes adapted SOSAW080: Debugging/Stabilizing/MakeUnitTestWork SOSAW080: Stabilized for UnitTests, cleanups SOSAW080: Adapted GetObjGraphic to just take a const SdrObject& SOSAW080: Removed ChangeModel from classes Classes SvxTextEditSource and SvxDrawPage (including TextEditSource stuff) do not need change of SdrModel anymore. SOSAW080: Adapted some comments to make more readable SOSAW080: Corrected constructor SOSAW080: getSdrModelFromUnoModel added override marks SOSAW080: Added missing includes SOSAW080: Corrected SdrPage constructor SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. SOSAW080: Added include for Mac-Build SOSAW080: Added Scale to DefaultProperties If a SdrModel change happens in DefaultProperties copy constructor (used from Clone()), potentially a Scale for the SfxItems has to be done. SOSAW080: Added missing include for MacBuild SOSAW080: Corrected CppunitTest_sc_anchor_test An adaption of a SdrPathObj instantiation was missing, added that. Seems as if that test is no tpart of the usual 'make' scenario, but used/executed in gerrit builds SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Free SdrObjects when SdrModel goes down In an UNO API test problem is that SvxShapes reference SdrShapes, but these are not added to a SdrPage and not 'owned' by the SvxShape. Thus these do not get deleted at all (same in master, memory leak). I extended SvxShape::Notify the case for ModelCleared to also Free the SdrObject when not owner and it's not added to a SdrPage (in that case it gets deleted with deleting the SdrModel) SOSAW080: Solve UNO API calls that move SvxShapes to other Model Due to UNO API tests I got a call to insert an xShape to a xDrawPage which was constructed in another Model, this has now to be done by Cloning the SdrObject to the new SdrModel, getting rid of the old one and getting all the UNO implementation stuff right (referemces SdrObject <-> xShape). 1cb7d573d323e98a89761fe662c10c4a654fdec0 24617494a0ef79f6e33dfcb02782a833a81c6434 763f39094b6a48b529a6952d01468f8776c97679 242b9e228a9a042c3a5bdd38b1ea6600144276d5 242b9e228a9a042c3a5bdd38b1ea6600144276d5 33a6f3f306b70c223171aef796dd5ee041ad14df 6878b33f8b05738a44c0910e40a60a0f0d1d58ed 0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2 8c4626274a5cc531dad27f27c0c45d4c528fb2fb 446685a49a6d67aedd01cfbbd5e87b07f97a4d7b c1b5ed3c99bc7219a0061e4ece24ea42afd2889a 22de9a1c8af7c25be5c108671ddc548ba323ed47 4caf6b6fbbe6e8130741d793dffb560fd01d4ed5 488b9601735ec1822433f82f633990063951fe08 c366d60299f239e3df856ddffedb19e743e4be0c c5137ba8c597c7b5f90318df50e87b93a39a28dc f9e646242cf89f6fde1315046952252a2c429779 f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410 1694b54903df784385abaa8452e1201e12344238 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 7b5c241faec7488924e5935ae8b19f785846b5e4 bf097ee7467895823fbd158a2a9543da3b5a5078 Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c Reviewed-on: https://gerrit.libreoffice.org/52526 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
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())
{