[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit libreofficekit/qa

Mihai Varga mihai.varga at collabora.com
Fri Sep 4 05:47:12 PDT 2015


 desktop/source/lib/init.cxx               |   24 ++++--------------------
 include/LibreOfficeKit/LibreOfficeKit.h   |    2 +-
 include/LibreOfficeKit/LibreOfficeKit.hxx |    9 +++------
 libreofficekit/qa/unit/tiledrendering.cxx |    8 ++------
 4 files changed, 10 insertions(+), 33 deletions(-)

New commits:
commit 262e7be01461887202f629d1ccc57751b1a085c5
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Sep 4 15:45:51 2015 +0300

    Revert "LOK: added a general getCommandValues method"
    
    This reverts commit 9640dcea46dd3201aa4c27f6a3918f7419288a2a.

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f15417c..c7f3aab 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -235,7 +235,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
                                   int nX,
                                   int nY);
 static void doc_resetSelection (LibreOfficeKitDocument* pThis);
-static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
+static char* doc_getStyles(LibreOfficeKitDocument* pThis);
 
 struct LibLODocument_Impl : public _LibreOfficeKitDocument
 {
@@ -270,7 +270,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
             m_pDocumentClass->getTextSelection = doc_getTextSelection;
             m_pDocumentClass->setGraphicSelection = doc_setGraphicSelection;
             m_pDocumentClass->resetSelection = doc_resetSelection;
-            m_pDocumentClass->getCommandValues = doc_getCommandValues;
+            m_pDocumentClass->getStyles = doc_getStyles;
 
             gDocumentClass = m_pDocumentClass;
         }
@@ -870,17 +870,15 @@ static void doc_resetSelection(LibreOfficeKitDocument* pThis)
     pDoc->resetSelection();
 }
 
-static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
+static char* doc_getStyles(LibreOfficeKitDocument* pThis)
 {
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
 
     boost::property_tree::ptree aTree;
-    aTree.put("commandName", pCommand);
     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();
 
-    boost::property_tree::ptree aValues;
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
     {
         boost::property_tree::ptree aChildren;
@@ -893,9 +891,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
             aChild.put("", aStyles[nInd]);
             aChildren.push_back(std::make_pair("", aChild));
         }
-        aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
+        aTree.add_child(sStyleFam.toUtf8().getStr(), aChildren);
     }
-    aTree.add_child("commandValues", aValues);
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);
     char* pJson = static_cast<char*>(malloc(aStream.str().size() + 1));
@@ -903,19 +900,6 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
     pJson[aStream.str().size()] = '\0';
     return pJson;
 }
-
-static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand)
-{
-    if (!strcmp(pCommand, ".uno:StyleApply"))
-    {
-        return getStyles(pThis, pCommand);
-    }
-    else {
-        gImpl->maLastExceptionMsg = "Unknown command, no values returned";
-        return NULL;
-    }
-}
-
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 8060f0e..af7155c 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -161,7 +161,7 @@ struct _LibreOfficeKitDocumentClass
     void (*resetSelection) (LibreOfficeKitDocument* pThis);
 
     /// @see lok::Document:getStyles
-    char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
+    char* (*getStyles) (LibreOfficeKitDocument* pThis);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4459994..c526bda 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -248,14 +248,11 @@ public:
     }
 
     /**
-     * Returns a json mapping of the possible values for the given command
-     * e.g. {commandName: ".uno:StyleApply", commandValues: {"familyName1" : ["list of style names in the family1"], etc.}}
-     * @param pCommand a uno command for which the possible values are requested
-     * @return {commandName: unoCmd, commandValues: {possible_values}}
+     * Returns a json map, {"familyName1" : ["list of style names in the family1"], etc.}
      */
-    inline char* getCommandValues(const char* pCommand)
+    inline char* getStyles()
     {
-        return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
+        return mpDoc->pClass->getStyles(mpDoc);
     }
 #endif // LOK_USE_UNSTABLE_API
 };
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
index a2cbe6e..a4e5525 100644
--- a/libreofficekit/qa/unit/tiledrendering.cxx
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -195,16 +195,12 @@ void TiledRenderingTest::testGetStyles( Office* pOffice )
     scoped_ptr< Document> pDocument( pOffice->documentLoad( sDocPath.c_str() ) );
 
     boost::property_tree::ptree aTree;
-    char* pJSON = pDocument->getCommandValues(".uno:StyleApply");
+    char* pJSON = pDocument->getStyles();
     std::stringstream aStream(pJSON);
     boost::property_tree::read_json(aStream, aTree);
     CPPUNIT_ASSERT( aTree.size() > 0 );
-    CPPUNIT_ASSERT( aTree.get_value<std::string>("commandName") == ".uno:StyleApply" );
 
-
-    boost::property_tree::ptree aValues = aTree.get_child("commandValues");
-    CPPUNIT_ASSERT( aValues.size() > 0 );
-    for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aValues)
+    for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
     {
         CPPUNIT_ASSERT( rPair.second.size() > 0);
         if (rPair.first != "CharacterStyles" &&


More information about the Libreoffice-commits mailing list