summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-10-30 13:23:29 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-04 20:26:19 +0100
commit5929a87b8137bf6326adfd4ddfd8075e585ae15c (patch)
treef7e1225a53a4cca41a6fa1b86bec3a944b9ebebb
parentcoverity#1242845 use of untrusted scalar (diff)
downloadcore-5929a87b8137bf6326adfd4ddfd8075e585ae15c.tar.gz
core-5929a87b8137bf6326adfd4ddfd8075e585ae15c.zip
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
-rw-r--r--configmgr/qa/unit/data.xcd5
-rw-r--r--include/svx/ParaLineSpacingPopup.hxx (renamed from svx/source/sidebar/paragraph/ParaLineSpacingPopup.hxx)28
-rw-r--r--include/svx/svxcommands.h1
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu5
-rw-r--r--svx/sdi/svx.sdi1
-rw-r--r--svx/source/sidebar/paragraph/ParaLineSpacingControl.cxx19
-rw-r--r--svx/source/sidebar/paragraph/ParaLineSpacingControl.hxx16
-rw-r--r--svx/source/sidebar/paragraph/ParaLineSpacingPopup.cxx47
-rw-r--r--svx/source/sidebar/paragraph/ParaPropertyPanel.cxx13
-rw-r--r--svx/source/sidebar/paragraph/ParaPropertyPanel.hxx4
-rw-r--r--sw/source/uibase/app/swmodule.cxx4
-rw-r--r--sw/uiconfig/swriter/toolbar/textobjectbar.xml4
12 files changed, 77 insertions, 70 deletions
diff --git a/configmgr/qa/unit/data.xcd b/configmgr/qa/unit/data.xcd
index caaf6ec02512..c4da17c3bf02 100644
--- a/configmgr/qa/unit/data.xcd
+++ b/configmgr/qa/unit/data.xcd
@@ -1644,6 +1644,11 @@
<value>7</value>
</prop>
</node>
+ <node oor:name=".uno:LineSpacing" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="x-no-translate"></value><value xml:lang="en-US">Line Spacing</value>
+ </prop>
+ </node>
<node oor:name=".uno:SpacePara1" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="x-no-translate"></value><value xml:lang="en-US">Line Spacing: 1</value>
diff --git a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.hxx b/include/svx/ParaLineSpacingPopup.hxx
index c331f73bf1f7..f0d41bf6de28 100644
--- a/svx/source/sidebar/paragraph/ParaLineSpacingPopup.hxx
+++ b/include/svx/ParaLineSpacingPopup.hxx
@@ -19,29 +19,31 @@
#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>
+#include <sfx2/tbxctrl.hxx>
+#include <svl/poolitem.hxx>
+#include <svx/svxdllapi.h>
+#include <tools/fldunit.hxx>
-namespace svx { namespace sidebar {
+namespace svx {
-class ParaLineSpacingPopup
- : public Popup
+class SVX_DLLPUBLIC ParaLineSpacingPopup : public SfxToolBoxControl
{
-public :
- ParaLineSpacingPopup(vcl::Window* pParent, const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator);
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ ParaLineSpacingPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
virtual ~ParaLineSpacingPopup();
- void Rearrange(SfxItemState currSPState, FieldUnit currMetricUnit, SvxLineSpacingItem* currSPItem, const ::sfx2::sidebar::EnumContext currentContext);
-private:
- void PopupModeEndCallback();
+ virtual SfxPopupWindowType GetPopupWindowType() const SAL_OVERRIDE;
+ virtual SfxPopupWindow* CreatePopupWindow() SAL_OVERRIDE;
+ virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) SAL_OVERRIDE;
};
-} } // end of namespace svx::sidebar
+} // namespace svx
#endif
diff --git a/include/svx/svxcommands.h b/include/svx/svxcommands.h
index fdcc22788808..3f31dd1ecbc0 100644
--- a/include/svx/svxcommands.h
+++ b/include/svx/svxcommands.h
@@ -95,6 +95,7 @@
#define CMD_SID_ATTR_PARA_ADJUST_BLOCK ".uno:JustifyPara"
#define CMD_SID_LEAVE_GROUP ".uno:LeaveGroup"
#define CMD_SID_ATTR_PARA_ADJUST_LEFT ".uno:LeftPara"
+#define CMD_SID_ATTR_PARA_LINESPACE ".uno:LineSpacing"
#define CMD_SID_FM_LISTBOX ".uno:ListBox"
#define CMD_SID_FM_NUMERICFIELD ".uno:NumericField"
#define CMD_SID_OBJECT_ALIGN ".uno:ObjectAlign"
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index d3fdb310d699..a15aa77bbabc 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -1590,6 +1590,11 @@
<value>15</value>
</prop>
</node>
+ <node oor:name=".uno:LineSpacing" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Line Spacing</value>
+ </prop>
+ </node>
<node oor:name=".uno:SpacePara1" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Line Spacing: 1</value>
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 839b243d1bef..1a50327ee3eb 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -10652,7 +10652,6 @@ SfxVoidItem Sortup SID_FM_SORTUP
GroupId = GID_TABLE;
]
-
SfxBoolItem SpacePara1 SID_ATTR_PARA_LINESPACE_10
[
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/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*);
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index bd1809f64c33..ecee71758f05 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -23,8 +23,9 @@
#include <swerror.h>
#include <vcl/wrkwin.hxx>
#include <vcl/graph.hxx>
-#include <svx/svdobj.hxx>
#include <svtools/ehdl.hxx>
+#include <svx/ParaLineSpacingPopup.hxx>
+#include <svx/svdobj.hxx>
#include <svx/fntszctl.hxx>
#include <svx/fntctl.hxx>
#include <svx/SmartTagCtl.hxx>
@@ -301,6 +302,7 @@ void SwDLL::RegisterControls()
SwTbxInsertCtrl::RegisterControl(FN_INSERT_OBJ_CTRL, pMod );
SwTbxFieldCtrl::RegisterControl(FN_INSERT_FIELD_CTRL, pMod );
SwTbxAutoTextCtrl::RegisterControl(FN_GLOSSARY_DLG, pMod );
+ svx::ParaLineSpacingPopup::RegisterControl(SID_ATTR_PARA_LINESPACE, pMod);
SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_BASIC, pMod );
SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_SYMBOL, pMod );
diff --git a/sw/uiconfig/swriter/toolbar/textobjectbar.xml b/sw/uiconfig/swriter/toolbar/textobjectbar.xml
index 3b9c27627ebd..ef691054514a 100644
--- a/sw/uiconfig/swriter/toolbar/textobjectbar.xml
+++ b/sw/uiconfig/swriter/toolbar/textobjectbar.xml
@@ -56,9 +56,7 @@
<toolbar:toolbaritem xlink:href=".uno:ParaLeftToRight" toolbar:style="radio"/>
<toolbar:toolbaritem xlink:href=".uno:ParaRightToLeft" toolbar:style="radio"/>
<toolbar:toolbarseparator/>
- <toolbar:toolbaritem xlink:href=".uno:SpacePara1" toolbar:style="radio"/>
- <toolbar:toolbaritem xlink:href=".uno:SpacePara15" toolbar:style="radio"/>
- <toolbar:toolbaritem xlink:href=".uno:SpacePara2" toolbar:style="radio"/>
+ <toolbar:toolbaritem xlink:href=".uno:LineSpacing"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:FontDialog" toolbar:visible="false"/>
<toolbar:toolbaritem xlink:href=".uno:ParagraphDialog" toolbar:visible="false"/>