diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-27 10:18:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-02-28 07:15:33 +0000 |
commit | 5993c41c75974c507683cdd1f19db45dd0c03dbf (patch) | |
tree | 86c9eac3e74da70372e9597b6a03d605a75079bf | |
parent | 9da3d052b9048e9139b6943621f4eb6777422078 (diff) |
flatten some internal classes in dbaccess
no need for the pimpl pattern here
Change-Id: I6e15dd7b68104b2848871c338d5560cb70c9c88d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147869
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | dbaccess/source/core/dataaccess/documenteventexecutor.cxx | 32 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/documenteventexecutor.hxx | 9 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/documentevents.cxx | 53 | ||||
-rw-r--r-- | dbaccess/source/core/inc/documentevents.hxx | 8 | ||||
-rw-r--r-- | dbaccess/source/core/inc/recovery/dbdocrecovery.hxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/dbdocrecovery.cxx | 21 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/storagetextstream.cxx | 19 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/storagetextstream.hxx | 7 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/storagexmlstream.cxx | 54 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/storagexmlstream.hxx | 15 | ||||
-rw-r--r-- | dbaccess/source/core/recovery/subcomponentrecovery.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/imageprovider.hxx | 14 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/singledoccontroller.hxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/imageprovider.cxx | 38 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/singledoccontroller.cxx | 20 |
15 files changed, 111 insertions, 193 deletions
diff --git a/dbaccess/source/core/dataaccess/documenteventexecutor.cxx b/dbaccess/source/core/dataaccess/documenteventexecutor.cxx index c3f8a01ea3e4..e1cb9f3f4e57 100644 --- a/dbaccess/source/core/dataaccess/documenteventexecutor.cxx +++ b/dbaccess/source/core/dataaccess/documenteventexecutor.cxx @@ -57,24 +57,14 @@ namespace dbaccess using namespace ::com::sun::star; - // DocumentEventExecutor_Data - struct DocumentEventExecutor_Data - { - WeakReference< XEventsSupplier > xDocument; - Reference< XURLTransformer > xURLTransformer; - - explicit DocumentEventExecutor_Data( const Reference< XEventsSupplier >& _rxDocument ) - :xDocument( _rxDocument ) - { - } - }; - namespace { - void lcl_dispatchScriptURL_throw( DocumentEventExecutor_Data const & _rDocExecData, + void lcl_dispatchScriptURL_throw( + css::uno::WeakReference< css::document::XEventsSupplier > const & xWeakDocument, + css::uno::Reference< css::util::XURLTransformer > const & xURLTransformer, const OUString& _rScriptURL, const DocumentEvent& _rTrigger ) { - Reference< XModel > xDocument( _rDocExecData.xDocument.get(), UNO_QUERY_THROW ); + Reference< XModel > xDocument( xWeakDocument.get(), UNO_QUERY_THROW ); Reference< XController > xController( xDocument->getCurrentController() ); Reference< XDispatchProvider > xDispProv; @@ -88,8 +78,8 @@ namespace dbaccess URL aScriptURL; aScriptURL.Complete = _rScriptURL; - if ( _rDocExecData.xURLTransformer.is() ) - _rDocExecData.xURLTransformer->parseStrict( aScriptURL ); + if ( xURLTransformer.is() ) + xURLTransformer->parseStrict( aScriptURL ); // unfortunately, executing a script can trigger all kind of complex stuff, and unfortunately, not // every component involved into this properly cares for thread safety. To be on the safe side, @@ -113,7 +103,7 @@ namespace dbaccess // DocumentEventExecutor DocumentEventExecutor::DocumentEventExecutor( const Reference<XComponentContext> & _rContext, const Reference< XEventsSupplier >& _rxDocument ) - :m_pData( new DocumentEventExecutor_Data( _rxDocument ) ) + :mxDocument( _rxDocument ) { Reference< XDocumentEventBroadcaster > xBroadcaster( _rxDocument, UNO_QUERY_THROW ); @@ -125,7 +115,7 @@ namespace dbaccess try { - m_pData->xURLTransformer = URLTransformer::create(_rContext); + mxURLTransformer = URLTransformer::create(_rContext); } catch( const Exception& ) { @@ -139,8 +129,8 @@ namespace dbaccess void SAL_CALL DocumentEventExecutor::documentEventOccured( const DocumentEvent& Event ) { - Reference< XEventsSupplier > xEventsSupplier( m_pData->xDocument.get(), UNO_QUERY ); - if ( !xEventsSupplier.is() ) + Reference< XEventsSupplier > xEventsSupplier( mxDocument.get(), UNO_QUERY ); + if ( !xEventsSupplier ) { OSL_FAIL( "DocumentEventExecutor::documentEventOccurred: no document anymore, but still being notified?" ); return; @@ -179,7 +169,7 @@ namespace dbaccess if ( bDispatchScriptURL && bNonEmptyScript ) { - lcl_dispatchScriptURL_throw( *m_pData, sScript, Event ); + lcl_dispatchScriptURL_throw( mxDocument, mxURLTransformer, sScript, Event ); } } catch( const RuntimeException& ) { throw; } diff --git a/dbaccess/source/core/dataaccess/documenteventexecutor.hxx b/dbaccess/source/core/dataaccess/documenteventexecutor.hxx index 90dc9083c4a3..58aee4bcd590 100644 --- a/dbaccess/source/core/dataaccess/documenteventexecutor.hxx +++ b/dbaccess/source/core/dataaccess/documenteventexecutor.hxx @@ -23,15 +23,13 @@ #include <com/sun/star/document/XEventsSupplier.hpp> #include <cppuhelper/implbase.hxx> - -#include <memory> +#include <cppuhelper/weakref.hxx> namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::util { class XURLTransformer; } namespace dbaccess { - - struct DocumentEventExecutor_Data; // DocumentEventExecutor typedef ::cppu::WeakImplHelper < css::document::XDocumentEventListener > DocumentEventExecutor_Base; @@ -51,7 +49,8 @@ namespace dbaccess virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; private: - std::unique_ptr< DocumentEventExecutor_Data > m_pData; + css::uno::WeakReference< css::document::XEventsSupplier > mxDocument; + css::uno::Reference< css::util::XURLTransformer > mxURLTransformer; }; } // namespace dbaccess diff --git a/dbaccess/source/core/dataaccess/documentevents.cxx b/dbaccess/source/core/dataaccess/documentevents.cxx index 571ad2c6fa21..6dbe9ad5965d 100644 --- a/dbaccess/source/core/dataaccess/documentevents.cxx +++ b/dbaccess/source/core/dataaccess/documentevents.cxx @@ -36,23 +36,6 @@ namespace dbaccess using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Type; - // DocumentEvents_Data - struct DocumentEvents_Data - { - ::cppu::OWeakObject& rParent; - ::osl::Mutex& rMutex; - DocumentEventsData& rEventsData; - - DocumentEvents_Data( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData ) - :rParent( _rParent ) - ,rMutex( _rMutex ) - ,rEventsData( _rEventsData ) - { - } - DocumentEvents_Data(const DocumentEvents_Data&) = delete; - const DocumentEvents_Data& operator=(const DocumentEvents_Data&) = delete; - }; - namespace { // helper @@ -97,15 +80,15 @@ namespace dbaccess // DocumentEvents DocumentEvents::DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData ) - :m_pData( new DocumentEvents_Data( _rParent, _rMutex, _rEventsData ) ) + :mrParent(_rParent), mrMutex(_rMutex), mrEventsData(_rEventsData) { const DocumentEventData* pEventData = lcl_getDocumentEventData(); while ( pEventData->pAsciiEventName ) { OUString sEventName = OUString::createFromAscii( pEventData->pAsciiEventName ); - DocumentEventsData::const_iterator existingPos = m_pData->rEventsData.find( sEventName ); - if ( existingPos == m_pData->rEventsData.end() ) - m_pData->rEventsData[ sEventName ] = Sequence< PropertyValue >(); + DocumentEventsData::const_iterator existingPos = mrEventsData.find( sEventName ); + if ( existingPos == mrEventsData.end() ) + mrEventsData[ sEventName ] = Sequence< PropertyValue >(); ++pEventData; } } @@ -116,12 +99,12 @@ namespace dbaccess void SAL_CALL DocumentEvents::acquire() noexcept { - m_pData->rParent.acquire(); + mrParent.acquire(); } void SAL_CALL DocumentEvents::release() noexcept { - m_pData->rParent.release(); + mrParent.release(); } bool DocumentEvents::needsSynchronousNotification( std::u16string_view _rEventName ) @@ -140,10 +123,10 @@ namespace dbaccess void SAL_CALL DocumentEvents::replaceByName( const OUString& Name, const Any& Element ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - DocumentEventsData::iterator elementPos = m_pData->rEventsData.find( Name ); - if ( elementPos == m_pData->rEventsData.end() ) + DocumentEventsData::iterator elementPos = mrEventsData.find( Name ); + if ( elementPos == mrEventsData.end() ) throw NoSuchElementException( Name, *this ); Sequence< PropertyValue > aEventDescriptor; @@ -173,10 +156,10 @@ namespace dbaccess Any SAL_CALL DocumentEvents::getByName( const OUString& Name ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - DocumentEventsData::const_iterator elementPos = m_pData->rEventsData.find( Name ); - if ( elementPos == m_pData->rEventsData.end() ) + DocumentEventsData::const_iterator elementPos = mrEventsData.find( Name ); + if ( elementPos == mrEventsData.end() ) throw NoSuchElementException( Name, *this ); Any aReturn; @@ -188,16 +171,16 @@ namespace dbaccess Sequence< OUString > SAL_CALL DocumentEvents::getElementNames( ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - return comphelper::mapKeysToSequence( m_pData->rEventsData ); + return comphelper::mapKeysToSequence( mrEventsData ); } sal_Bool SAL_CALL DocumentEvents::hasByName( const OUString& Name ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); + ::osl::MutexGuard aGuard( mrMutex ); - return m_pData->rEventsData.find( Name ) != m_pData->rEventsData.end(); + return mrEventsData.find( Name ) != mrEventsData.end(); } Type SAL_CALL DocumentEvents::getElementType( ) @@ -207,8 +190,8 @@ namespace dbaccess sal_Bool SAL_CALL DocumentEvents::hasElements( ) { - ::osl::MutexGuard aGuard( m_pData->rMutex ); - return !m_pData->rEventsData.empty(); + ::osl::MutexGuard aGuard( mrMutex ); + return !mrEventsData.empty(); } } // namespace dbaccess diff --git a/dbaccess/source/core/inc/documentevents.hxx b/dbaccess/source/core/inc/documentevents.hxx index e7f7ef9ff5ac..224fc407d2fe 100644 --- a/dbaccess/source/core/inc/documentevents.hxx +++ b/dbaccess/source/core/inc/documentevents.hxx @@ -24,7 +24,6 @@ #include <cppuhelper/implbase.hxx> -#include <memory> #include <map> namespace dbaccess @@ -33,9 +32,6 @@ namespace dbaccess typedef std::map< OUString, css::uno::Sequence< css::beans::PropertyValue > > DocumentEventsData; - // DocumentEvents - struct DocumentEvents_Data; - typedef ::cppu::WeakImplHelper< css::container::XNameReplace > DocumentEvents_Base; @@ -67,7 +63,9 @@ namespace dbaccess virtual sal_Bool SAL_CALL hasElements( ) override; private: - std::unique_ptr< DocumentEvents_Data > m_pData; + ::cppu::OWeakObject& mrParent; + ::osl::Mutex& mrMutex; + DocumentEventsData& mrEventsData; }; } // namespace dbaccess diff --git a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx index e5f924650b52..4f0f68d306c9 100644 --- a/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx +++ b/dbaccess/source/core/inc/recovery/dbdocrecovery.hxx @@ -24,13 +24,11 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <vector> -#include <memory> namespace dbaccess { // DatabaseDocumentRecovery - struct DatabaseDocumentRecovery_Data; class DatabaseDocumentRecovery { public: @@ -63,7 +61,7 @@ namespace dbaccess ); private: - const std::unique_ptr< DatabaseDocumentRecovery_Data > m_pData; + css::uno::Reference<css::uno::XComponentContext> mxContext; }; } // namespace dbaccess diff --git a/dbaccess/source/core/recovery/dbdocrecovery.cxx b/dbaccess/source/core/recovery/dbdocrecovery.cxx index 1c8763c02b4c..b2b868386304 100644 --- a/dbaccess/source/core/recovery/dbdocrecovery.cxx +++ b/dbaccess/source/core/recovery/dbdocrecovery.cxx @@ -195,20 +195,9 @@ namespace dbaccess } } - // DatabaseDocumentRecovery_Data - struct DatabaseDocumentRecovery_Data - { - const Reference<XComponentContext> aContext; - - explicit DatabaseDocumentRecovery_Data( const Reference<XComponentContext> & i_rContext ) - :aContext( i_rContext ) - { - } - }; - // DatabaseDocumentRecovery DatabaseDocumentRecovery::DatabaseDocumentRecovery( const Reference<XComponentContext> & i_rContext ) - :m_pData( new DatabaseDocumentRecovery_Data( i_rContext ) ) + : mxContext( i_rContext ) { } @@ -244,7 +233,7 @@ namespace dbaccess for ( auto const & component : aComponents ) { - SubComponentRecovery aComponentRecovery( m_pData->aContext, xDatabaseUI, component ); + SubComponentRecovery aComponentRecovery( mxContext, xDatabaseUI, component ); aComponentRecovery.saveToRecoveryStorage( xRecoveryStorage, aMapCompDescs ); } } @@ -253,7 +242,7 @@ namespace dbaccess { Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement( SubComponentRecovery::getComponentsStorageName( elem.first ), ElementModes::WRITE | ElementModes::NOCREATE ) ); - lcl_writeObjectMap_throw( m_pData->aContext, xComponentsStor, elem.second ); + lcl_writeObjectMap_throw( mxContext, xComponentsStor, elem.second ); tools::stor::commitStorageIfWriteable( xComponentsStor ); } } @@ -285,7 +274,7 @@ namespace dbaccess Reference< XStorage > xComponentsStor( xRecoveryStorage->openStorageElement( SubComponentRecovery::getComponentsStorageName( aKnownType ), ElementModes::READ ) ); - lcl_readObjectMap_throw( m_pData->aContext, xComponentsStor, aMapCompDescs[ aKnownType ] ); + lcl_readObjectMap_throw( mxContext, xComponentsStor, aMapCompDescs[ aKnownType ] ); xComponentsStor->dispose(); } @@ -319,7 +308,7 @@ namespace dbaccess // recover the single component Reference< XStorage > xCompStor( xComponentsStor->openStorageElement( elem.first, ElementModes::READ ) ); - SubComponentRecovery aComponentRecovery( m_pData->aContext, xDocumentUI, eComponentType ); + SubComponentRecovery aComponentRecovery( mxContext, xDocumentUI, eComponentType ); Reference< XComponent > xSubComponent( aComponentRecovery.recoverFromStorage( xCompStor, sComponentName, elem.second.bForEditing ) ); // at the moment, we only store, during session save, sub components which are modified. So, set this diff --git a/dbaccess/source/core/recovery/storagetextstream.cxx b/dbaccess/source/core/recovery/storagetextstream.cxx index 32f68da9a087..582e1b78e676 100644 --- a/dbaccess/source/core/recovery/storagetextstream.cxx +++ b/dbaccess/source/core/recovery/storagetextstream.cxx @@ -30,12 +30,6 @@ namespace dbaccess using ::com::sun::star::io::TextOutputStream; using ::com::sun::star::io::XTextOutputStream2; - // StorageTextOutputStream_Data - struct StorageTextOutputStream_Data - { - Reference< XTextOutputStream2 > xTextOutput; - }; - constexpr OUStringLiteral sLineFeed = u"\n"; // StorageTextOutputStream @@ -44,11 +38,10 @@ namespace dbaccess const OUString& i_rStreamName ) :StorageOutputStream( i_rParentStorage, i_rStreamName ) - ,m_pData( new StorageTextOutputStream_Data ) { - m_pData->xTextOutput = TextOutputStream::create( i_rContext ); - m_pData->xTextOutput->setEncoding( "UTF-8" ); - m_pData->xTextOutput->setOutputStream( getOutputStream() ); + mxTextOutput = TextOutputStream::create( i_rContext ); + mxTextOutput->setEncoding( "UTF-8" ); + mxTextOutput->setOutputStream( getOutputStream() ); } StorageTextOutputStream::~StorageTextOutputStream() @@ -57,13 +50,13 @@ namespace dbaccess void StorageTextOutputStream::writeLine( const OUString& i_rLine ) { - m_pData->xTextOutput->writeString( i_rLine ); - m_pData->xTextOutput->writeString( sLineFeed ); + mxTextOutput->writeString( i_rLine ); + mxTextOutput->writeString( sLineFeed ); } void StorageTextOutputStream::writeLine() { - m_pData->xTextOutput->writeString( sLineFeed ); + mxTextOutput->writeString( sLineFeed ); } } // namespace dbaccess diff --git a/dbaccess/source/core/recovery/storagetextstream.hxx b/dbaccess/source/core/recovery/storagetextstream.hxx index 46c3e5b2ee26..31bef3d83bd8 100644 --- a/dbaccess/source/core/recovery/storagetextstream.hxx +++ b/dbaccess/source/core/recovery/storagetextstream.hxx @@ -23,13 +23,12 @@ #include <com/sun/star/uno/XComponentContext.hpp> -#include <memory> +namespace com::sun::star::io { class XTextOutputStream2; } namespace dbaccess { // StorageTextStream - struct StorageTextOutputStream_Data; class StorageTextOutputStream : public StorageOutputStream { public: @@ -44,8 +43,8 @@ namespace dbaccess void writeLine(); private: - std::unique_ptr< StorageTextOutputStream_Data > m_pData; - }; + css::uno::Reference< css::io::XTextOutputStream2 > mxTextOutput; + }; } // namespace dbaccess diff --git a/dbaccess/source/core/recovery/storagexmlstream.cxx b/dbaccess/source/core/recovery/storagexmlstream.cxx index 98e238265b99..e828ac73d38d 100644 --- a/dbaccess/source/core/recovery/storagexmlstream.cxx +++ b/dbaccess/source/core/recovery/storagexmlstream.cxx @@ -25,11 +25,8 @@ #include <com/sun/star/xml/sax/Writer.hpp> #include <rtl/ref.hxx> -#include <comphelper/attributelist.hxx> #include <comphelper/diagnose_ex.hxx> -#include <stack> - namespace dbaccess { @@ -43,28 +40,19 @@ namespace dbaccess using ::com::sun::star::xml::sax::Parser; using ::com::sun::star::xml::sax::InputSource; - // StorageXMLOutputStream_Data - struct StorageXMLOutputStream_Data - { - Reference< XDocumentHandler > xHandler; - std::stack< OUString > aElements; - ::rtl::Reference<comphelper::AttributeList> xAttributes; - }; - // StorageXMLOutputStream StorageXMLOutputStream::StorageXMLOutputStream( const Reference<XComponentContext>& i_rContext, const Reference< XStorage >& i_rParentStorage, const OUString& i_rStreamName ) :StorageOutputStream( i_rParentStorage, i_rStreamName ) - ,m_pData( new StorageXMLOutputStream_Data ) { const Reference< XWriter > xSaxWriter = Writer::create( i_rContext ); xSaxWriter->setOutputStream( getOutputStream() ); - m_pData->xHandler.set( xSaxWriter, UNO_QUERY_THROW ); - m_pData->xHandler->startDocument(); + mxHandler.set( xSaxWriter, UNO_QUERY_THROW ); + mxHandler->startDocument(); - m_pData->xAttributes = new comphelper::AttributeList; + mxAttributes = new comphelper::AttributeList; } StorageXMLOutputStream::~StorageXMLOutputStream() @@ -73,48 +61,48 @@ namespace dbaccess void StorageXMLOutputStream::close() { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "illegal document handler" ); - m_pData->xHandler->endDocument(); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "illegal document handler" ); + mxHandler->endDocument(); // do not call the base class, it would call closeOutput on the output stream, which is already done by // endDocument } void StorageXMLOutputStream::addAttribute( const OUString& i_rName, const OUString& i_rValue ) const { - m_pData->xAttributes->AddAttribute( i_rName, i_rValue ); + mxAttributes->AddAttribute( i_rName, i_rValue ); } - void StorageXMLOutputStream::startElement( const OUString& i_rElementName ) const + void StorageXMLOutputStream::startElement( const OUString& i_rElementName ) { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); - m_pData->xHandler->startElement( i_rElementName, m_pData->xAttributes ); - m_pData->xAttributes = new comphelper::AttributeList; - m_pData->aElements.push( i_rElementName ); + mxHandler->startElement( i_rElementName, mxAttributes ); + mxAttributes = new comphelper::AttributeList; + maElements.push( i_rElementName ); } - void StorageXMLOutputStream::endElement() const + void StorageXMLOutputStream::endElement() { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); - ENSURE_OR_RETURN_VOID( !m_pData->aElements.empty(), "no element on the stack" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( !maElements.empty(), "no element on the stack" ); - const OUString sElementName( m_pData->aElements.top() ); - m_pData->xHandler->endElement( sElementName ); - m_pData->aElements.pop(); + const OUString sElementName( maElements.top() ); + mxHandler->endElement( sElementName ); + maElements.pop(); } void StorageXMLOutputStream::ignorableWhitespace( const OUString& i_rWhitespace ) const { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); - m_pData->xHandler->ignorableWhitespace( i_rWhitespace ); + mxHandler->ignorableWhitespace( i_rWhitespace ); } void StorageXMLOutputStream::characters( const OUString& i_rCharacters ) const { - ENSURE_OR_RETURN_VOID( m_pData->xHandler.is(), "no document handler" ); + ENSURE_OR_RETURN_VOID( mxHandler.is(), "no document handler" ); - m_pData->xHandler->characters( i_rCharacters ); + mxHandler->characters( i_rCharacters ); } // StorageXMLInputStream diff --git a/dbaccess/source/core/recovery/storagexmlstream.hxx b/dbaccess/source/core/recovery/storagexmlstream.hxx index fd762ae05dc8..8a340b6fea0c 100644 --- a/dbaccess/source/core/recovery/storagexmlstream.hxx +++ b/dbaccess/source/core/recovery/storagexmlstream.hxx @@ -25,14 +25,13 @@ #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> - -#include <memory> +#include <comphelper/attributelist.hxx> +#include <rtl/ref.hxx> +#include <stack> namespace dbaccess { - // StorageXMLOutputStream - struct StorageXMLOutputStream_Data; class StorageXMLOutputStream : public StorageOutputStream { public: @@ -47,8 +46,8 @@ namespace dbaccess void addAttribute( const OUString& i_rName, const OUString& i_rValue ) const; - void startElement( const OUString& i_rElementName ) const; - void endElement() const; + void startElement( const OUString& i_rElementName ); + void endElement(); void ignorableWhitespace( const OUString& i_rWhitespace ) const; void characters( const OUString& i_rCharacters ) const; @@ -58,7 +57,9 @@ namespace dbaccess StorageXMLOutputStream& operator=( const StorageXMLOutputStream& ) = delete; private: - std::unique_ptr< StorageXMLOutputStream_Data > m_pData; + css::uno::Reference< css::xml::sax::XDocumentHandler > mxHandler; + std::stack< OUString > maElements; + ::rtl::Reference<comphelper::AttributeList> mxAttributes; }; class StorageXMLInputStream diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx index 074a0113eded..c761f8afe370 100644 --- a/dbaccess/source/core/recovery/subcomponentrecovery.cxx +++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx @@ -170,7 +170,7 @@ namespace dbaccess class SettingsExportContext : public ::xmloff::XMLSettingsExportContext { public: - SettingsExportContext( const Reference<XComponentContext>& i_rContext, const StorageXMLOutputStream& i_rDelegator ) + SettingsExportContext( const Reference<XComponentContext>& i_rContext, StorageXMLOutputStream& i_rDelegator ) :m_rContext( i_rContext ) ,m_rDelegator( i_rDelegator ) ,m_aNamespace( ::xmloff::token::GetXMLToken( ::xmloff::token::XML_NP_CONFIG ) ) @@ -199,7 +199,7 @@ namespace dbaccess private: const Reference<XComponentContext>& m_rContext; - const StorageXMLOutputStream& m_rDelegator; + StorageXMLOutputStream& m_rDelegator; const OUString m_aNamespace; }; diff --git a/dbaccess/source/ui/inc/imageprovider.hxx b/dbaccess/source/ui/inc/imageprovider.hxx index a8d24f4288b9..28784e6dbfa1 100644 --- a/dbaccess/source/ui/inc/imageprovider.hxx +++ b/dbaccess/source/ui/inc/imageprovider.hxx @@ -22,12 +22,10 @@ #include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/sdbc/XConnection.hpp> -#include <memory> +namespace com::sun::star::sdb::application { class XTableUIProvider; } namespace dbaui { - // ImageProvider - struct ImageProvider_Data; /** provides images for database objects such as tables, queries, forms, reports ... At the moment, this class cares for small icons only, that is, icons which can be used @@ -36,9 +34,6 @@ namespace dbaui */ class ImageProvider { - private: - std::shared_ptr< ImageProvider_Data > m_pData; - public: /** creates a semi-functional ImageProvider instance @@ -98,6 +93,13 @@ namespace dbaui the image to be used for folders of this type */ static OUString getDatabaseImage(); + private: + /// the connection we work with + css::uno::Reference< css::sdbc::XConnection > mxConnection; + /// the views of the connection, if the DB supports views + css::uno::Reference< css::container::XNameAccess > mxViews; + /// interface for providing table's UI + css::uno::Reference< css::sdb::application::XTableUIProvider > mxTableUI; }; } // namespace dbaui diff --git a/dbaccess/source/ui/inc/singledoccontroller.hxx b/dbaccess/source/ui/inc/singledoccontroller.hxx index e5e11ba7a2f0..6b535882bc80 100644 --- a/dbaccess/source/ui/inc/singledoccontroller.hxx +++ b/dbaccess/source/ui/inc/singledoccontroller.hxx @@ -31,9 +31,8 @@ class SfxUndoManager; namespace dbaui { +class UndoManager; - // OSingleDocumentController - struct OSingleDocumentController_Data; typedef ::cppu::ImplInheritanceHelper< DBSubComponentController , css::document::XUndoManagerSupplier > OSingleDocumentController_Base; @@ -70,7 +69,8 @@ namespace dbaui using OSingleDocumentController_Base::disposing; private: - std::unique_ptr< OSingleDocumentController_Data > m_pData; + // no Reference! see UndoManager::acquire + std::unique_ptr<UndoManager> m_pUndoManager; }; } // namespace dbaui diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx index e3dea6dd62d0..388df30e271f 100644 --- a/dbaccess/source/ui/misc/imageprovider.cxx +++ b/dbaccess/source/ui/misc/imageprovider.cxx @@ -43,26 +43,16 @@ namespace dbaui namespace GraphicColorMode = css::graphic::GraphicColorMode; namespace DatabaseObject = css::sdb::application::DatabaseObject; - // ImageProvider_Data - struct ImageProvider_Data - { - /// the connection we work with - Reference< XConnection > xConnection; - /// the views of the connection, if the DB supports views - Reference< XNameAccess > xViews; - /// interface for providing table's UI - Reference< XTableUIProvider > xTableUI; - }; - namespace { - void lcl_getConnectionProvidedTableIcon_nothrow( const ImageProvider_Data& _rData, + void lcl_getConnectionProvidedTableIcon_nothrow( + const css::uno::Reference< css::sdb::application::XTableUIProvider >& _xTableUI, const OUString& _rName, Reference< XGraphic >& _out_rxGraphic ) { try { - if ( _rData.xTableUI.is() ) - _out_rxGraphic = _rData.xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL ); + if ( _xTableUI.is() ) + _out_rxGraphic = _xTableUI->getTableIcon( _rName, GraphicColorMode::NORMAL ); } catch( const Exception& ) { @@ -70,13 +60,15 @@ namespace dbaui } } - void lcl_getTableImageResourceID_nothrow( const ImageProvider_Data& _rData, const OUString& _rName, + void lcl_getTableImageResourceID_nothrow( + const css::uno::Reference< css::container::XNameAccess >& _xViews, + const OUString& _rName, OUString& _out_rResourceID) { _out_rResourceID = OUString(); try { - bool bIsView = _rData.xViews.is() && _rData.xViews->hasByName( _rName ); + bool bIsView = _xViews.is() && _xViews->hasByName( _rName ); if ( bIsView ) { _out_rResourceID = VIEW_TREE_ICON; @@ -94,21 +86,19 @@ namespace dbaui } // ImageProvider ImageProvider::ImageProvider() - :m_pData( std::make_shared<ImageProvider_Data>() ) { } ImageProvider::ImageProvider( const Reference< XConnection >& _rxConnection ) - :m_pData( std::make_shared<ImageProvider_Data>() ) + : mxConnection(_rxConnection) { - m_pData->xConnection = _rxConnection; try { - Reference< XViewsSupplier > xSuppViews( m_pData->xConnection, UNO_QUERY ); + Reference< XViewsSupplier > xSuppViews( mxConnection, UNO_QUERY ); if ( xSuppViews.is() ) - m_pData->xViews.set( xSuppViews->getViews(), UNO_SET_THROW ); + mxViews.set( xSuppViews->getViews(), UNO_SET_THROW ); - m_pData->xTableUI.set( _rxConnection, UNO_QUERY ); + mxTableUI.set( _rxConnection, UNO_QUERY ); } catch( const Exception& ) { @@ -127,7 +117,7 @@ namespace dbaui { // no -> determine by type OUString sImageResourceID; - lcl_getTableImageResourceID_nothrow( *m_pData, _rName, sImageResourceID ); + lcl_getTableImageResourceID_nothrow( mxViews, _rName, sImageResourceID ); return sImageResourceID; } } @@ -138,7 +128,7 @@ namespace dbaui if (_nDatabaseObjectType == DatabaseObject::TABLE) { // check whether the connection can give us an icon - lcl_getConnectionProvidedTableIcon_nothrow( *m_pData, _rName, xGraphic ); + lcl_getConnectionProvidedTableIcon_nothrow( mxTableUI, _rName, xGraphic ); } return xGraphic; } diff --git a/dbaccess/source/ui/misc/singledoccontroller.cxx b/dbaccess/source/ui/misc/singledoccontroller.cxx index 28b0c9e774bd..6f58676629d0 100644 --- a/dbaccess/source/ui/misc/singledoccontroller.cxx +++ b/dbaccess/source/ui/misc/singledoccontroller.cxx @@ -35,22 +35,10 @@ namespace dbaui using ::com::sun::star::document::XUndoManager; using ::com::sun::star::beans::PropertyValue; - // OSingleDocumentController_Data - struct OSingleDocumentController_Data - { - // no Reference! see UndoManager::acquire - std::unique_ptr<UndoManager> m_pUndoManager; - - OSingleDocumentController_Data( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex ) - : m_pUndoManager(new UndoManager(i_parent, i_mutex)) - { - } - }; - // OSingleDocumentController OSingleDocumentController::OSingleDocumentController( const Reference< XComponentContext >& _rxORB ) :OSingleDocumentController_Base( _rxORB ) - ,m_pData( new OSingleDocumentController_Data( *this, getMutex() ) ) + ,m_pUndoManager(new UndoManager(*this, getMutex())) { } @@ -62,7 +50,7 @@ namespace dbaui { OSingleDocumentController_Base::disposing(); ClearUndoManager(); - m_pData->m_pUndoManager->disposing(); + m_pUndoManager->disposing(); } void OSingleDocumentController::ClearUndoManager() @@ -72,7 +60,7 @@ namespace dbaui SfxUndoManager& OSingleDocumentController::GetUndoManager() const { - return m_pData->m_pUndoManager->GetSfxUndoManager(); + return m_pUndoManager->GetSfxUndoManager(); } void OSingleDocumentController::addUndoActionAndInvalidate(std::unique_ptr<SfxUndoAction> _pAction) @@ -91,7 +79,7 @@ namespace dbaui Reference< XUndoManager > SAL_CALL OSingleDocumentController::getUndoManager( ) { // see UndoManager::acquire - return m_pData->m_pUndoManager.get(); + return m_pUndoManager.get(); } FeatureState OSingleDocumentController::GetState(sal_uInt16 _nId) const |