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()
void ConditionColorWrapper::dispose()
{
disposeOnce();
mxControl.clear();
}
void OColorPopup::dispose()
void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const NamedColor& rNamedColor)
{
disposeBuilder();
m_aColorSet.disposeAndClear();
m_pCondition.clear();
FloatingWindow::dispose();
mxControl->ApplyCommand(mnSlotId, rNamedColor.first);
}
void OColorPopup::KeyInput( const KeyEvent& rKEvt )
{
m_aColorSet->KeyInput(rKEvt);
}
void OColorPopup::Resize()
{
Size aSize = GetOutputSizePixel();
aSize.Width() -= 4;
aSize.Height() -= 4;
m_aColorSet->SetPosSizePixel( Point(2,2), aSize );
}
void OColorPopup::StartSelection()
{
m_aColorSet->StartSelection();
}
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);
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);
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->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();
}