Blame SOURCES/0313-sw-lok-filter-out-defalt-styles-to-avoid-duplicates.patch

135360
From 389a3ba2f6855d22e4802381e6f23d48c9c515bc Mon Sep 17 00:00:00 2001
135360
From: Andrzej Hunt <andrzej@ahunt.org>
135360
Date: Thu, 12 Nov 2015 14:48:55 +0100
135360
Subject: [PATCH 313/398] sw lok: filter out defalt styles to avoid duplicates
135360
135360
Change-Id: Iff84c2f16844a507d30f30c1fd4b23d807ded466
135360
(cherry picked from commit 0b3fbf8299c51767689b4e7656bbf4c331450b98)
135360
---
135360
 desktop/source/lib/init.cxx | 18 ++++++++++++++----
135360
 1 file changed, 14 insertions(+), 4 deletions(-)
135360
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index a51e44591847..1d56f2e8abae 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -1263,7 +1263,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
135360
         "Heading 3"
135360
     };
135360
 
135360
-    // static const std::vector<OUString> aList = { "aaaa", "bbb" };
135360
+    // We need to keep a list of the default style names
135360
+    // in order to filter these out later when processing
135360
+    // the full list of styles.
135360
+    std::set<OUString> aDefaultStyleNames;
135360
 
135360
     boost::property_tree::ptree aValues;
135360
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
135360
@@ -1286,6 +1289,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
135360
                 xStyle->getPropertyValue("DisplayName") >>= sName;
135360
                 if( !sName.isEmpty() )
135360
                 {
135360
+                    aDefaultStyleNames.insert( sName );
135360
+
135360
                     boost::property_tree::ptree aChild;
135360
                     aChild.put("", sName.toUtf8());
135360
                     aChildren.push_back(std::make_pair("", aChild));
135360
@@ -1296,9 +1301,14 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
135360
         uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
135360
         for ( OUString aStyle: aStyles )
135360
         {
135360
-            boost::property_tree::ptree aChild;
135360
-            aChild.put("", aStyles[nInd]);
135360
-            aChildren.push_back(std::make_pair("", aChild));
135360
+            // Filter out the default styles - they are already at the top
135360
+            // of the list
135360
+            if (aDefaultStyleNames.find(aStyle) == aDefaultStyleNames.end())
135360
+            {
135360
+                boost::property_tree::ptree aChild;
135360
+                aChild.put("", aStyle);
135360
+                aChildren.push_back(std::make_pair("", aChild));
135360
+            }
135360
         }
135360
         aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
135360
     }
135360
-- 
135360
2.12.0
135360