[Libreoffice-commits] core.git: 2 commits - editeng/source sc/inc sc/source

Caolán McNamara caolanm at redhat.com
Thu Apr 6 08:26:18 UTC 2017


 editeng/source/editeng/impedit2.cxx |   15 +++++++--------
 sc/inc/autoform.hxx                 |    5 +++--
 sc/source/core/data/global.cxx      |   10 +++++++---
 sc/source/core/tool/autoform.cxx    |   18 ------------------
 4 files changed, 17 insertions(+), 31 deletions(-)

New commits:
commit dea248f5cbf91c41007bbb93037a653c5a543080
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Apr 6 09:25:13 2017 +0100

    unnecessary pre-all-oustring copy
    
    Change-Id: Ife45898482b74b1b911001d99d04bb8daeacfb41

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 64f9daaf9a2e..5103333281f8 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1641,19 +1641,18 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
             pField = pField->GetEnd() ? pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, pField->GetEnd() ) : nullptr;
         }
 
-        OUString aOUText( aText );
-        sal_Int32 nTextLen = aOUText.getLength();
+        sal_Int32 nTextLen = aText.getLength();
 
         sal_Int32 nPos = 0;
-        short nScriptType = _xBI->getScriptType( aOUText, nPos );
+        short nScriptType = _xBI->getScriptType( aText, nPos );
         rTypes.push_back( ScriptTypePosInfo( nScriptType, nPos, nTextLen ) );
-        nPos = _xBI->endOfScript( aOUText, nPos, nScriptType );
+        nPos = _xBI->endOfScript( aText, nPos, nScriptType );
         while ( ( nPos != (-1) ) && ( nPos < nTextLen ) )
         {
             rTypes.back().nEndPos = nPos;
 
-            nScriptType = _xBI->getScriptType( aOUText, nPos );
-            long nEndPos = _xBI->endOfScript( aOUText, nPos, nScriptType );
+            nScriptType = _xBI->getScriptType( aText, nPos );
+            long nEndPos = _xBI->endOfScript( aText, nPos, nScriptType );
 
             if ( ( nScriptType == i18n::ScriptType::WEAK ) || ( nScriptType == rTypes.back().nScriptType ) )
             {
@@ -1662,9 +1661,9 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara )
             }
             else
             {
-                if ( _xBI->getScriptType( aOUText, nPos - 1 ) == i18n::ScriptType::WEAK )
+                if ( _xBI->getScriptType( aText, nPos - 1 ) == i18n::ScriptType::WEAK )
                 {
-                    switch ( u_charType(aOUText.iterateCodePoints(&nPos, 0) ) ) {
+                    switch ( u_charType(aText.iterateCodePoints(&nPos, 0) ) ) {
                     case U_NON_SPACING_MARK:
                     case U_ENCLOSING_MARK:
                     case U_COMBINING_SPACING_MARK:
commit 167b730cc6bcf87508b2b4f344903a44470caf69
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Apr 5 09:22:49 2017 +0100

    move ScAutoFormat::Save out of dtor
    
    and drop unused copy ctor etc
    
    Change-Id: I958dae00ffc55cb42acae3c6341ccb6b21a30a84

diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index 66ff5725e7e7..d0e8760561d2 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -314,13 +314,14 @@ class SC_DLLPUBLIC ScAutoFormat
     bool mbSaveLater;
     ScAfVersions m_aVersions;
 
+    ScAutoFormat(const ScAutoFormat&) = delete;
+    const ScAutoFormat operator=(const ScAutoFormat&) = delete;
+
 public:
     typedef MapType::const_iterator const_iterator;
     typedef MapType::iterator iterator;
 
     ScAutoFormat();
-    ScAutoFormat(const ScAutoFormat& r);
-    ~ScAutoFormat();
     void Load();
     bool Save();
 
diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx
index 47fd37d831ae..c8821157da4e 100644
--- a/sc/source/core/data/global.cxx
+++ b/sc/source/core/data/global.cxx
@@ -246,10 +246,14 @@ void ScGlobal::SetSearchItem( const SvxSearchItem& rNew )
 
 void ScGlobal::ClearAutoFormat()
 {
-    if (pAutoFormat!=nullptr)
+    if (pAutoFormat)
     {
+        //  When modified via StarOne then only the SaveLater flag is set and no saving is done.
+        //  If the flag is set then save now.
+        if (pAutoFormat->IsSaveLater())
+            pAutoFormat->Save();
         delete pAutoFormat;
-        pAutoFormat=nullptr;
+        pAutoFormat = nullptr;
     }
 }
 
@@ -571,7 +575,7 @@ void ScGlobal::Clear()
     }
     theAddInAsyncTbl.clear();
     ExitExternalFunc();
-    DELETEZ(pAutoFormat);
+    ClearAutoFormat();
     DELETEZ(pSearchItem);
     DELETEZ(pLegacyFuncCollection);
     DELETEZ(pAddInCollection);
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 7649bc703203..15949443efe6 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -917,24 +917,6 @@ bool DefaultFirstEntry::operator() (const OUString& left, const OUString& right)
     return ScGlobal::GetCollator()->compareString( left, right) < 0;
 }
 
-ScAutoFormat::ScAutoFormat(const ScAutoFormat& r)
-    : mbSaveLater(false)
-{
-    for (auto const& it : r.m_Data)
-    {
-        m_Data.insert(std::make_pair(it.first, o3tl::make_unique<ScAutoFormatData>(*it.second)));
-    }
-}
-
-ScAutoFormat::~ScAutoFormat()
-{
-    //  When modified via StarOne then only the SaveLater flag is set and no saving is done.
-    //  If the flag is set then save now.
-
-    if (mbSaveLater)
-        Save();
-}
-
 void ScAutoFormat::SetSaveLater( bool bSet )
 {
     mbSaveLater = bSet;


More information about the Libreoffice-commits mailing list