[Libreoffice-commits] core.git: editeng/source include/editeng

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 10 13:09:15 UTC 2021


 editeng/source/editeng/eertfpar.cxx |   22 +++++++++++-----------
 editeng/source/rtf/svxrtf.cxx       |   26 +++++++++++++-------------
 include/editeng/svxrtf.hxx          |    3 ++-
 3 files changed, 26 insertions(+), 25 deletions(-)

New commits:
commit 447cec188191e77c09ffc51cc42549def277255b
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Mon Aug 9 18:14:14 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 10 15:08:37 2021 +0200

    no need to use unique_ptr for SvxRTFStyleType here
    
    Change-Id: I2af75b594096c54403af34d20303fbf3ff79a5f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120214
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index 278699dbfcb1..e3f7dba07249 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -374,8 +374,8 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
             auto const& pS = it->second;
             mpEditEngine->SetStyleSheet(
                 EditSelection(aStartPaM, aEndPaM),
-                static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS->sName, SfxStyleFamily::All)));
-            nOutlLevel = pS->nOutlineNo;
+                static_cast<SfxStyleSheet*>(mpEditEngine->GetStyleSheetPool()->Find(pS.sName, SfxStyleFamily::All)));
+            nOutlLevel = pS.nOutlineNo;
         }
     }
 
@@ -436,10 +436,10 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
 SvxRTFStyleType* EditRTFParser::FindStyleSheet( std::u16string_view rName )
 {
     SvxRTFStyleTbl& rTable = GetStyleTbl();
-    for (auto const& iter : rTable)
+    for (auto & iter : rTable)
     {
-        if (iter.second->sName == rName)
-            return iter.second.get();
+        if (iter.second.sName == rName)
+            return &iter.second;
     }
     return nullptr;
 }
@@ -458,9 +458,9 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType const * pRTFStyl
         SvxRTFStyleTbl::iterator it = GetStyleTbl().find( pRTFStyle->nBasedOn );
         if ( it != GetStyleTbl().end())
         {
-            SvxRTFStyleType *const pS = it->second.get();
-            if ( pS && ( pS !=pRTFStyle ) )
-                aParent = pS->sName;
+            SvxRTFStyleType const& rS = it->second;
+            if ( &rS != pRTFStyle )
+                aParent = rS.sName;
         }
     }
 
@@ -492,10 +492,10 @@ void EditRTFParser::CreateStyleSheets()
     // the SvxRTFParser has now created the template...
     if (mpEditEngine->GetStyleSheetPool() && mpEditEngine->IsImportRTFStyleSheetsSet())
     {
-        for (auto const& elem : GetStyleTbl())
+        for (auto & elem : GetStyleTbl())
         {
-            SvxRTFStyleType* pRTFStyle = elem.second.get();
-            CreateStyleSheet( pRTFStyle );
+            SvxRTFStyleType& rRTFStyle = elem.second;
+            CreateStyleSheet( &rRTFStyle );
         }
     }
 }
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 4b0fd66bb224..4157ca894aa5 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -274,8 +274,8 @@ void SvxRTFParser::ReadStyleTable()
     sal_uInt16 nStyleNo = 0;
     bool bHasStyleNo = false;
     int _nOpenBrakets = 1;      // the first was already detected earlier!!
-    std::unique_ptr<SvxRTFStyleType> pStyle(new SvxRTFStyleType(*pAttrPool, aWhichMap));
-    pStyle->aAttrSet.Put( GetRTFDefaults() );
+    std::optional<SvxRTFStyleType> xStyle(SvxRTFStyleType(*pAttrPool, aWhichMap));
+    xStyle->aAttrSet.Put( GetRTFDefaults() );
 
     bIsInReadStyleTab = true;
     bChkStyleAttr = false;      // Do not check Attribute against the Styles
@@ -310,10 +310,10 @@ void SvxRTFParser::ReadStyleTable()
             }
             break;
 
-        case RTF_SBASEDON:  pStyle->nBasedOn = sal_uInt16(nTokenValue); break;
+        case RTF_SBASEDON:  xStyle->nBasedOn = sal_uInt16(nTokenValue); break;
         case RTF_SNEXT:     break;
         case RTF_OUTLINELEVEL:
-        case RTF_SOUTLVL:   pStyle->nOutlineNo = sal_uInt8(nTokenValue);    break;
+        case RTF_SOUTLVL:   xStyle->nOutlineNo = sal_uInt8(nTokenValue);    break;
         case RTF_S:         nStyleNo = static_cast<short>(nTokenValue);
                             bHasStyleNo = true;
                             break;
@@ -324,16 +324,16 @@ void SvxRTFParser::ReadStyleTable()
         case RTF_TEXTTOKEN:
             if (bHasStyleNo)
             {
-                pStyle->sName = DelCharAtEnd( aToken, ';' );
+                xStyle->sName = DelCharAtEnd( aToken, ';' );
 
                 if (!m_StyleTable.empty())
                 {
                     m_StyleTable.erase(nStyleNo);
                 }
                 // All data from the font is available, so off to the table
-                m_StyleTable.insert(std::make_pair(nStyleNo, std::move(pStyle)));
-                pStyle.reset(new SvxRTFStyleType(*pAttrPool, aWhichMap));
-                pStyle->aAttrSet.Put( GetRTFDefaults() );
+                m_StyleTable.emplace(nStyleNo, std::move(*xStyle));
+                xStyle.emplace(*pAttrPool, aWhichMap);
+                xStyle->aAttrSet.Put( GetRTFDefaults() );
                 nStyleNo = 0;
                 bHasStyleNo = false;
             }
@@ -342,7 +342,7 @@ void SvxRTFParser::ReadStyleTable()
             switch( nToken & ~(0xff | RTF_SWGDEFS) )
             {
             case RTF_PARFMT:        // here are no SWGDEFS
-                ReadAttr( nToken, &pStyle->aAttrSet );
+                ReadAttr( nToken, &xStyle->aAttrSet );
                 break;
 
             case RTF_CHRFMT:
@@ -365,7 +365,7 @@ void SvxRTFParser::ReadStyleTable()
                         ++nSkippedTokens;
                     }
                 }
-                ReadAttr( nToken, &pStyle->aAttrSet );
+                ReadAttr( nToken, &xStyle->aAttrSet );
                 if (nSkippedTokens && m_nTokenIndex == nEnteringIndex - nSkippedTokens)
                 {
                     // we called SkipToken to go back one or two, but ReadAttrs
@@ -381,7 +381,7 @@ void SvxRTFParser::ReadStyleTable()
             break;
         }
     }
-    pStyle.reset();         // Delete the Last Style
+    xStyle.reset();         // Delete the Last Style
     SkipToken();        // the closing brace is evaluated "above"
 
     // Flag back to old state
@@ -664,8 +664,8 @@ void SvxRTFParser::ClearStyleAttr_( SvxRTFItemStackType& rStkType )
     {
         // Delete all Attributes, which are already defined in the Style,
         // from the current AttrSet.
-        auto const& pStyle = m_StyleTable.find(rStkType.nStyleNo)->second;
-        SfxItemSet &rStyleSet = pStyle->aAttrSet;
+        auto & rStyle = m_StyleTable.find(rStkType.nStyleNo)->second;
+        SfxItemSet &rStyleSet = rStyle.aAttrSet;
         const SfxPoolItem* pSItem;
         for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
         {
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index 44723700d4a8..78e38eeefa81 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -72,7 +72,6 @@ public:
 };
 
 typedef std::map<short, vcl::Font> SvxRTFFontTbl;
-typedef std::map<sal_uInt16, std::unique_ptr<SvxRTFStyleType>> SvxRTFStyleTbl;
 
 // own helper classes for the RTF Parser
 struct SvxRTFStyleType
@@ -85,6 +84,8 @@ struct SvxRTFStyleType
     SvxRTFStyleType(SfxItemPool& rPool, const WhichRangesContainer& pWhichRange);
 };
 
+typedef std::map<sal_uInt16, SvxRTFStyleType> SvxRTFStyleTbl;
+
 class EDITENG_DLLPUBLIC SvxRTFParser : public SvRTFParser
 {
     std::vector<Color>    maColorTable;


More information about the Libreoffice-commits mailing list