chart2/source/controller/main/ChartController_Window.cxx | 8 ++--- chart2/source/tools/ObjectIdentifier.cxx | 5 +-- chart2/source/tools/RangeHighlighter.cxx | 7 +--- connectivity/source/commontools/dbtools.cxx | 4 -- framework/source/fwe/helper/actiontriggerhelper.cxx | 21 +++----------- include/xmloff/SettingsExportHelper.hxx | 3 +- sc/source/ui/unoobj/funcuno.cxx | 3 -- sc/source/ui/vba/vbarange.cxx | 2 - sd/source/ui/animations/CustomAnimationPane.cxx | 17 +++-------- sd/source/ui/unoidl/unopback.cxx | 3 -- svx/source/unodraw/unoshap2.cxx | 8 ++--- sw/source/core/unocore/unodraw.cxx | 6 +--- xmloff/source/core/SettingsExportHelper.cxx | 22 ++++----------- xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx | 6 ---- xmloff/source/text/XMLAutoTextEventImport.cxx | 8 +---- 15 files changed, 37 insertions(+), 86 deletions(-)
New commits: commit d251b5b65a4b250f97542a2a26c14081724aebc0 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Nov 7 13:43:20 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Nov 8 05:34:48 2024 +0100 Simplify a bit And drop unneeded solar mutex locks, that were used when the menu implementation was accessed directly. Change-Id: I06d3d872343fdd6204b4e8bbd8bcec67c17fdbe6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176199 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx index 9caead9f98e4..1369efcf6b7e 100644 --- a/framework/source/fwe/helper/actiontriggerhelper.cxx +++ b/framework/source/fwe/helper/actiontriggerhelper.cxx @@ -67,19 +67,13 @@ static void GetMenuItemAttributes( const Reference< XPropertySet >& xActionTrigg Reference< XBitmap >& xBitmap, Reference< XIndexContainer >& xSubContainer ) { - Any a; - try { // mandatory properties - a = xActionTriggerPropertySet->getPropertyValue(u"Text"_ustr); - a >>= aMenuLabel; - a = xActionTriggerPropertySet->getPropertyValue(u"CommandURL"_ustr); - a >>= aCommandURL; - a = xActionTriggerPropertySet->getPropertyValue(u"Image"_ustr); - a >>= xBitmap; - a = xActionTriggerPropertySet->getPropertyValue(u"SubContainer"_ustr); - a >>= xSubContainer; + xActionTriggerPropertySet->getPropertyValue(u"Text"_ustr) >>= aMenuLabel; + xActionTriggerPropertySet->getPropertyValue(u"CommandURL"_ustr) >>= aCommandURL; + xActionTriggerPropertySet->getPropertyValue(u"Image"_ustr) >>= xBitmap; + xActionTriggerPropertySet->getPropertyValue(u"SubContainer"_ustr) >>= xSubContainer; } catch (const Exception&) { @@ -88,8 +82,7 @@ static void GetMenuItemAttributes( const Reference< XPropertySet >& xActionTrigg // optional properties try { - a = xActionTriggerPropertySet->getPropertyValue(u"HelpURL"_ustr); - a >>= aHelpURL; + xActionTriggerPropertySet->getPropertyValue(u"HelpURL"_ustr) >>= aHelpURL; } catch (const Exception&) { @@ -115,7 +108,6 @@ static void InsertSubMenuItems(const Reference<XPopupMenu>& rSubMenu, sal_uInt16 if ( IsSeparator( xPropSet )) { // Separator - SolarMutexGuard aGuard; rSubMenu->insertSeparator(i); } else @@ -130,7 +122,6 @@ static void InsertSubMenuItems(const Reference<XPopupMenu>& rSubMenu, sal_uInt16 sal_uInt16 nNewItemId = nItemId++; GetMenuItemAttributes( xPropSet, aLabel, aCommandURL, aHelpURL, xBitmap, xSubContainer ); - SolarMutexGuard aGuard; { // insert new menu item sal_Int32 nIndex = aCommandURL.indexOf( aSlotURL ); @@ -303,8 +294,6 @@ static Reference< XIndexContainer > CreateActionTriggerContainer( const Referenc static void FillActionTriggerContainerWithMenu(const Reference<XPopupMenu>& rMenu, const Reference<XIndexContainer>& rActionTriggerContainer) { - SolarMutexGuard aGuard; - for (sal_uInt16 nPos = 0, nCount = rMenu->getItemCount(); nPos < nCount; ++nPos) { sal_uInt16 nItemId = rMenu->getItemId(nPos); commit d833992e7e06f7d385fca6ffe35ce66b79360a63 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Nov 7 02:27:54 2024 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Nov 8 05:34:37 2024 +0100 Avoid checking exact interface type of Any value Change-Id: Ic883c3a9fd8eb87469aec6b6570a39aadf575c3e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176184 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index a4e54a5fd13e..b0fbf6a25cb4 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1644,8 +1644,7 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) if ( rSelection.hasValue() ) { - const uno::Type& rType = rSelection.getValueType(); - if ( rType == cppu::UnoType< OUString >::get() ) + if (rSelection.getValueType() == cppu::UnoType<OUString>::get()) { OUString aNewCID; if ( ( rSelection >>= aNewCID ) && m_aSelection.setSelection( aNewCID ) ) @@ -1653,10 +1652,9 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) bSuccess = true; } } - else if ( rType == cppu::UnoType<drawing::XShape>::get() ) + else if (uno::Reference<drawing::XShape> xShape; rSelection >>= xShape) { - uno::Reference< drawing::XShape > xShape; - if ( ( rSelection >>= xShape ) && m_aSelection.setSelection( xShape ) ) + if (m_aSelection.setSelection(xShape)) { bSuccess = true; } diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 1e4e2764d063..7e6314b15c69 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -239,12 +239,11 @@ ObjectIdentifier::ObjectIdentifier( const Reference< drawing::XShape >& rxShape ObjectIdentifier::ObjectIdentifier( const Any& rAny ) { - const uno::Type& rType = rAny.getValueType(); - if ( rType == cppu::UnoType<OUString>::get() ) + if (rAny.getValueType() == cppu::UnoType<OUString>::get()) { rAny >>= m_aObjectCID; } - else if ( rType == cppu::UnoType< drawing::XShape >::get() ) + else { rAny >>= m_xAdditionalShape; } diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx index eb3dffb2bdcc..63c8809be081 100644 --- a/chart2/source/tools/RangeHighlighter.cxx +++ b/chart2/source/tools/RangeHighlighter.cxx @@ -100,9 +100,8 @@ void RangeHighlighter::determineRanges() m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( m_xChartModel ); uno::Any aSelection( m_xSelectionSupplier->getSelection()); - const uno::Type& rType = aSelection.getValueType(); - if ( rType == cppu::UnoType<OUString>::get() ) + if (aSelection.getValueType() == cppu::UnoType<OUString>::get()) { // @todo??: maybe getSelection() should return a model object rather than a CID @@ -169,11 +168,9 @@ void RangeHighlighter::determineRanges() } } } - else if ( rType == cppu::UnoType< drawing::XShape >::get() ) + else if (Reference<drawing::XShape> xShape; aSelection >>= xShape) { // #i12587# support for shapes in chart - Reference< drawing::XShape > xShape; - aSelection >>= xShape; if ( xShape.is() ) { return; diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 33f1ecd14a7b..f9d54236e4b4 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -1603,10 +1603,8 @@ bool implSetObject( const Reference< XParameters >& _rxParameters, break; case TypeClass_INTERFACE: - if (_rValue.getValueType() == cppu::UnoType<XInputStream>::get()) + if (Reference<XInputStream> xStream; _rValue >>= xStream) { - Reference< XInputStream > xStream; - _rValue >>= xStream; _rxParameters->setBinaryStream(_nColumnIndex, xStream, xStream->available()); break; } diff --git a/include/xmloff/SettingsExportHelper.hxx b/include/xmloff/SettingsExportHelper.hxx index fa3bdf21b357..6e9a4769c9af 100644 --- a/include/xmloff/SettingsExportHelper.hxx +++ b/include/xmloff/SettingsExportHelper.hxx @@ -31,6 +31,7 @@ namespace com::sun::star::beans { struct PropertyValue; } namespace com::sun::star::formula { struct SymbolDescriptor; } +namespace com::sun::star::i18n { class XForbiddenCharacters; } namespace com::sun::star::util { class XStringSubstitution; } namespace com @@ -85,7 +86,7 @@ class UNLESS_MERGELIBS_MORE(XMLOFF_DLLPUBLIC) XMLSettingsExportHelper const css::uno::Sequence < css::formula::SymbolDescriptor > &rProps, const OUString& rName) const; void exportForbiddenCharacters( - const css::uno::Any &rAny, + const css::uno::Reference<css::i18n::XForbiddenCharacters>& xForbChars, const OUString& rName) const; public: diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx index 46ff71b0c731..82ad1eeab815 100644 --- a/sc/source/ui/unoobj/funcuno.cxx +++ b/sc/source/ui/unoobj/funcuno.cxx @@ -581,11 +581,10 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const OUString& aName, { ArrayOfArrayProc<uno::Any>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow ); } - else if ( aType.equals( cppu::UnoType<table::XCellRange>::get()) ) + else if (uno::Reference<table::XCellRange> xRange; rArg >>= xRange) { // currently, only our own cell ranges are supported - uno::Reference<table::XCellRange> xRange(rArg, uno::UNO_QUERY); ScCellRangesBase* pImpl = dynamic_cast<ScCellRangesBase*>( xRange.get() ); if ( pImpl ) { diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index af9858e5dba4..433b069fa6d0 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -3352,7 +3352,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L static uno::Reference< table::XCellRange > processKey( const uno::Any& Key, const uno::Reference< uno::XComponentContext >& xContext, ScDocShell* pDocSh ) { uno::Reference< excel::XRange > xKeyRange; - if ( Key.getValueType() == cppu::UnoType<excel::XRange>::get() ) + if (Key.getValueTypeClass() == css::uno::TypeClass_INTERFACE) { xKeyRange.set( Key, uno::UNO_QUERY_THROW ); } diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index b0075ad75a71..528e53e9d86d 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -1647,10 +1647,8 @@ void CustomAnimationPane::onChangeCurrentPage() } } -static bool getTextSelection( const Any& rSelection, Reference< XShape >& xShape, std::vector< sal_Int16 >& rParaList ) +static bool getTextSelection(const Reference< XTextRange >& xSelectedText, Reference< XShape >& xShape, std::vector< sal_Int16 >& rParaList ) { - Reference< XTextRange > xSelectedText; - rSelection >>= xSelectedText; if( xSelectedText.is() ) try { xShape.set( xSelectedText->getText(), UNO_QUERY_THROW ); @@ -1739,11 +1737,8 @@ void CustomAnimationPane::onAdd() // gather shapes from the selection maViewSelection = mxView->getSelection(); - if( maViewSelection.getValueType() == cppu::UnoType<XShapes>::get()) + if (Reference<XIndexAccess> xShapes; maViewSelection >>= xShapes) { - Reference< XIndexAccess > xShapes; - maViewSelection >>= xShapes; - sal_Int32 nCount = xShapes->getCount(); aTargets.reserve( nCount ); for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) @@ -1759,19 +1754,17 @@ void CustomAnimationPane::onAdd() } } } - else if ( maViewSelection.getValueType() == cppu::UnoType<XShape>::get()) + else if (Reference<XText> xText; maViewSelection >>= xText) { aTargets.push_back( maViewSelection ); - Reference< XText > xText; - maViewSelection >>= xText; if( !xText.is() || xText->getString().isEmpty() ) bHasText = false; } - else if ( maViewSelection.getValueType() == cppu::UnoType<XTextCursor>::get()) + else if (Reference<XTextCursor> xCursor; maViewSelection >>= xCursor) { Reference< XShape > xShape; std::vector< sal_Int16 > aParaList; - if( getTextSelection( maViewSelection, xShape, aParaList ) ) + if (getTextSelection(xCursor, xShape, aParaList)) { ParagraphTarget aParaTarget; aParaTarget.Shape = std::move(xShape); diff --git a/sd/source/ui/unoidl/unopback.cxx b/sd/source/ui/unoidl/unopback.cxx index 278ed2abd4ee..c4fc95421dc4 100644 --- a/sd/source/ui/unoidl/unopback.cxx +++ b/sd/source/ui/unoidl/unopback.cxx @@ -138,8 +138,7 @@ void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) case XATTR_FILLBITMAP : { if (pProp->nMemberId == MID_BITMAP && - (pAny->getValueType() == cppu::UnoType<css::awt::XBitmap>::get() || - pAny->getValueType() == cppu::UnoType<css::graphic::XGraphic>::get())) + (pAny->getValueTypeClass() == css::uno::TypeClass_INTERFACE)) { setPropertyValue( aPropertyName, *pAny ); } diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index 21607afa8a74..bb2707af781c 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1196,21 +1196,19 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte bOk = true; } } - else if (rValue.getValueType() == cppu::UnoType<graphic::XGraphic>::get()) + else if (uno::Reference<graphic::XGraphic> xGraphic; rValue >>= xGraphic) { - auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>(); if (xGraphic.is()) { static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(Graphic(xGraphic)); bOk = true; } } - else if (rValue.getValueType() == cppu::UnoType<awt::XBitmap>::get()) + else if (uno::Reference<awt::XBitmap> xBitmap; rValue >>= xBitmap) { - auto xBitmap = rValue.get<uno::Reference<awt::XBitmap>>(); if (xBitmap.is()) { - uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY); + xGraphic.set(xBitmap, uno::UNO_QUERY); Graphic aGraphic(xGraphic); static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic); bOk = true; diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 7b5b8f392630..d5b0a60f32b2 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1185,10 +1185,8 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a } else if (pEntry->nMemberId == MID_TEXT_BOX_CONTENT) { - if (aValue.getValueType() - == cppu::UnoType<uno::Reference<text::XTextFrame>>::get()) - SwTextBoxHelper::set(pFormat, pObj, - aValue.get<uno::Reference<text::XTextFrame>>()); + if (uno::Reference<text::XTextFrame> xTextFrame; aValue >>= xTextFrame) + SwTextBoxHelper::set(pFormat, pObj, xTextFrame); else SAL_WARN( "sw.uno", "This is not a TextFrame!" ); } diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx index 91b4ce443561..3f6f87fa1bbb 100644 --- a/xmloff/source/core/SettingsExportHelper.cxx +++ b/xmloff/source/core/SettingsExportHelper.cxx @@ -143,18 +143,12 @@ void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny, aAny >>= aProps; exportbase64Binary(aProps, rName); } - else if (aType.equals(cppu::UnoType<container::XNameContainer>::get()) || - aType.equals(cppu::UnoType<container::XNameAccess>::get())) + else if (uno::Reference<container::XNameAccess> aNamed; aAny >>= aNamed) { - uno::Reference< container::XNameAccess> aNamed; - aAny >>= aNamed; exportNameAccess(aNamed, rName); } - else if (aType.equals(cppu::UnoType<container::XIndexAccess>::get()) || - aType.equals(cppu::UnoType<container::XIndexContainer>::get()) ) + else if (uno::Reference<container::XIndexAccess> aIndexed; aAny >>= aIndexed) { - uno::Reference<container::XIndexAccess> aIndexed; - aAny >>= aIndexed; exportIndexAccess(aIndexed, rName); } else if (aType.equals(cppu::UnoType<util::DateTime>::get()) ) @@ -163,9 +157,9 @@ void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny, aAny >>= aDateTime; exportDateTime(aDateTime, rName); } - else if( aType.equals(cppu::UnoType<i18n::XForbiddenCharacters>::get()) ) + else if (uno::Reference<i18n::XForbiddenCharacters> xForbChars; aAny >>= xForbChars) { - exportForbiddenCharacters( aAny, rName ); + exportForbiddenCharacters(xForbChars, rName); } else if( aType.equals(cppu::UnoType<uno::Sequence<formula::SymbolDescriptor>>::get() ) ) { @@ -416,14 +410,10 @@ void XMLSettingsExportHelper::exportIndexAccess( } void XMLSettingsExportHelper::exportForbiddenCharacters( - const uno::Any &rAny, + const uno::Reference<i18n::XForbiddenCharacters>& xForbChars, const OUString& rName) const { - uno::Reference<i18n::XForbiddenCharacters> xForbChars; - uno::Reference<linguistic2::XSupportedLocales> xLocales; - - rAny >>= xForbChars; - rAny >>= xLocales; + uno::Reference<linguistic2::XSupportedLocales> xLocales(xForbChars, css::uno::UNO_QUERY); SAL_WARN_IF( !(xForbChars.is() && xLocales.is()), "xmloff","XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" ); diff --git a/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx b/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx index 78f302db2d27..34c941fa7d26 100644 --- a/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx +++ b/xmloff/source/core/XMLEmbeddedObjectExportFilter.cxx @@ -118,12 +118,8 @@ void SAL_CALL XMLEmbeddedObjectExportFilter::initialize( { for( const auto& rAny : aArguments ) { - if( rAny.getValueType() == - cppu::UnoType<XDocumentHandler>::get()) - { - rAny >>= xHandler; + if (rAny >>= xHandler) rAny >>= xExtHandler; - } } } diff --git a/xmloff/source/text/XMLAutoTextEventImport.cxx b/xmloff/source/text/XMLAutoTextEventImport.cxx index c814ba370ed3..c6f5940a63ba 100644 --- a/xmloff/source/text/XMLAutoTextEventImport.cxx +++ b/xmloff/source/text/XMLAutoTextEventImport.cxx @@ -52,18 +52,14 @@ void XMLAutoTextEventImport::initialize(const Sequence<Any>& rArguments) for (const auto& rArgument : rArguments) { - const Type& rType = rArgument.getValueType(); - if (rType == cppu::UnoType<XEventsSupplier>::get()) + if (Reference<XEventsSupplier> xSupplier; rArgument >>= xSupplier) { - Reference<XEventsSupplier> xSupplier; - rArgument >>= xSupplier; DBG_ASSERT(xSupplier.is(), "need XEventsSupplier or XNameReplace"); xEvents = xSupplier->getEvents(); } - else if (rType == cppu::UnoType<XNameReplace>::get()) + else if (rArgument >>= xEvents) { - rArgument >>= xEvents; DBG_ASSERT(xEvents.is(), "need XEventsSupplier or XNameReplace"); } }
