Kaydet (Commit) 5929a87b authored tarafından Jan Holesovsky's avatar Jan Holesovsky

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
üst c7ba28ea
......@@ -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>
......
......@@ -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
......
......@@ -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"
......
......@@ -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>
......
......@@ -10652,7 +10652,6 @@ SfxVoidItem Sortup SID_FM_SORTUP
GroupId = GID_TABLE;
]
SfxBoolItem SpacePara1 SID_ATTR_PARA_LINESPACE_10
[
......
......@@ -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();
}
......
......@@ -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
......
......@@ -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: */
......@@ -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)
......
......@@ -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*);
......
......@@ -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 );
......
......@@ -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"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment