chart2/source/controller/dialogs/dlg_View3D.cxx | 4 chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx | 30 chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx | 11 chart2/source/controller/inc/dlg_View3D.hxx | 3 chart2/source/controller/main/ChartController_Properties.cxx | 2 chart2/source/controller/sidebar/ChartColorWrapper.cxx | 4 chart2/source/controller/sidebar/ChartColorWrapper.hxx | 3 chart2/uiconfig/ui/tp_3D_SceneIllumination.ui | 4 cui/source/inc/border.hxx | 7 cui/source/inc/chardlg.hxx | 11 cui/source/inc/cuires.hrc | 1 cui/source/inc/cuitabarea.hxx | 24 cui/source/inc/cuitabline.hxx | 5 cui/source/inc/numpages.hxx | 6 cui/source/options/optchart.cxx | 107 ++ cui/source/options/optchart.hxx | 15 cui/source/options/optcolor.cxx | 93 -- cui/source/tabpages/backgrnd.cxx | 2 cui/source/tabpages/border.cxx | 58 - cui/source/tabpages/borderconn.cxx | 13 cui/source/tabpages/borderconn.hxx | 4 cui/source/tabpages/chardlg.cxx | 166 ---- cui/source/tabpages/numpages.cxx | 32 cui/source/tabpages/strings.src | 4 cui/source/tabpages/tpgradnt.cxx | 56 - cui/source/tabpages/tphatch.cxx | 55 - cui/source/tabpages/tpline.cxx | 30 cui/source/tabpages/tppattern.cxx | 58 - cui/source/tabpages/tpshadow.cxx | 35 cui/uiconfig/ui/borderpage.ui | 4 cui/uiconfig/ui/colorconfigwin.ui | 92 +- cui/uiconfig/ui/effectspage.ui | 6 cui/uiconfig/ui/gradientpage.ui | 4 cui/uiconfig/ui/hatchpage.ui | 4 cui/uiconfig/ui/linetabpage.ui | 2 cui/uiconfig/ui/numberingoptionspage.ui | 2 cui/uiconfig/ui/optchartcolorspage.ui | 3 cui/uiconfig/ui/patterntabpage.ui | 4 cui/uiconfig/ui/shadowtabpage.ui | 2 extensions/source/propctrlr/commoncontrol.cxx | 5 extensions/source/propctrlr/commoncontrol.hxx | 19 extensions/source/propctrlr/standardcontrol.cxx | 109 -- extensions/source/propctrlr/standardcontrol.hxx | 24 extras/source/glade/libreoffice-catalog.xml.in | 22 include/sfx2/controlwrapper.hxx | 22 include/svtools/ctrlbox.hxx | 82 -- include/svtools/svtools.hrc | 2 include/svx/PaletteManager.hxx | 11 include/svx/bmpmask.hxx | 15 include/svx/colorbox.hxx | 94 ++ include/svx/colorwindow.hxx | 48 - include/svx/dialogs.hrc | 7 include/svx/dlgctrl.hxx | 16 include/svx/float3d.hxx | 34 include/svx/fontwork.hxx | 9 include/svx/sidebar/AreaPropertyPanelBase.hxx | 6 include/svx/svxids.hrc | 6 include/svx/tbcontrl.hxx | 16 reportdesign/inc/RptResId.hrc | 4 reportdesign/inc/helpids.hrc | 1 reportdesign/source/ui/dlg/CondFormat.src | 16 reportdesign/source/ui/dlg/Condition.cxx | 174 ---- reportdesign/source/ui/dlg/Condition.hxx | 18 sc/inc/sc.hrc | 2 sc/source/ui/condformat/colorformat.cxx | 57 - sc/source/ui/condformat/condformatdlgentry.cxx | 79 -- sc/source/ui/dbgui/scendlg.cxx | 22 sc/source/ui/drawfunc/drawsh4.cxx | 25 sc/source/ui/drawfunc/drtxtob2.cxx | 25 sc/source/ui/inc/colorformat.hxx | 8 sc/source/ui/inc/condformatdlgentry.hxx | 11 sc/source/ui/inc/opredlin.hxx | 9 sc/source/ui/inc/scendlg.hxx | 4 sc/source/ui/inc/tpview.hxx | 3 sc/source/ui/optdlg/opredlin.cxx | 114 --- sc/source/ui/optdlg/tpview.cxx | 59 - sc/source/ui/src/scstring.src | 5 sc/uiconfig/scalc/ui/conditionalentry.ui | 6 sc/uiconfig/scalc/ui/databaroptions.ui | 17 sc/uiconfig/scalc/ui/optchangespage.ui | 8 sc/uiconfig/scalc/ui/scenariodialog.ui | 2 sc/uiconfig/scalc/ui/tpviewpage.ui | 2 sd/inc/sdabstdlg.hxx | 2 sd/qa/unit/dialogs-test.cxx | 6 sd/source/ui/animations/CustomAnimationDialog.cxx | 82 -- sd/source/ui/dlg/copydlg.cxx | 35 sd/source/ui/dlg/sddlgfact.cxx | 3 sd/source/ui/dlg/sddlgfact.hxx | 2 sd/source/ui/func/fucopy.cxx | 2 sd/source/ui/inc/copydlg.hxx | 12 sd/source/ui/sidebar/SlideBackground.cxx | 36 sd/source/ui/sidebar/SlideBackground.hxx | 8 sd/source/ui/view/drviews6.cxx | 21 sd/source/ui/view/drviewsi.cxx | 2 sd/uiconfig/sdraw/ui/copydlg.ui | 4 sd/uiconfig/simpress/ui/customanimationeffecttab.ui | 2 sd/uiconfig/simpress/ui/sidebarslidebackground.ui | 4 sfx2/source/dialog/itemconnect.cxx | 28 svtools/source/control/ctrlbox.cxx | 224 ----- svtools/source/control/ctrlbox.src | 5 svx/sdi/svx.sdi | 19 svx/source/dialog/_bmpmask.cxx | 56 - svx/source/dialog/bmpmask.hrc | 2 svx/source/dialog/bmpmask.src | 5 svx/source/dialog/dlgctrl.cxx | 48 - svx/source/dialog/fontwork.cxx | 13 svx/source/engine3d/float3d.cxx | 191 ++--- svx/source/engine3d/float3d.src | 15 svx/source/sidebar/area/AreaPropertyPanelBase.cxx | 97 -- svx/source/sidebar/shadow/ShadowPropertyPanel.cxx | 37 svx/source/sidebar/shadow/ShadowPropertyPanel.hxx | 11 svx/source/tbxctrls/PaletteManager.cxx | 23 svx/source/tbxctrls/tbcontrl.cxx | 411 +++++++++-- svx/source/tbxctrls/tbcontrl.src | 12 svx/uiconfig/ui/colorwindow.ui | 50 + svx/uiconfig/ui/docking3deffects.ui | 24 svx/uiconfig/ui/dockingcolorreplace.ui | 10 svx/uiconfig/ui/dockingfontwork.ui | 2 svx/uiconfig/ui/sidebararea.ui | 4 svx/uiconfig/ui/sidebarshadow.ui | 2 sw/inc/authratr.hxx | 2 sw/source/core/access/accpara.cxx | 1 sw/source/ui/config/optpage.cxx | 240 +----- sw/source/ui/frmdlg/column.cxx | 42 - sw/source/ui/misc/pgfnote.cxx | 42 - sw/source/ui/misc/pggrid.cxx | 30 sw/source/uibase/app/swmodul1.cxx | 1 sw/source/uibase/inc/column.hxx | 4 sw/source/uibase/inc/optpage.hxx | 16 sw/source/uibase/inc/pgfnote.hxx | 5 sw/source/uibase/inc/pggrid.hxx | 7 sw/source/uibase/shells/drawsh.cxx | 13 sw/source/uibase/shells/drwtxtsh.cxx | 13 sw/source/uibase/sidebar/PageStylesPanel.cxx | 62 - sw/source/uibase/sidebar/PageStylesPanel.hxx | 8 sw/uiconfig/swriter/ui/columnpage.ui | 2 sw/uiconfig/swriter/ui/footnoteareapage.ui | 2 sw/uiconfig/swriter/ui/optredlinepage.ui | 20 sw/uiconfig/swriter/ui/pagestylespanel.ui | 4 sw/uiconfig/swriter/ui/textgridpage.ui | 2 140 files changed, 1488 insertions(+), 2722 deletions(-)
New commits: commit f300754bb1c6a347c92bb9548be7a65237176542 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 17:10:13 2016 +0000 replace OColorPopup with SvxColorWindow Change-Id: I1aa06f70016b935bb13a0f6e93234eea10ba8b84 diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx index f6dee67..4b7f251 100644 --- a/include/svx/colorbox.hxx +++ b/include/svx/colorbox.hxx @@ -21,6 +21,7 @@ class SvxListBoxColorWrapper public: SvxListBoxColorWrapper(SvxColorListBox* pControl); void operator()(const OUString& rCommand, const NamedColor& rColor); + void dispose(); private: VclPtr<SvxColorListBox> mxControl; }; diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx index 3fc9510..1e41713 100644 --- a/include/svx/colorwindow.hxx +++ b/include/svx/colorwindow.hxx @@ -31,7 +31,7 @@ #include <functional> -class BorderColorStatus +class SVX_DLLPUBLIC BorderColorStatus { Color maColor; Color maTLBRColor; diff --git a/reportdesign/inc/RptResId.hrc b/reportdesign/inc/RptResId.hrc index 7e57bba..38102f3 100644 --- a/reportdesign/inc/RptResId.hrc +++ b/reportdesign/inc/RptResId.hrc @@ -108,10 +108,6 @@ #define STR_SHOW_RULER ( RID_STRING_START + 63 ) #define STR_SHOW_GRID ( RID_STRING_START + 64 ) -#define STR_COLOR_WHITE ( RID_STRING_START + 65 ) -#define STR_CHARCOLOR ( RID_STRING_START + 66 ) -#define STR_CHARBACKGROUND ( RID_STRING_START + 67 ) -#define STR_TRANSPARENT ( RID_STRING_START + 68 ) #define RID_STR_FIELDSELECTION ( RID_STRING_START + 69 ) #define RID_STR_UNDO_ADD_GROUP_HEADER ( RID_STRING_START + 70 ) diff --git a/reportdesign/inc/helpids.hrc b/reportdesign/inc/helpids.hrc index ed17967..aaa4883 100644 --- a/reportdesign/inc/helpids.hrc +++ b/reportdesign/inc/helpids.hrc @@ -31,7 +31,6 @@ #define HID_RPT_HORZ_SCROLLBAR "REPORTDESIGN_HID_RPT_HORZ_SCROLLBAR" #define HID_RPT_VERT_SCROLLBAR "REPORTDESIGN_HID_RPT_VERT_SCROLLBAR" #define HID_RPT_FIELDEXPRESSION "REPORTDESIGN_HID_RPT_FIELDEXPRESSION" -#define HID_RPT_POPUP_COLOR_CTRL "REPORTDESIGN_HID_RPT_POPUP_COLOR_CTRL" #define HID_RPT_POPUP_COLOR "REPORTDESIGN_HID_RPT_POPUP_COLOR" #define HID_RPT_FIELD_SEL "REPORTDESIGN_HID_RPT_FIELD_SEL" #define HID_RPT_FIELD_SEL_WIN "REPORTDESIGN_HID_RPT_FIELD_SEL_WIN" diff --git a/reportdesign/source/ui/dlg/CondFormat.src b/reportdesign/source/ui/dlg/CondFormat.src index e8f16c4..ecf70ca 100644 --- a/reportdesign/source/ui/dlg/CondFormat.src +++ b/reportdesign/source/ui/dlg/CondFormat.src @@ -24,21 +24,5 @@ String STR_NUMBERED_CONDITION { Text [ en-US ] = "Condition $number$"; }; -String STR_COLOR_WHITE -{ - Text [ en-US ] = "White" ; -}; -String STR_CHARCOLOR -{ - Text [ en-US ] = "Font color" ; -}; -String STR_CHARBACKGROUND -{ - Text [ en-US ] = "Background"; -}; -String STR_TRANSPARENT -{ - Text [ en-US ] = "No Fill" ; -}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 3a216d8..4632306 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -84,144 +84,34 @@ IMPL_LINK( ConditionField, OnFormula, Button*, _pClickedButton, void ) } } -// TO-DO, this is yet another color selector, can it be replaced with SvxColorWindor/SvxColorToolBoxControl ? -#ifndef WB_NO_DIRECTSELECT -#define WB_NO_DIRECTSELECT ((WinBits)0x04000000) -#endif - -#define PALETTE_X 10 -#define PALETTE_Y 10 -#define PALETTE_SIZE (PALETTE_X * PALETTE_Y) -class OColorPopup : public FloatingWindow +ConditionColorWrapper::ConditionColorWrapper(Condition* pControl) + : mxControl(pControl) + , mnSlotId(0) { - DECL_LINK( SelectHdl, ValueSet*, void ); - VclPtr<Condition> m_pCondition; - sal_uInt16 m_nSlotId; -public: - OColorPopup(vcl::Window* _pParent,Condition* _pCondition); - virtual ~OColorPopup() override; - virtual void dispose() override; - VclPtr<ValueSet> m_aColorSet; - - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Resize() override; - - void StartSelection(); - void SetSlotId(sal_uInt16 _nSlotId); -}; - -OColorPopup::OColorPopup(vcl::Window* _pParent,Condition* _pCondition) -:FloatingWindow(_pParent, WinBits( WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK|WB_DIALOGCONTROL )) -,m_pCondition(_pCondition) -,m_nSlotId(0) -,m_aColorSet( VclPtr<ValueSet>::Create(this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT)) ) -{ - m_aColorSet->SetHelpId( HID_RPT_POPUP_COLOR_CTRL ); - SetHelpId( HID_RPT_POPUP_COLOR ); - const Size aSize12( 13, 13 ); - short i = 0; - XColorListRef pColorList( XColorList::CreateStdColorList() ); - long nCount = pColorList->Count(); - Color aColWhite( COL_WHITE ); - OUString aStrWhite( ModuleRes(STR_COLOR_WHITE) ); - - if ( nCount > PALETTE_SIZE ) - // Show scrollbar if more than PALLETTE_SIZE colors are available - m_aColorSet->SetStyle( m_aColorSet->GetStyle() | WB_VSCROLL ); - - for ( i = 0; i < nCount; i++ ) - { - const XColorEntry* pEntry = pColorList->GetColor(i); - m_aColorSet->InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() ); - } - - while ( i < PALETTE_SIZE ) - { - // fill empty elements if less then PALLETTE_SIZE colors are available - m_aColorSet->InsertItem( i+1, aColWhite, aStrWhite ); - i++; - } - - m_aColorSet->SetSelectHdl( LINK( this, OColorPopup, SelectHdl ) ); - m_aColorSet->SetColCount( PALETTE_X ); - m_aColorSet->SetLineCount( PALETTE_Y ); - Size aSize = m_aColorSet->CalcWindowSizePixel( aSize12 ); - aSize.Width() += 4; - aSize.Height() += 4; - SetOutputSizePixel( aSize ); - m_aColorSet->Show(); -} - -OColorPopup::~OColorPopup() -{ - disposeOnce(); -} - -void OColorPopup::dispose() -{ - disposeBuilder(); - m_aColorSet.disposeAndClear(); - m_pCondition.clear(); - FloatingWindow::dispose(); -} - -void OColorPopup::KeyInput( const KeyEvent& rKEvt ) -{ - m_aColorSet->KeyInput(rKEvt); } -void OColorPopup::Resize() +void ConditionColorWrapper::dispose() { - Size aSize = GetOutputSizePixel(); - aSize.Width() -= 4; - aSize.Height() -= 4; - m_aColorSet->SetPosSizePixel( Point(2,2), aSize ); + mxControl.clear(); } -void OColorPopup::StartSelection() +void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const NamedColor& rNamedColor) { - m_aColorSet->StartSelection(); + mxControl->ApplyCommand(mnSlotId, rNamedColor.first); } -void OColorPopup::SetSlotId(sal_uInt16 _nSlotId) -{ - m_nSlotId = _nSlotId; - if ( SID_ATTR_CHAR_COLOR_BACKGROUND == _nSlotId || SID_BACKGROUND_COLOR == _nSlotId ) - { - m_aColorSet->SetStyle( m_aColorSet->GetStyle() | WB_NONEFIELD ); - m_aColorSet->SetText( OUString(ModuleRes( STR_TRANSPARENT )) ); - } -} - -IMPL_LINK_NOARG(OColorPopup, SelectHdl, ValueSet*, void) -{ - sal_uInt16 nItemId = m_aColorSet->GetSelectItemId(); - Color aColor( nItemId == 0 ? Color( COL_TRANSPARENT ) : m_aColorSet->GetItemColor( nItemId ) ); - - /* #i33380# Moved the following line above the Dispatch() calls. - This instance may be deleted in the meantime (i.e. when a dialog is opened - while in Dispatch()), accessing members will crash in this case. */ - m_aColorSet->SetNoSelection(); - - if ( IsInPopupMode() ) - EndPopupMode(); - - m_pCondition->ApplyCommand( m_nSlotId, aColor ); -} - - // = Condition Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController ) - :VclHBox(_pParent) - ,m_rController( _rController ) - ,m_rAction( _rAction ) - ,m_pColorFloat(nullptr) - ,m_pBtnUpdaterFontColor(nullptr) - ,m_pBtnUpdaterBackgroundColor(nullptr) - ,m_nCondIndex( 0 ) - ,m_bInDestruction( false ) + : VclHBox(_pParent) + , m_aColorWrapper(this) + , m_rController(_rController) + , m_rAction(_rAction) + , m_pBtnUpdaterFontColor(nullptr) + , m_pBtnUpdaterBackgroundColor(nullptr) + , m_nCondIndex(0) + , m_bInDestruction(false) { m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "modules/dbreport/ui/conditionwin.ui"); @@ -328,31 +218,27 @@ void Condition::dispose() m_pAddCondition.clear(); m_pRemoveCondition.clear(); m_pColorFloat.disposeAndClear(); + m_aColorWrapper.dispose(); disposeBuilder(); VclHBox::dispose(); } -IMPL_LINK_NOARG( Condition, DropdownClick, ToolBox*, void ) +IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void) { sal_uInt16 nId( m_pActions->GetCurItemId() ); - if ( !m_pColorFloat ) - m_pColorFloat = VclPtr<OColorPopup>::Create(m_pActions,this); - - sal_uInt16 nTextId = 0; - if (nId == m_nFontColorId) - { - nTextId = STR_CHARCOLOR; - } - else if (nId == m_nBackgroundColorId) - { - nTextId = STR_CHARBACKGROUND; - } - if ( nTextId ) - m_pColorFloat->SetText(OUString(ModuleRes(nTextId))); - m_pColorFloat->SetSlotId(mapToolbarItemToSlotId(nId)); - m_pColorFloat->SetPosPixel(m_pActions->GetItemPopupPosition(nId,m_pColorFloat->GetSizePixel())); - m_pColorFloat->StartPopupMode(m_pActions); - m_pColorFloat->StartSelection(); + m_pColorFloat.disposeAndClear(); + sal_uInt16 nSlotId(mapToolbarItemToSlotId(nId)); + m_aColorWrapper.SetSlotId(nSlotId); + m_pColorFloat = VclPtr<SvxColorWindow>::Create( + OUString() /*m_aCommandURL*/, + m_aPaletteManager, + m_aBorderColorStatus, + nSlotId, + nullptr, + pToolBox, + m_aColorWrapper); + + m_pColorFloat->StartPopupMode(pToolBox, FloatWinPopupFlags::GrabFocus); } IMPL_LINK_NOARG( Condition, OnFormatAction, ToolBox*, void ) diff --git a/reportdesign/source/ui/dlg/Condition.hxx b/reportdesign/source/ui/dlg/Condition.hxx index ab5194a..6a6d64e 100644 --- a/reportdesign/source/ui/dlg/Condition.hxx +++ b/reportdesign/source/ui/dlg/Condition.hxx @@ -26,6 +26,7 @@ #include <dbaccess/ToolBoxHelper.hxx> +#include <svx/colorwindow.hxx> #include <svx/fntctrl.hxx> #include <vcl/fixed.hxx> @@ -62,6 +63,18 @@ namespace rptui OUString GetText() const { return m_pSubEdit->GetText(); } }; + class ConditionColorWrapper + { + public: + ConditionColorWrapper(Condition* pControl); + void SetSlotId(sal_uInt16 nSlotId) { mnSlotId = nSlotId; } + void operator()(const OUString& rCommand, const NamedColor& rColor); + void dispose(); + private: + VclPtr<Condition> mxControl; + sal_uInt16 mnSlotId; + }; + //= Condition class Condition :public VclHBox @@ -74,6 +87,9 @@ namespace rptui sal_uInt16 m_nBackgroundColorId; sal_uInt16 m_nFontColorId; sal_uInt16 m_nFontDialogId; + PaletteManager m_aPaletteManager; + BorderColorStatus m_aBorderColorStatus; + ConditionColorWrapper m_aColorWrapper; ::rptui::OReportController& m_rController; IConditionalFormatAction& m_rAction; @@ -89,7 +105,7 @@ namespace rptui VclPtr<PushButton> m_pMoveDown; VclPtr<PushButton> m_pAddCondition; VclPtr<PushButton> m_pRemoveCondition; - VclPtr<OColorPopup> m_pColorFloat; + VclPtr<SvxColorWindow> m_pColorFloat; svx::ToolboxButtonColorUpdater* m_pBtnUpdaterFontColor; // updates the color below the toolbar icon svx::ToolboxButtonColorUpdater* m_pBtnUpdaterBackgroundColor; diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index b754581..c5c0d56 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -3192,6 +3192,11 @@ void SvxListBoxColorWrapper::operator()(const OUString& /*rCommand*/, const Name mxControl->Selected(rColor); } +void SvxListBoxColorWrapper::dispose() +{ + mxControl.clear(); +} + SvxColorListBox::SvxColorListBox(vcl::Window* pParent, WinBits nStyle) : MenuButton(pParent, nStyle) , m_aColorWrapper(this) @@ -3306,6 +3311,7 @@ SvxColorListBox::~SvxColorListBox() void SvxColorListBox::dispose() { m_xColorWindow.disposeAndClear(); + m_aColorWrapper.dispose(); MenuButton::dispose(); } commit 347c2c334589b18cc62af292674bb3df1dd54b71 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 15:55:12 2016 +0000 drop AutoColorInvalid/SID_ATTR_AUTO_COLOR_INVALID it doesn't appear to exist/be implemented and makes the reportdesigner font dialog from conditional formatting crash Change-Id: Iad929fec8aedfa31f6e8f9dfaa0055d61a9ff6f3 diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 919259e..8a7f7c5 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -750,7 +750,7 @@ #define SID_READONLY_MODE ( SID_SVX_START + 930 ) #define SID_ATTR_ALIGN_HYPHENATION ( SID_SVX_START + 931 ) #define SID_ATTR_NUMBERFORMAT_SOURCE ( SID_SVX_START + 932 ) -#define SID_ATTR_AUTO_COLOR_INVALID ( SID_SVX_START + 933 ) + #define SID_RULER_BORDER_DISTANCE ( SID_SVX_START + 935 ) #define SID_INSERT_DATEFIELD ( SID_SVX_START + 936 ) #define SID_INSERT_TIMEFIELD ( SID_SVX_START + 937 ) diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 0693af6..2e8b2f6 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -3596,25 +3596,6 @@ SfxBoolItem Freeline_Unfilled SID_DRAW_FREELINE_NOFILL ] -SfxBoolItem AutoColorInvalid SID_ATTR_AUTO_COLOR_INVALID - -[ - AutoUpdate = TRUE, - FastCall = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - - - AccelConfig = FALSE, - MenuConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_INSERT; -] - - SfxVoidItem Gallery SID_GALLERY [ diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 800e53a..b754581 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1298,15 +1298,7 @@ SvxColorWindow::SvxColorWindow(const OUString& rCommand, case SID_ATTR_CHAR_COLOR2: case SID_EXTRUSION_3D_COLOR: { - SfxPoolItem* pDummy; - - Reference< XDispatchProvider > aDisp( GetFrame()->getController(), UNO_QUERY ); - SfxQueryStatus aQueryStatus( aDisp, - SID_ATTR_AUTO_COLOR_INVALID, - OUString( ".uno:AutoColorInvalid" )); - SfxItemState eState = aQueryStatus.QueryState( pDummy ); - if( (SfxItemState::DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) ) - mpButtonAutoColor->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) ); + mpButtonAutoColor->SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) ); break; } default: commit 604b35bf55351751a396e34dcca3f85e75860fd5 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 15:26:23 2016 +0000 replace last ColorLB use with a listbox of colors Change-Id: Ia0058939faa63507b50c5ca70527850e59c0ba5d diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index aefd2672..060d3b0 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -26,70 +26,20 @@ #include <vcl/svapp.hxx> #include <svx/svxids.hrc> -class ColorLB : public ListBox +Color SvxDefaultColorOptPage::GetSelectEntryColor() const { - ImpColorList aColorList; // separate liste, in case of user data are required from outside - -public: - ColorLB(vcl::Window* pParent, WinBits nWinStyle = WB_BORDER); - virtual ~ColorLB() override; - virtual void dispose() override; - - using ListBox::InsertEntry; - sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos = LISTBOX_APPEND ); - using ListBox::RemoveEntry; - void RemoveEntry( sal_Int32 nPos ); - void Clear(); - - Color GetEntryColor( sal_Int32 nPos ) const; - - Color GetSelectEntryColor() const - { - sal_Int32 nPos = GetSelectEntryPos(); - Color aColor; - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - aColor = GetEntryColor( nPos ); - return aColor; - } - - void Append( const XColorEntry& rEntry ); - void Modify( const XColorEntry& rEntry, sal_Int32 nPos ); -}; - -VCL_BUILDER_DECL_FACTORY(ColorLB) -{ - bool bDropdown = VclBuilder::extractDropdown(rMap); - WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP; - if (bDropdown) - nWinBits |= WB_DROPDOWN; - OString sBorder = VclBuilder::extractCustomProperty(rMap); - if (!sBorder.isEmpty()) - nWinBits |= WB_BORDER; - VclPtrInstance<ColorLB> pListBox(pParent, nWinBits); - pListBox->EnableAutoSize(true); - rRet = pListBox; -} - -ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) : - ListBox( pParent, nWinStyle ) -{ - SetEdgeBlending(true); -} - -ColorLB::~ColorLB() -{ - disposeOnce(); + sal_Int32 nPos = m_pLbChartColors->GetSelectEntryPos(); + Color aColor; + if (nPos != LISTBOX_ENTRY_NOTFOUND) + aColor = GetEntryColor(nPos); + return aColor; } -void ColorLB::dispose() +void SvxDefaultColorOptPage::InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos) { - ListBox::dispose(); -} + const Color& rColor = rEntry.GetColor(); + const OUString& rStr = rEntry.GetName(); -sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos ) -{ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); Size aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); @@ -101,8 +51,9 @@ sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, xDevice->DrawRect(aRect); Bitmap aBitmap(xDevice->GetBitmap(Point(0, 0), xDevice->GetOutputSize())); - nPos = ListBox::InsertEntry(rStr, Image(aBitmap), nPos); - if ( nPos != LISTBOX_ERROR ) + nPos = m_pLbChartColors->InsertEntry(rStr, Image(aBitmap), nPos); + + if (nPos != LISTBOX_ERROR) { if ( static_cast<size_t>(nPos) < aColorList.size() ) { @@ -116,12 +67,11 @@ sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, nPos = aColorList.size() - 1; } } - return nPos; } -void ColorLB::RemoveEntry( sal_Int32 nPos ) +void SvxDefaultColorOptPage::RemoveColorEntry(sal_Int32 nPos) { - ListBox::RemoveEntry( nPos ); + m_pLbChartColors->RemoveEntry(nPos); if ( 0 <= nPos && static_cast<size_t>(nPos) < aColorList.size() ) { ImpColorList::iterator it = aColorList.begin(); @@ -130,13 +80,13 @@ void ColorLB::RemoveEntry( sal_Int32 nPos ) } } -void ColorLB::Clear() +void SvxDefaultColorOptPage::ClearColorEntries() { aColorList.clear(); - ListBox::Clear(); + m_pLbChartColors->Clear(); } -Color ColorLB::GetEntryColor( sal_Int32 nPos ) const +Color SvxDefaultColorOptPage::GetEntryColor(sal_Int32 nPos) const { Color aColor; if (0 <= nPos && static_cast<size_t>(nPos) < aColorList.size()) @@ -144,30 +94,24 @@ Color ColorLB::GetEntryColor( sal_Int32 nPos ) const return aColor; } -void ColorLB::Append( const XColorEntry& rEntry ) +void SvxDefaultColorOptPage::ModifyColorEntry(const XColorEntry& rEntry, sal_Int32 nPos) { - InsertEntry( rEntry.GetColor(), rEntry.GetName() ); + RemoveColorEntry(nPos); + InsertColorEntry(rEntry, nPos); } -void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos ) +void SvxDefaultColorOptPage::FillBoxChartColorLB() { - RemoveEntry( nPos ); - InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos ); -} + if (!pColorConfig) + return; -namespace -{ - void FillBoxChartColorLB(ColorLB *pLB, const SvxChartColorTable & rTab) - { - pLB->SetUpdateMode(false); - pLB->Clear(); - long nCount = rTab.size(); - for(long i = 0; i < nCount; ++i) - { - pLB->Append(rTab[i]); - } - pLB->SetUpdateMode(true); - } + const SvxChartColorTable & rTab = pColorConfig->GetColorList(); + m_pLbChartColors->SetUpdateMode(false); + ClearColorEntries(); + long nCount = rTab.size(); + for (long i = 0; i < nCount; ++i) + InsertColorEntry(rTab[i]); + m_pLbChartColors->SetUpdateMode(true); } SvxDefaultColorOptPage::SvxDefaultColorOptPage(vcl::Window* pParent, const SfxItemSet& rInAttrs) @@ -240,9 +184,7 @@ void SvxDefaultColorOptPage::dispose() void SvxDefaultColorOptPage::Construct() { - if( pColorConfig ) - FillBoxChartColorLB(m_pLbChartColors, pColorConfig->GetColorList()); - + FillBoxChartColorLB(); FillColorBox(); m_pLbChartColors->SelectEntryPos( 0 ); @@ -315,7 +257,7 @@ IMPL_LINK_NOARG(SvxDefaultColorOptPage, ResetToDefaults, Button*, void) { pColorConfig->GetColorList().useDefault(); - FillBoxChartColorLB(m_pLbChartColors, pColorConfig->GetColorList()); + FillBoxChartColorLB(); m_pLbChartColors->GetFocus(); m_pLbChartColors->SelectEntryPos( 0 ); @@ -334,7 +276,7 @@ IMPL_LINK_NOARG(SvxDefaultColorOptPage, AddChartColor, Button*, void) pColorConfig->GetColorList().append (XColorEntry ( black, pColorConfig->GetColorList().getDefaultName(pColorConfig->GetColorList().size()))); - FillBoxChartColorLB(m_pLbChartColors, pColorConfig->GetColorList()); + FillBoxChartColorLB(); m_pLbChartColors->GetFocus(); m_pLbChartColors->SelectEntryPos( pColorConfig->GetColorList().size() - 1 ); @@ -362,7 +304,7 @@ IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, Button*, pButton, void ) { pColorConfig->GetColorList().remove( nIndex ); - FillBoxChartColorLB(m_pLbChartColors, pColorConfig->GetColorList()); + FillBoxChartColorLB(); m_pLbChartColors->GetFocus(); @@ -376,9 +318,9 @@ IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, Button*, pButton, void ) } } -IMPL_LINK( SvxDefaultColorOptPage, ListClickedHdl, ListBox&, _rBox, void ) +IMPL_LINK_NOARG( SvxDefaultColorOptPage, ListClickedHdl, ListBox&, void ) { - Color aCol = static_cast<ColorLB&>(_rBox).GetSelectEntryColor(); + Color aCol = GetSelectEntryColor(); long nIndex = GetColorIndex( aCol ); @@ -395,7 +337,7 @@ IMPL_LINK_NOARG(SvxDefaultColorOptPage, BoxClickedHdl, ValueSet*, void) { const XColorEntry aEntry( m_pValSetColorBox->GetItemColor( m_pValSetColorBox->GetSelectItemId() ), m_pLbChartColors->GetSelectEntry() ); - m_pLbChartColors->Modify( aEntry, nIdx ); + ModifyColorEntry(aEntry, nIdx); pColorConfig->ReplaceColorByIndex( nIdx, aEntry ); m_pLbChartColors->SelectEntryPos( nIdx ); // reselect entry diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index ff8102a..79af3c1 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -30,12 +30,11 @@ #include "cfgchart.hxx" typedef std::vector<Color> ImpColorList; -class ColorLB; class SvxDefaultColorOptPage : public SfxTabPage { private: - VclPtr<ColorLB> m_pLbChartColors; + VclPtr<ListBox> m_pLbChartColors; VclPtr<ValueSet> m_pValSetColorBox; VclPtr<PushButton> m_pPBDefault; VclPtr<PushButton> m_pPBAdd; @@ -44,6 +43,7 @@ private: SvxChartOptions* pChartOptions; SvxChartColorTableItem* pColorConfig; XColorListRef pColorList; + ImpColorList aColorList; DECL_LINK( ResetToDefaults, Button *, void ); DECL_LINK( AddChartColor, Button *, void ); @@ -54,6 +54,15 @@ private: void FillColorBox(); long GetColorIndex( const Color& rCol ); +private: + void InsertColorEntry(const XColorEntry& rEntry, sal_Int32 nPos = LISTBOX_APPEND); + void RemoveColorEntry(sal_Int32 nPos); + void ModifyColorEntry(const XColorEntry& rEntry, sal_Int32 nPos); + void ClearColorEntries(); + void FillBoxChartColorLB(); + Color GetEntryColor(sal_Int32 nPos) const; + Color GetSelectEntryColor() const; + public: SvxDefaultColorOptPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); virtual ~SvxDefaultColorOptPage() override; diff --git a/cui/uiconfig/ui/optchartcolorspage.ui b/cui/uiconfig/ui/optchartcolorspage.ui index f01beda..3d1fc1a 100644 --- a/cui/uiconfig/ui/optchartcolorspage.ui +++ b/cui/uiconfig/ui/optchartcolorspage.ui @@ -26,8 +26,7 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="cuilo-ColorLB" id="colors:border"> - <property name="dropdown">False</property> + <object class="GtkTreeView" id="colors:border"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> commit 351a97ce6bda3075677b59fa1387ba3d1ab17d7a Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 15:06:55 2016 +0000 simplify, its just a vector of colors Change-Id: I7d388739225d371090872a33d30aa3178b20ca6e diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index ddc3e06..aefd2672 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -28,12 +28,7 @@ class ColorLB : public ListBox { - ImpColorList* pColorList; // separate liste, in case of user data are required from outside - Size aImageSize; - - using Window::ImplInit; - SVT_DLLPRIVATE void ImplInit(); - SVT_DLLPRIVATE void ImplDestroyColorEntries(); + ImpColorList aColorList; // separate liste, in case of user data are required from outside public: ColorLB(vcl::Window* pParent, WinBits nWinStyle = WB_BORDER); @@ -76,35 +71,9 @@ VCL_BUILDER_DECL_FACTORY(ColorLB) rRet = pListBox; } -class ImplColorListData -{ -public: - Color aColor; - bool bColor; - - ImplColorListData() : aColor( COL_BLACK ) { bColor = false; } - explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } -}; - -void ColorLB::ImplInit() -{ - pColorList = new ImpColorList(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); -} - -void ColorLB::ImplDestroyColorEntries() -{ - for ( size_t n = pColorList->size(); n; ) - delete (*pColorList)[ --n ]; - pColorList->clear(); -} - ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) : ListBox( pParent, nWinStyle ) { - ImplInit(); SetEdgeBlending(true); } @@ -115,12 +84,6 @@ ColorLB::~ColorLB() void ColorLB::dispose() { - if ( pColorList ) - { - ImplDestroyColorEntries(); - delete pColorList; - pColorList = nullptr; - } ListBox::dispose(); } @@ -128,6 +91,7 @@ sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos ) { const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + Size aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); VclPtr<VirtualDevice> xDevice = VclPtr<VirtualDevice>::Create(); xDevice->SetOutputSize(aImageSize); @@ -140,17 +104,16 @@ sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, nPos = ListBox::InsertEntry(rStr, Image(aBitmap), nPos); if ( nPos != LISTBOX_ERROR ) { - ImplColorListData* pData = new ImplColorListData( rColor ); - if ( static_cast<size_t>(nPos) < pColorList->size() ) + if ( static_cast<size_t>(nPos) < aColorList.size() ) { - ImpColorList::iterator it = pColorList->begin(); + ImpColorList::iterator it = aColorList.begin(); ::std::advance( it, nPos ); - pColorList->insert( it, pData ); + aColorList.insert( it, rColor ); } else { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; + aColorList.push_back( rColor ); + nPos = aColorList.size() - 1; } } return nPos; @@ -159,28 +122,25 @@ sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, void ColorLB::RemoveEntry( sal_Int32 nPos ) { ListBox::RemoveEntry( nPos ); - if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) + if ( 0 <= nPos && static_cast<size_t>(nPos) < aColorList.size() ) { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - delete *it; - pColorList->erase( it ); + ImpColorList::iterator it = aColorList.begin(); + std::advance(it, nPos); + aColorList.erase(it); } } void ColorLB::Clear() { - ImplDestroyColorEntries(); + aColorList.clear(); ListBox::Clear(); } Color ColorLB::GetEntryColor( sal_Int32 nPos ) const { Color aColor; - ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? - (*pColorList)[ nPos ] : nullptr; - if ( pData && pData->bColor ) - aColor = pData->aColor; + if (0 <= nPos && static_cast<size_t>(nPos) < aColorList.size()) + aColor = aColorList[nPos]; return aColor; } diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index 30f3196..ff8102a 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -29,11 +29,11 @@ #include "cfgchart.hxx" +typedef std::vector<Color> ImpColorList; class ColorLB; class SvxDefaultColorOptPage : public SfxTabPage { - private: VclPtr<ColorLB> m_pLbChartColors; VclPtr<ValueSet> m_pValSetColorBox; diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx index 28d1a34..cb5e29d 100644 --- a/include/svtools/ctrlbox.hxx +++ b/include/svtools/ctrlbox.hxx @@ -33,10 +33,8 @@ #include <o3tl/typed_flags_set.hxx> class FontList; -class ImplColorListData; class ImpLineListData; -typedef ::std::vector< ImplColorListData* > ImpColorList; typedef ::std::vector< ImpLineListData* > ImpLineList; typedef ::std::vector< FontMetric > ImplFontList; commit df738e0f8ceedb4bad756960be14d9c41adc165d Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 14:53:11 2016 +0000 replace user draw with an Image of the color Change-Id: I0d301ba4082a45e7030c6956c18aa76e52bce216 diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index cd92f14..ddc3e06 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -40,8 +40,6 @@ public: virtual ~ColorLB() override; virtual void dispose() override; - virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; - using ListBox::InsertEntry; sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos = LISTBOX_APPEND ); @@ -94,8 +92,6 @@ void ColorLB::ImplInit() const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); - EnableUserDraw( true ); - SetUserItemSize( aImageSize ); } void ColorLB::ImplDestroyColorEntries() @@ -131,7 +127,17 @@ void ColorLB::dispose() sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos ) { - nPos = ListBox::InsertEntry( rStr, nPos ); + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + VclPtr<VirtualDevice> xDevice = VclPtr<VirtualDevice>::Create(); + xDevice->SetOutputSize(aImageSize); + const Rectangle aRect(Point(0, 0), aImageSize); + xDevice->SetFillColor(rColor); + xDevice->SetLineColor(rStyleSettings.GetDisableColor()); + xDevice->DrawRect(aRect); + Bitmap aBitmap(xDevice->GetBitmap(Point(0, 0), xDevice->GetOutputSize())); + + nPos = ListBox::InsertEntry(rStr, Image(aBitmap), nPos); if ( nPos != LISTBOX_ERROR ) { ImplColorListData* pData = new ImplColorListData( rColor ); @@ -178,53 +184,6 @@ Color ColorLB::GetEntryColor( sal_Int32 nPos ) const return aColor; } -void ColorLB::UserDraw( const UserDrawEvent& rUDEvt ) -{ - size_t nPos = rUDEvt.GetItemId(); - ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; - if ( pData ) - { - if ( pData->bColor ) - { - Point aPos( rUDEvt.GetRect().TopLeft() ); - - aPos.X() += 2; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2; - - const Rectangle aRect(aPos, aImageSize); - - vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); - pRenderContext->Push(); - pRenderContext->SetFillColor(pData->aColor); - pRenderContext->SetLineColor(pRenderContext->GetTextColor()); - pRenderContext->DrawRect(aRect); - pRenderContext->Pop(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); - - if(nEdgeBlendingPercent) - { - const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); - const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); - const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); - const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); - - if(!aBlendFrame.IsEmpty()) - { - pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); - } - } - - ListBox::DrawEntry( rUDEvt, false, false ); - } - else - ListBox::DrawEntry( rUDEvt, false, true ); - } - else - ListBox::DrawEntry( rUDEvt, true, false ); -} - void ColorLB::Append( const XColorEntry& rEntry ) { InsertEntry( rEntry.GetColor(), rEntry.GetName() ); commit 08d6cd788f2584ce10ab8fa10665245e953c59d9 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 14:45:21 2016 +0000 strip down to the used pieces Change-Id: I1d9eed2345f3d8a78f467d0fb5f7b7cd0211a160 diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 254b464..cd92f14 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -26,7 +26,7 @@ #include <vcl/svapp.hxx> #include <svx/svxids.hrc> -class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ListBox +class ColorLB : public ListBox { ImpColorList* pColorList; // separate liste, in case of user data are required from outside Size aImageSize; @@ -36,38 +36,21 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ListBox SVT_DLLPRIVATE void ImplDestroyColorEntries(); public: - ColorLB( vcl::Window* pParent, - WinBits nWinStyle = WB_BORDER ); + ColorLB(vcl::Window* pParent, WinBits nWinStyle = WB_BORDER); virtual ~ColorLB() override; virtual void dispose() override; virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; using ListBox::InsertEntry; - sal_Int32 InsertEntry( const OUString& rStr, - sal_Int32 nPos = LISTBOX_APPEND ); sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos = LISTBOX_APPEND ); - bool IsAutomaticSelected() { return !GetSelectEntryPos(); } using ListBox::RemoveEntry; void RemoveEntry( sal_Int32 nPos ); void Clear(); - void CopyEntries( const ColorLB& rBox ); - using ListBox::GetEntryPos; - sal_Int32 GetEntryPos( const Color& rColor ) const; Color GetEntryColor( sal_Int32 nPos ) const; - void SelectEntry( const OUString& rStr ) - { ListBox::SelectEntry( rStr ); } - - void SelectEntry( const Color& rColor ) - { - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - ListBox::SelectEntryPos( nPos ); - } - Color GetSelectEntryColor() const { sal_Int32 nPos = GetSelectEntryPos(); @@ -77,25 +60,8 @@ public: return aColor; } - using ListBox::IsEntrySelected; - - bool IsEntrySelected(const Color& rColor) const - { - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - return IsEntryPosSelected( nPos ); - else - return false; - } - - void Fill( const XColorListRef &pTab ); - void Append( const XColorEntry& rEntry ); void Modify( const XColorEntry& rEntry, sal_Int32 nPos ); - -private: - ColorLB( const ColorLB& ) = delete; - ColorLB& operator =( const ColorLB& ) = delete; }; VCL_BUILDER_DECL_FACTORY(ColorLB) @@ -162,27 +128,6 @@ void ColorLB::dispose() ListBox::dispose(); } -sal_Int32 ColorLB::InsertEntry( const OUString& rStr, sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData; - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos ) { @@ -223,44 +168,6 @@ void ColorLB::Clear() ListBox::Clear(); } -void ColorLB::CopyEntries( const ColorLB& rBox ) -{ - // Liste leeren - ImplDestroyColorEntries(); - - // Daten kopieren - size_t nCount = rBox.pColorList->size(); - for ( size_t n = 0; n < nCount; n++ ) - { - ImplColorListData* pData = (*rBox.pColorList)[ n ]; - sal_Int32 nPos = InsertEntry( rBox.GetEntry( n ) ); - if ( nPos != LISTBOX_ERROR ) - { - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, new ImplColorListData( *pData ) ); - } - else - { - pColorList->push_back( new ImplColorListData( *pData ) ); - } - } - } -} - -sal_Int32 ColorLB::GetEntryPos( const Color& rColor ) const -{ - for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) - { - ImplColorListData* pData = (*pColorList)[ --n ]; - if ( pData->bColor && ( pData->aColor == rColor ) ) - return n; - } - return LISTBOX_ENTRY_NOTFOUND; -} - Color ColorLB::GetEntryColor( sal_Int32 nPos ) const { Color aColor; @@ -318,31 +225,9 @@ void ColorLB::UserDraw( const UserDrawEvent& rUDEvt ) ListBox::DrawEntry( rUDEvt, true, false ); } - -// Fills the Listbox with color and strings - -void ColorLB::Fill( const XColorListRef &pColorTab ) -{ - if( !pColorTab.is() ) - return; - - long nCount = pColorTab->Count(); - SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XColorEntry* pEntry = pColorTab->GetColor(i); - InsertEntry( pEntry->GetColor(), pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - SetUpdateMode( true ); -} - void ColorLB::Append( const XColorEntry& rEntry ) { InsertEntry( rEntry.GetColor(), rEntry.GetName() ); - AdaptDropDownLineCountToMaximum(); } void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos ) @@ -351,7 +236,6 @@ void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos ) InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos ); } - namespace { void FillBoxChartColorLB(ColorLB *pLB, const SvxChartColorTable & rTab) commit a19b18ad7c9eb0197c10e6d7e451ec4542e4bc9e Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 14:19:44 2016 +0000 move now combined ColorLB to location of last user Change-Id: I5dc1204c28b65d5dca993bf38aea217bbb49e913 diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 3d95da7..254b464 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -21,9 +21,337 @@ #include <cuires.hrc> #include "optchart.hxx" #include <dialmgr.hxx> +#include <vcl/builderfactory.hxx> #include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> #include <svx/svxids.hrc> +class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ListBox +{ + ImpColorList* pColorList; // separate liste, in case of user data are required from outside + Size aImageSize; + + using Window::ImplInit; + SVT_DLLPRIVATE void ImplInit(); + SVT_DLLPRIVATE void ImplDestroyColorEntries(); + +public: + ColorLB( vcl::Window* pParent, + WinBits nWinStyle = WB_BORDER ); + virtual ~ColorLB() override; + virtual void dispose() override; + + virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; + + using ListBox::InsertEntry; + sal_Int32 InsertEntry( const OUString& rStr, + sal_Int32 nPos = LISTBOX_APPEND ); + sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, + sal_Int32 nPos = LISTBOX_APPEND ); + bool IsAutomaticSelected() { return !GetSelectEntryPos(); } + using ListBox::RemoveEntry; + void RemoveEntry( sal_Int32 nPos ); + void Clear(); + void CopyEntries( const ColorLB& rBox ); + + using ListBox::GetEntryPos; + sal_Int32 GetEntryPos( const Color& rColor ) const; + Color GetEntryColor( sal_Int32 nPos ) const; + + void SelectEntry( const OUString& rStr ) + { ListBox::SelectEntry( rStr ); } + + void SelectEntry( const Color& rColor ) + { + sal_Int32 nPos = GetEntryPos( rColor ); + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + ListBox::SelectEntryPos( nPos ); + } + + Color GetSelectEntryColor() const + { + sal_Int32 nPos = GetSelectEntryPos(); + Color aColor; + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + aColor = GetEntryColor( nPos ); + return aColor; + } + + using ListBox::IsEntrySelected; + + bool IsEntrySelected(const Color& rColor) const + { + sal_Int32 nPos = GetEntryPos( rColor ); + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + return IsEntryPosSelected( nPos ); + else + return false; + } + + void Fill( const XColorListRef &pTab ); + + void Append( const XColorEntry& rEntry ); + void Modify( const XColorEntry& rEntry, sal_Int32 nPos ); + +private: + ColorLB( const ColorLB& ) = delete; + ColorLB& operator =( const ColorLB& ) = delete; +}; + +VCL_BUILDER_DECL_FACTORY(ColorLB) +{ + bool bDropdown = VclBuilder::extractDropdown(rMap); + WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP; + if (bDropdown) + nWinBits |= WB_DROPDOWN; + OString sBorder = VclBuilder::extractCustomProperty(rMap); + if (!sBorder.isEmpty()) + nWinBits |= WB_BORDER; + VclPtrInstance<ColorLB> pListBox(pParent, nWinBits); + pListBox->EnableAutoSize(true); + rRet = pListBox; +} + +class ImplColorListData +{ +public: + Color aColor; + bool bColor; + + ImplColorListData() : aColor( COL_BLACK ) { bColor = false; } + explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } +}; + +void ColorLB::ImplInit() +{ + pColorList = new ImpColorList(); + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); + EnableUserDraw( true ); + SetUserItemSize( aImageSize ); +} + +void ColorLB::ImplDestroyColorEntries() +{ + for ( size_t n = pColorList->size(); n; ) + delete (*pColorList)[ --n ]; + pColorList->clear(); +} + +ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) : + ListBox( pParent, nWinStyle ) +{ + ImplInit(); + SetEdgeBlending(true); +} + +ColorLB::~ColorLB() +{ + disposeOnce(); +} + +void ColorLB::dispose() +{ + if ( pColorList ) + { + ImplDestroyColorEntries(); + delete pColorList; + pColorList = nullptr; + } + ListBox::dispose(); +} + +sal_Int32 ColorLB::InsertEntry( const OUString& rStr, sal_Int32 nPos ) +{ + nPos = ListBox::InsertEntry( rStr, nPos ); + if ( nPos != LISTBOX_ERROR ) + { + ImplColorListData* pData = new ImplColorListData; + if ( static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + pColorList->insert( it, pData ); + } + else + { + pColorList->push_back( pData ); + nPos = pColorList->size() - 1; + } + } + return nPos; +} + +sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, + sal_Int32 nPos ) +{ + nPos = ListBox::InsertEntry( rStr, nPos ); + if ( nPos != LISTBOX_ERROR ) + { + ImplColorListData* pData = new ImplColorListData( rColor ); + if ( static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + pColorList->insert( it, pData ); + } + else + { + pColorList->push_back( pData ); + nPos = pColorList->size() - 1; + } + } + return nPos; +} + +void ColorLB::RemoveEntry( sal_Int32 nPos ) +{ + ListBox::RemoveEntry( nPos ); + if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + delete *it; + pColorList->erase( it ); + } +} + +void ColorLB::Clear() +{ + ImplDestroyColorEntries(); + ListBox::Clear(); +} + +void ColorLB::CopyEntries( const ColorLB& rBox ) +{ + // Liste leeren + ImplDestroyColorEntries(); + + // Daten kopieren + size_t nCount = rBox.pColorList->size(); + for ( size_t n = 0; n < nCount; n++ ) + { + ImplColorListData* pData = (*rBox.pColorList)[ n ]; + sal_Int32 nPos = InsertEntry( rBox.GetEntry( n ) ); + if ( nPos != LISTBOX_ERROR ) + { + if ( static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + pColorList->insert( it, new ImplColorListData( *pData ) ); + } + else + { + pColorList->push_back( new ImplColorListData( *pData ) ); + } + } + } +} + +sal_Int32 ColorLB::GetEntryPos( const Color& rColor ) const +{ + for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) + { + ImplColorListData* pData = (*pColorList)[ --n ]; + if ( pData->bColor && ( pData->aColor == rColor ) ) + return n; + } + return LISTBOX_ENTRY_NOTFOUND; +} + +Color ColorLB::GetEntryColor( sal_Int32 nPos ) const +{ + Color aColor; + ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? + (*pColorList)[ nPos ] : nullptr; + if ( pData && pData->bColor ) + aColor = pData->aColor; + return aColor; +} + +void ColorLB::UserDraw( const UserDrawEvent& rUDEvt ) +{ + size_t nPos = rUDEvt.GetItemId(); + ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; + if ( pData ) + { + if ( pData->bColor ) + { + Point aPos( rUDEvt.GetRect().TopLeft() ); + + aPos.X() += 2; + aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2; + + const Rectangle aRect(aPos, aImageSize); + + vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); + pRenderContext->Push(); + pRenderContext->SetFillColor(pData->aColor); + pRenderContext->SetLineColor(pRenderContext->GetTextColor()); + pRenderContext->DrawRect(aRect); + pRenderContext->Pop(); + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); + + if(nEdgeBlendingPercent) + { + const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); + const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); + const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); + const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); + + if(!aBlendFrame.IsEmpty()) + { + pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); + } + } + + ListBox::DrawEntry( rUDEvt, false, false ); + } + else + ListBox::DrawEntry( rUDEvt, false, true ); + } + else + ListBox::DrawEntry( rUDEvt, true, false ); +} + + +// Fills the Listbox with color and strings + +void ColorLB::Fill( const XColorListRef &pColorTab ) +{ + if( !pColorTab.is() ) + return; + + long nCount = pColorTab->Count(); + SetUpdateMode( false ); + + for( long i = 0; i < nCount; i++ ) + { + const XColorEntry* pEntry = pColorTab->GetColor(i); + InsertEntry( pEntry->GetColor(), pEntry->GetName() ); + } + + AdaptDropDownLineCountToMaximum(); + SetUpdateMode( true ); +} + +void ColorLB::Append( const XColorEntry& rEntry ) +{ + InsertEntry( rEntry.GetColor(), rEntry.GetName() ); + AdaptDropDownLineCountToMaximum(); +} + +void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos ) +{ + RemoveEntry( nPos ); + InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos ); +} + + namespace { void FillBoxChartColorLB(ColorLB *pLB, const SvxChartColorTable & rTab) diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index 34cd211..30f3196 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -29,6 +29,8 @@ #include "cfgchart.hxx" +class ColorLB; + class SvxDefaultColorOptPage : public SfxTabPage { diff --git a/cui/uiconfig/ui/optchartcolorspage.ui b/cui/uiconfig/ui/optchartcolorspage.ui index 3cadc55..f01beda 100644 --- a/cui/uiconfig/ui/optchartcolorspage.ui +++ b/cui/uiconfig/ui/optchartcolorspage.ui @@ -26,7 +26,7 @@ <property name="top_padding">6</property> <property name="left_padding">12</property> <child> - <object class="svxlo-ColorLB" id="colors:border"> + <object class="cuilo-ColorLB" id="colors:border"> <property name="dropdown">False</property> <property name="visible">True</property> <property name="can_focus">True</property> diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index cb0eec0..39cc688 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -207,80 +207,6 @@ public: /************************************************************************/ -class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ListBox -{ - ImpColorList* pColorList; // separate liste, in case of user data are required from outside - Size aImageSize; - - using Window::ImplInit; - SVT_DLLPRIVATE void ImplInit(); - SVT_DLLPRIVATE void ImplDestroyColorEntries(); - -public: - ColorLB( vcl::Window* pParent, - WinBits nWinStyle = WB_BORDER ); - virtual ~ColorLB() override; - virtual void dispose() override; - - virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; - - using ListBox::InsertEntry; - sal_Int32 InsertEntry( const OUString& rStr, - sal_Int32 nPos = LISTBOX_APPEND ); - sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos = LISTBOX_APPEND ); - bool IsAutomaticSelected() { return !GetSelectEntryPos(); } - using ListBox::RemoveEntry; - void RemoveEntry( sal_Int32 nPos ); - void Clear(); - void CopyEntries( const ColorLB& rBox ); - - using ListBox::GetEntryPos; - sal_Int32 GetEntryPos( const Color& rColor ) const; - Color GetEntryColor( sal_Int32 nPos ) const; - - void SelectEntry( const OUString& rStr ) - { ListBox::SelectEntry( rStr ); } - - void SelectEntry( const Color& rColor ) - { - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - ListBox::SelectEntryPos( nPos ); - } - - Color GetSelectEntryColor() const - { - sal_Int32 nPos = GetSelectEntryPos(); - Color aColor; - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - aColor = GetEntryColor( nPos ); - return aColor; - } - - using ListBox::IsEntrySelected; - - bool IsEntrySelected(const Color& rColor) const - { - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - return IsEntryPosSelected( nPos ); - else - return false; - } - - void Fill( const XColorListRef &pTab ); - - void Append( const XColorEntry& rEntry ); - void Modify( const XColorEntry& rEntry, sal_Int32 nPos ); - -private: - ColorLB( const ColorLB& ) = delete; - ColorLB& operator =( const ColorLB& ) = delete; -}; - -/************************************************************************/ - class SAL_WARN_UNUSED SVX_DLLPUBLIC HatchingLB : public ListBox { public: diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 3751903..d8f312b 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1103,259 +1103,6 @@ void SvxPixelCtl::Reset() Invalidate(); } -VCL_BUILDER_DECL_FACTORY(ColorLB) -{ - bool bDropdown = VclBuilder::extractDropdown(rMap); - WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE|WB_TABSTOP; - if (bDropdown) - nWinBits |= WB_DROPDOWN; - OString sBorder = VclBuilder::extractCustomProperty(rMap); - if (!sBorder.isEmpty()) - nWinBits |= WB_BORDER; - VclPtrInstance<ColorLB> pListBox(pParent, nWinBits); - pListBox->EnableAutoSize(true); - rRet = pListBox; -} - -class ImplColorListData -{ -public: - Color aColor; - bool bColor; - - ImplColorListData() : aColor( COL_BLACK ) { bColor = false; } - explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } -}; - -void ColorLB::ImplInit() -{ - pColorList = new ImpColorList(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); - EnableUserDraw( true ); - SetUserItemSize( aImageSize ); -} - -void ColorLB::ImplDestroyColorEntries() -{ - for ( size_t n = pColorList->size(); n; ) - delete (*pColorList)[ --n ]; - pColorList->clear(); -} - -ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) : - ListBox( pParent, nWinStyle ) -{ - ImplInit(); - SetEdgeBlending(true); -} - -ColorLB::~ColorLB() -{ - disposeOnce(); -} - -void ColorLB::dispose() -{ - if ( pColorList ) - { - ImplDestroyColorEntries(); - delete pColorList; - pColorList = nullptr; - } - ListBox::dispose(); -} - -sal_Int32 ColorLB::InsertEntry( const OUString& rStr, sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData; - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - -sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData( rColor ); - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - -void ColorLB::RemoveEntry( sal_Int32 nPos ) -{ - ListBox::RemoveEntry( nPos ); - if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - delete *it; - pColorList->erase( it ); - } -} - -void ColorLB::Clear() -{ - ImplDestroyColorEntries(); - ListBox::Clear(); -} - -void ColorLB::CopyEntries( const ColorLB& rBox ) -{ - // Liste leeren - ImplDestroyColorEntries(); - - // Daten kopieren - size_t nCount = rBox.pColorList->size(); - for ( size_t n = 0; n < nCount; n++ ) - { - ImplColorListData* pData = (*rBox.pColorList)[ n ]; - sal_Int32 nPos = InsertEntry( rBox.GetEntry( n ) ); - if ( nPos != LISTBOX_ERROR ) - { - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, new ImplColorListData( *pData ) ); - } - else - { - pColorList->push_back( new ImplColorListData( *pData ) ); - } - } - } -} - -sal_Int32 ColorLB::GetEntryPos( const Color& rColor ) const -{ - for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) - { - ImplColorListData* pData = (*pColorList)[ --n ]; - if ( pData->bColor && ( pData->aColor == rColor ) ) - return n; - } - return LISTBOX_ENTRY_NOTFOUND; -} - -Color ColorLB::GetEntryColor( sal_Int32 nPos ) const -{ - Color aColor; - ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? - (*pColorList)[ nPos ] : nullptr; - if ( pData && pData->bColor ) - aColor = pData->aColor; - return aColor; -} - -void ColorLB::UserDraw( const UserDrawEvent& rUDEvt ) -{ - size_t nPos = rUDEvt.GetItemId(); - ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; - if ( pData ) - { - if ( pData->bColor ) - { - Point aPos( rUDEvt.GetRect().TopLeft() ); - - aPos.X() += 2; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2; - - const Rectangle aRect(aPos, aImageSize); - - vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); - pRenderContext->Push(); - pRenderContext->SetFillColor(pData->aColor); - pRenderContext->SetLineColor(pRenderContext->GetTextColor()); - pRenderContext->DrawRect(aRect); - pRenderContext->Pop(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); - - if(nEdgeBlendingPercent) - { - const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); - const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); - const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); - const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); - - if(!aBlendFrame.IsEmpty()) - { - pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); - } - } - - ListBox::DrawEntry( rUDEvt, false, false ); - } - else - ListBox::DrawEntry( rUDEvt, false, true ); - } - else - ListBox::DrawEntry( rUDEvt, true, false ); -} - - -// Fills the Listbox with color and strings - -void ColorLB::Fill( const XColorListRef &pColorTab ) -{ - if( !pColorTab.is() ) - return; - - long nCount = pColorTab->Count(); - SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XColorEntry* pEntry = pColorTab->GetColor(i); - InsertEntry( pEntry->GetColor(), pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - SetUpdateMode( true ); -} - -void ColorLB::Append( const XColorEntry& rEntry ) -{ - InsertEntry( rEntry.GetColor(), rEntry.GetName() ); - AdaptDropDownLineCountToMaximum(); -} - -void ColorLB::Modify( const XColorEntry& rEntry, sal_Int32 nPos ) -{ - RemoveEntry( nPos ); - InsertEntry( rEntry.GetColor(), rEntry.GetName(), nPos ); -} - // Fills the listbox (provisional) with strings HatchingLB::HatchingLB( vcl::Window* pParent, WinBits nWinStyle) commit a989a0b1f2b425f05b58d0e44ce2de31c842ed65 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 14:14:54 2016 +0000 fold ColorListBox and ColorLB together Change-Id: I485109acd7cd4d6c2dc53e29f4b01bfc202a38f3 diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index 64ec881..cb0eec0 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -207,7 +207,7 @@ public: /************************************************************************/ -class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorListBox : public ListBox +class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ListBox { ImpColorList* pColorList; // separate liste, in case of user data are required from outside Size aImageSize; @@ -217,9 +217,9 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorListBox : public ListBox SVT_DLLPRIVATE void ImplDestroyColorEntries(); public: - ColorListBox( vcl::Window* pParent, + ColorLB( vcl::Window* pParent, WinBits nWinStyle = WB_BORDER ); - virtual ~ColorListBox() override; + virtual ~ColorLB() override; virtual void dispose() override; virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; @@ -233,7 +233,7 @@ public: using ListBox::RemoveEntry; void RemoveEntry( sal_Int32 nPos ); void Clear(); - void CopyEntries( const ColorListBox& rBox ); + void CopyEntries( const ColorLB& rBox ); using ListBox::GetEntryPos; sal_Int32 GetEntryPos( const Color& rColor ) const; @@ -241,8 +241,23 @@ public: void SelectEntry( const OUString& rStr ) { ListBox::SelectEntry( rStr ); } - void SelectEntry( const Color& rColor ); - Color GetSelectEntryColor() const; + + void SelectEntry( const Color& rColor ) + { + sal_Int32 nPos = GetEntryPos( rColor ); + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + ListBox::SelectEntryPos( nPos ); + } + + Color GetSelectEntryColor() const + { + sal_Int32 nPos = GetSelectEntryPos(); + Color aColor; + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + aColor = GetEntryColor( nPos ); + return aColor; + } + using ListBox::IsEntrySelected; bool IsEntrySelected(const Color& rColor) const @@ -254,38 +269,14 @@ public: return false; } -private: - ColorListBox( const ColorListBox& ) = delete; - ColorListBox& operator =( const ColorListBox& ) = delete; -}; - -inline void ColorListBox::SelectEntry( const Color& rColor ) -{ - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - ListBox::SelectEntryPos( nPos ); -} - -inline Color ColorListBox::GetSelectEntryColor() const -{ - sal_Int32 nPos = GetSelectEntryPos(); - Color aColor; - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - aColor = GetEntryColor( nPos ); - return aColor; -} - - -class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ColorListBox -{ - -public: - ColorLB( vcl::Window* pParent, WinBits aWB ) : ColorListBox( pParent, aWB ) {} - void Fill( const XColorListRef &pTab ); void Append( const XColorEntry& rEntry ); void Modify( const XColorEntry& rEntry, sal_Int32 nPos ); + +private: + ColorLB( const ColorLB& ) = delete; + ColorLB& operator =( const ColorLB& ) = delete; }; /************************************************************************/ diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 8793cfd..3751903 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1127,7 +1127,7 @@ public: explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } }; -void ColorListBox::ImplInit() +void ColorLB::ImplInit() { pColorList = new ImpColorList(); @@ -1137,26 +1137,26 @@ void ColorListBox::ImplInit() SetUserItemSize( aImageSize ); } -void ColorListBox::ImplDestroyColorEntries() +void ColorLB::ImplDestroyColorEntries() { for ( size_t n = pColorList->size(); n; ) delete (*pColorList)[ --n ]; pColorList->clear(); } -ColorListBox::ColorListBox( vcl::Window* pParent, WinBits nWinStyle ) : +ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) : ListBox( pParent, nWinStyle ) { ImplInit(); SetEdgeBlending(true); } -ColorListBox::~ColorListBox() +ColorLB::~ColorLB() { disposeOnce(); } -void ColorListBox::dispose() +void ColorLB::dispose() { if ( pColorList ) { @@ -1167,7 +1167,7 @@ void ColorListBox::dispose() ListBox::dispose(); } -sal_Int32 ColorListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos ) +sal_Int32 ColorLB::InsertEntry( const OUString& rStr, sal_Int32 nPos ) { nPos = ListBox::InsertEntry( rStr, nPos ); if ( nPos != LISTBOX_ERROR ) @@ -1188,7 +1188,7 @@ sal_Int32 ColorListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos ) return nPos; } -sal_Int32 ColorListBox::InsertEntry( const Color& rColor, const OUString& rStr, +sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr, sal_Int32 nPos ) { nPos = ListBox::InsertEntry( rStr, nPos ); @@ -1210,7 +1210,7 @@ sal_Int32 ColorListBox::InsertEntry( const Color& rColor, const OUString& rStr, return nPos; } -void ColorListBox::RemoveEntry( sal_Int32 nPos ) +void ColorLB::RemoveEntry( sal_Int32 nPos ) { ListBox::RemoveEntry( nPos ); if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) @@ -1222,13 +1222,13 @@ void ColorListBox::RemoveEntry( sal_Int32 nPos ) } } -void ColorListBox::Clear() +void ColorLB::Clear() { ImplDestroyColorEntries(); ListBox::Clear(); } -void ColorListBox::CopyEntries( const ColorListBox& rBox ) +void ColorLB::CopyEntries( const ColorLB& rBox ) { // Liste leeren ImplDestroyColorEntries(); @@ -1255,7 +1255,7 @@ void ColorListBox::CopyEntries( const ColorListBox& rBox ) } } -sal_Int32 ColorListBox::GetEntryPos( const Color& rColor ) const +sal_Int32 ColorLB::GetEntryPos( const Color& rColor ) const { for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) { @@ -1266,7 +1266,7 @@ sal_Int32 ColorListBox::GetEntryPos( const Color& rColor ) const return LISTBOX_ENTRY_NOTFOUND; } -Color ColorListBox::GetEntryColor( sal_Int32 nPos ) const +Color ColorLB::GetEntryColor( sal_Int32 nPos ) const { Color aColor; ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? @@ -1276,7 +1276,7 @@ Color ColorListBox::GetEntryColor( sal_Int32 nPos ) const return aColor; } -void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt ) +void ColorLB::UserDraw( const UserDrawEvent& rUDEvt ) { size_t nPos = rUDEvt.GetItemId(); ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; commit 760a198e697f3070a5e0e029e4eff7be220eb9cd Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 13:07:44 2016 +0000 move ColorListBox beside sole thing that uses it Change-Id: Ia458ded8881c415badd5d75bddad0daca57a1a25 diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx index c1ad071..28d1a34 100644 --- a/include/svtools/ctrlbox.hxx +++ b/include/svtools/ctrlbox.hxx @@ -42,17 +42,6 @@ typedef ::std::vector< FontMetric > ImplFontList; /************************************************************************* -Description -============ - -class ColorListBox - -Description - -Allows color selection - --------------------------------------------------------------------------- - class LineListBox Description @@ -141,75 +130,6 @@ FontList; FontNameBox; FontStyleBox; FontSizeMenu *************************************************************************/ -class SVT_DLLPUBLIC ColorListBox : public ListBox -{ - ImpColorList* pColorList; // separate liste, in case of user data are required from outside - Size aImageSize; - - using Window::ImplInit; - SVT_DLLPRIVATE void ImplInit(); - SVT_DLLPRIVATE void ImplDestroyColorEntries(); - -public: - ColorListBox( vcl::Window* pParent, - WinBits nWinStyle = WB_BORDER ); - virtual ~ColorListBox() override; - virtual void dispose() override; - - virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; - - using ListBox::InsertEntry; - sal_Int32 InsertEntry( const OUString& rStr, - sal_Int32 nPos = LISTBOX_APPEND ); - sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos = LISTBOX_APPEND ); - void InsertAutomaticEntryColor(const Color &rAutoColorValue); - bool IsAutomaticSelected() { return !GetSelectEntryPos(); } - using ListBox::RemoveEntry; - void RemoveEntry( sal_Int32 nPos ); - void Clear(); - void CopyEntries( const ColorListBox& rBox ); - - using ListBox::GetEntryPos; - sal_Int32 GetEntryPos( const Color& rColor ) const; - Color GetEntryColor( sal_Int32 nPos ) const; - - void SelectEntry( const OUString& rStr ) - { ListBox::SelectEntry( rStr ); } - void SelectEntry( const Color& rColor ); - Color GetSelectEntryColor() const; - using ListBox::IsEntrySelected; - - bool IsEntrySelected(const Color& rColor) const - { - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - return IsEntryPosSelected( nPos ); - else - return false; - } - -private: - ColorListBox( const ColorListBox& ) = delete; - ColorListBox& operator =( const ColorListBox& ) = delete; -}; - -inline void ColorListBox::SelectEntry( const Color& rColor ) -{ - sal_Int32 nPos = GetEntryPos( rColor ); - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - ListBox::SelectEntryPos( nPos ); -} - -inline Color ColorListBox::GetSelectEntryColor() const -{ - sal_Int32 nPos = GetSelectEntryPos(); - Color aColor; - if ( nPos != LISTBOX_ENTRY_NOTFOUND ) - aColor = GetEntryColor( nPos ); - return aColor; -} - /** Class computing border widths shared between Line style listbox and the SvxBorderLine implementation. diff --git a/include/svtools/svtools.hrc b/include/svtools/svtools.hrc index 92cc809..c149f86 100644 --- a/include/svtools/svtools.hrc +++ b/include/svtools/svtools.hrc @@ -26,8 +26,6 @@ // various unsorted stuff -#define STR_SVT_AUTOMATIC_COLOR (RID_SVTOOLS_START+16) - #define STR_SVT_FILEVIEW_COLUMN_TITLE (RID_SVTOOLS_START + 20) #define STR_SVT_FILEVIEW_COLUMN_SIZE (RID_SVTOOLS_START + 21) #define STR_SVT_FILEVIEW_COLUMN_DATE (RID_SVTOOLS_START + 22) diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index 5a2c217..64ec881 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -207,6 +207,75 @@ public: /************************************************************************/ +class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorListBox : public ListBox +{ + ImpColorList* pColorList; // separate liste, in case of user data are required from outside + Size aImageSize; + + using Window::ImplInit; + SVT_DLLPRIVATE void ImplInit(); + SVT_DLLPRIVATE void ImplDestroyColorEntries(); + +public: + ColorListBox( vcl::Window* pParent, + WinBits nWinStyle = WB_BORDER ); + virtual ~ColorListBox() override; + virtual void dispose() override; + + virtual void UserDraw( const UserDrawEvent& rUDEvt ) override; + + using ListBox::InsertEntry; + sal_Int32 InsertEntry( const OUString& rStr, + sal_Int32 nPos = LISTBOX_APPEND ); + sal_Int32 InsertEntry( const Color& rColor, const OUString& rStr, + sal_Int32 nPos = LISTBOX_APPEND ); + bool IsAutomaticSelected() { return !GetSelectEntryPos(); } + using ListBox::RemoveEntry; + void RemoveEntry( sal_Int32 nPos ); + void Clear(); + void CopyEntries( const ColorListBox& rBox ); + + using ListBox::GetEntryPos; + sal_Int32 GetEntryPos( const Color& rColor ) const; + Color GetEntryColor( sal_Int32 nPos ) const; + + void SelectEntry( const OUString& rStr ) + { ListBox::SelectEntry( rStr ); } + void SelectEntry( const Color& rColor ); + Color GetSelectEntryColor() const; + using ListBox::IsEntrySelected; + + bool IsEntrySelected(const Color& rColor) const + { + sal_Int32 nPos = GetEntryPos( rColor ); + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + return IsEntryPosSelected( nPos ); + else + return false; + } + +private: + ColorListBox( const ColorListBox& ) = delete; + ColorListBox& operator =( const ColorListBox& ) = delete; +}; + +inline void ColorListBox::SelectEntry( const Color& rColor ) +{ + sal_Int32 nPos = GetEntryPos( rColor ); + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + ListBox::SelectEntryPos( nPos ); +} + +inline Color ColorListBox::GetSelectEntryColor() const +{ + sal_Int32 nPos = GetSelectEntryPos(); + Color aColor; + if ( nPos != LISTBOX_ENTRY_NOTFOUND ) + aColor = GetEntryColor( nPos ); + return aColor; +} + + class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ColorListBox { diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index b54e54c..ce72348 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -59,218 +59,6 @@ #define FONTNAMEBOXMRUENTRIESFILE "/user/config/fontnameboxmruentries" -class ImplColorListData -{ -public: - Color aColor; - bool bColor; - - ImplColorListData() : aColor( COL_BLACK ) { bColor = false; } - explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } -}; - -void ColorListBox::ImplInit() -{ - pColorList = new ImpColorList(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); - EnableUserDraw( true ); - SetUserItemSize( aImageSize ); -} - -void ColorListBox::ImplDestroyColorEntries() -{ - for ( size_t n = pColorList->size(); n; ) - delete (*pColorList)[ --n ]; - pColorList->clear(); -} - -ColorListBox::ColorListBox( vcl::Window* pParent, WinBits nWinStyle ) : - ListBox( pParent, nWinStyle ) -{ - ImplInit(); - SetEdgeBlending(true); -} - -ColorListBox::~ColorListBox() -{ - disposeOnce(); -} - -void ColorListBox::dispose() -{ - if ( pColorList ) - { - ImplDestroyColorEntries(); - delete pColorList; - pColorList = nullptr; - } - ListBox::dispose(); -} - -sal_Int32 ColorListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData; - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - -sal_Int32 ColorListBox::InsertEntry( const Color& rColor, const OUString& rStr, - sal_Int32 nPos ) -{ - nPos = ListBox::InsertEntry( rStr, nPos ); - if ( nPos != LISTBOX_ERROR ) - { - ImplColorListData* pData = new ImplColorListData( rColor ); - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, pData ); - } - else - { - pColorList->push_back( pData ); - nPos = pColorList->size() - 1; - } - } - return nPos; -} - -void ColorListBox::InsertAutomaticEntryColor(const Color &rColor) -{ - // insert the "Automatic"-entry always on the first position - InsertEntry( rColor, SVT_RESSTR(STR_SVT_AUTOMATIC_COLOR), 0 ); -} - -void ColorListBox::RemoveEntry( sal_Int32 nPos ) -{ - ListBox::RemoveEntry( nPos ); - if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - delete *it; - pColorList->erase( it ); - } -} - -void ColorListBox::Clear() -{ - ImplDestroyColorEntries(); - ListBox::Clear(); -} - -void ColorListBox::CopyEntries( const ColorListBox& rBox ) -{ - // Liste leeren - ImplDestroyColorEntries(); - - // Daten kopieren - size_t nCount = rBox.pColorList->size(); - for ( size_t n = 0; n < nCount; n++ ) - { - ImplColorListData* pData = (*rBox.pColorList)[ n ]; - sal_Int32 nPos = InsertEntry( rBox.GetEntry( n ) ); - if ( nPos != LISTBOX_ERROR ) - { - if ( static_cast<size_t>(nPos) < pColorList->size() ) - { - ImpColorList::iterator it = pColorList->begin(); - ::std::advance( it, nPos ); - pColorList->insert( it, new ImplColorListData( *pData ) ); - } - else - { - pColorList->push_back( new ImplColorListData( *pData ) ); - } - } - } -} - -sal_Int32 ColorListBox::GetEntryPos( const Color& rColor ) const -{ - for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) - { - ImplColorListData* pData = (*pColorList)[ --n ]; - if ( pData->bColor && ( pData->aColor == rColor ) ) - return n; - } - return LISTBOX_ENTRY_NOTFOUND; -} - -Color ColorListBox::GetEntryColor( sal_Int32 nPos ) const -{ - Color aColor; - ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? - (*pColorList)[ nPos ] : nullptr; - if ( pData && pData->bColor ) - aColor = pData->aColor; - return aColor; -} - -void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt ) -{ - size_t nPos = rUDEvt.GetItemId(); - ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; - if ( pData ) - { - if ( pData->bColor ) - { - Point aPos( rUDEvt.GetRect().TopLeft() ); - - aPos.X() += 2; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2; - - const Rectangle aRect(aPos, aImageSize); - - vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); - pRenderContext->Push(); - pRenderContext->SetFillColor(pData->aColor); - pRenderContext->SetLineColor(pRenderContext->GetTextColor()); - pRenderContext->DrawRect(aRect); - pRenderContext->Pop(); - - const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); - const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); - - if(nEdgeBlendingPercent) - { - const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); - const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); - const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); - const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); - - if(!aBlendFrame.IsEmpty()) - { - pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); - } - } - - ListBox::DrawEntry( rUDEvt, false, false ); - } - else - ListBox::DrawEntry( rUDEvt, false, true ); - } - else - ListBox::DrawEntry( rUDEvt, true, false ); -} - BorderWidthImpl::BorderWidthImpl( BorderWidthImplFlags nFlags, double nRate1, double nRate2, double nRateGap ): m_nFlags( nFlags ), m_nRate1( nRate1 ), diff --git a/svtools/source/control/ctrlbox.src b/svtools/source/control/ctrlbox.src index 36036d9..4d04006 100644 --- a/svtools/source/control/ctrlbox.src +++ b/svtools/source/control/ctrlbox.src @@ -18,11 +18,6 @@ */ #include <svtools/svtools.hrc> -String STR_SVT_AUTOMATIC_COLOR -{ - Text [ en-US ] = "Automatic"; -}; - /* * resources for CollatorResource / CollatorResourceData resp. */ diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 0ee46f7..8793cfd 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1117,6 +1117,213 @@ VCL_BUILDER_DECL_FACTORY(ColorLB) rRet = pListBox; } +class ImplColorListData +{ +public: + Color aColor; + bool bColor; + + ImplColorListData() : aColor( COL_BLACK ) { bColor = false; } + explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; } +}; + +void ColorListBox::ImplInit() +{ + pColorList = new ImpColorList(); + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + aImageSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize(); + EnableUserDraw( true ); + SetUserItemSize( aImageSize ); +} + +void ColorListBox::ImplDestroyColorEntries() +{ + for ( size_t n = pColorList->size(); n; ) + delete (*pColorList)[ --n ]; + pColorList->clear(); +} + +ColorListBox::ColorListBox( vcl::Window* pParent, WinBits nWinStyle ) : + ListBox( pParent, nWinStyle ) +{ + ImplInit(); + SetEdgeBlending(true); +} + +ColorListBox::~ColorListBox() +{ + disposeOnce(); +} + +void ColorListBox::dispose() +{ + if ( pColorList ) + { + ImplDestroyColorEntries(); + delete pColorList; + pColorList = nullptr; + } + ListBox::dispose(); +} + +sal_Int32 ColorListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos ) +{ + nPos = ListBox::InsertEntry( rStr, nPos ); + if ( nPos != LISTBOX_ERROR ) + { + ImplColorListData* pData = new ImplColorListData; + if ( static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + pColorList->insert( it, pData ); + } + else + { + pColorList->push_back( pData ); + nPos = pColorList->size() - 1; + } + } + return nPos; +} + +sal_Int32 ColorListBox::InsertEntry( const Color& rColor, const OUString& rStr, + sal_Int32 nPos ) +{ + nPos = ListBox::InsertEntry( rStr, nPos ); + if ( nPos != LISTBOX_ERROR ) + { + ImplColorListData* pData = new ImplColorListData( rColor ); + if ( static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + pColorList->insert( it, pData ); + } + else + { + pColorList->push_back( pData ); + nPos = pColorList->size() - 1; + } + } + return nPos; +} + +void ColorListBox::RemoveEntry( sal_Int32 nPos ) +{ + ListBox::RemoveEntry( nPos ); + if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + delete *it; + pColorList->erase( it ); + } +} + +void ColorListBox::Clear() +{ + ImplDestroyColorEntries(); + ListBox::Clear(); +} + +void ColorListBox::CopyEntries( const ColorListBox& rBox ) +{ + // Liste leeren + ImplDestroyColorEntries(); + + // Daten kopieren + size_t nCount = rBox.pColorList->size(); + for ( size_t n = 0; n < nCount; n++ ) + { + ImplColorListData* pData = (*rBox.pColorList)[ n ]; + sal_Int32 nPos = InsertEntry( rBox.GetEntry( n ) ); + if ( nPos != LISTBOX_ERROR ) + { + if ( static_cast<size_t>(nPos) < pColorList->size() ) + { + ImpColorList::iterator it = pColorList->begin(); + ::std::advance( it, nPos ); + pColorList->insert( it, new ImplColorListData( *pData ) ); + } + else + { + pColorList->push_back( new ImplColorListData( *pData ) ); + } + } + } +} + +sal_Int32 ColorListBox::GetEntryPos( const Color& rColor ) const +{ + for( sal_Int32 n = (sal_Int32) pColorList->size(); n; ) + { + ImplColorListData* pData = (*pColorList)[ --n ]; + if ( pData->bColor && ( pData->aColor == rColor ) ) + return n; + } + return LISTBOX_ENTRY_NOTFOUND; +} + +Color ColorListBox::GetEntryColor( sal_Int32 nPos ) const +{ + Color aColor; + ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ? + (*pColorList)[ nPos ] : nullptr; + if ( pData && pData->bColor ) + aColor = pData->aColor; + return aColor; +} + +void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt ) +{ + size_t nPos = rUDEvt.GetItemId(); + ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr; + if ( pData ) + { + if ( pData->bColor ) + { + Point aPos( rUDEvt.GetRect().TopLeft() ); + + aPos.X() += 2; + aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2; + + const Rectangle aRect(aPos, aImageSize); + + vcl::RenderContext* pRenderContext = rUDEvt.GetRenderContext(); + pRenderContext->Push(); + pRenderContext->SetFillColor(pData->aColor); + pRenderContext->SetLineColor(pRenderContext->GetTextColor()); + pRenderContext->DrawRect(aRect); + pRenderContext->Pop(); + + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0); + + if(nEdgeBlendingPercent) + { + const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor()); + const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor()); + const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100); + const BitmapEx aBlendFrame(createBlendFrame(aRect.GetSize(), nAlpha, rTopLeft, rBottomRight)); + + if(!aBlendFrame.IsEmpty()) + { + pRenderContext->DrawBitmapEx(aRect.TopLeft(), aBlendFrame); + } + } + + ListBox::DrawEntry( rUDEvt, false, false ); + } + else + ListBox::DrawEntry( rUDEvt, false, true ); + } + else + ListBox::DrawEntry( rUDEvt, true, false ); +} + + // Fills the Listbox with color and strings void ColorLB::Fill( const XColorListRef &pColorTab ) commit 8bea644d6117a49405e6426dc97214220fc869d1 Author: Caolán McNamara <caol...@redhat.com> Date: Fri Nov 4 13:47:35 2016 +0000 extensions leaks out details of Color Selector, patch it up and rebase it on SvxColorListBox Change-Id: I3afef689ab0dc3c34e465810d82bf21797907558 diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx index 7458804..6e9cb6b 100644 --- a/extensions/source/propctrlr/commoncontrol.cxx +++ b/extensions/source/propctrlr/commoncontrol.cxx @@ -104,6 +104,11 @@ namespace pcr setModified(); } + IMPL_LINK_NOARG( CommonBehaviourControlHelper, ColorModifiedHdl, SvxColorListBox&, void ) + { + setModified(); + } + IMPL_LINK_NOARG( CommonBehaviourControlHelper, GetFocusHdl, Control&, void ) { try diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx index 05771dd..0d46aaa 100644 --- a/extensions/source/propctrlr/commoncontrol.hxx +++ b/extensions/source/propctrlr/commoncontrol.hxx @@ -32,6 +32,7 @@ class NotifyEvent; class Control; class ListBox; +class SvxColorListBox; class Edit; namespace pcr @@ -90,6 +91,7 @@ namespace pcr /// may be used by derived classes, they forward the event to the PropCtrListener DECL_LINK( ModifiedHdl, ListBox&, void ); + DECL_LINK( ColorModifiedHdl, SvxColorListBox&, void ); DECL_LINK( EditModifiedHdl, Edit&, void ); DECL_LINK( GetFocusHdl, Control&, void ); DECL_LINK( LoseFocusHdl, Control&, void ); @@ -150,8 +152,9 @@ namespace pcr inline void impl_checkDisposed_throw(); private: VclPtr<TControlWindow> m_pControlWindow; - void implSetModifyHandler(std::true_type); - void implSetModifyHandler(std::false_type); + void implSetModifyHandler(const Edit&); + void implSetModifyHandler(const ListBox&); + void implSetModifyHandler(const SvxColorListBox&); }; @@ -165,7 +168,7 @@ namespace pcr { if ( _bDoSetHandlers ) { - implSetModifyHandler(std::is_base_of<::Edit,TControlWindow>()); + implSetModifyHandler(*m_pControlWindow); m_pControlWindow->SetGetFocusHdl( LINK( this, CommonBehaviourControlHelper, GetFocusHdl ) ); m_pControlWindow->SetLoseFocusHdl( LINK( this, CommonBehaviourControlHelper, LoseFocusHdl ) ); } @@ -173,18 +176,24 @@ namespace pcr } template< class TControlInterface, class TControlWindow > - inline void CommonBehaviourControl< TControlInterface, TControlWindow >::implSetModifyHandler(std::true_type) + inline void CommonBehaviourControl< TControlInterface, TControlWindow >::implSetModifyHandler(const Edit&) { m_pControlWindow->SetModifyHdl( LINK( this, CommonBehaviourControlHelper, EditModifiedHdl ) ); } template< class TControlInterface, class TControlWindow > - inline void CommonBehaviourControl< TControlInterface, TControlWindow >::implSetModifyHandler(std::false_type) + inline void CommonBehaviourControl< TControlInterface, TControlWindow >::implSetModifyHandler(const ListBox&) { m_pControlWindow->SetModifyHdl( LINK( this, CommonBehaviourControlHelper, ModifiedHdl ) ); } template< class TControlInterface, class TControlWindow > + inline void CommonBehaviourControl< TControlInterface, TControlWindow >::implSetModifyHandler(const SvxColorListBox&) + { + m_pControlWindow->SetModifyHdl( LINK( this, CommonBehaviourControlHelper, ColorModifiedHdl ) ); + } + + template< class TControlInterface, class TControlWindow > inline void CommonBehaviourControl< TControlInterface, TControlWindow >::impl_checkDisposed_throw() { if ( ComponentBaseClass::rBHelper.bDisposed ) diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index ca2412f..7d42296 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -657,141 +657,50 @@ namespace pcr return aStr.makeStringAndClear(); } - OColorControl::OColorControl(vcl::Window* pParent, WinBits nWinStyle) - :OColorControl_Base( PropertyControlType::ColorListBox, pParent, nWinStyle ) + : OColorControl_Base(PropertyControlType::ColorListBox, pParent, nWinStyle) { - // initialize the color listbox - XColorListRef pColorList; - SfxObjectShell* pDocSh = SfxObjectShell::Current(); - const SfxPoolItem* pItem = pDocSh ? pDocSh->GetItem( SID_COLOR_TABLE ) : nullptr; - if ( pItem ) - { - DBG_ASSERT(dynamic_cast< const SvxColorListItem* >(pItem) != nullptr, "OColorControl::OColorControl: invalid color item!"); - pColorList = static_cast<const SvxColorListItem*>( pItem )->GetColorList(); - } - - if ( !pColorList.is() ) - pColorList = XColorList::GetStdColorList(); - - - DBG_ASSERT(pColorList.is(), "OColorControl::OColorControl: no color table!"); - - if ( pColorList.is() ) - { - for (long i = 0; i < pColorList->Count(); ++i) - { - const XColorEntry* pEntry = pColorList->GetColor(i); - getTypedControlWindow()->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); - } - } - - getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT ); - if ( ( nWinStyle & WB_READONLY ) != 0 ) - { - getTypedControlWindow()->SetReadOnly(); - getTypedControlWindow()->Enable(); - } } - void SAL_CALL OColorControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException, std::exception) { if ( _rValue.hasValue() ) { css::util::Color nColor = COL_TRANSPARENT; - if ( _rValue >>= nColor ) - { - ::Color aRgbCol((ColorData)nColor); - - getTypedControlWindow()->SelectEntry( aRgbCol ); - if ( !getTypedControlWindow()->IsEntrySelected( aRgbCol ) ) - { // the given color is not part of the list -> insert a new entry with the hex code of the color - OUString aStr("0x"); - aStr += MakeHexStr(nColor,8); - getTypedControlWindow()->InsertEntry( aRgbCol, aStr ); - getTypedControlWindow()->SelectEntry( aRgbCol ); - } - } - else - { - OUString sNonColorValue; - if ( !( _rValue >>= sNonColorValue ) ) - throw IllegalTypeException(); - getTypedControlWindow()->SelectEntry( sNonColorValue ); - if ( !getTypedControlWindow()->IsEntrySelected( sNonColorValue ) ) - getTypedControlWindow()->SetNoSelection(); - } + _rValue >>= nColor; + ::Color aRgbCol((ColorData)nColor); + getTypedControlWindow()->SelectEntry(std::make_pair(aRgbCol, MakeHexStr(nColor, 8))); } else getTypedControlWindow()->SetNoSelection(); } - Any SAL_CALL OColorControl::getValue() throw (RuntimeException, std::exception) { Any aPropValue; - if ( getTypedControlWindow()->GetSelectEntryCount() > 0 ) + if (!getTypedControlWindow()->IsNoSelection()) { - OUString sSelectedEntry = getTypedControlWindow()->GetSelectEntry(); - if ( m_aNonColorEntries.find( sSelectedEntry ) != m_aNonColorEntries.end() ) - aPropValue <<= sSelectedEntry; - else - { - ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits