summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editobj.cxx81
-rw-r--r--editeng/source/editeng/editobj2.hxx8
-rw-r--r--editeng/source/editeng/impedit4.cxx13
3 files changed, 27 insertions, 75 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 9f8cc2cb76df..5f14386c4ccb 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -254,51 +254,36 @@ void EditTextObjectImpl::Dump() const
}
#endif
-static EditEngineItemPool* getEditEngineItemPool(SfxItemPool* pPool)
+static rtl::Reference<SfxItemPool> getEditEngineItemPool(SfxItemPool* pPool, MapUnit eDefaultMetric)
{
- EditEngineItemPool* pRetval = dynamic_cast< EditEngineItemPool* >(pPool);
-
- while(!pRetval && pPool && pPool->GetSecondaryPool())
- {
- pPool = pPool->GetSecondaryPool();
-
- if(pPool)
- {
- pRetval = dynamic_cast< EditEngineItemPool* >(pPool);
- }
- }
-
- return pRetval;
-}
-
-EditTextObjectImpl::EditTextObjectImpl( SfxItemPool* pP )
- : meUserType(OutlinerMode::DontKnow)
- , meScriptType(SvtScriptType::NONE)
- , meRotation(TextRotation::NONE)
- , meMetric(MapUnit::LASTENUMDUMMY)
- , mbVertical(false)
-{
- // #i101239# ensure target is an EditEngineItemPool, else
- // fallback to pool ownership. This is needed to ensure that at
+ // #i101239# ensure target is an EditEngineItemPool, so that at
// pool destruction time of an alien pool, the pool is still alive.
// When registering would happen at an alien pool which just uses an
// EditEngineItemPool as some sub-pool, that pool could already
// be decoupled and deleted which would lead to crashes.
- mpPool = getEditEngineItemPool(pP);
+ for (; pPool; pPool = pPool->GetSecondaryPool())
+ if (dynamic_cast<EditEngineItemPool*>(pPool))
+ return pPool;
- if ( mpPool )
- {
- mbOwnerOfPool = false;
- }
- else
- {
- mpPool = EditEngine::CreatePool();
- mbOwnerOfPool = true;
- }
+ auto pRetval = EditEngine::CreatePool();
+ pRetval->SetDefaultMetric(eDefaultMetric);
+ return pRetval;
+}
+
+EditTextObjectImpl::EditTextObjectImpl(SfxItemPool* pP, MapUnit eDefaultMetric, bool bVertical,
+ TextRotation eRotation, SvtScriptType eScriptType)
+ : mpPool(getEditEngineItemPool(pP, eDefaultMetric))
+ , meUserType(OutlinerMode::DontKnow)
+ , meScriptType(eScriptType)
+ , meRotation(eRotation)
+ , meMetric(eDefaultMetric)
+ , mbVertical(bVertical)
+{
}
EditTextObjectImpl::EditTextObjectImpl( const EditTextObjectImpl& r )
- : meUserType(r.meUserType)
+ : mpPool(r.mpPool)
+ , meUserType(r.meUserType)
, meScriptType(r.meScriptType)
, meRotation(r.meRotation)
, meMetric(r.meMetric)
@@ -306,24 +291,6 @@ EditTextObjectImpl::EditTextObjectImpl( const EditTextObjectImpl& r )
{
// Do not copy PortionInfo
- if ( !r.mbOwnerOfPool )
- {
- // reuse alien pool; this must be an EditEngineItemPool
- // since there is no other way to construct an EditTextObject
- // than it's regular constructor where that is ensured
- mpPool = r.mpPool;
- mbOwnerOfPool = false;
- }
- else
- {
- mpPool = EditEngine::CreatePool();
- mbOwnerOfPool = true;
-
- }
-
- if (mbOwnerOfPool && r.mpPool)
- mpPool->SetDefaultMetric( r.mpPool->GetMetric( DEF_METRIC ) );
-
maContents.reserve(r.maContents.size());
for (auto const& content : r.maContents)
maContents.push_back(std::unique_ptr<ContentInfo>(new ContentInfo(*content, *mpPool)));
@@ -405,12 +372,6 @@ TextRotation EditTextObjectImpl::GetRotation() const
return meRotation;
}
-
-void EditTextObjectImpl::SetScriptType( SvtScriptType nType )
-{
- meScriptType = nType;
-}
-
XEditAttribute EditTextObjectImpl::CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
{
return MakeXEditAttribute( *mpPool, rItem, nStart, nEnd );
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index a6f2b1be0d6d..818ea0fbaf75 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -180,14 +180,14 @@ private:
TextRotation meRotation;
MapUnit meMetric;
- bool mbOwnerOfPool;
bool mbVertical;
bool ImpChangeStyleSheets( std::u16string_view rOldName, SfxStyleFamily eOldFamily,
const OUString& rNewName, SfxStyleFamily eNewFamily );
public:
- EditTextObjectImpl( SfxItemPool* pPool );
+ EditTextObjectImpl(SfxItemPool* pPool, MapUnit eDefaultMetric, bool bVertical,
+ TextRotation eRotation, SvtScriptType eScriptType);
EditTextObjectImpl( const EditTextObjectImpl& r );
virtual ~EditTextObjectImpl() override;
@@ -207,7 +207,6 @@ public:
virtual TextRotation GetRotation() const override;
virtual SvtScriptType GetScriptType() const override { return meScriptType;}
- void SetScriptType( SvtScriptType nType );
virtual std::unique_ptr<EditTextObject> Clone() const override;
@@ -254,9 +253,6 @@ public:
bool HasMetric() const { return meMetric != MapUnit::LASTENUMDUMMY; }
MapUnit GetMetric() const { return meMetric; }
- void SetMetric( MapUnit n ) { meMetric = n; }
-
- bool IsOwnerOfPool() const { return mbOwnerOfPool; }
virtual bool operator==( const EditTextObject& rCompare ) const override;
bool Equals( const EditTextObjectImpl& rCompare, bool bComparePool ) const;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 1786b3215d88..de36a316de83 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -989,14 +989,6 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject(const EditSelect
std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, bool bAllowBigObjects, sal_Int32 nBigObjectStart )
{
- std::unique_ptr<EditTextObjectImpl> pTxtObj(std::make_unique<EditTextObjectImpl>(pPool));
- pTxtObj->SetVertical( GetVertical() );
- pTxtObj->SetRotation( GetRotation() );
- MapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC );
- pTxtObj->SetMetric( eMapUnit );
- if ( pTxtObj->IsOwnerOfPool() )
- pTxtObj->GetPool()->SetDefaultMetric( eMapUnit );
-
sal_Int32 nStartNode, nEndNode;
sal_Int32 nTextPortions = 0;
@@ -1009,7 +1001,10 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
// Templates are not saved!
// (Only the name and family, template itself must be in App!)
- pTxtObj->SetScriptType(GetItemScriptType(aSel));
+
+ const MapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric(DEF_METRIC);
+ auto pTxtObj(std::make_unique<EditTextObjectImpl>(pPool, eMapUnit, GetVertical(), GetRotation(),
+ GetItemScriptType(aSel)));
// iterate over the paragraphs ...
sal_Int32 nNode;