[Libreoffice-commits] core.git: include/sfx2 include/svx include/tools sc/inc sc/source sfx2/source svx/source sw/inc sw/source

Ursache Vladimir ursache at collabora.co.uk
Sat Feb 14 06:55:17 PST 2015


 include/sfx2/objsh.hxx                   |    3 ++-
 include/svx/SvxColorValueSet.hxx         |    3 ++-
 include/tools/color.hxx                  |    5 +++++
 sc/inc/document.hxx                      |    2 +-
 sc/source/core/data/document10.cxx       |   10 ++++------
 sc/source/ui/docshell/docsh.cxx          |    2 +-
 sc/source/ui/inc/docsh.hxx               |    2 +-
 sfx2/source/doc/objcont.cxx              |    4 ++--
 svx/source/tbxctrls/PaletteManager.cxx   |    4 ++--
 svx/source/tbxctrls/SvxColorValueSet.cxx |   10 +++++-----
 sw/inc/doc.hxx                           |    2 +-
 sw/inc/docsh.hxx                         |    2 +-
 sw/source/core/doc/docfmt.cxx            |   10 ++++------
 sw/source/uibase/app/docst.cxx           |    2 +-
 14 files changed, 32 insertions(+), 29 deletions(-)

New commits:
commit 50a36041e18dc2a595259b5414ded409687dc47b
Author: Ursache Vladimir <ursache at collabora.co.uk>
Date:   Sat Feb 14 02:46:47 2015 +0200

    related tdf#89004 move to std:set instead of std::vector
    
    Conflicts:
    	sc/source/core/data/document10.cxx
    	sw/source/core/doc/docfmt.cxx
    
    Change-Id: I1312f476607ea3a78b162a7e59323b0a142f6629

diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index edf4248..90e7cfe 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -35,6 +35,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/document/CmisVersion.hpp>
 #include <boost/shared_ptr.hpp>
+#include <set>
 
 #include <vcl/timer.hxx>
 #include <svl/poolitem.hxx>
@@ -489,7 +490,7 @@ public:
 #define CONTENT_MACRO 2
 
 
-    virtual std::vector<Color> GetDocColors();
+    virtual std::set<Color> GetDocColors();
 
     virtual void                LoadStyles( SfxObjectShell &rSource );
     void                        ReadNote( INote * );
diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx
index 351116a..33409db 100644
--- a/include/svx/SvxColorValueSet.hxx
+++ b/include/svx/SvxColorValueSet.hxx
@@ -21,6 +21,7 @@
 
 #include <svtools/valueset.hxx>
 #include <svx/svxdllapi.h>
+#include <set>
 
 class XColorList;
 
@@ -36,7 +37,7 @@ public:
     sal_uInt32 getColumnCount() const;
 
     void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1);
-    void addEntriesForColorVector(const std::vector<Color>& rColorVector, const OUString& rNamePrefix, sal_uInt32 nStartIndex = 1);
+    void addEntriesForColorSet(const std::set<Color>& rColorSet, const OUString& rNamePrefix, sal_uInt32 nStartIndex = 1);
     Size layoutAllVisible(sal_uInt32 nEntryCount);
     Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount);
 };
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index ea92187..92ea210 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -112,6 +112,11 @@ public:
                                 sal_uInt8((rBColor.getBlue() * 255.0) + 0.5));
                         }
 
+                        bool operator<(const Color& b) const
+                        {
+                            return mnColor < b.GetColor();
+                        }
+
     void                SetRed( sal_uInt8 nRed );
     sal_uInt8           GetRed() const { return COLORDATA_RED( mnColor ); }
     void                SetGreen( sal_uInt8 nGreen );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 3ed76a6b..c0468c3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1863,7 +1863,7 @@ public:
 
     void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
 
-    std::vector<Color> GetDocColors();
+    std::set<Color> GetDocColors();
 
 private:
     ScDocument(const ScDocument& r) SAL_DELETED_FUNCTION;
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 362acbf..977a0db 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -156,9 +156,9 @@ void ScDocument::CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellVal
     pTab->CopyCellValuesFrom(rTopPos.Col(), rTopPos.Row(), rSrc);
 }
 
-std::vector<Color> ScDocument::GetDocColors()
+std::set<Color> ScDocument::GetDocColors()
 {
-    std::vector<Color> aDocColors;
+    std::set<Color> aDocColors;
     ScDocumentPool *pPool = GetPool();
     const sal_uInt16 pAttribs[] = {ATTR_BACKGROUND, ATTR_FONT_COLOR};
     for (size_t i=0; i<SAL_N_ELEMENTS( pAttribs ); i++)
@@ -171,10 +171,8 @@ std::vector<Color> ScDocument::GetDocColors()
             if (pItem == 0)
                 continue;
             Color aColor( pItem->GetValue() );
-            if (COL_AUTO == aColor.GetColor())
-                continue;
-            if (std::find(aDocColors.begin(), aDocColors.end(), aColor) == aDocColors.end())
-                aDocColors.push_back(aColor);
+            if (COL_AUTO != aColor.GetColor())
+                aDocColors.insert(aColor);
         }
     }
     return aDocColors;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 29b03c3..e7cb71a 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -205,7 +205,7 @@ void ScDocShell::FillClass( SvGlobalName* pClassName,
     }
 }
 
-std::vector<Color> ScDocShell::GetDocColors()
+std::set<Color> ScDocShell::GetDocColors()
 {
     return aDocument.GetDocColors();
 }
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index f7c2f28..03e867c 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -193,7 +193,7 @@ public:
                                sal_Int32 nFileFormat,
                                bool bTemplate = false ) const SAL_OVERRIDE;
 
-    virtual std::vector<Color> GetDocColors() SAL_OVERRIDE;
+    virtual std::set<Color> GetDocColors() SAL_OVERRIDE;
 
     virtual bool    InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ) SAL_OVERRIDE;
     virtual bool    Load( SfxMedium& rMedium ) SAL_OVERRIDE;
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index cd5c294..937a5e0 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -296,9 +296,9 @@ SfxDocumentInfoDialog* SfxObjectShell::CreateDocumentInfoDialog
 
 
 
-std::vector<Color> SfxObjectShell::GetDocColors()
+std::set<Color> SfxObjectShell::GetDocColors()
 {
-    std::vector<Color> empty;
+    std::set<Color> empty;
     return empty;
 }
 
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index f5ad051..8d0a211 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -104,10 +104,10 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
     else if( mnCurrentPalette == mnNumOfPalettes - 1 )
     {
         // Add doc colors to palette
-        std::vector<Color> aColors = pDocSh->GetDocColors();
+        std::set<Color> aColors = pDocSh->GetDocColors();
         mnColorCount = aColors.size();
         rColorSet.Clear();
-        rColorSet.addEntriesForColorVector(aColors, SVX_RESSTR( RID_SVXSTR_DOC_COLOR_PREFIX ) + " " );
+        rColorSet.addEntriesForColorSet(aColors, SVX_RESSTR( RID_SVXSTR_DOC_COLOR_PREFIX ) + " " );
     }
     else
     {
diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index 29b8056..e1bc89c 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -80,20 +80,20 @@ void SvxColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sa
     }
 }
 
-void SvxColorValueSet::addEntriesForColorVector(const std::vector<Color>& rColorVector, const OUString& rNamePrefix, sal_uInt32 nStartIndex)
+void SvxColorValueSet::addEntriesForColorSet(const std::set<Color>& rColorSet, const OUString& rNamePrefix, sal_uInt32 nStartIndex)
 {
     if(rNamePrefix.getLength() != 0)
     {
-        for(std::vector<Color>::const_iterator it = rColorVector.begin();
-            it != rColorVector.end(); ++it, nStartIndex++)
+        for(std::set<Color>::const_iterator it = rColorSet.begin();
+            it != rColorSet.end(); ++it, nStartIndex++)
         {
             InsertItem(nStartIndex, *it, rNamePrefix + OUString::number(nStartIndex));
         }
     }
     else
     {
-        for(std::vector<Color>::const_iterator it = rColorVector.begin();
-            it != rColorVector.end(); ++it, nStartIndex++)
+        for(std::set<Color>::const_iterator it = rColorSet.begin();
+            it != rColorSet.end(); ++it, nStartIndex++)
         {
             InsertItem(nStartIndex, *it, "");
         }
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 1fe0fd9..e030ff9 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1668,7 +1668,7 @@ public:
      */
     void dumpAsXml( xmlTextWriterPtr writer = NULL ) const;
 
-    std::vector<Color> GetDocColors();
+    std::set<Color> GetDocColors();
 
 private:
     // Copies master header to left / first one, if necessary - used by ChgPageDesc().
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 780883b..9b91772 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -249,7 +249,7 @@ public:
                                    sal_Int32 nFileFormat,
                                    bool bTemplate = false ) const SAL_OVERRIDE;
 
-    virtual std::vector<Color> GetDocColors() SAL_OVERRIDE;
+    virtual std::set<Color> GetDocColors() SAL_OVERRIDE;
 
     virtual void LoadStyles( SfxObjectShell& rSource ) SAL_OVERRIDE;
 
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index bed21c6..131ea4e 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1919,9 +1919,9 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const OUString & sNewName,
         BroadcastStyleOperation(sNewName, eFamily, SFX_STYLESHEET_MODIFIED);
 }
 
-std::vector<Color> SwDoc::GetDocColors()
+std::set<Color> SwDoc::GetDocColors()
 {
-    std::vector<Color> aDocColors;
+    std::set<Color> aDocColors;
     SwAttrPool& rPool = GetAttrPool();
     const sal_uInt16 pAttribs[] = {RES_CHRATR_COLOR, RES_CHRATR_HIGHLIGHT, RES_BACKGROUND};
     for (size_t i=0; i<SAL_N_ELEMENTS(pAttribs); i++)
@@ -1934,10 +1934,8 @@ std::vector<Color> SwDoc::GetDocColors()
             if (pItem == 0)
                 continue;
             Color aColor( pItem->GetValue() );
-            if (COL_AUTO == aColor.GetColor())
-                continue;
-            if (std::find(aDocColors.begin(), aDocColors.end(), aColor) == aDocColors.end())
-                aDocColors.push_back(aColor);
+            if (COL_AUTO != aColor.GetColor())
+                aDocColors.insert(aColor);
         }
     }
     return aDocColors;
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index 1d5a1b5..8eafb05 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1225,7 +1225,7 @@ sal_uInt16 SwDocShell::MakeByExample( const OUString &rName, sal_uInt16 nFamily,
     return nFamily;
 }
 
-std::vector<Color> SwDocShell::GetDocColors()
+std::set<Color> SwDocShell::GetDocColors()
 {
     return mpDoc->GetDocColors();
 }


More information about the Libreoffice-commits mailing list