From 0d7c5823124696f80583ac2a5f0e28f329f6f786 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 2 Jun 2016 15:06:06 +0200 Subject: New o3tl::try/doGet to obtain value from Any ...in an attempt to reduce usage of type-unsafe void const * css::uno::Any::getValue() These new functions are often more convenient to use than the existing ">>=" and Any::get. Note how they are careful to provide a pointer directly into the given Any, instead of creating temporaries. As an example, replaced most calls of getValue across xmloff: * Cases that first check for a specific type (via getValueType etc.) and then call getValue can instead call tryGet. (But beware that tryGet supports some conversions, which a check for a specific type may have missed---either intentionally or by accident. Also beware the somewhat common idiom of checking for TypeClass_ENUM and then using getValue to obtain a sal_Int32; this cannot be replaced with a call to tryGet.) * Cases that seem confident that the Any is of the correct type when calling getValue (but apparently are confident due to some higher-layer protocol, as the surrounding code does not do any checking via getValueType or similar) can instead call doGet. It throws an exception if it turns out the confidence wasn't warranted. (Many of the existing calls that directly dereferenced the return value of getValue as sal_Bool look suspicious, in that the author might have thought the given code would also cover a VOID Any---which technically it even would have happened to do. If any RuntimeExceptions thrown from these doGet calls start to crop up, these changes need to be revisited. Some may even be rewritten as uses of ">>=". But at least "make check" did not show any such problems. Also note that casting the value obtained from getValue to any css::uno::Reference with X being anything but the base css::uno::XInterface was always prone to producing a bad pointer, in case the interface actually stored in the Any derived from X via multiple inheritance.) * Should there ever be cases where an Any is known to be of the requested type, some additional forceGet could be introduced (which would assert instead of throwing an exception). Change-Id: I2d8739e86314eff73abfcafe01d806f5bc5c34db --- xmloff/source/core/unoatrcn.cxx | 10 ++-- xmloff/source/draw/XMLImageMapExport.cxx | 3 +- xmloff/source/draw/animationexport.cxx | 66 ++++++++++------------- xmloff/source/draw/shapeexport.cxx | 13 ++--- xmloff/source/draw/ximpcustomshape.cxx | 21 ++++---- xmloff/source/style/XMLPageExport.cxx | 3 +- xmloff/source/style/prstylei.cxx | 5 +- xmloff/source/style/styleexp.cxx | 9 ++-- xmloff/source/style/xmlbahdl.cxx | 3 +- xmloff/source/style/xmlnume.cxx | 6 ++- xmloff/source/style/xmlnumi.cxx | 3 +- xmloff/source/style/xmlstyle.cxx | 2 +- xmloff/source/text/XMLIndexMarkExport.cxx | 5 +- xmloff/source/text/XMLLineNumberingExport.cxx | 9 ++-- xmloff/source/text/XMLRedlineExport.cxx | 23 ++++---- xmloff/source/text/XMLSectionExport.cxx | 31 +++++------ xmloff/source/text/XMLTextColumnsExport.cxx | 7 ++- xmloff/source/text/XMLTextHeaderFooterContext.cxx | 7 +-- xmloff/source/text/XMLTextMasterPageContext.cxx | 3 +- xmloff/source/text/txtexppr.cxx | 9 ++-- xmloff/source/text/txtflde.cxx | 5 +- xmloff/source/text/txtftne.cxx | 6 ++- xmloff/source/text/txtimppr.cxx | 5 +- xmloff/source/text/txtparae.cxx | 45 ++++++++-------- xmloff/source/text/txtprhdl.cxx | 15 +++--- xmloff/source/text/txtstyli.cxx | 4 +- 26 files changed, 173 insertions(+), 145 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx index ed811df66157..ea8446278ccb 100644 --- a/xmloff/source/core/unoatrcn.cxx +++ b/xmloff/source/core/unoatrcn.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -157,14 +158,12 @@ sal_Bool SAL_CALL SvUnoAttributeContainer::hasByName(const OUString& aName) thro void SAL_CALL SvUnoAttributeContainer::replaceByName(const OUString& aName, const uno::Any& aElement) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { - if( aElement.hasValue() && aElement.getValueType() == cppu::UnoType::get()) + if( auto pData = o3tl::tryGet(aElement) ) { sal_uInt16 nAttr = getIndexByName(aName ); if( nAttr == USHRT_MAX ) throw container::NoSuchElementException(); - xml::AttributeData const * pData = static_cast(aElement.getValue()); - sal_Int32 nPos = aName.indexOf( ':' ); if( nPos != -1L ) { @@ -199,15 +198,14 @@ void SAL_CALL SvUnoAttributeContainer::replaceByName(const OUString& aName, cons void SAL_CALL SvUnoAttributeContainer::insertByName(const OUString& aName, const uno::Any& aElement) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { - if( !aElement.hasValue() || aElement.getValueType() != cppu::UnoType::get()) + auto pData = o3tl::tryGet(aElement); + if( !pData ) throw lang::IllegalArgumentException(); sal_uInt16 nAttr = getIndexByName(aName ); if( nAttr != USHRT_MAX ) throw container::ElementExistException(); - xml::AttributeData const * pData = static_cast(aElement.getValue()); - sal_Int32 nPos = aName.indexOf( ':' ); if( nPos != -1L ) { diff --git a/xmloff/source/draw/XMLImageMapExport.cxx b/xmloff/source/draw/XMLImageMapExport.cxx index 9ea9b5863e88..43ba08306b38 100644 --- a/xmloff/source/draw/XMLImageMapExport.cxx +++ b/xmloff/source/draw/XMLImageMapExport.cxx @@ -18,6 +18,7 @@ */ #include "XMLImageMapExport.hxx" +#include #include #include #include @@ -199,7 +200,7 @@ void XMLImageMapExport::ExportMapEntry( // is-active aAny = rPropertySet->getPropertyValue(msIsActive); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_NOHREF, XML_NOHREF); } diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx index 97ae81c7b97a..b9180575fe73 100644 --- a/xmloff/source/draw/animationexport.cxx +++ b/xmloff/source/draw/animationexport.cxx @@ -49,7 +49,7 @@ #include #include #include - +#include #include #include @@ -513,7 +513,7 @@ public: void exportAudio( const Reference< XAudio >& xAudio ); void exportCommand( const Reference< XCommand >& xCommand ); - static Reference< XInterface > getParagraphTarget( const ParagraphTarget* pTarget ); + static Reference< XInterface > getParagraphTarget( const ParagraphTarget& pTarget ); static void convertPath( OUStringBuffer& sTmp, const Any& rPath ); void convertValue( XMLTokenEnum eAttributeName, OUStringBuffer& sTmp, const Any& rValue ) const; @@ -1412,14 +1412,14 @@ void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xComman } } -Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget* pTarget ) +Reference< XInterface > AnimationsExporterImpl::getParagraphTarget( const ParagraphTarget& pTarget ) { - if( pTarget ) try + try { - Reference< XEnumerationAccess > xParaEnumAccess( pTarget->Shape, UNO_QUERY_THROW ); + Reference< XEnumerationAccess > xParaEnumAccess( pTarget.Shape, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xParaEnumAccess->createEnumeration(), UNO_QUERY_THROW ); - sal_Int32 nParagraph = pTarget->Paragraph; + sal_Int32 nParagraph = pTarget.Paragraph; while( xEnumeration->hasMoreElements() ) { @@ -1450,18 +1450,16 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUString if( !rValue.hasValue() ) return; - if( rValue.getValueType() == cppu::UnoType::get() ) + if( auto pValuePair = o3tl::tryGet(rValue) ) { - const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() ); OUStringBuffer sTmp2; convertValue( eAttributeName, sTmp, pValuePair->First ); sTmp.append( ',' ); convertValue( eAttributeName, sTmp2, pValuePair->Second ); sTmp.append( sTmp2.makeStringAndClear() ); } - else if( rValue.getValueType() == cppu::UnoType< Sequence >::get() ) + else if( auto pSequence = o3tl::tryGet>(rValue) ) { - const Sequence* pSequence = static_cast< const Sequence* >( rValue.getValue() ); const sal_Int32 nLength = pSequence->getLength(); sal_Int32 nElement; const Any* pAny = pSequence->getConstArray(); @@ -1478,7 +1476,6 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUString } else { - OUString aString; sal_Int32 nType; switch( eAttributeName ) @@ -1490,13 +1487,13 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUString case XML_ANIMATETRANSFORM: case XML_ANIMATEMOTION: { - if( rValue >>= aString ) + if( auto aString = o3tl::tryGet(rValue) ) { - sTmp.append( aString ); + sTmp.append( *aString ); } - else if( rValue.getValueType() == cppu::UnoType::get() ) + else if( auto x = o3tl::tryGet(rValue) ) { - sTmp.append( *(static_cast< const double* >( rValue.getValue() )) ); + sTmp.append( *x ); } else { @@ -1530,6 +1527,7 @@ void AnimationsExporterImpl::convertValue( XMLTokenEnum eAttributeName, OUString const XMLPropertyHandler* pHandler = mpSdPropHdlFactory->GetPropertyHandler( nType ); if( pHandler ) { + OUString aString; pHandler->exportXML( aString, rValue, mrExport.GetMM100UnitConverter() ); sTmp.append( aString ); } @@ -1541,9 +1539,8 @@ void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rVa if( !rValue.hasValue() ) return; - if( rValue.getValueType() == cppu::UnoType< Sequence >::get() ) + if( auto pSequence = o3tl::tryGet>(rValue) ) { - const Sequence* pSequence = static_cast< const Sequence* >( rValue.getValue() ); const sal_Int32 nLength = pSequence->getLength(); sal_Int32 nElement; const Any* pAny = pSequence->getConstArray(); @@ -1558,22 +1555,19 @@ void AnimationsExporterImpl::convertTiming( OUStringBuffer& sTmp, const Any& rVa sTmp.append( sTmp2.makeStringAndClear() ); } } - else if( rValue.getValueType() == cppu::UnoType::get() ) + else if( auto x = o3tl::tryGet(rValue) ) { - sTmp.append( *(static_cast< const double* >( rValue.getValue() )) ); + sTmp.append( *x ); sTmp.append( 's'); } - else if( rValue.getValueType() == cppu::UnoType::get() ) + else if( auto pTiming = o3tl::tryGet(rValue) ) { - const Timing* pTiming = static_cast< const Timing* >( rValue.getValue() ); sTmp.append( GetXMLToken( (*pTiming == Timing_MEDIA) ? XML_MEDIA : XML_INDEFINITE ) ); } - else if( rValue.getValueType() == cppu::UnoType::get() ) + else if( auto pEvent = o3tl::tryGet(rValue) ) { OUStringBuffer sTmp2; - const Event* pEvent = static_cast< const Event* >( rValue.getValue() ); - if( pEvent->Trigger != EventTrigger::NONE ) { if( pEvent->Source.hasValue() ) @@ -1615,13 +1609,12 @@ void AnimationsExporterImpl::convertTarget( OUStringBuffer& sTmp, const Any& rTa Reference< XInterface > xRef; - if( rTarget.getValueTypeClass() == css::uno::TypeClass_INTERFACE ) + if( !(rTarget >>= xRef) ) { - rTarget >>= xRef; - } - else if( rTarget.getValueType() == cppu::UnoType::get() ) - { - xRef = getParagraphTarget( static_cast< const ParagraphTarget* >( rTarget.getValue() ) ); + if( auto pt = o3tl::tryGet(rTarget) ) + { + xRef = getParagraphTarget( *pt ); + } } DBG_ASSERT( xRef.is(), "xmloff::AnimationsExporterImpl::convertTarget(), invalid target type!" ); @@ -1638,15 +1631,13 @@ void AnimationsExporterImpl::prepareValue( const Any& rValue ) if( !rValue.hasValue() ) return; - if( rValue.getValueType() == cppu::UnoType::get() ) + if( auto pValuePair = o3tl::tryGet(rValue) ) { - const ValuePair* pValuePair = static_cast< const ValuePair* >( rValue.getValue() ); prepareValue( pValuePair->First ); prepareValue( pValuePair->Second ); } - else if( rValue.getValueType() == cppu::UnoType< Sequence >::get() ) + else if( auto pSequence = o3tl::tryGet>(rValue) ) { - const Sequence* pSequence = static_cast< const Sequence* >( rValue.getValue() ); const sal_Int32 nLength = pSequence->getLength(); sal_Int32 nElement; const Any* pAny = pSequence->getConstArray(); @@ -1660,15 +1651,14 @@ void AnimationsExporterImpl::prepareValue( const Any& rValue ) if( xRef.is() ) mrExport.getInterfaceToIdentifierMapper().registerReference( xRef ); } - else if( rValue.getValueType() == cppu::UnoType::get() ) + else if( auto pt = o3tl::tryGet(rValue) ) { - Reference< XInterface> xRef( getParagraphTarget( static_cast< const ParagraphTarget* >( rValue.getValue() ) ) ); + Reference< XInterface> xRef( getParagraphTarget( *pt ) ); if( xRef.is() ) mrExport.getInterfaceToIdentifierMapper().registerReference( xRef ); } - else if( rValue.getValueType() == cppu::UnoType::get() ) + else if( auto pEvent = o3tl::tryGet(rValue) ) { - const Event* pEvent = static_cast< const Event* >( rValue.getValue() ); prepareValue( pEvent->Source ); } } diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index ed70149d0574..d851046beb9d 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -85,6 +85,8 @@ #include #include +#include + #include #include @@ -1995,9 +1997,8 @@ void XMLShapeExport::ImpExportLineShape( // get the two points uno::Any aAny(xPropSet->getPropertyValue("Geometry")); - drawing::PointSequenceSequence const * pSourcePolyPolygon = static_cast(aAny.getValue()); - - if(pSourcePolyPolygon) + if (auto pSourcePolyPolygon + = o3tl::tryGet(aAny)) { drawing::PointSequence* pOuterSequence = const_cast(pSourcePolyPolygon)->getArray(); if(pOuterSequence) @@ -2172,7 +2173,7 @@ void XMLShapeExport::ImpExportPolygonShape( // get PolygonBezier uno::Any aAny( xPropSet->getPropertyValue("Geometry") ); const basegfx::B2DPolyPolygon aPolyPolygon( - basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*static_cast(aAny.getValue()))); + basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*o3tl::doGet(aAny))); if(aPolyPolygon.count()) { @@ -2193,7 +2194,7 @@ void XMLShapeExport::ImpExportPolygonShape( // get non-bezier polygon uno::Any aAny( xPropSet->getPropertyValue("Geometry") ); const basegfx::B2DPolyPolygon aPolyPolygon( - basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*static_cast(aAny.getValue()))); + basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(*o3tl::doGet(aAny))); if(!aPolyPolygon.areControlPointsUsed() && 1 == aPolyPolygon.count()) { @@ -2585,7 +2586,7 @@ void XMLShapeExport::ImpExportConnectorShape( if( xProps->getPropertyValue("PolyPolygonBezier") >>= aAny ) { // get PolygonBezier - drawing::PolyPolygonBezierCoords const * pSourcePolyPolygon = static_cast(aAny.getValue()); + auto pSourcePolyPolygon = o3tl::tryGet(aAny); if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength()) { diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index 9f482d98092e..bdd752417930 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -19,6 +19,7 @@ #include "ximpcustomshape.hxx" #include "ximpshap.hxx" +#include #include #include #include @@ -1219,8 +1220,8 @@ void XMLEnhancedCustomShapeContext::EndElement() case EAS_GluePoints : { uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > const & rSeq = - *static_cast const *>( - aPathIter->Value.getValue()); + *o3tl::doGet >( + aPathIter->Value); for ( i = 0; i < rSeq.getLength(); i++ ) { CheckAndResolveEquationParameter( const_cast(rSeq[ i ].First), pH ); @@ -1231,8 +1232,8 @@ void XMLEnhancedCustomShapeContext::EndElement() case EAS_TextFrames : { uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > const & rSeq = - *static_cast const *>( - aPathIter->Value.getValue()); + *o3tl::doGet >( + aPathIter->Value); for ( i = 0; i < rSeq.getLength(); i++ ) { CheckAndResolveEquationParameter( const_cast(rSeq[ i ].TopLeft.First), pH ); @@ -1263,18 +1264,18 @@ void XMLEnhancedCustomShapeContext::EndElement() case EAS_RadiusRangeMinimum : case EAS_RadiusRangeMaximum : { - CheckAndResolveEquationParameter( *const_cast(static_cast( - pValues->Value.getValue())), pH ); + CheckAndResolveEquationParameter( const_cast(*o3tl::doGet( + pValues->Value)), pH ); } break; case EAS_Position : case EAS_Polar : { - CheckAndResolveEquationParameter( const_cast((*static_cast( - pValues->Value.getValue())).First), pH ); - CheckAndResolveEquationParameter( const_cast((*static_cast( - pValues->Value.getValue())).Second), pH ); + CheckAndResolveEquationParameter( const_cast((*o3tl::doGet( + pValues->Value)).First), pH ); + CheckAndResolveEquationParameter( const_cast((*o3tl::doGet( + pValues->Value)).Second), pH ); } break; default: diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx index 0d4f4061fa42..d7fc0c18073d 100644 --- a/xmloff/source/style/XMLPageExport.cxx +++ b/xmloff/source/style/XMLPageExport.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -92,7 +93,7 @@ bool XMLPageExport::exportStyle( if( xPropSetInfo->hasPropertyByName( sIsPhysical ) ) { Any aAny = xPropSet->getPropertyValue( sIsPhysical ); - if( !*static_cast(aAny.getValue()) ) + if( !*o3tl::doGet(aAny) ) return false; } diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index e246be5f64dc..1092568ddb80 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -373,7 +376,7 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite ) if( !bNew && xPropSetInfo->hasPropertyByName( msIsPhysical ) ) { Any aAny = xPropSet->getPropertyValue( msIsPhysical ); - bNew = !*static_cast(aAny.getValue()); + bNew = !*o3tl::doGet(aAny); } SetNew( bNew ); if( rName != GetName() ) diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index f96e1c78f188..d87979d57cba 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -96,7 +99,7 @@ bool XMLStyleExport::exportStyle( if( xPropSetInfo->hasPropertyByName( sIsPhysical ) ) { aAny = xPropSet->getPropertyValue( sIsPhysical ); - if( !*static_cast(aAny.getValue()) ) + if( !*o3tl::doGet(aAny) ) return false; } @@ -164,7 +167,7 @@ bool XMLStyleExport::exportStyle( if( xPropSetInfo->hasPropertyByName( sIsAutoUpdate ) ) { aAny = xPropSet->getPropertyValue( sIsAutoUpdate ); - if( *static_cast(aAny.getValue()) ) + if( *o3tl::doGet(aAny) ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_AUTO_UPDATE, XML_TRUE ); } @@ -474,7 +477,7 @@ void XMLStyleExport::exportStyleFamily( if (xPropSetInfo->hasPropertyByName( sIsPhysical )) { Any aAny( xPropSet->getPropertyValue( sIsPhysical ) ); - if (!*static_cast(aAny.getValue())) + if (!*o3tl::doGet(aAny)) continue; } diff --git a/xmloff/source/style/xmlbahdl.cxx b/xmloff/source/style/xmlbahdl.cxx index 6020dcdce3b2..5574ad6ddba6 100644 --- a/xmloff/source/style/xmlbahdl.cxx +++ b/xmloff/source/style/xmlbahdl.cxx @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -693,7 +694,7 @@ bool XMLIsTransparentPropHdl::exportXML( OUString& rStrExpValue, const Any& rVal // MIB: This looks a bit strange, because bTransPropValue == bValue should // do the same, but this only applies if 'true' is represented by the same // 8 bit value in bValue and bTransPropValue. Who will ensure this? - bool bValue = *static_cast(rValue.getValue()); + bool bValue = *o3tl::doGet(rValue); bool bIsTrans = bTransPropValue ? bValue : !bValue; if( bIsTrans ) diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx index ee4cfdcdd78c..d8470b4e4893 100644 --- a/xmloff/source/style/xmlnume.cxx +++ b/xmloff/source/style/xmlnume.cxx @@ -33,6 +33,8 @@ #include #include +#include + #include #include @@ -674,7 +676,7 @@ void SvxXMLNumRuleExport::exportNumberingRule( xPropSetInfo->hasPropertyByName( sIsContinuousNumbering ) ) { Any aAny( xPropSet->getPropertyValue( sIsContinuousNumbering ) ); - bContNumbering = *static_cast(aAny.getValue()); + bContNumbering = *o3tl::doGet(aAny); } if( bContNumbering ) GetExport().AddAttribute( XML_NAMESPACE_TEXT, @@ -702,7 +704,7 @@ void SvxXMLNumRuleExport::exportStyle( const Reference< XStyle >& rStyle ) if( xPropSetInfo->hasPropertyByName( sIsPhysical ) ) { aAny = xPropSet->getPropertyValue( sIsPhysical ); - if( !*static_cast(aAny.getValue()) ) + if( !*o3tl::doGet(aAny) ) return; } diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx index 0a8b5b6823c6..a5153de126bd 100644 --- a/xmloff/source/style/xmlnumi.cxx +++ b/xmloff/source/style/xmlnumi.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -1183,7 +1184,7 @@ void SvxXMLListStyleContext::CreateAndInsertLate( bool bOverwrite ) if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) ) { Any aAny = xPropSet->getPropertyValue( sIsPhysical ); - bNew = !*static_cast(aAny.getValue()); + bNew = !*o3tl::doGet(aAny); } if ( xPropSetInfo->hasPropertyByName( "Hidden" ) ) diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 73aa9053b134..6d9e8d997f1b 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -695,7 +695,7 @@ Reference < XAutoStyleFamily > SvXMLStylesContext::GetAutoStyles( sal_uInt16 nFa if (xAutoStyleFamilies->hasByName(sName)) { Any aAny = xAutoStyleFamilies->getByName( sName ); - xAutoStyles = *static_cast const *>(aAny.getValue()); + aAny >>= xAutoStyles; if( bPara ) const_cast(this)->mxParaAutoStyles = xAutoStyles; else diff --git a/xmloff/source/text/XMLIndexMarkExport.cxx b/xmloff/source/text/XMLIndexMarkExport.cxx index b4f0ad1d7ea9..14c983fe77b3 100644 --- a/xmloff/source/text/XMLIndexMarkExport.cxx +++ b/xmloff/source/text/XMLIndexMarkExport.cxx @@ -18,6 +18,7 @@ */ #include "XMLIndexMarkExport.hxx" +#include #include #include #include @@ -91,7 +92,7 @@ void XMLIndexMarkExport::ExportIndexMark( // collapsed/alternative text entry? aAny = rPropSet->getPropertyValue(sIsCollapsed); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { // collapsed entry: needs alternative text nElementNo = 0; @@ -107,7 +108,7 @@ void XMLIndexMarkExport::ExportIndexMark( { // start and end entries: has ID aAny = rPropSet->getPropertyValue(sIsStart); - nElementNo = *static_cast(aAny.getValue()) ? 1 : 2; + nElementNo = *o3tl::doGet(aAny) ? 1 : 2; // generate ID OUStringBuffer sBuf; diff --git a/xmloff/source/text/XMLLineNumberingExport.cxx b/xmloff/source/text/XMLLineNumberingExport.cxx index df911191b6a0..6394f81cd03c 100644 --- a/xmloff/source/text/XMLLineNumberingExport.cxx +++ b/xmloff/source/text/XMLLineNumberingExport.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -89,7 +90,7 @@ void XMLLineNumberingExport::Export() // enable aAny = xLineNumbering->getPropertyValue(sIsOn); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBER_LINES, XML_FALSE); @@ -97,7 +98,7 @@ void XMLLineNumberingExport::Export() // count empty lines aAny = xLineNumbering->getPropertyValue(sCountEmptyLines); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_COUNT_EMPTY_LINES, XML_FALSE); @@ -105,7 +106,7 @@ void XMLLineNumberingExport::Export() // count in frames aAny = xLineNumbering->getPropertyValue(sCountLinesInFrames); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_COUNT_IN_TEXT_BOXES, XML_TRUE); @@ -113,7 +114,7 @@ void XMLLineNumberingExport::Export() // restart numbering aAny = xLineNumbering->getPropertyValue(sRestartAtEachPage); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_RESTART_ON_PAGE, XML_TRUE); diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx index f7b38efb5edf..ce9bfa37f1b6 100644 --- a/xmloff/source/text/XMLRedlineExport.cxx +++ b/xmloff/source/text/XMLRedlineExport.cxx @@ -18,6 +18,7 @@ */ #include "XMLRedlineExport.hxx" +#include #include #include #include @@ -213,8 +214,8 @@ void XMLRedlineExport::ExportChangesListElements() Reference aDocPropertySet( rExport.GetModel(), uno::UNO_QUERY ); // redlining enabled? - bool bEnabled = *static_cast(aDocPropertySet->getPropertyValue( - sRecordChanges ).getValue()); + bool bEnabled = *o3tl::doGet(aDocPropertySet->getPropertyValue( + sRecordChanges )); // only export if we have redlines or attributes if ( aEnumAccess->hasElements() || bEnabled ) @@ -248,7 +249,7 @@ void XMLRedlineExport::ExportChangesListElements() // export only if not in header or footer // (those must be exported with their XText) aAny = xPropSet->getPropertyValue(sIsInHeaderFooter); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { // and finally, export change ExportChangedRegion(xPropSet); @@ -272,8 +273,8 @@ void XMLRedlineExport::ExportChangeAutoStyle( Any aIsStart = rPropSet->getPropertyValue(sIsStart); Any aIsCollapsed = rPropSet->getPropertyValue(sIsCollapsed); - if ( *static_cast(aIsStart.getValue()) || - *static_cast(aIsCollapsed.getValue()) ) + if ( *o3tl::doGet(aIsStart) || + *o3tl::doGet(aIsCollapsed) ) pCurrentChangesList->push_back(rPropSet); } @@ -315,7 +316,7 @@ void XMLRedlineExport::ExportChangesListAutoStyles() // export only if not in header or footer // (those must be exported with their XText) aAny = xPropSet->getPropertyValue(sIsInHeaderFooter); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { ExportChangeAutoStyle(xPropSet); } @@ -331,7 +332,7 @@ void XMLRedlineExport::ExportChangeInline( // determine element name (depending on collapsed, start/end) enum XMLTokenEnum eElement = XML_TOKEN_INVALID; Any aAny = rPropSet->getPropertyValue(sIsCollapsed); - bool bCollapsed = *static_cast(aAny.getValue()); + bool bCollapsed = *o3tl::doGet(aAny); if (bCollapsed) { eElement = XML_CHANGE; @@ -339,7 +340,7 @@ void XMLRedlineExport::ExportChangeInline( else { aAny = rPropSet->getPropertyValue(sIsStart); - const bool bStart = *static_cast(aAny.getValue()); + const bool bStart = *o3tl::doGet(aAny); eElement = bStart ? XML_CHANGE_START : XML_CHANGE_END; } @@ -364,7 +365,7 @@ void XMLRedlineExport::ExportChangedRegion( // merge-last-paragraph Any aAny = rPropSet->getPropertyValue(sMergeLastPara); - if( ! *static_cast(aAny.getValue()) ) + if( ! *o3tl::doGet(aAny) ) rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_MERGE_LAST_PARAGRAPH, XML_FALSE); @@ -581,11 +582,11 @@ void XMLRedlineExport::ExportStartOrEndRedline( } else if (sIsCollapsed.equals(pValues[i].Name)) { - bIsCollapsed = *static_cast(pValues[i].Value.getValue()); + bIsCollapsed = *o3tl::doGet(pValues[i].Value); } else if (sIsStart.equals(pValues[i].Name)) { - bIsStart = *static_cast(pValues[i].Value.getValue()); + bIsStart = *o3tl::doGet(pValues[i].Value); } } diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index 3242abfb1bd4..825e6a0191a5 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -18,6 +18,7 @@ */ #include "XMLSectionExport.hxx" +#include #include #include @@ -429,7 +430,7 @@ void XMLSectionExport::ExportRegularSectionStart( // #97450# store hidden-status (of conditional sections only) aAny = xPropSet->getPropertyValue(sIsCurrentlyVisible); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_IS_HIDDEN, XML_TRUE); @@ -440,14 +441,14 @@ void XMLSectionExport::ExportRegularSectionStart( eDisplay = XML_NONE; } aAny = xPropSet->getPropertyValue(sIsVisible); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_DISPLAY, eDisplay); } // protect + protection key aAny = xPropSet->getPropertyValue(sIsProtected); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE); } @@ -531,7 +532,7 @@ void XMLSectionExport::ExportRegularSectionStart( sItem); aAny = xPropSet->getPropertyValue(sIsAutomaticUpdate); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE, XML_TRUE); @@ -765,7 +766,7 @@ void XMLSectionExport::ExportBaseIndexStart( { // protect + protection key Any aAny = rPropertySet->getPropertyValue(sIsProtected); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_PROTECTED, XML_TRUE); } @@ -809,7 +810,7 @@ void XMLSectionExport::ExportBaseIndexSource( { // document or chapter index? aAny = rPropertySet->getPropertyValue(sCreateFromChapter); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_INDEX_SCOPE, XML_CHAPTER); @@ -817,7 +818,7 @@ void XMLSectionExport::ExportBaseIndexSource( // tab-stops relative to margin? aAny = rPropertySet->getPropertyValue(sIsRelativeTabstops); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_RELATIVE_TAB_STOP_POSITION, @@ -914,7 +915,7 @@ void XMLSectionExport::ExportTableAndIllustrationIndexSourceAttributes( { // use caption Any aAny = rPropertySet->getPropertyValue(sCreateFromLabels); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_USE_CAPTION, XML_FALSE); @@ -1284,7 +1285,7 @@ void XMLSectionExport::ExportIndexTemplateElement( case TOK_TPARAM_TAB_RIGHT_ALIGNED: bRightAligned = - *static_cast(rValues[i].Value.getValue()); + *o3tl::doGet(rValues[i].Value); break; case TOK_TPARAM_TAB_POSITION: @@ -1294,7 +1295,7 @@ void XMLSectionExport::ExportIndexTemplateElement( // #i21237# case TOK_TPARAM_TAB_WITH_TAB: - bWithTabStop = *static_cast(rValues[i].Value.getValue()); + bWithTabStop = *o3tl::doGet(rValues[i].Value); bWithTabStopOK = true; break; @@ -1591,7 +1592,7 @@ void XMLSectionExport::ExportBoolean( OSL_ENSURE(eAttributeName != XML_TOKEN_INVALID, "Need attribute name"); Any aAny = rPropSet->getPropertyValue(sPropertyName); - bool bTmp = *static_cast(aAny.getValue()); + bool bTmp = *o3tl::doGet(aAny); // value = value ^ bInvert // omit if value == default @@ -1647,14 +1648,14 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SUFFIX, sTmp); aAny = xPropSet->getPropertyValue(sIsNumberEntries); - if (*static_cast(aAny.getValue())) + if (*o3tl::doGet(aAny)) { rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_NUMBERED_ENTRIES, XML_TRUE); } aAny = xPropSet->getPropertyValue(sIsSortByPosition); - if (! *static_cast(aAny.getValue())) + if (! *o3tl::doGet(aAny)) { rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SORT_BY_POSITION, XML_FALSE); @@ -1709,7 +1710,7 @@ void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) } else if (rValue.Name == "IsSortAscending") { - bool bTmp = *static_cast(rValue.Value.getValue()); + bool bTmp = *o3tl::doGet(rValue.Value); rExport.AddAttribute(XML_NAMESPACE_TEXT, XML_SORT_ASCENDING, bTmp ? XML_TRUE : XML_FALSE); @@ -1749,7 +1750,7 @@ bool XMLSectionExport::IsMuteSection( { Any aAny = xPropSet->getPropertyValue(sIsGlobalDocumentSection); - if ( *static_cast(aAny.getValue()) ) + if ( *o3tl::doGet(aAny) ) { Reference xIndex; if (! GetIndex(rSection, xIndex)) diff --git a/xmloff/source/text/XMLTextColumnsExport.cxx b/xmloff/source/text/XMLTextColumnsExport.cxx index ee797e2c6b70..4d5eee50f365 100644 --- a/xmloff/source/text/XMLTextColumnsExport.cxx +++ b/xmloff/source/text/XMLTextColumnsExport.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include @@ -72,7 +75,7 @@ void XMLTextColumnsExport::exportXML( const Any& rAny ) if( xPropSet.is() ) { Any aAny = xPropSet->getPropertyValue( sIsAutomatic ); - if ( *static_cast(aAny.getValue()) ) + if ( *o3tl::doGet(aAny) ) { aAny = xPropSet->getPropertyValue( sAutomaticDistance ); sal_Int32 nDistance = 0; @@ -92,7 +95,7 @@ void XMLTextColumnsExport::exportXML( const Any& rAny ) if( xPropSet.is() ) { Any aAny = xPropSet->getPropertyValue( sSeparatorLineIsOn ); - if( *static_cast(aAny.getValue()) ) + if( *o3tl::doGet(aAny) ) { // style:width aAny = xPropSet->getPropertyValue( sSeparatorLineWidth ); diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx index efa42e333cbf..6dc6e25021eb 100644 --- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx +++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include "XMLTextHeaderFooterContext.hxx" @@ -58,7 +59,7 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa Any aAny; aAny = xPropSet->getPropertyValue( sOn ); - bool bOn = *static_cast(aAny.getValue()); + bool bOn = *o3tl::doGet(aAny); if( bOn ) { @@ -124,7 +125,7 @@ SvXMLImportContext *XMLTextHeaderFooterContext::CreateChildContext( else { aAny = xPropSet->getPropertyValue( sOn ); - bool bOn = *static_cast(aAny.getValue()); + bool bOn = *o3tl::doGet(aAny); if( !bOn ) { @@ -138,7 +139,7 @@ SvXMLImportContext *XMLTextHeaderFooterContext::CreateChildContext( // If a header or footer is not shared, share it now. aAny = xPropSet->getPropertyValue( sShareContent ); - bool bShared = *static_cast(aAny.getValue()); + bool bShared = *o3tl::doGet(aAny); if( !bShared ) { xPropSet->setPropertyValue( sShareContent, Any(true) ); diff --git a/xmloff/source/text/XMLTextMasterPageContext.cxx b/xmloff/source/text/XMLTextMasterPageContext.cxx index 155d29697ab8..8d39758498c1 100644 --- a/xmloff/source/text/XMLTextMasterPageContext.cxx +++ b/xmloff/source/text/XMLTextMasterPageContext.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -147,7 +148,7 @@ XMLTextMasterPageContext::XMLTextMasterPageContext( SvXMLImport& rImport, if( !bNew && xPropSetInfo->hasPropertyByName( sIsPhysical ) ) { aAny = xPropSet->getPropertyValue( sIsPhysical ); - bNew = !*static_cast(aAny.getValue()); + bNew = !*o3tl::doGet(aAny); } SetNew( bNew ); diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx index 687fa59383ba..d77a548e95ed 100644 --- a/xmloff/source/text/txtexppr.cxx +++ b/xmloff/source/text/txtexppr.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,7 @@ void XMLTextExportPropertySetMapper::handleSpecialItem( { case CTF_DROPCAPWHOLEWORD: DBG_ASSERT( !bDropWholeWord, "drop whole word is set already!" ); - pThis->bDropWholeWord = *static_cast(rProperty.maValue.getValue()); + pThis->bDropWholeWord = *o3tl::doGet(rProperty.maValue); break; case CTF_DROPCAPCHARSTYLE: DBG_ASSERT( sDropCharStyle.isEmpty(), "drop char style is set already!" ); @@ -1004,7 +1005,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( } if( pWrapContourModeState && (!pWrapContourState || - !*static_cast(pWrapContourState ->maValue.getValue()) ) ) + !*o3tl::doGet(pWrapContourState ->maValue) ) ) pWrapContourModeState->mnIndex = -1; } @@ -1022,7 +1023,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( if( pHoriOrientState && pHoriOrientMirroredState ) { if( pHoriOrientMirrorState && - *static_cast(pHoriOrientMirrorState->maValue.getValue()) ) + *o3tl::doGet(pHoriOrientMirrorState->maValue) ) pHoriOrientState->mnIndex = -1; else pHoriOrientMirroredState->mnIndex = -1; @@ -1098,7 +1099,7 @@ void XMLTextExportPropertySetMapper::ContextFilter( if( pShapeHoriOrientState && pShapeHoriOrientMirroredState ) { if( pShapeHoriOrientMirrorState && - *static_cast(pShapeHoriOrientMirrorState->maValue.getValue()) ) + *o3tl::doGet(pShapeHoriOrientMirrorState->maValue) ) pShapeHoriOrientState->mnIndex = -1; else pShapeHoriOrientMirroredState->mnIndex = -1; diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index c198d272d056..b87e256af950 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -2950,7 +2951,7 @@ enum XMLTokenEnum XMLTextFieldExport::MapPageNumberName( enum XMLTokenEnum eName = XML_TOKEN_INVALID; PageNumberType ePage; Any aAny = xPropSet->getPropertyValue(sPropertySubType); - ePage = *static_cast(aAny.getValue()); + ePage = *o3tl::doGet(aAny); switch (ePage) { @@ -3492,7 +3493,7 @@ inline bool GetBoolProperty( const Reference & xPropSet) { Any aAny = xPropSet->getPropertyValue(sPropName); - bool bBool = *static_cast(aAny.getValue()); + bool bBool = *o3tl::doGet(aAny); return bBool; } diff --git a/xmloff/source/text/txtftne.cxx b/xmloff/source/text/txtftne.cxx index f990e2f33150..97324420ccde 100644 --- a/xmloff/source/text/txtftne.cxx +++ b/xmloff/source/text/txtftne.cxx @@ -26,6 +26,10 @@ * - footnote configuration elements * - endnote configuration elements */ + +#include + +#include #include #include #include @@ -315,7 +319,7 @@ void XMLTextParagraphExport::exportTextFootnoteConfigurationHelper( aAny = rFootnoteConfig->getPropertyValue( sPositionEndOfDoc); GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_FOOTNOTES_POSITION, - ( (*static_cast(aAny.getValue())) ? + ( (*o3tl::doGet(aAny)) ? XML_DOCUMENT : XML_PAGE ) ); aAny = rFootnoteConfig->getPropertyValue(sFootnoteCounting); diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx index f89a142d0636..6bc35f5f469f 100644 --- a/xmloff/source/text/txtimppr.cxx +++ b/xmloff/source/text/txtimppr.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -671,7 +674,7 @@ void XMLTextImportPropertyMapper::finished( // #i5775# don't overwrite %transparency with binary transparency if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) ) { - if( ! *static_cast(pBackTransparent->maValue.getValue()) ) + if( ! *o3tl::doGet(pBackTransparent->maValue) ) pBackTransparent->mnIndex = -1; } diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index efe5a79b4e1e..dfea038f50ae 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -513,13 +516,13 @@ void XMLTextParagraphExport::Add( sal_uInt16 nFamily, xNumPropSet->getPropertySetInfo() ->hasPropertyByName( "IsAutomatic" ) ) { - bAdd = *static_cast(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue()); + bAdd = *o3tl::doGet(xNumPropSet->getPropertyValue( "IsAutomatic" )); // Check on outline style (#i73361#) if ( bAdd && xNumPropSet->getPropertySetInfo() ->hasPropertyByName( "NumberingIsOutline" ) ) { - bAdd = !(*static_cast(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue())); + bAdd = !(*o3tl::doGet(xNumPropSet->getPropertyValue( "NumberingIsOutline" ))); } } else @@ -619,13 +622,13 @@ void XMLTextParagraphExport::Add( sal_uInt16 nFamily, xNumPropSet->getPropertySetInfo() ->hasPropertyByName( "IsAutomatic" ) ) { - bAdd = *static_cast(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue()); + bAdd = *o3tl::doGet(xNumPropSet->getPropertyValue( "IsAutomatic" )); // Check on outline style (#i73361#) if ( bAdd && xNumPropSet->getPropertySetInfo() ->hasPropertyByName( "NumberingIsOutline" ) ) { - bAdd = !(*static_cast(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue())); + bAdd = !(*o3tl::doGet(xNumPropSet->getPropertyValue( "NumberingIsOutline" ))); } } else @@ -1456,13 +1459,13 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress ) } Any aAny = xAutoStyleFamilies->getByName( sName ); - Reference< XAutoStyleFamily > xAutoStyles = *static_cast const *>(aAny.getValue()); + Reference< XAutoStyleFamily > xAutoStyles = *o3tl::doGet>(aAny); Reference < XEnumeration > xAutoStylesEnum( xAutoStyles->createEnumeration() ); while ( xAutoStylesEnum->hasMoreElements() ) { aAny = xAutoStylesEnum->nextElement(); - Reference< XAutoStyle > xAutoStyle = *static_cast const *>(aAny.getValue()); + Reference< XAutoStyle > xAutoStyle = *o3tl::doGet>(aAny); Reference < XPropertySet > xPSet( xAutoStyle, uno::UNO_QUERY ); Add( nFamily, xPSet, nullptr, true ); } @@ -1479,7 +1482,7 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress ) while ( xTextFieldsEnum->hasMoreElements() ) { Any aAny = xTextFieldsEnum->nextElement(); - Reference< XTextField > xTextField = *static_cast const *>(aAny.getValue()); + Reference< XTextField > xTextField = *o3tl::doGet>(aAny); exportTextField( xTextField, bAutoStyles, bIsProgress, !xAutoStylesSupp.is() ); try @@ -1557,7 +1560,7 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress ) for( sal_Int32 i = 0; i < nCount; ++i ) { Any aAny = xSections->getByIndex( i ); - Reference< XTextSection > xSection = *static_cast const *>(aAny.getValue()); + Reference< XTextSection > xSection = *o3tl::doGet>(aAny); Reference < XPropertySet > xPSet( xSection, uno::UNO_QUERY ); Add( XML_STYLE_FAMILY_TEXT_SECTION, xPSet ); } @@ -1575,7 +1578,7 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress ) for( sal_Int32 i = 0; i < nCount; ++i ) { Any aAny = xTables->getByIndex( i ); - Reference< XTextTable > xTable = *static_cast const *>(aAny.getValue()); + Reference< XTextTable > xTable = *o3tl::doGet>(aAny); exportTable( xTable, true, true ); } } @@ -1605,13 +1608,13 @@ bool XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress ) xNumPropSet->getPropertySetInfo() ->hasPropertyByName( "IsAutomatic" ) ) { - bAdd = *static_cast(xNumPropSet->getPropertyValue( "IsAutomatic" ).getValue()); + bAdd = *o3tl::doGet(xNumPropSet->getPropertyValue( "IsAutomatic" )); // Check on outline style (#i73361#) if ( bAdd && xNumPropSet->getPropertySetInfo() ->hasPropertyByName( "NumberingIsOutline" ) ) { - bAdd = !(*static_cast(xNumPropSet->getPropertyValue( "NumberingIsOutline" ).getValue())); + bAdd = !(*o3tl::doGet(xNumPropSet->getPropertyValue( "NumberingIsOutline" ))); } } else @@ -2503,13 +2506,13 @@ void XMLTextParagraphExport::exportTextMark( // start, end, or point-reference? sal_Int8 nElement; - if( *static_cast(rPropSet->getPropertyValue(sIsCollapsed).getValue()) ) + if( *o3tl::doGet(rPropSet->getPropertyValue(sIsCollapsed)) ) { nElement = 0; } else { - nElement = *static_cast(rPropSet->getPropertyValue(sIsStart).getValue()) ? 1 : 2; + nElement = *o3tl::doGet(rPropSet->getPropertyValue(sIsStart)) ? 1 : 2; } // bookmark, bookmark-start: xml:id and RDFa for RDF metadata @@ -2669,7 +2672,7 @@ XMLShapeExportFlags XMLTextParagraphExport::addTextFrameAttributes( bool bSyncWidth = false; if( xPropSetInfo->hasPropertyByName( sIsSyncWidthToHeight ) ) { - bSyncWidth = *static_cast(rPropSet->getPropertyValue( sIsSyncWidthToHeight ).getValue()); + bSyncWidth = *o3tl::doGet(rPropSet->getPropertyValue( sIsSyncWidthToHeight )); if( bSyncWidth ) GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_REL_WIDTH, XML_SCALE ); @@ -2697,7 +2700,7 @@ XMLShapeExportFlags XMLTextParagraphExport::addTextFrameAttributes( bool bSyncHeight = false; if( xPropSetInfo->hasPropertyByName( sIsSyncHeightToWidth ) ) { - bSyncHeight = *static_cast(rPropSet->getPropertyValue( sIsSyncHeightToWidth ).getValue()); + bSyncHeight = *o3tl::doGet(rPropSet->getPropertyValue( sIsSyncHeightToWidth )); } sal_Int16 nRelHeight = 0; if( !bSyncHeight && xPropSetInfo->hasPropertyByName( sRelativeHeight ) ) @@ -2964,7 +2967,7 @@ void XMLTextParagraphExport::exportContour( if( rPropSetInfo->hasPropertyByName( sIsPixelContour ) ) { - bPixel = *static_cast(rPropSet->getPropertyValue( sIsPixelContour ).getValue()); + bPixel = *o3tl::doGet(rPropSet->getPropertyValue( sIsPixelContour )); } // svg: width @@ -3026,8 +3029,8 @@ void XMLTextParagraphExport::exportContour( if( rPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) { - bool bTmp = *static_cast(rPropSet->getPropertyValue( - sIsAutomaticContour ).getValue()); + bool bTmp = *o3tl::doGet(rPropSet->getPropertyValue( + sIsAutomaticContour )); GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_RECREATE_ON_EDIT, bTmp ? XML_TRUE : XML_FALSE ); } @@ -3247,7 +3250,7 @@ bool XMLTextParagraphExport::addHyperlinkAttributes( && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sServerMap ) ) ) { - bServerMap = *static_cast(rPropSet->getPropertyValue( sServerMap ).getValue()); + bServerMap = *o3tl::doGet(rPropSet->getPropertyValue( sServerMap )); if ( bServerMap ) bExport = true; } @@ -3624,11 +3627,11 @@ void XMLTextParagraphExport::exportRuby( bool bAutoStyles ) { // early out: a collapsed ruby makes no sense - if (*static_cast(rPropSet->getPropertyValue(sIsCollapsed).getValue())) + if (*o3tl::doGet(rPropSet->getPropertyValue(sIsCollapsed))) return; // start value ? - bool bStart = *static_cast(rPropSet->getPropertyValue(sIsStart).getValue()); + bool bStart = *o3tl::doGet(rPropSet->getPropertyValue(sIsStart)); if (bAutoStyles) { diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index 6d3a22735d73..3d4d2fbfee5f 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include @@ -351,7 +354,7 @@ bool XMLOpaquePropHdl_Impl::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - if( *static_cast(rValue.getValue()) ) + if( *o3tl::doGet(rValue) ) rStrExpValue = GetXMLToken( XML_FOREGROUND ); else rStrExpValue = GetXMLToken( XML_BACKGROUND ); @@ -401,7 +404,7 @@ bool XMLContourModePropHdl_Impl::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - if( *static_cast(rValue.getValue()) ) + if( *o3tl::doGet(rValue) ) rStrExpValue = GetXMLToken( XML_OUTSIDE ); else rStrExpValue = GetXMLToken( XML_FULL ); @@ -454,7 +457,7 @@ bool XMLParagraphOnlyPropHdl_Impl::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - if( *static_cast(rValue.getValue()) ) + if( *o3tl::doGet(rValue) ) rStrExpValue = GetXMLToken( XML_1 ); else rStrExpValue = GetXMLToken( XML_NO_LIMIT ); @@ -580,7 +583,7 @@ bool XMLFrameProtectPropHdl_Impl::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - if( *static_cast(rValue.getValue()) ) + if( *o3tl::doGet(rValue) ) { if( rStrExpValue.isEmpty() || IsXMLToken( rStrExpValue, XML_NONE ) ) @@ -822,7 +825,7 @@ bool XMLGrfMirrorPropHdl_Impl::exportXML( const Any& rValue, const SvXMLUnitConverter& ) const { - if( *static_cast(rValue.getValue()) ) + if( *o3tl::doGet(rValue) ) { if( rStrExpValue.isEmpty() || IsXMLToken( rStrExpValue, XML_NONE ) ) @@ -1097,7 +1100,7 @@ bool XMLTextSyncWidthHeightPropHdl_Impl::exportXML( const SvXMLUnitConverter& ) const { bool bRet = false; - if( *static_cast(rValue.getValue()) ) + if( *o3tl::doGet(rValue) ) { rStrExpValue = sValue; bRet = true; diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx index eb748ea87696..ccd3a4c8a39a 100644 --- a/xmloff/source/text/txtstyli.cxx +++ b/xmloff/source/text/txtstyli.cxx @@ -39,6 +39,8 @@ #include #include +#include + #include #include @@ -482,7 +484,7 @@ void XMLTextStyleContext::FillPropertySet( if ( nIndex != -1 ) { Any& rAny = GetProperties()[nIndex].maValue; - bool bVal = *static_cast(rAny.getValue()); + bool bVal = *o3tl::doGet(rAny); bHasCombinedCharactersLetter = bVal; } -- cgit