[Libreoffice-commits] core.git: Branch 'feature/gsoc14-colors' - 3 commits - sc/inc sc/source svx/source sw/source

Krisztian Pinter pin.terminator at gmail.com
Tue Jun 24 06:35:24 PDT 2014


 sc/inc/document.hxx                      |    2 +
 sc/source/core/data/document10.cxx       |   50 +++++++++++++++++++++++++++++++
 sc/source/ui/docshell/docsh.cxx          |    5 +++
 sc/source/ui/inc/docsh.hxx               |    2 +
 svx/source/tbxctrls/SvxColorValueSet.cxx |    6 ---
 sw/source/core/doc/docfmt.cxx            |   17 ++++++----
 6 files changed, 71 insertions(+), 11 deletions(-)

New commits:
commit 7ced18afb479f880fa135802980e1f66dc832fd0
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Tue Jun 24 15:32:18 2014 +0200

    Add loading document colors to Calc
    
    Change-Id: I06783b04dbbad2aa690820af1ca2cf05a1004f20

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 259d119..164f629d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1816,6 +1816,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 4112bb9..8ecf3de 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 7ed1836..77d082a 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -209,6 +209,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 89706d2..246cf0c 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -203,6 +203,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;
commit 7f12b0e1f886b25d424f8df21cad8898957c6a5d
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Thu Jun 19 18:26:54 2014 +0200

    Get more color attributes for document colors in Writer
    
    Change-Id: I2005b434f20a56417105c7b26ce09155a7023023

diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 86890b8..18626d2e 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -2599,14 +2599,19 @@ std::vector<Color> SwDoc::GetDocColors()
         while( nWhich )
         {
             const SfxPoolItem *pItem;
-            if( SFX_ITEM_SET == pItemSet->GetItemState( nWhich, false, &pItem ) &&
-                RES_CHRATR_COLOR == pItem->Which() )
+            if( SFX_ITEM_SET == pItemSet->GetItemState( nWhich, false, &pItem ) )
             {
-                Color aColor( ((SvxColorItem*)pItem)->GetValue() );
-                if( COL_AUTO != aColor.GetColor() &&
-                    std::find(docColors.begin(), docColors.end(), aColor) == docColors.end() )
+                sal_uInt16 aWhich = pItem->Which();
+                if( RES_CHRATR_COLOR        == aWhich ||
+                    RES_CHRATR_HIGHLIGHT    == aWhich ||
+                    RES_BACKGROUND          == aWhich )
                 {
-                    docColors.push_back( aColor );
+                    Color aColor( ((SvxColorItem*)pItem)->GetValue() );
+                    if( COL_AUTO != aColor.GetColor() &&
+                        std::find(docColors.begin(), docColors.end(), aColor) == docColors.end() )
+                    {
+                        docColors.push_back( aColor );
+                    }
                 }
             }
 
commit 5ae707cc498524bccfcbeecb653b0959990c4300
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Thu Jun 19 16:49:05 2014 +0200

    Code cleanup
    
    Change-Id: Ib452a5cd716ef243e04f498d2fa23d0d389865c0

diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx
index 1ee94f1..b2ada21 100644
--- a/svx/source/tbxctrls/SvxColorValueSet.cxx
+++ b/svx/source/tbxctrls/SvxColorValueSet.cxx
@@ -90,14 +90,10 @@ void SvxColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sa
 
 void SvxColorValueSet::addEntriesForColorVector(const std::vector<Color>& rColorVector, sal_uInt32 nStartIndex)
 {
-    const sal_uInt32 nColorCount(rColorVector.size());
-
-    //for(sal_uInt32 nIndex(0); nIndex < nColorCount; nIndex++, nStartIndex++)
     for(std::vector<Color>::const_iterator it = rColorVector.begin();
         it != rColorVector.end(); it++, nStartIndex++)
     {
-        const Color& rEntry = *it;
-        InsertItem(nStartIndex, rEntry, "");
+        InsertItem(nStartIndex, *it, "");
     }
 }
 


More information about the Libreoffice-commits mailing list