Kaydet (Commit) 0b3fbf82 authored tarafından Andrzej Hunt's avatar Andrzej Hunt

sw lok: filter out defalt styles to avoid duplicates

Change-Id: Iff84c2f16844a507d30f30c1fd4b23d807ded466
üst 6e6ae980
...@@ -1263,7 +1263,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) ...@@ -1263,7 +1263,10 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
"Heading 3" "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; boost::property_tree::ptree aValues;
for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam) for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
...@@ -1286,6 +1289,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) ...@@ -1286,6 +1289,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
xStyle->getPropertyValue("DisplayName") >>= sName; xStyle->getPropertyValue("DisplayName") >>= sName;
if( !sName.isEmpty() ) if( !sName.isEmpty() )
{ {
aDefaultStyleNames.insert( sName );
boost::property_tree::ptree aChild; boost::property_tree::ptree aChild;
aChild.put("", sName.toUtf8()); aChild.put("", sName.toUtf8());
aChildren.push_back(std::make_pair("", aChild)); aChildren.push_back(std::make_pair("", aChild));
...@@ -1296,9 +1301,14 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) ...@@ -1296,9 +1301,14 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
for ( OUString aStyle: aStyles ) for ( OUString aStyle: aStyles )
{ {
boost::property_tree::ptree aChild; // Filter out the default styles - they are already at the top
aChild.put("", aStyles[nInd]); // of the list
aChildren.push_back(std::make_pair("", aChild)); 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); aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment