summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-08-14 18:08:18 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-08-15 04:49:33 +0200
commit43cce4ef2cf865b2bb637e17b70102a4260295b0 (patch)
treea78861b32737ea70d756a51160efddb84b810b38 /sw
parentd3a565eddffc6e39ffd47f018ec7ab17d2a554cd (diff)
tdf#122529 lok - table border position manipulation
This adds a new LOK callback (LOK_CALLBACK_TABLE_SELECTED) that sends the border positions to the client when the user has the cursor or slelection in a table. In addition this adds a .uno:TableChangeCurrentBorderPosition uno command, which implements changing a specific border in the current table. Border can be either a column or a row border, which is either at the first, middle or last position. Change-Id: Ife7cff14d91ffc84c95c040f0b42319e3d6194b4 Reviewed-on: https://gerrit.libreoffice.org/77365 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/crsrsh.hxx1
-rw-r--r--sw/sdi/_viewsh.sdi4
-rw-r--r--sw/source/core/crsr/crsrsh.cxx81
-rw-r--r--sw/source/uibase/uiview/viewtab.cxx80
4 files changed, 165 insertions, 1 deletions
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 6e1d61d17167..7ccb97c5b954 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -272,6 +272,7 @@ private:
SAL_DLLPRIVATE const SwRangeRedline* GotoRedline_( SwRedlineTable::size_type nArrPos, bool bSelect );
+ SAL_DLLPRIVATE void sendLOKCursorUpdates();
protected:
inline SwMoveFnCollection const & MakeFindRange( SwDocPositions, SwDocPositions, SwPaM* ) const;
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 5c4a6234efe9..824eb2f0e6e3 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -289,6 +289,10 @@ interface BaseTextEditView
StateMethod = StateTabWin ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
+ SID_TABLE_CHANGE_CURRENT_BORDER_POSITION
+ [
+ ExecMethod = ExecTabWin;
+ ]
FN_EDIT_LINK_DLG // status(final|play)
[
ExecMethod = Execute ;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 33992f06f86f..6abe0046dd81 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -73,6 +73,10 @@
#include <DocumentSettingManager.hxx>
#include <vcl/uitest/logger.hxx>
#include <vcl/uitest/eventdescription.hxx>
+#include <cntfrm.hxx>
+#include <tabcol.hxx>
+#include <wrtsh.hxx>
+#include <boost/property_tree/json_parser.hpp>
using namespace com::sun::star;
using namespace util;
@@ -2025,9 +2029,86 @@ void SwCursorShell::UpdateCursor( sal_uInt16 eFlags, bool bIdleEnd )
if( m_bSVCursorVis )
m_pVisibleCursor->Show(); // show again
+ if (comphelper::LibreOfficeKit::isActive())
+ sendLOKCursorUpdates();
+
getIDocumentMarkAccess()->NotifyCursorUpdate(*this);
}
+void SwCursorShell::sendLOKCursorUpdates()
+{
+ SwWrtShell* pShell = GetDoc()->GetDocShell()->GetWrtShell();
+ if (!pShell)
+ return;
+
+ SwFrame* pCurrentFrame = GetCurrFrame();
+ SelectionType eType = pShell->GetSelectionType();
+
+ boost::property_tree::ptree aRootTree;
+
+ if (pCurrentFrame && (eType & SelectionType::Table) && pCurrentFrame->IsInTab())
+ {
+ const SwRect& rPageRect = pShell->GetAnyCurRect(CurRectType::Page, nullptr);
+
+ boost::property_tree::ptree aTableColumns;
+ {
+ SwTabCols aTabCols;
+ pShell->GetTabCols(aTabCols);
+
+ const int nColumnOffset = aTabCols.GetLeftMin() + rPageRect.Left();
+
+ aTableColumns.put("left", aTabCols.GetLeft());
+ aTableColumns.put("right", aTabCols.GetRight());
+ aTableColumns.put("tableOffset", nColumnOffset);
+
+ boost::property_tree::ptree aEntries;
+ for (size_t i = 0; i < aTabCols.Count(); ++i)
+ {
+ auto const & rEntry = aTabCols.GetEntry(i);
+ boost::property_tree::ptree aTableColumnEntry;
+ aTableColumnEntry.put("position", rEntry.nPos);
+ aTableColumnEntry.put("min", rEntry.nMin);
+ aTableColumnEntry.put("max", rEntry.nMax);
+ aTableColumnEntry.put("hidden", rEntry.bHidden);
+ aEntries.push_back(std::make_pair("", aTableColumnEntry));
+ }
+ aTableColumns.push_back(std::make_pair("entries", aEntries));
+ }
+
+ boost::property_tree::ptree aTableRows;
+ {
+ SwTabCols aTabRows;
+ pShell->GetTabRows(aTabRows);
+
+ const int nRowOffset = aTabRows.GetLeftMin() + rPageRect.Top();
+
+ aTableRows.put("left", aTabRows.GetLeft());
+ aTableRows.put("right", aTabRows.GetRight());
+ aTableRows.put("tableOffset", nRowOffset);
+
+ boost::property_tree::ptree aEntries;
+ for (size_t i = 0; i < aTabRows.Count(); ++i)
+ {
+ auto const & rEntry = aTabRows.GetEntry(i);
+ boost::property_tree::ptree aTableRowEntry;
+ aTableRowEntry.put("position", rEntry.nPos);
+ aTableRowEntry.put("min", rEntry.nMin);
+ aTableRowEntry.put("max", rEntry.nMax);
+ aTableRowEntry.put("hidden", rEntry.bHidden);
+ aEntries.push_back(std::make_pair("", aTableRowEntry));
+ }
+ aTableRows.push_back(std::make_pair("entries", aEntries));
+ }
+
+ aRootTree.add_child("columns", aTableColumns);
+ aRootTree.add_child("rows", aTableRows);
+ }
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aRootTree);
+ GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, aStream.str().c_str());
+}
+
void SwCursorShell::RefreshBlockCursor()
{
assert(m_pBlockCursor);
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index bc7c72c59040..5a13260040d3 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -58,7 +58,7 @@
#include <fmtcol.hxx>
#include <section.hxx>
#include <swruler.hxx>
-
+#include <cntfrm.hxx>
#include <ndtxt.hxx>
#include <pam.hxx>
@@ -1009,7 +1009,85 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
}
}
break;
+ case SID_TABLE_CHANGE_CURRENT_BORDER_POSITION:
+ {
+ if (pReqArgs)
+ {
+ const SfxPoolItem *pBorderType;
+ const SfxPoolItem *pIndex;
+ const SfxPoolItem *pNewPosition;
+ constexpr long constDistanceOffset = 40;
+
+ if (pReqArgs->GetItemState(SID_TABLE_BORDER_TYPE, true, &pBorderType) == SfxItemState::SET
+ && pReqArgs->GetItemState(SID_TABLE_BORDER_INDEX, true, &pIndex) == SfxItemState::SET
+ && pReqArgs->GetItemState(SID_TABLE_BORDER_NEW_POSITION, true, &pNewPosition) == SfxItemState::SET)
+ {
+ const OUString sType = static_cast<const SfxStringItem*>(pBorderType)->GetValue();
+ const sal_uInt16 nIndex = static_cast<const SfxUInt16Item*>(pIndex)->GetValue();
+ const sal_Int32 nNewPosition = static_cast<const SfxInt32Item*>(pNewPosition)->GetValue();
+
+ if (sType.startsWith("column"))
+ {
+ SwTabCols aTabCols;
+ rSh.GetTabCols(aTabCols);
+
+ if (sType == "column-left")
+ {
+ auto & rEntry = aTabCols.GetEntry(0);
+ long nPosition = std::min(long(nNewPosition), rEntry.nPos - constDistanceOffset);
+ aTabCols.SetLeft(nPosition);
+ }
+ else if (sType == "column-right")
+ {
+ auto & rEntry = aTabCols.GetEntry(aTabCols.Count() - 1);
+ long nPosition = std::max(long(nNewPosition), rEntry.nPos + constDistanceOffset);
+ aTabCols.SetRight(nPosition);
+ }
+ else if (sType == "column-middle")
+ {
+ if (nIndex < aTabCols.Count())
+ {
+ auto & rEntry = aTabCols.GetEntry(nIndex);
+ long nPosition = std::clamp(long(nNewPosition), rEntry.nMin, rEntry.nMax - constDistanceOffset);
+ rEntry.nPos = nPosition;
+ }
+ }
+ rSh.SetTabCols(aTabCols, false);
+ }
+ else if (sType.startsWith("row"))
+ {
+ SwTabCols aTabRows;
+ rSh.GetTabRows(aTabRows);
+
+ if (sType == "row-left")
+ {
+ auto & rEntry = aTabRows.GetEntry(0);
+ long nPosition = std::min(long(nNewPosition), rEntry.nPos - constDistanceOffset);
+ aTabRows.SetLeft(nPosition);
+ }
+ else if (sType == "row-right")
+ {
+ auto & rEntry = aTabRows.GetEntry(aTabRows.Count() - 1);
+ long nPosition = std::max(long(nNewPosition), rEntry.nPos + constDistanceOffset);
+ aTabRows.SetRight(nPosition);
+ }
+ else if (sType == "row-middle")
+ {
+ if (nIndex < aTabRows.Count())
+ {
+ auto & rEntry = aTabRows.GetEntry(nIndex);
+ long nPosition = std::clamp(long(nNewPosition), rEntry.nMin, rEntry.nMax - constDistanceOffset);
+ rEntry.nPos = nPosition;
+ }
+ }
+
+ rSh.SetTabRows(aTabRows, false);
+ }
+ }
+ }
+ }
+ break;
case SID_ATTR_PAGE_HEADER:
{
if ( pReqArgs )