diff --git a/svx/inc/shapecollection.hxx b/svx/inc/shapecollection.hxx index 44988281bb75..47eaec2e2e6d 100644 --- a/svx/inc/shapecollection.hxx +++ b/svx/inc/shapecollection.hxx @@ -31,7 +31,7 @@ class SvxShapeCollection final css::lang::XComponent> { private: - std::mutex m_aMutex; + mutable std::mutex m_aMutex; std::vector> maShapeContainer; comphelper::OInterfaceContainerHelper4 maEventListeners; bool bDisposed = false; @@ -67,7 +67,7 @@ public: virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; - void getAllShapes(std::vector>& rShapes) const; + std::vector> getAllShapes() const; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx index 70c9e4e37b2b..29b3f76bf891 100644 --- a/svx/source/accessibility/ChildrenManagerImpl.cxx +++ b/svx/source/accessibility/ChildrenManagerImpl.cxx @@ -871,17 +871,19 @@ void ChildrenManagerImpl::UpdateSelection() if (!xSelectedShape.is() && xSelectedShapeAccess.is()) { sal_Int32 nCount = xSelectedShapeAccess->getCount(); - aSortedSelectedShapes.reserve(nCount); if (auto pSvxShape = dynamic_cast(xSelectedShapeAccess.get())) { - pSvxShape->getAllShapes(aSortedSelectedShapes); + aSortedSelectedShapes = pSvxShape->getAllShapes(); } else + { + aSortedSelectedShapes.reserve(nCount); for (sal_Int32 i = 0; i < nCount; ++i) { css::uno::Reference xShape(xSelectedShapeAccess->getByIndex(i), uno::UNO_QUERY); aSortedSelectedShapes.push_back(xShape); } + } std::sort(aSortedSelectedShapes.begin(), aSortedSelectedShapes.end()); } diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx index b99f6674a371..116247e1916b 100644 --- a/svx/source/unodraw/unoshcol.cxx +++ b/svx/source/unodraw/unoshcol.cxx @@ -147,7 +147,6 @@ sal_Int32 SAL_CALL SvxShapeCollection::getCount() return maShapeContainer.size(); } - uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index ) { if( Index < 0 || Index >= getCount() ) @@ -158,6 +157,12 @@ uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index ) return uno::Any( xShape ); } +std::vector> SvxShapeCollection::getAllShapes() const +{ + std::unique_lock g(m_aMutex); + return maShapeContainer; +} + // XElementAccess uno::Type SAL_CALL SvxShapeCollection::getElementType() { @@ -185,11 +190,6 @@ uno::Sequence< OUString > SAL_CALL SvxShapeCollection::getSupportedServiceNames( return { u"com.sun.star.drawing.Shapes"_ustr, u"com.sun.star.drawing.ShapeCollection"_ustr }; } -void SvxShapeCollection::getAllShapes(std::vector>& rShapes) const -{ - rShapes = maShapeContainer; -} - extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_drawing_SvxShapeCollection_get_implementation( css::uno::XComponentContext *,