sw/inc/cmdid.h | 2 sw/sdi/_tabsh.sdi | 14 ++ sw/sdi/swriter.sdi | 36 +++++++ sw/source/uibase/shells/tabsh.cxx | 49 ++++++++++ sw/source/uibase/sidebar/SwPanelFactory.cxx | 2 sw/source/uibase/sidebar/TableEditPanel.cxx | 133 ++++++++++++++++++++++++++-- sw/source/uibase/sidebar/TableEditPanel.hxx | 21 ++++ 7 files changed, 248 insertions(+), 9 deletions(-)
New commits: commit ac48a33060304a62372b00bfef08b067cec6ceb6 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Mon Oct 28 17:11:21 2019 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sat Nov 2 13:25:53 2019 +0100 Table panel: Implement functionality of Column Width spinbutton Change-Id: I809cfe4af82cebabe80c171cdd488ff43d749a86 Reviewed-on: https://gerrit.libreoffice.org/81895 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index b9db78c21b81..838091eb82a7 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -412,6 +412,7 @@ #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 SID_ATTR_TABLE_COLUMN_WIDTH (FN_FORMAT2 + 194) #define FN_TABLE_AUTOSUM (FN_FORMAT + 195) /* */ diff --git a/sw/sdi/_tabsh.sdi b/sw/sdi/_tabsh.sdi index 948d6e5476f6..e39edc61c3c0 100644 --- a/sw/sdi/_tabsh.sdi +++ b/sw/sdi/_tabsh.sdi @@ -444,5 +444,12 @@ interface BaseTextTable StateMethod = GetState ; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_ATTR_TABLE_COLUMN_WIDTH + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] } diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index bdae66ae91d5..ae8e4a37b44a 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7808,3 +7808,21 @@ SfxUInt32Item TableRowHeight SID_ATTR_TABLE_ROW_HEIGHT ToolBoxConfig = TRUE, GroupId = SfxGroupId::Table; ] + +SfxUInt32Item TableColumWidth SID_ATTR_TABLE_COLUMN_WIDTH + +[ + 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 8dd1fbf65297..57e6f99b59ec 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -1129,6 +1129,18 @@ void SwTableShell::Execute(SfxRequest &rReq) } return; } + case SID_ATTR_TABLE_COLUMN_WIDTH: + { + const SfxUInt32Item* pItem2 = rReq.GetArg<SfxUInt32Item>(SID_ATTR_TABLE_COLUMN_WIDTH); + if (pItem2) + { + long nNewWidth = pItem2->GetValue(); + SwTableFUNC aFunc( &rSh ); + aFunc.InitTabCols(); + aFunc.SetColWidth(aFunc.GetCurColNum(), nNewWidth); + } + return; + } default: bMore = true; } @@ -1416,6 +1428,16 @@ void SwTableShell::GetState(SfxItemSet &rSet) } break; } + case SID_ATTR_TABLE_COLUMN_WIDTH: + { + SfxUInt32Item aColumnWidth(SID_ATTR_TABLE_COLUMN_WIDTH); + SwTableFUNC aFunc( &rSh ); + aFunc.InitTabCols(); + SwTwips nWidth = aFunc.GetColWidth(aFunc.GetCurColNum()); + aColumnWidth.SetValue(nWidth); + rSet.Put(aColumnWidth); + break; + } } nSlot = aIter.NextWhich(); } diff --git a/sw/source/uibase/sidebar/TableEditPanel.cxx b/sw/source/uibase/sidebar/TableEditPanel.cxx index 54395b8863b8..b803845547a6 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.cxx +++ b/sw/source/uibase/sidebar/TableEditPanel.cxx @@ -52,17 +52,39 @@ void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState if (pItem) { long nNewHeight = pItem->GetValue(); - nNewHeight = m_pHeightEdit->Normalize(nNewHeight); - m_pHeightEdit->SetValue(nNewHeight, FieldUnit::TWIP); + nNewHeight = m_pRowHeightEdit->Normalize(nNewHeight); + m_pRowHeightEdit->SetValue(nNewHeight, FieldUnit::TWIP); } } else if (eState == SfxItemState::DISABLED) { - m_pHeightEdit->Disable(); + m_pRowHeightEdit->Disable(); } else { - m_pHeightEdit->SetEmptyFieldValue(); + m_pRowHeightEdit->SetEmptyFieldValue(); + } + break; + } + case SID_ATTR_TABLE_COLUMN_WIDTH: + { + if (pState && eState >= SfxItemState::DEFAULT) + { + const SfxUInt32Item* pItem = static_cast<const SfxUInt32Item*>(pState); + if (pItem) + { + long nNewWidth = pItem->GetValue(); + nNewWidth = m_pColumnWidthEdit->Normalize(nNewWidth); + m_pColumnWidthEdit->SetValue(nNewWidth, FieldUnit::TWIP); + } + } + else if (eState == SfxItemState::DISABLED) + { + m_pColumnWidthEdit->Disable(); + } + else + { + m_pColumnWidthEdit->SetEmptyFieldValue(); } break; } @@ -75,9 +97,13 @@ TableEditPanel::TableEditPanel(vcl::Window* pParent, : PanelLayout(pParent, "TableEditPanel", "modules/swriter/ui/sidebartableedit.ui", rxFrame) , m_pBindings(pBindings) , m_aRowHeightController(SID_ATTR_TABLE_ROW_HEIGHT, *pBindings, *this) + , m_aColumnWidthController(SID_ATTR_TABLE_COLUMN_WIDTH, *pBindings, *this) { - get(m_pHeightEdit, "rowheight"); + get(m_pRowHeightEdit, "rowheight"); + get(m_pColumnWidthEdit, "columnwidth"); + InitRowHeightToolitem(); + InitColumnWidthToolitem(); } TableEditPanel::~TableEditPanel() { disposeOnce(); } @@ -85,19 +111,33 @@ TableEditPanel::~TableEditPanel() { disposeOnce(); } void TableEditPanel::InitRowHeightToolitem() { Link<Edit&, void> aLink = LINK(this, TableEditPanel, RowHeightMofiyHdl); - m_pHeightEdit->SetModifyHdl(aLink); + m_pRowHeightEdit->SetModifyHdl(aLink); FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(false)->GetMetric(); - SetFieldUnit(*m_pHeightEdit, eFieldUnit); + SetFieldUnit(*m_pRowHeightEdit, eFieldUnit); - m_pHeightEdit->SetMin(MINLAY, FieldUnit::TWIP); - m_pHeightEdit->SetMax(SAL_MAX_INT32, FieldUnit::TWIP); + m_pRowHeightEdit->SetMin(MINLAY, FieldUnit::TWIP); + m_pRowHeightEdit->SetMax(SAL_MAX_INT32, FieldUnit::TWIP); +} + +void TableEditPanel::InitColumnWidthToolitem() +{ + Link<Edit&, void> aLink = LINK(this, TableEditPanel, ColumnWidthMofiyHdl); + m_pColumnWidthEdit->SetModifyHdl(aLink); + + FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(false)->GetMetric(); + SetFieldUnit(*m_pColumnWidthEdit, eFieldUnit); + + m_pColumnWidthEdit->SetMin(MINLAY, FieldUnit::TWIP); + m_pColumnWidthEdit->SetMax(SAL_MAX_INT32, FieldUnit::TWIP); } void TableEditPanel::dispose() { - m_pHeightEdit.clear(); + m_pRowHeightEdit.clear(); + m_pColumnWidthEdit.clear(); m_aRowHeightController.dispose(); + m_aColumnWidthController.dispose(); PanelLayout::dispose(); } @@ -105,13 +145,24 @@ void TableEditPanel::dispose() IMPL_LINK_NOARG(TableEditPanel, RowHeightMofiyHdl, Edit&, void) { SwTwips nNewHeight = static_cast<SwTwips>( - m_pHeightEdit->Denormalize(m_pHeightEdit->GetValue(FieldUnit::TWIP))); + m_pRowHeightEdit->Denormalize(m_pRowHeightEdit->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 }); } + +IMPL_LINK_NOARG(TableEditPanel, ColumnWidthMofiyHdl, Edit&, void) +{ + SwTwips nNewWidth = static_cast<SwTwips>( + m_pColumnWidthEdit->Denormalize(m_pColumnWidthEdit->GetValue(FieldUnit::TWIP))); + SfxUInt32Item aColumnWidth(SID_ATTR_TABLE_COLUMN_WIDTH); + aColumnWidth.SetValue(nNewWidth); + + m_pBindings->GetDispatcher()->ExecuteList(SID_ATTR_TABLE_COLUMN_WIDTH, SfxCallMode::RECORD, + { &aColumnWidth }); +} } } // end of namespace ::sw::sidebar diff --git a/sw/source/uibase/sidebar/TableEditPanel.hxx b/sw/source/uibase/sidebar/TableEditPanel.hxx index 10044d582138..a0ce4e6f14d2 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.hxx +++ b/sw/source/uibase/sidebar/TableEditPanel.hxx @@ -40,13 +40,17 @@ private: virtual void dispose() override; void InitRowHeightToolitem(); + void InitColumnWidthToolitem(); SfxBindings* m_pBindings; - VclPtr<SvxRelativeField> m_pHeightEdit; + VclPtr<SvxRelativeField> m_pRowHeightEdit; + VclPtr<SvxRelativeField> m_pColumnWidthEdit; ::sfx2::sidebar::ControllerItem m_aRowHeightController; + ::sfx2::sidebar::ControllerItem m_aColumnWidthController; DECL_LINK(RowHeightMofiyHdl, Edit&, void); + DECL_LINK(ColumnWidthMofiyHdl, Edit&, void); }; } } // end of namespace sw::sidebar commit 5e113259f8382c2d045193abd79267529a6a5f6b Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Sat Nov 2 11:35:33 2019 +0100 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Sat Nov 2 13:25:35 2019 +0100 Table panel: Implement functionality of Row Height spinbutton Change-Id: Ic3e3ce31fdc74c9cb4c41e1243f10f5977d5bb0c Reviewed-on: https://gerrit.libreoffice.org/81894 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits