diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-10-30 13:23:29 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-11-04 20:26:19 +0100 |
commit | 5929a87b8137bf6326adfd4ddfd8075e585ae15c (patch) | |
tree | f7e1225a53a4cca41a6fa1b86bec3a944b9ebebb /svx/source | |
parent | c7ba28eaa766f2c1d4f0d3b25b40dd40777bc66b (diff) |
line spacing: Change the implementation so that it can be used in toolbars.
Before it was only sidebar-specific, duplicating most the sfx2 framework, and
making it impossible to be used from the toolbars.
Change-Id: Ibb382633395157602dd806052824e5275503c3e0
Diffstat (limited to 'svx/source')
6 files changed, 47 insertions, 101 deletions
diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx index 7eb29ab5efb1..5b890e995730 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx @@ -51,13 +51,13 @@ #define LSP_LV_GLOBAL_VALUE "Line_Spacing_Lv" #define BEGIN_VALUE 28 +using namespace svx; using namespace svx::sidebar; -ParaLineSpacingControl::ParaLineSpacingControl(vcl::Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel) - : PopupControl( pParent,SVX_RES(RID_POPUPPANEL_PARAPAGE_LINESPACING)) - , mbUseLineSPCustom (false) - , mbLineSPDisable (false) - , mrParaPropertyPanel(rPanel) +ParaLineSpacingControl::ParaLineSpacingControl(sal_uInt16 nId, const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, WinBits nBits) + : SfxPopupWindow(nId, rFrame, pParentWindow, nBits) + , mbUseLineSPCustom(false) + , mbLineSPDisable(false) , mpBindings(NULL) , nMinFixDist(BEGIN_VALUE) , pActLineDistFld(&aLineDistAtPercentBox) @@ -90,10 +90,9 @@ ParaLineSpacingControl::ParaLineSpacingControl(vcl::Window* pParent, svx::sideba { initial(); FreeResource(); - mpBindings = mrParaPropertyPanel.GetBindings(); -// m_eLNSpaceUnit = mrParaPropertyPanel.maLNSpaceControl.GetCoreMetric(); m_eLNSpaceUnit = SFX_MAPUNIT_100TH_MM; } + ParaLineSpacingControl::~ParaLineSpacingControl() { delete[] mpImg; @@ -714,10 +713,8 @@ IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) { if(!(mbLineSPDisable)) { - //maPos = mrParaPropertyPanel.maLinePos; aLineDist.SelectEntryPos( maPos ) ; aLineDist.SaveValue(); - //maValue = mrParaPropertyPanel.maLineValue; SvxLineSpacingItem aSpacing(_DEFAULT_LINE_SPACING, SID_ATTR_PARA_LINESPACE); switch(maPos) @@ -751,8 +748,7 @@ IMPL_LINK(ParaLineSpacingControl, VSSelHdl, void *, pControl) break; } } - if(bClosePop) - mrParaPropertyPanel.EndSpacingPopupMode(); + return 0; } @@ -776,7 +772,6 @@ void ParaLineSpacingControl::ExecuteLineSpacing( bool aIsCustom, sal_uInt16 aEnt if( !aIsCustom ) { mbUseLineSPCustom = DO_NOT_CUSTOM; - mrParaPropertyPanel.EndSpacingPopupMode(); } maLineSpacing.SetNoSelection(); } diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx index 1115298ef322..1b9af2d15d3f 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx @@ -19,24 +19,24 @@ #ifndef INCLUDED_SVX_SOURCE_SIDEBAR_PARAGRAPH_PARALINESPACINGCONTROL_HXX #define INCLUDED_SVX_SOURCE_SIDEBAR_PARAGRAPH_PARALINESPACINGCONTROL_HXX -#include "svx/sidebar/PopupControl.hxx" #include "svx/sidebar/ValueSetWithTextControl.hxx" #include <sfx2/bindings.hxx> #include <svtools/ctrlbox.hxx> #include <svtools/ctrltool.hxx> -#include "ParaPropertyPanel.hxx" #include <vcl/fixed.hxx> #include <svl/poolitem.hxx> #include <editeng/lspcitem.hxx> #include <sfx2/sidebar/EnumContext.hxx> +#include <sfx2/tbxctrl.hxx> -namespace svx { namespace sidebar { +namespace svx { -class ParaLineSpacingControl:public svx::sidebar::PopupControl +class ParaLineSpacingControl : public SfxPopupWindow { public: - ParaLineSpacingControl(vcl::Window* pParent, svx::sidebar::ParaPropertyPanel& rPanel); + ParaLineSpacingControl(sal_uInt16 nId, const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, WinBits nBits); virtual ~ParaLineSpacingControl(); + void Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext); //virtual void Paint(const Rectangle& rect); @@ -57,13 +57,12 @@ private: bool mbUseLineSPCustom; bool mbLineSPDisable; SfxMapUnit m_eLNSpaceUnit; - ParaPropertyPanel& mrParaPropertyPanel; SfxBindings* mpBindings; long nMinFixDist; Edit* pActLineDistFld; - ValueSetWithTextControl maLineSpacing; + svx::sidebar::ValueSetWithTextControl maLineSpacing; FixedText maCustomFT; FixedText maLSpacingFT; @@ -102,7 +101,8 @@ private: DECL_LINK(LineSPDistAtHdl_Impl, void*); DECL_LINK(VSSelHdl, void*); }; -}} + +} // namespace svx #endif diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx b/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx index e5cae1c859b0..4f97276be46e 100644 --- a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx +++ b/svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx @@ -17,45 +17,48 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "ParaLineSpacingPopup.hxx" #include "ParaLineSpacingControl.hxx" -#include <boost/bind.hpp> + +#include <svx/ParaLineSpacingPopup.hxx> #include <unotools/viewoptions.hxx> +#include <vcl/toolbox.hxx> + +using namespace svx; -namespace svx { namespace sidebar { +SFX_IMPL_TOOLBOX_CONTROL(ParaLineSpacingPopup, SvxLineSpacingItem); -ParaLineSpacingPopup::ParaLineSpacingPopup(vcl::Window* pParent, const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator) - : Popup( - pParent, - rControlCreator, - OUString("Paragraph Line Spacing")) +ParaLineSpacingPopup::ParaLineSpacingPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx) + : SfxToolBoxControl(nSlotId, nId, rTbx) { - SetPopupModeEndHandler(::boost::bind(&ParaLineSpacingPopup::PopupModeEndCallback, this)); + rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits(nId)); } ParaLineSpacingPopup::~ParaLineSpacingPopup() { } -void ParaLineSpacingPopup::Rearrange(SfxItemState currSPState,FieldUnit currMetricUnit,SvxLineSpacingItem* currSPItem,const ::sfx2::sidebar::EnumContext currentContext) +SfxPopupWindowType ParaLineSpacingPopup::GetPopupWindowType() const { - ProvideContainerAndControl(); - - ParaLineSpacingControl* pControl = dynamic_cast<ParaLineSpacingControl*>(mpControl.get()); - if (pControl != NULL) - pControl->Rearrange(currSPState, currMetricUnit, currSPItem,currentContext); + return SFX_POPUPWINDOW_ONTIMEOUT; } -void ParaLineSpacingPopup::PopupModeEndCallback() +SfxPopupWindow* ParaLineSpacingPopup::CreatePopupWindow() { - ProvideContainerAndControl(); - ParaLineSpacingControl* pControl = dynamic_cast<ParaLineSpacingControl*>(mpControl.get()); - if (pControl == NULL) - return; + ParaLineSpacingControl* pControl = new ParaLineSpacingControl(GetSlotId(), m_xFrame, &GetToolBox(), /* WinBits - TODO? */(WinBits)0); + + //pControl->StartPopupMode(&GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE); + pControl->StartPopupMode(&GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE); + //pControl->StartSelection(); - pControl->PopupModeEndCallback(); + SetPopupWindow(pControl); + //pControl->SetSelectedHdl(LINK(this, ParaLineSpacingPopup, SelectedHdl)); + + return pControl; } -} } +void ParaLineSpacingPopup::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) +{ + // FIXME - do we need to do anything here? +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.hxx b/svx/source/sidebar/paragraph/ParaLineSpacingPopup.hxx deleted file mode 100644 index c331f73bf1f7..000000000000 --- a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- 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 . - */ -#ifndef INCLUDED_SVX_SOURCE_SIDEBAR_PARAGRAPH_PARALINESPACINGPOPUP_HXX -#define INCLUDED_SVX_SOURCE_SIDEBAR_PARAGRAPH_PARALINESPACINGPOPUP_HXX - -#include "svx/sidebar/Popup.hxx" - -#include <boost/function.hpp> -#include <svl/poolitem.hxx> -#include <tools/fldunit.hxx> -#include <editeng/lspcitem.hxx> -#include <sfx2/sidebar/EnumContext.hxx> - -namespace svx { namespace sidebar { - -class ParaLineSpacingPopup - : public Popup -{ -public : - ParaLineSpacingPopup(vcl::Window* pParent, const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator); - virtual ~ParaLineSpacingPopup(); - - void Rearrange(SfxItemState currSPState, FieldUnit currMetricUnit, SvxLineSpacingItem* currSPItem, const ::sfx2::sidebar::EnumContext currentContext); -private: - void PopupModeEndCallback(); -}; - -} } // end of namespace svx::sidebar - -#endif - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx index eb8878fe78ae..45d7bd5e5d05 100644 --- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx +++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx @@ -19,7 +19,6 @@ #include "ParaPropertyPanel.hxx" #include "ParaPropertyPanel.hrc" -#include "ParaLineSpacingPopup.hxx" #include "ParaLineSpacingControl.hxx" #include "ParaBulletsPopup.hxx" #include "ParaBulletsControl.hxx" @@ -225,7 +224,7 @@ void ParaPropertyPanel::ReSize(bool /* bSize */) void ParaPropertyPanel::EndSpacingPopupMode (void) { - maLineSpacePopup.Hide(); + //maLineSpacePopup.Hide(); } void ParaPropertyPanel::EndBulletsPopupMode (void) @@ -504,8 +503,8 @@ IMPL_LINK( ParaPropertyPanel, ClickLineSPDropDownHdl_Impl, ToolBox*, pBox ) if (aCommand == UNO_LINESPACING) { pBox->SetItemDown( nId, true ); - maLineSpacePopup.Rearrange(meLnSpState,m_eMetricUnit,mpLnSPItem,maContext); - maLineSpacePopup.Show(*pBox); + //maLineSpacePopup.Rearrange(meLnSpState,m_eMetricUnit,mpLnSPItem,maContext); + //maLineSpacePopup.Show(*pBox); } return (0L); } @@ -969,11 +968,11 @@ FieldUnit ParaPropertyPanel::GetCurrentUnit( SfxItemState eState, const SfxPoolI return eUnit; } - +/* PopupControl* ParaPropertyPanel::CreateLineSpacingControl (PopupContainer* pParent) { return new ParaLineSpacingControl(pParent, *this); -} +}*/ PopupControl* ParaPropertyPanel::CreateBulletsPopupControl (PopupContainer* pParent) { @@ -1023,7 +1022,7 @@ ParaPropertyPanel::ParaPropertyPanel(vcl::Window* pParent, mxFrame(rxFrame), maContext(), mpBindings(pBindings), - maLineSpacePopup(this, ::boost::bind(&ParaPropertyPanel::CreateLineSpacingControl, this, _1)), + //maLineSpacePopup(this, ::boost::bind(&ParaPropertyPanel::CreateLineSpacingControl, this, _1)), maBulletsPopup(this, ::boost::bind(&ParaPropertyPanel::CreateBulletsPopupControl, this, _1)), maNumberingPopup(this, ::boost::bind(&ParaPropertyPanel::CreateNumberingPopupControl, this, _1)), mxSidebar(rxSidebar) diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx index b305b53086a0..f387988d8e12 100644 --- a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx +++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx @@ -39,7 +39,6 @@ #include "ParaBulletsPopup.hxx" #include "ParaNumberingPopup.hxx" -#include "ParaLineSpacingPopup.hxx" class FloatingWindow; class ToolBox; @@ -140,7 +139,6 @@ private: css::uno::Reference<css::frame::XFrame> mxFrame; ::sfx2::sidebar::EnumContext maContext; SfxBindings* mpBindings; - ParaLineSpacingPopup maLineSpacePopup; ParaBulletsPopup maBulletsPopup; ParaNumberingPopup maNumberingPopup; css::uno::Reference<css::ui::XSidebar> mxSidebar; @@ -175,7 +173,7 @@ private: void ReSize(bool bSize); - PopupControl* CreateLineSpacingControl (PopupContainer* pParent); + //PopupControl* CreateLineSpacingControl (PopupContainer* pParent); PopupControl* CreateBulletsPopupControl (PopupContainer* pParent); PopupControl* CreateNumberingPopupControl (PopupContainer* pParent); DECL_LINK(ClickLineSPDropDownHdl_Impl, ToolBox*); |