openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1468340 - in /openoffice/trunk/main: cui/source/inc/ cui/source/tabpages/ sd/source/ui/app/ sd/source/ui/slideshow/ sd/source/ui/view/ svx/ svx/inc/svx/ svx/inc/svx/sidebar/ svx/source/sidebar/tools/ svx/source/tbxctrls/
Date Tue, 16 Apr 2013 09:41:07 GMT
Author: alg
Date: Tue Apr 16 09:41:07 2013
New Revision: 1468340

URL: http://svn.apache.org/r1468340
Log:
i122041 Unified and centralized control for Color ValueSets

Modified:
    openoffice/trunk/main/cui/source/inc/backgrnd.hxx
    openoffice/trunk/main/cui/source/inc/cuitabarea.hxx
    openoffice/trunk/main/cui/source/tabpages/backgrnd.cxx
    openoffice/trunk/main/cui/source/tabpages/tpcolor.cxx
    openoffice/trunk/main/sd/source/ui/app/sddll2.cxx
    openoffice/trunk/main/sd/source/ui/slideshow/slideshowimpl.cxx
    openoffice/trunk/main/sd/source/ui/view/drviews6.cxx
    openoffice/trunk/main/sd/source/ui/view/drvwshrg.cxx
    openoffice/trunk/main/svx/Library_svx.mk
    openoffice/trunk/main/svx/Library_svxcore.mk
    openoffice/trunk/main/svx/Package_inc.mk
    openoffice/trunk/main/svx/inc/svx/colrctrl.hxx
    openoffice/trunk/main/svx/inc/svx/sidebar/ColorControl.hxx
    openoffice/trunk/main/svx/source/sidebar/tools/ColorControl.cxx
    openoffice/trunk/main/svx/source/tbxctrls/colorwindow.hxx
    openoffice/trunk/main/svx/source/tbxctrls/colrctrl.cxx
    openoffice/trunk/main/svx/source/tbxctrls/tbcontrl.cxx

Modified: openoffice/trunk/main/cui/source/inc/backgrnd.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cui/source/inc/backgrnd.hxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/cui/source/inc/backgrnd.hxx (original)
+++ openoffice/trunk/main/cui/source/inc/backgrnd.hxx Tue Apr 16 09:41:07 2013
@@ -32,7 +32,7 @@
 #ifndef _GRAPH_HXX //autogen
 #include <vcl/graph.hxx>
 #endif
-#include <svtools/valueset.hxx>
+#include <svx/SvxColorValueSet.hxx>
 #include <svx/dlgctrl.hxx>
 
 // class SvxBackgroundTabPage --------------------------------------------
@@ -89,7 +89,7 @@ private:
      ListBox		         aParaLBox;
 	// Hintergrundfarbe ------------------------------------
 	Control					aBorderWin;
-	ValueSet                aBackgroundColorSet;
+	SvxColorValueSet        aBackgroundColorSet;
     FixedLine               aBackgroundColorBox;
 	BackgroundPreviewImpl*  pPreviewWin1;
     //color transparency

Modified: openoffice/trunk/main/cui/source/inc/cuitabarea.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cui/source/inc/cuitabarea.hxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/cui/source/inc/cuitabarea.hxx (original)
+++ openoffice/trunk/main/cui/source/inc/cuitabarea.hxx Tue Apr 16 09:41:07 2013
@@ -26,6 +26,7 @@
 // include ---------------------------------------------------------------
 
 #include <svx/tabarea.hxx>
+#include <svx/SvxColorValueSet.hxx>
 
 /*************************************************************************
 |*
@@ -698,7 +699,7 @@ private:
 	ColorLB             aLbColor;
 
     FixedText           aTableNameFT;
-    ValueSet            aValSetColorTable;
+    SvxColorValueSet    aValSetColorTable;
 
     SvxXRectPreview     aCtlPreviewOld;
 	SvxXRectPreview     aCtlPreviewNew;
@@ -749,7 +750,8 @@ private:
 	sal_uInt16  ColorToPercent_Impl( sal_uInt16 nColor );
 	sal_uInt16  PercentToColor_Impl( sal_uInt16 nPercent );
 
-	void    FillValueSet_Impl( ValueSet& rVs );
+    void ImpColorCountChanged();
+
 	//-----------------------------------------------------------------------------------------------------
 	DECL_LINK( ClickAddHdl_Impl, void * );		// Button 'Hinzufuegen'
 	DECL_LINK( ClickModifyHdl_Impl, void * );	// Button 'Aendern'

Modified: openoffice/trunk/main/cui/source/tabpages/backgrnd.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cui/source/tabpages/backgrnd.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/cui/source/tabpages/backgrnd.cxx (original)
+++ openoffice/trunk/main/cui/source/tabpages/backgrnd.cxx Tue Apr 16 09:41:07 2013
@@ -401,6 +401,9 @@ SvxBackgroundTabPage::SvxBackgroundTabPa
 	FillColorValueSets_Impl();
 
 	aBackgroundColorSet.SetSelectHdl( HDL(BackgroundColorHdl_Impl) );
+    aBackgroundColorSet.SetStyle(aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD
| WB_NONEFIELD);
+	aBackgroundColorSet.SetText(SVX_RESSTR(RID_SVXSTR_TRANSPARENT));
+	aBackgroundColorSet.SetAccessibleName(aBackgroundColorBox.GetText());
 	FreeResource();
 
 	aBtnBrowse.SetAccessibleRelationMemberOf(&aGbFile);
@@ -1195,54 +1198,50 @@ void SvxBackgroundTabPage::FillColorValu
 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
 	const SfxPoolItem* pItem = NULL;
 	XColorList* pColorTable = NULL;
-	const Size aSize15x15 = Size( 15, 15 );
-	FASTBOOL bOwn = sal_False;
+	bool bOwn(false);
+    long nColorCount(0);
 
 	if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) )
+    {
 		pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+    }
 
 	if ( !pColorTable )
 	{
-		bOwn = sal_True;
+		bOwn = true;
 		pColorTable = new XColorList( SvtPathOptions().GetPalettePath() );
 	}
 
 	if ( pColorTable )
 	{
-		short i	= 0;
-		long nCount	= pColorTable->Count();
-		XColorEntry* pEntry	= NULL;
-		Color aColWhite( COL_WHITE );
-		String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
-		WinBits nBits = ( aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD
);
-		aBackgroundColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
-		aBackgroundColorSet.SetStyle( nBits );
-		aBackgroundColorSet.SetAccessibleName(aBackgroundColorBox.GetText());
-		for ( i = 0; i < nCount; i++ )
-		{
-            pEntry = pColorTable->GetColor(i);
-			aBackgroundColorSet.InsertItem(	i + 1, pEntry->GetColor(), pEntry->GetName() );
-		}
+        nColorCount = pColorTable->Count();
+        aBackgroundColorSet.Clear();
+        aBackgroundColorSet.addEntriesForXColorList(*pColorTable);
 
-		while ( i < 80 )
-		{
-			aBackgroundColorSet.InsertItem( i + 1, aColWhite, aStrWhite );
-			i++;
-		}
-
-		if ( nCount > 80 )
-		{
-			aBackgroundColorSet.SetStyle( nBits | WB_VSCROLL );
-		}
-	}
-
-	if ( bOwn )
-		delete pColorTable;
-
-	aBackgroundColorSet.SetColCount( 10 );
-	aBackgroundColorSet.SetLineCount( 10 );
-	aBackgroundColorSet.CalcWindowSizePixel( aSize15x15 );
+        if(bOwn)
+        {
+		    delete pColorTable;
+        }
+    }
 
+	const WinBits nBits(aBackgroundColorSet.GetStyle() | WB_ITEMBORDER | WB_NAMEFIELD | WB_NONEFIELD);
+	aBackgroundColorSet.SetStyle(nBits);
+    aBackgroundColorSet.SetColCount(aBackgroundColorSet.getColumnCount());
+
+    // here we have enough space to the left, so layout with fixed column size
+    // and fixed height, adapt width. Apply the adapted width by moving the left
+    // edge of the control to the left, keeping the right edge aligned
+    // with the original position
+    const Point aCurrentPosContainer(aBorderWin.GetPosPixel());
+    const Size aCurrentSizeContainer(aBorderWin.GetOutputSizePixel());
+    const Size aCurrentSizeContent(aBackgroundColorSet.GetOutputSizePixel());
+    const Size aNewSizeContent(aBackgroundColorSet.layoutToGivenHeight(aCurrentSizeContent.Height()
- 4, nColorCount));
+    const Size aNewSizeContainer(aNewSizeContent.Width() + 4, aNewSizeContent.Height() +
4);
+    const Point aNewPos((aCurrentPosContainer.X() + aCurrentSizeContainer.Width()) - aNewSizeContainer.Width(),
aCurrentPosContainer.Y());
+
+    aBorderWin.SetOutputSizePixel(aNewSizeContainer);
+    aBackgroundColorSet.SetOutputSizePixel(aNewSizeContent);
+    aBorderWin.SetPosSizePixel(aNewPos, aNewSizeContainer);
 }
 
 //------------------------------------------------------------------------

Modified: openoffice/trunk/main/cui/source/tabpages/tpcolor.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cui/source/tabpages/tpcolor.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/cui/source/tabpages/tpcolor.cxx (original)
+++ openoffice/trunk/main/cui/source/tabpages/tpcolor.cxx Tue Apr 16 09:41:07 2013
@@ -163,10 +163,7 @@ SvxColorTabPage::SvxColorTabPage
 	aBtnSave.SetClickHdl( LINK( this, SvxColorTabPage, ClickSaveHdl_Impl ) );
 
 	// ValueSet
-	aValSetColorTable.SetStyle( aValSetColorTable.GetStyle() | WB_VSCROLL | WB_ITEMBORDER );
-	aValSetColorTable.SetColCount( 8 );
-	aValSetColorTable.SetLineCount( 10 );
-	aValSetColorTable.SetExtraSpacing( 0 );
+	aValSetColorTable.SetStyle( aValSetColorTable.GetStyle() | WB_ITEMBORDER );
 	aValSetColorTable.Show();
 
 	aLbColorModel.SetAccessibleName( String( CUI_RES(STR_CUI_COLORMODEL) ) ); 
@@ -178,10 +175,37 @@ SvxColorTabPage::SvxColorTabPage
 
 // -----------------------------------------------------------------------
 
+void SvxColorTabPage::ImpColorCountChanged()
+{
+    if(pColorTab)
+    {
+        aValSetColorTable.SetColCount(aValSetColorTable.getColumnCount());
+
+        // here we have enough space to the left, so layout with fixed column size
+        // and fixed height, adapt width. Apply the adapted width by moving the left
+        // edge of the control to the left, keeping the right edge aligned
+        // with the original position
+        const Point aCurrentPos(aValSetColorTable.GetPosPixel());
+        const Size aCurrentSize(aValSetColorTable.GetOutputSizePixel());
+        const long nColorCount(pColorTab->Count());
+        const Size aNewSize(aValSetColorTable.layoutToGivenHeight(aCurrentSize.Height(),
nColorCount));
+        const Point aNewPos((aCurrentPos.X() + aCurrentSize.Width()) - aNewSize.Width(),
aCurrentPos.Y());
+
+        aValSetColorTable.SetOutputSizePixel(aNewSize);
+        aValSetColorTable.SetPosSizePixel(aNewPos, aNewSize);
+    }
+}
+
+// -----------------------------------------------------------------------
+
 void SvxColorTabPage::Construct()
 {
-	aLbColor.Fill( pColorTab );
-	FillValueSet_Impl( aValSetColorTable );
+    if(pColorTab)
+    {
+        aLbColor.Fill(pColorTab);
+        aValSetColorTable.addEntriesForXColorList(*pColorTab);
+        ImpColorCountChanged();
+    }
 }
 
 // -----------------------------------------------------------------------
@@ -529,6 +553,7 @@ IMPL_LINK( SvxColorTabPage, ClickAddHdl_
 		aLbColor.Append( pEntry );
 		aValSetColorTable.InsertItem( aValSetColorTable.GetItemCount() + 1,
 				pEntry->GetColor(), pEntry->GetName() );
+        ImpColorCountChanged();
 
 		aLbColor.SelectEntryPos( aLbColor.GetEntryCount() - 1 );
 
@@ -704,7 +729,9 @@ IMPL_LINK( SvxColorTabPage, ClickDeleteH
 			// Listbox und ValueSet aktualisieren
 			aLbColor.RemoveEntry( nPos );
 			aValSetColorTable.Clear();
-			FillValueSet_Impl( aValSetColorTable );
+            aValSetColorTable.addEntriesForXColorList(*pColorTab);
+            ImpColorCountChanged();
+			//FillValueSet_Impl( aValSetColorTable );
 
 			// Positionieren
 			aLbColor.SelectEntryPos( nPos );
@@ -1162,17 +1189,17 @@ long SvxColorTabPage::ChangeColorHdl_Imp
 
 //------------------------------------------------------------------------
 
-void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
-{
-	long nCount = pColorTab->Count();
-	XColorEntry* pColorEntry;
-
-	for( long i = 0; i < nCount; i++ )
-	{
-        pColorEntry = pColorTab->GetColor( i );
-		rVs.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName()
);
-	}
-}
+//void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
+//{
+//	long nCount = pColorTab->Count();
+//	XColorEntry* pColorEntry;
+//
+//	for( long i = 0; i < nCount; i++ )
+//	{
+//        pColorEntry = pColorTab->GetColor( i );
+//		rVs.InsertItem( (sal_uInt16) i + 1, pColorEntry->GetColor(), pColorEntry->GetName()
);
+//	}
+//}
 
 //------------------------------------------------------------------------
 

Modified: openoffice/trunk/main/sd/source/ui/app/sddll2.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/app/sddll2.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/app/sddll2.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/app/sddll2.cxx Tue Apr 16 09:41:07 2013
@@ -37,7 +37,7 @@
 #include <svx/galbrws.hxx>
 #include <svx/srchdlg.hxx>
 #include <svx/fontwork.hxx>
-#include <svx/colrctrl.hxx>
+#include <svx/SvxColorChildWindow.hxx>
 #include <svx/verttexttbxctrl.hxx>
 #include <svx/hyprlink.hxx>
 #include <svx/hyperdlg.hxx>

Modified: openoffice/trunk/main/sd/source/ui/slideshow/slideshowimpl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/slideshow/slideshowimpl.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/slideshow/slideshowimpl.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/slideshow/slideshowimpl.cxx Tue Apr 16 09:41:07 2013
@@ -56,7 +56,7 @@
 #include <svx/f3dchild.hxx>
 #include <svx/imapdlg.hxx>
 #include <svx/fontwork.hxx>
-#include <svx/colrctrl.hxx>
+#include <svx/SvxColorChildWindow.hxx>
 #include <svx/bmpmask.hxx>
 #include <svx/srchdlg.hxx>
 #include <svx/hyprlink.hxx>

Modified: openoffice/trunk/main/sd/source/ui/view/drviews6.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/view/drviews6.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/view/drviews6.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/view/drviews6.cxx Tue Apr 16 09:41:07 2013
@@ -46,7 +46,7 @@
 #ifndef _IMAPDLG_HXX
 #include <svx/imapdlg.hxx>
 #endif
-#include <svx/colrctrl.hxx>
+#include <svx/SvxColorChildWindow.hxx>
 #include <svx/f3dchild.hxx>
 #include "optsitem.hxx"
 #include <svx/extrusionbar.hxx>

Modified: openoffice/trunk/main/sd/source/ui/view/drvwshrg.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sd/source/ui/view/drvwshrg.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/sd/source/ui/view/drvwshrg.cxx (original)
+++ openoffice/trunk/main/sd/source/ui/view/drvwshrg.cxx Tue Apr 16 09:41:07 2013
@@ -31,7 +31,7 @@
 #include <svx/bmpmask.hxx>
 #include <svx/galbrws.hxx>
 #include <svx/imapdlg.hxx>
-#include <svx/colrctrl.hxx>
+#include <svx/SvxColorChildWindow.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/sidebar/SidebarChildWindow.hxx>
 #include <svx/f3dchild.hxx>

Modified: openoffice/trunk/main/svx/Library_svx.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/Library_svx.mk?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/Library_svx.mk (original)
+++ openoffice/trunk/main/svx/Library_svx.mk Tue Apr 16 09:41:07 2013
@@ -227,6 +227,7 @@ $(eval $(call gb_Library_add_exception_o
     svx/source/table/tablertfexporter \
     svx/source/table/tablertfimporter \
     svx/source/tbxctrls/colrctrl \
+    svx/source/tbxctrls/SvxColorChildWindow \
     svx/source/tbxctrls/fillctrl \
     svx/source/tbxctrls/formatpaintbrushctrl \
     svx/source/tbxctrls/grafctrl \

Modified: openoffice/trunk/main/svx/Library_svxcore.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/Library_svxcore.mk?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/Library_svxcore.mk (original)
+++ openoffice/trunk/main/svx/Library_svxcore.mk Tue Apr 16 09:41:07 2013
@@ -385,6 +385,7 @@ $(eval $(call gb_Library_add_exception_o
     svx/source/tbxctrls/fontworkgallery \
     svx/source/tbxctrls/tbcontrl \
     svx/source/tbxctrls/tbxcolorupdate \
+    svx/source/tbxctrls/SvxColorValueSet \
     svx/source/toolbars/extrusionbar \
     svx/source/toolbars/fontworkbar \
     svx/source/unodraw/gluepts \

Modified: openoffice/trunk/main/svx/Package_inc.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/Package_inc.mk?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/Package_inc.mk (original)
+++ openoffice/trunk/main/svx/Package_inc.mk Tue Apr 16 09:41:07 2013
@@ -552,7 +552,8 @@ $(eval $(call gb_Package_add_file,svx_in
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdtaaitm.hxx,svx/sdtaaitm.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/fmview.hxx,svx/fmview.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/svxdllapi.h,svx/svxdllapi.h))
-$(eval $(call gb_Package_add_file,svx_inc,inc/svx/colrctrl.hxx,svx/colrctrl.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/SvxColorValueSet.hxx,svx/SvxColorValueSet.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/SvxColorChildWindow.hxx,svx/SvxColorChildWindow.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/fmdpage.hxx,svx/fmdpage.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sxmtpitm.hxx,svx/sxmtpitm.hxx))
 $(eval $(call gb_Package_add_file,svx_inc,inc/svx/globlmn.hrc,globlmn_tmpl.hrc))

Modified: openoffice/trunk/main/svx/inc/svx/colrctrl.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/colrctrl.hxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/colrctrl.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/colrctrl.hxx Tue Apr 16 09:41:07 2013
@@ -25,7 +25,7 @@
 
 #include <sfx2/dockwin.hxx>
 #include <sfx2/childwin.hxx>
-#include <svtools/valueset.hxx>
+#include <svx/SvxColorValueSet.hxx>
 #include <svtools/transfer.hxx>
 #include <svl/lstner.hxx>
 #include "svx/svxdllapi.h"
@@ -35,17 +35,16 @@ class SvData;
 
 /*************************************************************************
 |*
-|* SvxColorValueSet
+|* SvxColorValueSet_docking
 |*
 \************************************************************************/
 
-class SvxColorValueSet : public ValueSet, public DragSourceHelper
+class SvxColorValueSet_docking : public SvxColorValueSet, public DragSourceHelper
 {
-	using ValueSet::StartDrag;
-
 private:
+    using SvxColorValueSet::StartDrag;
 
-	sal_Bool			bLeft;
+	bool            mbLeftButton;
 	Point           aDragPosPixel;
 
 protected:
@@ -60,28 +59,13 @@ protected:
 	// DragSourceHelper
 	virtual void	StartDrag( sal_Int8 nAction, const Point& rPtPixel );
 
-					DECL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*);
+					DECL_STATIC_LINK(SvxColorValueSet_docking, ExecDragHdl, void*);
 
 public:
-					SvxColorValueSet( Window* pParent, WinBits nWinStyle = WB_ITEMBORDER );
-					SvxColorValueSet( Window* pParent, const ResId& rResId );
-
-	sal_Bool			IsLeftButton() const { return bLeft; }
-};
-
-/*************************************************************************
-|*
-|* Ableitung vom SfxChildWindow als "Behaelter" fuer Controller
-|*
-\************************************************************************/
-
-class SVX_DLLPUBLIC SvxColorChildWindow : public SfxChildWindow
-{
- public:
-	SvxColorChildWindow( Window*, sal_uInt16, SfxBindings*,
-						 SfxChildWinInfo* );
+					SvxColorValueSet_docking( Window* pParent, WinBits nWinStyle = WB_ITEMBORDER );
+					SvxColorValueSet_docking( Window* pParent, const ResId& rResId );
 
-	SFX_DECL_CHILDWINDOW(SvxColorChildWindow);
+	bool IsLeftButton() const { return mbLeftButton; }
 };
 
 /*************************************************************************
@@ -96,13 +80,12 @@ class SvxColorDockingWindow : public Sfx
 
 private:
 	XColorList*		pColorTable;
-	SvxColorValueSet	aColorSet;
+	SvxColorValueSet_docking	aColorSet;
 	sal_uInt16				nLeftSlot;
 	sal_uInt16				nRightSlot;
 	sal_uInt16				nCols;
 	sal_uInt16				nLines;
 	long				nCount;
-	Size				aColorSize;
 	Size				aItemSize;
 
 //#if 0 // _SOLAR__PRIVATE

Modified: openoffice/trunk/main/svx/inc/svx/sidebar/ColorControl.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/sidebar/ColorControl.hxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/sidebar/ColorControl.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/sidebar/ColorControl.hxx Tue Apr 16 09:41:07 2013
@@ -23,6 +23,7 @@
 
 #include <svtools/valueset.hxx>
 #include <boost/function.hpp>
+#include <svx/SvxColorValueSet.hxx>
 
 class Window;
 class SfxBindings;
@@ -73,7 +74,7 @@ public:
 
 private:	
 	SfxBindings* mpBindings;
-	ValueSet maVSColor;
+	SvxColorValueSet maVSColor;
     FloatingWindow* mpFloatingWindow;
     const String msNoColorString;
     ::boost::function<Color(void)> maNoColorGetter;

Modified: openoffice/trunk/main/svx/source/sidebar/tools/ColorControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/sidebar/tools/ColorControl.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/sidebar/tools/ColorControl.cxx (original)
+++ openoffice/trunk/main/svx/source/sidebar/tools/ColorControl.cxx Tue Apr 16 09:41:07 2013
@@ -109,6 +109,7 @@ ColorControl::ColorControl (
       maColorSetter(rColorSetter)
 {
 	FreeResource();
+	FillColors();	
 }
 
 
@@ -126,40 +127,37 @@ void ColorControl::FillColors (void)
 
 	if (pColorTable)
 	{
-        const long nColorCount (pColorTable->Count());
+        const long nColorCount(pColorTable->Count());
         if (nColorCount <= 0)
             return;
-        const sal_Int32 nColumnCount (ceil(sqrt(double(nColorCount))));
-        const sal_Int32 nRowCount (ceil(double(nColorCount)/nColumnCount));
-        maVSColor.SetColCount(nColumnCount);
-        maVSColor.SetLineCount(nRowCount);
-        const sal_Int32 nItemSize (15*12 / ::std::max<sal_Int32>(nColumnCount, nRowCount));
-        maVSColor.CalcWindowSizePixel(Size(nItemSize,nItemSize));
-        Link aLink =  LINK(this, ColorControl, VSSelectHdl);
-        maVSColor.SetSelectHdl(aLink);
-        maVSColor.SetStyle(
-            (maVSColor.GetStyle()
-                | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD// | WB_FLATVALUESET
-                | WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT)
-                        & ~WB_VSCROLL);
 
-        if (msNoColorString.Len() > 0)
+        const WinBits aWinBits(maVSColor.GetStyle() | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD
| 
+            WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT);
+
+        maVSColor.SetStyle(aWinBits);
+
+        // neds to be done *before* layouting
+        if(msNoColorString.Len() > 0)
         {
             maVSColor.SetStyle(maVSColor.GetStyle() | WB_NONEFIELD);
             maVSColor.SetText(msNoColorString);
         }
 
+        const Size aNewSize(maVSColor.layoutAllVisible(nColorCount));
+        maVSColor.SetOutputSizePixel(aNewSize);
+        static sal_Int32 nAdd = 4;
+
+        SetOutputSizePixel(Size(aNewSize.Width() + nAdd, aNewSize.Height() + nAdd));
+        Link aLink = LINK(this, ColorControl, VSSelectHdl);
+        maVSColor.SetSelectHdl(aLink);
+
         // Now, after all calls to SetStyle, we can change the
         // background color.
         maVSColor.SetBackground(Theme::GetWallpaper(Theme::Paint_DropDownBackground));
 
+        // add entrties
         maVSColor.Clear();
-        XColorEntry* pEntry	= NULL;
-        for (sal_Int32 nIndex=0; nIndex<nColorCount; ++nIndex)
-        {
-            pEntry = pColorTable->GetColor(nIndex);
-            maVSColor.InsertItem(nIndex+1, pEntry->GetColor(), pEntry->GetName() );
-        }
+        maVSColor.addEntriesForXColorList(*pColorTable);
 	}
 
 	maVSColor.Show();
@@ -178,7 +176,7 @@ void ColorControl::GetFocus (void)
 
 void ColorControl::SetCurColorSelect (Color aCol, bool bAvailable)
 {
-	FillColors();	
+//	FillColors();	
 	short nCol = GetItemId_Imp( maVSColor, aCol );
 	if(! bAvailable)
 	{
@@ -193,7 +191,9 @@ void ColorControl::SetCurColorSelect (Co
 	}
 	else
 	{
-		maVSColor.SelectItem( nCol );
+        // remove selection first to force evtl. scroll when scroll is needed
+		maVSColor.SetNoSelection();
+		maVSColor.SelectItem(nCol);
 	}
 }
 

Modified: openoffice/trunk/main/svx/source/tbxctrls/colorwindow.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/tbxctrls/colorwindow.hxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/tbxctrls/colorwindow.hxx (original)
+++ openoffice/trunk/main/svx/source/tbxctrls/colorwindow.hxx Tue Apr 16 09:41:07 2013
@@ -29,6 +29,7 @@
 #include <svl/lstner.hxx>
 #include <rtl/ustring.hxx>
 #include <com/sun/star/frame/XFrame.hpp>
+#include <svx/SvxColorValueSet.hxx>
 
 //========================================================================
 // class SvxColorWindow_Impl --------------------------------------------------
@@ -39,9 +40,9 @@ class SvxColorWindow_Impl : public SfxPo
 	using FloatingWindow::StateChanged;
 
 private:
-	const sal_uInt16	                                                    theSlotId;
-	ValueSet		                                                    aColorSet;
-    rtl::OUString                                                       maCommand;
+    const sal_uInt16        theSlotId;
+    SvxColorValueSet        aColorSet;
+    rtl::OUString           maCommand;
 
 #if _SOLAR__PRIVATE
 	DECL_LINK( SelectHdl, void * );

Modified: openoffice/trunk/main/svx/source/tbxctrls/colrctrl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/tbxctrls/colrctrl.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/tbxctrls/colrctrl.cxx (original)
+++ openoffice/trunk/main/svx/source/tbxctrls/colrctrl.cxx Tue Apr 16 09:41:07 2013
@@ -44,8 +44,6 @@
 #include "svx/xexch.hxx"
 #include <vcl/svapp.hxx>
 
-SFX_IMPL_DOCKINGWINDOW( SvxColorChildWindow, SID_COLOR_CONTROL )
-
 // ------------------------
 // - SvxColorValueSetData -
 // ------------------------
@@ -100,55 +98,55 @@ sal_Bool SvxColorValueSetData::WriteObje
 
 /*************************************************************************
 |*
-|* SvxColorValueSet: Ctor
+|* SvxColorValueSet_docking: Ctor
 |*
 \************************************************************************/
 
-SvxColorValueSet::SvxColorValueSet( Window* _pParent, WinBits nWinStyle ) :
-	ValueSet( _pParent, nWinStyle ),
+SvxColorValueSet_docking::SvxColorValueSet_docking( Window* _pParent, WinBits nWinStyle )
:
+	SvxColorValueSet( _pParent, nWinStyle ),
 	DragSourceHelper( this ),
-    bLeft (sal_True)
+    mbLeftButton(true)
 {
 	SetAccessibleName(String( SVX_RES( STR_COLORTABLE ) ) );
 }
 
 /*************************************************************************
 |*
-|* SvxColorValueSet: Ctor
+|* SvxColorValueSet_docking: Ctor
 |*
 \************************************************************************/
 
-SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) :
-	ValueSet( _pParent, rResId ),
+SvxColorValueSet_docking::SvxColorValueSet_docking( Window* _pParent, const ResId& rResId
) :
+	SvxColorValueSet( _pParent, rResId ),
 	DragSourceHelper( this ),
-    bLeft (sal_True)
+    mbLeftButton(true)
 {
 	SetAccessibleName(String( SVX_RES( STR_COLORTABLE )  ));
 }
 
 /*************************************************************************
 |*
-|* SvxColorValueSet: MouseButtonDown
+|* SvxColorValueSet_docking: MouseButtonDown
 |*
 \************************************************************************/
 
-void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt )
+void SvxColorValueSet_docking::MouseButtonDown( const MouseEvent& rMEvt )
 {
 	// Fuer Mac noch anders handlen !
 	if( rMEvt.IsLeft() )
 	{
-		bLeft = sal_True;
-		ValueSet::MouseButtonDown( rMEvt );
+		mbLeftButton = true;
+		SvxColorValueSet::MouseButtonDown( rMEvt );
 	}
 	else
 	{
-		bLeft = sal_False;
+		mbLeftButton = false;
 		MouseEvent aMEvt( rMEvt.GetPosPixel(),
 						  rMEvt.GetClicks(),
 						  rMEvt.GetMode(),
 						  MOUSE_LEFT,
 						  rMEvt.GetModifier() );
-		ValueSet::MouseButtonDown( aMEvt );
+		SvxColorValueSet::MouseButtonDown( aMEvt );
 	}
 
 	aDragPosPixel = GetPointerPosPixel();
@@ -156,27 +154,27 @@ void SvxColorValueSet::MouseButtonDown( 
 
 /*************************************************************************
 |*
-|* SvxColorValueSet: MouseButtonUp
+|* SvxColorValueSet_docking: MouseButtonUp
 |*
 \************************************************************************/
 
-void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt )
+void SvxColorValueSet_docking::MouseButtonUp( const MouseEvent& rMEvt )
 {
 	// Fuer Mac noch anders handlen !
 	if( rMEvt.IsLeft() )
 	{
-		bLeft = sal_True;
-		ValueSet::MouseButtonUp( rMEvt );
+		mbLeftButton = true;
+		SvxColorValueSet::MouseButtonUp( rMEvt );
 	}
 	else
 	{
-		bLeft = sal_False;
+		mbLeftButton = false;
 		MouseEvent aMEvt( rMEvt.GetPosPixel(),
 						  rMEvt.GetClicks(),
 						  rMEvt.GetMode(),
 						  MOUSE_LEFT,
 						  rMEvt.GetModifier() );
-		ValueSet::MouseButtonUp( aMEvt );
+		SvxColorValueSet::MouseButtonUp( aMEvt );
 	}
 	SetNoSelection();
 }
@@ -187,10 +185,10 @@ void SvxColorValueSet::MouseButtonUp( co
 |*
 \************************************************************************/
 
-void SvxColorValueSet::Command(const CommandEvent& rCEvt)
+void SvxColorValueSet_docking::Command(const CommandEvent& rCEvt)
 {
 	// Basisklasse
-	ValueSet::Command(rCEvt);
+	SvxColorValueSet::Command(rCEvt);
 }
 
 /*************************************************************************
@@ -199,9 +197,9 @@ void SvxColorValueSet::Command(const Com
 |*
 \************************************************************************/
 
-void SvxColorValueSet::StartDrag( sal_Int8 , const Point&  )
+void SvxColorValueSet_docking::StartDrag( sal_Int8 , const Point&  )
 {
-	Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl));
+	Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet_docking, ExecDragHdl));
 }
 
 /*************************************************************************
@@ -210,7 +208,7 @@ void SvxColorValueSet::StartDrag( sal_In
 |*
 \************************************************************************/
 
-void SvxColorValueSet::DoDrag()
+void SvxColorValueSet_docking::DoDrag()
 {
 	SfxObjectShell* pDocSh = SfxObjectShell::Current();
 	sal_uInt16			nItemId = GetItemId( aDragPosPixel );
@@ -235,7 +233,7 @@ void SvxColorValueSet::DoDrag()
 |*
 \************************************************************************/
 
-IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG)
+IMPL_STATIC_LINK(SvxColorValueSet_docking, ExecDragHdl, void*, EMPTYARG)
 {
 	// Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die
 	// Farbleiste geloescht werden darf
@@ -245,29 +243,6 @@ IMPL_STATIC_LINK(SvxColorValueSet, ExecD
 
 /*************************************************************************
 |*
-|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator
-|*
-\************************************************************************/
-
-SvxColorChildWindow::SvxColorChildWindow( Window* _pParent,
-    									  sal_uInt16 nId,
-										  SfxBindings* pBindings,
-										  SfxChildWinInfo* pInfo ) :
-	SfxChildWindow( _pParent, nId )
-{
-	SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this,
-										_pParent, SVX_RES( RID_SVXCTRL_COLOR ) );
-	pWindow = pWin;
-
-	eChildAlignment = SFX_ALIGN_BOTTOM;
-
-	pWin->Initialize( pInfo );
-}
-
-
-
-/*************************************************************************
-|*
 |* Ctor: SvxColorDockingWindow
 |*
 \************************************************************************/
@@ -287,8 +262,7 @@ SvxColorDockingWindow::SvxColorDockingWi
 	nLeftSlot		( SID_ATTR_FILL_COLOR ),
 	nRightSlot		( SID_ATTR_LINE_COLOR ),
 	nCols			( 20 ),
-	nLines			( 1 ),
-	aColorSize		( 14, 14 )
+	nLines			( 1 )
 
 {
 	FreeResource();
@@ -320,13 +294,14 @@ SvxColorDockingWindow::SvxColorDockingWi
 		if( pItem )
 		{
 			pColorTable = ( (SvxColorTableItem*) pItem )->GetColorTable();
-			FillValueSet();
+            FillValueSet();
 		}
 	}
-	aItemSize = aColorSet.CalcItemSizePixel( aColorSize );
-	aItemSize.Width() = aItemSize.Width() + aColorSize.Width();
+
+	aItemSize = aColorSet.CalcItemSizePixel(Size(aColorSet.getEntryEdgeLength(), aColorSet.getEntryEdgeLength()));
+	aItemSize.Width() = aItemSize.Width() + aColorSet.getEntryEdgeLength();
 	aItemSize.Width() /= 2;
-	aItemSize.Height() = aItemSize.Height() + aColorSize.Height();
+	aItemSize.Height() = aItemSize.Height() + aColorSet.getEntryEdgeLength();
 	aItemSize.Height() /= 2;
 
 	SetSize();
@@ -374,13 +349,16 @@ void SvxColorDockingWindow::FillValueSet
 {
 	if( pColorTable )
 	{
+		nCount = pColorTable->Count();
 		aColorSet.Clear();
 
-		// Erster Eintrag: unsichtbar
+		// create the first entry for 'invisible/none'
+        const Size aColorSize(aColorSet.getEntryEdgeLength(), aColorSet.getEntryEdgeLength());
 		long nPtX = aColorSize.Width() - 1;
 		long nPtY = aColorSize.Height() - 1;
 		VirtualDevice aVD;
-		aVD.SetOutputSizePixel( aColorSize );
+
+        aVD.SetOutputSizePixel( aColorSize );
 		aVD.SetLineColor( Color( COL_BLACK ) );
 		aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) );
 		aVD.DrawLine( Point(), Point( nPtX, nPtY ) );
@@ -389,16 +367,7 @@ void SvxColorDockingWindow::FillValueSet
 		Bitmap aBmp( aVD.GetBitmap( Point(), aColorSize ) );
 
 		aColorSet.InsertItem( (sal_uInt16)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) );
-
-		XColorEntry* pEntry;
-		nCount = pColorTable->Count();
-
-		for( long i = 0; i < nCount; i++ )
-		{
-			pEntry = pColorTable->GetColor( i );
-			aColorSet.InsertItem( (sal_uInt16)i+2,
-							pEntry->GetColor(), pEntry->GetName() );
-		}
+        aColorSet.addEntriesForXColorList(*pColorTable, 2);
 	}
 }
 

Modified: openoffice/trunk/main/svx/source/tbxctrls/tbcontrl.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/tbxctrls/tbcontrl.cxx?rev=1468340&r1=1468339&r2=1468340&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/tbxctrls/tbcontrl.cxx (original)
+++ openoffice/trunk/main/svx/source/tbxctrls/tbcontrl.cxx Tue Apr 16 09:41:07 2013
@@ -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 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,44 +872,24 @@ SvxColorWindow_Impl::SvxColorWindow_Impl
 
 	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() );
-		}
-
-        while ( i < PALETTE_SIZE )
-		{
-            // fill empty elements if less then PALLETTE_SIZE colors are available
-			aColorSet.InsertItem( i+1, aColWhite, 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);
 	}
 
     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 )
+
+    if ( bKillTable )
 		delete pColorTable;
 }
 
@@ -1019,33 +994,14 @@ void SvxColorWindow_Impl::StateChanged( 
 			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);
 			}
 		}
 	}



Mime
View raw message