[Libreoffice-commits] core.git: Branch 'feature/gsoc14-colors' - 2897 commits - accessibility/inc accessibility/Library_acc.mk accessibility/source android/abs-lib android/Bootstrap android/CustomTarget_lo_android.mk android/experimental android/Module_android.mk avmedia/Library_avmedia.mk avmedia/Library_avmediaogl.mk avmedia/Module_avmedia.mk avmedia/source basctl/source basctl/uiconfig basebmp/Module_basebmp.mk basegfx/source basegfx/test basic/CppunitTest_basic_coverage.mk basic/CppunitTest_basic_enable.mk basic/CppunitTest_basic_nested_struct.mk basic/CppunitTest_basic_scanner.mk basic/CppunitTest_basic_vba.mk basic/inc basic/qa basic/source bean/inc bean/Library_officebean.mk bean/native binaryurp/source bin/distro-install-desktop-integration bin/distro-install-file-lists bin/find-german-comments bin/findunusedcode bin/gbuild-to-ide bin/get-bugzilla-attachments-by-mimetype bin/update_pch.sh bridges/inc bridges/Library_cpp_uno.mk bridges/source bridges/test canvas/source chart2/AllLangResTar get_chartcontroller.mk chart2/CppunitTest_chart2_export.mk chart2/CppunitTest_chart2_import.mk chart2/CppunitTest_chart2_xshape.mk chart2/inc chart2/Library_chartcontroller.mk chart2/Library_chartcore.mk chart2/opengl chart2/Package_opengl.mk chart2/qa chart2/source chart2/uiconfig chart2/UIConfig_chart2.mk cli_ure/CustomTarget_cli_ure_assemblies.mk cli_ure/Library_cli_cppuhelper_native.mk cli_ure/source codemaker/source comphelper/source compilerplugins/clang config.guess config_host/config_features.h.in config_host/config_vcl.h.in config_host.mk.in configmgr/qa configmgr/source config.sub configure.ac connectivity/CppunitTest_connectivity_ado.mk connectivity/CppunitTest_connectivity_commontools.mk connectivity/CppunitTest_connectivity_mork.mk connectivity/inc connectivity/Library_ado.mk connectivity/Library_calc.mk connectivity/Library_dbase.mk connectivity/Library_dbpool2.mk connectivity/Library_dbtools.mk connectivity/Library_firebird_sdbc.mk connectivity/Library_mysql.mk connec tivity/Library_odbc.mk connectivity/Library_postgresql-sdbc-impl.mk connectivity/Library_tdeab1.mk connectivity/Library_tdeabdrv1.mk connectivity/qa connectivity/registry connectivity/source connectivity/workben cppcanvas/CppunitTest_cppcanvas_emfplus.mk cppcanvas/CppunitTest_cppcanvas_test.mk cppcanvas/inc cppcanvas/Library_cppcanvas.mk cppcanvas/source cppuhelper/inc cppuhelper/Library_cppuhelper.mk cppuhelper/qa cppuhelper/source cppuhelper/test cppu/source crashrep/source cui/AllLangResTarget_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk dbaccess/AllLangResTarget_dbu.mk dbaccess/CppunitTest_dbaccess_dialog_save.mk dbaccess/CppunitTest_dbaccess_embeddeddb_performancetest.mk dbaccess/CppunitTest_dbaccess_firebird_test.mk dbaccess/CppunitTest_dbaccess_hsqldb_test.mk dbaccess/CppunitTest_dbaccess_macros_test.mk dbaccess/inc dbaccess/Library_dbaxml.mk dbaccess/Library_dbmm.mk dbaccess/Library_sdbt.mk dbaccess/source dbaccess/uiconfig dbaccess/UIConfig_dbaccess.mk desktop/inc des ktop/Library_deploymentgui.mk desktop/Library_deploymentmisc.mk desktop/Library_deployment.mk desktop/Library_libreoffice.mk desktop/Library_sofficeapp.mk desktop/Module_desktop.mk desktop/qa desktop/source desktop/test desktop/uiconfig desktop/UIConfig_deployment.mk desktop/unx desktop/win32 dictionaries download.lst drawinglayer/source editeng/CppunitTest_editeng_core.mk editeng/inc editeng/source embeddedobj/source embedserv/Library_emser.mk extensions/AllLangResTarget_bib.mk extensions/AllLangResTarget_scn.mk extensions/CppunitTest_extensions_test_update.mk extensions/inc extensions/Library_npsoplugin.mk extensions/Library_oleautobridge.mk extensions/Library_so_activex.mk extensions/Library_so_activex_x64.mk extensions/Library_updchk.mk extensions/Module_extensions.mk extensions/source extensions/test extensions/uiconfig extensions/UIConfig_sabpilot.mk extensions/UIConfig_sbibliography.mk extensions/UIConfig_scanner.mk extensions/UIConfig_spropctrlr.mk extensions/WinResTarget_ac tivex.mk external/beanshell external/boost external/clucene external/coinmp external/collada2gltf external/cppunit external/curl external/firebird external/glew external/hunspell external/hyphen external/icu external/jfreereport external/lcms2 external/libabw external/libebook external/libetonyek external/libexttextcat external/libfreehand external/libgltf external/liblangtag external/libmwaw external/libodfgen external/libpagemaker external/librevenge external/libvisio external/libwpd external/libwps external/libxml2 external/libxmlsec external/libxslt external/lpsolve external/Module_external.mk external/more_fonts external/mythes external/nss external/openssl external/poppler external/python3 external/redland external/rhino external/unixODBC extras/AllLangPackage_autotextshare.mk extras/CustomTarget_autocorr.mk extras/CustomTarget_autotextshare.mk extras/CustomTarget_autotextuser.mk extras/Module_extras.mk extras/Package_autocorr.mk extras/Package_autotextuser.mk extras/source fi lter/Configuration_filter.mk filter/CppunitTest_filter_pcx_test.mk filter/CppunitTest_filter_pict_test.mk filter/CppunitTest_filter_ppm_test.mk filter/CppunitTest_filter_priority.mk filter/CppunitTest_filter_psd_test.mk filter/CppunitTest_filter_ras_test.mk filter/CppunitTest_filter_tga_test.mk filter/CppunitTest_filter_tiff_test.mk filter/CppunitTest_filter_xslt.mk filter/Library_filterconfig.mk filter/Library_svgfilter.mk filter/Module_filter.mk filter/qa filter/source filter/uiconfig forms/source formula/inc formula/Module_formula.mk formula/source formula/uiconfig formula/UIConfig_formula.mk fpicker/Library_fps_office.mk fpicker/source fpicker/uiconfig fpicker/UIConfig_fps.mk framework/inc framework/Library_fwe.mk framework/Library_fwi.mk framework/Library_fwk.mk framework/Library_fwl.mk framework/source helpcompiler/inc helpcompiler/source helpcontent2 hwpfilter/CppunitTest_hwpfilter_test_hwpfilter.mk hwpfilter/inc hwpfilter/Library_hwp.mk hwpfilter/source i18nlangtag/qa i18nla ngtag/source i18npool/source icon-themes/galaxy icon-themes/tango icon-themes/tango_testing idlc/inc idlc/source idl/source include/avmedia include/basebmp include/basegfx include/basic include/canvas include/codemaker include/com include/comphelper include/connectivity include/cppu include/cppuhelper include/cppunittester include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/framework include/helpcompiler include/i18nlangtag include/jvmaccess include/LibreOfficeKit include/o3tl include/oox include/osl include/package include/rtl include/sal include/salhelper include/sax include/sfx2 include/sot include/store include/svl include/svtools include/svx include/systools include/test include/toolkit include/tools include/touch include/typelib include/ucbhelper include/uno include/unotest include/unotools include/vbahelper include/vcl include/writerperfect include/xmloff include/xmlreader include/xmlscript instsetoo_native/inc_openoffice ios/CustomTar get_TiledLibreOffice_app.mk ios/experimental ios/lo.xcconfig.in io/source jurt/com jurt/source jvmaccess/source jvmfwk/plugins jvmfwk/source l10ntools/inc l10ntools/source Library_merged.mk libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Makefile libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/README libreofficekit/source libreofficekit/StaticLibrary_libreofficekit.mk lingucomponent/source linguistic/source lotuswordpro/CppunitTest_lotuswordpro_test_lotuswordpro.mk lotuswordpro/Library_lwpft.mk lotuswordpro/source Makefile.fetch Makefile.in mysqlc/source odk/CustomTarget_check.mk odk/CustomTarget_javadoc.mk odk/examples odk/Package_examples.mk odk/source offapi/com offapi/UnoApi_offapi.mk officecfg/CustomTarget_registry.mk officecfg/registry oovbaapi/ooo oox/inc oox/Library_oox.mk oox/source package/inc package/Library_package2.mk package/Librar y_xstor.mk package/source postprocess/CppunitTest_services.mk postprocess/CustomTarget_registry.mk postprocess/qa postprocess/Rdb_services.mk pyuno/qa pyuno/source qadevOOo/runner qadevOOo/tests readlicense_oo/docs readlicense_oo/license README.Android README.cross registry/source reportbuilder/java reportdesign/inc reportdesign/source reportdesign/uiconfig reportdesign/UIConfig_dbreport.mk RepositoryExternal.mk Repository.mk RepositoryModule_host.mk ridljar/com rsc/inc rsc/source sal/android sal/cpprt sal/cppunittester sal/CppunitTest_sal_osl_process.mk salhelper/source salhelper/test sal/Library_lo-bootstrap.mk sal/Module_sal.mk sal/osl sal/qa sal/rtl sal/util sax/CppunitTest_sax_parser.mk sax/source scaddins/source sc/AllLangResTarget_sc.mk sccomp/CppunitTest_sccomp_lpsolver.mk sccomp/source sc/CppunitTest_sc_annotationobj.mk sc/CppunitTest_sc_annotationshapeobj.mk sc/CppunitTest_sc_annotationsobj.mk sc/CppunitTest_sc_cellrangeobj.mk sc/CppunitTest_sc_chart_regression_test.mk sc/ CppunitTest_sc_databaserangeobj.mk sc/CppunitTest_sc_datapilotfieldobj.mk sc/CppunitTest_sc_datapilottableobj.mk sc/CppunitTest_sc_editfieldobj_cell.mk sc/CppunitTest_sc_editfieldobj_header.mk sc/CppunitTest_sc_filters_test.mk sc/CppunitTest_sc_html_export_test.mk sc/CppunitTest_sc_macros_test.mk sc/CppunitTest_sc_modelobj.mk sc/CppunitTest_sc_namedrangeobj.mk sc/CppunitTest_sc_namedrangesobj.mk sc/CppunitTest_sc_opencl_test.mk sc/CppunitTest_sc_outlineobj.mk sc/CppunitTest_sc_rangelst_test.mk sc/CppunitTest_sc_subsequent_export_test.mk sc/CppunitTest_sc_subsequent_filters_test.mk sc/CppunitTest_sc_tableautoformatfield.mk sc/CppunitTest_sc_tablesheetobj.mk sc/CppunitTest_sc_tablesheetsobj.mk sc/CppunitTest_sc_ucalc.mk sc/inc sc/Library_scfilt.mk sc/Library_sc.mk sc/Library_scqahelper.mk scp2/AutoInstall.mk scp2/inc scp2/InstallModule_base.mk scp2/InstallModule_impress.mk scp2/InstallModule_ooo.mk scp2/InstallModule_ure.mk scp2/source sc/qa scripting/source scripting/workben sc/sourc e sc/uiconfig sc/UIConfig_scalc.mk sc/workben sd/AllLangResTarget_sd.mk sd/CppunitTest_sd_export_tests.mk sd/CppunitTest_sd_filters_test.mk sd/CppunitTest_sd_html_export_tests.mk sd/CppunitTest_sd_import_tests.mk sdext/CppunitTest_sdext_pdfimport.mk sdext/inc sdext/Library_pdfimport.mk sdext/Library_PresentationMinimizer.mk sdext/Library_PresenterScreen.mk sdext/source sd/inc sd/Library_sd.mk sd/Module_sd.mk sd/qa sd/sdi sd/source sd/uiconfig sd/UIConfig_simpress.mk sd/workben setup_native/Library_getuid.mk setup_native/source sfx2/AllLangResTarget_sfx2.mk sfx2/inc sfx2/Library_sfx.mk sfx2/qa sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk shell/inc shell/Library_tdebe.mk shell/Module_shell.mk shell/source slideshow/source smoketest/Executable_libtest.mk smoketest/libtest.cxx solenv/bin solenv/gbuild solenv/gcc-wrappers soltools/cpp soltools/mkdepend sot/inc sot/Library_sot.mk sot/source starmath/CppunitTest_starmath_qa_cppunit.mk starmath/inc starmath/source starmath/uiconfig stoc/i nc stoc/Library_javaloader.mk stoc/source stoc/test store/Library_store.mk store/source store/workben svgio/CppunitTest_svgio.mk svgio/inc svgio/Library_svgio.mk svgio/qa svgio/source svl/CppunitTest_svl_itempool.mk svl/CppunitTest_svl_items.mk svl/CppunitTest_svl_notify.mk svl/CppunitTest_svl_qa_cppunit.mk svl/Library_svl.mk svl/Module_svl.mk svl/qa svl/source svtools/CppunitTest_svtools_graphic.mk svtools/Library_svt.mk svtools/Module_svtools.mk svtools/qa svtools/source svtools/uiconfig svtools/UIConfig_svt.mk svx/inc svx/Library_svxcore.mk svx/Library_svx.mk svx/Module_svx.mk svx/source svx/uiconfig svx/UIConfig_svx.mk sw/AllLangResTarget_sw.mk sw/CppunitTest_sw_filters_test.mk sw/CppunitTest_sw_htmlexport.mk sw/CppunitTest_sw_macros_test.mk sw/CppunitTest_sw_odfexport.mk sw/CppunitTest_sw_odfimport.mk sw/CppunitTest_sw_ooxmlexport.mk sw/CppunitTest_sw_ooxmlfieldexport.mk sw/CppunitTest_sw_ooxmlimport.mk sw/CppunitTest_sw_ooxmlsdrexport.mk sw/CppunitTest_sw_ooxmlw14export.mk sw/ CppunitTest_sw_rtfexport.mk sw/CppunitTest_sw_rtfimport.mk sw/CppunitTest_sw_tox.mk sw/CppunitTest_sw_uiwriter.mk sw/CppunitTest_sw_uwriter.mk sw/CppunitTest_sw_ww8export.mk sw/CppunitTest_sw_ww8import.mk swext/mediawiki sw/inc sw/Library_sw.mk sw/Library_swui.mk sw/Module_sw.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk sysui/desktop test/Library_subsequenttest.mk test/Library_test.mk test/Library_vclbootstrapprotector.mk test/Module_test.mk test/source testtools/source toolkit/Library_tk.mk toolkit/source tools/Library_tl.mk tools/qa tools/source translations ucbhelper/source ucb/Library_cached1.mk ucb/Library_srtrs1.mk ucb/Library_ucpdav1.mk ucb/Library_ucpftp1.mk ucb/source ucb/workben udkapi/com UnoControls/inc UnoControls/source unodevtools/source unoidl/source unotest/source unotools/source unoxml/source unusedcode.easy ure/source uui/AllLangResTarget_uui.mk uui/inc uui/Library_uui.mk uui/source uui/uiconfig uui/UIConfig_uui.mk vbahelper/inc vbahelper/Library_m sforms.mk vbahelper/Library_vbahelper.mk vbahelper/source vcl/CppunitTest_vcl_complextext.mk vcl/CppunitTest_vcl_filters_test.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/CustomTarget_afm_hash.mk vcl/Executable_tdefilepicker.mk vcl/Executable_xid_fullscreen_on_all_monitors.mk vcl/generic vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Library_vclplug_tde.mk vcl/osx vcl/qa vcl/quartz vcl/source vcl/uiconfig vcl/unx vcl/win vcl/workben winaccessibility/Library_uacccom.mk winaccessibility/source wizards/com writerfilter/CppunitTest_writerfilter_misc.mk writerfilter/CppunitTest_writerfilter_rtftok.mk writerfilter/CustomTarget_source.mk writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/qa writerfilter/source writerperfect/CppunitTest_writerperfect_calc.mk writerperfect/CppunitTest_writerperfect_draw.mk writerperfect/CppunitTest_writerperfect_impress.mk writerperfect/CppunitTest_writerperfect_stream.mk writerperfect/CppunitTest_writerperfect_writer.mk writerperfect/Library_wpftdraw .mk writerperfect/qa writerperfect/source xmerge/source xmlhelp/source xmloff/CppunitTest_xmloff_uxmloff.mk xmloff/inc xmloff/Library_xo.mk xmloff/qa xmloff/source xmlreader/source xmlscript/inc xmlscript/Library_xmlscript.mk xmlscript/source xmlsecurity/inc xmlsecurity/Library_xmlsecurity.mk xmlsecurity/Library_xsec_fw.mk xmlsecurity/Library_xsec_xmlsec.mk xmlsecurity/source xmlsecurity/uiconfig

Krisztian Pinter pin.terminator at gmail.com
Fri Jul 25 08:34:37 PDT 2014


Rebased ref, commits from common ancestor:
commit b3d4482d551936d1bc24e0fda3a9eeee9e35a4a1
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Fri Jul 25 16:45:13 2014 +0200

    Add loading .soc palettes
    
    Change-Id: Ie0d084a70d9b135658840bb7529f2099a702d280

diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx
index d31e958..c659e06 100644
--- a/include/svx/Palette.hxx
+++ b/include/svx/Palette.hxx
@@ -19,16 +19,30 @@
 #ifndef INCLUDED_SVX_PALETTE_HXX
 #define INCLUDED_SVX_PALETTE_HXX
 
+#include <svx/SvxColorValueSet.hxx>
+#include <svx/xtable.hxx>
 #include <rtl/ustring.hxx>
 #include <tools/color.hxx>
 #include <tools/stream.hxx>
 
+
+typedef std::pair<Color, OString> NamedColor;
+typedef std::vector< NamedColor > ColorList;
+
+
 class Palette
 {
 public:
-    typedef std::pair<Color, OString> NamedColor;
-    typedef std::vector< NamedColor > ColorList;
-private:
+    virtual ~Palette();
+
+    virtual const OUString&     GetName() = 0;
+    virtual void                LoadColorSet( SvxColorValueSet& rColorSet ) = 0;
+
+    virtual bool                IsValid() = 0;
+};
+
+class PaletteGPL : public Palette
+{
     bool        mbLoadedPalette;
     bool        mbValidPalette;
     OUString    maFName;
@@ -40,12 +54,28 @@ private:
     void        LoadPaletteHeader();
     void        LoadPalette();
 public:
-    Palette( const OUString &rFPath, const OUString &rFName );
+    PaletteGPL( const OUString &rFPath, const OUString &rFName );
+    virtual ~PaletteGPL();
+
+    virtual const OUString&     GetName();
+    virtual void                LoadColorSet( SvxColorValueSet& rColorSet );
+
+    virtual bool                IsValid();
+};
+
+class PaletteSOC : public Palette
+{
+    //TODO add lazy loading
+    OUString        maName;
+    XColorListRef   mpColorList;
+public:
+    PaletteSOC( const OUString &rFPath, const OUString &rFName );
+    virtual ~PaletteSOC();
 
-    const OUString&     GetName();
-    const ColorList&    GetPaletteColors();
+    virtual const OUString&     GetName();
+    virtual void                LoadColorSet( SvxColorValueSet& rColorSet );
 
-    bool                IsValid();
+    virtual bool                IsValid();
 };
 
 #endif // INCLUDED_SVX_PALETTE_HXX
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index 925f67b..1bd0bd1 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_SVX_PALETTEMANAGER_HXX
 
 #include <svx/SvxColorValueSet.hxx>
+#include <svx/Palette.hxx>
 #include <rtl/ustring.hxx>
 #include <svx/tbxcolorupdate.hxx>
 
@@ -32,9 +33,10 @@ class PaletteManager
     svx::ToolboxButtonColorUpdater* mpBtnUpdater;
 
     Color       mLastColor;
-    std::vector<Palette> maPalettes;
+    std::vector<Palette*> maPalettes;
 public:
     PaletteManager();
+    ~PaletteManager();
     void        LoadPalettes();
     void        ReloadColorSet(SvxColorValueSet& rColorSet);
     std::vector<OUString> GetPaletteList();
diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx
index 7db9f4c..a3130ed 100644
--- a/include/svx/SvxColorValueSet.hxx
+++ b/include/svx/SvxColorValueSet.hxx
@@ -19,7 +19,6 @@
 #ifndef INCLUDED_SVX_SVXCOLORVALUESET_HXX
 #define INCLUDED_SVX_SVXCOLORVALUESET_HXX
 
-#include <svx/Palette.hxx>
 #include <svtools/valueset.hxx>
 #include <svx/svxdllapi.h>
 
@@ -41,7 +40,6 @@ public:
 
     void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1);
     void loadColorVector(const std::vector<Color>& rColorVector, const OUString& rNamePrefix, sal_uInt32 nStartIndex = 1);
-    void loadPalette(Palette& rPalette);
     Size layoutAllVisible(sal_uInt32 nEntryCount);
     Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
 };
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index f84f2d5..f499b98 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -19,39 +19,16 @@
 
 #include <svx/Palette.hxx>
 
-// finds first token in rStr from index, separated by whitespace
-// returns position of next token in index
-OString lcl_getToken(const OString& rStr, sal_Int32& index)
-{
-    sal_Int32 substart, toklen = 0;
-
-    while(index < rStr.getLength() &&
-          (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
-        ++index;
-    if(index == rStr.getLength())
-    {
-        index = -1;
-        return OString();
-    }
-    substart = index;
 
-    while(index < rStr.getLength() &&
-          !(rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
-    {
-        ++index;
-        ++toklen;
-    }
+Palette::~Palette()
+{
+}
 
-    while(index < rStr.getLength() &&
-          (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
-        ++index;
-    if(index == rStr.getLength())
-        index = -1;
+// PaletteGPL ------------------------------------------------------------------
 
-    return rStr.copy(substart, toklen);
-}
+OString lcl_getToken(const OString& rStr, sal_Int32& index);
 
-Palette::Palette( const OUString &rFPath, const OUString &rFName ) :
+PaletteGPL::PaletteGPL( const OUString &rFPath, const OUString &rFName ) :
     mbLoadedPalette( false ),
     mbValidPalette( false ),
     maFName( rFName ),
@@ -60,23 +37,36 @@ Palette::Palette( const OUString &rFPath, const OUString &rFName ) :
     LoadPaletteHeader();
 }
 
-const OUString& Palette::GetName()
+PaletteGPL::~PaletteGPL()
+{
+}
+
+const OUString& PaletteGPL::GetName()
 {
     return maName;
 }
 
-const Palette::ColorList& Palette::GetPaletteColors()
+void PaletteGPL::LoadColorSet( SvxColorValueSet& rColorSet )
 {
     LoadPalette();
-    return maColors;
+
+    rColorSet.Clear();
+    int nIx = 1;
+    for(ColorList::const_iterator it = maColors.begin();
+        it != maColors.end(); ++it)
+    {
+        // TODO make it->second OUString
+        rColorSet.InsertItem(nIx, it->first, OStringToOUString(it->second, RTL_TEXTENCODING_ASCII_US));
+        ++nIx;
+    }
 }
 
-bool Palette::IsValid()
+bool PaletteGPL::IsValid()
 {
     return mbValidPalette;
 }
 
-bool Palette::ReadPaletteHeader(SvFileStream& rFileStream)
+bool PaletteGPL::ReadPaletteHeader(SvFileStream& rFileStream)
 {
     OString aLine;
     OString aName;
@@ -98,14 +88,13 @@ bool Palette::ReadPaletteHeader(SvFileStream& rFileStream)
     return true;
 }
 
-//TODO make this LoadPaletteHeader and set a bool if palette is incorrect
-void Palette::LoadPaletteHeader()
+void PaletteGPL::LoadPaletteHeader()
 {
     SvFileStream aFile(maFPath, STREAM_READ);
     mbValidPalette = ReadPaletteHeader( aFile );
 }
 
-void Palette::LoadPalette()
+void PaletteGPL::LoadPalette()
 {
     if( mbLoadedPalette ) return;
     mbLoadedPalette = true;
@@ -145,4 +134,68 @@ void Palette::LoadPalette()
     } while (aFile.ReadLine(aLine));
 }
 
+// finds first token in rStr from index, separated by whitespace
+// returns position of next token in index
+OString lcl_getToken(const OString& rStr, sal_Int32& index)
+{
+    sal_Int32 substart, toklen = 0;
+    OUString aWhitespaceChars( " \n\t" );
+
+    while(index < rStr.getLength() &&
+            aWhitespaceChars.indexOf( rStr[index] ) != -1)
+        ++index;
+    if(index == rStr.getLength())
+    {
+        index = -1;
+        return OString();
+    }
+    substart = index;
+
+    //counts length of token
+    while(index < rStr.getLength() &&
+            aWhitespaceChars.indexOf( rStr[index] ) == -1 )
+    {
+        ++index;
+        ++toklen;
+    }
+
+    //counts to position of next token
+    while(index < rStr.getLength() &&
+            aWhitespaceChars.indexOf( rStr[index] ) != -1 )
+        ++index;
+    if(index == rStr.getLength())
+        index = -1;
+
+    return rStr.copy(substart, toklen);
+}
+
+// PaletteSOC ------------------------------------------------------------------
+
+PaletteSOC::PaletteSOC( const OUString &rFPath, const OUString &rFName )
+{
+    maName = rFName;
+    mpColorList = XPropertyList::AsColorList(XPropertyList::CreatePropertyListFromURL(XCOLOR_LIST, rFPath));
+    mpColorList->Load();
+}
+
+PaletteSOC::~PaletteSOC()
+{
+}
+
+const OUString& PaletteSOC::GetName()
+{
+    return maName;
+}
+
+void PaletteSOC::LoadColorSet( SvxColorValueSet& rColorSet )
+{
+    rColorSet.Clear();
+    rColorSet.addEntriesForXColorList( *mpColorList );
+}
+
+bool PaletteSOC::IsValid()
+{
+    return mpColorList.is();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 95c351d..95485ce 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -39,6 +39,16 @@ PaletteManager::PaletteManager() :
     mnNumOfPalettes += maPalettes.size();
 }
 
+PaletteManager::~PaletteManager()
+{
+    for( std::vector<Palette*>::iterator it = maPalettes.begin();
+         it != maPalettes.end();
+         ++it)
+    {
+        delete *it;
+    }
+}
+
 void PaletteManager::LoadPalettes()
 {
     OUString aPalPath = SvtPathOptions().GetPalettePath();
@@ -57,12 +67,14 @@ void PaletteManager::LoadPalettes()
             if(aFileStat.isRegular() || aFileStat.isLink())
             {
                 OUString aFName = aFileStat.getFileName();
+                Palette* pPalette = 0;
                 if( aFName.endsWithIgnoreAsciiCase(".gpl") )
-                {
-                    Palette aPalette( aFileStat.getFileURL(), aFName );
-                    if( aPalette.IsValid() )
-                        maPalettes.push_back( aPalette );
-                }
+                    pPalette = new PaletteGPL( aFileStat.getFileURL(), aFName );
+                else if( aFName.endsWithIgnoreAsciiCase(".soc") )
+                    pPalette = new PaletteSOC( aFileStat.getFileURL(), aFName );
+
+                if( pPalette && pPalette->IsValid() )
+                    maPalettes.push_back( pPalette );
             }
         }
     }
@@ -104,10 +116,8 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
     }
     else
     {
-        Palette& rPal = maPalettes[mnCurrentPalette-1];
-        mnColorCount = rPal.GetPaletteColors().size();
-        rColorSet.Clear();
-        rColorSet.loadPalette(rPal);
+        maPalettes[mnCurrentPalette-1]->LoadColorSet( rColorSet );
+        mnColorCount = rColorSet.GetItemCount();
     }
 }
 
@@ -117,11 +127,11 @@ std::vector<OUString> PaletteManager::GetPaletteList()
 
     aPaletteNames.push_back( STR_DEFAULT_PAL );
 
-    for( std::vector<Palette>::iterator it = maPalettes.begin();
+    for( std::vector<Palette*>::iterator it = maPalettes.begin();
          it != maPalettes.end();
          ++it)
     {
-        aPaletteNames.push_back( it->GetName() );
+        aPaletteNames.push_back( (*it)->GetName() );
     }
 
     aPaletteNames.push_back( STR_DOC_COLORS );
@@ -151,7 +161,7 @@ OUString PaletteManager::GetPaletteName()
     else if( mnCurrentPalette == mnNumOfPalettes - 1 )
         return OUString( STR_DOC_COLORS );
     else
-        return maPalettes[mnCurrentPalette - 1].GetName();
+        return maPalettes[mnCurrentPalette - 1]->GetName();
 }
 
 const Color& PaletteManager::GetLastColor()
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index e338109..2faeb6f 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -106,20 +106,6 @@ void SvxColorValueSet::loadColorVector(const std::vector<Color>& rColorVector, c
     }
 }
 
-
-void SvxColorValueSet::loadPalette(Palette& rPalette)
-{
-    const Palette::ColorList &rColors = rPalette.GetPaletteColors();
-    Clear();
-    int nIx = 1;
-    for(Palette::ColorList::const_iterator it = rColors.begin();
-        it != rColors.end(); ++it)
-    {
-        InsertItem(nIx, it->first, OStringToOUString(it->second, RTL_TEXTENCODING_ASCII_US));
-        ++nIx;
-    }
-}
-
 Size SvxColorValueSet::layoutAllVisible(sal_uInt32 nEntryCount)
 {
     if(!nEntryCount)
commit 04cd9df2203acc1396354646539e7cd08169fbbc
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Thu Jul 24 12:20:21 2014 +0200

    Add SvxLineColorToolBoxControl functionality to SvxColorToolBoxControl
    
    This is the first step in merging SvxLineColorToolBoxControl into
    SvxColorToolBoxControl.
    
    Change-Id: I6a725fef5f9a08524d509b70de15c7a0202e7ed6

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 01a0ebb..591c51a 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1026,8 +1026,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     SfxPopupWindow( nSlotId, rFrame, pParentWindow,
                     "palette_popup_window", "svx/ui/colorwindow.ui",
                     WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
-    maWindowSize( 250, 350 ),
     theSlotId( nSlotId ),
+    maWindowSize( 250, 350 ),
     maCommand( rCommand ),
     mrPaletteManager( rPaletteManager )
 
@@ -2221,6 +2221,11 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
         case SID_EXTRUSION_3D_COLOR:
             addStatusListener( OUString( ".uno:Extrusion3DColor"));
             break;
+
+        case SID_ATTR_LINE_COLOR:
+            addStatusListener( OUString( ".uno:XLineColor" ));
+            mPaletteManager.SetLastColor( COL_BLACK );
+            break;
     }
 
     pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
@@ -2264,6 +2269,10 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
         case SID_EXTRUSION_3D_COLOR:
             pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR ) );
             break;
+
+        case SID_ATTR_LINE_COLOR:
+            pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
+            break;
     }
 
     pColorWin->StartPopupMode( &GetToolBox(),
@@ -2335,6 +2344,11 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
             aCommand    = ".uno:Extrusion3DColor";
             aParamName  = "Extrusion3DColor";
             break;
+
+        case SID_ATTR_LINE_COLOR:
+            aCommand    = ".uno:XLineColor";
+            aParamName  = "XLineColor";
+            break;
     }
 
     Sequence< PropertyValue > aArgs( 1 );
commit 0e2891031a3d628211193466097136296932c513
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Mon Jul 21 16:34:30 2014 +0200

    Convert SvxColorWindow_Impl to Widget Layout
    
    Change-Id: I8c830de56892fd8eb1c14add25f65c25046d47fd

diff --git a/include/sfx2/tbxctrl.hxx b/include/sfx2/tbxctrl.hxx
index 2c7d81a..a5f78a1 100644
--- a/include/sfx2/tbxctrl.hxx
+++ b/include/sfx2/tbxctrl.hxx
@@ -148,6 +148,12 @@ public:
                             SfxPopupWindow( sal_uInt16 nId,
                                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
                                             Window* pParentWindow,
+                                            const OString& rID,
+                                            const OUString& rUIXMLDescription,
+                                            WinBits nBits );
+                            SfxPopupWindow( sal_uInt16 nId,
+                                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
+                                            Window* pParentWindow,
                                             const ResId &rId );
                             virtual ~SfxPopupWindow();
 
diff --git a/include/vcl/floatwin.hxx b/include/vcl/floatwin.hxx
index 45aefab..507ce0d 100644
--- a/include/vcl/floatwin.hxx
+++ b/include/vcl/floatwin.hxx
@@ -21,8 +21,11 @@
 #define INCLUDED_VCL_FLOATWIN_HXX
 
 #include <tools/solar.h>
+#include <vcl/builder.hxx>
 #include <vcl/dllapi.h>
 #include <vcl/syswin.hxx>
+#include <vcl/window.hxx>
+#include <vcl/layout.hxx>
 
 class ToolBox;
 
@@ -70,7 +73,9 @@ enum HitTest
 
 // - FloatingWindow -
 
-class VCL_DLLPUBLIC FloatingWindow : public SystemWindow
+class VCL_DLLPUBLIC FloatingWindow
+    : public SystemWindow
+    , public VclBuilderContainer
 {
     class   ImplData;
 private:
@@ -120,6 +125,7 @@ public:
 
 public:
     explicit        FloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
+    explicit        FloatingWindow( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WinBits nStyle = WB_STDFLOATWIN );
     explicit        FloatingWindow( Window* pParent, const ResId& );
     virtual         ~FloatingWindow();
 
@@ -149,6 +155,11 @@ public:
     bool            GrabsFocus() const { return mbGrabFocus; }
 
     static Point    CalcFloatingPosition( Window* pWindow, const Rectangle& rRect, sal_uLong nFlags, sal_uInt16& rArrangeIndex );
+
+    virtual void    SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) SAL_OVERRIDE;
+    virtual void    SetPosPixel(const Point& rNewPos) SAL_OVERRIDE;
+    virtual void    SetSizePixel(const Size& rNewSize) SAL_OVERRIDE;
+    virtual Size    GetOptimalSize() const SAL_OVERRIDE;
 };
 
 #endif // INCLUDED_VCL_FLOATWIN_HXX
diff --git a/sfx2/source/toolbox/tbxitem.cxx b/sfx2/source/toolbox/tbxitem.cxx
index d4152af..a5971f5 100644
--- a/sfx2/source/toolbox/tbxitem.cxx
+++ b/sfx2/source/toolbox/tbxitem.cxx
@@ -1181,6 +1181,26 @@ SfxPopupWindow::SfxPopupWindow(
         ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
 }
 
+
+SfxPopupWindow::SfxPopupWindow(
+    sal_uInt16 nId,
+    const Reference< XFrame >& rFrame,
+    Window* pParentWindow,
+    const OString& rID,
+    const OUString& rUIXMLDescription,
+    WinBits nBits ) :
+    FloatingWindow( pParentWindow, rID, rUIXMLDescription, nBits )
+    , m_bFloating( false )
+    , m_bCascading( false )
+    , m_nId( nId )
+    , m_xFrame( rFrame )
+    , m_pStatusListener( 0 )
+{
+    Window* pWindow = GetTopMostParentSystemWindow( this );
+    if ( pWindow )
+        ((SystemWindow *)pWindow)->GetTaskPaneList()->AddWindow( this );
+}
+
 SfxPopupWindow::SfxPopupWindow(
     sal_uInt16 nId,
     const Reference< XFrame >& rFrame,
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index 1d9d266..13134a4 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -20,6 +20,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
 	svx/uiconfig/ui/asianphoneticguidedialog \
 	svx/uiconfig/ui/chineseconversiondialog \
 	svx/uiconfig/ui/chinesedictionary \
+	svx/uiconfig/ui/colorwindow \
 	svx/uiconfig/ui/compressgraphicdialog \
 	svx/uiconfig/ui/deleteheaderdialog \
 	svx/uiconfig/ui/deletefooterdialog \
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 086cdef..2f2d318 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -41,16 +41,15 @@ class SvxColorWindow_Impl : public SfxPopupWindow
     using FloatingWindow::StateChanged;
 
 private:
-    const sal_uInt16 theSlotId;
-    SvxColorValueSet aColorSet;
-    ComboBox aPaletteComboBox;
-    PushButton aButtonPicker;
-    OUString  maCommand;
-    Link maSelectedLink;
-
-    const sal_uInt16 nButtonWidth;
-    const sal_uInt16 nButtonHeight;
-    PaletteManager& mrPaletteManager;
+    const sal_uInt16    theSlotId;
+    SvxColorValueSet*   mpColorSet;
+    Size                maWindowSize;
+    ComboBox*           mpPaletteComboBox;
+    PushButton*         mpButtonPicker;
+    OUString            maCommand;
+    Link                maSelectedLink;
+
+    PaletteManager&     mrPaletteManager;
 
     DECL_LINK( SelectHdl, void * );
     DECL_LINK( SelectPaletteHdl, void *);
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index d8210d2..01a0ebb 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1015,28 +1015,33 @@ void SvxFontNameBox_Impl::Select()
 #define WB_NO_DIRECTSELECT      ((WinBits)0x04000000)
 #endif
 
+
 SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
                                           PaletteManager&            rPaletteManager,
                                           sal_uInt16                 nSlotId,
                                           const Reference< XFrame >& rFrame,
                                           const OUString&            rWndTitle,
                                           Window*                    pParentWindow ):
-    SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
+
+    SfxPopupWindow( nSlotId, rFrame, pParentWindow,
+                    "palette_popup_window", "svx/ui/colorwindow.ui",
+                    WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
+    maWindowSize( 250, 350 ),
     theSlotId( nSlotId ),
-    aColorSet   ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
-    aPaletteComboBox( this, WinBits( WB_BORDER | WB_DROPDOWN | WB_AUTOSIZE) ),
-    aButtonPicker( this ),
     maCommand( rCommand ),
-    nButtonWidth ( 28 ),
-    nButtonHeight( 28 ),
     mrPaletteManager( rPaletteManager )
 
 {
+    get(mpPaletteComboBox,  "palette_list_combobox");
+    get(mpButtonPicker,     "color_picker_button");
+    get(mpColorSet,         "colorset");
+
+    mpColorSet->SetStyle( WinBits(WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) );
     if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
     {
-        aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
-        aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
-        aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
+        mpColorSet->SetStyle( mpColorSet->GetStyle() | WB_NONEFIELD );
+        mpColorSet->SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
+        mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_BACKGROUND ) );
     }
     else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId )
     {
@@ -1049,45 +1054,43 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
         SfxItemState eState = aQueryStatus.QueryState( pDummy );
         if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
         {
-            aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
-            aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
-            aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
+            mpColorSet->SetStyle( mpColorSet->GetStyle() | WB_NONEFIELD );
+            mpColorSet->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
+            mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_TEXTCOLOR ) );
         }
     }
     else if ( SID_FRAME_LINECOLOR == theSlotId )
     {
-        aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
+        mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_FRAME_COLOR ) );
     }
     else
     {
-        aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
+        mpColorSet->SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
     }
 
-    aPaletteComboBox.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectPaletteHdl ) );
-    aPaletteComboBox.AdaptDropDownLineCountToMaximum();
-    aPaletteComboBox.Show();
+    mpPaletteComboBox->SetStyle( mpPaletteComboBox->GetStyle() | WB_BORDER | WB_AUTOSIZE );
+    mpPaletteComboBox->SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectPaletteHdl ) );
+    mpPaletteComboBox->AdaptDropDownLineCountToMaximum();
     std::vector<OUString> aPaletteList = mrPaletteManager.GetPaletteList();
+    mpPaletteComboBox->SetText( aPaletteList[ mrPaletteManager.GetPalette() ] );
     for( std::vector<OUString>::iterator it = aPaletteList.begin(); it != aPaletteList.end(); ++it )
     {
-        aPaletteComboBox.InsertEntry( *it );
+        mpPaletteComboBox->InsertEntry( *it );
     }
-    aPaletteComboBox.SetText( aPaletteList[ mrPaletteManager.GetPalette() ] );
 
-    aButtonPicker.SetText("P");
-    aButtonPicker.SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
-    aButtonPicker.Show();
+    mpButtonPicker->SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
 
-    aColorSet.Show();
-
-    aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
+    mpColorSet->SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
     SetHelpId( HID_POPUP_COLOR );
-    aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
+    mpColorSet->SetHelpId( HID_POPUP_COLOR_CTRL );
     SetText( rWndTitle );
-
     AddStatusListener( OUString( ".uno:ColorTableState" ));
     AddStatusListener( maCommand );
 
-    mrPaletteManager.ReloadColorSet(aColorSet);
+    mrPaletteManager.ReloadColorSet(*mpColorSet);
+    mpPaletteComboBox->Show();
+    mpButtonPicker->Show();
+    mpColorSet->Show();
 }
 
 SvxColorWindow_Impl::~SvxColorWindow_Impl()
@@ -1096,7 +1099,7 @@ SvxColorWindow_Impl::~SvxColorWindow_Impl()
 
 void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
 {
-    aColorSet.KeyInput(rKEvt);
+    mpColorSet->KeyInput(rKEvt);
 }
 
 SfxPopupWindow* SvxColorWindow_Impl::Clone() const
@@ -1106,20 +1109,20 @@ SfxPopupWindow* SvxColorWindow_Impl::Clone() const
 
 IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
 {
-    sal_uInt16 nItemId = aColorSet.GetSelectItemId();
+    sal_uInt16 nItemId = mpColorSet->GetSelectItemId();
     Color aColor;
     if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId  || SID_BACKGROUND_COLOR == theSlotId ) )
         aColor = COL_TRANSPARENT;
     else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2  == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) )
         aColor = COL_AUTO;
     else
-        aColor = aColorSet.GetItemColor( nItemId );
+        aColor = mpColorSet->GetItemColor( nItemId );
 
     SvxColorItem aColorItem( aColor, theSlotId );
     /*  #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
         This instance may be deleted in the meantime (i.e. when a dialog is opened
         while in Dispatch()), accessing members will crash in this case. */
-    aColorSet.SetNoSelection();
+    mpColorSet->SetNoSelection();
 
     if ( IsInPopupMode() )
         EndPopupMode();
@@ -1143,10 +1146,10 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
 
 IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
 {
-    OUString sSrchTxt = aPaletteComboBox.GetText();
-    sal_Int32 nPos = aPaletteComboBox.GetEntryPos( sSrchTxt );
+    OUString sSrchTxt = mpPaletteComboBox->GetText();
+    sal_Int32 nPos = mpPaletteComboBox->GetEntryPos( sSrchTxt );
     mrPaletteManager.SetPalette( nPos );
-    mrPaletteManager.ReloadColorSet(aColorSet);
+    mrPaletteManager.ReloadColorSet(*mpColorSet);
     Resize();
     return 0;
 }
@@ -1159,21 +1162,13 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
 
 void SvxColorWindow_Impl::Resize()
 {
-    const Size aSize(this->GetOutputSizePixel());
-    aColorSet.SetPosSizePixel( Point(2, nButtonHeight + 2), Size(aSize.Width()  - 4, aSize.Height() - 6 - nButtonHeight) );
-
-    const Size aNewSize(aColorSet.layoutAllVisible(mrPaletteManager.GetColorCount()));
-    aColorSet.SetOutputSizePixel(aNewSize);
-
-    SetOutputSizePixel(Size(aNewSize.Width() + 4, aNewSize.Height() + 4 + nButtonHeight));
-
-    aPaletteComboBox.SetPosSizePixel(Point(2, 0), Size(aNewSize.Width() - nButtonWidth, nButtonHeight));
-    aButtonPicker.SetPosSizePixel(Point(aNewSize.Width() + 4 - nButtonWidth, 0), Size(nButtonWidth, nButtonHeight));
+    mpColorSet->layoutAllVisible(mrPaletteManager.GetColorCount());
+    SetOutputSizePixel(maWindowSize);
 }
 
 void SvxColorWindow_Impl::StartSelection()
 {
-    aColorSet.StartSelection();
+    mpColorSet->StartSelection();
 }
 
 bool SvxColorWindow_Impl::Close()
@@ -1187,11 +1182,11 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
     {
         if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
         {
-            mrPaletteManager.ReloadColorSet(aColorSet);
+            mrPaletteManager.ReloadColorSet(*mpColorSet);
         }
         else if ( SFX_ITEM_DEFAULT <= eState )
         {
-            aColorSet.SetNoSelection();
+            mpColorSet->SetNoSelection();
 
             Color aColor;
             if ( pState->ISA( SvxColorItem ) )
@@ -1199,16 +1194,16 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
             else if ( pState->ISA( XLineColorItem ) )
                 aColor = ((const XLineColorItem*)pState)->GetColorValue();
 
-            for ( size_t i = 1; i <= aColorSet.GetItemCount(); ++i )
+            for ( size_t i = 1; i <= mpColorSet->GetItemCount(); ++i )
             {
-                if ( aColor == aColorSet.GetItemColor(i) )
+                if ( aColor == mpColorSet->GetItemColor(i) )
                 {
-                    aColorSet.SelectItem(i);
+                    mpColorSet->SelectItem(i);
                     return;
                 }
             }
             if ( aColor == COL_AUTO || aColor == COL_TRANSPARENT )
-                aColorSet.SelectItem(0);
+                mpColorSet->SelectItem(0);
         }
     }
 }
diff --git a/svx/uiconfig/ui/colorwindow.ui b/svx/uiconfig/ui/colorwindow.ui
new file mode 100644
index 0000000..54b8f49
--- /dev/null
+++ b/svx/uiconfig/ui/colorwindow.ui
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <object class="GtkWindow" id="palette_popup_window">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkBox" id="box2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkComboBox" id="palette_list_combobox">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="has_entry">True</property>
+                <child internal-child="entry">
+                  <object class="GtkEntry" id="combobox-entry">
+                    <property name="can_focus">False</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="color_picker_button">
+                <property name="label">Palette</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="svxlo-SvxColorValueSet" id="colorset">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index a77c38f..178843f 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -152,6 +152,13 @@ FloatingWindow::FloatingWindow( Window* pParent, WinBits nStyle ) :
     ImplInit( pParent, nStyle );
 }
 
+FloatingWindow::FloatingWindow( Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WinBits nStyle ) :
+    SystemWindow( WINDOW_FLOATINGWINDOW )
+{
+    ImplInit( pParent, nStyle );
+    m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID);
+}
+
 FloatingWindow::FloatingWindow( Window* pParent, const ResId& rResId ) :
     SystemWindow( WINDOW_FLOATINGWINDOW )
 {
@@ -815,4 +822,33 @@ void FloatingWindow::AddPopupModeWindow( Window* pWindow )
     mpFirstPopupModeWin = pWindow;
 }
 
+
+Size FloatingWindow::GetOptimalSize() const
+{
+    if (isLayoutEnabled(this))
+        return VclContainer::getLayoutRequisition(*GetWindow(WINDOW_FIRSTCHILD));
+    return getLegacyBestSizeForChildren(*this);
+}
+
+void FloatingWindow::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
+{
+    Window::SetPosSizePixel(rAllocPos, rAllocation);
+    if (isLayoutEnabled(this))
+        VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
+}
+
+void FloatingWindow::SetSizePixel(const Size& rAllocation)
+{
+    Window::SetSizePixel(rAllocation);
+    if (isLayoutEnabled(this))
+        VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
+}
+
+void FloatingWindow::SetPosPixel(const Point& rAllocPos)
+{
+    Window::SetPosPixel(rAllocPos);
+    if (isLayoutEnabled(this))
+        VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), GetOutputSizePixel());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ec8cad53209564c92e2d49cc2fa61cbbb58ed18c
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Fri Jul 11 19:16:13 2014 +0200

    Move palette selection ComboBox to top of popup window
    
    Change-Id: Iff958cc8d2ef301a43db406aa38dd446bb2242a5

diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index fd8eef7..086cdef 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -52,8 +52,6 @@ private:
     const sal_uInt16 nButtonHeight;
     PaletteManager& mrPaletteManager;
 
-    void UpdateGUI();
-
     DECL_LINK( SelectHdl, void * );
     DECL_LINK( SelectPaletteHdl, void *);
     DECL_LINK( OpenPickerClickHdl, void * );
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index f75c049..d8210d2 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -98,7 +98,6 @@
 // don't make more than 15 entries visible at once
 #define MAX_STYLES_ENTRIES          static_cast< sal_uInt16 >( 15 )
 
-static void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet, sal_uInt16 nVertPadding );
 static void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize );
 
 // namespaces
@@ -1075,7 +1074,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     aPaletteComboBox.SetText( aPaletteList[ mrPaletteManager.GetPalette() ] );
 
     aButtonPicker.SetText("P");
-    aButtonPicker.SetSizePixel(Size(nButtonWidth, nButtonHeight));
     aButtonPicker.SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
     aButtonPicker.Show();
 
@@ -1089,26 +1087,7 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     AddStatusListener( OUString( ".uno:ColorTableState" ));
     AddStatusListener( maCommand );
 
-    UpdateGUI();
-}
-
-
-void SvxColorWindow_Impl::UpdateGUI()
-{
     mrPaletteManager.ReloadColorSet(aColorSet);
-
-    const Size aNewSize(aColorSet.layoutAllVisible(mrPaletteManager.GetColorCount()));
-    aColorSet.SetOutputSizePixel(aNewSize);
-    static sal_Int32 nAdd = 4;
-
-    //TODO: Move left/right buttons above the colors
-    SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nButtonHeight));
-
-    aPaletteComboBox.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1));
-
-    aButtonPicker.SetPosPixel(Point(aNewSize.Width() + nAdd - nButtonWidth, aNewSize.Height() + nAdd + 1));
-
-    aPaletteComboBox.SetSizePixel(Size(aNewSize.Width() - nButtonWidth, nButtonHeight));
 }
 
 SvxColorWindow_Impl::~SvxColorWindow_Impl()
@@ -1167,7 +1146,8 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
     OUString sSrchTxt = aPaletteComboBox.GetText();
     sal_Int32 nPos = aPaletteComboBox.GetEntryPos( sSrchTxt );
     mrPaletteManager.SetPalette( nPos );
-    UpdateGUI();
+    mrPaletteManager.ReloadColorSet(aColorSet);
+    Resize();
     return 0;
 }
 
@@ -1179,7 +1159,16 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
 
 void SvxColorWindow_Impl::Resize()
 {
-    lcl_ResizeValueSet( *this, aColorSet, nButtonHeight + 2);
+    const Size aSize(this->GetOutputSizePixel());
+    aColorSet.SetPosSizePixel( Point(2, nButtonHeight + 2), Size(aSize.Width()  - 4, aSize.Height() - 6 - nButtonHeight) );
+
+    const Size aNewSize(aColorSet.layoutAllVisible(mrPaletteManager.GetColorCount()));
+    aColorSet.SetOutputSizePixel(aNewSize);
+
+    SetOutputSizePixel(Size(aNewSize.Width() + 4, aNewSize.Height() + 4 + nButtonHeight));
+
+    aPaletteComboBox.SetPosSizePixel(Point(2, 0), Size(aNewSize.Width() - nButtonWidth, nButtonHeight));
+    aButtonPicker.SetPosSizePixel(Point(aNewSize.Width() + 4 - nButtonWidth, 0), Size(nButtonWidth, nButtonHeight));
 }
 
 void SvxColorWindow_Impl::StartSelection()
@@ -1198,7 +1187,7 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
     {
         if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
         {
-            UpdateGUI();
+            mrPaletteManager.ReloadColorSet(aColorSet);
         }
         else if ( SFX_ITEM_DEFAULT <= eState )
         {
@@ -1436,7 +1425,8 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl)
 
 void SvxFrameWindow_Impl::Resize()
 {
-    lcl_ResizeValueSet( *this, aFrameSet, 0 );
+    const Size aSize(this->GetOutputSizePixel());
+    aFrameSet.SetPosSizePixel(Point(2,2), Size(aSize.Width() - 4, aSize.Height() - 4));
 }
 
 void SvxFrameWindow_Impl::StateChanged(
@@ -2532,14 +2522,6 @@ void SvxSimpleUndoRedoController::StateChanged( sal_uInt16, SfxItemState eState,
 
 
 
-static void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet, sal_uInt16 nVertPadding)
-{
-    Size aSize = rWin.GetOutputSizePixel();
-    aSize.Width()  -= 4;
-    aSize.Height() -= 4 + nVertPadding;
-    rValueSet.SetPosSizePixel( Point(2,2), aSize );
-}
-
 static void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize )
 {
     Size aSize = rValueSet.CalcWindowSizePixel( aItemSize );
commit 1830d50c01fd871ce3a44d9b6cb72a062bc23181
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Thu Jul 10 16:14:29 2014 +0200

    Change SvxColorWindow_Impl to use ComboBox for palette selection
    
    Change-Id: I0fb9b46298f45bbdf9ae9198c145b9ea5e403bbf

diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx
index f7ced03..d31e958 100644
--- a/include/svx/Palette.hxx
+++ b/include/svx/Palette.hxx
@@ -21,6 +21,7 @@
 
 #include <rtl/ustring.hxx>
 #include <tools/color.hxx>
+#include <tools/stream.hxx>
 
 class Palette
 {
@@ -28,17 +29,23 @@ public:
     typedef std::pair<Color, OString> NamedColor;
     typedef std::vector< NamedColor > ColorList;
 private:
-    bool        mbLoaded;
-    OUString    maFname;
-    OString     maName;
+    bool        mbLoadedPalette;
+    bool        mbValidPalette;
+    OUString    maFName;
+    OUString    maFPath;
+    OUString    maName;
     ColorList   maColors;
 
-    void LoadPalette();
+    bool        ReadPaletteHeader(SvFileStream& rFileStream);
+    void        LoadPaletteHeader();
+    void        LoadPalette();
 public:
-    Palette(const OUString &rFname);
+    Palette( const OUString &rFPath, const OUString &rFName );
 
-    const OString&      GetPaletteName();
+    const OUString&     GetName();
     const ColorList&    GetPaletteColors();
+
+    bool                IsValid();
 };
 
 #endif // INCLUDED_SVX_PALETTE_HXX
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index e1d7201..925f67b 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -37,8 +37,10 @@ public:
     PaletteManager();
     void        LoadPalettes();
     void        ReloadColorSet(SvxColorValueSet& rColorSet);
-    void        PrevPalette();
-    void        NextPalette();
+    std::vector<OUString> GetPaletteList();
+    void        SetPalette( sal_Int32 nPos );
+    sal_Int32   GetPalette();
+
     long        GetColorCount();
     OUString    GetPaletteName();
     const Color& GetLastColor();
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index aebb7f0..f84f2d5 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <svx/Palette.hxx>
-#include <tools/stream.hxx>
 
 // finds first token in rStr from index, separated by whitespace
 // returns position of next token in index
@@ -52,13 +51,17 @@ OString lcl_getToken(const OString& rStr, sal_Int32& index)
     return rStr.copy(substart, toklen);
 }
 
-Palette::Palette(const OUString &rFname) :
-    mbLoaded( false ),
-    maFname( rFname ){}
+Palette::Palette( const OUString &rFPath, const OUString &rFName ) :
+    mbLoadedPalette( false ),
+    mbValidPalette( false ),
+    maFName( rFName ),
+    maFPath( rFPath )
+{
+    LoadPaletteHeader();
+}
 
-const OString& Palette::GetPaletteName()
+const OUString& Palette::GetName()
 {
-    LoadPalette();
     return maName;
 }
 
@@ -68,27 +71,52 @@ const Palette::ColorList& Palette::GetPaletteColors()
     return maColors;
 }
 
-void Palette::LoadPalette()
+bool Palette::IsValid()
 {
-    if( mbLoaded ) return;
-
-    mbLoaded = true;
-
-    // TODO add error handling!!!
-    SvFileStream aFile(maFname, STREAM_READ);
+    return mbValidPalette;
+}
 
+bool Palette::ReadPaletteHeader(SvFileStream& rFileStream)
+{
     OString aLine;
+    OString aName;
 
-    aFile.ReadLine(aLine);
-    if( !aLine.startsWith("GIMP Palette") ) return;
-    aFile.ReadLine(aLine);
-    if( aLine.startsWith("Name: ", &maName) )
+    rFileStream.ReadLine(aLine);
+    if( !aLine.startsWith("GIMP Palette") ) return false;
+    rFileStream.ReadLine(aLine);
+    if( aLine.startsWith("Name: ", &aName) )
     {
-        aFile.ReadLine(aLine);
+        maName = OStringToOUString(aName, RTL_TEXTENCODING_ASCII_US);
+        rFileStream.ReadLine(aLine);
         if( aLine.startsWith("Columns: "))
-            aFile.ReadLine(aLine); // we can ignore this
+            rFileStream.ReadLine(aLine); // we can ignore this
+    }
+    else
+    {
+        maName = maFName;
     }
+    return true;
+}
+
+//TODO make this LoadPaletteHeader and set a bool if palette is incorrect
+void Palette::LoadPaletteHeader()
+{
+    SvFileStream aFile(maFPath, STREAM_READ);
+    mbValidPalette = ReadPaletteHeader( aFile );
+}
 
+void Palette::LoadPalette()
+{
+    if( mbLoadedPalette ) return;
+    mbLoadedPalette = true;
+
+    // TODO add error handling!!!
+    SvFileStream aFile(maFPath, STREAM_READ);
+    mbValidPalette = ReadPaletteHeader( aFile );
+
+    if( !mbValidPalette ) return;
+
+    OString aLine;
     do {
         if (aLine[0] != '#' && aLine[0] != '\n')
         {
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index e9933d4..95c351d 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -25,6 +25,10 @@
 #include <svx/dialogs.hrc>
 #include <svtools/colrdlg.hxx>
 
+#define STR_DEFAULT_PAL         "Default palette"
+#define STR_DOC_COLORS          "Document colors"
+#define STR_DOC_COLOR_PREFIX    "Document Color "
+
 PaletteManager::PaletteManager() :
     mnNumOfPalettes(2),
     mnCurrentPalette(0),
@@ -42,7 +46,9 @@ void PaletteManager::LoadPalettes()
     osl::Directory aDir(aPalPath);
     maPalettes.clear();
     osl::DirectoryItem aDirItem;
-    osl::FileStatus aFileStat(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+    osl::FileStatus aFileStat( osl_FileStatus_Mask_FileName |
+                               osl_FileStatus_Mask_FileURL  |
+                               osl_FileStatus_Mask_Type     );
     if( aDir.open() == osl::FileBase::E_None )
     {
         while( aDir.getNextItem(aDirItem) == osl::FileBase::E_None )
@@ -50,11 +56,12 @@ void PaletteManager::LoadPalettes()
             aDirItem.getFileStatus(aFileStat);
             if(aFileStat.isRegular() || aFileStat.isLink())
             {
-                OUString aPath = aFileStat.getFileURL();
-                if(aPath.getLength() > 4 &&
-                    aPath.copy(aPath.getLength()-4).toAsciiLowerCase() == ".gpl")
+                OUString aFName = aFileStat.getFileName();
+                if( aFName.endsWithIgnoreAsciiCase(".gpl") )
                 {
-                    maPalettes.push_back(Palette(aPath));
+                    Palette aPalette( aFileStat.getFileURL(), aFName );
+                    if( aPalette.IsValid() )
+                        maPalettes.push_back( aPalette );
                 }
             }
         }
@@ -93,7 +100,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
         std::vector<Color> aColors = pDocSh->GetDocColors();
         mnColorCount = aColors.size();
         rColorSet.Clear();
-        rColorSet.loadColorVector(aColors, "Document Color ");
+        rColorSet.loadColorVector(aColors, STR_DOC_COLOR_PREFIX );
     }
     else
     {
@@ -104,14 +111,32 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
     }
 }
 
-void PaletteManager::PrevPalette()
+std::vector<OUString> PaletteManager::GetPaletteList()
+{
+    std::vector<OUString> aPaletteNames;
+
+    aPaletteNames.push_back( STR_DEFAULT_PAL );
+
+    for( std::vector<Palette>::iterator it = maPalettes.begin();
+         it != maPalettes.end();
+         ++it)
+    {
+        aPaletteNames.push_back( it->GetName() );
+    }
+
+    aPaletteNames.push_back( STR_DOC_COLORS );
+
+    return aPaletteNames;
+}
+
+void PaletteManager::SetPalette( sal_Int32 nPos )
 {
-    mnCurrentPalette = mnCurrentPalette == 0 ? mnNumOfPalettes - 1 : mnCurrentPalette - 1;
+    mnCurrentPalette = nPos;
 }
 
-void PaletteManager::NextPalette()
+sal_Int32 PaletteManager::GetPalette()
 {
-    mnCurrentPalette = mnCurrentPalette == mnNumOfPalettes - 1 ? 0 : mnCurrentPalette + 1;
+    return mnCurrentPalette;
 }
 
 long PaletteManager::GetColorCount()
@@ -122,11 +147,11 @@ long PaletteManager::GetColorCount()
 OUString PaletteManager::GetPaletteName()
 {
     if( mnCurrentPalette == 0 )
-        return OUString("Default palette");
+        return OUString( STR_DEFAULT_PAL );
     else if( mnCurrentPalette == mnNumOfPalettes - 1 )
-        return OUString("Document colors");
+        return OUString( STR_DOC_COLORS );
     else
-        return OStringToOUString(maPalettes[mnCurrentPalette - 1].GetPaletteName(), RTL_TEXTENCODING_ASCII_US);
+        return maPalettes[mnCurrentPalette - 1].GetName();
 }
 
 const Color& PaletteManager::GetLastColor()
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index fe8fe8d..fd8eef7 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -30,6 +30,7 @@
 #include <com/sun/star/frame/XFrame.hpp>
 #include <svx/SvxColorValueSet.hxx>
 #include <svx/PaletteManager.hxx>
+#include <vcl/combobox.hxx>
 
 
 // class SvxColorWindow_Impl --------------------------------------------------
@@ -42,22 +43,19 @@ class SvxColorWindow_Impl : public SfxPopupWindow
 private:
     const sal_uInt16 theSlotId;
     SvxColorValueSet aColorSet;
-    PushButton aButtonLeft;
-    PushButton aButtonRight;
+    ComboBox aPaletteComboBox;
     PushButton aButtonPicker;
-    FixedText  aPaletteName;
     OUString  maCommand;
     Link maSelectedLink;
 
-    const sal_uInt16 nNavButtonWidth;
-    const sal_uInt16 nNavButtonHeight;
+    const sal_uInt16 nButtonWidth;
+    const sal_uInt16 nButtonHeight;
     PaletteManager& mrPaletteManager;
 
     void UpdateGUI();
 
     DECL_LINK( SelectHdl, void * );
-    DECL_LINK( StepLeftClickHdl, void * );
-    DECL_LINK( StepRightClickHdl, void * );
+    DECL_LINK( SelectPaletteHdl, void *);
     DECL_LINK( OpenPickerClickHdl, void * );
 
 protected:
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index b3360a5..f75c049 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1025,13 +1025,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
     theSlotId( nSlotId ),
     aColorSet   ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
-    aButtonLeft ( this ),
-    aButtonRight( this ),
+    aPaletteComboBox( this, WinBits( WB_BORDER | WB_DROPDOWN | WB_AUTOSIZE) ),
     aButtonPicker( this ),
-    aPaletteName( this ),
     maCommand( rCommand ),
-    nNavButtonWidth ( 20 ),
-    nNavButtonHeight( 20 ),
+    nButtonWidth ( 28 ),
+    nButtonHeight( 28 ),
     mrPaletteManager( rPaletteManager )
 
 {
@@ -1066,22 +1064,21 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
         aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
     }
 
-    aButtonLeft.SetText("<");
-    aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
-    aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) );
-    aButtonLeft.Show();
-
-    aButtonRight.SetText(">");
-    aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
-    aButtonRight.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepRightClickHdl ) );
-    aButtonRight.Show();
+    aPaletteComboBox.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectPaletteHdl ) );
+    aPaletteComboBox.AdaptDropDownLineCountToMaximum();
+    aPaletteComboBox.Show();
+    std::vector<OUString> aPaletteList = mrPaletteManager.GetPaletteList();
+    for( std::vector<OUString>::iterator it = aPaletteList.begin(); it != aPaletteList.end(); ++it )
+    {
+        aPaletteComboBox.InsertEntry( *it );
+    }
+    aPaletteComboBox.SetText( aPaletteList[ mrPaletteManager.GetPalette() ] );
 
     aButtonPicker.SetText("P");
-    aButtonPicker.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
+    aButtonPicker.SetSizePixel(Size(nButtonWidth, nButtonHeight));
     aButtonPicker.SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
     aButtonPicker.Show();
 
-    aPaletteName.SetSizePixel(Size(150, nNavButtonHeight));
     aColorSet.Show();
 
     aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
@@ -1089,8 +1086,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
     SetText( rWndTitle );
 
-    aPaletteName.Show();
-
     AddStatusListener( OUString( ".uno:ColorTableState" ));
     AddStatusListener( maCommand );
 
@@ -1107,16 +1102,13 @@ void SvxColorWindow_Impl::UpdateGUI()
     static sal_Int32 nAdd = 4;
 
     //TODO: Move left/right buttons above the colors
-    SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nNavButtonHeight));
-
-    aButtonLeft.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1));
+    SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nButtonHeight));
 
-    aButtonRight.SetPosPixel(Point(aNewSize.Width() + nAdd - nNavButtonWidth, aNewSize.Height() + nAdd + 1));
+    aPaletteComboBox.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1));
 
-    aButtonPicker.SetPosPixel(Point(aNewSize.Width() + nAdd - 2 * nNavButtonWidth, aNewSize.Height() + nAdd + 1));
+    aButtonPicker.SetPosPixel(Point(aNewSize.Width() + nAdd - nButtonWidth, aNewSize.Height() + nAdd + 1));
 
-    aPaletteName.SetPosPixel(Point(nNavButtonWidth, aNewSize.Height() + nAdd + 1));
-    aPaletteName.SetText(mrPaletteManager.GetPaletteName());
+    aPaletteComboBox.SetSizePixel(Size(aNewSize.Width() - nButtonWidth, nButtonHeight));
 }
 
 SvxColorWindow_Impl::~SvxColorWindow_Impl()
@@ -1170,16 +1162,11 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
     return 0;
 }
 
-IMPL_LINK_NOARG(SvxColorWindow_Impl, StepLeftClickHdl)
-{
-    mrPaletteManager.PrevPalette();
-    UpdateGUI();
-    return 0;
-}
-
-IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl)
+IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectPaletteHdl)
 {
-    mrPaletteManager.NextPalette();
+    OUString sSrchTxt = aPaletteComboBox.GetText();
+    sal_Int32 nPos = aPaletteComboBox.GetEntryPos( sSrchTxt );
+    mrPaletteManager.SetPalette( nPos );
     UpdateGUI();
     return 0;
 }
@@ -1192,7 +1179,7 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
 
 void SvxColorWindow_Impl::Resize()
 {
-    lcl_ResizeValueSet( *this, aColorSet, nNavButtonHeight + 2);
+    lcl_ResizeValueSet( *this, aColorSet, nButtonHeight + 2);
 }
 
 void SvxColorWindow_Impl::StartSelection()
commit b44ab86f66c4d405984b676760f28f35f0bf9cf7
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Tue Jul 8 22:38:42 2014 +0200

    Reduce ColorValueSetMaximumRowCount to 20 from 40
    
    Change-Id: Id37698c20e5ded3034b62b753d25964541643fd7

diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index d93ffe9..67b338d 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -547,7 +547,7 @@ ImplStyleData::ImplStyleData() :
     maEdgeBlendingBottomRightColor = RGB_COLORDATA(0x40, 0x40, 0x40);
     mnListBoxMaximumLineCount = 25;
     mnColorValueSetColumnCount = 12;
-    mnColorValueSetMaximumRowCount = 40;
+    mnColorValueSetMaximumRowCount = 20;
     maListBoxPreviewDefaultLogicSize = Size(15, 7);
     maListBoxPreviewDefaultPixelSize = Size(0, 0); // on-demand calculated in GetListBoxPreviewDefaultPixelSize()
     mnListBoxPreviewDefaultLineWidth = 1;
commit ba8b80f996bd2022a1ff072b93df823bbbae73cc
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Tue Jul 8 19:08:38 2014 +0200

    Add color picker to color palette
    
    Change-Id: I651f485598ee57af815780e234031f101b63fa24

diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
index a6b2dfa..e1d7201 100644
--- a/include/svx/PaletteManager.hxx
+++ b/include/svx/PaletteManager.hxx
@@ -21,6 +21,7 @@
 
 #include <svx/SvxColorValueSet.hxx>
 #include <rtl/ustring.hxx>
+#include <svx/tbxcolorupdate.hxx>
 
 class PaletteManager
 {
@@ -28,7 +29,9 @@ class PaletteManager
     sal_uInt16  mnCurrentPalette;
 
     long        mnColorCount;
+    svx::ToolboxButtonColorUpdater* mpBtnUpdater;
 
+    Color       mLastColor;
     std::vector<Palette> maPalettes;
 public:
     PaletteManager();
@@ -38,6 +41,10 @@ public:
     void        NextPalette();
     long        GetColorCount();
     OUString    GetPaletteName();
+    const Color& GetLastColor();
+    void        SetLastColor(const Color& rLastColor);
+    void        SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater);
+    void        PopupColorPicker();
 };
 
 #endif // INCLUDED_SVX_PALETTEMANAGER_HXX
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 1e9c4b1..762f33d 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -221,7 +221,6 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
     using SfxToolBoxControl::StateChanged;
 
     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
-    Color                               mLastColor;
     PaletteManager                      mPaletteManager;
     DECL_LINK( SelectedHdl, Color* );
 public:
@@ -242,7 +241,6 @@ public:
 class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
 {
     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
-    Color                               mLastColor;
     PaletteManager                      mPaletteManager;
     DECL_LINK( SelectedHdl, Color* );
 public:
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 88916ee..e9933d4 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -23,11 +23,13 @@
 #include <sfx2/objsh.hxx>
 #include "svx/drawitem.hxx"
 #include <svx/dialogs.hrc>
+#include <svtools/colrdlg.hxx>
 
 PaletteManager::PaletteManager() :
     mnNumOfPalettes(2),
     mnCurrentPalette(0),
-    mnColorCount(0)
+    mnColorCount(0),
+    mLastColor(COL_AUTO)
 {
     LoadPalettes();
     mnNumOfPalettes += maPalettes.size();
@@ -127,4 +129,31 @@ OUString PaletteManager::GetPaletteName()
         return OStringToOUString(maPalettes[mnCurrentPalette - 1].GetPaletteName(), RTL_TEXTENCODING_ASCII_US);
 }
 
+const Color& PaletteManager::GetLastColor()
+{
+    return mLastColor;
+}
+
+void PaletteManager::SetLastColor(const Color& rLastColor)
+{
+    mLastColor = rLastColor;
+}
+
+void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
+{
+    mpBtnUpdater = pBtnUpdater;
+}
+
+void PaletteManager::PopupColorPicker()
+{
+    SvColorDialog aColorDlg( 0 );
+    aColorDlg.SetColor ( mLastColor );
+    aColorDlg.SetMode( svtools::ColorPickerMode_MODIFY );
+    if( aColorDlg.Execute() == RET_OK )
+    {
+        mpBtnUpdater->Update( aColorDlg.GetColor() );
+        mLastColor = aColorDlg.GetColor();
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 3e19796..fe8fe8d 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -44,6 +44,7 @@ private:
     SvxColorValueSet aColorSet;
     PushButton aButtonLeft;
     PushButton aButtonRight;
+    PushButton aButtonPicker;
     FixedText  aPaletteName;
     OUString  maCommand;
     Link maSelectedLink;
@@ -57,6 +58,7 @@ private:
     DECL_LINK( SelectHdl, void * );
     DECL_LINK( StepLeftClickHdl, void * );
     DECL_LINK( StepRightClickHdl, void * );
+    DECL_LINK( OpenPickerClickHdl, void * );
 
 protected:
     virtual void    Resize() SAL_OVERRIDE;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e41370c..b3360a5 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1027,6 +1027,7 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     aColorSet   ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
     aButtonLeft ( this ),
     aButtonRight( this ),
+    aButtonPicker( this ),
     aPaletteName( this ),
     maCommand( rCommand ),
     nNavButtonWidth ( 20 ),
@@ -1066,18 +1067,27 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     }
 
     aButtonLeft.SetText("<");
+    aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
     aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) );
     aButtonLeft.Show();
 
     aButtonRight.SetText(">");
+    aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
     aButtonRight.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepRightClickHdl ) );
     aButtonRight.Show();
 
+    aButtonPicker.SetText("P");
+    aButtonPicker.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
+    aButtonPicker.SetClickHdl( LINK( this, SvxColorWindow_Impl, OpenPickerClickHdl ) );
+    aButtonPicker.Show();
+
+    aPaletteName.SetSizePixel(Size(150, nNavButtonHeight));
+    aColorSet.Show();
+
     aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
     SetHelpId( HID_POPUP_COLOR );
     aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
     SetText( rWndTitle );
-    aColorSet.Show();
 
     aPaletteName.Show();
 
@@ -1099,13 +1109,12 @@ void SvxColorWindow_Impl::UpdateGUI()
     //TODO: Move left/right buttons above the colors
     SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd + nNavButtonHeight));
 
-    aButtonLeft.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
     aButtonLeft.SetPosPixel(Point(0, aNewSize.Height() + nAdd + 1));
 
-    aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
     aButtonRight.SetPosPixel(Point(aNewSize.Width() + nAdd - nNavButtonWidth, aNewSize.Height() + nAdd + 1));
 
-    aPaletteName.SetSizePixel(Size(150, nNavButtonHeight));
+    aButtonPicker.SetPosPixel(Point(aNewSize.Width() + nAdd - 2 * nNavButtonWidth, aNewSize.Height() + nAdd + 1));
+
     aPaletteName.SetPosPixel(Point(nNavButtonWidth, aNewSize.Height() + nAdd + 1));
     aPaletteName.SetText(mrPaletteManager.GetPaletteName());
 }
@@ -1175,6 +1184,12 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl)
     return 0;
 }
 
+IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
+{
+    mrPaletteManager.PopupColorPicker();
+    return 0;
+}
+
 void SvxColorWindow_Impl::Resize()
 {
     lcl_ResizeValueSet( *this, aColorSet, nNavButtonHeight + 2);
@@ -2199,8 +2214,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
     sal_uInt16 nSlotId,
     sal_uInt16 nId,
     ToolBox& rTbx ) :
-    SfxToolBoxControl( nSlotId, nId, rTbx ),
-    mLastColor( COL_AUTO )
+    SfxToolBoxControl( nSlotId, nId, rTbx )
 {
     rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
 
@@ -2209,27 +2223,27 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
     {
         case SID_ATTR_CHAR_COLOR:
             addStatusListener( OUString( ".uno:Color" ));
-            mLastColor = COL_RED;
+            mPaletteManager.SetLastColor( COL_RED );
             break;
 
         case SID_ATTR_CHAR_COLOR2:
             addStatusListener( OUString( ".uno:CharColorExt" ));
-            mLastColor = COL_RED;
+            mPaletteManager.SetLastColor( COL_RED );
             break;
 
         case SID_BACKGROUND_COLOR:
             addStatusListener( OUString( ".uno:BackgroundColor" ));
-            mLastColor = COL_YELLOW;
+            mPaletteManager.SetLastColor( COL_YELLOW );
             break;
 
         case SID_ATTR_CHAR_COLOR_BACKGROUND:
             addStatusListener( OUString( ".uno:CharBackgroundExt" ));
-            mLastColor = COL_YELLOW;
+            mPaletteManager.SetLastColor( COL_YELLOW );
             break;
 
         case SID_FRAME_LINECOLOR:
             addStatusListener( OUString( ".uno:FrameLineColor" ));
-            mLastColor = COL_BLUE;
+            mPaletteManager.SetLastColor( COL_BLUE );
             break;
 
         case SID_EXTRUSION_3D_COLOR:
@@ -2238,6 +2252,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
     }
 
     pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
+    mPaletteManager.SetBtnUpdater( pBtnUpdater.get() );
 }
 
 SvxColorToolBoxControl::~SvxColorToolBoxControl()
@@ -2290,7 +2305,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
 IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, Color*, pColor)
 {
     pBtnUpdater->Update( *pColor );
-    mLastColor = *pColor;
+    mPaletteManager.SetLastColor( *pColor );
     return 0;
 }
 
@@ -2352,21 +2367,24 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
 
     Sequence< PropertyValue > aArgs( 1 );
     aArgs[0].Name  = aParamName;
-    aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() ));
+    aArgs[0].Value = makeAny( (sal_uInt32)( mPaletteManager.GetLastColor().GetColor() ));
     Dispatch( aCommand, aArgs );
 }
 
+// class SvxLineColorToolBoxControl ----------------------------------------
+
 SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
     sal_uInt16 nSlotId,
     sal_uInt16 nId,
     ToolBox& rTbx ) :
 
-    SfxToolBoxControl( nSlotId, nId, rTbx ),
-    mLastColor( COL_BLACK )
+    SfxToolBoxControl( nSlotId, nId, rTbx )
 {
     rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
     addStatusListener( OUString( ".uno:XLineColor" ) );
     pBtnUpdater.reset( new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) );
+    mPaletteManager.SetLastColor( COL_BLACK );
+    mPaletteManager.SetBtnUpdater( pBtnUpdater.get() );
 }
 
 SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
@@ -2400,7 +2418,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow()
 IMPL_LINK(SvxLineColorToolBoxControl, SelectedHdl, Color*, pColor)
 {
     pBtnUpdater->Update( *pColor );
-    mLastColor = *pColor;
+    mPaletteManager.SetLastColor( *pColor );
     return 0;
 }
 
@@ -2417,7 +2435,7 @@ void SvxLineColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
 {
     Sequence< PropertyValue > aArgs( 1 );
     aArgs[0].Name  = "XLineColor";
-    aArgs[0].Value = makeAny( (sal_uInt32)( mLastColor.GetColor() ));
+    aArgs[0].Value = makeAny( (sal_uInt32)( mPaletteManager.GetLastColor().GetColor() ));
     Dispatch( OUString( ".uno:XLineColor" ), aArgs );
 }
 
commit 6ad7cd500108adb452ada83ecf59dbd4a4f58ff5
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Mon Jul 7 13:36:19 2014 +0200

    Make SvColorDialog allocate on stack
    
    Change-Id: Ia47feda85bcde1ed44a2fbbcd28bbb5be0abafc8

diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 9a1218a..8caa396 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -803,15 +803,15 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickModifyHdl_Impl)
 
 IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl)
 {
-    SvColorDialog* pColorDlg = new SvColorDialog( GetParentDialog() );
+    SvColorDialog pColorDlg( GetParentDialog() );
 
-    pColorDlg->SetColor (aCurrentColor);
-    pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY );
+    pColorDlg.SetColor (aCurrentColor);
+    pColorDlg.SetMode( svtools::ColorPickerMode_MODIFY );
 
-    if( pColorDlg->Execute() == RET_OK )
+    if( pColorDlg.Execute() == RET_OK )
     {
         sal_uInt16 nK = 0;
-        Color aPreviewColor = pColorDlg->GetColor();
+        Color aPreviewColor = pColorDlg.GetColor();
         aCurrentColor = aPreviewColor;
         if (eCM != CM_RGB)
         {
@@ -836,7 +836,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl)
 
         m_pCtlPreviewNew->Invalidate();
     }
-    delete( pColorDlg );
 
     return 0;
 }
commit 455c6437b55a9de4478d0c9488b6d6a6368a43cd
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Fri Jul 4 22:36:29 2014 +0200

    Fix variable and method names
    
    Change-Id: I2f02dbeaa61e959d9420410100c6e958580a6567

diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 6d9975f..1e9c4b1 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -222,7 +222,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
 
     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
     Color                               mLastColor;
-    PaletteManager                      mrPaletteManager;
+    PaletteManager                      mPaletteManager;
     DECL_LINK( SelectedHdl, Color* );
 public:
     SFX_DECL_TOOLBOX_CONTROL();
@@ -243,7 +243,7 @@ class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
 {
     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
     Color                               mLastColor;
-    PaletteManager                      mrPaletteManager;
+    PaletteManager                      mPaletteManager;
     DECL_LINK( SelectedHdl, Color* );
 public:
     SFX_DECL_TOOLBOX_CONTROL();
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 5a700c7..3e19796 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -52,7 +52,7 @@ private:
     const sal_uInt16 nNavButtonHeight;
     PaletteManager& mrPaletteManager;
 
-    void Update();
+    void UpdateGUI();
 
     DECL_LINK( SelectHdl, void * );
     DECL_LINK( StepLeftClickHdl, void * );
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 81f024e..e41370c 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1084,11 +1084,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     AddStatusListener( OUString( ".uno:ColorTableState" ));
     AddStatusListener( maCommand );
 
-    Update();
+    UpdateGUI();
 }
 
 
-void SvxColorWindow_Impl::Update()
+void SvxColorWindow_Impl::UpdateGUI()
 {
     mrPaletteManager.ReloadColorSet(aColorSet);
 
@@ -1164,14 +1164,14 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
 IMPL_LINK_NOARG(SvxColorWindow_Impl, StepLeftClickHdl)
 {
     mrPaletteManager.PrevPalette();
-    Update();
+    UpdateGUI();
     return 0;
 }
 
 IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl)
 {
     mrPaletteManager.NextPalette();
-    Update();
+    UpdateGUI();
     return 0;
 }
 
@@ -1196,7 +1196,7 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
     {
         if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
         {
-            Update();
+            UpdateGUI();
         }
         else if ( SFX_ITEM_DEFAULT <= eState )
         {
@@ -2254,7 +2254,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
     SvxColorWindow_Impl* pColorWin =
         new SvxColorWindow_Impl(
                             m_aCommandURL,
-                            mrPaletteManager,
+                            mPaletteManager,
                             GetSlotId(),
                             m_xFrame,
                             SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
@@ -2383,7 +2383,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow()
     SvxColorWindow_Impl* pColorWin =
         new SvxColorWindow_Impl(
                             m_aCommandURL,
-                            mrPaletteManager,
+                            mPaletteManager,
                             GetSlotId(),
                             m_xFrame,
                             SVX_RESSTR( RID_SVXSTR_LINECOLOR ),
commit 52df93992a904c2206906240131a297b8526a361
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Fri Jul 4 11:41:28 2014 +0200

    Fix SvxColorWindow_Impl::StateChanged updating
    
    Change-Id: Ifb884f8830280d44ea3c73caf319109593bbebf9

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 1793552..81f024e 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1196,15 +1196,7 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
     {
         if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorListItem )))
         {
-            XColorListRef pColorList = ((SvxColorListItem *)pState)->GetColorList();
-            const long nColorCount(pColorList->Count());
-            const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
-            aColorSet.SetOutputSizePixel(aNewSize);
-            static sal_Int32 nAdd = 4;
-
-            SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
-            aColorSet.Clear();
-            aColorSet.addEntriesForXColorList(*pColorList);
+            Update();
         }
         else if ( SFX_ITEM_DEFAULT <= eState )
         {
commit 0ac41beac1495e86b103889ffa8d2ba6bf64ddcd
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Thu Jul 3 18:47:10 2014 +0200

    Add PaletteManager, refactor palette code
    
    Change-Id: I7e30fc895834318514b51bc648d32aa6d297bfae

diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx
new file mode 100644
index 0000000..f7ced03
--- /dev/null
+++ b/include/svx/Palette.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SVX_PALETTE_HXX
+#define INCLUDED_SVX_PALETTE_HXX
+
+#include <rtl/ustring.hxx>
+#include <tools/color.hxx>
+
+class Palette
+{
+public:
+    typedef std::pair<Color, OString> NamedColor;
+    typedef std::vector< NamedColor > ColorList;
+private:
+    bool        mbLoaded;
+    OUString    maFname;
+    OString     maName;
+    ColorList   maColors;
+
+    void LoadPalette();
+public:
+    Palette(const OUString &rFname);
+
+    const OString&      GetPaletteName();
+    const ColorList&    GetPaletteColors();
+};
+
+#endif // INCLUDED_SVX_PALETTE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx
new file mode 100644
index 0000000..a6b2dfa
--- /dev/null
+++ b/include/svx/PaletteManager.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SVX_PALETTEMANAGER_HXX
+#define INCLUDED_SVX_PALETTEMANAGER_HXX
+
+#include <svx/SvxColorValueSet.hxx>
+#include <rtl/ustring.hxx>
+
+class PaletteManager
+{
+    sal_uInt16  mnNumOfPalettes;
+    sal_uInt16  mnCurrentPalette;
+
+    long        mnColorCount;
+
+    std::vector<Palette> maPalettes;
+public:
+    PaletteManager();
+    void        LoadPalettes();
+    void        ReloadColorSet(SvxColorValueSet& rColorSet);
+    void        PrevPalette();
+    void        NextPalette();
+    long        GetColorCount();
+    OUString    GetPaletteName();
+};
+
+#endif // INCLUDED_SVX_PALETTEMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx
index 77ad9b2..7db9f4c 100644
--- a/include/svx/SvxColorValueSet.hxx
+++ b/include/svx/SvxColorValueSet.hxx
@@ -19,21 +19,12 @@
 #ifndef INCLUDED_SVX_SVXCOLORVALUESET_HXX
 #define INCLUDED_SVX_SVXCOLORVALUESET_HXX
 
+#include <svx/Palette.hxx>
 #include <svtools/valueset.hxx>
 #include <svx/svxdllapi.h>
 
 class XColorList;
 
-struct Palette
-{
-    typedef std::pair<Color, OString> NamedColor;
-    typedef std::vector< NamedColor > ColorList;
-    Palette(){};
-    Palette(const OUString &rFname);
-    OString maName;
-    ColorList maColors;
-};
-
 class SVX_DLLPUBLIC SvxColorValueSet : public ValueSet
 {
 private:
@@ -50,7 +41,7 @@ public:
 
     void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1);
     void loadColorVector(const std::vector<Color>& rColorVector, const OUString& rNamePrefix, sal_uInt32 nStartIndex = 1);
-    void loadPalette(const Palette& rPalette);
+    void loadPalette(Palette& rPalette);
     Size layoutAllVisible(sal_uInt32 nEntryCount);
     Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
 };
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index b1b578f..6d9975f 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -133,6 +133,7 @@
 #include <svx/svxdllapi.h>
 #include <boost/scoped_ptr.hpp>
 #include <com/sun/star/awt/FontDescriptor.hpp>
+#include <svx/PaletteManager.hxx>
 
 // important im tbxctrls.hxx created HeDaBu !!!
 class SvxLineItem;
@@ -221,7 +222,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl
 
     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
     Color                               mLastColor;
-    sal_uInt16                          nCurrentPalette;
+    PaletteManager                      mrPaletteManager;
     DECL_LINK( SelectedHdl, Color* );
 public:
     SFX_DECL_TOOLBOX_CONTROL();
@@ -242,7 +243,7 @@ class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl
 {
     ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater;
     Color                               mLastColor;
-    sal_uInt16                          nCurrentPalette;
+    PaletteManager                      mrPaletteManager;
     DECL_LINK( SelectedHdl, Color* );
 public:
     SFX_DECL_TOOLBOX_CONTROL();
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
index 960650b..831d4f5 100644
--- a/svx/Library_svxcore.mk
+++ b/svx/Library_svxcore.mk
@@ -343,6 +343,8 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
     svx/source/table/viewcontactoftableobj \
     svx/source/tbxctrls/extrusioncontrols \
     svx/source/tbxctrls/fontworkgallery \
+    svx/source/tbxctrls/Palette \
+    svx/source/tbxctrls/PaletteManager \
     svx/source/tbxctrls/tbcontrl \
     svx/source/tbxctrls/tbxcolorupdate \
     svx/source/tbxctrls/SvxColorValueSet \
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
new file mode 100644
index 0000000..aebb7f0
--- /dev/null
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/Palette.hxx>
+#include <tools/stream.hxx>
+
+// finds first token in rStr from index, separated by whitespace
+// returns position of next token in index
+OString lcl_getToken(const OString& rStr, sal_Int32& index)
+{
+    sal_Int32 substart, toklen = 0;
+
+    while(index < rStr.getLength() &&
+          (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
+        ++index;
+    if(index == rStr.getLength())
+    {
+        index = -1;
+        return OString();
+    }
+    substart = index;
+
+    while(index < rStr.getLength() &&
+          !(rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
+    {
+        ++index;
+        ++toklen;
+    }
+
+    while(index < rStr.getLength() &&
+          (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
+        ++index;
+    if(index == rStr.getLength())
+        index = -1;
+
+    return rStr.copy(substart, toklen);
+}
+
+Palette::Palette(const OUString &rFname) :
+    mbLoaded( false ),
+    maFname( rFname ){}
+
+const OString& Palette::GetPaletteName()
+{
+    LoadPalette();
+    return maName;
+}
+
+const Palette::ColorList& Palette::GetPaletteColors()
+{
+    LoadPalette();
+    return maColors;
+}
+
+void Palette::LoadPalette()
+{
+    if( mbLoaded ) return;
+
+    mbLoaded = true;
+
+    // TODO add error handling!!!
+    SvFileStream aFile(maFname, STREAM_READ);
+
+    OString aLine;
+
+    aFile.ReadLine(aLine);
+    if( !aLine.startsWith("GIMP Palette") ) return;
+    aFile.ReadLine(aLine);
+    if( aLine.startsWith("Name: ", &maName) )
+    {
+        aFile.ReadLine(aLine);
+        if( aLine.startsWith("Columns: "))
+            aFile.ReadLine(aLine); // we can ignore this
+    }
+
+    do {
+        if (aLine[0] != '#' && aLine[0] != '\n')
+        {
+            // TODO check if r,g,b are 0<= x <=255, or just clamp?
+            sal_Int32 nIndex = 0;
+            OString token;
+
+            token = lcl_getToken(aLine, nIndex);
+            if(token == "" || nIndex == -1) continue;
+            sal_Int32 r = token.toInt32();
+
+            token = lcl_getToken(aLine, nIndex);
+            if(token == "" || nIndex == -1) continue;
+            sal_Int32 g = token.toInt32();
+
+            token = lcl_getToken(aLine, nIndex);
+            if(token == "") continue;
+            sal_Int32 b = token.toInt32();
+
+            OString name;
+            if(nIndex != -1)
+                name = aLine.copy(nIndex);
+
+            maColors.push_back(std::make_pair(Color(r, g, b), name));
+        }
+    } while (aFile.ReadLine(aLine));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
new file mode 100644
index 0000000..88916ee
--- /dev/null
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/PaletteManager.hxx>
+#include <osl/file.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/objsh.hxx>
+#include "svx/drawitem.hxx"
+#include <svx/dialogs.hrc>
+
+PaletteManager::PaletteManager() :
+    mnNumOfPalettes(2),
+    mnCurrentPalette(0),
+    mnColorCount(0)
+{
+    LoadPalettes();
+    mnNumOfPalettes += maPalettes.size();
+}
+
+void PaletteManager::LoadPalettes()
+{
+    OUString aPalPath = SvtPathOptions().GetPalettePath();
+
+    osl::Directory aDir(aPalPath);
+    maPalettes.clear();
+    osl::DirectoryItem aDirItem;
+    osl::FileStatus aFileStat(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+    if( aDir.open() == osl::FileBase::E_None )
+    {
+        while( aDir.getNextItem(aDirItem) == osl::FileBase::E_None )
+        {
+            aDirItem.getFileStatus(aFileStat);
+            if(aFileStat.isRegular() || aFileStat.isLink())
+            {
+                OUString aPath = aFileStat.getFileURL();
+                if(aPath.getLength() > 4 &&
+                    aPath.copy(aPath.getLength()-4).toAsciiLowerCase() == ".gpl")
+                {
+                    maPalettes.push_back(Palette(aPath));
+                }
+            }
+        }
+    }
+}
+
+void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
+{
+    SfxObjectShell* pDocSh = SfxObjectShell::Current();
+
+    if( mnCurrentPalette == 0 )
+    {
+        const SfxPoolItem* pItem = NULL;
+        XColorListRef pColorList;
+
+        if ( pDocSh )
+        {
+            if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
+                pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
+        }
+
+        if ( !pColorList.is() )
+            pColorList = XColorList::CreateStdColorList();
+
+
+        if ( pColorList.is() )
+        {
+            mnColorCount = pColorList->Count();
+            rColorSet.Clear();
+            rColorSet.addEntriesForXColorList(*pColorList);
+        }
+    }
+    else if( mnCurrentPalette == mnNumOfPalettes - 1 )
+    {
+        // Add doc colors to palette
+        std::vector<Color> aColors = pDocSh->GetDocColors();
+        mnColorCount = aColors.size();
+        rColorSet.Clear();
+        rColorSet.loadColorVector(aColors, "Document Color ");
+    }
+    else
+    {
+        Palette& rPal = maPalettes[mnCurrentPalette-1];
+        mnColorCount = rPal.GetPaletteColors().size();
+        rColorSet.Clear();
+        rColorSet.loadPalette(rPal);
+    }
+}
+
+void PaletteManager::PrevPalette()
+{
+    mnCurrentPalette = mnCurrentPalette == 0 ? mnNumOfPalettes - 1 : mnCurrentPalette - 1;
+}
+
+void PaletteManager::NextPalette()
+{
+    mnCurrentPalette = mnCurrentPalette == mnNumOfPalettes - 1 ? 0 : mnCurrentPalette + 1;
+}
+
+long PaletteManager::GetColorCount()
+{
+    return mnColorCount;
+}
+
+OUString PaletteManager::GetPaletteName()
+{
+    if( mnCurrentPalette == 0 )
+        return OUString("Default palette");
+    else if( mnCurrentPalette == mnNumOfPalettes - 1 )
+        return OUString("Document colors");
+    else
+        return OStringToOUString(maPalettes[mnCurrentPalette - 1].GetPaletteName(), RTL_TEXTENCODING_ASCII_US);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index dc2f2c2..e338109 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -23,85 +23,6 @@
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 
-
-// finds first token in rStr from index, separated by whitespace
-// returns position of next token in index
-OString lcl_getToken(const OString& rStr, sal_Int32& index)
-{
-    sal_Int32 substart, toklen = 0;
-
-    while(index < rStr.getLength() &&
-          (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
-        ++index;
-    if(index == rStr.getLength())
-    {
-        index = -1;
-        return OString();
-    }
-    substart = index;
-
-    while(index < rStr.getLength() &&
-          !(rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
-    {
-        ++index;
-        ++toklen;
-    }
-
-    while(index < rStr.getLength() &&
-          (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t'))
-        ++index;
-    if(index == rStr.getLength())
-        index = -1;
-
-    return rStr.copy(substart, toklen);
-}
-
-Palette::Palette(const OUString &rFname)
-{
-    // TODO add error handling!!!
-    SvFileStream aFile(rFname, STREAM_READ);
-
-    OString aPaletteName;
-    OString aLine;
-
-    aFile.ReadLine(aLine);
-    if( !aLine.startsWith("GIMP Palette") ) return;
-    aFile.ReadLine(aLine);
-    if( aLine.startsWith("Name: ", &aPaletteName) )
-    {
-        aFile.ReadLine(aLine);
-        if( aLine.startsWith("Columns: "))
-            aFile.ReadLine(aLine); // we can ignore this
-    }
-
-    do {
-        if (aLine[0] != '#' && aLine[0] != '\n')
-        {
-            // TODO check if r,g,b are 0<= x <=255, or just clamp?
-            sal_Int32 nIndex = 0;
-            OString token;
-
-            token = lcl_getToken(aLine, nIndex);
-            if(token == "" || nIndex == -1) continue;
-            sal_Int32 r = token.toInt32();
-
-            token = lcl_getToken(aLine, nIndex);
-            if(token == "" || nIndex == -1) continue;
-            sal_Int32 g = token.toInt32();
-
-            token = lcl_getToken(aLine, nIndex);
-            if(token == "") continue;
-            sal_Int32 b = token.toInt32();
-
-            OString name;
-            if(nIndex != -1)
-                name = aLine.copy(nIndex);
-
-            maColors.push_back(std::make_pair(Color(r, g, b), name));
-        }
-    } while (aFile.ReadLine(aLine));
-}
-
 SvxColorValueSet::SvxColorValueSet(Window* _pParent, WinBits nWinStyle)
 :   ValueSet(_pParent, nWinStyle)
 {
@@ -186,9 +107,9 @@ void SvxColorValueSet::loadColorVector(const std::vector<Color>& rColorVector, c
 }
 
 
-void SvxColorValueSet::loadPalette(const Palette& rPalette)
+void SvxColorValueSet::loadPalette(Palette& rPalette)
 {
-    const Palette::ColorList &rColors = rPalette.maColors;
+    const Palette::ColorList &rColors = rPalette.GetPaletteColors();
     Clear();
     int nIx = 1;
     for(Palette::ColorList::const_iterator it = rColors.begin();
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index c699986..5a700c7 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -29,6 +29,7 @@
 #include <rtl/ustring.hxx>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <svx/SvxColorValueSet.hxx>
+#include <svx/PaletteManager.hxx>
 
 
 // class SvxColorWindow_Impl --------------------------------------------------
@@ -43,15 +44,15 @@ private:
     SvxColorValueSet aColorSet;
     PushButton aButtonLeft;
     PushButton aButtonRight;
+    FixedText  aPaletteName;
     OUString  maCommand;
     Link maSelectedLink;
 
     const sal_uInt16 nNavButtonWidth;
     const sal_uInt16 nNavButtonHeight;
-    sal_uInt16& rnCurrentPalette;
-    sal_uInt16 nNumOfPalettes;
+    PaletteManager& mrPaletteManager;
 
-    void ReloadColorSet();
+    void Update();
 
     DECL_LINK( SelectHdl, void * );
     DECL_LINK( StepLeftClickHdl, void * );
@@ -63,7 +64,7 @@ protected:
 
 public:
     SvxColorWindow_Impl( const OUString& rCommand,
-                         sal_uInt16& rnCurrentPalette_,
+                         PaletteManager& rPaletteManager,
                          sal_uInt16 nSlotId,
                          const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
                          const OUString& rWndTitle,
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index da69d77..1793552 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -31,11 +31,9 @@
 #include <svtools/ctrltool.hxx>
 #include <svtools/borderhelper.hxx>
 #include <svl/stritem.hxx>
-#include <unotools/pathoptions.hxx>
 #include <sfx2/tplpitem.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/viewsh.hxx>
-#include <sfx2/objsh.hxx>
 #include <sfx2/docfac.hxx>
 #include <sfx2/templdlg.hxx>
 #include <svl/isethint.hxx>
@@ -1019,7 +1017,7 @@ void SvxFontNameBox_Impl::Select()
 #endif
 
 SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
-                                          sal_uInt16&                rnCurrentPalette_,
+                                          PaletteManager&            rPaletteManager,
                                           sal_uInt16                 nSlotId,
                                           const Reference< XFrame >& rFrame,
                                           const OUString&            rWndTitle,
@@ -1029,11 +1027,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     aColorSet   ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
     aButtonLeft ( this ),
     aButtonRight( this ),
+    aPaletteName( this ),
     maCommand( rCommand ),
     nNavButtonWidth ( 20 ),
     nNavButtonHeight( 20 ),
-    rnCurrentPalette( rnCurrentPalette_ ),
-    nNumOfPalettes( 1 )
+    mrPaletteManager( rPaletteManager )
 
 {
     if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
@@ -1067,9 +1065,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
         aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) );
     }
 
-    if( SfxObjectShell::Current()->GetDocColors().size() > 0 )
-        nNumOfPalettes++;
-
     aButtonLeft.SetText("<");
     aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) );
     aButtonLeft.Show();
@@ -1084,49 +1079,20 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString&            rCommand,
     SetText( rWndTitle );
     aColorSet.Show();
 
+    aPaletteName.Show();
+
     AddStatusListener( OUString( ".uno:ColorTableState" ));
     AddStatusListener( maCommand );
 
-    ReloadColorSet();
+    Update();
 }
 
-void SvxColorWindow_Impl::ReloadColorSet()
-{
-    SfxObjectShell* pDocSh = SfxObjectShell::Current();
-    long nColorCount = 0;
-
-    if( rnCurrentPalette == 0 )
-    {
-        const SfxPoolItem* pItem = NULL;
-        XColorListRef pColorList;
-
-        if ( pDocSh )
-        {
-            if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
-                pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
-        }
-
-        if ( !pColorList.is() )
-            pColorList = XColorList::CreateStdColorList();
-
 
-        if ( pColorList.is() )
-        {
-            nColorCount = pColorList->Count();
-            aColorSet.Clear();
-            aColorSet.addEntriesForXColorList(*pColorList);
-        }
-    }
-    else if( rnCurrentPalette == nNumOfPalettes - 1 )
-    {
-        // Add doc colors to palette
-        std::vector<Color> aColors = pDocSh->GetDocColors();
-        nColorCount = aColors.size();
-        aColorSet.Clear();
-        aColorSet.addEntriesForColorVector(aColors);
-    }
+void SvxColorWindow_Impl::Update()
+{
+    mrPaletteManager.ReloadColorSet(aColorSet);
 
-    const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
+    const Size aNewSize(aColorSet.layoutAllVisible(mrPaletteManager.GetColorCount()));
     aColorSet.SetOutputSizePixel(aNewSize);
     static sal_Int32 nAdd = 4;
 
@@ -1138,6 +1104,10 @@ void SvxColorWindow_Impl::ReloadColorSet()
 
     aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight));
     aButtonRight.SetPosPixel(Point(aNewSize.Width() + nAdd - nNavButtonWidth, aNewSize.Height() + nAdd + 1));
+
+    aPaletteName.SetSizePixel(Size(150, nNavButtonHeight));
+    aPaletteName.SetPosPixel(Point(nNavButtonWidth, aNewSize.Height() + nAdd + 1));
+    aPaletteName.SetText(mrPaletteManager.GetPaletteName());
 }
 
 SvxColorWindow_Impl::~SvxColorWindow_Impl()
@@ -1151,7 +1121,7 @@ void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
 
 SfxPopupWindow* SvxColorWindow_Impl::Clone() const
 {
-    return new SvxColorWindow_Impl( maCommand, rnCurrentPalette, theSlotId, GetFrame(), GetText(), GetParent() );
+    return new SvxColorWindow_Impl( maCommand, mrPaletteManager, theSlotId, GetFrame(), GetText(), GetParent() );
 }
 
 IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
@@ -1193,15 +1163,15 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
 
 IMPL_LINK_NOARG(SvxColorWindow_Impl, StepLeftClickHdl)
 {
-    rnCurrentPalette = (rnCurrentPalette - 1) % nNumOfPalettes;
-    ReloadColorSet();
+    mrPaletteManager.PrevPalette();
+    Update();
     return 0;
 }
 
 IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl)
 {
-    rnCurrentPalette = (rnCurrentPalette + 1) % nNumOfPalettes;
-    ReloadColorSet();
+    mrPaletteManager.NextPalette();
+    Update();
     return 0;
 }
 
@@ -2238,8 +2208,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl(
     sal_uInt16 nId,
     ToolBox& rTbx ) :
     SfxToolBoxControl( nSlotId, nId, rTbx ),
-    mLastColor( COL_AUTO ),
-    nCurrentPalette( 0 )
+    mLastColor( COL_AUTO )
 {
     rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
 
@@ -2293,7 +2262,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
     SvxColorWindow_Impl* pColorWin =
         new SvxColorWindow_Impl(
                             m_aCommandURL,
-                            nCurrentPalette,
+                            mrPaletteManager,
                             GetSlotId(),
                             m_xFrame,
                             SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
@@ -2401,8 +2370,7 @@ SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
     ToolBox& rTbx ) :
 
     SfxToolBoxControl( nSlotId, nId, rTbx ),
-    mLastColor( COL_BLACK ),
-    nCurrentPalette( 0 )
+    mLastColor( COL_BLACK )
 {
     rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
     addStatusListener( OUString( ".uno:XLineColor" ) );
@@ -2423,7 +2391,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow()
     SvxColorWindow_Impl* pColorWin =
         new SvxColorWindow_Impl(
                             m_aCommandURL,
-                            nCurrentPalette,
+                            mrPaletteManager,
                             GetSlotId(),
                             m_xFrame,
                             SVX_RESSTR( RID_SVXSTR_LINECOLOR ),
commit 1cff66591f531f2acc40a4400c704f8708d8027d
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Tue Jul 1 23:56:25 2014 +0200

    Add GIMP palette loading code
    
    Change-Id: Ie0d0787342bc806a1848cb904114f0ca16c9df69

diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx
index 7502d93..77ad9b2 100644
--- a/include/svx/SvxColorValueSet.hxx
+++ b/include/svx/SvxColorValueSet.hxx
@@ -24,6 +24,16 @@
 
 class XColorList;
 
+struct Palette
+{
+    typedef std::pair<Color, OString> NamedColor;
+    typedef std::vector< NamedColor > ColorList;
+    Palette(){};
+    Palette(const OUString &rFname);
+    OString maName;
+    ColorList maColors;
+};
+
 class SVX_DLLPUBLIC SvxColorValueSet : public ValueSet
 {
 private:
@@ -39,7 +49,8 @@ public:
     sal_uInt32 getColumnCount() const;
 
     void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1);
-    void addEntriesForColorVector(const std::vector<Color>& rColorVector, sal_uInt32 nStartIndex = 1);
+    void loadColorVector(const std::vector<Color>& rColorVector, const OUString& rNamePrefix, sal_uInt32 nStartIndex = 1);
+    void loadPalette(const Palette& rPalette);
     Size layoutAllVisible(sal_uInt32 nEntryCount);
     Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
 };
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index b2ada21..dc2f2c2 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -24,6 +24,83 @@
 #include <vcl/settings.hxx>
 
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list