summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrisztian Pinter <pin.terminator@gmail.com>2014-06-16 21:52:12 +0200
committerKrisztian Pinter <pin.terminator@gmail.com>2014-07-25 17:09:07 +0200
commitef6521a1833bf1f1a12da8ad012783be112dbf3a (patch)
tree46332f06961988a710c0b6a8983a7a5c2ac39489
parent0497864bd4f603605997938d504ef9598623e713 (diff)
Add writer document font colors to color palettes
Change-Id: If3fedc45586eee068c40e92da87d5d550a456a64
-rw-r--r--include/sfx2/objsh.hxx2
-rw-r--r--sfx2/source/doc/objcont.cxx7
-rw-r--r--svx/source/tbxctrls/colorwindow.hxx1
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx15
-rw-r--r--sw/inc/doc.hxx3
-rw-r--r--sw/inc/docsh.hxx2
-rw-r--r--sw/source/core/doc/docfmt.cxx38
-rw-r--r--sw/source/uibase/app/docst.cxx5
8 files changed, 72 insertions, 1 deletions
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 1cb8e910af05..6f5b51631b00 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -485,6 +485,8 @@ public:
#define DEF_CONTENT_COUNT 1
+ virtual std::vector<Color> GetDocColors();
+
virtual void LoadStyles( SfxObjectShell &rSource );
void ReadNote( INote * );
void UpdateNote( INote * );
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 33700ffc22f7..7794832a6062 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -298,6 +298,13 @@ SfxDocumentInfoDialog* SfxObjectShell::CreateDocumentInfoDialog
+
+std::vector<Color> SfxObjectShell::GetDocColors()
+{
+ std::vector<Color> empty;
+ return empty;
+}
+
SfxStyleSheetBasePool* SfxObjectShell::GetStyleSheetPool()
{
return 0;
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
index 3aad292a7071..6ed74f31c115 100644
--- a/svx/source/tbxctrls/colorwindow.hxx
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -41,6 +41,7 @@ class SvxColorWindow_Impl : public SfxPopupWindow
private:
const sal_uInt16 theSlotId;
SvxColorValueSet aColorSet;
+ SvxColorValueSet aDocColorSet;
OUString maCommand;
Link maSelectedLink;
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 5728791bf83e..c802aa6c5777 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1025,7 +1025,8 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
Window* pParentWindow ):
SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
theSlotId( nSlotId ),
- aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
+ aColorSet ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
+ aDocColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
maCommand( rCommand )
{
@@ -1034,8 +1035,20 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
XColorListRef pColorList;
if ( pDocSh )
+ {
if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
pColorList = ( (SvxColorListItem*)pItem )->GetColorList();
+//-------- Add doc colors to palette
+ XColorEntry* pEntry;
+ std::vector<Color> aColors = pDocSh->GetDocColors();
+ for( unsigned int i = 0; i < aColors.size(); ++i )
+ {
+ pEntry = new XColorEntry( aColors[i],
+ "Document Color " + OUString::number(i) );
+ pColorList->Insert( pEntry, pColorList->Count() );
+ }
+//---------
+ }
if ( !pColorList.is() )
pColorList = XColorList::CreateStdColorList();
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 779df32d016a..99a2d5fc8c11 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -57,6 +57,7 @@
#include <vector>
#include <set>
#include <memory>
+#include <algorithm>
#include <boost/scoped_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
@@ -1777,6 +1778,8 @@ public:
*/
void dumpAsXml( xmlTextWriterPtr writer = NULL );
+ std::vector<Color> GetDocColors();
+
private:
// Copies master header to left / first one, if necessary - used by ChgPageDesc().
void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst);
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 4e03e15ad4ec..c2fc61b8a713 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -244,6 +244,8 @@ public:
sal_Int32 nFileFormat,
bool bTemplate = false ) const SAL_OVERRIDE;
+ virtual std::vector<Color> GetDocColors();
+
virtual void LoadStyles( SfxObjectShell& rSource ) SAL_OVERRIDE;
void _LoadStyles( SfxObjectShell& rSource, bool bPreserveCurrentDocument );
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 055bc4645450..89d720cec1df 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -26,6 +26,7 @@
#include <editeng/lrspitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <editeng/rsiditem.hxx>
+#include <editeng/colritem.hxx>
#include <svl/whiter.hxx>
#include <svl/zforlist.hxx>
#include <comphelper/processfactory.hxx>
@@ -1885,6 +1886,43 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const OUString & sNewName,
BroadcastStyleOperation(sNewName, eFamily, SFX_STYLESHEET_MODIFIED);
}
+
+std::vector<Color> SwDoc::GetDocColors()
+{
+ std::vector<Color> docColors;
+
+ for(unsigned int i = 0; i < m_pNodes->Count(); ++i)
+ {
+ const SwNode* pNode = (*m_pNodes)[i];
+ if( ! pNode->IsTxtNode() )
+ continue;
+
+ const SfxItemSet* pItemSet = pNode->GetTxtNode()->GetpSwAttrSet();
+ if( pItemSet == 0 )
+ continue;
+
+ SfxWhichIter aIter( *pItemSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == pItemSet->GetItemState( nWhich, false, &pItem ) &&
+ RES_CHRATR_COLOR == pItem->Which() )
+ {
+ 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;
+}
+
// #i69627#
namespace docfunc
{
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
index b9c27d8973f7..62bdef1d266a 100644
--- a/sw/source/uibase/app/docst.cxx
+++ b/sw/source/uibase/app/docst.cxx
@@ -1229,6 +1229,11 @@ sal_uInt16 SwDocShell::MakeByExample( const OUString &rName, sal_uInt16 nFamily,
return nFamily;
}
+std::vector<Color> SwDocShell::GetDocColors()
+{
+ return pDoc->GetDocColors();
+}
+
void SwDocShell::LoadStyles( SfxObjectShell& rSource )
{
_LoadStyles(rSource, false);