editeng/source/items/xmlcnitm.cxx | 18 ++----- editeng/source/misc/acorrcfg.cxx | 95 +++++++++++++++++++------------------- editeng/source/uno/unoipset.cxx | 21 ++++---- 3 files changed, 66 insertions(+), 68 deletions(-)
New commits: commit fb7b701c189a1b479dde6cc5a30c612825ce4bf7 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 13 12:10:27 2016 +0200 Clean up uses of Any::getValue() in editeng Change-Id: I2bce1aba3e01e5c8d67d47b88cddca1f7ad37a93 diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx index f832890..96cbd49 100644 --- a/editeng/source/items/xmlcnitm.cxx +++ b/editeng/source/items/xmlcnitm.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/xml/AttributeData.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> +#include <o3tl/any.hxx> #include <xmloff/xmlcnimp.hxx> #include <xmloff/unoatrcn.hxx> #include <editeng/xmlcnitm.hxx> @@ -80,16 +81,11 @@ bool SvXMLAttrContainerItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMembe bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) { - Reference<XInterface> xRef; SvUnoAttributeContainer* pContainer = nullptr; - if( rVal.getValue() != nullptr && rVal.getValueType().getTypeClass() == TypeClass_INTERFACE ) - { - xRef = *static_cast<Reference<XInterface> const *>(rVal.getValue()); - Reference<XUnoTunnel> xTunnel(xRef, UNO_QUERY); - if( xTunnel.is() ) - pContainer = reinterpret_cast<SvUnoAttributeContainer*>((sal_uLong)xTunnel->getSomething(SvUnoAttributeContainer::getUnoTunnelId())); - } + Reference<XUnoTunnel> xTunnel(rVal, UNO_QUERY); + if( xTunnel.is() ) + pContainer = reinterpret_cast<SvUnoAttributeContainer*>((sal_uLong)xTunnel->getSomething(SvUnoAttributeContainer::getUnoTunnelId())); if( pContainer ) { @@ -101,7 +97,7 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM try { - Reference<XNameContainer> xContainer( xRef, UNO_QUERY ); + Reference<XNameContainer> xContainer( rVal, UNO_QUERY ); if( !xContainer.is() ) return false; @@ -116,10 +112,10 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM const OUString aName( *pNames++ ); aAny = xContainer->getByName( aName ); - if( aAny.getValue() == nullptr || aAny.getValueType() != cppu::UnoType<AttributeData>::get() ) + auto pData = o3tl::tryAccess<AttributeData>(aAny); + if( !pData ) return false; - AttributeData const * pData = static_cast<AttributeData const *>(aAny.getValue()); sal_Int32 pos = aName.indexOf( ':' ); if( pos != -1 ) { diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx index 7357d45..ac800ee 100644 --- a/editeng/source/misc/acorrcfg.cxx +++ b/editeng/source/misc/acorrcfg.cxx @@ -19,6 +19,7 @@ #include <comphelper/processfactory.hxx> #include <editeng/acorrcfg.hxx> +#include <o3tl/any.hxx> #include <tools/debug.hxx> #include <tools/urlobj.hxx> #include <ucbhelper/content.hxx> @@ -140,51 +141,51 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) switch(nProp) { case 0: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= SaveWordCplSttLst; break;//"Exceptions/TwoCapitalsAtStart", case 1: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= SaveWordWrdSttLst; break;//"Exceptions/CapitalAtStartSentence", case 2: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= Autocorrect; break;//"UseReplacementTable", case 3: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= CapitalStartWord; break;//"TwoCapitalsAtStart", case 4: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= CapitalStartSentence; break;//"CapitalAtStartSentence", case 5: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= ChgWeightUnderl; break;//"ChangeUnderlineWeight", case 6: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= SetINetAttr; break;//"SetInetAttribute", case 7: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= ChgOrdinalNumber; break;//"ChangeOrdinalNumber", case 8: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= AddNonBrkSpace; break;//"AddNonBreakingSpace" case 9: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= ChgToEnEmDash; break;//"ChangeDash", case 10: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= IgnoreDoubleSpace; break;//"RemoveDoubleSpaces", case 11: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= ChgSglQuotes; break;//"ReplaceSingleQuote", case 12: @@ -198,7 +199,7 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) sal::static_int_cast< sal_Unicode >( nTemp ) ); break;//"SingleQuoteAtEnd", case 14: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= ChgQuotes; break;//"ReplaceDoubleQuote", case 15: @@ -212,7 +213,7 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) sal::static_int_cast< sal_Unicode >( nTemp ) ); break;//"DoubleQuoteAtEnd" case 17: - if(*static_cast<sal_Bool const *>(pValues[nProp].getValue())) + if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= CorrectCapsLock; break;//"CorrectAccidentalCapsLock" } @@ -388,23 +389,23 @@ void SvxSwAutoCorrCfg::Load(bool bInit) { switch(nProp) { - case 0: rParent.bFileRel = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/FileLinks", - case 1: rParent.bNetRel = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/InternetLinks", - case 2: rParent.bAutoTextPreview = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/ShowPreview", - case 3: rParent.bAutoTextTip = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Text/ShowToolTip", - case 4: rParent.bSearchInAllCategories = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; //"Text/SearchInAllCategories" - case 5: rSwFlags.bAutoCorrect = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/UseReplacementTable", - case 6: rSwFlags.bCapitalStartSentence = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/TwoCapitalsAtStart", - case 7: rSwFlags.bCapitalStartWord = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/CapitalAtStartSentence", - case 8: rSwFlags.bChgWeightUnderl = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeUnderlineWeight", - case 9: rSwFlags.bSetINetAttr = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/SetInetAttribute", - case 10: rSwFlags.bChgOrdinalNumber = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeOrdinalNumber", - case 11: rSwFlags.bAddNonBrkSpace = *static_cast<sal_Bool const *>(pValues[nProp].getValue( )); break; // "Format/Option/AddNonBreakingSpace", + case 0: rParent.bFileRel = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/FileLinks", + case 1: rParent.bNetRel = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/InternetLinks", + case 2: rParent.bAutoTextPreview = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/ShowPreview", + case 3: rParent.bAutoTextTip = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/ShowToolTip", + case 4: rParent.bSearchInAllCategories = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Text/SearchInAllCategories" + case 5: rSwFlags.bAutoCorrect = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/UseReplacementTable", + case 6: rSwFlags.bCapitalStartSentence = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/TwoCapitalsAtStart", + case 7: rSwFlags.bCapitalStartWord = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/CapitalAtStartSentence", + case 8: rSwFlags.bChgWeightUnderl = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeUnderlineWeight", + case 9: rSwFlags.bSetINetAttr = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/SetInetAttribute", + case 10: rSwFlags.bChgOrdinalNumber = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeOrdinalNumber", + case 11: rSwFlags.bAddNonBrkSpace = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/AddNonBreakingSpace", // it doesn't exist here - the common flags are used for that -> LM -// case 12: rSwFlags.bChgToEnEmDash = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeDash", - case 13: rSwFlags.bDelEmptyNode = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/DelEmptyParagraphs", - case 14: rSwFlags.bChgUserColl = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ReplaceUserStyle", - case 15: rSwFlags.bChgEnumNum = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/ChangeToBullets/Enable", +// case 12: rSwFlags.bChgToEnEmDash = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeDash", + case 13: rSwFlags.bDelEmptyNode = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelEmptyParagraphs", + case 14: rSwFlags.bChgUserColl = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ReplaceUserStyle", + case 15: rSwFlags.bChgEnumNum = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeToBullets/Enable", case 16: { sal_Int32 nVal = 0; pValues[nProp] >>= nVal; @@ -436,7 +437,7 @@ void SvxSwAutoCorrCfg::Load(bool bInit) rSwFlags.aBulletFont.SetPitch(FontPitch(nVal)); } break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch", - case 21: rSwFlags.bRightMargin = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/CombineParagraphs", + case 21: rSwFlags.bRightMargin = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/CombineParagraphs", case 22: { sal_Int32 nVal = 0; pValues[nProp] >>= nVal; @@ -444,17 +445,17 @@ void SvxSwAutoCorrCfg::Load(bool bInit) sal::static_int_cast< sal_uInt8 >(nVal); } break; // "Format/Option/CombineValue", - case 23: rSwFlags.bAFormatDelSpacesAtSttEnd = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/DelSpacesAtStartEnd", - case 24: rSwFlags.bAFormatDelSpacesBetweenLines = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/Option/DelSpacesBetween", - case 25: rParent.bAutoFmtByInput = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/Enable", - case 26: rSwFlags.bChgToEnEmDash = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ChangeDash", - case 27: rSwFlags.bSetNumRule = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ApplyNumbering/Enable", - case 28: rSwFlags.bSetBorder = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ChangeToBorders", - case 29: rSwFlags.bCreateTable = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ChangeToTable", - case 30: rSwFlags.bReplaceStyles = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/ReplaceStyle", - case 31: rSwFlags.bAFormatByInpDelSpacesAtSttEnd = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/DelSpacesAtStartEnd", - case 32: rSwFlags.bAFormatByInpDelSpacesBetweenLines = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Format/ByInput/DelSpacesBetween", - case 33: rSwFlags.bAutoCompleteWords = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/Enable", + case 23: rSwFlags.bAFormatDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelSpacesAtStartEnd", + case 24: rSwFlags.bAFormatDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelSpacesBetween", + case 25: rParent.bAutoFmtByInput = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/Enable", + case 26: rSwFlags.bChgToEnEmDash = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeDash", + case 27: rSwFlags.bSetNumRule = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ApplyNumbering/Enable", + case 28: rSwFlags.bSetBorder = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToBorders", + case 29: rSwFlags.bCreateTable = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToTable", + case 30: rSwFlags.bReplaceStyles = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ReplaceStyle", + case 31: rSwFlags.bAFormatByInpDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesAtStartEnd", + case 32: rSwFlags.bAFormatByInpDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesBetween", + case 33: rSwFlags.bAutoCompleteWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/Enable", case 34: { sal_Int32 nVal = 0; pValues[nProp] >>= nVal; @@ -469,10 +470,10 @@ void SvxSwAutoCorrCfg::Load(bool bInit) sal::static_int_cast< sal_uInt16 >(nVal); } break; // "Completion/MaxListLen", - case 36: rSwFlags.bAutoCmpltCollectWords = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/CollectWords", - case 37: rSwFlags.bAutoCmpltEndless = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/EndlessList", - case 38: rSwFlags.bAutoCmpltAppendBlanc = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/AppendBlank", - case 39: rSwFlags.bAutoCmpltShowAsTip = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break; // "Completion/ShowAsTip", + case 36: rSwFlags.bAutoCmpltCollectWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/CollectWords", + case 37: rSwFlags.bAutoCmpltEndless = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/EndlessList", + case 38: rSwFlags.bAutoCmpltAppendBlanc = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/AppendBlank", + case 39: rSwFlags.bAutoCmpltShowAsTip = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/ShowAsTip", case 40: { sal_Int32 nVal = 0; pValues[nProp] >>= nVal; @@ -480,7 +481,7 @@ void SvxSwAutoCorrCfg::Load(bool bInit) sal::static_int_cast< sal_uInt16 >(nVal); } break; // "Completion/AcceptKey" - case 41 :rSwFlags.bAutoCmpltKeepList = *static_cast<sal_Bool const *>(pValues[nProp].getValue()); break;//"Completion/KeepList" + case 41 :rSwFlags.bAutoCmpltKeepList = *o3tl::doAccess<bool>(pValues[nProp]); break;//"Completion/KeepList" case 42 : { sal_Int32 nVal = 0; pValues[nProp] >>= nVal; diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index 40677da..3fd6de0 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -26,6 +26,7 @@ #include <editeng/editids.hrc> #include <editeng/editeng.hxx> #include <svl/itempool.hxx> +#include <o3tl/any.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -286,19 +287,19 @@ void SvxUnoConvertToMM( const SfxMapUnit eSourceMapUnit, uno::Any & rMetric ) th switch( rMetric.getValueTypeClass() ) { case uno::TypeClass_BYTE: - rMetric <<= (sal_Int8)(TWIPS_TO_MM(*static_cast<sal_Int8 const *>(rMetric.getValue()))); + rMetric <<= (sal_Int8)(TWIPS_TO_MM(*o3tl::forceAccess<sal_Int8>(rMetric))); break; case uno::TypeClass_SHORT: - rMetric <<= (sal_Int16)(TWIPS_TO_MM(*static_cast<sal_Int16 const *>(rMetric.getValue()))); + rMetric <<= (sal_Int16)(TWIPS_TO_MM(*o3tl::forceAccess<sal_Int16>(rMetric))); break; case uno::TypeClass_UNSIGNED_SHORT: - rMetric <<= (sal_uInt16)(TWIPS_TO_MM(*static_cast<sal_uInt16 const *>(rMetric.getValue()))); + rMetric <<= (sal_uInt16)(TWIPS_TO_MM(*o3tl::forceAccess<sal_uInt16>(rMetric))); break; case uno::TypeClass_LONG: - rMetric <<= (sal_Int32)(TWIPS_TO_MM(*static_cast<sal_Int32 const *>(rMetric.getValue()))); + rMetric <<= (sal_Int32)(TWIPS_TO_MM(*o3tl::forceAccess<sal_Int32>(rMetric))); break; case uno::TypeClass_UNSIGNED_LONG: - rMetric <<= (sal_uInt32)(TWIPS_TO_MM(*static_cast<sal_uInt32 const *>(rMetric.getValue()))); + rMetric <<= (sal_uInt32)(TWIPS_TO_MM(*o3tl::forceAccess<sal_uInt32>(rMetric))); break; default: OSL_FAIL("AW: Missing unit translation to 100th mm!"); @@ -323,19 +324,19 @@ void SvxUnoConvertFromMM( const SfxMapUnit eDestinationMapUnit, uno::Any & rMetr switch( rMetric.getValueTypeClass() ) { case uno::TypeClass_BYTE: - rMetric <<= (sal_Int8)(MM_TO_TWIPS(*static_cast<sal_Int8 const *>(rMetric.getValue()))); + rMetric <<= (sal_Int8)(MM_TO_TWIPS(*o3tl::forceAccess<sal_Int8>(rMetric))); break; case uno::TypeClass_SHORT: - rMetric <<= (sal_Int16)(MM_TO_TWIPS(*static_cast<sal_Int16 const *>(rMetric.getValue()))); + rMetric <<= (sal_Int16)(MM_TO_TWIPS(*o3tl::forceAccess<sal_Int16>(rMetric))); break; case uno::TypeClass_UNSIGNED_SHORT: - rMetric <<= (sal_uInt16)(MM_TO_TWIPS(*static_cast<sal_uInt16 const *>(rMetric.getValue()))); + rMetric <<= (sal_uInt16)(MM_TO_TWIPS(*o3tl::forceAccess<sal_uInt16>(rMetric))); break; case uno::TypeClass_LONG: - rMetric <<= (sal_Int32)(MM_TO_TWIPS(*static_cast<sal_Int32 const *>(rMetric.getValue()))); + rMetric <<= (sal_Int32)(MM_TO_TWIPS(*o3tl::forceAccess<sal_Int32>(rMetric))); break; case uno::TypeClass_UNSIGNED_LONG: - rMetric <<= (sal_uInt32)(MM_TO_TWIPS(*static_cast<sal_uInt32 const *>(rMetric.getValue()))); + rMetric <<= (sal_uInt32)(MM_TO_TWIPS(*o3tl::forceAccess<sal_uInt32>(rMetric))); break; default: OSL_FAIL("AW: Missing unit translation to 100th mm!"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits