summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMihai Varga <mihai.varga@collabora.com>2015-08-17 18:49:40 +0300
committerMihai Varga <mihai.varga@collabora.com>2015-08-18 13:04:35 +0300
commitc5a516bd1bf0216ee39f31322369f6bffdf464eb (patch)
treeb4641152ef602ac4f03a17062aec4a9c91c928b1 /desktop
parent0405975042e91e5cca56068ad0d16ad8ab910737 (diff)
lok::Document getStyles method
This method returns a JSON mapping of style families to a list of styles from the corresponding family. Will be used to know and apply styles in tiledrendering. Change-Id: I0aa395c40b9573920ade44255f97c077475ae5f1
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index abd8ca0b640b..51302d1f8466 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -35,11 +35,13 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
@@ -233,6 +235,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
int nX,
int nY);
static void doc_resetSelection (LibreOfficeKitDocument* pThis);
+static char* doc_getStyles(LibreOfficeKitDocument* pThis);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -267,6 +270,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->getTextSelection = doc_getTextSelection;
m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
m_pDocumentClass->resetSelection = doc_resetSelection;
+ m_pDocumentClass->getStyles = doc_getStyles;
gDocumentClass = m_pDocumentClass;
}
@@ -864,6 +868,36 @@ static void doc_resetSelection(LibreOfficeKitDocument* pThis)
pDoc->resetSelection();
}
+static char* doc_getStyles(LibreOfficeKitDocument* pThis)
+{
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ boost::property_tree::ptree aTree;
+ uno::Reference<css::style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(pDocument->mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+ uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames();
+
+ for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
+ {
+ boost::property_tree::ptree aChildren;
+ OUString sStyleFam = aStyleFamilies[nStyleFam];
+ uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(sStyleFam), uno::UNO_QUERY);
+ uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
+ for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd)
+ {
+ boost::property_tree::ptree aChild;
+ aChild.put("", aStyles[nInd]);
+ aChildren.push_back(std::make_pair("", aChild));
+ }
+ aTree.add_child(sStyleFam.toUtf8().getStr(), aChildren);
+ }
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
+ strcpy(pJson, aStream.str().c_str());
+ pJson[aStream.str().size()] = '\0';
+ return pJson;
+}
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);