diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-01-21 15:43:46 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-01-22 17:55:28 +0100 |
commit | eae55d7397f953ca8a4be1a2665e8ca887adfe81 (patch) | |
tree | 47d84a1b81c3a4d7b4719b328cb1241ae80f1a2f /svx | |
parent | 2399373778cf0778ad15b1fec9a1bf289b4089de (diff) |
rework line style to be a wide toolbar button
involves converting SvxLineStyleToolBoxControl to a PopupWindowController
because chart is doing interesting things in its panel there needs to be
a non-standard way to report/detect the selected line style, which is
then reused to disable/enable the arrows when none is selected/deselected
in non-chart sidebars
SvxLineBox becomes a toolbar dropdown instead of a combobox itemwindow
linectrl.cxx split into linewidthctrl.cxx and linewidthctrl because
SvxLineBox is now needed in svxcore
Change-Id: Icf0ef5e612b894a43d389af8a2908138c2e9c580
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87164
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/Library_svx.mk | 2 | ||||
-rw-r--r-- | svx/Library_svxcore.mk | 1 | ||||
-rw-r--r-- | svx/UIConfig_svx.mk | 1 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanel.cxx | 42 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanel.hxx | 5 | ||||
-rw-r--r-- | svx/source/sidebar/line/LinePropertyPanelBase.cxx | 226 | ||||
-rw-r--r-- | svx/source/tbxctrls/itemwin.cxx | 231 | ||||
-rw-r--r-- | svx/source/tbxctrls/linectrl.cxx | 390 | ||||
-rw-r--r-- | svx/source/tbxctrls/linewidthctrl.cxx | 116 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbxcolorupdate.cxx | 66 | ||||
-rw-r--r-- | svx/uiconfig/ui/floatinglinestyle.ui | 49 | ||||
-rw-r--r-- | svx/uiconfig/ui/sidebarline.ui | 82 | ||||
-rw-r--r-- | svx/util/svx.component | 4 | ||||
-rw-r--r-- | svx/util/svxcore.component | 8 |
14 files changed, 579 insertions, 644 deletions
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index a2f22cd7c700..2b9b96f04a3b 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -232,7 +232,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/tbxctrls/itemwin \ svx/source/tbxctrls/layctrl \ svx/source/tbxctrls/lboxctrl \ - svx/source/tbxctrls/linectrl \ + svx/source/tbxctrls/linewidthctrl \ svx/source/tbxctrls/tbunocontroller \ svx/source/tbxctrls/tbunosearchcontrollers \ svx/source/tbxctrls/tbxcolor \ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index e07289cc80f7..cd3abc58e624 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -370,6 +370,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\ svx/source/table/viewcontactoftableobj \ svx/source/tbxctrls/extrusioncontrols \ svx/source/tbxctrls/fontworkgallery \ + svx/source/tbxctrls/linectrl \ svx/source/tbxctrls/Palette \ svx/source/tbxctrls/PaletteManager \ svx/source/tbxctrls/tbcontrl \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index dd0ac621adcc..3d52a8369b3f 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -51,6 +51,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/floatingframeborder \ svx/uiconfig/ui/floatinglineend \ svx/uiconfig/ui/floatinglineproperty \ + svx/uiconfig/ui/floatinglinestyle \ svx/uiconfig/ui/floatingundoredo \ svx/uiconfig/ui/fontworkgallerydialog \ svx/uiconfig/ui/fontworkspacingdialog \ diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx b/svx/source/sidebar/line/LinePropertyPanel.cxx index cf6dc5505f72..bd0fde7a8674 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.cxx +++ b/svx/source/sidebar/line/LinePropertyPanel.cxx @@ -54,7 +54,6 @@ LinePropertyPanel::LinePropertyPanel( maStyleControl(SID_ATTR_LINE_STYLE, *pBindings, *this), maDashControl (SID_ATTR_LINE_DASH, *pBindings, *this), maWidthControl(SID_ATTR_LINE_WIDTH, *pBindings, *this), - maLineStyleListControl(SID_DASH_LIST, *pBindings, *this), maTransControl(SID_ATTR_LINE_TRANSPARENCE, *pBindings, *this), maEdgeStyle(SID_ATTR_LINE_JOINT, *pBindings, *this), maCapStyle(SID_ATTR_LINE_CAP, *pBindings, *this), @@ -74,7 +73,6 @@ void LinePropertyPanel::dispose() maStyleControl.dispose(); maDashControl.dispose(); maWidthControl.dispose(); - maLineStyleListControl.dispose(); maTransControl.dispose(); maEdgeStyle.dispose(); maCapStyle.dispose(); @@ -107,16 +105,6 @@ void LinePropertyPanel::NotifyItemUpdate( switch(nSID) { - case SID_ATTR_LINE_DASH: - { - updateLineDash(bDisabled, bSetOrDefault, pState); - break; - } - case SID_ATTR_LINE_STYLE: - { - updateLineStyle(bDisabled, bSetOrDefault, pState); - break; - } case SID_ATTR_LINE_TRANSPARENCE: { updateLineTransparence(bDisabled, bSetOrDefault, pState); @@ -127,12 +115,6 @@ void LinePropertyPanel::NotifyItemUpdate( updateLineWidth(bDisabled, bSetOrDefault, pState); break; } - case SID_DASH_LIST: - { - FillLineStyleList(); - SelectLineStyle(); - break; - } case SID_ATTR_LINE_JOINT: { updateLineJoint(bDisabled, bSetOrDefault, pState); @@ -176,30 +158,6 @@ void LinePropertyPanel::HandleContextChange( enableArrowHead(); } -void LinePropertyPanel::setLineStyle(const XLineStyleItem& rItem) -{ - GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_STYLE, - SfxCallMode::RECORD, { &rItem }); -} - -void LinePropertyPanel::setLineDash(const XLineDashItem& rItem) -{ - GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_DASH, - SfxCallMode::RECORD, { &rItem }); -} - -void LinePropertyPanel::setLineEndStyle(const XLineEndItem* pItem) -{ - GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINEEND_STYLE, - SfxCallMode::RECORD, { pItem }); -} - -void LinePropertyPanel::setLineStartStyle(const XLineStartItem* pItem) -{ - GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINEEND_STYLE, - SfxCallMode::RECORD, { pItem }); -} - void LinePropertyPanel::setLineJoint(const XLineJointItem* pItem) { GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_LINE_JOINT, diff --git a/svx/source/sidebar/line/LinePropertyPanel.hxx b/svx/source/sidebar/line/LinePropertyPanel.hxx index 00585290f579..c2ae25639db7 100644 --- a/svx/source/sidebar/line/LinePropertyPanel.hxx +++ b/svx/source/sidebar/line/LinePropertyPanel.hxx @@ -72,10 +72,6 @@ public: protected: - virtual void setLineStyle(const XLineStyleItem& rItem) override; - virtual void setLineDash(const XLineDashItem& rItem) override; - virtual void setLineEndStyle(const XLineEndItem* pItem) override; - virtual void setLineStartStyle(const XLineStartItem* pItem) override; virtual void setLineTransparency(const XLineTransparenceItem& rItem) override; virtual void setLineJoint(const XLineJointItem* pItem) override; virtual void setLineCap(const XLineCapItem* pItem) override; @@ -85,7 +81,6 @@ private: sfx2::sidebar::ControllerItem maStyleControl; sfx2::sidebar::ControllerItem maDashControl; sfx2::sidebar::ControllerItem maWidthControl; - sfx2::sidebar::ControllerItem maLineStyleListControl; sfx2::sidebar::ControllerItem maTransControl; sfx2::sidebar::ControllerItem maEdgeStyle; sfx2::sidebar::ControllerItem maCapStyle; diff --git a/svx/source/sidebar/line/LinePropertyPanelBase.cxx b/svx/source/sidebar/line/LinePropertyPanelBase.cxx index cee744ebd3b1..e0bba5977fe6 100644 --- a/svx/source/sidebar/line/LinePropertyPanelBase.cxx +++ b/svx/source/sidebar/line/LinePropertyPanelBase.cxx @@ -32,6 +32,7 @@ #include <svx/xtable.hxx> #include <svx/xdash.hxx> #include <svx/drawitem.hxx> +#include <svx/linectrl.hxx> #include <svx/svxitems.hrc> #include <svtools/valueset.hxx> #include <unotools/pathoptions.hxx> @@ -55,19 +56,53 @@ const char SELECTWIDTH[] = "SelectWidth"; namespace svx::sidebar { +// trigger disabling the arrows if the none line style is selected +class DisableArrowsWrapper +{ +private: + LinePropertyPanelBase& m_rPanel; + +public: + DisableArrowsWrapper(LinePropertyPanelBase& rPanel) + : m_rPanel(rPanel) + { + } + + bool operator()(const OUString& rCommand, const css::uno::Any& rValue) + { + if (rCommand == ".uno:XLineStyle") + { + css::drawing::LineStyle eLineStyle(css::drawing::LineStyle_NONE); + rValue >>= eLineStyle; + m_rPanel.SetNoneLineStyle(eLineStyle == css::drawing::LineStyle_NONE); + } + return false; + } +}; + +namespace +{ + SvxLineStyleToolBoxControl* getLineStyleToolBoxControl(ToolbarUnoDispatcher& rToolBoxColor) + { + css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxColor.GetControllerForCommand(".uno:XLineStyle"); + SvxLineStyleToolBoxControl* pToolBoxLineStyleControl = dynamic_cast<SvxLineStyleToolBoxControl*>(xController.get()); + return pToolBoxLineStyleControl; + } +} + + LinePropertyPanelBase::LinePropertyPanelBase( vcl::Window* pParent, const uno::Reference<css::frame::XFrame>& rxFrame) : PanelLayout(pParent, "LinePropertyPanel", "svx/ui/sidebarline.ui", rxFrame, true), mxTBColor(m_xBuilder->weld_toolbar("color")), mxColorDispatch(new ToolbarUnoDispatcher(*mxTBColor, rxFrame)), + mxLineStyleTB(m_xBuilder->weld_toolbar("linestyle")), + mxLineStyleDispatch(new ToolbarUnoDispatcher(*mxLineStyleTB, rxFrame)), mxFTWidth(m_xBuilder->weld_label("widthlabel")), mxTBWidth(m_xBuilder->weld_toolbar("width")), - mxLBStyle(new SvxLineLB(m_xBuilder->weld_combo_box("linestyle"))), mxFTTransparency(m_xBuilder->weld_label("translabel")), mxMFTransparent(m_xBuilder->weld_metric_spin_button("linetransparency", FieldUnit::PERCENT)), - mxArrowsTB(m_xBuilder->weld_toolbar("arrowheads")), - mxArrowsDispatch(new ToolbarUnoDispatcher(*mxArrowsTB, rxFrame)), mxFTEdgeStyle(m_xBuilder->weld_label("cornerlabel")), mxLBEdgeStyle(m_xBuilder->weld_combo_box("edgestyle")), mxFTCapStyle(m_xBuilder->weld_label("caplabel")), @@ -75,14 +110,14 @@ LinePropertyPanelBase::LinePropertyPanelBase( mxGridLineProps(m_xBuilder->weld_widget("lineproperties")), mxBoxArrowProps(m_xBuilder->weld_widget("arrowproperties")), mxLineWidthPopup(new LineWidthPopup(mxTBWidth.get(), *this)), - mpStyleItem(), - mpDashItem(), + mxDisableArrowsWrapper(new DisableArrowsWrapper(*this)), mnTrans(0), meMapUnit(MapUnit::MapMM), mnWidthCoreValue(0), maIMGNone(BMP_NONE_ICON), mbWidthValuable(true), - mbArrowSupported(true) + mbArrowSupported(true), + mbNoneLineStyle(false) { Initialize(); } @@ -99,11 +134,10 @@ void LinePropertyPanelBase::dispose() mxTBWidth.reset(); mxColorDispatch.reset(); mxTBColor.reset(); - mxLBStyle.reset(); mxFTTransparency.reset(); mxMFTransparent.reset(); - mxArrowsDispatch.reset(); - mxArrowsTB.reset(); + mxLineStyleDispatch.reset(); + mxLineStyleTB.reset(); mxFTEdgeStyle.reset(); mxLBEdgeStyle.reset(); mxFTCapStyle.reset(); @@ -127,10 +161,6 @@ void LinePropertyPanelBase::Initialize() maIMGWidthIcon[6] = BMP_WIDTH7_ICON; maIMGWidthIcon[7] = BMP_WIDTH8_ICON; - FillLineStyleList(); - SelectLineStyle(); - mxLBStyle->connect_changed( LINK( this, LinePropertyPanelBase, ChangeLineStyleHdl ) ); - mxTBWidth->set_item_icon_name(SELECTWIDTH, maIMGWidthIcon[0]); mxTBWidth->connect_clicked(LINK(this, LinePropertyPanelBase, ToolboxWidthSelectHdl)); @@ -139,62 +169,9 @@ void LinePropertyPanelBase::Initialize() mxLBEdgeStyle->connect_changed( LINK( this, LinePropertyPanelBase, ChangeEdgeStyleHdl ) ); mxLBCapStyle->connect_changed( LINK( this, LinePropertyPanelBase, ChangeCapStyleHdl ) ); -} - -void LinePropertyPanelBase::DataChanged(const DataChangedEvent& /*rEvent*/) -{ -} - -void LinePropertyPanelBase::updateLineStyle(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem) -{ - if(bDisabled) - { - mxLBStyle->set_sensitive(false); - } - else - { - mxLBStyle->set_sensitive(true); - } - if(bSetOrDefault) - { - if(pItem) - { - mpStyleItem.reset(static_cast<XLineStyleItem*>(pItem->Clone())); - } - } - else - { - mpStyleItem.reset(); - } - - SelectLineStyle(); -} - -void LinePropertyPanelBase::updateLineDash(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem) -{ - if(bDisabled) - { - mxLBStyle->set_sensitive(false); - } - else - { - mxLBStyle->set_sensitive(true); - } - - if(bSetOrDefault) - { - if(pItem) - { - mpDashItem.reset(static_cast<XLineDashItem*>(pItem->Clone())); - } - } - else - { - mpDashItem.reset(); - } - - SelectLineStyle(); + SvxLineStyleToolBoxControl* pLineStyleControl = getLineStyleToolBoxControl(*mxLineStyleDispatch); + pLineStyleControl->setLineStyleSelectFunction(*mxDisableArrowsWrapper); } void LinePropertyPanelBase::updateLineTransparence(bool bDisabled, bool bSetOrDefault, @@ -366,44 +343,6 @@ void LinePropertyPanelBase::updateLineCap(bool bDisabled, bool bSetOrDefault, mxLBCapStyle->set_active(-1); } -IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeLineStyleHdl, weld::ComboBox&, void) -{ - const sal_Int32 nPos(mxLBStyle->get_active()); - - if (nPos != -1 && mxLBStyle->get_value_changed_from_saved()) - { - if(0 == nPos) - { - // drawing::LineStyle_NONE - const XLineStyleItem aItem(drawing::LineStyle_NONE); - - setLineStyle(aItem); - } - else if(1 == nPos) - { - // drawing::LineStyle_SOLID - const XLineStyleItem aItem(drawing::LineStyle_SOLID); - - setLineStyle(aItem); - } - else if (mxLineStyleList.is() && mxLineStyleList->Count() > static_cast<long>(nPos - 2)) - { - // drawing::LineStyle_DASH - const XLineStyleItem aItemA(drawing::LineStyle_DASH); - const XDashEntry* pDashEntry = mxLineStyleList->GetDash(nPos - 2); - OSL_ENSURE(pDashEntry, "OOps, got empty XDash from XDashList (!)"); - const XLineDashItem aItemB( - pDashEntry ? pDashEntry->GetName() : OUString(), - pDashEntry ? pDashEntry->GetDash() : XDash()); - - setLineStyle(aItemA); - setLineDash(aItemB); - } - } - - ActivateControls(); -} - IMPL_LINK_NOARG(LinePropertyPanelBase, ChangeEdgeStyleHdl, weld::ComboBox&, void) { const sal_Int32 nPos(mxLBEdgeStyle->get_active()); @@ -533,79 +472,12 @@ void LinePropertyPanelBase::SetWidth(long nWidth) mxLineWidthPopup->SetWidthSelect(mnWidthCoreValue, mbWidthValuable, meMapUnit); } -void LinePropertyPanelBase::FillLineStyleList() -{ - SfxObjectShell* pSh = SfxObjectShell::Current(); - if ( pSh && pSh->GetItem( SID_DASH_LIST ) ) - { - mxLBStyle->set_sensitive(true); - mxLineStyleList = pSh->GetItem( SID_DASH_LIST )->GetDashList(); - - if (mxLineStyleList.is()) - { - mxLBStyle->Fill(mxLineStyleList); - } - - mxLBStyle->set_active(0); - } - else - { - mxLBStyle->set_sensitive(false); - } -} - -void LinePropertyPanelBase::SelectLineStyle() -{ - if (!mpStyleItem || !mpDashItem) - { - mxLBStyle->set_active(-1); - mxLBStyle->set_sensitive(false); - return; - } - - const drawing::LineStyle eXLS(mpStyleItem->GetValue()); - bool bSelected(false); - - switch(eXLS) - { - case drawing::LineStyle_NONE: - break; - case drawing::LineStyle_SOLID: - mxLBStyle->set_active(1); - bSelected = true; - break; - default: - if(mxLineStyleList.is()) - { - const XDash& rDash = mpDashItem->GetDashValue(); - for(long a(0);!bSelected && a < mxLineStyleList->Count(); a++) - { - const XDashEntry* pEntry = mxLineStyleList->GetDash(a); - const XDash& rEntry = pEntry->GetDash(); - if(rDash == rEntry) - { - mxLBStyle->set_active(a + 2); - bSelected = true; - } - } - } - break; - } - - if(!bSelected) - mxLBStyle->set_active( 0 ); - - ActivateControls(); -} - void LinePropertyPanelBase::ActivateControls() { - const sal_Int32 nPos(mxLBStyle->get_active()); - bool bLineStyle( nPos != 0 ); - - mxGridLineProps->set_sensitive( bLineStyle ); - mxBoxArrowProps->set_sensitive( bLineStyle ); - mxArrowsTB->set_sensitive( bLineStyle && mbArrowSupported ); + mxGridLineProps->set_sensitive(mbNoneLineStyle); + mxBoxArrowProps->set_sensitive(mbNoneLineStyle); + mxLineStyleTB->set_item_visible(".uno:LineEndStyle", mbArrowSupported); + mxLineStyleTB->set_item_sensitive(".uno:LineEndStyle", !mbNoneLineStyle); } void LinePropertyPanelBase::setMapUnit(MapUnit eMapUnit) diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx index 5443d4f12751..7e6b661f9ec4 100644 --- a/svx/source/tbxctrls/itemwin.cxx +++ b/svx/source/tbxctrls/itemwin.cxx @@ -34,8 +34,6 @@ #include <svx/svxids.hrc> -#define DELAY_TIMEOUT 100 - #include <svx/xlnclit.hxx> #include <svx/xlnwtit.hxx> #include <svx/xlineit0.hxx> @@ -47,6 +45,7 @@ #include <svx/linectrl.hxx> #include <svtools/colorcfg.hxx> #include <svtools/unitconv.hxx> +#include <svtools/valueset.hxx> #include <boost/property_tree/json_parser.hpp> @@ -56,231 +55,6 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; -SvxLineBox::SvxLineBox( vcl::Window* pParent, const Reference< XFrame >& rFrame ) : - ListBox(pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL), - nCurPos ( 0 ), - aLogicalSize(40,140), - bRelease ( true ), - mpSh ( nullptr ), - mxFrame ( rFrame ) -{ - SetSizePixel(LogicToPixel(aLogicalSize, MapMode(MapUnit::MapAppFont))); - Show(); - - aDelayTimer.SetTimeout( DELAY_TIMEOUT ); - aDelayTimer.SetInvokeHandler( LINK( this, SvxLineBox, DelayHdl_Impl ) ); - aDelayTimer.Start(); -} - - -// Fills the listbox (provisional) with strings - -void SvxLineBox::Fill( const XDashListRef &pList ) -{ - Clear(); - - if( !pList.is() ) - return; - - // entry for 'none' - InsertEntry(pList->GetStringForUiNoLine()); - - // entry for solid line - InsertEntry(pList->GetStringForUiSolidLine(), - Image(pList->GetBitmapForUISolidLine())); - - // entries for dashed lines - - long nCount = pList->Count(); - SetUpdateMode( false ); - - for( long i = 0; i < nCount; i++ ) - { - const XDashEntry* pEntry = pList->GetDash(i); - const BitmapEx aBitmap = pList->GetUiBitmap( i ); - if( !aBitmap.IsEmpty() ) - { - InsertEntry(pEntry->GetName(), Image(aBitmap)); - } - else - InsertEntry( pEntry->GetName() ); - } - - AdaptDropDownLineCountToMaximum(); - SetUpdateMode( true ); -} - -IMPL_LINK_NOARG(SvxLineBox, DelayHdl_Impl, Timer *, void) -{ - if ( GetEntryCount() == 0 ) - { - mpSh = SfxObjectShell::Current(); - FillControl(); - } -} - - -void SvxLineBox::Select() -{ - // Call the parent's Select() member to trigger accessibility events. - ListBox::Select(); - - if ( IsTravelSelect() ) - return; - - drawing::LineStyle eXLS; - sal_Int32 nPos = GetSelectedEntryPos(); - - switch ( nPos ) - { - case 0: - eXLS = drawing::LineStyle_NONE; - break; - - case 1: - eXLS = drawing::LineStyle_SOLID; - break; - - default: - { - eXLS = drawing::LineStyle_DASH; - - if ( nPos != LISTBOX_ENTRY_NOTFOUND && - SfxObjectShell::Current() && - SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) - { - // LineDashItem will only be sent if it also has a dash. - // Notify cares! - SvxDashListItem const * pItem = SfxObjectShell::Current()->GetItem( SID_DASH_LIST ); - XLineDashItem aLineDashItem( GetSelectedEntry(), - pItem->GetDashList()->GetDash( nPos - 2 )->GetDash() ); - - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "LineDash"; - aLineDashItem.QueryValue ( a ); - aArgs[0].Value = a; - SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), - ".uno:LineDash", - aArgs ); - } - } - break; - } - - XLineStyleItem aLineStyleItem( eXLS ); - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "XLineStyle"; - aLineStyleItem.QueryValue ( a ); - aArgs[0].Value = a; - SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ), - ".uno:XLineStyle", - aArgs ); - - nCurPos = GetSelectedEntryPos(); - ReleaseFocus_Impl(); -} - - -bool SvxLineBox::PreNotify( NotifyEvent& rNEvt ) -{ - MouseNotifyEvent nType = rNEvt.GetType(); - - switch(nType) - { - case MouseNotifyEvent::MOUSEBUTTONDOWN: - case MouseNotifyEvent::GETFOCUS: - nCurPos = GetSelectedEntryPos(); - break; - case MouseNotifyEvent::LOSEFOCUS: - SelectEntryPos(nCurPos); - break; - case MouseNotifyEvent::KEYINPUT: - { - const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); - if( pKEvt->GetKeyCode().GetCode() == KEY_TAB) - { - bRelease = false; - Select(); - } - } - break; - default: - break; - } - return ListBox::PreNotify( rNEvt ); -} - - -bool SvxLineBox::EventNotify( NotifyEvent& rNEvt ) -{ - bool bHandled = ListBox::EventNotify( rNEvt ); - - if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); - - switch ( pKEvt->GetKeyCode().GetCode() ) - { - case KEY_RETURN: - Select(); - bHandled = true; - break; - - case KEY_ESCAPE: - SelectEntryPos( nCurPos ); - ReleaseFocus_Impl(); - bHandled = true; - break; - } - } - return bHandled; -} - - -void SvxLineBox::ReleaseFocus_Impl() -{ - if(!bRelease) - { - bRelease = true; - return; - } - - if( SfxViewShell::Current() ) - { - vcl::Window* pShellWnd = SfxViewShell::Current()->GetWindow(); - - if ( pShellWnd ) - pShellWnd->GrabFocus(); - } -} - -void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt ) -{ - if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) && - (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) ) - { - SetSizePixel(LogicToPixel(aLogicalSize, MapMode(MapUnit::MapAppFont))); - } - - ListBox::DataChanged( rDCEvt ); -} - -void SvxLineBox::FillControl() -{ - // FillStyles(); - if ( !mpSh ) - mpSh = SfxObjectShell::Current(); - - if( mpSh ) - { - const SvxDashListItem* pItem = mpSh->GetItem( SID_DASH_LIST ); - if ( pItem ) - Fill( pItem->GetDashList() ); - } -} - SvxMetricField::SvxMetricField( vcl::Window* pParent, const Reference< XFrame >& rFrame ) : MetricField(pParent, WB_BORDER | WB_SPIN | WB_REPEAT) @@ -303,7 +77,6 @@ SvxMetricField::SvxMetricField( Show(); } - void SvxMetricField::Update( const XLineWidthItem* pItem ) { if ( pItem ) @@ -315,7 +88,6 @@ void SvxMetricField::Update( const XLineWidthItem* pItem ) SetText( "" ); } - void SvxMetricField::Modify() { MetricField::Modify(); @@ -332,7 +104,6 @@ void SvxMetricField::Modify() aArgs ); } - void SvxMetricField::ReleaseFocus_Impl() { if( SfxViewShell::Current() ) diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx index 80c36beb55d5..31233a13e5ea 100644 --- a/svx/source/tbxctrls/linectrl.cxx +++ b/svx/source/tbxctrls/linectrl.cxx @@ -19,6 +19,8 @@ #include <string> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> #include <vcl/toolbox.hxx> #include <sfx2/app.hxx> #include <sfx2/dispatch.hxx> @@ -42,6 +44,7 @@ #include <svx/linectrl.hxx> #include <svx/itemwin.hxx> #include <svx/dialmgr.hxx> +#include <svx/tbxcolorupdate.hxx> #include <svx/unoapi.hxx> #include <memory> @@ -55,198 +58,171 @@ using namespace ::com::sun::star; // For End Line Controller #define MAX_LINES 12 -SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem ); -SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem ); - -SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( sal_uInt16 nSlotId, - sal_uInt16 nId, - ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ), - bUpdate ( false ) +SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext ) + : svt::PopupWindowController( rContext, nullptr, OUString() ) { - addStatusListener( ".uno:LineDash"); - addStatusListener( ".uno:DashListState"); + addStatusListener(".uno:LineDash"); } - SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl() { } - -void SvxLineStyleToolBoxControl::StateChanged ( - - sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) - +void SAL_CALL SvxLineStyleToolBoxControl::statusChanged( const frame::FeatureStateEvent& rEvent ) { - SvxLineBox* pBox = static_cast<SvxLineBox*>( GetToolBox().GetItemWindow( GetId() ) ); - DBG_ASSERT( pBox, "Window not found!" ); + ToolBox* pToolBox = nullptr; + sal_uInt16 nId = 0; + if (!getToolboxId(nId, &pToolBox) && !m_pToolbar) + return; + + OString sId(m_aCommandURL.toUtf8()); - if( eState == SfxItemState::DISABLED ) + if ( rEvent.FeatureURL.Complete == m_aCommandURL ) { - pBox->Disable(); - pBox->SetNoSelection(); + if (m_pToolbar) + m_pToolbar->set_item_sensitive(sId, rEvent.IsEnabled); + else + pToolBox->EnableItem( nId, rEvent.IsEnabled ); } - else - { - pBox->Enable(); - if ( eState == SfxItemState::DEFAULT ) + m_xBtnUpdater->Update(rEvent); + + SfxObjectShell* pSh = SfxObjectShell::Current(); + if (pSh) + { + const SvxDashListItem* pItem = pSh->GetItem( SID_DASH_LIST ); + if (pItem) { - if( nSID == SID_ATTR_LINE_STYLE ) + XDashListRef xList = pItem->GetDashList(); + int nIndex = m_xBtnUpdater->GetStyleIndex(); + switch (nIndex) { - pStyleItem.reset( static_cast<XLineStyleItem*>(pState->Clone()) ); - } - else if( nSID == SID_ATTR_LINE_DASH ) - { - pDashItem.reset( static_cast<XLineDashItem*>(pState->Clone()) ); + case -1: + case 0: + { + BitmapEx aEmpty(xList->GetBitmapForUISolidLine()); + aEmpty.Erase(Application::GetSettings().GetStyleSettings().GetFieldColor()); + if (m_pToolbar) + { + Graphic aGraf(aEmpty); + m_pToolbar->set_item_image(sId, aGraf.GetXGraphic()); + } + else + pToolBox->SetItemImage(nId, Image(aEmpty)); + break; + } + case 1: + if (m_pToolbar) + { + Graphic aGraf(xList->GetBitmapForUISolidLine()); + m_pToolbar->set_item_image(sId, aGraf.GetXGraphic()); + } + else + pToolBox->SetItemImage(nId, Image(xList->GetBitmapForUISolidLine())); + break; + default: + if (m_pToolbar) + { + Graphic aGraf(xList->GetUiBitmap(nIndex - 2)); + m_pToolbar->set_item_image(sId, aGraf.GetXGraphic()); + } + else + pToolBox->SetItemImage(nId, Image(xList->GetUiBitmap(nIndex - 2))); + break; } - - bUpdate = true; - Update( pState ); - } - else if ( nSID != SID_DASH_LIST ) - { - // no or ambiguous status - pBox->SetNoSelection(); } } } - -void SvxLineStyleToolBoxControl::Update( const SfxPoolItem* pState ) +void SAL_CALL SvxLineStyleToolBoxControl::execute(sal_Int16 /*KeyModifier*/) { - if ( pState && bUpdate ) + if (m_pToolbar) { - bUpdate = false; - - SvxLineBox* pBox = static_cast<SvxLineBox*>(GetToolBox().GetItemWindow( GetId() )); - DBG_ASSERT( pBox, "Window not found!" ); - - // Since the timer can strike unexpectedly, it may happen that - // the LB is not yet filled. A ClearCache() on the control - // in DelayHdl () was unsuccessful. - if( pBox->GetEntryCount() == 0 ) - pBox->FillControl(); - - drawing::LineStyle eXLS; - - if ( pStyleItem ) - eXLS = pStyleItem->GetValue(); - else - eXLS = drawing::LineStyle_NONE; - - switch( eXLS ) - { - case drawing::LineStyle_NONE: - pBox->SelectEntryPos( 0 ); - break; - - case drawing::LineStyle_SOLID: - pBox->SelectEntryPos( 1 ); - break; + // Toggle the popup also when toolbutton is activated + const OString aId(m_aCommandURL.toUtf8()); + m_pToolbar->set_menu_item_active(aId, !m_pToolbar->get_menu_item_active(aId)); + } + else + { + // Open the popup also when Enter key is pressed. + createPopupWindow(); + } +} - case drawing::LineStyle_DASH: - { - if( pDashItem ) - { - OUString aString = SvxUnogetInternalNameForItem( - XATTR_LINEDASH, pDashItem->GetName()); - pBox->SelectEntry( aString ); - } - else - pBox->SetNoSelection(); - } - break; +void SvxLineStyleToolBoxControl::initialize( const css::uno::Sequence<css::uno::Any>& rArguments ) +{ + svt::PopupWindowController::initialize( rArguments ); - default: - OSL_FAIL( "Unsupported type of line" ); - break; - } + if (m_pToolbar) + { + mxPopoverContainer.reset(new ToolbarPopupContainer(m_pToolbar)); + m_pToolbar->set_item_popover(m_aCommandURL.toUtf8(), mxPopoverContainer->getTopLevel()); } - if ( auto pDashListItem = dynamic_cast<const SvxDashListItem*>( pState) ) + ToolBox* pToolBox = nullptr; + sal_uInt16 nId = 0; + if ( getToolboxId( nId, &pToolBox ) ) { - // The list of line styles has changed - SvxLineBox* pBox = static_cast<SvxLineBox*>(GetToolBox().GetItemWindow( GetId() )); - DBG_ASSERT( pBox, "Window not found!" ); - - OUString aString( pBox->GetSelectedEntry() ); - pBox->Clear(); - pBox->InsertEntry( SvxResId(RID_SVXSTR_INVISIBLE) ); - pBox->InsertEntry( SvxResId(RID_SVXSTR_SOLID) ); - pBox->Fill( pDashListItem->GetDashList() ); - pBox->SelectEntry( aString ); + pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY ); } -} + m_xBtnUpdater.reset(new svx::ToolboxButtonLineStyleUpdater); +} -VclPtr<vcl::Window> SvxLineStyleToolBoxControl::CreateItemWindow( vcl::Window *pParent ) +void SvxLineStyleToolBoxControl::setLineStyleSelectFunction(const LineStyleSelectFunction& rLineStyleSelectFunction) { - return VclPtr<SvxLineBox>::Create( pParent, m_xFrame ).get(); + m_aLineStyleSelectFunction = rLineStyleSelectFunction; } -SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl( - sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ) +void SvxLineStyleToolBoxControl::dispatchLineStyleCommand(const OUString& rCommand, const Sequence<PropertyValue>& rArgs) { - addStatusListener( ".uno:MetricUnit"); -} + if (m_aLineStyleSelectFunction && m_aLineStyleSelectFunction(rCommand, rArgs[0].Value)) + return; + dispatchCommand(rCommand, rArgs); +} -SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl() +int SvxLineStyleToolBoxControl::GetStyleIndex() const { + return m_xBtnUpdater->GetStyleIndex(); } - -void SvxLineWidthToolBoxControl::StateChanged( - sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) +std::unique_ptr<WeldToolbarPopup> SvxLineStyleToolBoxControl::weldPopupWindow() { - SvxMetricField* pFld = static_cast<SvxMetricField*>( - GetToolBox().GetItemWindow( GetId() )); - DBG_ASSERT( pFld, "Window not found" ); + return std::make_unique<SvxLineBox>(this, m_pToolbar, m_xBtnUpdater->GetStyleIndex()); +} - if ( nSID == SID_ATTR_METRIC ) - { - pFld->RefreshDlgUnit(); - } - else - { - if ( eState == SfxItemState::DISABLED ) - { - pFld->Disable(); - pFld->SetText( "" ); - } - else - { - pFld->Enable(); +VclPtr<vcl::Window> SvxLineStyleToolBoxControl::createVclPopupWindow( vcl::Window* pParent ) +{ + mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent, + std::make_unique<SvxLineBox>(this, pParent->GetFrameWeld(), m_xBtnUpdater->GetStyleIndex())); - if ( eState == SfxItemState::DEFAULT ) - { - DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) != nullptr, "wrong ItemType" ); + mxInterimPopover->Show(); - // Core-Unit handed over to MetricField - // Should not happen in CreateItemWin ()! - // CD!!! GetCoreMetric(); - pFld->SetCoreUnit( MapUnit::Map100thMM ); + return mxInterimPopover; +} - pFld->Update( static_cast<const XLineWidthItem*>(pState) ); - } - else - pFld->Update( nullptr ); - } - } +OUString SvxLineStyleToolBoxControl::getImplementationName() +{ + return "com.sun.star.comp.svx.LineStyleToolBoxControl"; } +css::uno::Sequence<OUString> SvxLineStyleToolBoxControl::getSupportedServiceNames() +{ + return { "com.sun.star.frame.ToolbarController" }; +} -VclPtr<vcl::Window> SvxLineWidthToolBoxControl::CreateItemWindow( vcl::Window *pParent ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * +com_sun_star_comp_svx_LineStyleToolBoxControl_get_implementation( + css::uno::XComponentContext* rContext, + css::uno::Sequence<css::uno::Any> const & ) { - return VclPtr<SvxMetricField>::Create( pParent, m_xFrame ).get(); + return cppu::acquire( new SvxLineStyleToolBoxControl( rContext ) ); } namespace { -class SvxLineEndToolBoxControl : public svt::PopupWindowController +class SvxLineEndToolBoxControl final : public svt::PopupWindowController { public: explicit SvxLineEndToolBoxControl( const css::uno::Reference<css::uno::XComponentContext>& rContext ); @@ -529,4 +505,136 @@ com_sun_star_comp_svx_LineEndToolBoxControl_get_implementation( return cppu::acquire( new SvxLineEndToolBoxControl( rContext ) ); } +SvxLineBox::SvxLineBox(SvxLineStyleToolBoxControl* pControl, weld::Widget* pParent, int nInitialIndex) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/floatinglinestyle.ui", "FloatingLineStyle") + , mxControl(pControl) + , mxLineStyleSet(new SvtValueSet(m_xBuilder->weld_scrolled_window("valuesetwin"))) + , mxLineStyleSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLineStyleSet)) +{ + mxLineStyleSet->SetStyle(WB_FLATVALUESET | WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT); + + FillControl(); + + mxLineStyleSet->SelectItem(nInitialIndex + 1); + + mxLineStyleSet->SetSelectHdl( LINK( this, SvxLineBox, SelectHdl ) ); +} + +void SvxLineBox::GrabFocus() +{ + mxLineStyleSet->GrabFocus(); +} + +SvxLineBox::~SvxLineBox() +{ +} + +// Fills the listbox (provisional) with strings + +void SvxLineBox::Fill( const XDashListRef &pList ) +{ + mxLineStyleSet->Clear(); + + if( !pList.is() ) + return; + + // entry for 'none' + mxLineStyleSet->InsertItem(1, Image(), pList->GetStringForUiNoLine()); + + // entry for solid line + auto aBmp = pList->GetBitmapForUISolidLine(); + Size aBmpSize = aBmp.GetSizePixel(); + mxLineStyleSet->InsertItem(2, Image(aBmp), pList->GetStringForUiSolidLine()); + + // entries for dashed lines + long nCount = pList->Count(); + for( long i = 0; i < nCount; i++ ) + { + const XDashEntry* pEntry = pList->GetDash(i); + const BitmapEx aBitmap = pList->GetUiBitmap(i); + + mxLineStyleSet->InsertItem(i + 3, Image(aBitmap), pEntry->GetName()); + } + + sal_uInt16 nLines = std::min( static_cast<sal_uInt16>(nCount + 2), sal_uInt16(MAX_LINES) ); + mxLineStyleSet->SetLineCount(nLines); + + WinBits nBits = mxLineStyleSet->GetStyle(); + if ( nLines == mxLineStyleSet->GetItemCount() ) + nBits &= ~WB_VSCROLL; + else + nBits |= WB_VSCROLL; + mxLineStyleSet->SetStyle( nBits ); + + Size aSize(aBmpSize); + aSize.AdjustWidth(6); + aSize.AdjustHeight(6); + aSize = mxLineStyleSet->CalcWindowSizePixel(aSize); + mxLineStyleSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height()); + mxLineStyleSet->SetOutputSizePixel(aSize); +} + +IMPL_LINK_NOARG(SvxLineBox, SelectHdl, SvtValueSet*, void) +{ + drawing::LineStyle eXLS; + sal_Int32 nPos = mxLineStyleSet->GetSelectedItemId(); + --nPos; // ids start at 1, get the pos of the id + + switch ( nPos ) + { + case 0: + eXLS = drawing::LineStyle_NONE; + break; + + case 1: + eXLS = drawing::LineStyle_SOLID; + break; + + default: + { + eXLS = drawing::LineStyle_DASH; + + if ( nPos != -1 && + SfxObjectShell::Current() && + SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) + { + // LineDashItem will only be sent if it also has a dash. + // Notify cares! + SvxDashListItem const * pItem = SfxObjectShell::Current()->GetItem( SID_DASH_LIST ); + const XDashEntry* pEntry = pItem->GetDashList()->GetDash(nPos - 2); + XLineDashItem aLineDashItem(pEntry->GetName(), pEntry->GetDash()); + + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = "LineDash"; + aLineDashItem.QueryValue ( a ); + aArgs[0].Value = a; + mxControl->dispatchLineStyleCommand(".uno:LineDash", aArgs); + } + } + break; + } + + XLineStyleItem aLineStyleItem( eXLS ); + Any a; + Sequence< PropertyValue > aArgs( 1 ); + aArgs[0].Name = "XLineStyle"; + aLineStyleItem.QueryValue ( a ); + aArgs[0].Value = a; + mxControl->dispatchLineStyleCommand(".uno:XLineStyle", aArgs); + + mxControl->EndPopupMode(); +} + +void SvxLineBox::FillControl() +{ + SfxObjectShell* pSh = SfxObjectShell::Current(); + if (pSh) + { + const SvxDashListItem* pItem = pSh->GetItem( SID_DASH_LIST ); + if (pItem) + Fill(pItem->GetDashList()); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/linewidthctrl.cxx b/svx/source/tbxctrls/linewidthctrl.cxx new file mode 100644 index 000000000000..0a6d75446819 --- /dev/null +++ b/svx/source/tbxctrls/linewidthctrl.cxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <string> + +#include <vcl/toolbox.hxx> +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objsh.hxx> + +#include <svtools/toolbarmenu.hxx> +#include <svtools/popupwindowcontroller.hxx> +#include <svtools/valueset.hxx> + +#include <svx/strings.hrc> +#include <svx/svxids.hrc> +#include <helpids.h> + +#include <svx/drawitem.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlnwtit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xlnstit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xtable.hxx> +#include <svx/linectrl.hxx> +#include <svx/itemwin.hxx> +#include <svx/dialmgr.hxx> +#include <svx/tbxcolorupdate.hxx> +#include <svx/unoapi.hxx> +#include <memory> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star; + +SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem ); + +SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl( + sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : + SfxToolBoxControl( nSlotId, nId, rTbx ) +{ + addStatusListener( ".uno:MetricUnit"); +} + + +SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl() +{ +} + + +void SvxLineWidthToolBoxControl::StateChanged( + sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) +{ + SvxMetricField* pFld = static_cast<SvxMetricField*>( + GetToolBox().GetItemWindow( GetId() )); + DBG_ASSERT( pFld, "Window not found" ); + + if ( nSID == SID_ATTR_METRIC ) + { + pFld->RefreshDlgUnit(); + } + else + { + if ( eState == SfxItemState::DISABLED ) + { + pFld->Disable(); + pFld->SetText( "" ); + } + else + { + pFld->Enable(); + + if ( eState == SfxItemState::DEFAULT ) + { + DBG_ASSERT( dynamic_cast<const XLineWidthItem*>( pState) != nullptr, "wrong ItemType" ); + + // Core-Unit handed over to MetricField + // Should not happen in CreateItemWin ()! + // CD!!! GetCoreMetric(); + pFld->SetCoreUnit( MapUnit::Map100thMM ); + + pFld->Update( static_cast<const XLineWidthItem*>(pState) ); + } + else + pFld->Update( nullptr ); + } + } +} + + +VclPtr<vcl::Window> SvxLineWidthToolBoxControl::CreateItemWindow( vcl::Window *pParent ) +{ + return VclPtr<SvxMetricField>::Create( pParent, m_xFrame ).get(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx index 2895f258590b..554bf0205c7b 100644 --- a/svx/source/tbxctrls/tbxcolorupdate.cxx +++ b/svx/source/tbxctrls/tbxcolorupdate.cxx @@ -17,9 +17,14 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sfx2/objsh.hxx> +#include <svx/drawitem.hxx> #include <svx/tbxcolorupdate.hxx> #include <svx/svxids.hrc> +#include <svx/unomid.hxx> #include <svx/xdef.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xlndsit.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/svapp.hxx> @@ -275,6 +280,67 @@ namespace svx return Size(nWidth, nHeight); } + ToolboxButtonLineStyleUpdater::ToolboxButtonLineStyleUpdater() + : m_eXLS(css::drawing::LineStyle_NONE) + , m_nDashStyleIndex(-1) + { + } + + void ToolboxButtonLineStyleUpdater::Update(const com::sun::star::frame::FeatureStateEvent& rEvent) + { + if (rEvent.FeatureURL.Complete == ".uno:LineDash") + { + m_nDashStyleIndex = -1; + + SfxObjectShell* pSh = SfxObjectShell::Current(); + if (!pSh) + return; + const SvxDashListItem* pItem = pSh->GetItem( SID_DASH_LIST ); + if (!pItem) + return; + + XLineDashItem aDashItem; + aDashItem.PutValue(rEvent.State, 0); + const XDash& rDash = aDashItem.GetDashValue(); + + XDashListRef xLineStyleList = pItem->GetDashList(); + for (long i = 0; i < xLineStyleList->Count(); ++i) + { + const XDashEntry* pEntry = xLineStyleList->GetDash(i); + const XDash& rEntry = pEntry->GetDash(); + if (rDash == rEntry) + { + m_nDashStyleIndex = i; + break; + } + } + } + else if (rEvent.FeatureURL.Complete == ".uno:XLineStyle") + { + XLineStyleItem aLineStyleItem; + aLineStyleItem.PutValue(rEvent.State, 0); + + m_eXLS = aLineStyleItem.GetValue(); + } + } + + int ToolboxButtonLineStyleUpdater::GetStyleIndex() const + { + int nRet; + switch (m_eXLS) + { + case css::drawing::LineStyle_NONE: + nRet = 0; + break; + case css::drawing::LineStyle_SOLID: + nRet = 1; + break; + default: + nRet = m_nDashStyleIndex + 2; + break; + } + return nRet; + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/floatinglinestyle.ui b/svx/uiconfig/ui/floatinglinestyle.ui new file mode 100644 index 000000000000..126d8f6aa758 --- /dev/null +++ b/svx/uiconfig/ui/floatinglinestyle.ui @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface domain="sc"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkPopover" id="FloatingLineStyle"> + <property name="can_focus">False</property> + <property name="no_show_all">True</property> + <property name="border_width">4</property> + <child> + <object class="GtkBox" id="container"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkScrolledWindow" id="valuesetwin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="valueset"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/svx/uiconfig/ui/sidebarline.ui b/svx/uiconfig/ui/sidebarline.ui index 997255fc5e80..5ae3faa288d3 100644 --- a/svx/uiconfig/ui/sidebarline.ui +++ b/svx/uiconfig/ui/sidebarline.ui @@ -7,18 +7,6 @@ <property name="step_increment">10</property> <property name="page_increment">20</property> </object> - <object class="GtkListStore" id="liststore5"> - <columns> - <!-- column-name text --> - <column type="gchararray"/> - <!-- column-name id --> - <column type="gchararray"/> - <!-- column-name image --> - <column type="GdkPixbuf"/> - <!-- column-name surface --> - <column type="CairoSurface"/> - </columns> - </object> <object class="GtkGrid" id="LinePropertyPanel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -42,33 +30,13 @@ <property name="can_focus">False</property> <property name="spacing">3</property> <child> - <object class="GtkComboBox" id="linestyle"> - <property name="width_request">105</property> + <object class="GtkLabel" id="linelabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes" context="sidebarline|linestyle|tooltip_text">Select the style of the line.</property> - <property name="valign">center</property> - <property name="hexpand">True</property> - <property name="model">liststore5</property> - <property name="entry_text_column">0</property> - <property name="id_column">1</property> - <child> - <object class="GtkCellRendererText" id="cellrenderertext7"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - <child> - <object class="GtkCellRendererPixbuf" id="cellrenderertext11"/> - <attributes> - <attribute name="surface">3</attribute> - </attributes> - </child> - <child internal-child="accessible"> - <object class="AtkObject" id="linestyle-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes" context="sidebarline|linestyle-atkobject">Style</property> - </object> - </child> + <property name="label" translatable="yes" context="sidebarline|widthlabel">_Line:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">linestyle</property> + <property name="xalign">0</property> </object> <packing> <property name="expand">False</property> @@ -77,18 +45,17 @@ </packing> </child> <child> - <object class="GtkToolbar" id="arrowheads"> + <object class="GtkToolbar" id="linestyle"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="tooltip_text" translatable="yes" context="sidebarline|arrowheads|tooltip_text">Select the style of the arrowheads.</property> <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> <property name="icon_size">2</property> <child> - <object class="GtkMenuToolButton" id=".uno:LineEndStyle"> + <object class="GtkMenuToolButton" id=".uno:XLineStyle"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="tooltip_text" translatable="yes" context="sidebarline|arrowheads|tooltip_text">Select the style of the arrowheads.</property> + <property name="tooltip_text" translatable="yes" context="sidebarline|linestyle|tooltip_text">Select the style of the line.</property> <property name="use_underline">True</property> </object> <packing> @@ -96,10 +63,17 @@ <property name="homogeneous">False</property> </packing> </child> - <child internal-child="accessible"> - <object class="AtkObject" id="arrowheads-atkobject"> - <property name="AtkObject::accessible-name" context="sidebarline|arrowheads-atkobject" translatable="yes">Arrow Styles</property> + <child> + <object class="GtkMenuToolButton" id=".uno:LineEndStyle"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="tooltip_text" translatable="yes" context="sidebarline|linestyle|tooltip_text">Select the style of the arrowheads.</property> + <property name="use_underline">True</property> </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">False</property> + </packing> </child> </object> <packing> @@ -360,4 +334,24 @@ <widget name="color"/> </widgets> </object> + <object class="GtkSizeGroup"> + <widgets> + <widget name="linelabel"/> + <widget name="widthlabel"/> + <widget name="colorlabel"/> + <widget name="translabel"/> + </widgets> + </object> + <object class="GtkListStore" id="liststore5"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="GdkPixbuf"/> + <!-- column-name surface --> + <column type="CairoSurface"/> + </columns> + </object> </interface> diff --git a/svx/util/svx.component b/svx/util/svx.component index e54318dea597..81cae7623bd2 100644 --- a/svx/util/svx.component +++ b/svx/util/svx.component @@ -100,10 +100,6 @@ constructor="com_sun_star_comp_svx_SmartTagMenuController_get_implementation"> <service name="com.sun.star.frame.PopupMenuController"/> </implementation> - <implementation name="com.sun.star.comp.svx.LineEndToolBoxControl" - constructor="com_sun_star_comp_svx_LineEndToolBoxControl_get_implementation"> - <service name="com.sun.star.frame.ToolbarController"/> - </implementation> <implementation name="com.sun.star.comp.svx.LineSpacingToolBoxControl" constructor="com_sun_star_comp_svx_LineSpacingToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component index 50fedcc67feb..2c5a103857c4 100644 --- a/svx/util/svxcore.component +++ b/svx/util/svxcore.component @@ -62,6 +62,14 @@ constructor="com_sun_star_comp_svx_FontNameToolBoxControl_get_implementation"> <service name="com.sun.star.frame.ToolbarController"/> </implementation> + <implementation name="com.sun.star.comp.svx.LineEndToolBoxControl" + constructor="com_sun_star_comp_svx_LineEndToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> + <implementation name="com.sun.star.comp.svx.LineStyleToolBoxControl" + constructor="com_sun_star_comp_svx_LineStyleToolBoxControl_get_implementation"> + <service name="com.sun.star.frame.ToolbarController"/> + </implementation> <implementation name="com.sun.star.comp.Svx.GraphicExportHelper" constructor="com_sun_star_comp_Svx_GraphicExportHelper_get_implementation"> <service name="com.sun.star.document.BinaryStreamResolver"/> |