Blame SOURCES/0243-LOK-initial-Document-getCommandValues-for-RowColumnH.patch

135360
From 406b705cba1093c06770a2f09da6dd95a0c2bf3c Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Fri, 30 Oct 2015 11:18:19 +0100
135360
Subject: [PATCH 243/398] LOK: initial Document::getCommandValues() for
135360
 RowColumnHeaders
135360
135360
Only the row info and for the entire tiled rendering area as a start.
135360
135360
Change-Id: Idbccd805b355e8d151ab7025ac1cf0c686cb237b
135360
(cherry picked from commit a7ce5f83343f8f6ba8a59b05820b3a2066c0ce9a)
135360
---
135360
 desktop/source/lib/init.cxx      | 18 +++++++++++++++++-
135360
 include/vcl/ITiledRenderable.hxx |  8 ++++++++
135360
 sc/inc/docuno.hxx                |  3 +++
135360
 sc/source/ui/inc/tabview.hxx     |  2 ++
135360
 sc/source/ui/unoobj/docuno.cxx   | 13 +++++++++++++
135360
 sc/source/ui/view/tabview.cxx    | 29 +++++++++++++++++++++++++++++
135360
 6 files changed, 72 insertions(+), 1 deletion(-)
135360
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index 9dacde8b0287..6785ae2328d4 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -1134,7 +1134,23 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
135360
     {
135360
         return getStyles(pThis, pCommand);
135360
     }
135360
-    else {
135360
+    else if (OString(pCommand) == ".uno:ViewRowColumnHeaders")
135360
+    {
135360
+        ITiledRenderable* pDoc = getTiledRenderable(pThis);
135360
+        if (!pDoc)
135360
+        {
135360
+            gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
135360
+            return 0;
135360
+        }
135360
+
135360
+        OUString aHeaders = pDoc->getRowColumnHeaders();
135360
+        OString aString = OUStringToOString(aHeaders, RTL_TEXTENCODING_UTF8);
135360
+        char* pMemory = static_cast<char*>(malloc(aString.getLength() + 1));
135360
+        strcpy(pMemory, aString.getStr());
135360
+        return pMemory;
135360
+    }
135360
+    else
135360
+    {
135360
         gImpl->maLastExceptionMsg = "Unknown command, no values returned";
135360
         return NULL;
135360
     }
135360
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
135360
index 8ae719edf752..48a13ffc1275 100644
135360
--- a/include/vcl/ITiledRenderable.hxx
135360
+++ b/include/vcl/ITiledRenderable.hxx
135360
@@ -148,6 +148,14 @@ public:
135360
         return OUString();
135360
     }
135360
 
135360
+    /**
135360
+     * Get position and content of row/column headers of Calc documents.
135360
+     */
135360
+    virtual OUString getRowColumnHeaders()
135360
+    {
135360
+        return OUString();
135360
+    }
135360
+
135360
     /// Sets the clipboard of the component.
135360
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0;
135360
 
135360
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
135360
index a8595b00c36e..b4711c54c883 100644
135360
--- a/sc/inc/docuno.hxx
135360
+++ b/sc/inc/docuno.hxx
135360
@@ -421,6 +421,9 @@ public:
135360
 
135360
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
135360
     virtual bool isMimeTypeSupported() override;
135360
+
135360
+    /// @see vcl::ITiledRenderable::getRowColumnHeaders().
135360
+    virtual OUString getRowColumnHeaders() override;
135360
 };
135360
 
135360
 class ScDrawPagesObj : public cppu::WeakImplHelper2<
135360
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
135360
index d7e2a2dbf12e..5b0852041108 100644
135360
--- a/sc/source/ui/inc/tabview.hxx
135360
+++ b/sc/source/ui/inc/tabview.hxx
135360
@@ -520,6 +520,8 @@ public:
135360
     void EnableAutoSpell( bool bEnable );
135360
     void ResetAutoSpell();
135360
     void SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges );
135360
+    /// @see ScModelObj::getRowColumnHeaders().
135360
+    OUString getRowColumnHeaders();
135360
 };
135360
 
135360
 #endif
135360
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
135360
index d58d6a900856..f9a9e03f2839 100644
135360
--- a/sc/source/ui/unoobj/docuno.cxx
135360
+++ b/sc/source/ui/unoobj/docuno.cxx
135360
@@ -870,6 +870,19 @@ bool ScModelObj::isMimeTypeSupported()
135360
     return EditEngine::HasValidData(aDataHelper.GetTransferable());
135360
 }
135360
 
135360
+OUString ScModelObj::getRowColumnHeaders()
135360
+{
135360
+    ScViewData* pViewData = ScDocShell::GetViewData();
135360
+    if (!pViewData)
135360
+        return OUString();
135360
+
135360
+    ScTabView* pTabView = pViewData->GetView();
135360
+    if (!pTabView)
135360
+        return OUString();
135360
+
135360
+    return pTabView->getRowColumnHeaders();
135360
+}
135360
+
135360
 void ScModelObj::initializeForTiledRendering()
135360
 {
135360
     SolarMutexGuard aGuard;
135360
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
135360
index b5d308be1aab..f177bbe704f1 100644
135360
--- a/sc/source/ui/view/tabview.cxx
135360
+++ b/sc/source/ui/view/tabview.cxx
135360
@@ -50,6 +50,7 @@
135360
 
135360
 #include <string>
135360
 #include <algorithm>
135360
+#include <boost/property_tree/json_parser.hpp>
135360
 
135360
 #include <basegfx/tools/zoomtools.hxx>
135360
 
135360
@@ -2302,4 +2303,32 @@ void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector
135360
     }
135360
 }
135360
 
135360
+OUString ScTabView::getRowColumnHeaders()
135360
+{
135360
+    ScDocument* pDoc = aViewData.GetDocument();
135360
+    if (!pDoc)
135360
+        return OUString();
135360
+
135360
+    SCCOL nEndCol = 0;
135360
+    SCROW nEndRow = 0;
135360
+    pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
135360
+
135360
+    boost::property_tree::ptree aRows;
135360
+    for (SCROW nRow = 0; nRow < nEndRow; ++nRow)
135360
+    {
135360
+        boost::property_tree::ptree aRow;
135360
+        sal_uInt16 nSize = pRowBar[SC_SPLIT_BOTTOM]->GetEntrySize(nRow);
135360
+        aRow.put("size", OString::number(nSize).getStr());
135360
+        OUString aText = pRowBar[SC_SPLIT_BOTTOM]->GetEntryText(nRow);
135360
+        aRow.put("text", aText.toUtf8().getStr());
135360
+        aRows.push_back(std::make_pair("", aRow));
135360
+    }
135360
+
135360
+    boost::property_tree::ptree aTree;
135360
+    aTree.add_child("rows", aRows);
135360
+    std::stringstream aStream;
135360
+    boost::property_tree::write_json(aStream, aTree);
135360
+    return OUString::fromUtf8(aStream.str().c_str());
135360
+}
135360
+
135360
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
135360
-- 
135360
2.12.0
135360