summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUrsache Vladimir <ursache@collabora.co.uk>2015-02-14 02:46:47 +0200
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-02-14 01:51:54 +0100
commit50a36041e18dc2a595259b5414ded409687dc47b (patch)
tree2f61edb3336449a6649eb5defbd0ca50d5c966b8
parentrelated tdf#89004 improve performance of document data collection (diff)
downloadcore-50a36041e18dc2a595259b5414ded409687dc47b.tar.gz
core-50a36041e18dc2a595259b5414ded409687dc47b.zip
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
-rw-r--r--include/sfx2/objsh.hxx3
-rw-r--r--include/svx/SvxColorValueSet.hxx3
-rw-r--r--include/tools/color.hxx5
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/source/core/data/document10.cxx10
-rw-r--r--sc/source/ui/docshell/docsh.cxx2
-rw-r--r--sc/source/ui/inc/docsh.hxx2
-rw-r--r--sfx2/source/doc/objcont.cxx4
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx4
-rw-r--r--svx/source/tbxctrls/SvxColorValueSet.cxx10
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/inc/docsh.hxx2
-rw-r--r--sw/source/core/doc/docfmt.cxx10
-rw-r--r--sw/source/uibase/app/docst.cxx2
14 files changed, 32 insertions, 29 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index edf424810d71..90e7cfe669ac 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 351116a01bae..33409db00da3 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 ea921878e48c..92ea21011dbb 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 3ed76a6b41d9..c0468c3c5967 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 362acbf8ec91..977a0dba5be0 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 29b03c3c79bb..e7cb71a76164 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 f7c2f2865e28..03e867c2eca4 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 cd5c294546ea..937a5e04ba46 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 f5ad05161ae4..8d0a21147fe5 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 29b805675e97..e1bc89c12385 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 1fe0fd95dd2c..e030ff9ad36e 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 780883b3b6ad..9b917728bc53 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 bed21c6a8b91..131ea4e1d971 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 1d5a1b507633..8eafb05fd063 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();
}