Kaydet (Commit) 533958c0 authored tarafından Andrzej Hunt's avatar Andrzej Hunt

lok sw: Place default styles at top of style selector

The order/list of default styles for Writer should be hardcoded,
(by default the list contains 100+ items), it makes most sense to
place these at the start of the list, allowing the client to then
select how many styles they actually want to show.

Change-Id: I491a426397e06b3502cee7484c5f8adfd9d9cdf2
Reviewed-on: https://gerrit.libreoffice.org/19918Reviewed-by: 's avatarAndrzej Hunt <andrzej@ahunt.org>
Tested-by: 's avatarAndrzej Hunt <andrzej@ahunt.org>
(cherry picked from commit 5c6119ee)
üst 030318a3
...@@ -1261,12 +1261,45 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) ...@@ -1261,12 +1261,45 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames(); uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames();
static const sal_Char* aWriterStyles[] =
{
"Text body",
"Quotations",
"Title",
"Subtitle",
"Heading 1",
"Heading 2",
"Heading 3"
};
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)
{ {
boost::property_tree::ptree aChildren; boost::property_tree::ptree aChildren;
OUString sStyleFam = aStyleFamilies[nStyleFam]; OUString sStyleFam = aStyleFamilies[nStyleFam];
uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(sStyleFam), uno::UNO_QUERY); uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(sStyleFam), uno::UNO_QUERY);
// Writer provides a huge number of styles, we have a list of 7 "default" styles which
// should be shown in the normal dropdown, which we should add to the start of the list
// to simplify their selection.
if (sStyleFam == "ParagraphStyles"
&& doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
{
for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
{
uno::Reference< beans::XPropertySet > xStyle;
xStyleFamily->getByName( OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
OUString sName;
xStyle->getPropertyValue("DisplayName") >>= sName;
if( !sName.isEmpty() )
{
boost::property_tree::ptree aChild;
aChild.put("", sName.toUtf8());
aChildren.push_back(std::make_pair("", aChild));
}
}
}
uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames(); uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd) for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd)
{ {
......
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