diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-03-22 20:14:10 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-03-22 20:50:51 +0900 |
commit | 647b968191a6b452d1d8f704200e0d604c721991 (patch) | |
tree | ecee32bf9c82f12d9e8a1bd5bb9c0a124c28d59e | |
parent | 6ce97778dec8824058e8216e103a517592bca2c1 (diff) |
cleanup sidebar: LinePropertyPanel
Change-Id: Ic8de5d12ee83713b04e947fbabfe1a1184f868ca
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanel.cxx | 262 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanel.hxx | 93 |
2 files changed, 147 insertions, 208 deletions
diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx index 3913f24e818f..f7a91e709f8a 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.cxx +++ b/svx/source/sidebar/line/LinePropertyPanel.cxx @@ -53,104 +53,102 @@ using namespace css; using namespace css::uno; -using ::sfx2::sidebar::Theme; +using sfx2::sidebar::Theme; const char UNO_SELECTWIDTH[] = ".uno:SelectWidth"; -namespace { - void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLineEndList& rList) - { - const sal_uInt32 nCount(rList.Count()); - const OUString sNone(SVX_RESSTR(RID_SVXSTR_NONE)); +namespace +{ - rListBoxStart.SetUpdateMode(false); - rListBoxEnd.SetUpdateMode(false); +void FillLineEndListBox(ListBox& rListBoxStart, ListBox& rListBoxEnd, const XLineEndList& rList) +{ + const sal_uInt32 nCount(rList.Count()); + const OUString sNone(SVX_RESSTR(RID_SVXSTR_NONE)); - rListBoxStart.Clear(); - rListBoxEnd.Clear(); + rListBoxStart.SetUpdateMode(false); + rListBoxEnd.SetUpdateMode(false); - // add 'none' entries - rListBoxStart.InsertEntry(sNone); - rListBoxEnd.InsertEntry(sNone); + rListBoxStart.Clear(); + rListBoxEnd.Clear(); - for(sal_uInt32 i(0); i < nCount; i++) - { - XLineEndEntry* pEntry = rList.GetLineEnd(i); - const Bitmap aBitmap = const_cast< XLineEndList& >(rList).GetUiBitmap(i); + // add 'none' entries + rListBoxStart.InsertEntry(sNone); + rListBoxEnd.InsertEntry(sNone); - if(!aBitmap.IsEmpty()) - { - Bitmap aCopyStart(aBitmap); - Bitmap aCopyEnd(aBitmap); - // delete pBitmap; - const Size aBmpSize(aCopyStart.GetSizePixel()); - const Rectangle aCropRectStart(Point(), Size(aBmpSize.Width() / 2, aBmpSize.Height())); - const Rectangle aCropRectEnd(Point(aBmpSize.Width() / 2, 0), Size(aBmpSize.Width() / 2, aBmpSize.Height())); - - aCopyStart.Crop(aCropRectStart); - rListBoxStart.InsertEntry( - pEntry->GetName(), - Image(aCopyStart)); - - aCopyEnd.Crop(aCropRectEnd); - rListBoxEnd.InsertEntry( - pEntry->GetName(), - Image(aCopyEnd)); - } - else - { - rListBoxStart.InsertEntry(pEntry->GetName()); - rListBoxEnd.InsertEntry(pEntry->GetName()); - } - } + for(sal_uInt32 i(0); i < nCount; i++) + { + XLineEndEntry* pEntry = rList.GetLineEnd(i); + const Bitmap aBitmap = const_cast< XLineEndList& >(rList).GetUiBitmap(i); - rListBoxStart.SetUpdateMode(true); - rListBoxEnd.SetUpdateMode(true); + if(!aBitmap.IsEmpty()) + { + Bitmap aCopyStart(aBitmap); + Bitmap aCopyEnd(aBitmap); + + const Size aBmpSize(aCopyStart.GetSizePixel()); + const Rectangle aCropRectStart(Point(), Size(aBmpSize.Width() / 2, aBmpSize.Height())); + const Rectangle aCropRectEnd(Point(aBmpSize.Width() / 2, 0), Size(aBmpSize.Width() / 2, aBmpSize.Height())); + + aCopyStart.Crop(aCropRectStart); + rListBoxStart.InsertEntry( + pEntry->GetName(), + Image(aCopyStart)); + + aCopyEnd.Crop(aCropRectEnd); + rListBoxEnd.InsertEntry( + pEntry->GetName(), + Image(aCopyEnd)); + } + else + { + rListBoxStart.InsertEntry(pEntry->GetName()); + rListBoxEnd.InsertEntry(pEntry->GetName()); + } } - void FillLineStyleListBox(ListBox& rListBox, const XDashList& rList) - { - const sal_uInt32 nCount(rList.Count()); - rListBox.SetUpdateMode(false); + rListBoxStart.SetUpdateMode(true); + rListBoxEnd.SetUpdateMode(true); +} - rListBox.Clear(); +void FillLineStyleListBox(ListBox& rListBox, const XDashList& rList) +{ + const sal_uInt32 nCount(rList.Count()); + rListBox.SetUpdateMode(false); - // entry for 'none' - rListBox.InsertEntry(rList.GetStringForUiNoLine()); + rListBox.Clear(); - // entry for solid line - rListBox.InsertEntry(rList.GetStringForUiSolidLine(), - Image( rList.GetBitmapForUISolidLine())); + // entry for 'none' + rListBox.InsertEntry(rList.GetStringForUiNoLine()); - for(sal_uInt32 i(0); i < nCount; i++) - { - XDashEntry* pEntry = rList.GetDash(i); - const Bitmap aBitmap = const_cast< XDashList& >(rList).GetUiBitmap(i); + // entry for solid line + rListBox.InsertEntry(rList.GetStringForUiSolidLine(), + Image( rList.GetBitmapForUISolidLine())); - if(!aBitmap.IsEmpty()) - { - rListBox.InsertEntry( - pEntry->GetName(), - Image(aBitmap)); - // delete pBitmap; - } - else - { - rListBox.InsertEntry(pEntry->GetName()); - } - } + for(sal_uInt32 i(0); i < nCount; i++) + { + XDashEntry* pEntry = rList.GetDash(i); + const Bitmap aBitmap = const_cast< XDashList& >(rList).GetUiBitmap(i); - rListBox.SetUpdateMode(true); + if(!aBitmap.IsEmpty()) + { + rListBox.InsertEntry(pEntry->GetName(), Image(aBitmap)); + } + else + { + rListBox.InsertEntry(pEntry->GetName()); + } } -} // end of anonymous namespace -// namespace open + rListBox.SetUpdateMode(true); +} + +} // end of anonymous namespace namespace svx { namespace sidebar { LinePropertyPanel::LinePropertyPanel( vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame, + const uno::Reference<frame::XFrame>& rxFrame, SfxBindings* pBindings) : PanelLayout(pParent, "LinePropertyPanel", "svx/ui/sidebarline.ui", rxFrame), maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this), @@ -194,14 +192,10 @@ LinePropertyPanel::LinePropertyPanel( Initialize(); } - - LinePropertyPanel::~LinePropertyPanel() { } - - void LinePropertyPanel::Initialize() { mpIMGWidthIcon.reset(new Image[8]); @@ -235,16 +229,16 @@ void LinePropertyPanel::Initialize() SelectEndStyle(false); aLink = LINK( this, LinePropertyPanel, ChangeStartHdl ); mpLBStart->SetSelectHdl( aLink ); - mpLBStart->SetAccessibleName(OUString( "Beginning Style")); //wj acc + mpLBStart->SetAccessibleName(OUString("Beginning Style")); //wj acc mpLBStart->AdaptDropDownLineCountToMaximum(); aLink = LINK( this, LinePropertyPanel, ChangeEndHdl ); mpLBEnd->SetSelectHdl( aLink ); - mpLBEnd->SetAccessibleName(OUString( "Ending Style")); //wj acc + mpLBEnd->SetAccessibleName(OUString("Ending Style")); //wj acc mpLBEnd->AdaptDropDownLineCountToMaximum(); aLink = LINK(this, LinePropertyPanel, ChangeTransparentHdl); mpMFTransparent->SetModifyHdl(aLink); - mpMFTransparent->SetAccessibleName(OUString( "Transparency")); //wj acc + mpMFTransparent->SetAccessibleName(OUString("Transparency")); //wj acc mpTBWidth->SetAccessibleRelationLabeledBy(mpFTWidth); mpLBStyle->SetAccessibleRelationLabeledBy(mpFTStyle); @@ -254,15 +248,13 @@ void LinePropertyPanel::Initialize() aLink = LINK( this, LinePropertyPanel, ChangeEdgeStyleHdl ); mpLBEdgeStyle->SetSelectHdl( aLink ); - mpLBEdgeStyle->SetAccessibleName(OUString( "Corner Style")); + mpLBEdgeStyle->SetAccessibleName(OUString("Corner Style")); aLink = LINK( this, LinePropertyPanel, ChangeCapStyleHdl ); mpLBCapStyle->SetSelectHdl( aLink ); - mpLBCapStyle->SetAccessibleName(OUString( "Cap Style")); + mpLBCapStyle->SetAccessibleName(OUString("Cap Style")); } - - void LinePropertyPanel::SetupIcons(void) { if(Theme::GetBoolean(Theme::Bool_UseSymphonyIcons)) @@ -275,11 +267,9 @@ void LinePropertyPanel::SetupIcons(void) } } - - LinePropertyPanel* LinePropertyPanel::Create ( vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame, + const uno::Reference<frame::XFrame>& rxFrame, SfxBindings* pBindings) { if (pParent == NULL) @@ -289,33 +279,20 @@ LinePropertyPanel* LinePropertyPanel::Create ( if (pBindings == NULL) throw lang::IllegalArgumentException("no SfxBindings given to LinePropertyPanel::Create", NULL, 2); - return new LinePropertyPanel( - pParent, - rxFrame, - pBindings); + return new LinePropertyPanel(pParent, rxFrame, pBindings); } - - - -void LinePropertyPanel::DataChanged( - const DataChangedEvent& rEvent) +void LinePropertyPanel::DataChanged(const DataChangedEvent& /*rEvent*/) { - (void)rEvent; - SetupIcons(); } - - - void LinePropertyPanel::NotifyItemUpdate( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, - const bool bIsEnabled) + const bool /*bIsEnabled*/) { - (void)bIsEnabled; const bool bDisabled(SfxItemState::DISABLED == eState); switch(nSID) @@ -523,23 +500,23 @@ void LinePropertyPanel::NotifyItemUpdate( switch(pItem->GetValue()) { - case com::sun::star::drawing::LineJoint_MIDDLE: - case com::sun::star::drawing::LineJoint_ROUND: + case drawing::LineJoint_MIDDLE: + case drawing::LineJoint_ROUND: { nEntryPos = 1; break; } - case com::sun::star::drawing::LineJoint_NONE: + case drawing::LineJoint_NONE: { nEntryPos = 2; break; } - case com::sun::star::drawing::LineJoint_MITER: + case drawing::LineJoint_MITER: { nEntryPos = 3; break; } - case com::sun::star::drawing::LineJoint_BEVEL: + case drawing::LineJoint_BEVEL: { nEntryPos = 4; break; @@ -583,17 +560,17 @@ void LinePropertyPanel::NotifyItemUpdate( switch(pItem->GetValue()) { - case com::sun::star::drawing::LineCap_BUTT: + case drawing::LineCap_BUTT: { nEntryPos = 1; break; } - case com::sun::star::drawing::LineCap_ROUND: + case drawing::LineCap_ROUND: { nEntryPos = 2; break; } - case com::sun::star::drawing::LineCap_SQUARE: + case drawing::LineCap_SQUARE: { nEntryPos = 3; break; @@ -617,12 +594,6 @@ void LinePropertyPanel::NotifyItemUpdate( } } - - - - - - IMPL_LINK_NOARG(LinePropertyPanel, ChangeLineStyleHdl) { const sal_Int32 nPos(mpLBStyle->GetSelectEntryPos()); @@ -661,8 +632,6 @@ IMPL_LINK_NOARG(LinePropertyPanel, ChangeLineStyleHdl) return 0; } - - IMPL_LINK(LinePropertyPanel, ChangeStartHdl, void*, EMPTYARG) { sal_Int32 nPos = mpLBStart->GetSelectEntryPos(); @@ -678,9 +647,6 @@ IMPL_LINK(LinePropertyPanel, ChangeStartHdl, void*, EMPTYARG) return 0; } - - - IMPL_LINK(LinePropertyPanel, ChangeEndHdl, void*, EMPTYARG) { sal_Int32 nPos = mpLBEnd->GetSelectEntryPos(); @@ -696,9 +662,6 @@ IMPL_LINK(LinePropertyPanel, ChangeEndHdl, void*, EMPTYARG) return 0; } - - - IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, EMPTYARG) { const sal_Int32 nPos(mpLBEdgeStyle->GetSelectEntryPos()); @@ -711,22 +674,22 @@ IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, EMPTYARG) { case 0: // rounded { - pItem.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_ROUND)); + pItem.reset(new XLineJointItem(drawing::LineJoint_ROUND)); break; } case 1: // none { - pItem.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_NONE)); + pItem.reset(new XLineJointItem(drawing::LineJoint_NONE)); break; } case 2: // mitered { - pItem.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_MITER)); + pItem.reset(new XLineJointItem(drawing::LineJoint_MITER)); break; } case 3: // beveled { - pItem.reset(new XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL)); + pItem.reset(new XLineJointItem(drawing::LineJoint_BEVEL)); break; } } @@ -736,9 +699,6 @@ IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, EMPTYARG) return 0; } - - - IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, EMPTYARG) { const sal_Int32 nPos(mpLBCapStyle->GetSelectEntryPos()); @@ -751,17 +711,17 @@ IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, EMPTYARG) { case 0: // flat { - pItem.reset(new XLineCapItem(com::sun::star::drawing::LineCap_BUTT)); + pItem.reset(new XLineCapItem(drawing::LineCap_BUTT)); break; } case 1: // round { - pItem.reset(new XLineCapItem(com::sun::star::drawing::LineCap_ROUND)); + pItem.reset(new XLineCapItem(drawing::LineCap_ROUND)); break; } case 2: // square { - pItem.reset(new XLineCapItem(com::sun::star::drawing::LineCap_SQUARE)); + pItem.reset(new XLineCapItem(drawing::LineCap_SQUARE)); break; } } @@ -771,9 +731,6 @@ IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, EMPTYARG) return 0; } - - - IMPL_LINK(LinePropertyPanel, ToolboxWidthSelectHdl,ToolBox*, pToolBox) { if (pToolBox->GetItemCommand(pToolBox->GetCurItemId()) == UNO_SELECTWIDTH) @@ -784,9 +741,6 @@ IMPL_LINK(LinePropertyPanel, ToolboxWidthSelectHdl,ToolBox*, pToolBox) return 0; } - - - IMPL_LINK( LinePropertyPanel, ChangeTransparentHdl, void *, EMPTYARG ) { sal_uInt16 nVal = (sal_uInt16)mpMFTransparent->GetValue(); @@ -796,36 +750,25 @@ IMPL_LINK( LinePropertyPanel, ChangeTransparentHdl, void *, EMPTYARG ) return 0L; } - - - PopupControl* LinePropertyPanel::CreateLineWidthPopupControl (PopupContainer* pParent) { return new LineWidthControl(pParent, *this); } - - - void LinePropertyPanel::EndLineWidthPopupMode (void) { maLineWidthPopup.Hide(); } - - - void LinePropertyPanel::SetWidthIcon(int n) { const sal_uInt16 nIdWidth = mpTBWidth->GetItemId(UNO_SELECTWIDTH); - if(n==0) + if (n == 0) mpTBWidth->SetItemImage( nIdWidth, maIMGNone); else mpTBWidth->SetItemImage( nIdWidth, mpIMGWidthIcon[n-1]); } - - void LinePropertyPanel::SetWidthIcon() { if(!mbWidthValuable) @@ -857,16 +800,12 @@ void LinePropertyPanel::SetWidthIcon() } - - void LinePropertyPanel::SetWidth(long nWidth) { mnWidthCoreValue = nWidth; mbWidthValuable = true; } - - void LinePropertyPanel::FillLineEndList() { SfxObjectShell* pSh = SfxObjectShell::Current(); @@ -891,8 +830,6 @@ void LinePropertyPanel::FillLineEndList() } } - - void LinePropertyPanel::FillLineStyleList() { SfxObjectShell* pSh = SfxObjectShell::Current(); @@ -915,8 +852,6 @@ void LinePropertyPanel::FillLineStyleList() } } - - void LinePropertyPanel::SelectLineStyle() { if( !mpStyleItem.get() || !mpDashItem.get() ) @@ -1023,7 +958,6 @@ void LinePropertyPanel::SelectEndStyle(bool bStart) } } - -} } // end of namespace svx::sidebar +}} // end of namespace svx::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/line/LinePropertyPanel.hxx b/svx/source/sidebar/line/LinePropertyPanel.hxx index 476c4799f855..e9836837221b 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.hxx +++ b/svx/source/sidebar/line/LinePropertyPanel.hxx @@ -42,19 +42,23 @@ class ListBox; class ToolBox; class FloatingWindow; -namespace { - #define SIDEBAR_LINE_WIDTH_GLOBAL_VALUE "PopupPanel_LineWidth" +namespace +{ + +#define SIDEBAR_LINE_WIDTH_GLOBAL_VALUE "PopupPanel_LineWidth" + } //end of anonymous namespace -namespace svx { namespace sidebar { +namespace svx +{ +namespace sidebar +{ class PopupContainer; class LineWidthControl; - -class LinePropertyPanel -: public PanelLayout, - public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface +class LinePropertyPanel : public PanelLayout, + public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface { public: static LinePropertyPanel* Create( @@ -81,53 +85,54 @@ public: private: //ui controls - FixedText* mpFTWidth; - ToolBox* mpTBWidth; - FixedText* mpFTStyle; - ListBox* mpLBStyle; - FixedText* mpFTTrancparency; - MetricField* mpMFTransparent; - FixedText* mpFTArrow; - ListBox* mpLBStart; - ListBox* mpLBEnd; - FixedText* mpFTEdgeStyle; - ListBox* mpLBEdgeStyle; - FixedText* mpFTCapStyle; - ListBox* mpLBCapStyle; + FixedText* mpFTWidth; + ToolBox* mpTBWidth; + FixedText* mpFTStyle; + ListBox* mpLBStyle; + FixedText* mpFTTrancparency; + MetricField* mpMFTransparent; + FixedText* mpFTArrow; + ListBox* mpLBStart; + ListBox* mpLBEnd; + FixedText* mpFTEdgeStyle; + ListBox* mpLBEdgeStyle; + FixedText* mpFTCapStyle; + ListBox* mpLBCapStyle; //ControllerItem - ::sfx2::sidebar::ControllerItem maStyleControl; - ::sfx2::sidebar::ControllerItem maDashControl; - ::sfx2::sidebar::ControllerItem maWidthControl; - ::sfx2::sidebar::ControllerItem maStartControl; - ::sfx2::sidebar::ControllerItem maEndControl; - ::sfx2::sidebar::ControllerItem maLineEndListControl; - ::sfx2::sidebar::ControllerItem maLineStyleListControl; - ::sfx2::sidebar::ControllerItem maTransControl; - ::sfx2::sidebar::ControllerItem maEdgeStyle; - ::sfx2::sidebar::ControllerItem maCapStyle; - - ::boost::scoped_ptr< XLineStyleItem > mpStyleItem; - ::boost::scoped_ptr< XLineDashItem > mpDashItem; - sal_uInt16 mnTrans; - SfxMapUnit meMapUnit; - sal_Int32 mnWidthCoreValue; - XLineEndListRef mxLineEndList; - XDashListRef mxLineStyleList; - ::boost::scoped_ptr< XLineStartItem > mpStartItem; - ::boost::scoped_ptr< XLineEndItem > mpEndItem; + sfx2::sidebar::ControllerItem maStyleControl; + sfx2::sidebar::ControllerItem maDashControl; + sfx2::sidebar::ControllerItem maWidthControl; + sfx2::sidebar::ControllerItem maStartControl; + sfx2::sidebar::ControllerItem maEndControl; + sfx2::sidebar::ControllerItem maLineEndListControl; + sfx2::sidebar::ControllerItem maLineStyleListControl; + sfx2::sidebar::ControllerItem maTransControl; + sfx2::sidebar::ControllerItem maEdgeStyle; + sfx2::sidebar::ControllerItem maCapStyle; + + boost::scoped_ptr<XLineStyleItem> mpStyleItem; + boost::scoped_ptr<XLineDashItem> mpDashItem; + + sal_uInt16 mnTrans; + SfxMapUnit meMapUnit; + sal_Int32 mnWidthCoreValue; + XLineEndListRef mxLineEndList; + XDashListRef mxLineStyleList; + boost::scoped_ptr<XLineStartItem> mpStartItem; + boost::scoped_ptr<XLineEndItem> mpEndItem; //popup windows LineWidthPopup maLineWidthPopup; // images from resource - Image maIMGNone; + Image maIMGNone; // multi-images - ::boost::scoped_array<Image> mpIMGWidthIcon; + boost::scoped_array<Image> mpIMGWidthIcon; - css::uno::Reference< css::frame::XFrame > mxFrame; - SfxBindings* mpBindings; + css::uno::Reference<css::frame::XFrame> mxFrame; + SfxBindings* mpBindings; /// bitfield bool mbWidthValuable : 1; |