diff options
author | Adam Co <rattles2013@gmail.com> | 2013-12-02 18:47:52 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-12-16 10:09:58 +0100 |
commit | b39265c9728b52352d13aef5fb6a28540ebc93aa (patch) | |
tree | 6f2584a2c0325288850a2303a6ccf02ae9cda630 | |
parent | e3d62eff008c241d96b1e3745c09fa9cdb1d17fe (diff) |
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
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 0543f6560f5c..8783e5a67e4a 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 ); |