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

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