diff options
author | Xisco Fauli <anistenis@gmail.com> | 2016-06-06 00:40:56 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-06-09 08:31:18 +0000 |
commit | 5e7564dc6917d65d8b5f30534b78c1fe58cf4463 (patch) | |
tree | 6f4d7f2827d1a8c571fa9556bd8ad97c398f1029 | |
parent | aea4fdb65ace539970e468e77792a377071108b8 (diff) |
tdf#89329: use unique_ptr for pImpl in dataaccessdescriptor
Change-Id: I0d04c23b8760ce2e7df9523d99a1fd862e501038
Reviewed-on: https://gerrit.libreoffice.org/25938
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r-- | include/svx/dataaccessdescriptor.hxx | 14 | ||||
-rw-r--r-- | svx/source/form/dataaccessdescriptor.cxx | 33 |
2 files changed, 3 insertions, 44 deletions
diff --git a/include/svx/dataaccessdescriptor.hxx b/include/svx/dataaccessdescriptor.hxx index 80336b974610..fe04960c4bb4 100644 --- a/include/svx/dataaccessdescriptor.hxx +++ b/include/svx/dataaccessdescriptor.hxx @@ -23,17 +23,13 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <svx/svxdllapi.h> - +#include <memory> namespace svx { - - class ODADescriptorImpl; - //= DataAccessDescriptorProperty - enum DataAccessDescriptorProperty { daDataSource, /// data source name (string) @@ -56,7 +52,6 @@ namespace svx daComponent /// component name (XContent) }; - //= ODataAccessDescriptor /** class encapsulating the css::sdb::DataAccessDescriptor service. @@ -64,7 +59,7 @@ namespace svx class SAL_WARN_UNUSED SVX_DLLPUBLIC ODataAccessDescriptor { protected: - ODADescriptorImpl* m_pImpl; + std::unique_ptr<ODADescriptorImpl> m_pImpl; public: ODataAccessDescriptor(); @@ -112,12 +107,10 @@ namespace svx */ css::uno::Any& operator [] ( DataAccessDescriptorProperty _eWhich ); - /** returns either the data source name if given or the database location */ OUString getDataSource() const; - /** set the data source name, if it is not file URL @param _sDataSourceNameOrLocation the data source name or database location @@ -125,11 +118,8 @@ namespace svx void setDataSource(const OUString& _sDataSourceNameOrLocation); }; - } - #endif // INCLUDED_SVX_DATAACCESSDESCRIPTOR_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/form/dataaccessdescriptor.cxx b/svx/source/form/dataaccessdescriptor.cxx index 935a564f0ff0..29915af33312 100644 --- a/svx/source/form/dataaccessdescriptor.cxx +++ b/svx/source/form/dataaccessdescriptor.cxx @@ -26,11 +26,8 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <tools/urlobj.hxx> - namespace svx { - - using namespace ::com::sun::star::uno; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::beans; @@ -77,14 +74,12 @@ namespace svx static PropertyMapEntry const * getPropertyMapEntry( const DescriptorValues::const_iterator& _rPos ); }; - ODADescriptorImpl::ODADescriptorImpl() :m_bSetOutOfDate(true) ,m_bSequenceOutOfDate(true) { } - ODADescriptorImpl::ODADescriptorImpl(const ODADescriptorImpl& _rSource) :m_bSetOutOfDate( _rSource.m_bSetOutOfDate ) ,m_bSequenceOutOfDate( _rSource.m_bSequenceOutOfDate ) @@ -96,7 +91,6 @@ namespace svx m_aAsSequence = _rSource.m_aAsSequence; } - bool ODADescriptorImpl::buildFrom( const Sequence< PropertyValue >& _rValues ) { const MapString2PropertyEntry& rProperties = getPropertyMap(); @@ -130,7 +124,6 @@ namespace svx return bValidPropsOnly; } - bool ODADescriptorImpl::buildFrom( const Reference< XPropertySet >& _rxValues ) { Reference< XPropertySetInfo > xPropInfo; @@ -168,14 +161,12 @@ namespace svx return bValidPropsOnly; } - void ODADescriptorImpl::invalidateExternRepresentations() { m_bSetOutOfDate = true; m_bSequenceOutOfDate = true; } - const ODADescriptorImpl::MapString2PropertyEntry& ODADescriptorImpl::getPropertyMap( ) { // the properties we know @@ -212,7 +203,6 @@ namespace svx return s_aProperties; } - PropertyMapEntry const * ODADescriptorImpl::getPropertyMapEntry( const DescriptorValues::const_iterator& _rPos ) { const MapString2PropertyEntry& rProperties = getPropertyMap(); @@ -230,7 +220,6 @@ namespace svx throw RuntimeException(); } - PropertyValue ODADescriptorImpl::buildPropertyValue( const DescriptorValues::const_iterator& _rPos ) { // the map entry @@ -247,7 +236,6 @@ namespace svx return aReturn; } - void ODADescriptorImpl::updateSequence() { if (!m_bSequenceOutOfDate) @@ -274,28 +262,23 @@ namespace svx { } - ODataAccessDescriptor::ODataAccessDescriptor( const ODataAccessDescriptor& _rSource ) :m_pImpl(new ODADescriptorImpl(*_rSource.m_pImpl)) { } - ODataAccessDescriptor& ODataAccessDescriptor::operator=(const ODataAccessDescriptor& _rSource) { - delete m_pImpl; - m_pImpl = new ODADescriptorImpl(*_rSource.m_pImpl); + m_pImpl.reset(new ODADescriptorImpl(*_rSource.m_pImpl)); return *this; } - ODataAccessDescriptor::ODataAccessDescriptor( const Reference< XPropertySet >& _rValues ) :m_pImpl(new ODADescriptorImpl) { m_pImpl->buildFrom(_rValues); } - ODataAccessDescriptor::ODataAccessDescriptor( const Any& _rValues ) :m_pImpl(new ODADescriptorImpl) { @@ -308,26 +291,21 @@ namespace svx m_pImpl->buildFrom( xValues ); } - ODataAccessDescriptor::ODataAccessDescriptor( const Sequence< PropertyValue >& _rValues ) :m_pImpl(new ODADescriptorImpl) { m_pImpl->buildFrom(_rValues); } - ODataAccessDescriptor::~ODataAccessDescriptor() { - delete m_pImpl; } - void ODataAccessDescriptor::clear() { m_pImpl->m_aValues.clear(); } - void ODataAccessDescriptor::erase(DataAccessDescriptorProperty _eWhich) { OSL_ENSURE(has(_eWhich), "ODataAccessDescriptor::erase: invalid call!"); @@ -335,13 +313,11 @@ namespace svx m_pImpl->m_aValues.erase(_eWhich); } - bool ODataAccessDescriptor::has(DataAccessDescriptorProperty _eWhich) const { return m_pImpl->m_aValues.find(_eWhich) != m_pImpl->m_aValues.end(); } - const Any& ODataAccessDescriptor::operator [] ( DataAccessDescriptorProperty _eWhich ) const { if (!has(_eWhich)) @@ -354,28 +330,24 @@ namespace svx return m_pImpl->m_aValues[_eWhich]; } - Any& ODataAccessDescriptor::operator[] ( DataAccessDescriptorProperty _eWhich ) { m_pImpl->invalidateExternRepresentations(); return m_pImpl->m_aValues[_eWhich]; } - void ODataAccessDescriptor::initializeFrom(const Sequence< PropertyValue >& _rValues) { clear(); m_pImpl->buildFrom(_rValues); } - Sequence< PropertyValue > ODataAccessDescriptor::createPropertyValueSequence() { m_pImpl->updateSequence(); return m_pImpl->m_aAsSequence; } - OUString ODataAccessDescriptor::getDataSource() const { OUString sDataSourceName; @@ -396,9 +368,6 @@ namespace svx else (*this)[ daDataSource ] <<= OUString(); } - - } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |