diff options
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/sdi/_tabsh.sdi | 7 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 18 | ||||
-rw-r--r-- | sw/source/uibase/shells/tabsh.cxx | 27 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/SwPanelFactory.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/TableEditPanel.cxx | 82 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/TableEditPanel.hxx | 17 |
7 files changed, 145 insertions, 9 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 491b18228167..b9db78c21b81 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -411,6 +411,7 @@ #define FN_TABLE_MODE_FIX_PROP (FN_FORMAT + 190) /* -"- */ #define FN_TABLE_MODE_VARIABLE (FN_FORMAT + 191) /* -"- */ #define FN_TABLE_BOX_TEXTORIENTATION (FN_FORMAT + 192) /* text orientation of table cells */ +#define SID_ATTR_TABLE_ROW_HEIGHT (FN_FORMAT + 193) #define FN_TABLE_AUTOSUM (FN_FORMAT + 195) /* */ diff --git a/sw/sdi/_tabsh.sdi b/sw/sdi/_tabsh.sdi index 9cb65cd4d276..948d6e5476f6 100644 --- a/sw/sdi/_tabsh.sdi +++ b/sw/sdi/_tabsh.sdi @@ -437,5 +437,12 @@ interface BaseTextTable StateMethod = GetState ; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_ATTR_TABLE_ROW_HEIGHT + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] } diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 8316bd9c8bd5..bdae66ae91d5 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7790,3 +7790,21 @@ SfxVoidItem DatePickerFormField FN_INSERT_DATE_FORMFIELD ToolBoxConfig = TRUE, GroupId = SfxGroupId::Controls; ] + +SfxUInt32Item TableRowHeight SID_ATTR_TABLE_ROW_HEIGHT + +[ + AutoUpdate = TRUE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = TRUE, + MenuConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = SfxGroupId::Table; +] diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 3555f79b8217..8dd1fbf65297 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -1114,6 +1114,21 @@ void SwTableShell::Execute(SfxRequest &rReq) //'this' is already destroyed return; } + case SID_ATTR_TABLE_ROW_HEIGHT: + { + const SfxUInt32Item* pItem2 = rReq.GetArg<SfxUInt32Item>(SID_ATTR_TABLE_ROW_HEIGHT); + if (pItem2) + { + long nNewHeight = pItem2->GetValue(); + std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight(); + if ( pHeight ) + { + pHeight->SetHeight(nNewHeight); + rSh.SetRowHeight(*pHeight); + } + } + return; + } default: bMore = true; } @@ -1389,6 +1404,18 @@ void SwTableShell::GetState(SfxItemSet &rSet) if(rSh.HasBoxSelection()) rSet.DisableItem( nSlot ); break; + case SID_ATTR_TABLE_ROW_HEIGHT: + { + SfxUInt32Item aRowHeight(SID_ATTR_TABLE_ROW_HEIGHT); + std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight(); + if (pHeight) + { + long nHeight = pHeight->GetHeight(); + aRowHeight.SetValue(nHeight); + rSet.Put(aRowHeight); + } + break; + } } nSlot = aIter.NextWhich(); } diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx index e602093d966a..4c7f28e1753e 100644 --- a/sw/source/uibase/sidebar/SwPanelFactory.cxx +++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx @@ -185,7 +185,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement ( } else if (rsResourceURL.endsWith("/TableEditPanel")) { - VclPtr<vcl::Window> pPanel = sw::sidebar::TableEditPanel::Create(pParentWindow, xFrame); + VclPtr<vcl::Window> pPanel = sw::sidebar::TableEditPanel::Create(pParentWindow, xFrame, pBindings ); xElement = sfx2::sidebar::SidebarPanelBase::Create( rsResourceURL, xFrame, pPanel, ui::LayoutSize(-1,-1,-1)); } diff --git a/sw/source/uibase/sidebar/TableEditPanel.cxx b/sw/source/uibase/sidebar/TableEditPanel.cxx index 0d563f0f4211..54395b8863b8 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.cxx +++ b/sw/source/uibase/sidebar/TableEditPanel.cxx @@ -8,8 +8,16 @@ * */ -#include <sal/config.h> #include "TableEditPanel.hxx" +#include <sal/config.h> +#include <swtypes.hxx> +#include <cmdid.h> +#include <svl/intitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <svtools/unitconv.hxx> +#include <swmodule.hxx> +#include <usrpref.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -18,7 +26,8 @@ namespace sw namespace sidebar { VclPtr<vcl::Window> TableEditPanel::Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame) + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) { if (pParent == nullptr) throw css::lang::IllegalArgumentException( @@ -27,21 +36,82 @@ VclPtr<vcl::Window> TableEditPanel::Create(vcl::Window* pParent, throw css::lang::IllegalArgumentException("no XFrame given to TableEditPanel::Create", nullptr, 1); - return VclPtr<TableEditPanel>::Create(pParent, rxFrame); + return VclPtr<TableEditPanel>::Create(pParent, rxFrame, pBindings); } -void TableEditPanel::NotifyItemUpdate(const sal_uInt16 /*nSId*/, const SfxItemState /*eState*/, - const SfxPoolItem* /*pState*/) +void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState eState, + const SfxPoolItem* pState) { + switch (nSID) + { + case SID_ATTR_TABLE_ROW_HEIGHT: + { + if (pState && eState >= SfxItemState::DEFAULT) + { + const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(pState); + if (pItem) + { + long nNewHeight = pItem->GetValue(); + nNewHeight = m_pHeightEdit->Normalize(nNewHeight); + m_pHeightEdit->SetValue(nNewHeight, FieldUnit::TWIP); + } + } + else if (eState == SfxItemState::DISABLED) + { + m_pHeightEdit->Disable(); + } + else + { + m_pHeightEdit->SetEmptyFieldValue(); + } + break; + } + } } TableEditPanel::TableEditPanel(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame) + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings) : PanelLayout(pParent, "TableEditPanel", "modules/swriter/ui/sidebartableedit.ui", rxFrame) + , m_pBindings(pBindings) + , m_aRowHeightController(SID_ATTR_TABLE_ROW_HEIGHT, *pBindings, *this) { + get(m_pHeightEdit, "rowheight"); + InitRowHeightToolitem(); } TableEditPanel::~TableEditPanel() { disposeOnce(); } + +void TableEditPanel::InitRowHeightToolitem() +{ + Link<Edit&, void> aLink = LINK(this, TableEditPanel, RowHeightMofiyHdl); + m_pHeightEdit->SetModifyHdl(aLink); + + FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(false)->GetMetric(); + SetFieldUnit(*m_pHeightEdit, eFieldUnit); + + m_pHeightEdit->SetMin(MINLAY, FieldUnit::TWIP); + m_pHeightEdit->SetMax(SAL_MAX_INT32, FieldUnit::TWIP); +} + +void TableEditPanel::dispose() +{ + m_pHeightEdit.clear(); + m_aRowHeightController.dispose(); + + PanelLayout::dispose(); +} + +IMPL_LINK_NOARG(TableEditPanel, RowHeightMofiyHdl, Edit&, void) +{ + SwTwips nNewHeight = static_cast<SwTwips>( + m_pHeightEdit->Denormalize(m_pHeightEdit->GetValue(FieldUnit::TWIP))); + SfxUInt32Item aRowHeight(SID_ATTR_TABLE_ROW_HEIGHT); + aRowHeight.SetValue(nNewHeight); + + m_pBindings->GetDispatcher()->ExecuteList(SID_ATTR_TABLE_ROW_HEIGHT, SfxCallMode::RECORD, + { &aRowHeight }); +} } } // end of namespace ::sw::sidebar diff --git a/sw/source/uibase/sidebar/TableEditPanel.hxx b/sw/source/uibase/sidebar/TableEditPanel.hxx index 4ab651a98a0d..10044d582138 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.hxx +++ b/sw/source/uibase/sidebar/TableEditPanel.hxx @@ -14,6 +14,7 @@ #include <com/sun/star/frame/XFrame.hpp> #include <svx/sidebar/PanelLayout.hxx> #include <sfx2/sidebar/ControllerItem.hxx> +#include <svx/relfld.hxx> namespace sw { @@ -26,14 +27,26 @@ class TableEditPanel : public PanelLayout, public: static VclPtr<vcl::Window> Create(vcl::Window* pParent, - const css::uno::Reference<css::frame::XFrame>& rxFrame); + const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState eState, const SfxPoolItem* pState) override; private: - TableEditPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame); + TableEditPanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, + SfxBindings* pBindings); virtual ~TableEditPanel() override; + virtual void dispose() override; + + void InitRowHeightToolitem(); + + SfxBindings* m_pBindings; + + VclPtr<SvxRelativeField> m_pHeightEdit; + ::sfx2::sidebar::ControllerItem m_aRowHeightController; + + DECL_LINK(RowHeightMofiyHdl, Edit&, void); }; } } // end of namespace sw::sidebar |