From 389a3ba2f6855d22e4802381e6f23d48c9c515bc Mon Sep 17 00:00:00 2001 From: Andrzej Hunt Date: Thu, 12 Nov 2015 14:48:55 +0100 Subject: [PATCH 313/398] sw lok: filter out defalt styles to avoid duplicates Change-Id: Iff84c2f16844a507d30f30c1fd4b23d807ded466 (cherry picked from commit 0b3fbf8299c51767689b4e7656bbf4c331450b98) --- desktop/source/lib/init.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a51e44591847..1d56f2e8abae 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1263,7 +1263,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) "Heading 3" }; - // static const std::vector 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 aDefaultStyleNames; boost::property_tree::ptree aValues; for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam) @@ -1286,6 +1289,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)); @@ -1296,9 +1301,14 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) uno::Sequence 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); } -- 2.12.0