summaryrefslogtreecommitdiff
path: root/svx/source/tbxctrls/tbcontrl.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2013-04-16 08:41:07 +0000
committerArmin Le Grand <alg@apache.org>2013-04-16 08:41:07 +0000
commit68e707bbc6fe23881b822e6efab8a2933343dc1a (patch)
tree182e2fe8efee67cf005f8563574706d5878cf249 /svx/source/tbxctrls/tbcontrl.cxx
parent4413cf97c42cd2318bf10562715ae755dfccf104 (diff)
i122041 Unified and centralized control for Color ValueSets
Notes
Diffstat (limited to 'svx/source/tbxctrls/tbcontrl.cxx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx76
1 files changed, 16 insertions, 60 deletions
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 93f726ff5ef3..0e107532b830 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -815,10 +815,6 @@ void SvxFontNameBox_Impl::Select()
#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
#endif
-#define PALETTE_X 10
-#define PALETTE_Y 11
-#define PALETTE_SIZE (PALETTE_X * PALETTE_Y)
-
SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
sal_uInt16 nSlotId,
const Reference< XFrame >& rFrame,
@@ -836,7 +832,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
const SfxPoolItem* pItem = NULL;
XColorList* pColorTable = NULL;
sal_Bool bKillTable = sal_False;
- const Size aSize12( 13, 13 );
if ( pDocSh )
if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
@@ -877,43 +872,23 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
if ( pColorTable )
{
- short i = 0;
- long nCount = pColorTable->Count();
- XColorEntry* pEntry = NULL;
- ::Color aColWhite( COL_WHITE );
- String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) );
-
- if ( nCount > PALETTE_SIZE )
- // Show scrollbar if more than PALLETTE_SIZE colors are available
- aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL );
-
- for ( i = 0; i < nCount; i++ )
- {
- pEntry = pColorTable->GetColor(i);
- aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
- }
+ const long nColorCount(pColorTable->Count());
+ const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
+ aColorSet.SetOutputSizePixel(aNewSize);
+ static sal_Int32 nAdd = 4;
- while ( i < PALETTE_SIZE )
- {
- // fill empty elements if less then PALLETTE_SIZE colors are available
- aColorSet.InsertItem( i+1, aColWhite, aStrWhite );
- i++;
- }
+ SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
+ aColorSet.Clear();
+ aColorSet.addEntriesForXColorList(*pColorTable);
}
aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
- aColorSet.SetColCount( PALETTE_X );
- aColorSet.SetLineCount( PALETTE_Y );
-
- lcl_CalcSizeValueSet( *this, aColorSet, aSize12 );
-
SetHelpId( HID_POPUP_COLOR );
aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
-
SetText( rWndTitle );
aColorSet.Show();
-
AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
+
if ( bKillTable )
delete pColorTable;
}
@@ -1019,33 +994,14 @@ void SvxColorWindow_Impl::StateChanged( sal_uInt16 nSID, SfxItemState eState, co
if ( pColorTable )
{
// Die Liste der Farben (ColorTable) hat sich ge"andert:
- short i = 0;
- long nCount = pColorTable->Count();
- XColorEntry* pEntry = NULL;
- ::Color aColWhite( COL_WHITE );
- String aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE ) );
-
- // ScrollBar an oder aus
- WinBits nBits = aColorSet.GetStyle();
- if ( nCount > PALETTE_SIZE )
- nBits &= ~WB_VSCROLL;
- else
- nBits |= WB_VSCROLL;
- aColorSet.SetStyle( nBits );
-
- for ( i = 0; i < nCount; ++i )
- {
- pEntry = pColorTable->GetColor(i);
- aColorSet.SetItemColor( i + 1, pEntry->GetColor() );
- aColorSet.SetItemText ( i + 1, pEntry->GetName() );
- }
-
- while ( i < PALETTE_SIZE )
- {
- aColorSet.SetItemColor( i + 1, aColWhite );
- aColorSet.SetItemText ( i + 1, aStrWhite );
- i++;
- }
+ const long nColorCount(pColorTable->Count());
+ const Size aNewSize(aColorSet.layoutAllVisible(nColorCount));
+ aColorSet.SetOutputSizePixel(aNewSize);
+ static sal_Int32 nAdd = 4;
+
+ SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
+ aColorSet.Clear();
+ aColorSet.addEntriesForXColorList(*pColorTable);
}
}
}