[Libreoffice-commits] core.git: 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:45 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          |   72 ++++++++++++++++++++++++++-
 6 files changed, 105 insertions(+), 3 deletions(-)

New commits:
commit a60b18a8c5d5c11c87dbbaaf884de138dfeb6c8f
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:04 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/+/92147
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 5ad801a7a74f..53bc3099e282 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 32b0f5ba8350..1aa3111beeba 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -533,6 +533,9 @@ class SvxSetItem;
 #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 0d7ad9b9e7a6..c9235f41b2a4 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1398,6 +1398,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 75d2993297ee..ad31871008af 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -7207,6 +7207,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 acef4c75f26a..47b95ab80409 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -643,6 +643,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 844bbfce782b..6b7dee96379b 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -55,6 +55,9 @@
 #include <section.hxx>
 #include <ndtxt.hxx>
 #include <pam.hxx>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <boost/property_tree/json_parser.hpp>
 
 #include <IDocumentSettingAccess.hxx>
 
@@ -647,6 +650,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:
     {
@@ -1266,14 +1312,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 );
@@ -1496,6 +1542,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