diff options
author | Pranav Kant <pranavk@collabora.com> | 2016-02-14 02:08:20 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-02-15 07:47:30 +0000 |
commit | b0111f494c1ee2d75ac4f1544c06c24d464cc416 (patch) | |
tree | 375a9be9feff0e270bd9d8eb9a2d619bc8acefc6 /desktop | |
parent | 53bf3ea58e0f4f9f4399a44bfc9ddecc71cb54c7 (diff) |
lok: Expose DisplayName of styles, not internal ones
Change-Id: I2119713600703e3aa18f673979c7cd84c38177d7
Reviewed-on: https://gerrit.libreoffice.org/22349
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b24fbbcdaaab..f73a97658bfc 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1375,9 +1375,28 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); for (const OUString& rStyle: aStyles ) { - // Filter out the default styles - they are already at the top - // of the list - if (aDefaultStyleNames.find(rStyle) == aDefaultStyleNames.end()) + uno::Reference< beans::XPropertySet > xStyle (xStyleFamily->getByName(rStyle), uno::UNO_QUERY); + bool bStyleInserted = false; + // Its possible that the style does not implement XPropertySet. + // For example, TableDesignFamily doesn't yet. + if (xStyle.is()) + { + // Filter out the default styles - they are already at the top + // of the list + OUString sName; + xStyle->getPropertyValue("DisplayName") >>= sName; + if (!sName.isEmpty() && aDefaultStyleNames.find(sName) == aDefaultStyleNames.end()) + { + boost::property_tree::ptree aChild; + aChild.put("", sName.toUtf8()); + aChildren.push_back(std::make_pair("", aChild)); + bStyleInserted = true; + } + } + + // If XPropertySet is not implemented or DisplayName is empty string, + // fallback to LO internal names + if (!bStyleInserted) { boost::property_tree::ptree aChild; aChild.put("", rStyle); |