summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-10-26 16:15:58 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-10-28 17:10:31 +0100
commitef44d2e190ace76b07d37c38f17c08a292683148 (patch)
tree353715562ddb6d0f1c7f851f227ccdc0104c1798
parentAdd new 'Table' sidebar panel to Writer (diff)
downloadcore-ef44d2e190ace76b07d37c38f17c08a292683148.tar.gz
core-ef44d2e190ace76b07d37c38f17c08a292683148.zip
Table panel: Implement functionality of Row Height spinbutton
Change-Id: Ic3e3ce31fdc74c9cb4c41e1243f10f5977d5bb0c
-rw-r--r--sw/inc/cmdid.h1
-rw-r--r--sw/sdi/_tabsh.sdi7
-rw-r--r--sw/sdi/swriter.sdi18
-rw-r--r--sw/source/uibase/shells/tabsh.cxx27
-rw-r--r--sw/source/uibase/sidebar/SwPanelFactory.cxx2
-rw-r--r--sw/source/uibase/sidebar/TableEditPanel.cxx82
-rw-r--r--sw/source/uibase/sidebar/TableEditPanel.hxx16
7 files changed, 143 insertions, 10 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 3f96725b5bf8..54b23f73382b 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -7788,3 +7788,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 3eaa79c98208..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,23 +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::dispose() { PanelLayout::dispose(); }
+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 bdbfe6ff236e..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,15 +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