[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 4 commits - desktop/qa desktop/source

Andrzej Hunt andrzej at ahunt.org
Thu Nov 12 06:37:30 PST 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    2 -
 desktop/source/lib/init.cxx                 |   51 +++++++++++++++++++++-------
 2 files changed, 41 insertions(+), 12 deletions(-)

New commits:
commit bd4f17848f439913c048dc688322740b9e36b33f
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Nov 12 14:48:55 2015 +0100

    sw lok: filter out defalt styles to avoid duplicates
    
    Change-Id: Iff84c2f16844a507d30f30c1fd4b23d807ded466
    (cherry picked from commit 0b3fbf8299c51767689b4e7656bbf4c331450b98)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4a37c51..1ab5dc8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1272,7 +1272,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         "Heading 3"
     };
 
-    // static const std::vector<OUString> aList = { "aaaa", "bbb" };
+    // We need to keep a list of the default style names
+    // in order to filter these out later when processing
+    // the full list of styles.
+    std::set<OUString> aDefaultStyleNames;
 
     boost::property_tree::ptree aValues;
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
@@ -1295,6 +1298,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
                 xStyle->getPropertyValue("DisplayName") >>= sName;
                 if( !sName.isEmpty() )
                 {
+                    aDefaultStyleNames.insert( sName );
+
                     boost::property_tree::ptree aChild;
                     aChild.put("", sName.toUtf8());
                     aChildren.push_back(std::make_pair("", aChild));
@@ -1305,9 +1310,14 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
         for ( OUString aStyle: aStyles )
         {
-            boost::property_tree::ptree aChild;
-            aChild.put("", aStyles[nInd]);
-            aChildren.push_back(std::make_pair("", aChild));
+            // Filter out the default styles - they are already at the top
+            // of the list
+            if (aDefaultStyleNames.find(aStyle) == aDefaultStyleNames.end())
+            {
+                boost::property_tree::ptree aChild;
+                aChild.put("", aStyle);
+                aChildren.push_back(std::make_pair("", aChild));
+            }
         }
         aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
     }
commit 572ab72c98673537c032b83a78c3c297e56a3d63
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Nov 12 14:41:02 2015 +0100

    More range based for
    
    Change-Id: I9cdcd8dca413981389cd4db3059a420131e5f839
    (cherry picked from commit 6e6ae9803796b120e95f6e89575e03c5fd0ed3c2)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c977af6..4a37c51 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1303,7 +1303,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         }
 
         uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
-        for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd)
+        for ( OUString aStyle: aStyles )
         {
             boost::property_tree::ptree aChild;
             aChild.put("", aStyles[nInd]);
commit 6a44e4a4d5ae37d8237f3061ce362e7052ca6de0
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Nov 12 14:30:40 2015 +0100

    Use std::vector instead of an array of strings
    
    This makes the code much more readable / sane.
    
    Change-Id: I1d60f4102b6c619fa2fefac4a3644b7f04c0b9c0
    (cherry picked from commit d5545979fb27e317cce4d374a5a913790d8a2adf)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 14315d0..c977af6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1261,7 +1261,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
     uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
     uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames();
 
-    static const sal_Char* aWriterStyles[] =
+    static const std::vector<OUString> aWriterStyles =
     {
         "Text body",
         "Quotations",
@@ -1272,6 +1272,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         "Heading 3"
     };
 
+    // static const std::vector<OUString> aList = { "aaaa", "bbb" };
+
     boost::property_tree::ptree aValues;
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
     {
@@ -1285,10 +1287,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         if (sStyleFam == "ParagraphStyles"
             && doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
         {
-            for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
+            for( OUString aStyle: aWriterStyles )
             {
                 uno::Reference< beans::XPropertySet > xStyle;
-                xStyleFamily->getByName( OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
+                xStyleFamily->getByName( aStyle ) >>= xStyle;
                 OUString sName;
                 xStyle->getPropertyValue("DisplayName") >>= sName;
                 if( !sName.isEmpty() )
commit a747fbc7379d3e649d056ee1775bd1fa4a3e7a97
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Thu Nov 12 13:50:52 2015 +0100

    lok: send list of commands instead of ClearStyles
    
    We currently send just one command, but this could be expanded
    server side in future.
    
    Change-Id: Id8f14196158f3a7fe9c54595d094603efd5e2ce3
    (cherry picked from commit fbc3965dc117967d2b5f51aa3902823da7c69d12)

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 981e546..d6a4eb9 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -196,7 +196,7 @@ void DesktopLOKTest::testGetStyles()
             rPair.first != "NumberingStyles" &&
             rPair.first != "CellStyles" &&
             rPair.first != "ShapeStyles" &&
-            rPair.first != "ClearStyle")
+            rPair.first != "Commands")
         {
             CPPUNIT_FAIL("Unknown style family: " + rPair.first);
         }
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 20bc654..14315d0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1310,10 +1310,27 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
     }
 
-    boost::property_tree::ptree aChildClearFormat;
-    OUString sClearFormat = SVX_RESSTR( RID_SVXSTR_CLEARFORM );
-    aChildClearFormat.put("", sClearFormat.toUtf8());
-    aValues.add_child("ClearStyle", aChildClearFormat);
+    {
+        boost::property_tree::ptree aCommandList;
+
+        {
+            boost::property_tree::ptree aChild;
+
+            OUString sClearFormat = SVX_RESSTR( RID_SVXSTR_CLEARFORM );
+
+            boost::property_tree::ptree aName;
+            aName.put("", sClearFormat.toUtf8());
+            aChild.push_back(std::make_pair("text", aName));
+
+            boost::property_tree::ptree aCommand;
+            aCommand.put("", ".uno:ResetAttributes");
+            aChild.push_back(std::make_pair("id", aCommand));
+
+            aCommandList.push_back(std::make_pair("", aChild));
+        }
+
+        aValues.add_child("Commands", aCommandList);
+    }
 
     aTree.add_child("commandValues", aValues);
     std::stringstream aStream;


More information about the Libreoffice-commits mailing list