Blame SOURCES/0306-lok-sw-Place-default-styles-at-top-of-style-selector.patch

135360
From 9ec2ecca18e0ac62c5a9a0fcd628c6dde610e174 Mon Sep 17 00:00:00 2001
135360
From: Andrzej Hunt <andrzej@ahunt.org>
135360
Date: Wed, 11 Nov 2015 21:07:13 +0100
135360
Subject: [PATCH 306/398] lok sw: Place default styles at top of style selector
135360
135360
The order/list of default styles for Writer should be hardcoded,
135360
(by default the list contains 100+ items), it makes most sense to
135360
place these at the start of the list, allowing the client to then
135360
select how many styles they actually want to show.
135360
135360
Change-Id: I491a426397e06b3502cee7484c5f8adfd9d9cdf2
135360
Reviewed-on: https://gerrit.libreoffice.org/19918
135360
Reviewed-by: Andrzej Hunt <andrzej@ahunt.org>
135360
Tested-by: Andrzej Hunt <andrzej@ahunt.org>
135360
(cherry picked from commit 5c6119eeaaaed322c884504a53bb558258233fe9)
135360
---
135360
 desktop/source/lib/init.cxx | 33 +++++++++++++++++++++++++++++++++
135360
 1 file changed, 33 insertions(+)
135360
135360
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
135360
index b7459e03244c..e09ad171678e 100644
135360
--- a/desktop/source/lib/init.cxx
135360
+++ b/desktop/source/lib/init.cxx
135360
@@ -1252,12 +1252,45 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
135360
     uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
135360
     uno::Sequence<OUString> aStyleFamilies = xStyleFamilies->getElementNames();
135360
 
135360
+    static const sal_Char* aWriterStyles[] =
135360
+    {
135360
+        "Text body",
135360
+        "Quotations",
135360
+        "Title",
135360
+        "Subtitle",
135360
+        "Heading 1",
135360
+        "Heading 2",
135360
+        "Heading 3"
135360
+    };
135360
+
135360
     boost::property_tree::ptree aValues;
135360
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
135360
     {
135360
         boost::property_tree::ptree aChildren;
135360
         OUString sStyleFam = aStyleFamilies[nStyleFam];
135360
         uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName(sStyleFam), uno::UNO_QUERY);
135360
+
135360
+        // Writer provides a huge number of styles, we have a list of 7 "default" styles which
135360
+        // should be shown in the normal dropdown, which we should add to the start of the list
135360
+        // to simplify their selection.
135360
+        if (sStyleFam == "ParagraphStyles"
135360
+            && doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
135360
+        {
135360
+            for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
135360
+            {
135360
+                uno::Reference< beans::XPropertySet > xStyle;
135360
+                xStyleFamily->getByName( OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
135360
+                OUString sName;
135360
+                xStyle->getPropertyValue("DisplayName") >>= sName;
135360
+                if( !sName.isEmpty() )
135360
+                {
135360
+                    boost::property_tree::ptree aChild;
135360
+                    aChild.put("", sName.toUtf8());
135360
+                    aChildren.push_back(std::make_pair("", aChild));
135360
+                }
135360
+            }
135360
+        }
135360
+
135360
         uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
135360
         for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd)
135360
         {
135360
-- 
135360
2.12.0
135360