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

Matúš Kukan matus.kukan at gmail.com
Fri Oct 25 08:15:36 PDT 2013


 sw/source/core/unocore/unoobj.cxx       |   36 +++++++++++++++++++++------
 sw/source/core/unocore/unoparagraph.cxx |    8 +++---
 sw/source/core/unocore/unoport.cxx      |    6 +++-
 sw/source/core/unocore/unotext.cxx      |   42 +-------------------------------
 4 files changed, 38 insertions(+), 54 deletions(-)

New commits:
commit 986fa38eb23a397546061c3ce0df9077ba334a07
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Oct 21 16:40:36 2013 +0200

    fdo#44736 - set and fetch multiple properties concurrently 2
    
    This fixes commit ee0bf5d58bc59052923c4ced928a989956e71456
    Although it's a bit hacky.
    
    Change-Id: I4dfe9ff4a56b993fbcdc7acea29ee3700422f7b3

diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 0ffc5b9..5fc9a01 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1824,6 +1824,18 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode, bTableMode);
 }
 
+// FN_UNO_PARA_STYLE is known to set attributes for nodes, inside
+// SwUnoCursorHelper::SetTxtFmtColl, instead of extending item set.
+// We need to get them from nodes in next call to GetCrsrAttr.
+// The rest could cause similar problems in theory, so we just list them here.
+inline bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
+{
+    return nWID == FN_UNO_PARA_STYLE ||
+           nWID == FN_UNO_CHARFMT_SEQUENCE ||
+           nWID == FN_UNO_NUM_START_VALUE ||
+           nWID == FN_UNO_NUM_RULES;
+}
+
 void SwUnoCursorHelper::SetPropertyValues(
     SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
     const uno::Sequence< beans::PropertyValue > &rPropertyValues,
@@ -1873,20 +1885,28 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
         SfxItemSet aItemSet(pDoc->GetAttrPool(), &aWhichPairs[0]);
 
         // Fetch, overwrite, and re-set the attributes from the core
-        SwUnoCursorHelper::GetCrsrAttr( rPaM, aItemSet );
 
-        for (sal_Int32 i = 0; ( i < rPropertyValues.getLength() &&
-                                i < (sal_Int32)aEntries.size() ); ++i)
+        bool bPreviousPropertyCausesSideEffectsInNodes = false;
+        for (size_t i = 0; i < aEntries.size(); ++i)
         {
-            const uno::Any &rValue = rPropertyValues[i].Value;
             SfxItemPropertySimpleEntry const*const pEntry = aEntries[i];
-            if (!pEntry)
-                continue;
+            bool bPropertyCausesSideEffectsInNodes =
+                propertyCausesSideEffectsInNodes(pEntry->nWID);
+
+            // we need to get up-to-date item set from nodes
+            if (i == 0 || bPreviousPropertyCausesSideEffectsInNodes)
+                SwUnoCursorHelper::GetCrsrAttr(rPaM, aItemSet);
+
+            const uno::Any &rValue = rPropertyValues[i].Value;
+            // this can set some attributes in nodes' mpAttrSet
             if (!SwUnoCursorHelper::SetCursorPropertyValue(*pEntry, rValue, rPaM, aItemSet))
                 rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
-        }
 
-        SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode);
+            if (i + 1 == aEntries.size() || bPropertyCausesSideEffectsInNodes)
+                SwUnoCursorHelper::SetCrsrAttr(rPaM, aItemSet, nAttrMode, bTableMode);
+
+            bPreviousPropertyCausesSideEffectsInNodes = bPropertyCausesSideEffectsInNodes;
+        }
     }
 
     if (!aUnknownExMsg.isEmpty())
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index fbe7c40..3d4e972 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -390,8 +390,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
     const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
     SwParaSelection aParaSel( aCursor );
 
-    // FIXME: this should be replaced with the significantly faster
-    // SwUnoCursorHelper::SetPropertyValues...
+    uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
     {
         SfxItemPropertySimpleEntry const*const pEntry =
@@ -410,9 +409,10 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
                     + pPropertyNames[nProp],
                 static_cast< cppu::OWeakObject * >(&m_rThis));
         }
-        SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet,
-                pPropertyNames[nProp], pValues[nProp]);
+        aValues[nProp].Name = pPropertyNames[nProp];
+        aValues[nProp].Value = pValues[nProp];
     }
+    SwUnoCursorHelper::SetPropertyValues(aCursor, m_rPropSet, aValues);
 }
 
 void SAL_CALL SwXParagraph::setPropertyValues(
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index a50a61c..0c817e5 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -459,6 +459,7 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
         const OUString* pPropertyNames = rPropertyNames.getConstArray();
         const uno::Any* pValues = rValues.getConstArray();
         const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap();
+        uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
         for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
         {
             const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
@@ -467,9 +468,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl(
             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
                 throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
 
-            SwUnoCursorHelper::SetPropertyValue( *pUnoCrsr, *m_pPropSet,
-                     pPropertyNames[nProp], pValues[nProp]);
+            aValues[nProp].Name = pPropertyNames[nProp];
+            aValues[nProp].Value = pValues[nProp];
         }
+        SwUnoCursorHelper::SetPropertyValues( *pUnoCrsr, *m_pPropSet, aValues );
     }
 }
 
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index cfbc527..0312b2c 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1309,50 +1309,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
     {
         aPam.Move( fnMoveBackward, fnGoNode );
     }
-#if 1 // This section should be removed in favour of the one below when it works.
-    if (rProperties.getLength())
-    {
-        // now set the properties
-        SfxItemPropertySet const*const pParaPropSet =
-            aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
-        const SfxItemPropertyMap &rParagraphMap =
-            pParaPropSet->getPropertyMap();
 
-        const beans::PropertyValue* pValues = rProperties.getConstArray();
-
-        for (sal_Int32 nProp = 0; nProp < rProperties.getLength(); ++nProp)
-        {
-            if (!rParagraphMap.getByName(pValues[nProp].Name))
-            {
-                bIllegalException = true;
-                break;
-            }
-            try
-            {
-                SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet,
-                    pValues[nProp].Name, pValues[nProp].Value);
-            }
-            catch (const lang::IllegalArgumentException& rIllegal)
-            {
-                sMessage = rIllegal.Message;
-                bIllegalException = true;
-                break;
-            }
-            catch (const uno::RuntimeException& rRuntime)
-            {
-                sMessage = rRuntime.Message;
-                bRuntimeException = true;
-                break;
-            }
-        }
-    }
-#else
     try
     {
         SfxItemPropertySet const*const pParaPropSet =
             aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH);
-        if (!bIllegalException)
-            SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
+
+        SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
     }
     catch (const lang::IllegalArgumentException& rIllegal)
     {
@@ -1364,7 +1327,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
         sMessage = rRuntime.Message;
         bRuntimeException = true;
     }
-#endif
 
     m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL);
     if (bIllegalException || bRuntimeException)


More information about the Libreoffice-commits mailing list