Blame SOURCES/0102-Revert-LOK-added-a-general-getCommandValues-method.patch

f325b2
From fb4862718de305e2c806b68666106371fccea4f1 Mon Sep 17 00:00:00 2001
f325b2
From: Mihai Varga <mihai.varga@collabora.com>
f325b2
Date: Fri, 4 Sep 2015 15:45:51 +0300
f325b2
Subject: [PATCH 102/398] Revert "LOK: added a general getCommandValues method"
f325b2
f325b2
This reverts commit 9640dcea46dd3201aa4c27f6a3918f7419288a2a.
f325b2
f325b2
(cherry picked from commit 262e7be01461887202f629d1ccc57751b1a085c5)
f325b2
---
f325b2
 desktop/source/lib/init.cxx               | 24 ++++--------------------
f325b2
 include/LibreOfficeKit/LibreOfficeKit.h   |  2 +-
f325b2
 include/LibreOfficeKit/LibreOfficeKit.hxx |  9 +++------
f325b2
 libreofficekit/qa/unit/tiledrendering.cxx |  8 ++------
f325b2
 4 files changed, 10 insertions(+), 33 deletions(-)
f325b2
f325b2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
f325b2
index f15417c92d0b..c7f3aabb58b7 100644
f325b2
--- a/desktop/source/lib/init.cxx
f325b2
+++ b/desktop/source/lib/init.cxx
f325b2
@@ -235,7 +235,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
f325b2
                                   int nX,
f325b2
                                   int nY);
f325b2
 static void doc_resetSelection (LibreOfficeKitDocument* pThis);
f325b2
-static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
f325b2
+static char* doc_getStyles(LibreOfficeKitDocument* pThis);
f325b2
 
f325b2
 struct LibLODocument_Impl : public _LibreOfficeKitDocument
f325b2
 {
f325b2
@@ -270,7 +270,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
f325b2
             m_pDocumentClass->getTextSelection = doc_getTextSelection;
f325b2
             m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
f325b2
             m_pDocumentClass->resetSelection = doc_resetSelection;
f325b2
-            m_pDocumentClass->getCommandValues = doc_getCommandValues;
f325b2
+            m_pDocumentClass->getStyles = doc_getStyles;
f325b2
 
f325b2
             gDocumentClass = m_pDocumentClass;
f325b2
         }
f325b2
@@ -870,17 +870,15 @@ static void doc_resetSelection(LibreOfficeKitDocument* pThis)
f325b2
     pDoc->resetSelection();
f325b2
 }
f325b2
 
f325b2
-static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
f325b2
+static char* doc_getStyles(LibreOfficeKitDocument* pThis)
f325b2
 {
f325b2
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
f325b2
 
f325b2
     boost::property_tree::ptree aTree;
f325b2
-    aTree.put("commandName", pCommand);
f325b2
     uno::Reference<css::style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(pDocument->mxComponent, uno::UNO_QUERY);
f325b2
     uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
f325b2
     uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames();
f325b2
 
f325b2
-    boost::property_tree::ptree aValues;
f325b2
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
f325b2
     {
f325b2
         boost::property_tree::ptree aChildren;
f325b2
@@ -893,9 +891,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
f325b2
             aChild.put("", aStyles[nInd]);
f325b2
             aChildren.push_back(std::make_pair("", aChild));
f325b2
         }
f325b2
-        aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
f325b2
+        aTree.add_child(sStyleFam.toUtf8().getStr(), aChildren);
f325b2
     }
f325b2
-    aTree.add_child("commandValues", aValues);
f325b2
     std::stringstream aStream;
f325b2
     boost::property_tree::write_json(aStream, aTree);
f325b2
     char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
f325b2
@@ -903,19 +900,6 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
f325b2
     pJson[aStream.str().size()] = '\0';
f325b2
     return pJson;
f325b2
 }
f325b2
-
f325b2
-static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand)
f325b2
-{
f325b2
-    if (!strcmp(pCommand, ".uno:StyleApply"))
f325b2
-    {
f325b2
-        return getStyles(pThis, pCommand);
f325b2
-    }
f325b2
-    else {
f325b2
-        gImpl->maLastExceptionMsg = "Unknown command, no values returned";
f325b2
-        return NULL;
f325b2
-    }
f325b2
-}
f325b2
-
f325b2
 static char* lo_getError (LibreOfficeKit *pThis)
f325b2
 {
f325b2
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
index 8060f0e6ec7c..af7155c4db67 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
f325b2
@@ -161,7 +161,7 @@ struct _LibreOfficeKitDocumentClass
f325b2
     void (*resetSelection) (LibreOfficeKitDocument* pThis);
f325b2
 
f325b2
     /// @see lok::Document:getStyles
f325b2
-    char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
f325b2
+    char* (*getStyles) (LibreOfficeKitDocument* pThis);
f325b2
 #endif // LOK_USE_UNSTABLE_API
f325b2
 };
f325b2
 
f325b2
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
index 44599948e659..c526bda95593 100644
f325b2
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
f325b2
@@ -248,14 +248,11 @@ public:
f325b2
     }
f325b2
 
f325b2
     /**
f325b2
-     * Returns a json mapping of the possible values for the given command
f325b2
-     * e.g. {commandName: ".uno:StyleApply", commandValues: {"familyName1" : ["list of style names in the family1"], etc.}}
f325b2
-     * @param pCommand a uno command for which the possible values are requested
f325b2
-     * @return {commandName: unoCmd, commandValues: {possible_values}}
f325b2
+     * Returns a json map, {"familyName1" : ["list of style names in the family1"], etc.}
f325b2
      */
f325b2
-    inline char* getCommandValues(const char* pCommand)
f325b2
+    inline char* getStyles()
f325b2
     {
f325b2
-        return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
f325b2
+        return mpDoc->pClass->getStyles(mpDoc);
f325b2
     }
f325b2
 #endif // LOK_USE_UNSTABLE_API
f325b2
 };
f325b2
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
f325b2
index f4a721b3e164..a0f4bcb5b8eb 100644
f325b2
--- a/libreofficekit/qa/unit/tiledrendering.cxx
f325b2
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
f325b2
@@ -195,16 +195,12 @@ void TiledRenderingTest::testGetStyles( Office* pOffice )
f325b2
     scoped_ptr< Document> pDocument( pOffice->documentLoad( sDocPath.c_str() ) );
f325b2
 
f325b2
     boost::property_tree::ptree aTree;
f325b2
-    char* pJSON = pDocument->getCommandValues(".uno:StyleApply");
f325b2
+    char* pJSON = pDocument->getStyles();
f325b2
     std::stringstream aStream(pJSON);
f325b2
     boost::property_tree::read_json(aStream, aTree);
f325b2
     CPPUNIT_ASSERT( aTree.size() > 0 );
f325b2
-    CPPUNIT_ASSERT( aTree.get_value<std::string>("commandName") == ".uno:StyleApply" );
f325b2
 
f325b2
-
f325b2
-    boost::property_tree::ptree aValues = aTree.get_child("commandValues");
f325b2
-    CPPUNIT_ASSERT( aValues.size() > 0 );
f325b2
-    for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aValues)
f325b2
+    for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
f325b2
     {
f325b2
         CPPUNIT_ASSERT( rPair.second.size() > 0);
f325b2
         if (rPair.first != "CharacterStyles" &&
f325b2
-- 
f325b2
2.12.0
f325b2