diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-26 11:41:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-26 16:15:39 +0200 |
commit | c99d3a3ff5ed860d50541ca8962b03ae4b665c50 (patch) | |
tree | da4b972db8ab2df561a1c8c0b83c0eac4db02f50 /sw | |
parent | 7b1d50e97eaa00855152e74f42b789fc643e0bac (diff) |
use boost::optional in sw
instead of std::unique_ptr, where we end up needlessly putting small
objects separately on the heap
Change-Id: I107421e7530c9580869b7a0f088ea7b0514bcf36
Reviewed-on: https://gerrit.libreoffice.org/51863
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/anchoreddrawobject.hxx | 6 | ||||
-rw-r--r-- | sw/inc/undobj.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/inc/UndoDelete.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/inc/UndoInsert.hxx | 11 | ||||
-rw-r--r-- | sw/source/core/layout/anchoreddrawobject.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/undo/undel.cxx | 57 | ||||
-rw-r--r-- | sw/source/core/undo/undobj.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/undo/undobj1.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/undo/unins.cxx | 64 | ||||
-rw-r--r-- | sw/source/uibase/inc/toxmgr.hxx | 77 |
10 files changed, 110 insertions, 131 deletions
diff --git a/sw/inc/anchoreddrawobject.hxx b/sw/inc/anchoreddrawobject.hxx index 46318fda434a..21fa967ff0a3 100644 --- a/sw/inc/anchoreddrawobject.hxx +++ b/sw/inc/anchoreddrawobject.hxx @@ -21,6 +21,7 @@ #include <memory> #include "anchoredobject.hxx" +#include <boost/optional.hpp> namespace tools { class Rectangle; } @@ -36,7 +37,7 @@ class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject bool mbValidPos; // rectangle, keeping the last object rectangle after the positioning - std::unique_ptr<tools::Rectangle> mpLastObjRect; + boost::optional<tools::Rectangle> maLastObjRect; // boolean, indicating that anchored drawing object hasn't been attached // to a anchor frame yet. Once, it is attached to a anchor frame the @@ -140,9 +141,8 @@ class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject // accessors to the object area and its position virtual const SwRect GetObjRect() const override; - // Return value can be NULL. - const tools::Rectangle* GetLastObjRect() const { return mpLastObjRect.get();} + boost::optional<tools::Rectangle> const & GetLastObjRect() const { return maLastObjRect;} void SetLastObjRect( const tools::Rectangle& _rNewObjRect ); /** adjust positioning and alignment attributes for new anchor frame diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 48a576dca537..a04d61e6f951 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -27,6 +27,7 @@ #include "SwRewriter.hxx" #include "swundo.hxx" #include <o3tl/typed_flags_set.hxx> +#include <boost/optional.hpp> class SwHistory; class SwIndex; @@ -57,7 +58,7 @@ class SwUndo protected: bool bCacheComment; - mutable std::unique_ptr<OUString> pComment; + mutable boost::optional<OUString> maComment; static void RemoveIdxFromSection( SwDoc&, sal_uLong nSttIdx, const sal_uLong* pEndIdx = nullptr ); static void RemoveIdxFromRange( SwPaM& rPam, bool bMoveNext ); diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx index a29993610cd2..81cc23e196bb 100644 --- a/sw/source/core/inc/UndoDelete.hxx +++ b/sw/source/core/inc/UndoDelete.hxx @@ -24,6 +24,7 @@ #include <rtl/ustring.hxx> #include <tools/mempool.hxx> #include <memory> +#include <boost/optional.hpp> class SwRedlineSaveDatas; class SwTextNode; @@ -38,7 +39,7 @@ class SwUndoDelete , private SwUndoSaveContent { SwNodeIndex* m_pMvStt; // Position of Nodes in UndoNodes-Array - std::unique_ptr<OUString> m_pSttStr, m_pEndStr; + boost::optional<OUString> m_aSttStr, m_aEndStr; SwRedlineSaveDatas* m_pRedlSaveData; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx index d16b2c07aa91..5f0b652f8ed6 100644 --- a/sw/source/core/inc/UndoInsert.hxx +++ b/sw/source/core/inc/UndoInsert.hxx @@ -28,6 +28,7 @@ #include <tools/mempool.hxx> #include <swtypes.hxx> #include <IDocumentContentOperations.hxx> +#include <boost/optional.hpp> class Graphic; class SwGrfNode; @@ -41,8 +42,8 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent { /// start of Content in UndoNodes for Redo std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex; - std::unique_ptr<OUString> m_pText; - std::unique_ptr<OUString> pUndoText; + boost::optional<OUString> maText; + boost::optional<OUString> maUndoText; SwRedlineData* pRedlData; sal_uLong nNode; sal_Int32 nContent, nLen; @@ -59,7 +60,7 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent SwDoc * pDoc; void Init(const SwNodeIndex & rNode); - OUString * GetTextFromDoc() const; + boost::optional<OUString> GetTextFromDoc() const; public: SwUndoInsert( const SwNodeIndex& rNode, sal_Int32 nContent, sal_Int32 nLen, @@ -137,8 +138,8 @@ private: class SwUndoReRead : public SwUndo { std::unique_ptr<Graphic> pGrf; - std::unique_ptr<OUString> pNm; - std::unique_ptr<OUString> pFltr; + boost::optional<OUString> maNm; + boost::optional<OUString> maFltr; sal_uLong nPos; MirrorGraph nMirr; diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx index bc7d76bae69e..8f96c6fd8bca 100644 --- a/sw/source/core/layout/anchoreddrawobject.cxx +++ b/sw/source/core/layout/anchoreddrawobject.cxx @@ -198,8 +198,6 @@ bool SwObjPosOscillationControl::OscillationDetected() SwAnchoredDrawObject::SwAnchoredDrawObject() : SwAnchoredObject(), mbValidPos( false ), - // --> #i34748# - mpLastObjRect( nullptr ), mbNotYetAttachedToAnchorFrame( true ), // --> #i28749# mbNotYetPositioned( true ), @@ -724,11 +722,7 @@ void SwAnchoredDrawObject::AdjustPositioningAttr( const SwFrame* _pNewAnchorFram // If member <mpLastObjRect> is NULL, create one. void SwAnchoredDrawObject::SetLastObjRect( const tools::Rectangle& _rNewLastRect ) { - if ( !mpLastObjRect ) - { - mpLastObjRect.reset( new tools::Rectangle ); - } - *(mpLastObjRect) = _rNewLastRect; + maLastObjRect = _rNewLastRect; } void SwAnchoredDrawObject::ObjectAttachedToAnchorFrame() diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 2795e84fbe14..e4f3ea72f6b0 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -99,8 +99,6 @@ SwUndoDelete::SwUndoDelete( : SwUndo(SwUndoId::DELETE, rPam.GetDoc()), SwUndRng( rPam ), m_pMvStt( nullptr ), - m_pSttStr(nullptr), - m_pEndStr(nullptr), m_pRedlSaveData(nullptr), m_nNode(0), m_nNdDiff(0), @@ -383,13 +381,13 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) - m_pSttStr.reset( new OUString( pSttTextNd->GetText().copy(nSttContent, nLen)) ); + m_aSttStr = pSttTextNd->GetText().copy(nSttContent, nLen); pSttTextNd->EraseText( pStt->nContent, nLen ); if( pSttTextNd->GetpSwpHints() ) pSttTextNd->GetpSwpHints()->DeRegister(); // METADATA: store - bool emptied( !m_pSttStr->isEmpty() && !pSttTextNd->Len() ); + bool emptied( !m_aSttStr->isEmpty() && !pSttTextNd->Len() ); if (!bOneNode || emptied) // merging may overwrite xmlids... { m_pMetadataUndoStart = emptied @@ -418,14 +416,13 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) - m_pEndStr.reset( new OUString( pEndTextNd->GetText().copy( 0, - pEnd->nContent.GetIndex() )) ); + m_aEndStr = pEndTextNd->GetText().copy( 0, pEnd->nContent.GetIndex() ); pEndTextNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTextNd->GetpSwpHints() ) pEndTextNd->GetpSwpHints()->DeRegister(); // METADATA: store - bool emptied = !m_pEndStr->isEmpty() && !pEndTextNd->Len(); + bool emptied = !m_aEndStr->isEmpty() && !pEndTextNd->Len(); m_pMetadataUndoEnd = emptied ? pEndTextNd->CreateUndoForDelete() @@ -442,7 +439,7 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) { // Is Undo greater than one Node (that is Start and EndString)? - if( !m_pSttStr || m_pSttStr->isEmpty() || m_pEndStr ) + if( !m_aSttStr || m_aSttStr->isEmpty() || m_aEndStr ) return false; // only the deletion of single char's can be condensed @@ -478,12 +475,12 @@ bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) SwTextNode * pDelTextNd = pStt->nNode.GetNode().GetTextNode(); if( !pDelTextNd ) return false; - sal_Int32 nUChrPos = m_bBackSp ? 0 : m_pSttStr->getLength()-1; + sal_Int32 nUChrPos = m_bBackSp ? 0 : m_aSttStr->getLength()-1; sal_Unicode cDelChar = pDelTextNd->GetText()[ pStt->nContent.GetIndex() ]; CharClass& rCC = GetAppCharClass(); if( ( CH_TXTATR_BREAKWORD == cDelChar || CH_TXTATR_INWORD == cDelChar ) || rCC.isLetterNumeric( OUString( cDelChar ), 0 ) != - rCC.isLetterNumeric( *m_pSttStr, nUChrPos ) ) + rCC.isLetterNumeric( *m_aSttStr, nUChrPos ) ) return false; { @@ -508,7 +505,7 @@ bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) nEndContent++; // Delete: attach char at the end nUChrPos++; } - (*m_pSttStr) = m_pSttStr->replaceAt( nUChrPos, 0, OUString(cDelChar) ); + m_aSttStr = m_aSttStr->replaceAt( nUChrPos, 0, OUString(cDelChar) ); pDelTextNd->EraseText( pStt->nContent, 1 ); m_bGroup = true; @@ -694,22 +691,22 @@ SwRewriter SwUndoDelete::GetRewriter() const { OUString aStr; - if (m_pSttStr != nullptr && m_pEndStr != nullptr && m_pSttStr->isEmpty() && - m_pEndStr->isEmpty()) + if (m_aSttStr && m_aEndStr && m_aSttStr->isEmpty() && + m_aEndStr->isEmpty()) { aStr = SwResId(STR_PARAGRAPH_UNDO); } else { - OUString * pStr = nullptr; - if (m_pSttStr != nullptr) - pStr = m_pSttStr.get(); - else if (m_pEndStr != nullptr) - pStr = m_pEndStr.get(); + boost::optional<OUString> aTmpStr; + if (m_aSttStr) + aTmpStr = m_aSttStr; + else if (m_aEndStr) + aTmpStr = m_aEndStr; - if (pStr != nullptr) + if (aTmpStr) { - aStr = DenoteSpecialCharacters(*pStr); + aStr = DenoteSpecialCharacters(*aTmpStr); } else { @@ -793,7 +790,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) bool bNodeMove = 0 != m_nNode; - if( m_pEndStr ) + if( m_aEndStr ) { // discard attributes since they all saved! SwTextNode* pTextNd = aPos.nNode.GetNode().GetTextNode(); @@ -804,7 +801,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) if( pTextNd && pTextNd->GetpSwpHints() ) pTextNd->ClearSwpHintsArr( true ); - if( m_pSttStr && !m_bFromTableCopy ) + if( m_aSttStr && !m_bFromTableCopy ) { sal_uLong nOldIdx = aPos.nNode.GetIndex(); rDoc.getIDocumentContentOperations().SplitNode( aPos, false ); @@ -818,15 +815,15 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) } if( pTextNd ) { - OUString const ins( pTextNd->InsertText(*m_pEndStr, aPos.nContent, + OUString const ins( pTextNd->InsertText(*m_aEndStr, aPos.nContent, SwInsertFlags::NOHINTEXPAND) ); - assert(ins.getLength() == m_pEndStr->getLength()); // must succeed + assert(ins.getLength() == m_aEndStr->getLength()); // must succeed (void) ins; // METADATA: restore pTextNd->RestoreMetadata(m_pMetadataUndoEnd); } } - else if( m_pSttStr && bNodeMove ) + else if( m_aSttStr && bNodeMove ) { SwTextNode * pNd = aPos.nNode.GetNode().GetTextNode(); if( pNd ) @@ -896,7 +893,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) if( pMovedNode ) lcl_MakeAutoFrames(*rDoc.GetSpzFrameFormats(), pMovedNode->GetIndex()); - if( m_pSttStr ) + if( m_aSttStr ) { aPos.nNode = nSttNode - m_nNdDiff + ( m_bJoinNext ? 0 : m_nReplaceDummy ); SwTextNode * pTextNd = aPos.nNode.GetNode().GetTextNode(); @@ -904,7 +901,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) // attributes were saved if (pTextNd != nullptr) { - if( pTextNd->HasSwAttrSet() && bNodeMove && !m_pEndStr ) + if( pTextNd->HasSwAttrSet() && bNodeMove && !m_aEndStr ) pTextNd->ResetAllAttr(); if( pTextNd->GetpSwpHints() ) @@ -913,9 +910,9 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) // SectionNode mode and selection from top to bottom: // -> in StartNode is still the rest of the Join => delete aPos.nContent.Assign( pTextNd, nSttContent ); - OUString const ins( pTextNd->InsertText(*m_pSttStr, aPos.nContent, + OUString const ins( pTextNd->InsertText(*m_aSttStr, aPos.nContent, SwInsertFlags::NOHINTEXPAND) ); - assert(ins.getLength() == m_pSttStr->getLength()); // must succeed + assert(ins.getLength() == m_aSttStr->getLength()); // must succeed (void) ins; // METADATA: restore pTextNd->RestoreMetadata(m_pMetadataUndoStart); @@ -1027,7 +1024,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext) m_nSetPos = pHistory ? pHistory->Count() : 0; } - if( !m_pSttStr && !m_pEndStr ) + if( !m_aSttStr && !m_aEndStr ) { SwNodeIndex aSttIdx = ( m_bDelFullPara || m_bJoinNext ) ? rPam.GetMark()->nNode diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 4c624a6018f8..252557ac08b6 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -160,7 +160,7 @@ SwUndo::SwUndo(SwUndoId const nId, const SwDoc* pDoc) : m_nId(nId), nOrigRedlineFlags(RedlineFlags::NONE) , m_nViewShellId(CreateViewShellId(pDoc)) , m_isRepeatIgnored(false) - , bCacheComment(true), pComment(nullptr) + , bCacheComment(true) { } @@ -653,16 +653,16 @@ OUString SwUndo::GetComment() const if (bCacheComment) { - if (! pComment) + if (! maComment) { - pComment.reset(new OUString(GetUndoComment(GetId()))); + maComment = GetUndoComment(GetId()); SwRewriter aRewriter = GetRewriter(); - *pComment = aRewriter.Apply(*pComment); + maComment = aRewriter.Apply(*maComment); } - aResult = *pComment; + aResult = *maComment; } else { diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index b36cb96f11e4..27063a251aab 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -366,7 +366,7 @@ OUString SwUndoInsLayFormat::GetComment() const aResult = SwUndo::GetComment(); } else - aResult = *pComment; + aResult = *maComment; return aResult; } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index af2f8c718a89..c721330682d2 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -62,9 +62,9 @@ using namespace ::com::sun::star; // INSERT -OUString * SwUndoInsert::GetTextFromDoc() const +boost::optional<OUString> SwUndoInsert::GetTextFromDoc() const { - OUString * pResult = nullptr; + boost::optional<OUString> aResult; SwNodeIndex aNd( pDoc->GetNodes(), nNode); SwContentNode* pCNd = aNd.GetNode().GetContentNode(); @@ -85,10 +85,10 @@ OUString * SwUndoInsert::GetTextFromDoc() const nStart = 0; } - pResult = new OUString(sText.copy(nStart, nLength)); + aResult = sText.copy(nStart, nLength); } - return pResult; + return aResult; } void SwUndoInsert::Init(const SwNodeIndex & rNd) @@ -102,7 +102,7 @@ void SwUndoInsert::Init(const SwNodeIndex & rNd) SetRedlineFlags( pDoc->getIDocumentRedlineAccess().GetRedlineFlags() ); } - pUndoText.reset( GetTextFromDoc() ); + maUndoText = GetTextFromDoc(); bCacheComment = false; } @@ -142,8 +142,8 @@ bool SwUndoInsert::CanGrouping( sal_Unicode cIns ) nLen++; nContent++; - if (pUndoText) - (*pUndoText) += OUStringLiteral1(cIns); + if (maUndoText) + (*maUndoText) += OUStringLiteral1(cIns); return true; } @@ -203,7 +203,7 @@ SwUndoInsert::~SwUndoInsert() } else // the inserted text { - m_pText.reset(); + maText.reset(); } delete pRedlData; } @@ -260,7 +260,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) aPaM.GetMark()->nContent.GetIndex()); } RemoveIdxFromRange( aPaM, false ); - m_pText.reset(new OUString(pTextNode->GetText().copy(nContent-nLen, nLen))); + maText = pTextNode->GetText().copy(nContent-nLen, nLen); pTextNode->EraseText( aPaM.GetPoint()->nContent, nLen ); } else // otherwise Graphics/OLE/Text/... @@ -274,7 +274,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) nNd = aPaM.GetPoint()->nNode.GetIndex(); nCnt = aPaM.GetPoint()->nContent.GetIndex(); - if (!m_pText) + if (!maText) { m_pUndoNodeIndex.reset( new SwNodeIndex(pDoc->GetNodes().GetEndOfContent())); @@ -292,7 +292,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) pPam->GetPoint()->nNode.GetNode().GetContentNode(), nCnt ); } - pUndoText.reset(); + maUndoText.reset(); } void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) @@ -334,15 +334,15 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) { const bool bMvBkwrd = MovePtBackward( *pPam ); - if (m_pText) + if (maText) { SwTextNode *const pTextNode = pCNd->GetTextNode(); OSL_ENSURE( pTextNode, "where is my textnode ?" ); OUString const ins( - pTextNode->InsertText( *m_pText, pPam->GetMark()->nContent, + pTextNode->InsertText( *maText, pPam->GetMark()->nContent, m_nInsertFlags) ); - assert(ins.getLength() == m_pText->getLength()); // must succeed - m_pText.reset(); + assert(ins.getLength() == maText->getLength()); // must succeed + maText.reset(); if (m_bWithRsid) // re-insert RSID { SwPaM pam(*pPam->GetMark(), nullptr); // mark -> point @@ -375,7 +375,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) } } - pUndoText.reset( GetTextFromDoc() ); + maUndoText = GetTextFromDoc(); } void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext) @@ -458,17 +458,17 @@ void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext) SwRewriter SwUndoInsert::GetRewriter() const { SwRewriter aResult; - OUString * pStr = nullptr; + boost::optional<OUString> aStr; bool bDone = false; - if (m_pText) - pStr = m_pText.get(); - else if (pUndoText) - pStr = pUndoText.get(); + if (maText) + aStr = maText; + else if (maUndoText) + aStr = maUndoText; - if (pStr) + if (aStr) { - OUString aString = ShortenString(DenoteSpecialCharacters(*pStr), + OUString aString = ShortenString(DenoteSpecialCharacters(*aStr), nUndoStringLength, SwResId(STR_LDOTS)); @@ -810,15 +810,15 @@ void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) // cache the old values std::unique_ptr<Graphic> pOldGrf( pGrf ? new Graphic(*pGrf) : nullptr); - std::unique_ptr<OUString> pOldNm( pNm ? new OUString(*pNm) : nullptr); - std::unique_ptr<OUString> pOldFltr( pFltr ? new OUString(*pFltr) : nullptr); + boost::optional<OUString> aOldNm = maNm; + boost::optional<OUString> aOldFltr = maFltr; MirrorGraph nOldMirr = nMirr; // since all of them are cleared/modified by SaveGraphicData: SaveGraphicData( *pGrfNd ); - if( pOldNm ) + if( aOldNm ) { - pGrfNd->ReRead( *pOldNm, pFltr ? *pFltr : OUString() ); + pGrfNd->ReRead( *aOldNm, maFltr ? *maFltr : OUString() ); } else { @@ -845,16 +845,16 @@ void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd ) { if( rGrfNd.IsGrfLink() ) { - pNm.reset( new OUString ); - pFltr.reset( new OUString ); - rGrfNd.GetFileFilterNms( pNm.get(), pFltr.get() ); + maNm = OUString(); + maFltr = OUString(); + rGrfNd.GetFileFilterNms( maNm ? &*maNm : nullptr, maFltr ? &*maFltr : nullptr ); pGrf.reset(); } else { pGrf.reset( new Graphic( rGrfNd.GetGrf(true) ) ); - pNm.reset(); - pFltr.reset(); + maNm.reset(); + maFltr.reset(); } nMirr = rGrfNd.GetSwAttrSet().GetMirrorGrf().GetValue(); } diff --git a/sw/source/uibase/inc/toxmgr.hxx b/sw/source/uibase/inc/toxmgr.hxx index 470bc0a5fe22..0cf6a5f22745 100644 --- a/sw/source/uibase/inc/toxmgr.hxx +++ b/sw/source/uibase/inc/toxmgr.hxx @@ -24,6 +24,7 @@ #include <tox.hxx> #include <authfld.hxx> #include <memory> +#include <boost/optional.hpp> class SwWrtShell; class SwForm; @@ -37,10 +38,10 @@ class SW_DLLPUBLIC SwTOXDescription OUString m_sSequenceName; OUString m_sMainEntryCharStyle; OUString m_sAutoMarkURL; - std::unique_ptr<OUString> - m_pTitle; - std::unique_ptr<OUString> - m_pTOUName; + boost::optional<OUString> + m_aTitle; + boost::optional<OUString> + m_aTOUName; std::unique_ptr<SwForm> m_pForm; SwTOXElement m_nContent; @@ -72,8 +73,6 @@ public: // single argument ctors shall be explicit. explicit SwTOXDescription(TOXTypes eType) : m_eTOXType(eType), - m_pTitle(nullptr), - m_pTOUName(nullptr), m_pForm(nullptr), m_nContent(SwTOXElement::Mark | SwTOXElement::OutlineLevel), m_nIndexOptions(SwTOIOptions::SameEntry|SwTOIOptions::FF|SwTOIOptions::CaseSensitive), @@ -99,11 +98,11 @@ public: const OUString& GetAutoMarkURL() const { return m_sAutoMarkURL;} void SetAutoMarkURL(const OUString& rSet) {m_sAutoMarkURL = rSet;} - void SetTitle(const OUString& pSet) { m_pTitle.reset( new OUString(pSet) );} - const OUString* GetTitle() const {return m_pTitle.get(); } + void SetTitle(const OUString& rSet) { m_aTitle = rSet; } + boost::optional<OUString> const & GetTitle() const {return m_aTitle; } - void SetTOUName(const OUString& pSet) { m_pTOUName.reset( new OUString(pSet) );} - const OUString* GetTOUName() const {return m_pTOUName.get(); } + void SetTOUName(const OUString& rSet) { m_aTOUName = rSet; } + boost::optional<OUString> const & GetTOUName() const { return m_aTOUName; } void SetForm(const SwForm& rSet) { m_pForm.reset( new SwForm(rSet) );} const SwForm* GetForm() const {return m_pForm.get();} @@ -174,14 +173,14 @@ class SwTOXMarkDescription int nLevel; bool bMainEntry; - std::unique_ptr<OUString> pPrimKey; - std::unique_ptr<OUString> pSecKey; - std::unique_ptr<OUString> pAltStr; - std::unique_ptr<OUString> pTOUName; + boost::optional<OUString> maPrimKey; + boost::optional<OUString> maSecKey; + boost::optional<OUString> maAltStr; + boost::optional<OUString> maTOUName; - std::unique_ptr<OUString> pPhoneticReadingOfAltStr; - std::unique_ptr<OUString> pPhoneticReadingOfPrimKey; - std::unique_ptr<OUString> pPhoneticReadingOfSecKey; + boost::optional<OUString> maPhoneticReadingOfAltStr; + boost::optional<OUString> maPhoneticReadingOfPrimKey; + boost::optional<OUString> maPhoneticReadingOfSecKey; SwTOXMarkDescription(SwTOXMarkDescription&) = delete; SwTOXMarkDescription & operator= (SwTOXMarkDescription&) = delete; @@ -191,14 +190,7 @@ public: explicit SwTOXMarkDescription(TOXTypes eType) : eTOXType(eType), nLevel(0), - bMainEntry(false), - pPrimKey(nullptr), - pSecKey(nullptr), - pAltStr(nullptr), - pTOUName(nullptr), - pPhoneticReadingOfAltStr(nullptr), - pPhoneticReadingOfPrimKey(nullptr), - pPhoneticReadingOfSecKey(nullptr) + bMainEntry(false) { } @@ -210,33 +202,26 @@ public: void SetMainEntry(bool bSet) {bMainEntry = bSet;} bool IsMainEntry() const {return bMainEntry;} - void SetPrimKey(const OUString& rSet) - { pPrimKey.reset( new OUString(rSet) );} - const OUString* GetPrimKey() const {return pPrimKey.get();} + void SetPrimKey(const OUString& rSet) { maPrimKey = rSet; } + boost::optional<OUString> const & GetPrimKey() const { return maPrimKey; } - void SetSecKey(const OUString& rSet) - { pSecKey.reset( new OUString(rSet) );} - const OUString* GetSecKey() const { return pSecKey.get(); } + void SetSecKey(const OUString& rSet) { maSecKey = rSet; } + boost::optional<OUString> const & GetSecKey() const { return maSecKey; } - void SetAltStr(const OUString& rSet) - { pAltStr.reset( new OUString(rSet) );} - const OUString* GetAltStr() const { return pAltStr.get(); } + void SetAltStr(const OUString& rSet) { maAltStr = rSet; } + boost::optional<OUString> const & GetAltStr() const { return maAltStr; } - void SetTOUName(const OUString& rSet) - { pTOUName.reset( new OUString(rSet) );} - const OUString* GetTOUName() const {return pTOUName.get();} + void SetTOUName(const OUString& rSet) { maTOUName = rSet; } + boost::optional<OUString> const & GetTOUName() const { return maTOUName; } - void SetPhoneticReadingOfAltStr(const OUString& rSet) - { pPhoneticReadingOfAltStr.reset( new OUString(rSet) );} - const OUString* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr.get(); } + void SetPhoneticReadingOfAltStr(const OUString& rSet) { maPhoneticReadingOfAltStr = rSet; } + boost::optional<OUString> const & GetPhoneticReadingOfAltStr() const { return maPhoneticReadingOfAltStr; } - void SetPhoneticReadingOfPrimKey(const OUString& rSet) - { pPhoneticReadingOfPrimKey.reset( new OUString(rSet) );} - const OUString* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey.get(); } + void SetPhoneticReadingOfPrimKey(const OUString& rSet) { maPhoneticReadingOfPrimKey = rSet; } + boost::optional<OUString> const & GetPhoneticReadingOfPrimKey() const { return maPhoneticReadingOfPrimKey; } - void SetPhoneticReadingOfSecKey(const OUString& rSet) - { pPhoneticReadingOfSecKey.reset( new OUString(rSet) );} - const OUString* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey.get(); } + void SetPhoneticReadingOfSecKey(const OUString& rSet) { maPhoneticReadingOfSecKey = rSet; } + boost::optional<OUString> const & GetPhoneticReadingOfSecKey() const { return maPhoneticReadingOfSecKey; } }; class SW_DLLPUBLIC SwTOXMgr |