From 0ac41beac1495e86b103889ffa8d2ba6bf64ddcd Mon Sep 17 00:00:00 2001 From: Krisztian Pinter Date: Thu, 3 Jul 2014 18:47:10 +0200 Subject: Add PaletteManager, refactor palette code Change-Id: I7e30fc895834318514b51bc648d32aa6d297bfae --- include/svx/Palette.hxx | 46 +++++++++++ include/svx/PaletteManager.hxx | 45 +++++++++++ include/svx/SvxColorValueSet.hxx | 13 +--- include/svx/tbcontrl.hxx | 5 +- svx/Library_svxcore.mk | 2 + svx/source/tbxctrls/Palette.cxx | 120 ++++++++++++++++++++++++++++ svx/source/tbxctrls/PaletteManager.cxx | 130 +++++++++++++++++++++++++++++++ svx/source/tbxctrls/SvxColorValueSet.cxx | 83 +------------------- svx/source/tbxctrls/colorwindow.hxx | 9 ++- svx/source/tbxctrls/tbcontrl.cxx | 78 ++++++------------- 10 files changed, 378 insertions(+), 153 deletions(-) create mode 100644 include/svx/Palette.hxx create mode 100644 include/svx/PaletteManager.hxx create mode 100644 svx/source/tbxctrls/Palette.cxx create mode 100644 svx/source/tbxctrls/PaletteManager.cxx diff --git a/include/svx/Palette.hxx b/include/svx/Palette.hxx new file mode 100644 index 000000000000..f7ced038c3e6 --- /dev/null +++ b/include/svx/Palette.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_PALETTE_HXX +#define INCLUDED_SVX_PALETTE_HXX + +#include +#include + +class Palette +{ +public: + typedef std::pair NamedColor; + typedef std::vector< NamedColor > ColorList; +private: + bool mbLoaded; + OUString maFname; + OString maName; + ColorList maColors; + + void LoadPalette(); +public: + Palette(const OUString &rFname); + + const OString& GetPaletteName(); + const ColorList& GetPaletteColors(); +}; + +#endif // INCLUDED_SVX_PALETTE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/PaletteManager.hxx b/include/svx/PaletteManager.hxx new file mode 100644 index 000000000000..a6b2dfa79317 --- /dev/null +++ b/include/svx/PaletteManager.hxx @@ -0,0 +1,45 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_PALETTEMANAGER_HXX +#define INCLUDED_SVX_PALETTEMANAGER_HXX + +#include +#include + +class PaletteManager +{ + sal_uInt16 mnNumOfPalettes; + sal_uInt16 mnCurrentPalette; + + long mnColorCount; + + std::vector maPalettes; +public: + PaletteManager(); + void LoadPalettes(); + void ReloadColorSet(SvxColorValueSet& rColorSet); + void PrevPalette(); + void NextPalette(); + long GetColorCount(); + OUString GetPaletteName(); +}; + +#endif // INCLUDED_SVX_PALETTEMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/SvxColorValueSet.hxx b/include/svx/SvxColorValueSet.hxx index 77ad9b294ff6..7db9f4c38a6e 100644 --- a/include/svx/SvxColorValueSet.hxx +++ b/include/svx/SvxColorValueSet.hxx @@ -19,21 +19,12 @@ #ifndef INCLUDED_SVX_SVXCOLORVALUESET_HXX #define INCLUDED_SVX_SVXCOLORVALUESET_HXX +#include #include #include class XColorList; -struct Palette -{ - typedef std::pair NamedColor; - typedef std::vector< NamedColor > ColorList; - Palette(){}; - Palette(const OUString &rFname); - OString maName; - ColorList maColors; -}; - class SVX_DLLPUBLIC SvxColorValueSet : public ValueSet { private: @@ -50,7 +41,7 @@ public: void addEntriesForXColorList(const XColorList& rXColorList, sal_uInt32 nStartIndex = 1); void loadColorVector(const std::vector& rColorVector, const OUString& rNamePrefix, sal_uInt32 nStartIndex = 1); - void loadPalette(const Palette& rPalette); + void loadPalette(Palette& rPalette); Size layoutAllVisible(sal_uInt32 nEntryCount); Size layoutToGivenHeight(sal_uInt32 nHeight, sal_uInt32 nEntryCount); }; diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index b1b578f6548f..6d9975f46110 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -133,6 +133,7 @@ #include #include #include +#include // important im tbxctrls.hxx created HeDaBu !!! class SvxLineItem; @@ -221,7 +222,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public SfxToolBoxControl ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater; Color mLastColor; - sal_uInt16 nCurrentPalette; + PaletteManager mrPaletteManager; DECL_LINK( SelectedHdl, Color* ); public: SFX_DECL_TOOLBOX_CONTROL(); @@ -242,7 +243,7 @@ class SVX_DLLPUBLIC SvxLineColorToolBoxControl : public SfxToolBoxControl { ::boost::scoped_ptr< ::svx::ToolboxButtonColorUpdater > pBtnUpdater; Color mLastColor; - sal_uInt16 nCurrentPalette; + PaletteManager mrPaletteManager; DECL_LINK( SelectedHdl, Color* ); public: SFX_DECL_TOOLBOX_CONTROL(); diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index 960650b431c0..831d4f5f3fcd 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -343,6 +343,8 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/table/viewcontactoftableobj \ svx/source/tbxctrls/extrusioncontrols \ svx/source/tbxctrls/fontworkgallery \ + svx/source/tbxctrls/Palette \ + svx/source/tbxctrls/PaletteManager \ svx/source/tbxctrls/tbcontrl \ svx/source/tbxctrls/tbxcolorupdate \ svx/source/tbxctrls/SvxColorValueSet \ diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx new file mode 100644 index 000000000000..aebb7f0fa48d --- /dev/null +++ b/svx/source/tbxctrls/Palette.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +// finds first token in rStr from index, separated by whitespace +// returns position of next token in index +OString lcl_getToken(const OString& rStr, sal_Int32& index) +{ + sal_Int32 substart, toklen = 0; + + while(index < rStr.getLength() && + (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t')) + ++index; + if(index == rStr.getLength()) + { + index = -1; + return OString(); + } + substart = index; + + while(index < rStr.getLength() && + !(rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t')) + { + ++index; + ++toklen; + } + + while(index < rStr.getLength() && + (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t')) + ++index; + if(index == rStr.getLength()) + index = -1; + + return rStr.copy(substart, toklen); +} + +Palette::Palette(const OUString &rFname) : + mbLoaded( false ), + maFname( rFname ){} + +const OString& Palette::GetPaletteName() +{ + LoadPalette(); + return maName; +} + +const Palette::ColorList& Palette::GetPaletteColors() +{ + LoadPalette(); + return maColors; +} + +void Palette::LoadPalette() +{ + if( mbLoaded ) return; + + mbLoaded = true; + + // TODO add error handling!!! + SvFileStream aFile(maFname, STREAM_READ); + + OString aLine; + + aFile.ReadLine(aLine); + if( !aLine.startsWith("GIMP Palette") ) return; + aFile.ReadLine(aLine); + if( aLine.startsWith("Name: ", &maName) ) + { + aFile.ReadLine(aLine); + if( aLine.startsWith("Columns: ")) + aFile.ReadLine(aLine); // we can ignore this + } + + do { + if (aLine[0] != '#' && aLine[0] != '\n') + { + // TODO check if r,g,b are 0<= x <=255, or just clamp? + sal_Int32 nIndex = 0; + OString token; + + token = lcl_getToken(aLine, nIndex); + if(token == "" || nIndex == -1) continue; + sal_Int32 r = token.toInt32(); + + token = lcl_getToken(aLine, nIndex); + if(token == "" || nIndex == -1) continue; + sal_Int32 g = token.toInt32(); + + token = lcl_getToken(aLine, nIndex); + if(token == "") continue; + sal_Int32 b = token.toInt32(); + + OString name; + if(nIndex != -1) + name = aLine.copy(nIndex); + + maColors.push_back(std::make_pair(Color(r, g, b), name)); + } + } while (aFile.ReadLine(aLine)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx new file mode 100644 index 000000000000..88916ee85fc7 --- /dev/null +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include "svx/drawitem.hxx" +#include + +PaletteManager::PaletteManager() : + mnNumOfPalettes(2), + mnCurrentPalette(0), + mnColorCount(0) +{ + LoadPalettes(); + mnNumOfPalettes += maPalettes.size(); +} + +void PaletteManager::LoadPalettes() +{ + OUString aPalPath = SvtPathOptions().GetPalettePath(); + + osl::Directory aDir(aPalPath); + maPalettes.clear(); + osl::DirectoryItem aDirItem; + osl::FileStatus aFileStat(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type); + if( aDir.open() == osl::FileBase::E_None ) + { + while( aDir.getNextItem(aDirItem) == osl::FileBase::E_None ) + { + aDirItem.getFileStatus(aFileStat); + if(aFileStat.isRegular() || aFileStat.isLink()) + { + OUString aPath = aFileStat.getFileURL(); + if(aPath.getLength() > 4 && + aPath.copy(aPath.getLength()-4).toAsciiLowerCase() == ".gpl") + { + maPalettes.push_back(Palette(aPath)); + } + } + } + } +} + +void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet) +{ + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + + if( mnCurrentPalette == 0 ) + { + const SfxPoolItem* pItem = NULL; + XColorListRef pColorList; + + if ( pDocSh ) + { + if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) + pColorList = ( (SvxColorListItem*)pItem )->GetColorList(); + } + + if ( !pColorList.is() ) + pColorList = XColorList::CreateStdColorList(); + + + if ( pColorList.is() ) + { + mnColorCount = pColorList->Count(); + rColorSet.Clear(); + rColorSet.addEntriesForXColorList(*pColorList); + } + } + else if( mnCurrentPalette == mnNumOfPalettes - 1 ) + { + // Add doc colors to palette + std::vector aColors = pDocSh->GetDocColors(); + mnColorCount = aColors.size(); + rColorSet.Clear(); + rColorSet.loadColorVector(aColors, "Document Color "); + } + else + { + Palette& rPal = maPalettes[mnCurrentPalette-1]; + mnColorCount = rPal.GetPaletteColors().size(); + rColorSet.Clear(); + rColorSet.loadPalette(rPal); + } +} + +void PaletteManager::PrevPalette() +{ + mnCurrentPalette = mnCurrentPalette == 0 ? mnNumOfPalettes - 1 : mnCurrentPalette - 1; +} + +void PaletteManager::NextPalette() +{ + mnCurrentPalette = mnCurrentPalette == mnNumOfPalettes - 1 ? 0 : mnCurrentPalette + 1; +} + +long PaletteManager::GetColorCount() +{ + return mnColorCount; +} + +OUString PaletteManager::GetPaletteName() +{ + if( mnCurrentPalette == 0 ) + return OUString("Default palette"); + else if( mnCurrentPalette == mnNumOfPalettes - 1 ) + return OUString("Document colors"); + else + return OStringToOUString(maPalettes[mnCurrentPalette - 1].GetPaletteName(), RTL_TEXTENCODING_ASCII_US); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/SvxColorValueSet.cxx b/svx/source/tbxctrls/SvxColorValueSet.cxx index dc2f2c23d89e..e33810946d3b 100644 --- a/svx/source/tbxctrls/SvxColorValueSet.cxx +++ b/svx/source/tbxctrls/SvxColorValueSet.cxx @@ -23,85 +23,6 @@ #include #include - -// finds first token in rStr from index, separated by whitespace -// returns position of next token in index -OString lcl_getToken(const OString& rStr, sal_Int32& index) -{ - sal_Int32 substart, toklen = 0; - - while(index < rStr.getLength() && - (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t')) - ++index; - if(index == rStr.getLength()) - { - index = -1; - return OString(); - } - substart = index; - - while(index < rStr.getLength() && - !(rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t')) - { - ++index; - ++toklen; - } - - while(index < rStr.getLength() && - (rStr[index] == ' ' || rStr[index] == '\n' || rStr[index] == '\t')) - ++index; - if(index == rStr.getLength()) - index = -1; - - return rStr.copy(substart, toklen); -} - -Palette::Palette(const OUString &rFname) -{ - // TODO add error handling!!! - SvFileStream aFile(rFname, STREAM_READ); - - OString aPaletteName; - OString aLine; - - aFile.ReadLine(aLine); - if( !aLine.startsWith("GIMP Palette") ) return; - aFile.ReadLine(aLine); - if( aLine.startsWith("Name: ", &aPaletteName) ) - { - aFile.ReadLine(aLine); - if( aLine.startsWith("Columns: ")) - aFile.ReadLine(aLine); // we can ignore this - } - - do { - if (aLine[0] != '#' && aLine[0] != '\n') - { - // TODO check if r,g,b are 0<= x <=255, or just clamp? - sal_Int32 nIndex = 0; - OString token; - - token = lcl_getToken(aLine, nIndex); - if(token == "" || nIndex == -1) continue; - sal_Int32 r = token.toInt32(); - - token = lcl_getToken(aLine, nIndex); - if(token == "" || nIndex == -1) continue; - sal_Int32 g = token.toInt32(); - - token = lcl_getToken(aLine, nIndex); - if(token == "") continue; - sal_Int32 b = token.toInt32(); - - OString name; - if(nIndex != -1) - name = aLine.copy(nIndex); - - maColors.push_back(std::make_pair(Color(r, g, b), name)); - } - } while (aFile.ReadLine(aLine)); -} - SvxColorValueSet::SvxColorValueSet(Window* _pParent, WinBits nWinStyle) : ValueSet(_pParent, nWinStyle) { @@ -186,9 +107,9 @@ void SvxColorValueSet::loadColorVector(const std::vector& rColorVector, c } -void SvxColorValueSet::loadPalette(const Palette& rPalette) +void SvxColorValueSet::loadPalette(Palette& rPalette) { - const Palette::ColorList &rColors = rPalette.maColors; + const Palette::ColorList &rColors = rPalette.GetPaletteColors(); Clear(); int nIx = 1; for(Palette::ColorList::const_iterator it = rColors.begin(); diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx index c6999860d535..5a700c7297a8 100644 --- a/svx/source/tbxctrls/colorwindow.hxx +++ b/svx/source/tbxctrls/colorwindow.hxx @@ -29,6 +29,7 @@ #include #include #include +#include // class SvxColorWindow_Impl -------------------------------------------------- @@ -43,15 +44,15 @@ private: SvxColorValueSet aColorSet; PushButton aButtonLeft; PushButton aButtonRight; + FixedText aPaletteName; OUString maCommand; Link maSelectedLink; const sal_uInt16 nNavButtonWidth; const sal_uInt16 nNavButtonHeight; - sal_uInt16& rnCurrentPalette; - sal_uInt16 nNumOfPalettes; + PaletteManager& mrPaletteManager; - void ReloadColorSet(); + void Update(); DECL_LINK( SelectHdl, void * ); DECL_LINK( StepLeftClickHdl, void * ); @@ -63,7 +64,7 @@ protected: public: SvxColorWindow_Impl( const OUString& rCommand, - sal_uInt16& rnCurrentPalette_, + PaletteManager& rPaletteManager, sal_uInt16 nSlotId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const OUString& rWndTitle, diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index da69d77b145c..179355223023 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -31,11 +31,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -1019,7 +1017,7 @@ void SvxFontNameBox_Impl::Select() #endif SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, - sal_uInt16& rnCurrentPalette_, + PaletteManager& rPaletteManager, sal_uInt16 nSlotId, const Reference< XFrame >& rFrame, const OUString& rWndTitle, @@ -1029,11 +1027,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, aColorSet ( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ), aButtonLeft ( this ), aButtonRight( this ), + aPaletteName( this ), maCommand( rCommand ), nNavButtonWidth ( 20 ), nNavButtonHeight( 20 ), - rnCurrentPalette( rnCurrentPalette_ ), - nNumOfPalettes( 1 ) + mrPaletteManager( rPaletteManager ) { if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) @@ -1067,9 +1065,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, aColorSet.SetAccessibleName( SVX_RESSTR( RID_SVXSTR_LINECOLOR ) ); } - if( SfxObjectShell::Current()->GetDocColors().size() > 0 ) - nNumOfPalettes++; - aButtonLeft.SetText("<"); aButtonLeft.SetClickHdl( LINK( this, SvxColorWindow_Impl, StepLeftClickHdl ) ); aButtonLeft.Show(); @@ -1084,49 +1079,20 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand, SetText( rWndTitle ); aColorSet.Show(); + aPaletteName.Show(); + AddStatusListener( OUString( ".uno:ColorTableState" )); AddStatusListener( maCommand ); - ReloadColorSet(); + Update(); } -void SvxColorWindow_Impl::ReloadColorSet() -{ - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - long nColorCount = 0; - - if( rnCurrentPalette == 0 ) - { - const SfxPoolItem* pItem = NULL; - XColorListRef pColorList; - - if ( pDocSh ) - { - if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) - pColorList = ( (SvxColorListItem*)pItem )->GetColorList(); - } - - if ( !pColorList.is() ) - pColorList = XColorList::CreateStdColorList(); - - if ( pColorList.is() ) - { - nColorCount = pColorList->Count(); - aColorSet.Clear(); - aColorSet.addEntriesForXColorList(*pColorList); - } - } - else if( rnCurrentPalette == nNumOfPalettes - 1 ) - { - // Add doc colors to palette - std::vector aColors = pDocSh->GetDocColors(); - nColorCount = aColors.size(); - aColorSet.Clear(); - aColorSet.addEntriesForColorVector(aColors); - } +void SvxColorWindow_Impl::Update() +{ + mrPaletteManager.ReloadColorSet(aColorSet); - const Size aNewSize(aColorSet.layoutAllVisible(nColorCount)); + const Size aNewSize(aColorSet.layoutAllVisible(mrPaletteManager.GetColorCount())); aColorSet.SetOutputSizePixel(aNewSize); static sal_Int32 nAdd = 4; @@ -1138,6 +1104,10 @@ void SvxColorWindow_Impl::ReloadColorSet() aButtonRight.SetSizePixel(Size(nNavButtonWidth, nNavButtonHeight)); aButtonRight.SetPosPixel(Point(aNewSize.Width() + nAdd - nNavButtonWidth, aNewSize.Height() + nAdd + 1)); + + aPaletteName.SetSizePixel(Size(150, nNavButtonHeight)); + aPaletteName.SetPosPixel(Point(nNavButtonWidth, aNewSize.Height() + nAdd + 1)); + aPaletteName.SetText(mrPaletteManager.GetPaletteName()); } SvxColorWindow_Impl::~SvxColorWindow_Impl() @@ -1151,7 +1121,7 @@ void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt ) SfxPopupWindow* SvxColorWindow_Impl::Clone() const { - return new SvxColorWindow_Impl( maCommand, rnCurrentPalette, theSlotId, GetFrame(), GetText(), GetParent() ); + return new SvxColorWindow_Impl( maCommand, mrPaletteManager, theSlotId, GetFrame(), GetText(), GetParent() ); } IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl) @@ -1193,15 +1163,15 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl) IMPL_LINK_NOARG(SvxColorWindow_Impl, StepLeftClickHdl) { - rnCurrentPalette = (rnCurrentPalette - 1) % nNumOfPalettes; - ReloadColorSet(); + mrPaletteManager.PrevPalette(); + Update(); return 0; } IMPL_LINK_NOARG(SvxColorWindow_Impl, StepRightClickHdl) { - rnCurrentPalette = (rnCurrentPalette + 1) % nNumOfPalettes; - ReloadColorSet(); + mrPaletteManager.NextPalette(); + Update(); return 0; } @@ -2238,8 +2208,7 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( sal_uInt16 nId, ToolBox& rTbx ) : SfxToolBoxControl( nSlotId, nId, rTbx ), - mLastColor( COL_AUTO ), - nCurrentPalette( 0 ) + mLastColor( COL_AUTO ) { rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); @@ -2293,7 +2262,7 @@ SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow() SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl( m_aCommandURL, - nCurrentPalette, + mrPaletteManager, GetSlotId(), m_xFrame, SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ), @@ -2401,8 +2370,7 @@ SvxLineColorToolBoxControl::SvxLineColorToolBoxControl( ToolBox& rTbx ) : SfxToolBoxControl( nSlotId, nId, rTbx ), - mLastColor( COL_BLACK ), - nCurrentPalette( 0 ) + mLastColor( COL_BLACK ) { rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); addStatusListener( OUString( ".uno:XLineColor" ) ); @@ -2423,7 +2391,7 @@ SfxPopupWindow* SvxLineColorToolBoxControl::CreatePopupWindow() SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl( m_aCommandURL, - nCurrentPalette, + mrPaletteManager, GetSlotId(), m_xFrame, SVX_RESSTR( RID_SVXSTR_LINECOLOR ), -- cgit v1.2.3