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

Adam Co rattles2013 at gmail.com
Mon Dec 16 01:10:17 PST 2013


 sw/source/core/unocore/unocrsrhelper.cxx |   66 +++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

New commits:
commit b39265c9728b52352d13aef5fb6a28540ebc93aa
Author: Adam Co <rattles2013 at gmail.com>
Date:   Mon Dec 2 18:47:52 2013 +0200

    Add support in the 'makeRedline' function for 'formatting properties'
    
    This patch adds support in the 'makeRedline' function to allow it to
    receive from the importer the format changes that were done when
    'Track Changes' was turned on.
    (Following commit will be for the importer code)
    
    Reviewed on:
    	https://gerrit.libreoffice.org/6902
    
    Change-Id: Ieb06dcdf15fd39d0ad928795f90146dc2f060e77

diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 0543f65..8783e5a 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1213,8 +1213,74 @@ void makeRedline( SwPaM& rPaM,
         DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) );
     }
 
+    SwRedlineExtraData_FormattingChanges* pRedlineExtraData = NULL;
+
+    // Read the 'Redline Revert Properties' from the parameters
+    uno::Sequence< beans::PropertyValue > aRevertProperties;
+    uno::Any aRevertPropertiesValue;
+    aRevertPropertiesValue = aPropMap.getUnpackedValueOrDefault("RedlineRevertProperties", aRevertPropertiesValue);
+
+    // Check if the value exists
+    if ( aRevertPropertiesValue >>= aRevertProperties )
+    {
+        // sw/source/core/unocore/unoport.cxx#83 is where it's decided what map gets used for a text portion
+        // so it's PROPERTY_MAP_TEXTPORTION_EXTENSIONS, unless it's a redline portion
+        SfxItemPropertySet const& rPropSet = (*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS));
+
+        // Check if there are any properties
+        if (aRevertProperties.getLength())
+        {
+            SwDoc *const pDoc = rPaM.GetDoc();
+            OUString aUnknownExMsg, aPropertyVetoExMsg;
+
+            // Build set of attributes we want to fetch
+            std::vector<sal_uInt16> aWhichPairs;
+            std::vector<SfxItemPropertySimpleEntry const*> aEntries;
+            aEntries.reserve(aRevertProperties.getLength());
+            for (sal_Int32 i = 0; i < aRevertProperties.getLength(); ++i)
+            {
+                const OUString &rPropertyName = aRevertProperties[i].Name;
+                SfxItemPropertySimpleEntry const* pEntry = rPropSet.getPropertyMap().getByName(rPropertyName);
+
+                // Queue up any exceptions until the end ...
+                if (!pEntry)
+                {
+                    aUnknownExMsg += "Unknown property: '" + rPropertyName + "' ";
+                    break;
+                }
+                else if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
+                {
+                    aPropertyVetoExMsg += "Property is read-only: '" + rPropertyName + "' ";
+                    break;
+                }
+                else
+                {
+                    // FIXME: we should have some nice way of merging ranges surely ?
+                    aWhichPairs.push_back(pEntry->nWID);
+                    aWhichPairs.push_back(pEntry->nWID);
+                }
+                aEntries.push_back(pEntry);
+            }
+
+            if (!aWhichPairs.empty())
+            {
+                aWhichPairs.push_back(0); // terminate
+                SfxItemSet aItemSet(pDoc->GetAttrPool(), &aWhichPairs[0]);
+
+                for (size_t i = 0; i < aEntries.size(); ++i)
+                {
+                    SfxItemPropertySimpleEntry const*const pEntry = aEntries[i];
+                    const uno::Any &rValue = aRevertProperties[i].Value;
+                    rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
+                }
+                pRedlineExtraData = new SwRedlineExtraData_FormattingChanges( &aItemSet );
+            }
+        }
+    }
+
     SwRedline* pRedline = new SwRedline( aRedlineData, rPaM );
     RedlineMode_t nPrevMode = pRedlineAccess->GetRedlineMode( );
+    pRedline->SetExtraData( pRedlineExtraData );
 
     pRedlineAccess->SetRedlineMode_intern(nsRedlineMode_t::REDLINE_ON);
     bool bRet = pRedlineAccess->AppendRedline( pRedline, false );


More information about the Libreoffice-commits mailing list