[Libreoffice-commits] core.git: desktop/source

Pranav Kant pranavk at collabora.com
Fri Mar 4 13:20:38 UTC 2016


 desktop/source/lib/init.cxx |   43 +++++++++----------------------------------
 1 file changed, 9 insertions(+), 34 deletions(-)

New commits:
commit e04284587a5db51d96430137baa76bbef3937a5d
Author: Pranav Kant <pranavk at collabora.com>
Date:   Mon Feb 22 20:56:12 2016 +0530

    lok: Export only programmatic style names
    
    First, it reverts b0111f494c1ee2d75ac4f1544c06c24d464cc416. It
    was a bad idea to export UI names via LOK because the client
    would need the programmatic ones anyways for UNO commands. We
    cannot expect UNO commands to accept UI style names and work,
    though that's another thing that they will work in most cases
    because mostly UI names are equal to programmatic ones. Clients
    are now supposed to have their own UI name <-> programmatic name
    mapping, if they want style names to use for translations.
    
    Secondly, it fixes a bug that was already there mixing programmatic
    names with UI ones in an effort to put default writer styles on
    the top of the list.
    
    Change-Id: I307f987fe740b3c43b0e14ec4773edcb672a11df
    Reviewed-on: https://gerrit.libreoffice.org/22810
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 829254c..8935027 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1364,49 +1364,24 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand)
         {
             for (const OUString& rStyle: aWriterStyles)
             {
-                uno::Reference< beans::XPropertySet > xStyle;
-                xStyleFamily->getByName(rStyle) >>= xStyle;
-                OUString sName;
-                xStyle->getPropertyValue("DisplayName") >>= sName;
-                if( !sName.isEmpty() )
-                {
-                    aDefaultStyleNames.insert( sName );
+                aDefaultStyleNames.insert( rStyle );
 
-                    boost::property_tree::ptree aChild;
-                    aChild.put("", sName.toUtf8());
-                    aChildren.push_back(std::make_pair("", aChild));
-                }
+                boost::property_tree::ptree aChild;
+                aChild.put("", rStyle.toUtf8());
+                aChildren.push_back(std::make_pair("", aChild));
             }
         }
 
         uno::Sequence<OUString> aStyles = xStyleFamily->getElementNames();
         for (const OUString& rStyle: aStyles )
         {
-            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)
+            // Filter out the default styles - they are already at the top
+            // of the list
+            if (aDefaultStyleNames.find(rStyle) == aDefaultStyleNames.end() ||
+                (sStyleFam != "ParagraphStyles" || doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT) )
             {
                 boost::property_tree::ptree aChild;
-                aChild.put("", rStyle);
+                aChild.put("", rStyle.toUtf8());
                 aChildren.push_back(std::make_pair("", aChild));
             }
         }


More information about the Libreoffice-commits mailing list