summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-08-08 21:04:48 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-12 22:12:45 +0200
commitd57ad60d8ed5279a3366386553c5cefb7ae8b5bf (patch)
tree45cc7d41f54c3e0a7dc7590b611574b38f01e3e1
parentd624c870943647a9896e45f1aeed7a1862ddbd8a (diff)
unique_ptr->optional in SwXTextPortion
Change-Id: I6b55ed9fb907473ff2e44bfa0bd5ccced750ca60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138158 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/inc/unoport.hxx10
-rw-r--r--sw/source/core/unocore/unoport.cxx37
2 files changed, 25 insertions, 22 deletions
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index d0d9b5b64176..5bdade8eda6e 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -111,11 +111,11 @@ private:
m_xMeta;
css::uno::Reference<css::text::XTextContent> m_xLineBreak;
css::uno::Reference<css::text::XTextContent> m_xContentControl;
- std::unique_ptr< css::uno::Any > m_pRubyText;
- std::unique_ptr< css::uno::Any > m_pRubyStyle;
- std::unique_ptr< css::uno::Any > m_pRubyAdjust;
- std::unique_ptr< css::uno::Any > m_pRubyIsAbove;
- std::unique_ptr< css::uno::Any > m_pRubyPosition;
+ std::optional< css::uno::Any > m_oRubyText;
+ std::optional< css::uno::Any > m_oRubyStyle;
+ std::optional< css::uno::Any > m_oRubyAdjust;
+ std::optional< css::uno::Any > m_oRubyIsAbove;
+ std::optional< css::uno::Any > m_oRubyPosition;
sw::UnoCursorPointer m_pUnoCursor;
SwFrameFormat* m_pFrameFormat;
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index a10da8a9c35f..1a4c065df2cd 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -100,25 +100,28 @@ SwXTextPortion::SwXTextPortion(
: m_pPropSet(aSwMapProvider.GetPropertySet(
PROPERTY_MAP_TEXTPORTION_EXTENSIONS))
, m_xParentText(std::move(xParent))
- , m_pRubyText ( bIsEnd ? nullptr : new uno::Any )
- , m_pRubyStyle ( bIsEnd ? nullptr : new uno::Any )
- , m_pRubyAdjust ( bIsEnd ? nullptr : new uno::Any )
- , m_pRubyIsAbove( bIsEnd ? nullptr : new uno::Any )
- , m_pRubyPosition( bIsEnd ? nullptr : new uno::Any )
, m_pFrameFormat(nullptr)
, m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START )
, m_bIsCollapsed(false)
{
+ if (!bIsEnd)
+ {
+ m_oRubyText.emplace();
+ m_oRubyStyle.emplace();
+ m_oRubyAdjust.emplace();
+ m_oRubyIsAbove.emplace();
+ m_oRubyPosition.emplace();
+ }
init( pPortionCursor);
if (!bIsEnd)
{
const SfxPoolItem& rItem = rAttr.GetAttr();
- rItem.QueryValue(*m_pRubyText);
- rItem.QueryValue(*m_pRubyStyle, MID_RUBY_CHARSTYLE);
- rItem.QueryValue(*m_pRubyAdjust, MID_RUBY_ADJUST);
- rItem.QueryValue(*m_pRubyIsAbove, MID_RUBY_ABOVE);
- rItem.QueryValue(*m_pRubyPosition, MID_RUBY_POSITION);
+ rItem.QueryValue(*m_oRubyText);
+ rItem.QueryValue(*m_oRubyStyle, MID_RUBY_CHARSTYLE);
+ rItem.QueryValue(*m_oRubyAdjust, MID_RUBY_ADJUST);
+ rItem.QueryValue(*m_oRubyIsAbove, MID_RUBY_ABOVE);
+ rItem.QueryValue(*m_oRubyPosition, MID_RUBY_POSITION);
}
}
@@ -357,17 +360,17 @@ void SwXTextPortion::GetPropertyValue(
break;
case RES_TXTATR_CJK_RUBY:
{
- const uno::Any* pToSet = nullptr;
+ const std::optional<uno::Any>* pToSet = nullptr;
switch(rEntry.nMemberId)
{
- case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break;
- case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break;
- case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break;
- case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break;
- case MID_RUBY_POSITION: pToSet = m_pRubyPosition.get();break;
+ case MID_RUBY_TEXT : pToSet = &m_oRubyText; break;
+ case MID_RUBY_ADJUST : pToSet = &m_oRubyAdjust; break;
+ case MID_RUBY_CHARSTYLE:pToSet = &m_oRubyStyle; break;
+ case MID_RUBY_ABOVE : pToSet = &m_oRubyIsAbove;break;
+ case MID_RUBY_POSITION: pToSet = &m_oRubyPosition;break;
}
if(pToSet)
- rVal = *pToSet;
+ rVal = **pToSet;
}
break;
default: