basctl/source/basicide/baside3.cxx | 3 ++- basctl/source/dlged/dlged.cxx | 20 ++++++++------------ basctl/source/dlged/dlgedobj.cxx | 3 +-- basctl/source/dlged/managelang.cxx | 3 ++- include/com/sun/star/uno/Sequence.hxx | 3 ++- include/comphelper/sequence.hxx | 10 ++++++---- include/oox/helper/containerhelper.hxx | 3 ++- include/toolkit/helper/macros.hxx | 2 +- include/vbahelper/vbahelperinterface.hxx | 7 +------ 9 files changed, 25 insertions(+), 29 deletions(-)
New commits: commit dd97bfce9900e6bae40eece36124f8b22e70ff47 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Oct 28 16:03:49 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Oct 28 20:09:27 2021 +0200 Prepare for removal of non-const operator[] from Sequence in basctl Change-Id: Icc6ea4eea08a1cd3fffbfb211f420ab91602e8de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124336 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 085228971eae..23eb5ab1e0eb 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -1010,13 +1010,14 @@ bool implImportDialog(weld::Window* pWin, const ScriptDocument& rDocument, const if( nOnlyInImportLanguageCount > 1 ) { Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 ); + auto pRemainingLocaleSeq = aRemainingLocaleSeq.getArray(); lang::Locale aTmpLocale; int iSeq = 0; for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i ) { aTmpLocale = aOnlyInImportLanguages[i]; if( !localesAreEqual( aFirstLocale, aTmpLocale ) ) - aRemainingLocaleSeq[iSeq++] = aTmpLocale; + pRemainingLocaleSeq[iSeq++] = aTmpLocale; } pCurMgr->handleAddLocales( aRemainingLocaleSeq ); } diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 203fa9cc44b9..13ff7a17ca36 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -182,8 +182,14 @@ DlgEditor::DlgEditor ( ,pVScroll(nullptr) ,pDlgEdModel(new DlgEdModel()) ,pDlgEdPage(new DlgEdPage(*pDlgEdModel)) - ,m_ClipboardDataFlavors(1) - ,m_ClipboardDataFlavorsResource(2) + // set clipboard data flavors + ,m_ClipboardDataFlavors{ { /* MimeType */ "application/vnd.sun.xml.dialog", + /* HumanPresentableName */ "Dialog 6.0", + /* DataType */ cppu::UnoType<Sequence< sal_Int8 >>::get() } } + ,m_ClipboardDataFlavorsResource{ m_ClipboardDataFlavors[0], + { /* MimeType */ "application/vnd.sun.xml.dialogwithresource", + /* HumanPresentableName */ "Dialog 8.0", + /* DataType */ cppu::UnoType<Sequence< sal_Int8 >>::get() } } ,pObjFac(new DlgEdFactory(xModel)) ,rWindow(rWindow_) ,pFunc(new DlgEdFuncSelect(*this)) @@ -207,16 +213,6 @@ DlgEditor::DlgEditor ( pDlgEdModel->InsertPage(pDlgEdPage); - // set clipboard data flavors - m_ClipboardDataFlavors[0].MimeType = "application/vnd.sun.xml.dialog" ; - m_ClipboardDataFlavors[0].HumanPresentableName = "Dialog 6.0" ; - m_ClipboardDataFlavors[0].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - - m_ClipboardDataFlavorsResource[0] = m_ClipboardDataFlavors[0]; - m_ClipboardDataFlavorsResource[1].MimeType = "application/vnd.sun.xml.dialogwithresource" ; - m_ClipboardDataFlavorsResource[1].HumanPresentableName = "Dialog 8.0" ; - m_ClipboardDataFlavorsResource[1].DataType = cppu::UnoType<Sequence< sal_Int8 >>::get(); - aMarkIdle.SetInvokeHandler( LINK( this, DlgEditor, MarkTimeout ) ); rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) ); diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 6353ddf9ecd6..c9ae1de4ae6e 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -1685,8 +1685,7 @@ void DlgEdObj::MakeDataAware( const Reference< frame::XModel >& xModel ) aValue.Name = "BoundCell"; aValue.Value <<= aApiAddress; - Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= aValue; + Sequence< Any > aArgs{ Any(aValue) }; if ( xBindable.is() ) { diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx index d36c23803e7a..c7cd423cccee 100644 --- a/basctl/source/dlged/managelang.cxx +++ b/basctl/source/dlged/managelang.cxx @@ -162,12 +162,13 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void) int nPos = m_xLanguageLB->get_selected_index(); // remove locales Sequence< Locale > aLocaleSeq( nCount ); + auto aLocaleSeqRange = asNonConstRange(aLocaleSeq); for (int i = 0; i < nCount; ++i) { const sal_Int32 nSelPos = aSelection[i]; LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64()); if ( pEntry ) - aLocaleSeq[i] = pEntry->m_aLocale; + aLocaleSeqRange[i] = pEntry->m_aLocale; } m_xLocalizationMgr->handleRemoveLocales( aLocaleSeq ); // update listbox commit c131f32fcfff1208adc38536839bc5168fcb7487 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Oct 28 15:57:38 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Oct 28 20:09:19 2021 +0200 Prepare for removal of non-const operator[] from Sequence in include Change-Id: I85ca453f3add5ac5b59dc6f1ccb2cdb55f0a463c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124333 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx index 5356872b1378..73e51a9bc7f5 100644 --- a/include/com/sun/star/uno/Sequence.hxx +++ b/include/com/sun/star/uno/Sequence.hxx @@ -295,8 +295,9 @@ template <class E> inline auto asNonConstRange(css::uno::Sequence<E>& s) // These allow to pass it as range-expression to range-based for loops E* begin() { return std::pair<E*, E*>::first; } E* end() { return std::pair<E*, E*>::second; } + E& operator[](sal_Int32 i) { assert(i >= 0 && i < end() - begin()); return begin()[i]; } }; - return SequenceRange(s.getArray(), s.getLength()); + return SequenceRange(s.getLength() ? s.getArray() : nullptr, s.getLength()); }; /// @endcond diff --git a/include/comphelper/sequence.hxx b/include/comphelper/sequence.hxx index ada6ee27b4ef..a42ef2d2f341 100644 --- a/include/comphelper/sequence.hxx +++ b/include/comphelper/sequence.hxx @@ -64,7 +64,8 @@ namespace comphelper sal_Int32 n1 = left.getLength(); css::uno::Sequence<T> ret(n1 + right.getLength()); //TODO: check for overflow - std::copy_n(left.getConstArray(), n1, ret.getArray()); + auto pRet = ret.getArray(); + std::copy_n(left.getConstArray(), n1, pRet); sal_Int32 n2 = n1; for (sal_Int32 i = 0; i != right.getLength(); ++i) { bool found = false; @@ -75,7 +76,7 @@ namespace comphelper } } if (!found) { - ret[n2++] = right[i]; + pRet[n2++] = right[i]; } } ret.realloc(n2); @@ -181,8 +182,9 @@ namespace comphelper template < typename DstElementType, typename SrcType > inline css::uno::Sequence< DstElementType > containerToSequence( const SrcType& i_Container ) { - css::uno::Sequence< DstElementType > result( ::std::size(i_Container) ); - ::std::copy( ::std::begin(i_Container), ::std::end(i_Container), result.getArray() ); + using ::std::size, ::std::begin, ::std::end; + css::uno::Sequence< DstElementType > result( size(i_Container) ); + ::std::copy( begin(i_Container), end(i_Container), result.getArray() ); return result; } diff --git a/include/oox/helper/containerhelper.hxx b/include/oox/helper/containerhelper.hxx index 256719c5334e..10af6995f52c 100644 --- a/include/oox/helper/containerhelper.hxx +++ b/include/oox/helper/containerhelper.hxx @@ -282,8 +282,9 @@ template< typename MatrixType > if( !rMatrix.empty() ) { aSeq.realloc( static_cast< sal_Int32 >( rMatrix.height() ) ); + auto pSeq = aSeq.getArray(); for( size_t nRow = 0, nHeight = rMatrix.height(); nRow < nHeight; ++nRow ) - aSeq[ static_cast< sal_Int32 >( nRow ) ] = + pSeq[ static_cast< sal_Int32 >( nRow ) ] = css::uno::Sequence< ValueType >( &rMatrix.row_front( nRow ), static_cast< sal_Int32 >( rMatrix.width() ) ); } return aSeq; diff --git a/include/toolkit/helper/macros.hxx b/include/toolkit/helper/macros.hxx index cd121bc0998d..a04815ebaf20 100644 --- a/include/toolkit/helper/macros.hxx +++ b/include/toolkit/helper/macros.hxx @@ -149,7 +149,7 @@ IMPL_LISTENERMULTIPLEXER_LISTENERMETHOD_BODY( ClassName, InterfaceName, MethodNa { \ css::uno::Sequence< OUString > aNames = BaseClass::getSupportedServiceNames( ); \ aNames.realloc( aNames.getLength() + 1 ); \ - aNames[ aNames.getLength() - 1 ] = ServiceName; \ + aNames.getArray()[ aNames.getLength() - 1 ] = ServiceName; \ return aNames; \ } \ diff --git a/include/vbahelper/vbahelperinterface.hxx b/include/vbahelper/vbahelperinterface.hxx index 0bbf18992ec3..c7fb615b1f5a 100644 --- a/include/vbahelper/vbahelperinterface.hxx +++ b/include/vbahelper/vbahelperinterface.hxx @@ -132,12 +132,7 @@ OUString classname::getServiceImplName() \ } \ css::uno::Sequence< OUString > classname::getServiceNames() \ { \ - static css::uno::Sequence< OUString > saServiceNames; \ - if( saServiceNames.getLength() == 0 ) \ - { \ - saServiceNames.realloc( 1 ); \ - saServiceNames[ 0 ] = servicename; \ - } \ + static const css::uno::Sequence< OUString > saServiceNames { servicename }; \ return saServiceNames; \ }