[Libreoffice-commits] core.git: Branch 'feature/gsoc14-colors' - include/svx svx/source

Krisztian Pinter pin.terminator at gmail.com
Thu Jul 31 01:59:00 PDT 2014


 include/svx/Palette.hxx         |    3 ++-
 svx/source/tbxctrls/Palette.cxx |   19 +++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

New commits:
commit 771b951a806d956c2ae2dc7b64cb6e15f4839630
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Thu Jul 31 10:56:58 2014 +0200

    Make .soc loading lazy
    
    Change-Id: If7475d6c46faaa6f6f6cde494990e6573b3aadff

diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx
index 2be4eb2..11a3462 100644
--- a/include/svx/Palette.hxx
+++ b/include/svx/Palette.hxx
@@ -65,7 +65,8 @@ public:
 
 class PaletteSOC : public Palette
 {
-    //TODO add lazy loading
+    bool            mbLoadedPalette;
+    OUString        maFPath;
     OUString        maName;
     XColorListRef   mpColorList;
 public:
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index 95ebb58..496e0fc 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -173,11 +173,11 @@ OString lcl_getToken(const OString& rStr, sal_Int32& index)
 
 // PaletteSOC ------------------------------------------------------------------
 
-PaletteSOC::PaletteSOC( const OUString &rFPath, const OUString &rFName )
+PaletteSOC::PaletteSOC( const OUString &rFPath, const OUString &rFName ) :
+    mbLoadedPalette( false ),
+    maFPath( rFPath ),
+    maName( rFName )
 {
-    maName = rFName;
-    mpColorList = XPropertyList::AsColorList(XPropertyList::CreatePropertyListFromURL(XCOLOR_LIST, rFPath));
-    mpColorList->Load();
 }
 
 PaletteSOC::~PaletteSOC()
@@ -191,13 +191,20 @@ const OUString& PaletteSOC::GetName()
 
 void PaletteSOC::LoadColorSet( SvxColorValueSet& rColorSet )
 {
+    if( !mbLoadedPalette )
+    {
+        mbLoadedPalette = true;
+        mpColorList = XPropertyList::AsColorList(XPropertyList::CreatePropertyListFromURL(XCOLOR_LIST, maFPath));
+        mpColorList->Load();
+    }
     rColorSet.Clear();
-    rColorSet.addEntriesForXColorList( *mpColorList );
+    if( mpColorList.is() )
+        rColorSet.addEntriesForXColorList( *mpColorList );
 }
 
 bool PaletteSOC::IsValid()
 {
-    return mpColorList.is();
+    return true;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list