[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 2 commits - desktop/Library_sofficeapp.mk desktop/qa desktop/source

Andrzej Hunt andrzej at ahunt.org
Wed Nov 11 12:42:19 PST 2015


 desktop/Library_sofficeapp.mk               |    1 
 desktop/qa/desktop_lib/test_desktop_lib.cxx |    8 ++++-
 desktop/source/lib/init.cxx                 |   41 ++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

New commits:
commit 533958c02d22bbca2af9c332392bafbdfe7a0309
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Wed Nov 11 21:07:13 2015 +0100

    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/19918
    Reviewed-by: Andrzej Hunt <andrzej at ahunt.org>
    Tested-by: Andrzej Hunt <andrzej at ahunt.org>
    (cherry picked from commit 5c6119eeaaaed322c884504a53bb558258233fe9)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 32570df..20bc654 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1261,12 +1261,45 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
     uno::Reference<container::XNameAccess> xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
     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;
     for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam)
     {
         boost::property_tree::ptree aChildren;
         OUString sStyleFam = aStyleFamilies[nStyleFam];
         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();
         for (sal_Int32 nInd = 0; nInd < aStyles.getLength(); ++nInd)
         {
commit 030318a39b3057a56f9f5f6332d7f8c763e2e505
Author: Andrzej Hunt <andrzej at ahunt.org>
Date:   Wed Nov 11 17:09:47 2015 +0100

    lok: add Clear formatting to getStyles()
    
    This requires client-side support too.
    
    Change-Id: I5197ed3ed2b8244b50f7faf84a1cadde6a61b2cb
    Reviewed-on: https://gerrit.libreoffice.org/19917
    Reviewed-by: Andrzej Hunt <andrzej at ahunt.org>
    Tested-by: Andrzej Hunt <andrzej at ahunt.org>
    (cherry picked from commit 0b5991e4862501f0fa8e34f1b403aca40e51436f)

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index f0faf21..ed5057b 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
     sb \
     sfx \
     svl \
+    svxcore \
     svt \
     tk \
     tl \
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 5170785..981e546 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -185,14 +185,18 @@ void DesktopLOKTest::testGetStyles()
     CPPUNIT_ASSERT( aValues.size() > 0 );
     for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aValues)
     {
-        CPPUNIT_ASSERT( rPair.second.size() > 0);
+        if( rPair.first != "ClearStyle")
+        {
+            CPPUNIT_ASSERT( rPair.second.size() > 0);
+        }
         if (rPair.first != "CharacterStyles" &&
             rPair.first != "ParagraphStyles" &&
             rPair.first != "FrameStyles" &&
             rPair.first != "PageStyles" &&
             rPair.first != "NumberingStyles" &&
             rPair.first != "CellStyles" &&
-            rPair.first != "ShapeStyles")
+            rPair.first != "ShapeStyles" &&
+            rPair.first != "ClearStyle")
         {
             CPPUNIT_FAIL("Unknown style family: " + rPair.first);
         }
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b672525..32570df 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -66,6 +66,8 @@
 #include <sfx2/lokhelper.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/viewsh.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
 #include <svx/svxids.hrc>
 #include <vcl/svapp.hxx>
 #include <vcl/svpforlokit.hxx>
@@ -1274,6 +1276,12 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         }
         aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren);
     }
+
+    boost::property_tree::ptree aChildClearFormat;
+    OUString sClearFormat = SVX_RESSTR( RID_SVXSTR_CLEARFORM );
+    aChildClearFormat.put("", sClearFormat.toUtf8());
+    aValues.add_child("ClearStyle", aChildClearFormat);
+
     aTree.add_child("commandValues", aValues);
     std::stringstream aStream;
     boost::property_tree::write_json(aStream, aTree);


More information about the Libreoffice-commits mailing list