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