[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/LibreOfficeKit include/svx libreofficekit/source svx/sdi sw/sdi sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Apr 14 13:03:59 UTC 2020
include/LibreOfficeKit/LibreOfficeKitEnums.h | 9 +++
include/svx/svxids.hrc | 3 +
libreofficekit/source/gtk/lokdocview.cxx | 1
svx/sdi/svx.sdi | 19 +++++++
sw/sdi/_viewsh.sdi | 4 +
sw/source/uibase/uiview/viewtab.cxx | 70 ++++++++++++++++++++++++++-
6 files changed, 103 insertions(+), 3 deletions(-)
New commits:
commit d6a15427a15166c4910e28645346cd47135b706a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Apr 14 07:35:02 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Apr 14 15:03:22 2020 +0200
lok: add tabstop changing and callback to send tabstop updates
This adds callback LOK_CALLBACK_TAB_STOP_LIST to send the tabstops
for the current paragraph.
In addition it adds .uno:ChangeTabStop action, with which it is
possible to change just one tabstop identified by the index.
Change-Id: I7762ead12e47288cbb0b0a1c8ffb8e9872cee8e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92139
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index de547df505ea..401b5f24dc0b 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -720,7 +720,12 @@ typedef enum
* Send the list of functions whose name starts with the characters entered
* by the user in the formula input bar.
*/
- LOK_CALLBACK_CALC_FUNCTION_LIST = 47
+ LOK_CALLBACK_CALC_FUNCTION_LIST = 47,
+
+ /**
+ * Sends the tab stop list for the current of the current cursor position.
+ */
+ LOK_CALLBACK_TAB_STOP_LIST = 48,
}
LibreOfficeKitCallbackType;
@@ -845,6 +850,8 @@ static inline const char* lokCallbackTypeToString(int nType)
return "LOK_CALLBACK_JSDIALOG";
case LOK_CALLBACK_CALC_FUNCTION_LIST:
return "LOK_CALLBACK_CALC_FUNCTION_LIST";
+ case LOK_CALLBACK_TAB_STOP_LIST:
+ return "LOK_CALLBACK_TAB_STOP_LIST";
}
assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index d429b17f2af0..7d9d69e08dfe 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -529,6 +529,9 @@ class SfxStringItem;
#define SID_ATTR_ALIGN_DEGREES ( SID_SVX_START + 577 )
#define SID_ATTR_ALIGN_LOCKPOS ( SID_SVX_START + 578 )
#define SID_ATTR_NUMBERFORMAT_ONE_AREA ( SID_SVX_START + 580 )
+#define SID_TABSTOP_ADD_OR_CHANGE ( SID_SVX_START + 581 )
+#define SID_TABSTOP_ATTR_INDEX ( SID_SVX_START + 582 )
+#define SID_TABSTOP_ATTR_POSITION ( SID_SVX_START + 583 )
// CAUTION! Range <587 .. 587> used by EditEngine (!)
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 87fe7689ce0e..6284d85ee9b1 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1377,6 +1377,7 @@ callback (gpointer pData)
case LOK_CALLBACK_TABLE_SELECTED:
case LOK_CALLBACK_JSDIALOG:
case LOK_CALLBACK_CALC_FUNCTION_LIST:
+ case LOK_CALLBACK_TAB_STOP_LIST:
{
// TODO: Implement me
break;
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 6f85de054c85..5261f616308b 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -7175,6 +7175,25 @@ SfxVoidItem RulerChangeState SID_RULER_CHANGE_STATE
GroupId = ;
]
+SfxVoidItem ChangeTabStop SID_TABSTOP_ADD_OR_CHANGE
+ (SfxInt32Item Index SID_TABSTOP_ATTR_INDEX,
+ SfxInt32Item Position SID_TABSTOP_ATTR_POSITION)
+[
+ AutoUpdate = FALSE,
+ FastCall = TRUE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = ;
+]
+
SfxVoidItem TableChangeCurrentBorderPosition SID_TABLE_CHANGE_CURRENT_BORDER_POSITION
(SfxStringItem BorderType SID_TABLE_BORDER_TYPE,
SfxUInt16Item Index SID_TABLE_BORDER_INDEX,
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 824eb2f0e6e3..b4c3803e0a0d 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -631,6 +631,10 @@ interface BaseTextEditView
StateMethod = StateTabWin ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
+ SID_TABSTOP_ADD_OR_CHANGE // status()
+ [
+ ExecMethod = ExecTabWin;
+ ]
// from here Export = FALSE;
FID_SEARCH_ON // status()
[
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index d9b61426b9e1..7b51c2331408 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -57,6 +57,7 @@
#include <ndtxt.hxx>
#include <pam.hxx>
#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <IDocumentSettingAccess.hxx>
@@ -652,6 +653,49 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
rSh.SetAttrItem( aTabStops );
}
break;
+ case SID_TABSTOP_ADD_OR_CHANGE:
+ if (pReqArgs)
+ {
+ const auto aIndexItem = static_cast<const SfxInt32Item&>(pReqArgs->Get(SID_TABSTOP_ATTR_INDEX));
+ const auto aPositionItem = static_cast<const SfxInt32Item&>(pReqArgs->Get(SID_TABSTOP_ATTR_POSITION));
+ const sal_Int32 nIndex = aIndexItem.GetValue();
+ const sal_Int32 nPosition = aPositionItem.GetValue();
+
+ SfxItemSet aItemSet(GetPool(), svl::Items<RES_PARATR_TABSTOP, RES_PARATR_TABSTOP>{});
+ rSh.GetCurAttr(aItemSet);
+ SvxTabStopItem aTabStopItem(aItemSet.Get(RES_PARATR_TABSTOP));
+ lcl_EraseDefTabs(aTabStopItem);
+
+ if (nIndex < aTabStopItem.Count())
+ {
+ if (nIndex == -1)
+ {
+ SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
+ aTabStopItem.Insert(aSwTabStop);
+
+ const SvxTabStopItem& rDefaultTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
+ MakeDefTabs(GetTabDist(rDefaultTabs), aTabStopItem);
+
+ SvxTabStop aTabStop(nPosition);
+ aTabStopItem.Insert(aTabStop);
+ }
+ else
+ {
+ SvxTabStop aTabStop = aTabStopItem.At(nIndex);
+ aTabStopItem.Remove(nIndex);
+ aTabStop.GetTabPos() = nPosition;
+ aTabStopItem.Insert(aTabStop);
+
+ SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
+ aTabStopItem.Insert(aSwTabStop);
+
+ const SvxTabStopItem& rDefaultTabs = rSh.GetDefault(RES_PARATR_TABSTOP);
+ MakeDefTabs(GetTabDist(rDefaultTabs), aTabStopItem);
+ }
+ rSh.SetAttrItem(aTabStopItem);
+ }
+ }
+ break;
case SID_HANGING_INDENT:
{
@@ -1272,14 +1316,14 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
// will be submitted to the tab bar.
void SwView::StateTabWin(SfxItemSet& rSet)
{
- SwWrtShell &rSh = GetWrtShell();
+ SwWrtShell &rSh = GetWrtShell();
const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &m_aTabColFromDocPos : nullptr;
const FrameTypeFlags nFrameType = rSh.IsObjSelected()
? FrameTypeFlags::DRAWOBJ
: rSh.GetFrameType( pPt, true );
- const bool bFrameSelection = rSh.IsFrameSelected();
+ const bool bFrameSelection = rSh.IsFrameSelected();
const bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
// PageOffset/limiter
const SwRect& rPageRect = rSh.GetAnyCurRect( CurRectType::Page, pPt );
@@ -1502,6 +1546,28 @@ void SwView::StateTabWin(SfxItemSet& rSet)
::lcl_EraseDefTabs(aTabStops);
aTabStops.SetWhich(nWhich);
rSet.Put(aTabStops);
+
+ if (comphelper::LibreOfficeKit::isActive() && nWhich == RES_PARATR_TABSTOP)
+ {
+ boost::property_tree::ptree aRootTree;
+ boost::property_tree::ptree aEntries;
+
+ for (sal_uInt16 i = 0; i < aTabStops.Count(); ++i)
+ {
+ SvxTabStop const & rTabStop = aTabStops[i];
+ boost::property_tree::ptree aEntry;
+ aEntry.put("position", convertTwipToMm100(rTabStop.GetTabPos()));
+ aEntry.put("type", sal_uInt16(rTabStop.GetAdjustment()));
+ aEntry.put("decimal", OUString(rTabStop.GetDecimal()));
+ aEntry.put("fill", OUString(rTabStop.GetFill()));
+ aEntries.push_back(std::make_pair("", aEntry));
+ }
+ aRootTree.push_back(std::make_pair("tabstops", aEntries));
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aRootTree);
+ rSh.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TAB_STOP_LIST, aStream.str().c_str());
+ }
}
break;
}
More information about the Libreoffice-commits
mailing list