summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrisztian Pinter <pin.terminator@gmail.com>2014-06-24 15:32:18 +0200
committerKrisztian Pinter <pin.terminator@gmail.com>2014-07-25 17:14:10 +0200
commitba5e1e45dcf15e0b7b1c8373b8ebc5b0d36a0cfc (patch)
treec2d624597c31aa8033af4a4ff27eea467dfba8cc
parent966473d87b6dae1f32b039fe38e4c0fec1f82702 (diff)
Add loading document colors to Calc
Change-Id: I06783b04dbbad2aa690820af1ca2cf05a1004f20
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/source/core/data/document10.cxx50
-rw-r--r--sc/source/ui/docshell/docsh.cxx5
-rw-r--r--sc/source/ui/inc/docsh.hxx2
4 files changed, 59 insertions, 0 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 44e88c073a33..0e9fa3ab6e66 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1820,6 +1820,8 @@ public:
void CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellValues& rSrc );
+ std::vector<Color> GetDocColors();
+
private:
ScDocument(const ScDocument& r); // disabled with no definition
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index d44bc33839a2..e723a68076e6 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -18,6 +18,12 @@
#include <tokenstringcontext.hxx>
#include <poolhelp.hxx>
+#include "dociter.hxx"
+#include "patattr.hxx"
+#include <svl/whiter.hxx>
+#include <editeng/colritem.hxx>
+#include "scitems.hxx"
+
// Add totally brand-new methods to this source file.
bool ScDocument::IsMerged( const ScAddress& rPos ) const
@@ -234,6 +240,50 @@ void ScDocument::CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellVal
pTab->CopyCellValuesFrom(rTopPos.Col(), rTopPos.Row(), rSrc);
}
+std::vector<Color> ScDocument::GetDocColors()
+{
+ std::vector<Color> docColors;
+
+ for( unsigned int nTabIx = 0; nTabIx < maTabs.size(); ++nTabIx )
+ {
+ ScUsedAreaIterator aIt(this, nTabIx, 0, 0, MAXCOLCOUNT-1, MAXROWCOUNT-1);
+
+ for( bool bIt = aIt.GetNext(); bIt; bIt = aIt.GetNext() )
+ {
+ const ScPatternAttr* pPattern = aIt.GetPattern();
+
+ if( pPattern == 0 )
+ continue;
+
+ const SfxItemSet& rItemSet = pPattern->GetItemSet();
+
+ SfxWhichIter aIter( rItemSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == rItemSet.GetItemState( nWhich, false, &pItem ) )
+ {
+ sal_uInt16 aWhich = pItem->Which();
+ if( ATTR_FONT_COLOR == aWhich ||
+ ATTR_BACKGROUND == aWhich )
+ {
+ Color aColor( ((SvxColorItem*)pItem)->GetValue() );
+ if( COL_AUTO != aColor.GetColor() &&
+ std::find(docColors.begin(), docColors.end(), aColor) == docColors.end() )
+ {
+ docColors.push_back( aColor );
+ }
+ }
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+ }
+ return docColors;
+}
+
void ScDocument::SetCalcConfig( const ScCalcConfig& rConfig )
{
maCalcConfig = rConfig;
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 92cc36ca2b14..35ce7c9a2bfa 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -208,6 +208,11 @@ void ScDocShell::FillClass( SvGlobalName* pClassName,
}
}
+std::vector<Color> ScDocShell::GetDocColors()
+{
+ return aDocument.GetDocColors();
+}
+
void ScDocShell::DoEnterHandler()
{
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 46bd07ebc8f4..740b0bc4ec57 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -202,6 +202,8 @@ public:
sal_Int32 nFileFormat,
bool bTemplate = false ) const SAL_OVERRIDE;
+ virtual std::vector<Color> GetDocColors();
+
virtual bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ) SAL_OVERRIDE;
virtual bool Load( SfxMedium& rMedium ) SAL_OVERRIDE;
virtual bool LoadFrom( SfxMedium& rMedium ) SAL_OVERRIDE;