[Libreoffice-commits] core.git: extensions/source

Noel Grandin noelgrandin at gmail.com
Fri Apr 1 07:34:32 UTC 2016


 extensions/source/inc/componentmodule.cxx            |   83 ++++++++-----------
 extensions/source/inc/componentmodule.hxx            |    9 +-
 extensions/source/propctrlr/eventhandler.cxx         |   78 +++++++----------
 extensions/source/propctrlr/eventhandler.hxx         |    6 -
 extensions/source/propctrlr/fontdialog.cxx           |   17 +--
 extensions/source/propctrlr/fontdialog.hxx           |    2 
 extensions/source/propctrlr/formcomponenthandler.cxx |   15 +--
 extensions/source/propctrlr/formlinkdialog.cxx       |   40 ++++-----
 extensions/source/propctrlr/formlinkdialog.hxx       |   14 +--
 extensions/source/propctrlr/listselectiondlg.cxx     |   14 +--
 extensions/source/propctrlr/listselectiondlg.hxx     |    2 
 extensions/source/propctrlr/propertycomposer.cxx     |    4 
 extensions/source/update/feed/updatefeed.cxx         |    9 --
 13 files changed, 134 insertions(+), 159 deletions(-)

New commits:
commit 8c8fdb0a668d759adac11bd83203c8eeded390d5
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Sat Feb 13 15:13:10 2016 +0200

    sequence->vector in extensions
    
    Change-Id: Iaf7feae5927795e8b5508f9ef49369fad802a57f
    Reviewed-on: https://gerrit.libreoffice.org/23689
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/extensions/source/inc/componentmodule.cxx b/extensions/source/inc/componentmodule.cxx
index de212fe..da66d2b 100644
--- a/extensions/source/inc/componentmodule.cxx
+++ b/extensions/source/inc/componentmodule.cxx
@@ -140,10 +140,10 @@ namespace COMPMOD_NAMESPACE
     //- registration helper
 
 
-    Sequence< OUString >*                OModule::s_pImplementationNames = nullptr;
-    Sequence< Sequence< OUString > >*    OModule::s_pSupportedServices = nullptr;
-    Sequence< sal_Int64 >*                      OModule::s_pCreationFunctionPointers = nullptr;
-    Sequence< sal_Int64 >*                      OModule::s_pFactoryFunctionPointers = nullptr;
+    std::vector< OUString >*                OModule::s_pImplementationNames = nullptr;
+    std::vector< Sequence< OUString > >*    OModule::s_pSupportedServices = nullptr;
+    std::vector< ComponentInstantiation >*  OModule::s_pCreationFunctionPointers = nullptr;
+    std::vector< FactoryInstantiation >*    OModule::s_pFactoryFunctionPointers = nullptr;
 
 
     void OModule::registerComponent(
@@ -156,29 +156,23 @@ namespace COMPMOD_NAMESPACE
         {
             OSL_ENSURE(!s_pSupportedServices && !s_pCreationFunctionPointers && !s_pFactoryFunctionPointers,
                 "OModule::registerComponent : inconsistent state (the pointers (1)) !");
-            s_pImplementationNames = new Sequence< OUString >;
-            s_pSupportedServices = new Sequence< Sequence< OUString > >;
-            s_pCreationFunctionPointers = new Sequence< sal_Int64 >;
-            s_pFactoryFunctionPointers = new Sequence< sal_Int64 >;
+            s_pImplementationNames = new std::vector< OUString >;
+            s_pSupportedServices = new std::vector< Sequence< OUString > >;
+            s_pCreationFunctionPointers = new std::vector< ComponentInstantiation >;
+            s_pFactoryFunctionPointers = new std::vector< FactoryInstantiation >;
         }
         OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
             "OModule::registerComponent : inconsistent state (the pointers (2)) !");
 
-        OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
-                    &&  (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
-                    &&  (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+        OSL_ENSURE( (s_pImplementationNames->size() == s_pSupportedServices->size())
+                    &&  (s_pImplementationNames->size() == s_pCreationFunctionPointers->size())
+                    &&  (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()),
             "OModule::registerComponent : inconsistent state !");
 
-        sal_Int32 nOldLen = s_pImplementationNames->getLength();
-        s_pImplementationNames->realloc(nOldLen + 1);
-        s_pSupportedServices->realloc(nOldLen + 1);
-        s_pCreationFunctionPointers->realloc(nOldLen + 1);
-        s_pFactoryFunctionPointers->realloc(nOldLen + 1);
-
-        s_pImplementationNames->getArray()[nOldLen] = _rImplementationName;
-        s_pSupportedServices->getArray()[nOldLen] = _rServiceNames;
-        s_pCreationFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pCreateFunction);
-        s_pFactoryFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pFactoryFunction);
+        s_pImplementationNames->push_back(_rImplementationName);
+        s_pSupportedServices->push_back(_rServiceNames);
+        s_pCreationFunctionPointers->push_back(_pCreateFunction);
+        s_pFactoryFunctionPointers->push_back(_pFactoryFunction);
     }
 
 
@@ -191,26 +185,25 @@ namespace COMPMOD_NAMESPACE
         }
         OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
             "OModule::revokeComponent : inconsistent state (the pointers) !");
-        OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
-                    &&  (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
-                    &&  (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+        OSL_ENSURE( (s_pImplementationNames->size() == s_pSupportedServices->size())
+                    &&  (s_pImplementationNames->size() == s_pCreationFunctionPointers->size())
+                    &&  (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()),
             "OModule::revokeComponent : inconsistent state !");
 
-        sal_Int32 nLen = s_pImplementationNames->getLength();
-        const OUString* pImplNames = s_pImplementationNames->getConstArray();
-        for (sal_Int32 i=0; i<nLen; ++i, ++pImplNames)
+        sal_Int32 nLen = s_pImplementationNames->size();
+        for (sal_Int32 i=0; i<nLen; ++i)
         {
-            if (pImplNames->equals(_rImplementationName))
+            if ((*s_pImplementationNames)[i] == _rImplementationName)
             {
-                removeElementAt(*s_pImplementationNames, i);
-                removeElementAt(*s_pSupportedServices, i);
-                removeElementAt(*s_pCreationFunctionPointers, i);
-                removeElementAt(*s_pFactoryFunctionPointers, i);
+                s_pImplementationNames->erase(s_pImplementationNames->begin() + i);
+                s_pSupportedServices->erase(s_pSupportedServices->begin() + i);
+                s_pCreationFunctionPointers->erase(s_pCreationFunctionPointers->begin() + i);
+                s_pFactoryFunctionPointers->erase(s_pFactoryFunctionPointers->begin() + i);
                 break;
             }
         }
 
-        if (s_pImplementationNames->getLength() == 0)
+        if (s_pImplementationNames->empty())
         {
             delete s_pImplementationNames; s_pImplementationNames = nullptr;
             delete s_pSupportedServices; s_pSupportedServices = nullptr;
@@ -234,35 +227,33 @@ namespace COMPMOD_NAMESPACE
         }
         OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
             "OModule::getComponentFactory : inconsistent state (the pointers) !");
-        OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
-                    &&  (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
-                    &&  (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+        OSL_ENSURE( (s_pImplementationNames->size() == s_pSupportedServices->size())
+                    &&  (s_pImplementationNames->size() == s_pCreationFunctionPointers->size())
+                    &&  (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()),
             "OModule::getComponentFactory : inconsistent state !");
 
 
         Reference< XInterface > xReturn;
 
 
-        sal_Int32 nLen = s_pImplementationNames->getLength();
-        const OUString* pImplName = s_pImplementationNames->getConstArray();
-        const Sequence< OUString >* pServices = s_pSupportedServices->getConstArray();
-        const sal_Int64* pComponentFunction = s_pCreationFunctionPointers->getConstArray();
-        const sal_Int64* pFactoryFunction = s_pFactoryFunctionPointers->getConstArray();
+        sal_Int32 nLen = s_pImplementationNames->size();
 
-        for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices, ++pComponentFunction, ++pFactoryFunction)
+        for (sal_Int32 i=0; i<nLen; ++i)
         {
-            if (pImplName->equals(_rImplementationName))
+            if ((*s_pImplementationNames)[i] == _rImplementationName)
             {
-                const FactoryInstantiation FactoryInstantiationFunction = reinterpret_cast<const FactoryInstantiation>(*pFactoryFunction);
-                const ComponentInstantiation ComponentInstantiationFunction = reinterpret_cast<const ComponentInstantiation>(*pComponentFunction);
+                const FactoryInstantiation FactoryInstantiationFunction = (*s_pFactoryFunctionPointers)[i];
 
-                xReturn = FactoryInstantiationFunction( _rxServiceManager, *pImplName, ComponentInstantiationFunction, *pServices, nullptr);
+                xReturn = FactoryInstantiationFunction( _rxServiceManager, _rImplementationName,
+                    (*s_pCreationFunctionPointers)[i],
+                    (*s_pSupportedServices)[i], nullptr);
                 if (xReturn.is())
                 {
                     xReturn->acquire();
                     return xReturn.get();
                 }
             }
+            return nullptr;
         }
 
         return nullptr;
diff --git a/extensions/source/inc/componentmodule.hxx b/extensions/source/inc/componentmodule.hxx
index 58f80ba..f523e3f 100644
--- a/extensions/source/inc/componentmodule.hxx
+++ b/extensions/source/inc/componentmodule.hxx
@@ -36,6 +36,7 @@
 #include <com/sun/star/registry/XRegistryKey.hpp>
 #include <cppuhelper/factory.hxx>
 #include <rtl/string.hxx>
+#include <vector>
 
 class ResMgr;
 
@@ -69,13 +70,13 @@ typedef css::uno::Reference< css::lang::XSingleServiceFactory > (SAL_CALL *Facto
         static OString   s_sResPrefix;
 
         // auto registration administration
-        static  css::uno::Sequence< OUString >*
+        static  std::vector< OUString >*
             s_pImplementationNames;
-        static  css::uno::Sequence< css::uno::Sequence< OUString > >*
+        static  std::vector< css::uno::Sequence< OUString > >*
             s_pSupportedServices;
-        static  css::uno::Sequence< sal_Int64 >*
+        static  std::vector< cppu::ComponentInstantiation >*
             s_pCreationFunctionPointers;
-        static  css::uno::Sequence< sal_Int64 >*
+        static  std::vector< FactoryInstantiation >*
             s_pFactoryFunctionPointers;
 
     public:
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx
index 396239d..17dc4a7 100644
--- a/extensions/source/propctrlr/eventhandler.cxx
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -225,7 +225,7 @@ namespace pcr
             return aPropertyName.makeStringAndClear();
         }
 
-        ScriptEventDescriptor lcl_getAssignedScriptEvent( const EventDescription& _rEvent, const Sequence< ScriptEventDescriptor >& _rAllAssignedMacros )
+        ScriptEventDescriptor lcl_getAssignedScriptEvent( const EventDescription& _rEvent, const std::vector< ScriptEventDescriptor >& _rAllAssignedMacros )
         {
             ScriptEventDescriptor aScriptEvent;
             // for the case there is actually no event assigned, initialize at least ListenerType and MethodName,
@@ -233,24 +233,22 @@ namespace pcr
             aScriptEvent.ListenerType = _rEvent.sListenerClassName;
             aScriptEvent.EventMethod = _rEvent.sListenerMethodName;
 
-            const ScriptEventDescriptor* pAssignedEvent = _rAllAssignedMacros.getConstArray();
-            sal_Int32 assignedEventCount( _rAllAssignedMacros.getLength() );
-            for ( sal_Int32 assignedEvent = 0; assignedEvent < assignedEventCount; ++assignedEvent, ++pAssignedEvent )
+            for ( const ScriptEventDescriptor& rSED :  _rAllAssignedMacros )
             {
-                if  (   ( pAssignedEvent->ListenerType != _rEvent.sListenerClassName )
-                    ||  ( pAssignedEvent->EventMethod != _rEvent.sListenerMethodName )
+                if  (   rSED.ListenerType != _rEvent.sListenerClassName
+                    ||  rSED.EventMethod != _rEvent.sListenerMethodName
                     )
                     continue;
 
-                if  (   ( pAssignedEvent->ScriptCode.isEmpty() )
-                    ||  ( pAssignedEvent->ScriptType.isEmpty() )
+                if  (  rSED.ScriptCode.isEmpty()
+                    || rSED.ScriptType.isEmpty()
                     )
                 {
                     OSL_FAIL( "lcl_getAssignedScriptEvent: me thinks this should not happen!" );
                     continue;
                 }
 
-                aScriptEvent = *pAssignedEvent;
+                aScriptEvent = rSED;
 
                 if ( aScriptEvent.ScriptType != "StarBasic" )
                     continue;
@@ -537,20 +535,17 @@ namespace pcr
 
         const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
 
-        Sequence< ScriptEventDescriptor > aEvents;
+        std::vector< ScriptEventDescriptor > aEvents;
         impl_getComponentScriptEvents_nothrow( aEvents );
 
-        sal_Int32 nEventCount = aEvents.getLength();
-        const ScriptEventDescriptor* pEvents = aEvents.getConstArray();
-
         ScriptEventDescriptor aPropertyValue;
-        for ( sal_Int32 event = 0; event < nEventCount; ++event, ++pEvents )
+        for ( const ScriptEventDescriptor& rSCD : aEvents )
         {
-            if  (   rEvent.sListenerClassName == pEvents->ListenerType
-                &&  rEvent.sListenerMethodName == pEvents->EventMethod
+            if  (   rEvent.sListenerClassName == rSCD.ListenerType
+                &&  rEvent.sListenerMethodName == rSCD.EventMethod
                 )
             {
-                aPropertyValue = *pEvents;
+                aPropertyValue = rSCD;
                 break;
             }
         }
@@ -595,7 +590,7 @@ namespace pcr
         OUString sNewScriptCode;
         OSL_VERIFY( _rControlValue >>= sNewScriptCode );
 
-        Sequence< ScriptEventDescriptor > aAllAssignedEvents;
+        std::vector< ScriptEventDescriptor > aAllAssignedEvents;
         impl_getComponentScriptEvents_nothrow( aAllAssignedEvents );
 
         const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
@@ -814,7 +809,7 @@ namespace pcr
         ::osl::MutexGuard aGuard( m_aMutex );
         const EventDescription& rForEvent = impl_getEventForName_throw( _rPropertyName );
 
-        Sequence< ScriptEventDescriptor > aAllAssignedEvents;
+        std::vector< ScriptEventDescriptor > aAllAssignedEvents;
         impl_getComponentScriptEvents_nothrow( aAllAssignedEvents );
 
         // SvxMacroAssignDlg-compatible structure holding all event/assignments
@@ -933,23 +928,20 @@ namespace pcr
         throw NoSuchElementException();
     }
 
-    void EventHandler::impl_getFormComponentScriptEvents_nothrow( Sequence < ScriptEventDescriptor >& _out_rEvents ) const
+    void EventHandler::impl_getFormComponentScriptEvents_nothrow( std::vector < ScriptEventDescriptor >& _out_rEvents ) const
     {
-        _out_rEvents = Sequence < ScriptEventDescriptor >();
+        _out_rEvents.clear();
         try
         {
             Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
             Reference< XEventAttacherManager > xEventManager( xChild->getParent(), UNO_QUERY_THROW );
-            _out_rEvents = xEventManager->getScriptEvents( impl_getComponentIndexInParent_throw() );
+            comphelper::sequenceToContainer(_out_rEvents, xEventManager->getScriptEvents( impl_getComponentIndexInParent_throw() ));
 
             // the form component script API has unqualified listener names, but for normalization
             // purpose, we want fully qualified ones
-            ScriptEventDescriptor* pEvents = _out_rEvents.getArray();
-            ScriptEventDescriptor* pEventsEnd = _out_rEvents.getArray() + _out_rEvents.getLength();
-            while ( pEvents != pEventsEnd )
+            for ( ScriptEventDescriptor& rSED :  _out_rEvents)
             {
-                pEvents->ListenerType = lcl_getQualifiedKnownListenerName( *pEvents );
-                ++pEvents;
+                rSED.ListenerType = lcl_getQualifiedKnownListenerName( rSED );
             }
         }
         catch( const Exception& )
@@ -988,9 +980,9 @@ namespace pcr
         }
     }
 
-    void EventHandler::impl_getDialogElementScriptEvents_nothrow( Sequence < ScriptEventDescriptor >& _out_rEvents ) const
+    void EventHandler::impl_getDialogElementScriptEvents_nothrow( std::vector < ScriptEventDescriptor >& _out_rEvents ) const
     {
-        _out_rEvents = Sequence < ScriptEventDescriptor >();
+        _out_rEvents.clear();
         try
         {
             Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW );
@@ -998,13 +990,10 @@ namespace pcr
             Sequence< OUString > aEventNames( xEvents->getElementNames() );
 
             sal_Int32 nEventCount = aEventNames.getLength();
-            _out_rEvents.realloc( nEventCount );
-
-            const OUString* pNames = aEventNames.getConstArray();
-            ScriptEventDescriptor* pDescs = _out_rEvents.getArray();
+            _out_rEvents.resize( nEventCount );
 
-            for( sal_Int32 i = 0 ; i < nEventCount ; ++i, ++pNames, ++pDescs )
-                OSL_VERIFY( xEvents->getByName( *pNames ) >>= *pDescs );
+            for( sal_Int32 i = 0; i < nEventCount; ++i )
+                OSL_VERIFY( xEvents->getByName( aEventNames[i] ) >>= _out_rEvents[i] );
         }
         catch( const Exception& )
         {
@@ -1068,13 +1057,14 @@ namespace pcr
             sal_Int32 nObjectIndex = impl_getComponentIndexInParent_throw();
             Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
             Reference< XEventAttacherManager > xEventManager( xChild->getParent(), UNO_QUERY_THROW );
-            Sequence< ScriptEventDescriptor > aEvents( xEventManager->getScriptEvents( nObjectIndex ) );
+            std::vector< ScriptEventDescriptor > aEvents;
+            comphelper::sequenceToContainer( aEvents, xEventManager->getScriptEvents( nObjectIndex ) );
 
             // is there already a registered script for this event?
-            ScriptEventDescriptor* pEvent = aEvents.getArray();
-            sal_Int32 eventCount = aEvents.getLength(), event = 0;
-            for ( event = 0; event < eventCount; ++event, ++pEvent )
+            sal_Int32 eventCount = aEvents.size(), event = 0;
+            for ( event = 0; event < eventCount; ++event )
             {
+                ScriptEventDescriptor* pEvent = &aEvents[event];
                 if  (   ( pEvent->EventMethod == _rScriptEvent.EventMethod )
                     &&  ( lcl_endsWith( _rScriptEvent.ListenerType, pEvent->ListenerType ) )
                           // (strange enough, the events we get from getScriptEvents are not fully qualified)
@@ -1089,9 +1079,8 @@ namespace pcr
                     }
                     else
                     {
-                        // set to empty -> remove from sequence
-                        ::std::copy( pEvent + 1, aEvents.getArray() + eventCount, pEvent );
-                        aEvents.realloc( eventCount - 1 );
+                        // set to empty -> remove from vector
+                        aEvents.erase(aEvents.begin() + event );
                         --eventCount;
                     }
                     break;
@@ -1100,12 +1089,11 @@ namespace pcr
             if ( ( event >= eventCount ) && !bResetScript )
             {
                 // no, did not find it -> append
-                aEvents.realloc( eventCount + 1 );
-                aEvents[ eventCount ] = _rScriptEvent;
+                aEvents.push_back( _rScriptEvent );
             }
 
             xEventManager->revokeScriptEvents( nObjectIndex );
-            xEventManager->registerScriptEvents( nObjectIndex, aEvents );
+            xEventManager->registerScriptEvents( nObjectIndex, comphelper::containerToSequence(aEvents) );
 
             PropertyHandlerHelper::setContextDocumentModified( m_xContext );
         }
diff --git a/extensions/source/propctrlr/eventhandler.hxx b/extensions/source/propctrlr/eventhandler.hxx
index e33c6f3..afa9e7f0 100644
--- a/extensions/source/propctrlr/eventhandler.hxx
+++ b/extensions/source/propctrlr/eventhandler.hxx
@@ -143,7 +143,7 @@ namespace pcr
                 Our introspectee is a form component
         */
         void    impl_getFormComponentScriptEvents_nothrow(
-                    css::uno::Sequence< css::script::ScriptEventDescriptor >& _out_rEvents
+                    std::vector< css::script::ScriptEventDescriptor >& _out_rEvents
                 ) const;
 
         /** returns the script events associated with our introspectee
@@ -153,7 +153,7 @@ namespace pcr
                 Our introspectee is a dialog element
         */
         void    impl_getDialogElementScriptEvents_nothrow(
-                    css::uno::Sequence< css::script::ScriptEventDescriptor >& _out_rEvents
+                    std::vector< css::script::ScriptEventDescriptor >& _out_rEvents
                 ) const;
 
         /** returns the script events associated with our introspectee
@@ -161,7 +161,7 @@ namespace pcr
                 Takes, the events currently associated with the introspectee
         */
         inline void impl_getComponentScriptEvents_nothrow(
-                    css::uno::Sequence< css::script::ScriptEventDescriptor >& _out_rEvents
+                    std::vector< css::script::ScriptEventDescriptor >& _out_rEvents
                 ) const
         {
             if ( m_bIsDialogElement )
diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx
index 4aa9f88..2839b04 100644
--- a/extensions/source/propctrlr/fontdialog.cxx
+++ b/extensions/source/propctrlr/fontdialog.cxx
@@ -291,17 +291,16 @@ namespace pcr
 
     namespace
     {
-        void lcl_pushBackPropertyValue( Sequence< NamedValue >& _out_properties, const OUString& _name, const Any& _value )
+        void lcl_pushBackPropertyValue( std::vector< NamedValue >& _out_properties, const OUString& _name, const Any& _value )
         {
-            _out_properties.realloc( _out_properties.getLength() + 1 );
-            _out_properties[ _out_properties.getLength() - 1 ] = NamedValue( _name, _value );
+            _out_properties.push_back( NamedValue( _name, _value ) );
         }
     }
 
 
-    void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, Sequence< NamedValue >& _out_properties )
+    void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, std::vector< NamedValue >& _out_properties )
     {
-        _out_properties.realloc( 0 );
+        _out_properties.clear();
 
         try
         {
@@ -462,14 +461,12 @@ namespace pcr
         if ( !_rxModel.is())
             return;
 
-        Sequence< NamedValue > aPropertyValues;
+        std::vector< NamedValue > aPropertyValues;
         translateItemsToProperties( _rSet, aPropertyValues );
         try
         {
-            const NamedValue* propertyValue = aPropertyValues.getConstArray();
-            const NamedValue* propertyValueEnd = propertyValue + aPropertyValues.getLength();
-            for ( ; propertyValue != propertyValueEnd; ++propertyValue )
-                _rxModel->setPropertyValue( propertyValue->Name, propertyValue->Value );
+            for ( const NamedValue& rNV : aPropertyValues )
+                _rxModel->setPropertyValue( rNV.Name, rNV.Value );
         }
         catch( const Exception& )
         {
diff --git a/extensions/source/propctrlr/fontdialog.hxx b/extensions/source/propctrlr/fontdialog.hxx
index 707a35e4..e041349 100644
--- a/extensions/source/propctrlr/fontdialog.hxx
+++ b/extensions/source/propctrlr/fontdialog.hxx
@@ -58,7 +58,7 @@ namespace pcr
         */
         static void translateItemsToProperties(
             const SfxItemSet& _rSet,
-            css::uno::Sequence< css::beans::NamedValue >& _out_properties );
+            std::vector< css::beans::NamedValue >& _out_properties );
 
     protected:
         virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage) override;
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index c44d3d9..09ec0ed 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -277,9 +277,8 @@ namespace pcr
                 const OUString* pStrings = aStrings.getConstArray();
                 sal_Int32 nCount = aStrings.getLength();
 
-                Sequence< OUString > aResolvedStrings;
-                aResolvedStrings.realloc( nCount );
-                OUString* pResolvedStrings = aResolvedStrings.getArray();
+                std::vector< OUString > aResolvedStrings;
+                aResolvedStrings.resize( nCount );
                 try
                 {
                     for ( sal_Int32 i = 0; i < nCount; ++i )
@@ -287,14 +286,14 @@ namespace pcr
                         OUString aIdStr = pStrings[i];
                         OUString aPureIdStr = aIdStr.copy( 1 );
                         if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
-                            pResolvedStrings[i] = xStringResourceResolver->resolveString( aPureIdStr );
+                            aResolvedStrings[i] = xStringResourceResolver->resolveString( aPureIdStr );
                         else
-                            pResolvedStrings[i] = aIdStr;
+                            aResolvedStrings[i] = aIdStr;
                     }
                 }
                 catch( const resource::MissingResourceException & )
                 {}
-                aPropertyValue <<= aResolvedStrings;
+                aPropertyValue <<= comphelper::containerToSequence(aResolvedStrings);
             }
         }
         else
@@ -2873,9 +2872,9 @@ namespace pcr
                 const SfxItemSet* pOut = aDlg->GetOutputItemSet();
                 if ( pOut )
                 {
-                    Sequence< NamedValue > aFontPropertyValues;
+                    std::vector< NamedValue > aFontPropertyValues;
                     ControlCharacterDialog::translateItemsToProperties( *pOut, aFontPropertyValues );
-                    _out_rNewValue <<= aFontPropertyValues;
+                    _out_rNewValue <<= comphelper::containerToSequence(aFontPropertyValues);
                     bSuccess = true;
                 }
             }
diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx
index fbd6eb2..73ea806 100644
--- a/extensions/source/propctrlr/formlinkdialog.cxx
+++ b/extensions/source/propctrlr/formlinkdialog.cxx
@@ -35,6 +35,7 @@
 #include <connectivity/dbexception.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
 
 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
 #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
@@ -316,22 +317,19 @@ namespace pcr
     }
 
 
-    void FormLinkDialog::initializeFieldRowsFrom( Sequence< OUString >& _rDetailFields, Sequence< OUString >& _rMasterFields )
+    void FormLinkDialog::initializeFieldRowsFrom( std::vector< OUString >& _rDetailFields, std::vector< OUString >& _rMasterFields )
     {
         // our UI does allow 4 fields max
-        _rDetailFields.realloc( 4 );
-        _rMasterFields.realloc( 4 );
-
-        const OUString* pDetailFields = _rDetailFields.getConstArray();
-        const OUString* pMasterFields = _rMasterFields.getConstArray();
+        _rDetailFields.resize( 4 );
+        _rMasterFields.resize( 4 );
 
         FieldLinkRow* aRows[] = {
             m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
         };
-        for ( sal_Int32 i = 0; i < 4; ++i, ++pDetailFields, ++pMasterFields )
+        for ( sal_Int32 i = 0; i < 4; ++i )
         {
-            aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, *pDetailFields );
-            aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, *pMasterFields );
+            aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, _rDetailFields[i] );
+            aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, _rMasterFields[i] );
         }
     }
 
@@ -350,7 +348,11 @@ namespace pcr
                 xDetailFormProps->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
             }
 
-            initializeFieldRowsFrom( aDetailFields, aMasterFields );
+            std::vector< OUString > aDetailFields1;
+            comphelper::sequenceToContainer(aDetailFields1, aDetailFields);
+            std::vector< OUString > aMasterFields1;
+            comphelper::sequenceToContainer(aMasterFields1, aMasterFields);
+            initializeFieldRowsFrom( aDetailFields1, aMasterFields1 );
         }
         catch( const Exception& )
         {
@@ -516,7 +518,7 @@ namespace pcr
 
     bool FormLinkDialog::getExistingRelation( const Reference< XPropertySet >& _rxLHS, const Reference< XPropertySet >& /*_rxRHS*/,
             // TODO: fix the usage of _rxRHS. This is issue #i81956#.
-        Sequence< OUString >& _rLeftFields, Sequence< OUString >& _rRightFields )
+        std::vector< OUString >& _rLeftFields, std::vector< OUString >& _rRightFields )
     {
         try
         {
@@ -552,8 +554,8 @@ namespace pcr
                         continue;
 
                     const sal_Int32 columnCount = xKeyColumns->getCount();
-                    _rLeftFields.realloc( columnCount );
-                    _rRightFields.realloc( columnCount );
+                    _rLeftFields.resize( columnCount );
+                    _rRightFields.resize( columnCount );
                     for ( sal_Int32 column = 0; column < columnCount; ++column )
                     {
                         xKeyColumn.clear();
@@ -576,7 +578,7 @@ namespace pcr
             OSL_FAIL( "FormLinkDialog::getExistingRelation: caught an exception!" );
         }
 
-        return ( _rLeftFields.getLength() > 0 ) && ( !_rLeftFields[ 0 ].isEmpty() );
+        return ( !_rLeftFields.empty() ) && ( !_rLeftFields[ 0 ].isEmpty() );
     }
 
 
@@ -626,15 +628,15 @@ namespace pcr
             }
 
             // only enable the button if there is a relation between both tables
-            m_aRelationDetailColumns.realloc( 0 );
-            m_aRelationMasterColumns.realloc( 0 );
+            m_aRelationDetailColumns.clear();
+            m_aRelationMasterColumns.clear();
             if ( bEnable )
             {
                 bEnable = getExistingRelation( xDetailTable, xMasterTable, m_aRelationDetailColumns, m_aRelationMasterColumns );
-                SAL_WARN_IF( m_aRelationMasterColumns.getLength() != m_aRelationDetailColumns.getLength(),
+                SAL_WARN_IF( m_aRelationMasterColumns.size() != m_aRelationDetailColumns.size(),
                     "extensions.propctrlr",
                     "FormLinkDialog::initializeSuggest: nonsense!" );
-                if ( m_aRelationMasterColumns.getLength() == 0 )
+                if ( m_aRelationMasterColumns.empty() )
                 {   // okay, there is no relation "pointing" (via a foreign key) from the detail table to the master table
                     // but perhaps the other way round (would make less sense, but who knows ...)
                     bEnable = getExistingRelation( xMasterTable, xDetailTable, m_aRelationMasterColumns, m_aRelationDetailColumns );
@@ -644,7 +646,7 @@ namespace pcr
             // only enable the button if the relation contains at most 4 field pairs
             if ( bEnable )
             {
-                bEnable = ( m_aRelationMasterColumns.getLength() <= 4 );
+                bEnable = ( m_aRelationMasterColumns.size() <= 4 );
             }
 
             m_pSuggest->Enable( bEnable );
diff --git a/extensions/source/propctrlr/formlinkdialog.hxx b/extensions/source/propctrlr/formlinkdialog.hxx
index b341cd0..896c941 100644
--- a/extensions/source/propctrlr/formlinkdialog.hxx
+++ b/extensions/source/propctrlr/formlinkdialog.hxx
@@ -61,10 +61,8 @@ namespace pcr
         css::uno::Reference< css::beans::XPropertySet >
                                         m_xMasterForm;
 
-        css::uno::Sequence< OUString >
-                                        m_aRelationDetailColumns;
-        css::uno::Sequence< OUString >
-                                        m_aRelationMasterColumns;
+        std::vector< OUString >         m_aRelationDetailColumns;
+        std::vector< OUString >         m_aRelationMasterColumns;
 
         OUString                 m_sDetailLabel;
         OUString                 m_sMasterLabel;
@@ -98,8 +96,8 @@ namespace pcr
         void        commitLinkPairs();
 
         void        initializeFieldRowsFrom(
-                        css::uno::Sequence< OUString >& _rDetailFields,
-                        css::uno::Sequence< OUString >& _rMasterFields
+                        std::vector< OUString >& _rDetailFields,
+                        std::vector< OUString >& _rMasterFields
                     );
 
         static OUString getFormDataSourceType(
@@ -126,8 +124,8 @@ namespace pcr
         static bool getExistingRelation(
                         const css::uno::Reference< css::beans::XPropertySet >& _rxLHS,
                         const css::uno::Reference< css::beans::XPropertySet >& _rxRHS,
-                        css::uno::Sequence< OUString >& /* [out] */ _rLeftFields,
-                        css::uno::Sequence< OUString >& /* [out] */ _rRightFields
+                        std::vector< OUString >& /* [out] */ _rLeftFields,
+                        std::vector< OUString >& /* [out] */ _rRightFields
                     );
     };
 
diff --git a/extensions/source/propctrlr/listselectiondlg.cxx b/extensions/source/propctrlr/listselectiondlg.cxx
index 01b1134..73afae7 100644
--- a/extensions/source/propctrlr/listselectiondlg.cxx
+++ b/extensions/source/propctrlr/listselectiondlg.cxx
@@ -23,6 +23,7 @@
 #include "formresid.hrc"
 #include "formstrings.hxx"
 #include <vcl/msgbox.hxx>
+#include <comphelper/sequence.hxx>
 
 namespace pcr
 {
@@ -106,12 +107,12 @@ namespace pcr
         if ( !m_xListBox.is() )
             return;
 
-        Sequence< sal_Int16 > aSelection;
+        std::vector< sal_Int16 > aSelection;
         collectSelection( aSelection );
 
         try
         {
-            m_xListBox->setPropertyValue( m_sPropertyName, makeAny( aSelection ) );
+            m_xListBox->setPropertyValue( m_sPropertyName, makeAny( comphelper::containerToSequence(aSelection) ) );
         }
         catch( const Exception& )
         {
@@ -130,13 +131,12 @@ namespace pcr
     }
 
 
-    void ListSelectionDialog::collectSelection( Sequence< sal_Int16 >& /* [out] */ _rSelection )
+    void ListSelectionDialog::collectSelection( std::vector< sal_Int16 >& /* [out] */ _rSelection )
     {
         const sal_Int32 nSelectedCount = m_pEntries->GetSelectEntryCount( );
-        _rSelection.realloc( nSelectedCount );
-        sal_Int16* pSelection = _rSelection.getArray();
-        for ( sal_Int32 selected = 0; selected < nSelectedCount; ++selected, ++pSelection )
-            *pSelection = static_cast< sal_Int16 >( m_pEntries->GetSelectEntryPos( selected ) );
+        _rSelection.resize( nSelectedCount );
+        for ( sal_Int32 selected = 0; selected < nSelectedCount; ++selected )
+            _rSelection[selected] = static_cast< sal_Int16 >( m_pEntries->GetSelectEntryPos( selected ) );
     }
 
 
diff --git a/extensions/source/propctrlr/listselectiondlg.hxx b/extensions/source/propctrlr/listselectiondlg.hxx
index 18abad9..6404aeb 100644
--- a/extensions/source/propctrlr/listselectiondlg.hxx
+++ b/extensions/source/propctrlr/listselectiondlg.hxx
@@ -57,7 +57,7 @@ namespace pcr
         void    fillEntryList   ( const css::uno::Sequence< OUString >& _rListEntries );
 
         void    selectEntries   ( const css::uno::Sequence< sal_Int16 >& /* [in ] */ _rSelection );
-        void    collectSelection(       css::uno::Sequence< sal_Int16 >& /* [out] */ _rSelection );
+        void    collectSelection(       std::vector< sal_Int16 >& /* [out] */ _rSelection );
     };
 
 
diff --git a/extensions/source/propctrlr/propertycomposer.cxx b/extensions/source/propctrlr/propertycomposer.cxx
index 74e60b4..e0b94cf 100644
--- a/extensions/source/propctrlr/propertycomposer.cxx
+++ b/extensions/source/propctrlr/propertycomposer.cxx
@@ -21,6 +21,7 @@
 
 #include <com/sun/star/lang/NullPointerException.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <comphelper/sequence.hxx>
 #include <osl/diagnose.h>
 #include <tools/diagnose_ex.h>
 
@@ -254,8 +255,7 @@ namespace pcr
             m_bSupportedPropertiesAreKnown = true;
         }
 
-        Sequence< Property > aSurvived;
-        copyBagToArray( m_aSupportedProperties, aSurvived );
+        Sequence< Property > aSurvived = comphelper::containerToSequence<Property>( m_aSupportedProperties );
         return aSurvived;
     }
 
diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx
index 87d170f..0cf1e50 100644
--- a/extensions/source/update/feed/updatefeed.cxx
+++ b/extensions/source/update/feed/updatefeed.cxx
@@ -22,6 +22,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/implementationentry.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
 #include <com/sun/star/beans/Property.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/beans/XPropertySetInfo.hpp>
@@ -668,7 +669,7 @@ UpdateInformationProvider::getUpdateInformation(
         getUpdateInformationEnumeration(repositories, extensionId)
     );
 
-    uno::Sequence< uno::Reference< xml::dom::XElement > > aRet;
+    std::vector< uno::Reference< xml::dom::XElement > > aRet;
 
     if( xEnumeration.is() )
     {
@@ -679,9 +680,7 @@ UpdateInformationProvider::getUpdateInformation(
                 deployment::UpdateInformationEntry aEntry;
                 if( (xEnumeration->nextElement() >>= aEntry ) && aEntry.UpdateDocument.is() )
                 {
-                    sal_Int32 n = aRet.getLength();
-                    aRet.realloc(n + 1);
-                    aRet[n] = aEntry.UpdateDocument;
+                    aRet.push_back(aEntry.UpdateDocument);
                 }
             }
 
@@ -698,7 +697,7 @@ UpdateInformationProvider::getUpdateInformation(
         }
     }
 
-    return aRet;
+    return comphelper::containerToSequence(aRet);
 }
 
 


More information about the Libreoffice-commits mailing list