diff options
Diffstat (limited to 'dbaccess/source/core')
19 files changed, 308 insertions, 147 deletions
diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index a3a66290d5b5..eda2c1ac8c14 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -430,6 +430,12 @@ void OQuery::registerProperties() } // ----------------------------------------------------------------------------- +::rtl::OUString OQuery::determineContentType() const +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQuery" ) ); +} + +// ----------------------------------------------------------------------------- //........................................................................ } // namespace dbaccess //........................................................................ diff --git a/dbaccess/source/core/api/query.hxx b/dbaccess/source/core/api/query.hxx index 2055100e7179..dd200764d364 100644 --- a/dbaccess/source/core/api/query.hxx +++ b/dbaccess/source/core/api/query.hxx @@ -169,6 +169,9 @@ protected: virtual void rebuildColumns( ); + // OContentHelper overridables + virtual ::rtl::OUString determineContentType() const; + private: void registerProperties(); }; diff --git a/dbaccess/source/core/api/querycontainer.cxx b/dbaccess/source/core/api/querycontainer.cxx index 00ce37c4191e..89124a9751c9 100644 --- a/dbaccess/source/core/api/querycontainer.cxx +++ b/dbaccess/source/core/api/querycontainer.cxx @@ -387,6 +387,13 @@ void SAL_CALL OQueryContainer::disposing( const ::com::sun::star::lang::EventObj ODefinitionContainer::disposing(_rSource); } } + +// ----------------------------------------------------------------------------- +::rtl::OUString OQueryContainer::determineContentType() const +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseQueryContainer" ) ); +} + // ----------------------------------------------------------------------------- Reference< XContent > OQueryContainer::implCreateWrapper(const ::rtl::OUString& _rName) { diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx index b26a7c46f9f9..452931848e5c 100644 --- a/dbaccess/source/core/dataaccess/ComponentDefinition.cxx +++ b/dbaccess/source/core/dataaccess/ComponentDefinition.cxx @@ -240,6 +240,15 @@ Reference< XPropertySetInfo > SAL_CALL OComponentDefinition::getPropertySetInfo( Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) ); return xInfo; } + +// ----------------------------------------------------------------------------- +::rtl::OUString OComponentDefinition::determineContentType() const +{ + return m_bTable + ? ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseTable" ) ) + : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseCommandDefinition" ) ); +} + // ----------------------------------------------------------------------------- Reference< XNameAccess> OComponentDefinition::getColumns() throw (RuntimeException) { diff --git a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx index acf908ee762d..e6f49dbbcbe6 100644 --- a/dbaccess/source/core/dataaccess/ComponentDefinition.hxx +++ b/dbaccess/source/core/dataaccess/ComponentDefinition.hxx @@ -195,6 +195,10 @@ protected: virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); + + // OContentHelper overridables + virtual ::rtl::OUString determineContentType() const; + private: void registerProperties(); }; diff --git a/dbaccess/source/core/dataaccess/ContentHelper.cxx b/dbaccess/source/core/dataaccess/ContentHelper.cxx index e4c1d781d63b..b43292aada37 100644 --- a/dbaccess/source/core/dataaccess/ContentHelper.cxx +++ b/dbaccess/source/core/dataaccess/ContentHelper.cxx @@ -159,9 +159,16 @@ Reference< XContentIdentifier > SAL_CALL OContentHelper::getIdentifier( ) throw // return Reference< XContentIdentifier >(); } // ----------------------------------------------------------------------------- -::rtl::OUString SAL_CALL OContentHelper::getContentType( ) throw (RuntimeException) +::rtl::OUString SAL_CALL OContentHelper::getContentType() throw (RuntimeException) { - return getImplementationName(); + ::osl::MutexGuard aGuard(m_aMutex); + + if ( !m_pImpl->m_aProps.aContentType ) + { // content type not yet retrieved + m_pImpl->m_aProps.aContentType.reset( determineContentType() ); + } + + return *m_pImpl->m_aProps.aContentType; } // ----------------------------------------------------------------------------- void SAL_CALL OContentHelper::addContentEventListener( const Reference< XContentEventListener >& _rxListener ) throw (RuntimeException) @@ -415,7 +422,7 @@ Sequence< Any > OContentHelper::setPropertyValues(const Sequence< PropertyValue try { - rename( aNewValue ); + impl_rename_throw( aNewValue ,false); OSL_ENSURE( m_pImpl->m_aProps.aTitle == aNewValue, "OContentHelper::setPropertyValues('Title'): rename did not work!" ); aEvent.NewValue = makeAny( aNewValue ); @@ -491,7 +498,7 @@ Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ContentType" ) ) ) { - xRow->appendString ( rProp, m_pImpl->m_aProps.aContentType ); + xRow->appendString ( rProp, getContentType() ); } else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { @@ -526,7 +533,7 @@ Reference< XRow > OContentHelper::getPropertyValues( const Sequence< Property >& getCppuType( static_cast< const rtl::OUString * >( 0 ) ), PropertyAttribute::BOUND | PropertyAttribute::READONLY ), - m_pImpl->m_aProps.aContentType ); + getContentType() ); xRow->appendString ( Property( rtl::OUString::createFromAscii( "Title" ), -1, @@ -669,42 +676,69 @@ void SAL_CALL OContentHelper::setParent( const Reference< XInterface >& _xParent } // ----------------------------------------------------------------------------- -void SAL_CALL OContentHelper::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException) +void OContentHelper::impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify ) { - ::osl::MutexGuard aGuard(m_aMutex); - if ( newName.equals( m_pImpl->m_aProps.aTitle ) ) + osl::ClearableGuard< osl::Mutex > aGuard(m_aMutex); + if ( _sNewName.equals( m_pImpl->m_aProps.aTitle ) ) return; - - Reference<XNameContainer> xNameCont(m_xParentContainer,UNO_QUERY); - if ( xNameCont.is() ) + try { - if ( xNameCont->hasByName(newName) ) - throw ElementExistException(newName,*this); + Sequence< PropertyChangeEvent > aChanges( 1 ); - try - { - if ( xNameCont->hasByName(m_pImpl->m_aProps.aTitle) ) - xNameCont->removeByName(m_pImpl->m_aProps.aTitle); + aChanges[0].Source = static_cast< cppu::OWeakObject * >( this ); + aChanges[0].Further = sal_False; + aChanges[0].PropertyName = PROPERTY_NAME; + aChanges[0].PropertyHandle = PROPERTY_ID_NAME; + aChanges[0].OldValue <<= m_pImpl->m_aProps.aTitle; + aChanges[0].NewValue <<= _sNewName; - m_pImpl->m_aProps.aTitle = newName; - xNameCont->insertByName(m_pImpl->m_aProps.aTitle,makeAny(Reference<XContent>(*this,UNO_QUERY))); - notifyDataSourceModified(); - } - catch(IllegalArgumentException) - { - throw SQLException(); - } - catch(NoSuchElementException) - { - throw SQLException(); - } - catch(WrappedTargetException) - { - throw SQLException(); - } + aGuard.clear(); + + m_pImpl->m_aProps.aTitle = _sNewName; + if ( _bNotify ) + notifyPropertiesChange( aChanges ); + notifyDataSourceModified(); } - else - m_pImpl->m_aProps.aTitle = newName; + catch(const PropertyVetoException&) + { + throw ElementExistException(_sNewName,*this); + } +} +// ----------------------------------------------------------------------------- +void SAL_CALL OContentHelper::rename( const ::rtl::OUString& newName ) throw (SQLException, ElementExistException, RuntimeException) +{ + + impl_rename_throw(newName); + //Reference<XNameContainer> xNameCont(m_xParentContainer,UNO_QUERY); + //if ( xNameCont.is() ) + //{ + // if ( xNameCont->hasByName(newName) ) + // throw ElementExistException(newName,*this); + + // try + // { + // if ( xNameCont->hasByName(m_pImpl->m_aProps.aTitle) ) + // xNameCont->removeByName(m_pImpl->m_aProps.aTitle); + + // m_pImpl->m_aProps.aTitle = newName; + // xNameCont->insertByName(m_pImpl->m_aProps.aTitle,makeAny(Reference<XContent>(*this,UNO_QUERY))); + // notifyDataSourceModified(); + // } + // catch(IllegalArgumentException) + // { + // throw SQLException(); + // } + // catch(NoSuchElementException) + // { + // throw SQLException(); + // } + // catch(WrappedTargetException) + // { + // throw SQLException(); + // } + //} + //else + // m_pImpl->m_aProps.aTitle = newName; } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/dataaccess/commandcontainer.cxx b/dbaccess/source/core/dataaccess/commandcontainer.cxx index 0a7e0449b53e..2c51a9b18869 100644 --- a/dbaccess/source/core/dataaccess/commandcontainer.cxx +++ b/dbaccess/source/core/dataaccess/commandcontainer.cxx @@ -69,7 +69,7 @@ OCommandContainer::OCommandContainer( const Reference< ::com::sun::star::lang::X ,const TContentPtr& _pImpl ,sal_Bool _bTables ) - :ODefinitionContainer(_xORB,_xParentContainer,_pImpl) + :ODefinitionContainer(_xORB,_xParentContainer,_pImpl,!_bTables) ,m_bTables(_bTables) { DBG_CTOR(OCommandContainer, NULL); @@ -106,6 +106,12 @@ Reference< XInterface > SAL_CALL OCommandContainer::createInstance( ) throw (Exc return m_aContext.createComponent( (::rtl::OUString)( m_bTables ? SERVICE_SDB_TABLEDEFINITION : SERVICE_SDB_COMMAND_DEFINITION ) ); } +// ----------------------------------------------------------------------------- +::rtl::OUString OCommandContainer::determineContentType() const +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.org.openoffice.DatabaseCommandDefinitionContainer" ) ); +} + //........................................................................ } // namespace dbaccess //........................................................................ diff --git a/dbaccess/source/core/dataaccess/commandcontainer.hxx b/dbaccess/source/core/dataaccess/commandcontainer.hxx index 19cd8e717a6b..4015b1072470 100644 --- a/dbaccess/source/core/dataaccess/commandcontainer.hxx +++ b/dbaccess/source/core/dataaccess/commandcontainer.hxx @@ -81,6 +81,10 @@ protected: // ODefinitionContainer virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject(const ::rtl::OUString& _rName); + +protected: + // OContentHelper overridables + virtual ::rtl::OUString determineContentType() const; }; //........................................................................ diff --git a/dbaccess/source/core/dataaccess/commanddefinition.hxx b/dbaccess/source/core/dataaccess/commanddefinition.hxx index bd849f89e464..6a50395d11ed 100644 --- a/dbaccess/source/core/dataaccess/commanddefinition.hxx +++ b/dbaccess/source/core/dataaccess/commanddefinition.hxx @@ -132,6 +132,7 @@ public: // OPropertySetHelper DECLARE_PROPERTYCONTAINER_DEFAULTS( ); + private: // helper void registerProperties(); diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx index 5b023dcaff4f..01a3b65b5c8a 100644 --- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx +++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx @@ -144,11 +144,13 @@ DBG_NAME(ODefinitionContainer) ODefinitionContainer::ODefinitionContainer( const Reference< XMultiServiceFactory >& _xORB , const Reference< XInterface >& _xParentContainer , const TContentPtr& _pImpl + , bool _bCheckSlash ) :OContentHelper(_xORB,_xParentContainer,_pImpl) ,m_aApproveListeners(m_aMutex) ,m_aContainerListeners(m_aMutex) ,m_bInPropertyChange(sal_False) + ,m_bCheckSlash(_bCheckSlash) { m_pImpl->m_aProps.bIsDocument = sal_False; m_pImpl->m_aProps.bIsFolder = sal_True; @@ -645,7 +647,7 @@ void ODefinitionContainer::approveNewObject(const ::rtl::OUString& _sName,const *this, 0 ); - if ( _sName.indexOf( '/' ) != -1 ) + if ( m_bCheckSlash && _sName.indexOf( '/' ) != -1 ) throw IllegalArgumentException( m_aErrorHelper.getErrorMessage( ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES ), *this, @@ -681,7 +683,7 @@ void ODefinitionContainer::approveNewObject(const ::rtl::OUString& _sName,const void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException) { ClearableMutexGuard aGuard(m_aMutex); - if(evt.PropertyName == (rtl::OUString) PROPERTY_NAME) + if(evt.PropertyName == (rtl::OUString) PROPERTY_NAME || evt.PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) )) { m_bInPropertyChange = sal_True; try @@ -708,7 +710,7 @@ void SAL_CALL ODefinitionContainer::vetoableChange( const PropertyChangeEvent& a { MutexGuard aGuard(m_aMutex); - if(aEvent.PropertyName == (rtl::OUString) PROPERTY_NAME) + if(aEvent.PropertyName == (rtl::OUString) PROPERTY_NAME || aEvent.PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { ::rtl::OUString sNewName; aEvent.NewValue >>= sNewName; @@ -725,7 +727,10 @@ void ODefinitionContainer::addObjectListener(const Reference< XContent >& _xNewO { xProp->addPropertyChangeListener(PROPERTY_NAME, this); xProp->addVetoableChangeListener(PROPERTY_NAME, this); - } + //::rtl::OUString sTitle(RTL_CONSTASCII_USTRINGPARAM( "Title" )); + //xProp->addPropertyChangeListener(sTitle, this); + //xProp->addVetoableChangeListener(sTitle, this); + } // if ( xProp.is() ) } // ----------------------------------------------------------------------------- void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xNewObject) @@ -736,6 +741,9 @@ void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xN { xProp->removePropertyChangeListener(PROPERTY_NAME, this); xProp->removeVetoableChangeListener(PROPERTY_NAME, this); + //::rtl::OUString sTitle(RTL_CONSTASCII_USTRINGPARAM( "Title" )); + //xProp->removePropertyChangeListener(sTitle, this); + //xProp->removeVetoableChangeListener(sTitle, this); } } // ----------------------------------------------------------------------------- diff --git a/dbaccess/source/core/dataaccess/documentcontainer.cxx b/dbaccess/source/core/dataaccess/documentcontainer.cxx index 859855b0bc0c..6ccbb4d03a03 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.cxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.cxx @@ -181,7 +181,12 @@ Sequence< ::rtl::OUString > SAL_CALL ODocumentContainer::getSupportedServiceName aSupported[0] = m_bFormsContainer ? SERVICE_NAME_FORM_COLLECTION : SERVICE_NAME_REPORT_COLLECTION; return aSupported; } + // ----------------------------------------------------------------------------- +::rtl::OUString ODocumentContainer::determineContentType() const +{ + return ::rtl::OUString(); +} //-------------------------------------------------------------------------- Reference< XContent > ODocumentContainer::createObject( const ::rtl::OUString& _rName) @@ -288,7 +293,7 @@ Reference< XInterface > SAL_CALL ODocumentContainer::createInstanceWithArguments } if ( ( aClassID.getLength() == 0 ) && ( 0 == sURL.getLength() ) ) - ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext.getLegacyServiceFactory(), aClassID ); + ODocumentDefinition::GetDocumentServiceFromMediaType( getContainerStorage(), sPersistentName, m_aContext, aClassID ); } ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( sName ); diff --git a/dbaccess/source/core/dataaccess/documentcontainer.hxx b/dbaccess/source/core/dataaccess/documentcontainer.hxx index 888798495a0e..b5c5a16e0383 100644 --- a/dbaccess/source/core/dataaccess/documentcontainer.hxx +++ b/dbaccess/source/core/dataaccess/documentcontainer.hxx @@ -134,11 +134,16 @@ public: // helper ::rtl::Reference<OContentHelper> getContent(const ::rtl::OUString& _sName) const; - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> getContainerStorage() const; + ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > getContainerStorage() const; protected: virtual ~ODocumentContainer(); -// ODefinitionContainer + + /** OContentHelper + */ + virtual ::rtl::OUString determineContentType() const; + + // ODefinitionContainer virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent > createObject( const ::rtl::OUString& _rName ); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index db239fd11654..50c3083fbc9a 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -283,13 +283,38 @@ namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject; #define DEFAULT_WIDTH 10000 #define DEFAULT_HEIGHT 7500 -//........................................................................ +//............................................................................. namespace dbaccess { -//........................................................................ +//............................................................................. typedef ::boost::optional< bool > optional_bool; + //========================================================================= + //= helper + //========================================================================= + namespace + { + // -------------------------------------------------------------------- + ::rtl::OUString lcl_determineContentType_nothrow( const Reference< XStorage >& _rxContainerStorage, + const ::rtl::OUString& _rEntityName ) + { + ::rtl::OUString sContentType; + try + { + Reference< XStorage > xContainerStorage( _rxContainerStorage, UNO_QUERY_THROW ); + ::utl::SharedUNOComponent< XPropertySet > xStorageProps( + xContainerStorage->openStorageElement( _rEntityName, ElementModes::READ ), UNO_QUERY_THROW ); + OSL_VERIFY( xStorageProps->getPropertyValue( INFO_MEDIATYPE ) >>= sContentType ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sContentType; + } + } + //================================================================== // OEmbedObjectHolder //================================================================== @@ -467,61 +492,47 @@ namespace dbaccess m_xParentContainer = _xParent; } -::rtl::OUString ODocumentDefinition::GetDocumentServiceFromMediaType( const Reference< XStorage >& xStorage - ,const ::rtl::OUString& sEntName - ,const Reference< XMultiServiceFactory >& _xORB - ,Sequence< sal_Int8 >& _rClassId - ) +// ----------------------------------------------------------------------------- +::rtl::OUString ODocumentDefinition::GetDocumentServiceFromMediaType( const Reference< XStorage >& _rxContainerStorage, + const ::rtl::OUString& _rEntityName, const ::comphelper::ComponentContext& _rContext, + Sequence< sal_Int8 >& _rClassId ) +{ + return GetDocumentServiceFromMediaType( + lcl_determineContentType_nothrow( _rxContainerStorage, _rEntityName ), + _rContext, _rClassId ); +} + +// ----------------------------------------------------------------------------- +::rtl::OUString ODocumentDefinition::GetDocumentServiceFromMediaType( const ::rtl::OUString& _rMediaType, + const ::comphelper::ComponentContext& _rContext, Sequence< sal_Int8 >& _rClassId ) { ::rtl::OUString sResult; try { - if ( xStorage->isStorageElement( sEntName ) ) + ::comphelper::MimeConfigurationHelper aConfigHelper( _rContext.getLegacyServiceFactory() ); + sResult = aConfigHelper.GetDocServiceNameFromMediaType( _rMediaType ); + _rClassId = aConfigHelper.GetSequenceClassIDRepresentation(aConfigHelper.GetExplicitlyRegisteredObjClassID( _rMediaType )); + if ( !_rClassId.getLength() && sResult.getLength() ) { - // the object must be based on storage - - Reference< XPropertySet > xPropSet( xStorage->openStorageElement( sEntName, ElementModes::READ ), UNO_QUERY_THROW ); - - ::rtl::OUString aMediaType; - try { - Any aAny = xPropSet->getPropertyValue( INFO_MEDIATYPE ); - aAny >>= aMediaType; - } - catch ( Exception& ) + Reference< XNameAccess > xObjConfig = aConfigHelper.GetObjConfiguration(); + if ( xObjConfig.is() ) { - } - ::comphelper::MimeConfigurationHelper aConfigHelper(_xORB); - sResult = aConfigHelper.GetDocServiceNameFromMediaType(aMediaType); - _rClassId = aConfigHelper.GetSequenceClassIDRepresentation(aConfigHelper.GetExplicitlyRegisteredObjClassID(aMediaType)); - if ( !_rClassId.getLength() && sResult.getLength() ) - { - Reference< XNameAccess > xObjConfig = aConfigHelper.GetObjConfiguration(); - if ( xObjConfig.is() ) + Sequence< ::rtl::OUString > aClassIDs = xObjConfig->getElementNames(); + for ( sal_Int32 nInd = 0; nInd < aClassIDs.getLength(); nInd++ ) { - try + Reference< XNameAccess > xObjectProps; + ::rtl::OUString aEntryDocName; + + if ( ( xObjConfig->getByName( aClassIDs[nInd] ) >>= xObjectProps ) && xObjectProps.is() + && ( xObjectProps->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ObjectDocumentServiceName")) + ) >>= aEntryDocName ) + && aEntryDocName.equals( sResult ) ) { - Sequence< ::rtl::OUString > aClassIDs = xObjConfig->getElementNames(); - for ( sal_Int32 nInd = 0; nInd < aClassIDs.getLength(); nInd++ ) - { - Reference< XNameAccess > xObjectProps; - ::rtl::OUString aEntryDocName; - - if ( ( xObjConfig->getByName( aClassIDs[nInd] ) >>= xObjectProps ) && xObjectProps.is() - && ( xObjectProps->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ObjectDocumentServiceName")) - ) >>= aEntryDocName ) - && aEntryDocName.equals( sResult ) ) - { - _rClassId = aConfigHelper.GetSequenceClassIDRepresentation(aClassIDs[nInd]); - break; - } - } + _rClassId = aConfigHelper.GetSequenceClassIDRepresentation(aClassIDs[nInd]); + break; } - catch( Exception& ) - {} } } - - ::comphelper::disposeComponent( xPropSet ); } } catch ( Exception& ) @@ -1030,8 +1041,8 @@ void ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, con impl_onActivateEmbeddedObject(); } - // LLA: Alle fillReportData() calls prfen, sollte es welche geben, die danach noch viel machen - // LLA: sollten wir einen _aGuard Pointer bergeben, sonst erstmal als Referenz + // LLA: Alle fillReportData() calls prfen, sollte es welche geben, die danach noch viel machen + // LLA: sollten wir einen _aGuard Pointer bergeben, sonst erstmal als Referenz fillReportData(_aGuard); _out_rComponent <<= xModel; } @@ -1094,10 +1105,13 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co Environment ); // Unreachable } - Reference< XStorage> xStorage(aIni[0],UNO_QUERY); + Reference< XStorage> xDest(aIni[0],UNO_QUERY); ::rtl::OUString sPersistentName; aIni[1] >>= sPersistentName; - loadEmbeddedObject( true ); + Reference< XStorage> xStorage = getContainerStorage(); + // ----------------------------------------------------------------------------- + xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xDest,sPersistentName); + /*loadEmbeddedObject( true ); Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY); if ( xPersist.is() ) { @@ -1106,7 +1120,7 @@ Any SAL_CALL ODocumentDefinition::execute( const Command& aCommand, sal_Int32 Co m_xEmbeddedObject->changeState(EmbedStates::LOADED); } else - throw CommandAbortedException(); + throw CommandAbortedException();*/ } else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "preview" ) ) ) { @@ -1529,7 +1543,15 @@ namespace // ----------------------------------------------------------------------------- sal_Bool ODocumentDefinition::objectSupportsEmbeddedScripts() const { - bool bAllowDocumentMacros = !m_pImpl->m_pDataSource || m_pImpl->m_pDataSource->hasAnyObjectWithMacros(); +// bool bAllowDocumentMacros = !m_pImpl->m_pDataSource || m_pImpl->m_pDataSource->hasAnyObjectWithMacros(); + // TODO: revert to the disabled code. The current version is just to be able + // to integrate an intermediate version of the CWS, which should behave as + // if no macros in DB docs are allowed + bool bAllowDocumentMacros = !m_pImpl->m_pDataSource->hasMacroStorages(); + // even if the current version is not able to create documents which contain macros, + // later versions will be. Such documents contain macro/script storages in the + // document root storage, in which case we need to disable the per-form/report + // scripting. // if *any* of the objects of the database document already has macros, we continue to allow it // to have them, until the user did a migration. @@ -1537,6 +1559,13 @@ sal_Bool ODocumentDefinition::objectSupportsEmbeddedScripts() const return bAllowDocumentMacros; } + +// ----------------------------------------------------------------------------- +::rtl::OUString ODocumentDefinition::determineContentType() const +{ + return lcl_determineContentType_nothrow( getContainerStorage(), m_pImpl->m_aProps.sPersistentName ); +} + // ----------------------------------------------------------------------------- Sequence< PropertyValue > ODocumentDefinition::fillLoadArgs( const Reference< XConnection>& _xConnection, const bool _bSuppressMacros, const bool _bReadOnly, const Sequence< PropertyValue >& _rAdditionalArgs, Sequence< PropertyValue >& _out_rEmbeddedObjectDescriptor ) @@ -1629,7 +1658,7 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& _x } else { - sDocumentService = GetDocumentServiceFromMediaType( xStorage, m_pImpl->m_aProps.sPersistentName, m_aContext.getLegacyServiceFactory(), aClassID ); + sDocumentService = GetDocumentServiceFromMediaType( getContentType(), m_aContext, aClassID ); // check if we are not a form and // the com.sun.star.report.pentaho.SOReportJobFactory is not present. if ( !m_bForm && !sDocumentService.equalsAscii("com.sun.star.text.TextDocument")) @@ -1642,6 +1671,7 @@ void ODocumentDefinition::loadEmbeddedObject( const Reference< XConnection >& _x { com::sun::star::io::WrongFormatException aWFE; aWFE.Message = ::rtl::OUString::createFromAscii("Extension not present."); + // TODO: resource throw aWFE; } } diff --git a/dbaccess/source/core/dataaccess/documentdefinition.hxx b/dbaccess/source/core/dataaccess/documentdefinition.hxx index 97c3aa85659e..510d9f30153c 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.hxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.hxx @@ -168,11 +168,17 @@ public: static ::com::sun::star::uno::Sequence< sal_Int8 > getDefaultDocumentTypeClassId(); - static ::rtl::OUString GetDocumentServiceFromMediaType( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage - ,const ::rtl::OUString& sEntName - ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB - ,::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId - ); + static ::rtl::OUString GetDocumentServiceFromMediaType( + const ::rtl::OUString& _rMediaType, + const ::comphelper::ComponentContext& _rContext, + ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId + ); + static ::rtl::OUString GetDocumentServiceFromMediaType( + const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _rxContainerStorage, + const ::rtl::OUString& _rEntityName, + const ::comphelper::ComponentContext& _rContext, + ::com::sun::star::uno::Sequence< sal_Int8 >& _rClassId + ); private: /** does necessary initializations after our embedded object has been switched to ACTIVE @@ -211,14 +217,18 @@ private: bool impl_close_throw(); -protected: +private: // OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; virtual void getPropertyDefaultByHandle( sal_Int32 _nHandle, ::com::sun::star::uno::Any& _rDefault ) const; + // helper virtual void SAL_CALL disposing(); + // OContentHelper overridables + virtual ::rtl::OUString determineContentType() const; + private: /** fills the load arguments */ diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx index 697ec70fcdb2..0f5247528709 100644 --- a/dbaccess/source/core/inc/ContentHelper.hxx +++ b/dbaccess/source/core/inc/ContentHelper.hxx @@ -103,7 +103,8 @@ namespace dbaccess struct ContentProperties { ::rtl::OUString aTitle; // Title - ::rtl::OUString aContentType; // ContentType + ::boost::optional< ::rtl::OUString > + aContentType; // ContentType (aka MediaType aka MimeType) sal_Bool bIsDocument; // IsDocument sal_Bool bIsFolder; // IsFolder sal_Bool bAsTemplate; // AsTemplate @@ -156,6 +157,8 @@ namespace dbaccess getProperties( const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv ); + void impl_rename_throw(const ::rtl::OUString& _sNewName,bool _bNotify = true); + protected: ::cppu::OInterfaceContainerHelper m_aContentListeners; PropertyChangeListenerContainer m_aPropertyChangeListeners; @@ -231,6 +234,9 @@ namespace dbaccess ::com::sun::star::beans::Property >& rProperties ); inline TContentPtr getImpl() const { return m_pImpl; } + + protected: + virtual ::rtl::OUString determineContentType() const = 0; }; //........................................................................ diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx index 31f3d694bbbf..68d67808e921 100644 --- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -202,8 +202,8 @@ private: virtual void SAL_CALL disposing(); void impl_fillRowSet_throw(); - bool impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies); - bool fillParameters( ::osl::ResettableMutexGuard& _rClearForNotifies, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxCompletionHandler ); + void impl_executeRowSet_nothrow(::osl::ResettableMutexGuard& _rClearForNotifies); + bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies); void impl_fillInternalDataProvider_throw(); void impl_invalidateParameter_nothrow(); @@ -228,6 +228,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xInternal; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeXMLConversion> m_xRangeConversion; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xHandler; // the object doin' most of the work - an SDB-rowset ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xAggregateSet; diff --git a/dbaccess/source/core/inc/definitioncontainer.hxx b/dbaccess/source/core/inc/definitioncontainer.hxx index 0740eab777e9..0abbe34aa95a 100644 --- a/dbaccess/source/core/inc/definitioncontainer.hxx +++ b/dbaccess/source/core/inc/definitioncontainer.hxx @@ -174,6 +174,7 @@ protected: m_aContainerListeners; sal_Bool m_bInPropertyChange; + bool m_bCheckSlash; protected: /** Additionally to our own approvals which new elements must pass, derived classes @@ -204,7 +205,8 @@ public: ODefinitionContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParentContainer - ,const TContentPtr& _pImpl + , const TContentPtr& _pImpl + , bool _bCheckSlash = true ); // ::com::sun::star::uno::XInterface diff --git a/dbaccess/source/core/inc/querycontainer.hxx b/dbaccess/source/core/inc/querycontainer.hxx index 08830d4ccc2b..869371f7ade4 100644 --- a/dbaccess/source/core/inc/querycontainer.hxx +++ b/dbaccess/source/core/inc/querycontainer.hxx @@ -209,6 +209,10 @@ namespace dbaccess // ::com::sun::star::container::XNameAccess virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException); + protected: + // OContentHelper overridables + virtual ::rtl::OUString determineContentType() const; + private: // helper /** create a query object wrapping a CommandDefinition given by name. To retrieve the object, the CommandDescription diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index d6851cf14901..33c437f970b9 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -6,8 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: DatabaseDataProvider.cxx,v $ - * $Revision: 1.5.34.1 $ + * $RCSfile$ + * $Revision$ * * This file is part of OpenOffice.org. * @@ -35,6 +35,7 @@ #include "cppuhelper/implbase1.hxx" #include <comphelper/types.hxx> #include <connectivity/FValue.hxx> +#include <connectivity/dbtools.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/task/XInteractionHandler.hpp> @@ -42,8 +43,6 @@ #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> -#include <com/sun/star/sdbc/XResultSetMetaData.hpp> -#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/XChartDataArray.hpp> @@ -86,7 +85,7 @@ DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContex m_xAggregate.set(m_xRowSet,uno::UNO_QUERY); m_xAggregateSet.set(m_xRowSet,uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xProp(static_cast< ::cppu::OWeakObject* >( this ),uno::UNO_QUERY); - m_aFilterManager.initialize( xProp, m_xAggregateSet ); + m_aFilterManager.initialize( m_xAggregateSet ); m_aParameterManager.initialize( xProp, m_xAggregate ); m_xAggregateSet->setPropertyValue(PROPERTY_COMMAND_TYPE,uno::makeAny(m_CommandType)); m_xAggregateSet->setPropertyValue(PROPERTY_ESCAPE_PROCESSING,uno::makeAny(m_EscapeProcessing)); @@ -158,12 +157,14 @@ uno::Reference< uno::XInterface > DatabaseDataProvider::Create(uno::Reference< u void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception) { osl::MutexGuard g(m_aMutex); - const uno::Any* pIter = aArguments.getConstArray(); - const uno::Any* pEnd = pIter + aArguments.getLength(); + const uno::Any* pIter = aArguments.getConstArray(); + const uno::Any* pEnd = pIter + aArguments.getLength(); for(;pIter != pEnd;++pIter) { - if ( !m_xActiveConnection.is() && ((*pIter) >>= m_xActiveConnection) ) - break; + if ( !m_xActiveConnection.is() ) + (*pIter) >>= m_xActiveConnection; + else if ( !m_xHandler.is() ) + (*pIter) >>= m_xHandler; } m_xAggregateSet->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, uno::makeAny( m_xActiveConnection ) ); } @@ -179,14 +180,12 @@ void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & try { impl_fillRowSet_throw(); - bRet = impl_executeRowSet_throw(aClearForNotifies); - if ( bRet ) - impl_fillInternalDataProvider_throw(); + impl_executeRowSet_nothrow(aClearForNotifies); + impl_fillInternalDataProvider_throw(); + bRet = true; } - catch(const uno::Exception& e) + catch(const uno::Exception& /*e*/) { - (void)e; - OSL_ENSURE(0,"Exception caught!"); } } if ( !bRet ) // no command set or an error occured, use Internal data handler @@ -500,18 +499,16 @@ void SAL_CALL DatabaseDataProvider::setDataSourceName(const ::rtl::OUString& the set(PROPERTY_DATASOURCENAME,the_value,m_DataSourceName); } // ----------------------------------------------------------------------------- -bool DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies) +void DatabaseDataProvider::impl_executeRowSet_nothrow(::osl::ResettableMutexGuard& _rClearForNotifies) { - uno::Reference<task::XInteractionHandler> xHandler( - m_xContext->getServiceManager()->createInstanceWithContext( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.InteractionHandler")) - ,m_xContext), - uno::UNO_QUERY); - if (!fillParameters(_rClearForNotifies, xHandler)) - return false; - - m_xRowSet->execute(); - return true; + try + { + if ( impl_fillParameters_nothrow(_rClearForNotifies) ) + m_xRowSet->execute(); + } + catch(const uno::Exception&) + { + } } // ----------------------------------------------------------------------------- void DatabaseDataProvider::impl_fillInternalDataProvider_throw() @@ -519,19 +516,25 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw() // clear the data before fill the new one uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY); if ( xChartData.is() ) + { xChartData->setData(uno::Sequence< uno::Sequence<double> >()); + xChartData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >()); + m_xInternal->deleteSequence(0); + } + + uno::Sequence< ::rtl::OUString > aColumns = ::dbtools::getFieldNamesByCommandDescriptor(getActiveConnection() + ,getCommandType() + ,m_Command); // fill the data - uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY); - uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY); - uno::Reference< sdbc::XResultSetMetaDataSupplier> xResMDSup(m_xRowSet,uno::UNO_QUERY); - uno::Reference< sdbc::XResultSetMetaData> xResultSetMetaData = xResMDSup->getMetaData(); + uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW); + uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW); uno::Sequence< uno::Any > aLabelArgs(1); - const sal_Int32 nCount = xResultSetMetaData->getColumnCount(); - for (sal_Int32 i = 2; i <= nCount; ++i) + const sal_Int32 nCount = aColumns.getLength(); + for (sal_Int32 i = 1; i < nCount; ++i) { - aLabelArgs[0] <<= xResultSetMetaData->getColumnName(i); + aLabelArgs[0] <<= aColumns[i]; // i == 0 is the category const ::rtl::OUString sLabelRange = lcl_getLabel() + ::rtl::OUString::valueOf(i - 1); m_xInternal->setDataByRangeRepresentation(sLabelRange,aLabelArgs); } @@ -543,6 +546,22 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw() ++nRowCount; for (sal_Int32 j = 1; j <= nCount; ++j) aDataValues[j-1].push_back(uno::makeAny(xRow->getString(j))); + } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) + if ( !nRowCount ) + { + nRowCount = 3; + const double fDefaultData[ ] = + { 9.10, 3.20, 4.54, + 2.40, 8.80, 9.65, + 3.10, 1.50, 3.70, + 4.30, 9.02, 6.20 }; + for (sal_Int32 j = 1,k = 0; j <= nCount; ++j,++k) + { + sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); + if ( k >= nSize ) + k = 0; + aDataValues[j-1].push_back(uno::makeAny(fDefaultData[k])); + } } ::std::vector< ::std::vector< uno::Any > >::iterator aDataValuesIter = aDataValues.begin(); const ::std::vector< ::std::vector< uno::Any > >::iterator aDataValuesEnd = aDataValues.end(); @@ -559,7 +578,7 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw() else m_xInternal->setDataByRangeRepresentation(::rtl::OUString::valueOf(nPos-1),uno::Sequence< uno::Any >(&(*aDataValuesIter->begin()),aDataValuesIter->size())); } - } + } // for (sal_Int32 nPos = 0;nRowCount && aDataValuesIter != aDataValuesEnd ; ++aDataValuesIter,++nPos) } // ----------------------------------------------------------------------------- void DatabaseDataProvider::impl_fillRowSet_throw() @@ -569,14 +588,14 @@ void DatabaseDataProvider::impl_fillRowSet_throw() xParam->clearParameters( ); } // ----------------------------------------------------------------------------- -bool DatabaseDataProvider::fillParameters( ::osl::ResettableMutexGuard& _rClearForNotifies, const uno::Reference< task::XInteractionHandler >& _rxCompletionHandler ) +bool DatabaseDataProvider::impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies) { // do we have to fill the parameters again? if ( !m_aParameterManager.isUpToDate() ) m_aParameterManager.updateParameterInfo( m_aFilterManager ); if ( m_aParameterManager.isUpToDate() ) - return m_aParameterManager.fillParameterValues( _rxCompletionHandler, _rClearForNotifies ); + return m_aParameterManager.fillParameterValues( m_xHandler, _rClearForNotifies ); return true; } @@ -723,11 +742,8 @@ void SAL_CALL DatabaseDataProvider::clearParameters() throw( SQLException, Runti //------------------------------------------------------------------------------ void SAL_CALL DatabaseDataProvider::execute() throw( SQLException, RuntimeException ) { - ::osl::ResettableMutexGuard aGuard(m_aMutex); - impl_fillRowSet_throw(); - bool bRet = impl_executeRowSet_throw(aGuard); - if ( bRet ) - impl_fillInternalDataProvider_throw(); + uno::Sequence< beans::PropertyValue > aEmpty; + createDataSourcePossible(aEmpty); } //------------------------------------------------------------------------------ void SAL_CALL DatabaseDataProvider::addRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException ) |