[Libreoffice-commits] core.git: sc/source sc/uiconfig
Maxim Monastirsky
momonasmon at gmail.com
Sun May 11 09:23:14 PDT 2014
sc/source/ui/sidebar/AlignmentPropertyPanel.cxx | 244 ++----------------------
sc/source/ui/sidebar/AlignmentPropertyPanel.hxx | 11 -
sc/uiconfig/scalc/ui/sidebaralignment.ui | 4
3 files changed, 31 insertions(+), 228 deletions(-)
New commits:
commit f1cb19422a023c5cd8b80e871037c3522fd6eb50
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Sun May 11 19:12:21 2014 +0300
sc: some cleanup of the alignment panel
- Use generic Toolbox handler when possible.
- Use bool values directly, instead of if-else blocks.
Change-Id: Ica4986ed3fd2aa5c1babac7fa29f0ca67717c019
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index d7d0d87..8e6b164 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -17,12 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <sfx2/sidebar/ResourceDefinitions.hrc>
-#include <sfx2/sidebar/Theme.hxx>
-#include <sfx2/sidebar/ControlFactory.hxx>
#include "AlignmentPropertyPanel.hxx"
#include <editeng/justifyitem.hxx>
-#include <svx/dialmgr.hxx>
#include "sc.hrc"
#include "scresid.hxx"
#include <sfx2/bindings.hxx>
@@ -34,16 +30,6 @@
using namespace css;
using namespace cssu;
-using ::sfx2::sidebar::ControlFactory;
-
-const char UNO_ALIGNBLOCK[] = ".uno:AlignBlock";
-const char UNO_ALIGNBOTTOM[] = ".uno:AlignBottom";
-const char UNO_ALIGNLEFT[] = ".uno:AlignLeft";
-const char UNO_ALIGNHORIZONTALCENTER[] = ".uno:AlignHorizontalCenter";
-const char UNO_ALIGNRIGHT[] = ".uno:AlignRight";
-const char UNO_ALIGNTOP[] = ".uno:AlignTop";
-const char UNO_ALIGNVCENTER[] = ".uno:AlignVCenter";
-
// namespace open
@@ -55,21 +41,16 @@ AlignmentPropertyPanel::AlignmentPropertyPanel(
SfxBindings* pBindings)
: PanelLayout(pParent, "AlignmentPropertyPanel", "modules/scalc/ui/sidebaralignment.ui", rxFrame),
maAlignHorControl(SID_H_ALIGNCELL, *pBindings, *this),
- maAlignVerControl(SID_V_ALIGNCELL, *pBindings, *this),
maLeftIndentControl(SID_ATTR_ALIGN_INDENT, *pBindings, *this),
maMergeCellControl(FID_MERGE_TOGGLE, *pBindings, *this),
maWrapTextControl(SID_ATTR_ALIGN_LINEBREAK, *pBindings, *this),
maAngleControl(SID_ATTR_ALIGN_DEGREES, *pBindings, *this),
maStackControl(SID_ATTR_ALIGN_STACKED, *pBindings, *this),
- meHorAlignState(SVX_HOR_JUSTIFY_STANDARD),
- meVerAlignState(SVX_VER_JUSTIFY_STANDARD),
mbMultiDisable(false),
mxFrame(rxFrame),
maContext(),
mpBindings(pBindings)
{
- get(mpTBHorizontal, "horizontalalignment");
- get(mpTBVertical, "verticalalignment");
get(mpFTLeftIndent, "leftindentlabel");
get(mpMFLeftIndent, "leftindent");
get(mpCBXWrapText, "wraptext");
@@ -91,16 +72,10 @@ AlignmentPropertyPanel::~AlignmentPropertyPanel()
void AlignmentPropertyPanel::Initialize()
{
- Link aLink = LINK(this, AlignmentPropertyPanel, TbxHorAlignSelectHdl);
- mpTBHorizontal->SetSelectHdl ( aLink );
-
- aLink = LINK(this, AlignmentPropertyPanel, TbxVerAlignSelectHdl);
- mpTBVertical->SetSelectHdl ( aLink );
-
mpFTLeftIndent->Disable();
mpMFLeftIndent->Disable();
mpMFLeftIndent->SetAccessibleName(OUString( "Left Indent")); //wj acc
- aLink = LINK(this, AlignmentPropertyPanel, MFLeftIndentMdyHdl);
+ Link aLink = LINK(this, AlignmentPropertyPanel, MFLeftIndentMdyHdl);
mpMFLeftIndent->SetModifyHdl ( aLink );
aLink = LINK(this, AlignmentPropertyPanel, CBOXMergnCellClkHdl);
@@ -131,13 +106,8 @@ void AlignmentPropertyPanel::Initialize()
mpMtrAngle->InsertValue(315, FUNIT_CUSTOM);
mpMtrAngle->SetDropDownLineCount(mpMtrAngle->GetEntryCount());
- mpTBHorizontal->SetAccessibleRelationLabeledBy(mpTBHorizontal);
- mpTBVertical->SetAccessibleRelationLabeledBy(mpTBVertical);
mpMFLeftIndent->SetAccessibleRelationLabeledBy(mpFTLeftIndent);
mpMtrAngle->SetAccessibleRelationLabeledBy(mpFtRotate);
-#ifdef HAS_IA2
- mpMtrAngle->SetMpSubEditAccLableBy(mpFtRotate);
-#endif
}
IMPL_LINK( AlignmentPropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
@@ -180,75 +150,6 @@ IMPL_LINK( AlignmentPropertyPanel, ClickStackHdl, void *, EMPTYARG )
return 0;
}
-IMPL_LINK(AlignmentPropertyPanel, TbxHorAlignSelectHdl, ToolBox*, pToolBox)
-{
- const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
-
- if(aCommand == UNO_ALIGNLEFT)
- {
- if(meHorAlignState != SVX_HOR_JUSTIFY_LEFT)
- meHorAlignState = SVX_HOR_JUSTIFY_LEFT;
- else
- meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
- }
- else if(aCommand == UNO_ALIGNHORIZONTALCENTER )
- {
- if(meHorAlignState != SVX_HOR_JUSTIFY_CENTER)
- meHorAlignState = SVX_HOR_JUSTIFY_CENTER;
- else
- meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
- }
- else if(aCommand == UNO_ALIGNRIGHT )
- {
- if(meHorAlignState != SVX_HOR_JUSTIFY_RIGHT)
- meHorAlignState = SVX_HOR_JUSTIFY_RIGHT;
- else
- meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
- }
- else if(aCommand == UNO_ALIGNBLOCK )
- {
- if(meHorAlignState != SVX_HOR_JUSTIFY_BLOCK)
- meHorAlignState = SVX_HOR_JUSTIFY_BLOCK;
- else
- meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
- }
- SvxHorJustifyItem aHorItem(meHorAlignState, SID_H_ALIGNCELL);
- GetBindings()->GetDispatcher()->Execute(SID_H_ALIGNCELL, SFX_CALLMODE_RECORD, &aHorItem, 0L);
- UpdateHorAlign();
- return 0;
-}
-
-IMPL_LINK(AlignmentPropertyPanel, TbxVerAlignSelectHdl, ToolBox*, pToolBox)
-{
- const OUString aCommand(pToolBox->GetItemCommand(pToolBox->GetCurItemId()));
-
- if(aCommand == UNO_ALIGNTOP)
- {
- if(meVerAlignState != SVX_VER_JUSTIFY_TOP)
- meVerAlignState = SVX_VER_JUSTIFY_TOP;
- else
- meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
- }
- else if(aCommand == UNO_ALIGNVCENTER)
- {
- if(meVerAlignState != SVX_VER_JUSTIFY_CENTER)
- meVerAlignState = SVX_VER_JUSTIFY_CENTER;
- else
- meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
- }
- else if(aCommand == UNO_ALIGNBOTTOM)
- {
- if(meVerAlignState != SVX_VER_JUSTIFY_BOTTOM)
- meVerAlignState = SVX_VER_JUSTIFY_BOTTOM;
- else
- meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
- }
- SvxVerJustifyItem aVerItem(meVerAlignState, SID_V_ALIGNCELL);
- GetBindings()->GetDispatcher()->Execute(SID_V_ALIGNCELL, SFX_CALLMODE_RECORD, &aVerItem, 0L);
- UpdateVerAlign();
- return 0;
-}
-
IMPL_LINK(AlignmentPropertyPanel, MFLeftIndentMdyHdl, void*, EMPTYARG)
{
mpCBXWrapText->EnableTriState(false);
@@ -333,28 +234,31 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
switch(nSID)
{
case SID_H_ALIGNCELL:
- if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxHorJustifyItem) )
{
+ SvxCellHorJustify meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
+ if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxHorJustifyItem) )
+ {
const SvxHorJustifyItem* pItem = (const SvxHorJustifyItem*)pState;
meHorAlignState = (SvxCellHorJustify)pItem->GetValue();
+ }
+
+ if( meHorAlignState == SVX_HOR_JUSTIFY_REPEAT )
+ {
+ mpFtRotate->Disable();
+ mpCtrlDial->Disable();
+ mpMtrAngle->Disable();
+ }
+ else
+ {
+ mpFtRotate->Enable(!mbMultiDisable);
+ mpCtrlDial->Enable(!mbMultiDisable);
+ mpMtrAngle->Enable(!mbMultiDisable);
+ }
+
+ mpCbStacked->Enable( meHorAlignState != SVX_HOR_JUSTIFY_REPEAT );
+ mpFTLeftIndent->Enable( meHorAlignState == SVX_HOR_JUSTIFY_LEFT );
+ mpMFLeftIndent->Enable( meHorAlignState == SVX_HOR_JUSTIFY_LEFT );
}
- else
- {
- meHorAlignState = SVX_HOR_JUSTIFY_STANDARD;
- }
- UpdateHorAlign();
- break;
- case SID_V_ALIGNCELL:
- if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SvxVerJustifyItem) )
- {
- const SvxVerJustifyItem* pItem = (const SvxVerJustifyItem*)pState;
- meVerAlignState = (SvxCellVerJustify)pItem->GetValue();
- }
- else
- {
- meVerAlignState = SVX_VER_JUSTIFY_STANDARD;
- }
- UpdateVerAlign();
break;
case SID_ATTR_ALIGN_INDENT:
if(eState >= SFX_ITEM_DEFAULT && pState && pState->ISA(SfxUInt16Item) )
@@ -374,11 +278,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
{
mpCBXMergeCell->Enable();
const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
- bool bVal = pItem->GetValue();
- if(bVal)
- mpCBXMergeCell->Check(true);
- else
- mpCBXMergeCell->Check(false);
+ mpCBXMergeCell->Check(pItem->GetValue());
}
else
{
@@ -401,11 +301,7 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
{
mpCBXWrapText->EnableTriState(false);
const SfxBoolItem* pItem = (const SfxBoolItem*)pState;
- bool bVal = pItem->GetValue();
- if(bVal)
- mpCBXWrapText->Check(true);
- else
- mpCBXWrapText->Check(false);
+ mpCBXWrapText->Check(pItem->GetValue());
}
else if(eState == SFX_ITEM_DONTCARE)
{
@@ -458,23 +354,11 @@ void AlignmentPropertyPanel::NotifyItemUpdate(
{
mpCbStacked->EnableTriState(false);
const SfxBoolItem* aStackItem = (const SfxBoolItem*)pState;
- bool IsChecked = (bool)aStackItem->GetValue();
- if(IsChecked)
- {
- mpCbStacked->Check(IsChecked);
- mpFtRotate->Disable();
- mpMtrAngle->Disable();
- mpCtrlDial->Disable();
- mbMultiDisable = true;
- }
- else
- {
- mpCbStacked->Check(IsChecked);
- mpFtRotate->Enable();
- mpMtrAngle->Enable();
- mpCtrlDial->Enable();
- mbMultiDisable = false;
- }
+ mbMultiDisable = aStackItem->GetValue();
+ mpCbStacked->Check(mbMultiDisable);
+ mpFtRotate->Enable(!mbMultiDisable);
+ mpMtrAngle->Enable(!mbMultiDisable);
+ mpCtrlDial->Enable(!mbMultiDisable);
}
else
{
@@ -501,76 +385,6 @@ void AlignmentPropertyPanel::FormatDegrees(double& dTmp)
dTmp = 359;
}
-void AlignmentPropertyPanel::UpdateHorAlign()
-{
- const sal_uInt16 nIdLeft = mpTBHorizontal->GetItemId(UNO_ALIGNLEFT);
- const sal_uInt16 nIdCenter = mpTBHorizontal->GetItemId(UNO_ALIGNHORIZONTALCENTER);
- const sal_uInt16 nIdRight = mpTBHorizontal->GetItemId(UNO_ALIGNRIGHT);
- const sal_uInt16 nIdBlock = mpTBHorizontal->GetItemId(UNO_ALIGNBLOCK);
-
- mpTBHorizontal->SetItemState(nIdLeft, TRISTATE_FALSE);
- mpTBHorizontal->SetItemState(nIdCenter, TRISTATE_FALSE);
- mpTBHorizontal->SetItemState(nIdRight, TRISTATE_FALSE);
- mpTBHorizontal->SetItemState(nIdBlock, TRISTATE_FALSE);
- mpFTLeftIndent->Disable();
- mpMFLeftIndent->Disable();
- if(meHorAlignState==SVX_HOR_JUSTIFY_REPEAT)
- {
- mpFtRotate->Disable();
- mpCtrlDial->Disable();
- mpMtrAngle->Disable();
- mpCbStacked->Disable();
- }
- else
- {
- if(!mbMultiDisable)
- {
- mpFtRotate->Enable();
- mpCtrlDial->Enable();
- mpMtrAngle->Enable();
- }
- else
- {
- mpFtRotate->Disable();
- mpCtrlDial->Disable();
- mpMtrAngle->Disable();
- }
- mpCbStacked->Enable();
- }
- switch(meHorAlignState)
- {
- case SVX_HOR_JUSTIFY_LEFT:
- mpTBHorizontal->SetItemState(nIdLeft, TRISTATE_TRUE);
- mpFTLeftIndent->Enable();
- mpMFLeftIndent->Enable();
- break;
- case SVX_HOR_JUSTIFY_CENTER:mpTBHorizontal->SetItemState(nIdCenter, TRISTATE_TRUE);break;
- case SVX_HOR_JUSTIFY_RIGHT: mpTBHorizontal->SetItemState(nIdRight, TRISTATE_TRUE);break;
- case SVX_HOR_JUSTIFY_BLOCK: mpTBHorizontal->SetItemState(nIdBlock, TRISTATE_TRUE);break;
- default:;
- }
-}
-
-void AlignmentPropertyPanel::UpdateVerAlign()
-{
- const sal_uInt16 nIdTop = mpTBVertical->GetItemId(UNO_ALIGNTOP);
- const sal_uInt16 nIdVCenter = mpTBVertical->GetItemId(UNO_ALIGNVCENTER);
- const sal_uInt16 nIdBottom = mpTBVertical->GetItemId(UNO_ALIGNBOTTOM);
-
- mpTBVertical->SetItemState(nIdTop, TRISTATE_FALSE);
- mpTBVertical->SetItemState(nIdVCenter, TRISTATE_FALSE);
- mpTBVertical->SetItemState(nIdBottom, TRISTATE_FALSE);
-
- switch(meVerAlignState)
- {
- case SVX_VER_JUSTIFY_TOP: mpTBVertical->SetItemState(nIdTop, TRISTATE_TRUE);break;
- case SVX_VER_JUSTIFY_CENTER:mpTBVertical->SetItemState(nIdVCenter, TRISTATE_TRUE);break;
- case SVX_VER_JUSTIFY_BOTTOM:mpTBVertical->SetItemState(nIdBottom, TRISTATE_TRUE);break;
- default:;
- }
-}
-
-
// namespace close
}} // end of namespace ::sc::sidebar
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx
index a00c639..d350540 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.hxx
@@ -23,7 +23,6 @@
#include <sfx2/sidebar/IContextChangeReceiver.hxx>
#include <svx/sidebar/PanelLayout.hxx>
#include <vcl/fixed.hxx>
-#include <boost/scoped_ptr.hpp>
#include <editeng/svxenum.hxx>
class ToolBox;
@@ -61,8 +60,6 @@ public:
private:
//ui controls
- ToolBox* mpTBHorizontal;
- ToolBox* mpTBVertical;
FixedText* mpFTLeftIndent;
MetricField* mpMFLeftIndent;
CheckBox* mpCBXWrapText;
@@ -73,16 +70,12 @@ private:
CheckBox* mpCbStacked;
::sfx2::sidebar::ControllerItem maAlignHorControl;
- ::sfx2::sidebar::ControllerItem maAlignVerControl;
::sfx2::sidebar::ControllerItem maLeftIndentControl;
::sfx2::sidebar::ControllerItem maMergeCellControl;
::sfx2::sidebar::ControllerItem maWrapTextControl;
::sfx2::sidebar::ControllerItem maAngleControl;
::sfx2::sidebar::ControllerItem maStackControl;
- SvxCellHorJustify meHorAlignState;
- SvxCellVerJustify meVerAlignState;
-
/// bitfield
bool mbMultiDisable : 1;
@@ -90,8 +83,6 @@ private:
::sfx2::sidebar::EnumContext maContext;
SfxBindings* mpBindings;
- DECL_LINK( TbxHorAlignSelectHdl, ToolBox* );
- DECL_LINK( TbxVerAlignSelectHdl, ToolBox* );
DECL_LINK( MFLeftIndentMdyHdl, void * );
DECL_LINK( CBOXMergnCellClkHdl, void * );
DECL_LINK( CBOXWrapTextClkHdl, void * );
@@ -107,8 +98,6 @@ private:
virtual ~AlignmentPropertyPanel();
void Initialize();
- void UpdateHorAlign();
- void UpdateVerAlign();
void FormatDegrees(double& dTmp);
};
diff --git a/sc/uiconfig/scalc/ui/sidebaralignment.ui b/sc/uiconfig/scalc/ui/sidebaralignment.ui
index a4716cd..5891972 100644
--- a/sc/uiconfig/scalc/ui/sidebaralignment.ui
+++ b/sc/uiconfig/scalc/ui/sidebaralignment.ui
@@ -20,7 +20,7 @@
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkToolbar" id="horizontalalignment">
+ <object class="sfxlo-SidebarToolBox" id="horizontalalignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
@@ -123,7 +123,7 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="verticalalignment">
+ <object class="sfxlo-SidebarToolBox" id="verticalalignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Vertical Alignment</property>
More information about the Libreoffice-commits
mailing list