diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2014-06-24 15:32:18 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-09-17 10:19:31 +0200 |
commit | 9b37819adb7282bb7f12f0cc977c2fb0d24b329d (patch) | |
tree | a604d3b29c21972bc6ede7744bef71f3cc9649c4 | |
parent | 4ef268d2628038542eac4ac83d0f22a62bb42c85 (diff) |
Add loading document colors to Calc
Change-Id: I06783b04dbbad2aa690820af1ca2cf05a1004f20
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document10.cxx | 50 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 2 |
4 files changed, 59 insertions, 0 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index e314145fd5f2..c30cea833b5d 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1818,6 +1818,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 90856d2c4128..9d1509979bff 100644 --- a/sc/source/core/data/document10.cxx +++ b/sc/source/core/data/document10.cxx @@ -19,6 +19,12 @@ #include <poolhelp.hxx> #include <bcaslot.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 @@ -240,6 +246,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 1287c8a8c07f..36e1c2d9a30a 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 b432f94199b3..b621a8aa7d76 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; |