diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-10-21 17:23:10 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-11-21 12:57:57 +0000 |
commit | 783b93978d49ccdbc30b4afdd95a94980f99100e (patch) | |
tree | 359e5c67f94f4a9c1244c45f2b3d5a30886211c7 /sw | |
parent | 1617eef124e01ca3b3286e0ad5985c34dde7fadb (diff) |
introduce getValue(sKey) for SequenceAsHashMap
returns the plain value (Any) if it exists, else return an empty Any
replaces some getUnpackedValueOrDefault calls in sw
where is was not clear if the unpacked value exsisted or was default
needed for removal of Any-to-Any template specialisations
Change-Id: I618da7a7174143f5edef48e47e7aa1b6a52845e1
Reviewed-on: https://gerrit.libreoffice.org/30114
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unocrsrhelper.cxx | 44 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 16 |
2 files changed, 19 insertions, 41 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 8de8c1e12b65..6ee2bb80b4e5 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -1172,25 +1172,18 @@ void makeRedline( SwPaM& rPaM, //todo: what about REDLINE_FMTCOLL? comphelper::SequenceAsHashMap aPropMap( rRedlineProperties ); - uno::Any aAuthorValue; - aAuthorValue = aPropMap.getUnpackedValueOrDefault("RedlineAuthor", aAuthorValue); sal_uInt16 nAuthor = 0; OUString sAuthor; - if( aAuthorValue >>= sAuthor ) + if( aPropMap.getValue("RedlineAuthor") >>= sAuthor ) nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor); OUString sComment; - uno::Any aCommentValue; - aCommentValue = aPropMap.getUnpackedValueOrDefault("RedlineComment", aCommentValue); - SwRedlineData aRedlineData( eType, nAuthor ); - if( aCommentValue >>= sComment ) + if( aPropMap.getValue("RedlineComment") >>= sComment ) aRedlineData.SetComment( sComment ); ::util::DateTime aStamp; - uno::Any aDateTimeValue; - aDateTimeValue = aPropMap.getUnpackedValueOrDefault("RedlineDateTime", aDateTimeValue); - if( aDateTimeValue >>= aStamp ) + if( aPropMap.getValue("RedlineDateTime") >>= aStamp ) { aRedlineData.SetTimeStamp( DateTime( aStamp)); } @@ -1199,11 +1192,8 @@ void makeRedline( SwPaM& rPaM, // 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 ) + if ( aPropMap.getValue("RedlineRevertProperties") >>= aRevertProperties ) { int nMap = 0; // Make sure that paragraph format gets its own map, otherwise e.g. fill attributes are not preserved. @@ -1297,25 +1287,18 @@ void makeTableRowRedline( SwTableLine& rTableLine, } comphelper::SequenceAsHashMap aPropMap( rRedlineProperties ); - uno::Any aAuthorValue; - aAuthorValue = aPropMap.getUnpackedValueOrDefault("RedlineAuthor", aAuthorValue); sal_uInt16 nAuthor = 0; OUString sAuthor; - if( aAuthorValue >>= sAuthor ) + if( aPropMap.getValue("RedlineAuthor") >>= sAuthor ) nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor); OUString sComment; - uno::Any aCommentValue; - aCommentValue = aPropMap.getUnpackedValueOrDefault("RedlineComment", aCommentValue); - SwRedlineData aRedlineData( eType, nAuthor ); - if( aCommentValue >>= sComment ) + if( aPropMap.getValue("RedlineComment") >>= sComment ) aRedlineData.SetComment( sComment ); ::util::DateTime aStamp; - uno::Any aDateTimeValue; - aDateTimeValue = aPropMap.getUnpackedValueOrDefault("RedlineDateTime", aDateTimeValue); - if( aDateTimeValue >>= aStamp ) + if( aPropMap.getValue("RedlineDateTime") >>= aStamp ) { aRedlineData.SetTimeStamp( DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), tools::Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) ); @@ -1354,25 +1337,18 @@ void makeTableCellRedline( SwTableBox& rTableBox, } comphelper::SequenceAsHashMap aPropMap( rRedlineProperties ); - uno::Any aAuthorValue; - aAuthorValue = aPropMap.getUnpackedValueOrDefault("RedlineAuthor", aAuthorValue); sal_uInt16 nAuthor = 0; OUString sAuthor; - if( aAuthorValue >>= sAuthor ) + if( aPropMap.getValue("RedlineAuthor") >>= sAuthor ) nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor); OUString sComment; - uno::Any aCommentValue; - aCommentValue = aPropMap.getUnpackedValueOrDefault("RedlineComment", aCommentValue); - SwRedlineData aRedlineData( eType, nAuthor ); - if( aCommentValue >>= sComment ) + if( aPropMap.getValue("RedlineComment") >>= sComment ) aRedlineData.SetComment( sComment ); ::util::DateTime aStamp; - uno::Any aDateTimeValue; - aDateTimeValue = aPropMap.getUnpackedValueOrDefault("RedlineDateTime", aDateTimeValue); - if( aDateTimeValue >>= aStamp ) + if( aPropMap.getValue("RedlineDateTime") >>= aStamp ) { aRedlineData.SetTimeStamp( DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), tools::Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) ); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 88b85f500e21..0eab02785d22 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1037,11 +1037,15 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV uno::Sequence<beans::PropertyValue> tableCellProperties; tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >(); comphelper::SequenceAsHashMap aPropMap(tableCellProperties); - uno::Any sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", uno::Any()); - if(!sRedlineTypeValue.has<OUString>()) + OUString sRedlineType; + if(aPropMap.getValue("RedlineType") >>= sRedlineType) + { + // Create a 'Table Cell Redline' object + SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineType, tableCellProperties); + } + else throw beans::UnknownPropertyException("No redline type property: ", static_cast<cppu::OWeakObject*>(this)); - // Create a 'Table Cell Redline' object - SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineTypeValue.get<OUString>(), tableCellProperties); + } else { @@ -1312,9 +1316,7 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno: tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >(); comphelper::SequenceAsHashMap aPropMap( tableRowProperties ); OUString sRedlineType; - uno::Any sRedlineTypeValue; - sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", sRedlineTypeValue); - if( sRedlineTypeValue >>= sRedlineType ) + if( aPropMap.getValue("RedlineType") >>= sRedlineType ) { // Create a 'Table Row Redline' object SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties); |