[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - include/svx sd/sdi svx/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 5 13:48:45 UTC 2019


 include/svx/sdr/table/tablecontroller.hxx |    1 
 include/svx/svdotable.hxx                 |    8 +
 sd/sdi/tables.sdi                         |    5 +
 svx/source/inc/tablemodel.hxx             |    3 
 svx/source/svdraw/svdmrkv.cxx             |   68 ++++++++++------
 svx/source/table/svdotable.cxx            |  122 +++++++++++++++++++++++-------
 svx/source/table/tablecontroller.cxx      |   74 ++++++++++++++++++
 svx/source/table/tablelayouter.cxx        |   31 +++++++
 svx/source/table/tablelayouter.hxx        |   17 ++++
 svx/source/table/tablemodel.cxx           |    8 +
 svx/source/table/tablerow.cxx             |    5 +
 svx/source/table/tablerow.hxx             |    2 
 12 files changed, 287 insertions(+), 57 deletions(-)

New commits:
commit 2b97f12c0a740dfdabb4fd27154aef46c963a81c
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Aug 26 20:07:12 2019 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Sep 5 15:47:53 2019 +0200

    tdf#126959 impress table border resize handle support
    
    This adds support to edit the resize handles for the impress.
    It includes:
    - sending the positions of handles when table object is
    selected or changed
    - a implementaton of SID_TABLE_CHANGE_CURRENT_BORDER_POSITION
    to perform the changing of the border positions of a table
    
    Reviewed-on: https://gerrit.libreoffice.org/78201
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 0285492a45e9cc19c26e14dcdf297bcc491da4d2)
    
    Change-Id: I6f60822c5cd9afc3be5c48ea7b775f1860bfa5a7
    Reviewed-on: https://gerrit.libreoffice.org/78331
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index 79730758b419..e99d8fdf6ee6 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -75,6 +75,7 @@ public:
     SVX_DLLPRIVATE void DistributeColumns();
     SVX_DLLPRIVATE void DistributeRows();
     SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
+    SVX_DLLPRIVATE void changeTableEdge(const SfxRequest& rReq);
 
     SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
 
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index 7537e2184d00..fb95069726f8 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -26,7 +26,7 @@
 #include <rtl/ref.hxx>
 #include <svx/svdotext.hxx>
 #include <svx/svxdllapi.h>
-
+#include <boost/property_tree/json_parser.hpp>
 
 class SvStream;
 class SfxStyleSheet;
@@ -88,7 +88,6 @@ struct SVX_DLLPUBLIC TableStyleSettings
     bool operator==( const TableStyleSettings& r ) const;
 };
 
-
 /// SdrTableObj
 class SdrTableObjImpl;
 
@@ -138,6 +137,11 @@ public:
     void setActiveCell( const sdr::table::CellPos& rPos );
     void getActiveCellPos( sdr::table::CellPos& rPos ) const;
     sal_Int32 getColumnCount() const;
+    sal_Int32 getRowCount() const;
+
+    bool createTableEdgesJson(boost::property_tree::ptree & rJsonRoot);
+    void changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset);
+
     void getCellBounds( const sdr::table::CellPos& rPos, ::tools::Rectangle& rCellRect );
 
     const SfxItemSet& GetActiveCellItemSet() const;
diff --git a/sd/sdi/tables.sdi b/sd/sdi/tables.sdi
index ba9488841933..624415942efa 100644
--- a/sd/sdi/tables.sdi
+++ b/sd/sdi/tables.sdi
@@ -155,5 +155,10 @@ shell TableObjectBar
         ExecMethod = Execute;
         StateMethod = GetState;
     ]
+    SID_TABLE_CHANGE_CURRENT_BORDER_POSITION
+    [
+        ExecMethod = Execute;
+    ]
+
 }
 
diff --git a/svx/source/inc/tablemodel.hxx b/svx/source/inc/tablemodel.hxx
index 5c1ac7a86e6d..31d670e5f99b 100644
--- a/svx/source/inc/tablemodel.hxx
+++ b/svx/source/inc/tablemodel.hxx
@@ -87,6 +87,9 @@ public:
 
     void dumpAsXml(struct _xmlTextWriter * pWriter) const;
 
+    /// Get the height of all rows in this table.
+    std::vector<sal_Int32> getRowHeights();
+
     // ICellRange
     virtual sal_Int32 getLeft() override;
     virtual sal_Int32 getTop() override;
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 00a2e44e428b..0db55b20b8cd 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -25,6 +25,7 @@
 #include <svx/svdview.hxx>
 #include <svx/svdpagv.hxx>
 #include <svx/svdpage.hxx>
+#include <svx/svdotable.hxx>
 #include "svddrgm1.hxx"
 
 #ifdef DBG_UTIL
@@ -44,6 +45,7 @@
 #include <svx/svdovirt.hxx>
 #include <sdr/overlay/overlayrollingrectangle.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/sdr/table/tablecontroller.hxx>
 #include <svx/sdrpaintwindow.hxx>
 #include <svx/sdrpagewindow.hxx>
 #include <svx/sdrhittesthelper.hxx>
@@ -758,7 +760,7 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
     Point aGridOff = GetGridOffset();
 
     SfxViewShell* pViewShell = GetSfxViewShell();
-
+    bool bIsInTextEditMode = false;
     // check if text edit or ole is active and handles need to be suppressed. This may be the case
     // when a single object is selected
     // Using a strict return statement is okay here; no handles means *no* handles.
@@ -774,18 +776,12 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
         {
             const SdrTextObj* pSdrTextObj = dynamic_cast< const SdrTextObj* >(mpMarkedObj);
 
-            if(pSdrTextObj && pSdrTextObj->IsInEditMode())
+            if (pSdrTextObj && pSdrTextObj->IsInEditMode())
             {
                 if (bTiledRendering)
-                {
-                    // Suppress handles -> empty graphic selection.
-                    if (pViewShell)
-                    {
-                        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
-                        SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
-                    }
-                }
-                return;
+                    bIsInTextEditMode = true;
+                else
+                    return;
             }
         }
 
@@ -798,21 +794,6 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
             SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "INPLACE");
             return;
         }
-
-        if (bTiledRendering && mpMarkedObj->GetObjIdentifier() == OBJ_TABLE)
-        {
-            rtl::Reference<sdr::SelectionController> xController = static_cast<SdrView*>(this)->getSelectionController();
-            if (xController.is() && xController->hasSelectedCells())
-            {
-                // The table shape has selected cells, which provide text selection already -> no graphic selection.
-                if (pViewShell)
-                {
-                    pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
-                    SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
-                }
-                return;
-            }
-        }
     }
 
     tools::Rectangle aRect(GetMarkedObjRect());
@@ -860,7 +841,22 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
 
         {
             OString sSelectionText;
+            boost::property_tree::ptree aTableJsonTree;
+            bool bTableSelection = false;
+            bool bCellsAreSelected = false;
+
+            if (mpMarkedObj && mpMarkedObj->GetObjIdentifier() == OBJ_TABLE)
+            {
+                auto* pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(mpMarkedObj);
+                bTableSelection = pTableObject->createTableEdgesJson(aTableJsonTree);
 
+                rtl::Reference<sdr::SelectionController> xController = static_cast<SdrView*>(this)->getSelectionController();
+                if (xController.is() && xController->hasSelectedCells())
+                {
+                    // The table shape has selected cells, which provide text selection already -> no graphic selection.
+                    bCellsAreSelected = true;
+                }
+            }
             if (GetMarkedObjectCount())
             {
                 SdrMark* pM = GetSdrMarkByIndex(0);
@@ -1017,9 +1013,27 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
                 }
             }
 
-            if (sSelectionText.isEmpty())
+            if (sSelectionText.isEmpty() || bCellsAreSelected || bIsInTextEditMode)
                 sSelectionText = "EMPTY";
 
+            if (bTableSelection)
+            {
+                boost::property_tree::ptree aTableRectangle;
+                aTableRectangle.put("x", aSelection.Left());
+                aTableRectangle.put("y", aSelection.Top());
+                aTableRectangle.put("width", aSelection.GetWidth());
+                aTableRectangle.put("height", aSelection.GetHeight());
+                aTableJsonTree.push_back(std::make_pair("rectangle", aTableRectangle));
+
+                std::stringstream aStream;
+                boost::property_tree::write_json(aStream, aTableJsonTree);
+                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, aStream.str().c_str());
+            }
+            else
+            {
+                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TABLE_SELECTED, "{}");
+            }
+
             if (pOtherShell)
             {
                 // An other shell wants to know about our existing
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 441b4a01fbbb..17812d1e0b52 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1484,6 +1484,16 @@ sal_Int32 SdrTableObj::getColumnCount() const
     return mpImpl.is() ? mpImpl->getColumnCount() : 0;
 }
 
+sal_Int32 SdrTableObj::getRowCount() const
+{
+    return mpImpl.is() ? mpImpl->getRowCount() : 0;
+}
+
+void SdrTableObj::changeEdge(bool bHorizontal, int nEdge, sal_Int32 nOffset)
+{
+    if (mpImpl.is())
+        mpImpl->DragEdge(bHorizontal, nEdge, nOffset);
+}
 
 void SdrTableObj::setActiveCell( const CellPos& rPos )
 {
@@ -2008,41 +2018,29 @@ void SdrTableObj::AddToHdlList(SdrHdlList& rHdlList) const
     const sal_Int32 nColCount = mpImpl->getColumnCount();
 
     // first add row handles
-    std::vector< TableEdgeHdl* > aRowEdges( nRowCount + 1 );
-
-    for( sal_Int32 nRow = 0; nRow <= nRowCount; nRow++ )
+    std::vector<TableEdgeHdl*> aRowEdges(nRowCount + 1);
+    for (auto const & rEdge : mpImpl->mpLayouter->getHorizontalEdges())
     {
-        sal_Int32 nEdgeMin, nEdgeMax;
-        const sal_Int32 nEdge = mpImpl->mpLayouter->getHorizontalEdge( nRow, &nEdgeMin, &nEdgeMax );
-        nEdgeMin -= nEdge;
-        nEdgeMax -= nEdge;
-
-        Point aPoint( maRect.TopLeft() );
-        aPoint.Y() += nEdge;
+        Point aPoint(maRect.TopLeft());
+        aPoint.Y() += rEdge.nPosition;
 
-        TableEdgeHdl* pHdl= new TableEdgeHdl(aPoint,true,nEdgeMin,nEdgeMax,nColCount+1);
-        pHdl->SetPointNum( nRow );
-        rHdlList.AddHdl( pHdl );
-        aRowEdges[nRow] = pHdl;
+        TableEdgeHdl* pHdl= new TableEdgeHdl(aPoint,true,rEdge.nMin,rEdge.nMax,nColCount+1);
+        pHdl->SetPointNum(rEdge.nIndex);
+        rHdlList.AddHdl(pHdl);
+        aRowEdges[rEdge.nIndex] = pHdl;
     }
 
     // second add column handles
-    std::vector< TableEdgeHdl* > aColEdges( nColCount + 1 );
-
-    for( sal_Int32 nCol = 0; nCol <= nColCount; nCol++ )
+    std::vector<TableEdgeHdl*> aColEdges(nColCount + 1);
+    for (auto const & rEdge : mpImpl->mpLayouter->getVerticalEdges())
     {
-        sal_Int32 nEdgeMin, nEdgeMax;
-        const sal_Int32 nEdge = mpImpl->mpLayouter->getVerticalEdge( nCol, &nEdgeMin, &nEdgeMax );
-        nEdgeMin -= nEdge;
-        nEdgeMax -= nEdge;
+        Point aPoint(maRect.TopLeft());
+        aPoint.X() += rEdge.nPosition;
 
-        Point aPoint( maRect.TopLeft() );
-        aPoint.X() += nEdge;
-
-        TableEdgeHdl* pHdl = new TableEdgeHdl(aPoint,false,nEdgeMin,nEdgeMax, nRowCount+1);
-        pHdl->SetPointNum( nCol );
-        rHdlList.AddHdl( pHdl );
-        aColEdges[nCol] = pHdl;
+        TableEdgeHdl* pHdl = new TableEdgeHdl(aPoint,false,rEdge.nMin,rEdge.nMax, nRowCount+1);
+        pHdl->SetPointNum(rEdge.nIndex);
+        rHdlList.AddHdl(pHdl);
+        aColEdges[rEdge.nIndex] = pHdl;
     }
 
     // now add visible edges to row and column handles
@@ -2456,6 +2454,74 @@ void SdrTableObj::dumpAsXml(xmlTextWriterPtr pWriter) const
     xmlTextWriterEndElement(pWriter);
 }
 
+bool SdrTableObj::createTableEdgesJson(boost::property_tree::ptree & rJsonRoot)
+{
+    if (!mpImpl.is() || !mpImpl->mxTable.is())
+        return false;
+
+    tools::Rectangle aRect = GetCurrentBoundRect();
+    boost::property_tree::ptree aTableColumns;
+    {
+        aTableColumns.put("tableOffset", convertMm100ToTwip(aRect.Left()));
+
+        boost::property_tree::ptree aEntries;
+        auto const & aEdges = mpImpl->mpLayouter->getVerticalEdges();
+        for (auto & rEdge : aEdges)
+        {
+            if (rEdge.nIndex == 0)
+            {
+                aTableColumns.put("left", convertMm100ToTwip(rEdge.nPosition));
+            }
+            else if (rEdge.nIndex == sal_Int32(aEdges.size() - 1))
+            {
+                aTableColumns.put("right", convertMm100ToTwip(rEdge.nPosition));
+            }
+            else
+            {
+                boost::property_tree::ptree aEntry;
+                aEntry.put("position", convertMm100ToTwip(rEdge.nPosition));
+                aEntry.put("min", convertMm100ToTwip(rEdge.nPosition + rEdge.nMin));
+                aEntry.put("max", convertMm100ToTwip(rEdge.nPosition + rEdge.nMax));
+                aEntry.put("hidden", false);
+                aEntries.push_back(std::make_pair("", aEntry));
+            }
+        }
+        aTableColumns.push_back(std::make_pair("entries", aEntries));
+    }
+    rJsonRoot.add_child("columns", aTableColumns);
+
+    boost::property_tree::ptree aTableRows;
+    {
+        aTableRows.put("tableOffset", convertMm100ToTwip(aRect.Top()));
+
+        boost::property_tree::ptree aEntries;
+        auto const & aEdges = mpImpl->mpLayouter->getHorizontalEdges();
+        for (auto & rEdge : aEdges)
+        {
+            if (rEdge.nIndex == 0)
+            {
+                aTableRows.put("left", convertMm100ToTwip(rEdge.nPosition));
+            }
+            else if (rEdge.nIndex == sal_Int32(aEdges.size() - 1))
+            {
+                aTableRows.put("right", convertMm100ToTwip(rEdge.nPosition));
+            }
+            else
+            {
+                boost::property_tree::ptree aEntry;
+                aEntry.put("position", convertMm100ToTwip(rEdge.nPosition));
+                aEntry.put("min", convertMm100ToTwip(rEdge.nPosition + rEdge.nMin));
+                aEntry.put("max", convertMm100ToTwip(rEdge.nPosition + rEdge.nMax));
+                aEntry.put("hidden", false);
+                aEntries.push_back(std::make_pair("", aEntry));
+            }
+        }
+        aTableRows.push_back(std::make_pair("entries", aEntries));
+    }
+    rJsonRoot.add_child("rows", aTableRows);
+    return true;
+}
+
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index cb7cdc67528f..bd77eb18e360 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -72,6 +72,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <comphelper/lok.hxx>
 #include <sfx2/viewsh.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <editeng/editview.hxx>
 
 using ::editeng::SvxBorderLine;
@@ -1028,6 +1029,9 @@ void SvxTableController::Execute( SfxRequest& rReq )
     case SID_TABLE_STYLE_SETTINGS:
         SetTableStyleSettings( rReq.GetArgs() );
         break;
+    case SID_TABLE_CHANGE_CURRENT_BORDER_POSITION:
+        changeTableEdge(rReq);
+        break;
     }
 }
 
@@ -1437,6 +1441,72 @@ bool SvxTableController::SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRe
     return false;
 }
 
+void SvxTableController::changeTableEdge(const SfxRequest& rReq)
+{
+    if (!checkTableObject())
+        return;
+
+    const auto* pType = rReq.GetArg<SfxStringItem>(SID_TABLE_BORDER_TYPE);
+    const auto* pIndex = rReq.GetArg<SfxUInt16Item>(SID_TABLE_BORDER_INDEX);
+    const auto* pOffset = rReq.GetArg<SfxInt32Item>(SID_TABLE_BORDER_OFFSET);
+
+    if (pType && pIndex && pOffset)
+    {
+        const OUString sType = pType->GetValue();
+        const sal_uInt16 nIndex = pIndex->GetValue();
+        const sal_Int32 nOffset = convertTwipToMm100(pOffset->GetValue());
+
+        SdrTableObj* pTableObj = dynamic_cast<SdrTableObj*>(mxTableObj.get());
+        if (pTableObj)
+            return;
+
+        sal_Int32 nEdgeIndex = -1;
+        bool bHorizontal = sType.startsWith("row");
+
+        if (sType == "column-left" || sType == "row-left")
+        {
+            nEdgeIndex = 0;
+        }
+        else if (sType == "column-right")
+        {
+            // Number of edges = number of columns + 1
+            nEdgeIndex = pTableObj->getColumnCount();
+        }
+        else if (sType == "row-right")
+        {
+            // Number of edges = number of rows + 1
+            nEdgeIndex = pTableObj->getRowCount();
+        }
+        else if (sType == "column-middle" || sType == "row-middle")
+        {
+            nEdgeIndex = nIndex + 1;
+        }
+
+        if (nEdgeIndex >= 0)
+        {
+            TableModelNotifyGuard aGuard(mxTable.get());
+            const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+            if (bUndo)
+            {
+                auto* pUndoObject = mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj);
+                mpModel->BegUndo(pUndoObject->GetComment());
+                mpModel->AddUndo(pUndoObject);
+
+                auto* pGeoUndo = static_cast<SdrUndoGeoObj*>(pUndoObject);
+                if (pGeoUndo)
+                    pGeoUndo->SetSkipChangeLayout(true);
+            }
+            tools::Rectangle aBoundRect;
+            if (pTableObj->GetUserCall())
+                aBoundRect = pTableObj->GetLastBoundRect();
+            pTableObj->changeEdge(bHorizontal, nEdgeIndex, nOffset);
+            pTableObj->SetChanged();
+            pTableObj->SendUserCall(SdrUserCallType::Resize, aBoundRect);
+            if (bUndo)
+                mpModel->EndUndo();
+        }
+    }
+}
 
 // internals
 
@@ -2178,6 +2248,9 @@ void SvxTableController::updateSelectionOverlay()
                 {
                     pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, aSelection.toString().getStr());
                     pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aSelection.toString().getStr());
+                    OString sSelection("EMPTY");
+                    pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr());
+                    SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
                 }
             }
         }
@@ -2197,6 +2270,7 @@ void SvxTableController::destroySelectionOverlay()
             // Clear the LOK text selection so far provided by this table.
             if(SfxViewShell* pViewShell = SfxViewShell::Current())
             {
+                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, "EMPTY");
                 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_START, "EMPTY");
                 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION_END, "EMPTY");
                 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "EMPTY");
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 2b150e365456..131e736d80d0 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -214,6 +214,37 @@ SvxBorderLine* TableLayouter::getBorderLine( sal_Int32 nEdgeX, sal_Int32 nEdgeY,
     return pLine;
 }
 
+std::vector<EdgeInfo> TableLayouter::getHorizontalEdges()
+{
+    std::vector<EdgeInfo> aReturn;
+    sal_Int32 nRowSize = sal_Int32(maRows.size());
+    for (sal_Int32 i = 0; i <= nRowSize; i++)
+    {
+        sal_Int32 nEdgeMin = 0;
+        sal_Int32 nEdgeMax = 0;
+        sal_Int32 nEdge = getHorizontalEdge(i, &nEdgeMin, &nEdgeMax);
+        nEdgeMin -= nEdge;
+        nEdgeMax -= nEdge;
+        aReturn.emplace_back(i, nEdge, nEdgeMin, nEdgeMax);
+    }
+    return aReturn;
+}
+
+std::vector<EdgeInfo> TableLayouter::getVerticalEdges()
+{
+    std::vector<EdgeInfo> aReturn;
+    sal_Int32 nColumnSize = sal_Int32(maColumns.size());
+    for (sal_Int32 i = 0; i <= nColumnSize; i++)
+    {
+        sal_Int32 nEdgeMin = 0;
+        sal_Int32 nEdgeMax = 0;
+        sal_Int32 nEdge = getVerticalEdge(i, &nEdgeMin, &nEdgeMax);
+        nEdgeMin -= nEdge;
+        nEdgeMax -= nEdge;
+        aReturn.emplace_back(i, nEdge, nEdgeMin, nEdgeMax);
+    }
+    return aReturn;
+}
 
 sal_Int32 TableLayouter::getHorizontalEdge( int nEdgeY, sal_Int32* pnMin /*= 0*/, sal_Int32* pnMax /*= 0*/ )
 {
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index c5f1ca99c367..78ea756a82dc 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -51,6 +51,20 @@ typedef std::vector< BorderLineVector > BorderLineMap;
 
 // TableModel
 
+struct EdgeInfo final
+{
+    sal_Int32 nIndex;
+    sal_Int32 nPosition;
+    sal_Int32 nMin;
+    sal_Int32 nMax;
+
+    EdgeInfo(sal_Int32 nInIndex, sal_Int32 nInPosition, sal_Int32 nInMin, sal_Int32 nInMax)
+        : nIndex(nInIndex)
+        , nPosition(nInPosition)
+        , nMin(nInMin)
+        , nMax(nInMax)
+    {}
+};
 
 class TableLayouter final
 {
@@ -91,7 +105,10 @@ public:
 
     void updateCells( ::tools::Rectangle& rRectangle );
 
+    std::vector<EdgeInfo> getHorizontalEdges();
     sal_Int32 getHorizontalEdge( int nEdgeY, sal_Int32* pnMin, sal_Int32* pnMax );
+
+    std::vector<EdgeInfo> getVerticalEdges();
     sal_Int32 getVerticalEdge( int nEdgeX , sal_Int32* pnMin, sal_Int32* pnMax);
 
     void DistributeColumns( ::tools::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index 2f8c94dc4636..040b42405ecd 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -317,6 +317,14 @@ sal_Int32 SAL_CALL TableModel::getRowCount()
     return getRowCountImpl();
 }
 
+std::vector<sal_Int32> TableModel::getRowHeights()
+{
+    std::vector<sal_Int32> aRet;
+    for (const TableRowRef& xRow : maRows)
+        aRet.push_back(xRow->getHeight());
+    return aRet;
+}
+
 
 sal_Int32 SAL_CALL TableModel::getColumnCount()
 {
diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx
index 43010ad698fe..ece7945b342c 100644
--- a/svx/source/table/tablerow.cxx
+++ b/svx/source/table/tablerow.cxx
@@ -155,6 +155,11 @@ const TableModelRef& TableRow::getModel() const
     return mxTableModel;
 }
 
+sal_Int32 TableRow::getHeight() const
+{
+    return mnHeight;
+}
+
 // XCellRange
 
 
diff --git a/svx/source/table/tablerow.hxx b/svx/source/table/tablerow.hxx
index 5c14452831b1..c45957962208 100644
--- a/svx/source/table/tablerow.hxx
+++ b/svx/source/table/tablerow.hxx
@@ -50,6 +50,8 @@ public:
     void removeColumns( sal_Int32 nIndex, sal_Int32 nCount );
     /// Reference to the table model containing this row.
     const TableModelRef& getModel() const;
+    /// Get the height of this row.
+    sal_Int32 getHeight() const;
 
     // XCellRange
     virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override;


More information about the Libreoffice-commits mailing list