[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 6 12:53:33 UTC 2019


 sw/source/core/unocore/unocrsrhelper.cxx |   82 ++++++++++++++++++++++++++-----
 1 file changed, 71 insertions(+), 11 deletions(-)

New commits:
commit 7ae13834fb2e79fdb1547bbd20e9bf9edba6becd
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Dec 5 19:02:30 2019 +0100
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Dec 6 13:52:25 2019 +0100

    sw: add getter for RES_PARATR_LIST_AUTOFMT
    
    Change-Id: Ic492dd4062a5ce659a996fb96f3ed9e12d1767ce
    Reviewed-on: https://gerrit.libreoffice.org/84581
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit d8c36a8771398327ba83884a2e0aa82a6d7c8492)
    Reviewed-on: https://gerrit.libreoffice.org/84615

diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 291f3a8f0d34..d7634e2a2713 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -23,6 +23,7 @@
 #include <algorithm>
 #include <memory>
 
+#include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/beans/PropertyState.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
@@ -307,6 +308,31 @@ GetNestedTextContent(SwTextNode const & rTextNode, sal_Int32 const nIndex,
     return xRet;
 }
 
+static uno::Any GetParaListAutoFormat(SwTextNode const& rNode)
+{
+    SwFormatAutoFormat const*const pFormat(
+        rNode.GetSwAttrSet().GetItem<SwFormatAutoFormat>(RES_PARATR_LIST_AUTOFMT, false));
+    if (!pFormat)
+    {
+        return uno::Any();
+    }
+    SfxItemSet const& rSet(*pFormat->GetStyleHandle());
+    SfxItemPropertySet const& rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE));
+    SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
+    std::vector<beans::NamedValue> props;
+    // have to iterate the map, not the item set?
+    for (auto const& rEntry : rMap.getPropertyEntries())
+    {
+        if (rPropSet.getPropertyState(rEntry, rSet) == PropertyState_DIRECT_VALUE)
+        {
+            Any value;
+            rPropSet.getPropertyValue(rEntry, rSet, value);
+            props.emplace_back(rEntry.sName, value);
+        }
+    }
+    return uno::makeAny(comphelper::containerToSequence(props));
+}
+
 // Read the special properties of the cursor
 bool getCursorPropertyValue(const SfxItemPropertySimpleEntry& rEntry
                                         , SwPaM& rPam
@@ -417,48 +443,82 @@ bool getCursorPropertyValue(const SfxItemPropertySimpleEntry& rEntry
         // #i91601#
         case FN_UNO_LIST_ID:
         case FN_NUMBER_NEWSTART:
+        case FN_UNO_PARA_NUM_AUTO_FORMAT:
         {
+            if (!pAny)
+            {
+                break;
+            }
             // a multi selection is not considered
             const SwTextNode* pTextNd = rPam.GetNode().GetTextNode();
             if ( pTextNd && pTextNd->IsInList() )
             {
-                if( pAny )
+                switch (rEntry.nWID)
                 {
-                    if(rEntry.nWID == FN_UNO_NUM_LEVEL)
+                    case FN_UNO_NUM_LEVEL:
+                    {
                         *pAny <<= static_cast<sal_Int16>(pTextNd->GetActualListLevel());
-                    else if(rEntry.nWID == FN_UNO_IS_NUMBER)
+                        break;
+                    }
+                    case FN_UNO_IS_NUMBER:
                     {
                         *pAny <<= pTextNd->IsCountedInList();
+                        break;
                     }
                     // #i91601#
-                    else if ( rEntry.nWID == FN_UNO_LIST_ID )
+                    case FN_UNO_LIST_ID:
                     {
                         *pAny <<= pTextNd->GetListId();
+                        break;
                     }
-                    else
+                    case FN_NUMBER_NEWSTART:
                     {
                         *pAny <<= pTextNd->IsListRestart();
+                        break;
                     }
+                    case FN_UNO_PARA_NUM_AUTO_FORMAT:
+                    {
+                        *pAny = GetParaListAutoFormat(*pTextNd);
+                        break;
+                    }
+                    default:
+                        assert(false);
                 }
             }
             else
             {
                 eNewState = PropertyState_DEFAULT_VALUE;
 
-                if( pAny )
-                {
                     // #i30838# set default values for default properties
-                    if(rEntry.nWID == FN_UNO_NUM_LEVEL)
+                switch (rEntry.nWID)
+                {
+                    case FN_UNO_NUM_LEVEL:
+                    {
                         *pAny <<= static_cast<sal_Int16>( 0 );
-                    else if(rEntry.nWID == FN_UNO_IS_NUMBER)
+                        break;
+                    }
+                    case FN_UNO_IS_NUMBER:
+                    {
                         *pAny <<= false;
+                        break;
+                    }
                     // #i91601#
-                    else if ( rEntry.nWID == FN_UNO_LIST_ID )
+                    case FN_UNO_LIST_ID:
                     {
                         *pAny <<= OUString();
+                        break;
                     }
-                    else
+                    case FN_NUMBER_NEWSTART:
+                    {
                         *pAny <<= false;
+                        break;
+                    }
+                    case FN_UNO_PARA_NUM_AUTO_FORMAT:
+                    {
+                        break; // void
+                    }
+                    default:
+                        assert(false);
                 }
             }
             //PROPERTY_MAYBEVOID!


More information about the Libreoffice-commits mailing list