[Libreoffice-commits] core.git: sfx2/source svx/source

Caolán McNamara caolanm at redhat.com
Tue Aug 1 11:03:58 UTC 2017


 sfx2/source/sidebar/ResourceManager.cxx |   52 ++++++++++++++++++++++++++------
 svx/source/tbxctrls/PaletteManager.cxx  |   10 ++++--
 2 files changed, 50 insertions(+), 12 deletions(-)

New commits:
commit 879c1c398ffdd00b7a9e9cc3cbe26e1aa263e00d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Aug 1 10:08:58 2017 +0100

    Related: tdf#108655 only write to config if values changed
    
    Change-Id: I6ba001745638dc2b8ce091d717915e334ece4b04
    Reviewed-on: https://gerrit.libreoffice.org/40623
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index 83ff5337dd6e..a75aa42c86b6 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -322,11 +322,29 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc)
 
     utl::OConfigurationNode aDeckNode (aDeckRootNode.openNode(pDeckDesc->msNodeName));
 
-    aDeckNode.setNodeValue("Title", makeAny(pDeckDesc->msTitle));
-    aDeckNode.setNodeValue("OrderIndex", makeAny(pDeckDesc->mnOrderIndex));
-    aDeckNode.setNodeValue("ContextList", makeAny( sContextList ));
+    css::uno::Any aTitle(makeAny(pDeckDesc->msTitle));
+    css::uno::Any aOrder(makeAny(pDeckDesc->mnOrderIndex));
+    css::uno::Any aContextList(makeAny(sContextList));
 
-    aDeckRootNode.commit();
+    bool bChanged = false;
+    if (aTitle != aDeckNode.getNodeValue("Title"))
+    {
+        aDeckNode.setNodeValue("Title", aTitle);
+        bChanged = true;
+    }
+    if (aOrder != aDeckNode.getNodeValue("OrderIndex"))
+    {
+        aDeckNode.setNodeValue("OrderIndex", aOrder);
+        bChanged = true;
+    }
+    if (aContextList != aDeckNode.getNodeValue("ContextList"))
+    {
+        aDeckNode.setNodeValue("ContextList", aContextList);
+        bChanged = true;
+    }
+
+    if (bChanged)
+        aDeckRootNode.commit();
 
     // save panel settings
 
@@ -343,6 +361,7 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc)
 
     SharedPanelContainer rPanels = pDeckDesc->mpDeck->GetPanels();
 
+    bChanged = false;
     for ( SharedPanelContainer::iterator iPanel(rPanels.begin()), iEnd(rPanels.end());
               iPanel!=iEnd; ++iPanel)
     {
@@ -354,14 +373,29 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc)
 
         utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(xPanelDesc->msNodeName));
 
-        aPanelNode.setNodeValue("Title", makeAny(xPanelDesc->msTitle));
-        aPanelNode.setNodeValue("OrderIndex", makeAny(xPanelDesc->mnOrderIndex));
-        aPanelNode.setNodeValue("ContextList", makeAny( sPanelContextList ));
+        aTitle <<= xPanelDesc->msTitle;
+        aOrder <<= xPanelDesc->mnOrderIndex;
+        aContextList <<= sPanelContextList;
 
+        if (aTitle != aPanelNode.getNodeValue("Title"))
+        {
+            aPanelNode.setNodeValue("Title", aTitle);
+            bChanged = true;
+        }
+        if (aOrder != aPanelNode.getNodeValue("OrderIndex"))
+        {
+            aPanelNode.setNodeValue("OrderIndex", aOrder);
+            bChanged = true;
+        }
+        if (aContextList != aPanelNode.getNodeValue("ContextList"))
+        {
+            aPanelNode.setNodeValue("ContextList", aContextList);
+            bChanged = true;
+        }
     }
 
-     aPanelRootNode.commit();
-
+    if (bChanged)
+        aPanelRootNode.commit();
 }
 
 void ResourceManager::ReadPanelList()
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index b9e14521af6e..6e77ff700521 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -206,9 +206,13 @@ void PaletteManager::SetPalette( sal_Int32 nPos )
             }
         }
     }
-    std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
-    officecfg::Office::Common::UserColors::PaletteName::set(GetPaletteName(), batch);
-    batch->commit();
+    OUString aPaletteName(officecfg::Office::Common::UserColors::PaletteName::get());
+    if (aPaletteName != GetPaletteName())
+    {
+        std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
+        officecfg::Office::Common::UserColors::PaletteName::set(GetPaletteName(), batch);
+        batch->commit();
+    }
 }
 
 sal_Int32 PaletteManager::GetPalette()


More information about the Libreoffice-commits mailing list