@@ -1955,7 +1955,7 @@ namespace detail virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); }; virtual Reference< XBlob > getBlob() const { return m_xRow->getBlob( m_nPos ); }; virtual Reference< XClob > getClob() const { return m_xRow->getClob( m_nPos ); }; - virtual Any getObject() const { return m_xRow->getObject( m_nPos, NULL ); }; + virtual Any getObject() const { return m_xRow->getObject( m_nPos ,NULL); }; virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); }; private: @@ -1388,16 +1388,18 @@ namespace ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); Reference< XPropertySetInfo > xInfo = _xTable->getPropertySetInfo(); if ( xInfo.is() - && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) - && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) ) { ::rtl::OUString aCatalog; ::rtl::OUString aSchema; ::rtl::OUString aTable; - _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog; - _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= _out_rSchema; + if ( xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) + && xInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) ) + { + _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= _out_rCatalog; + _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= _out_rSchema; + } _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= _out_rName; } else @@ -1779,15 +1781,31 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>(); Reference<XNameAccess> xParamsAsNames(xParamsAsIndicies, UNO_QUERY); sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0; - if ( (nParamCount && _aParametersSet.empty()) || ::std::count(_aParametersSet.begin(),_aParametersSet.end(),true) != nParamCount ) + ::std::bit_vector aNewParameterSet( _aParametersSet ); + if ( nParamCount || ::std::count(aNewParameterSet.begin(),aNewParameterSet.end(),true) != nParamCount ) { + static const ::rtl::OUString PROPERTY_NAME(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)); + aNewParameterSet.resize(nParamCount ,false); + typedef ::std::map< ::rtl::OUString, ::std::vector<sal_Int32> > TParameterPositions; + TParameterPositions aParameterNames; + for(sal_Int32 i = 0; i < nParamCount; ++i) + { + Reference<XPropertySet> xParam(xParamsAsIndicies->getByIndex(i),UNO_QUERY); + ::rtl::OUString sName; + xParam->getPropertyValue(PROPERTY_NAME) >>= sName; + + TParameterPositions::iterator aFind = aParameterNames.find(sName); + if ( aFind != aParameterNames.end() ) + aNewParameterSet[i] = true; + aParameterNames[sName].push_back(i+1); + } // build an interaction request // two continuations (Ok and Cancel) OInteractionAbort* pAbort = new OInteractionAbort; OParameterContinuation* pParams = new OParameterContinuation; // the request ParametersRequest aRequest; - Reference<XIndexAccess> xWrappedParameters = new OParameterWrapper(_aParametersSet,xParamsAsIndicies); + Reference<XIndexAccess> xWrappedParameters = new OParameterWrapper(aNewParameterSet,xParamsAsIndicies); aRequest.Parameters = xWrappedParameters; aRequest.Connection = _xConnection; OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aRequest)); @@ -1815,11 +1833,10 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, Reference< XPropertySet > xParamColumn(xWrappedParameters->getByIndex(i),UNO_QUERY); if (xParamColumn.is()) { -#ifdef DBG_UTIL ::rtl::OUString sName; - xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sName; + xParamColumn->getPropertyValue(PROPERTY_NAME) >>= sName; OSL_ENSURE(sName.equals(pFinalValues->Name), "::dbaui::askForParameters: inconsistent parameter names!"); -#endif + // determine the field type and ... sal_Int32 nParamType = 0; xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nParamType; @@ -1827,21 +1844,17 @@ void askForParameters(const Reference< XSingleSelectQueryComposer >& _xComposer, sal_Int32 nScale = 0; if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), xParamColumn)) xParamColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale; - // and set the value - ::std::bit_vector::const_iterator aIter = _aParametersSet.begin(); - ::std::bit_vector::const_iterator aEnd = _aParametersSet.end(); - sal_Int32 j = 0; - sal_Int32 nParamPos = -1; - for(; aIter != aEnd && j <= i; ++aIter) + // (the index of the parameters is one-based) + TParameterPositions::iterator aFind = aParameterNames.find(pFinalValues->Name); + ::std::vector<sal_Int32>::iterator aIterPos = aFind->second.begin(); + ::std::vector<sal_Int32>::iterator aEndPos = aFind->second.end(); + for(;aIterPos != aEndPos;++aIterPos) { - ++nParamPos; - if ( !*aIter ) + if ( _aParametersSet.empty() || !_aParametersSet[(*aIterPos)-1] ) { - ++j; + _xParameters->setObjectWithInfo(*aIterPos, pFinalValues->Value, nParamType, nScale); } } - _xParameters->setObjectWithInfo(nParamPos + 1, pFinalValues->Value, nParamType, nScale); - // (the index of the parameters is one-based) } } } @@ -153,6 +153,8 @@ java_util_Properties* connectivity::createStringPropertyArray(const Sequence< Pr && pBegin->Name.compareToAscii( "SupportsTableCreation" ) && pBegin->Name.compareToAscii( "UseJava" ) && pBegin->Name.compareToAscii( "Authentication" ) + && pBegin->Name.compareToAscii( "PreferDosLikeLineEnds" ) + && pBegin->Name.compareToAscii( "PrimaryKeySupport" ) ) { ::rtl::OUString aStr; @@ -116,7 +116,7 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos ) { OParseColumn* pColumn = new OParseColumn( - _rxResMetaData->getColumnName( _nColumnPos ), + _rxResMetaData->getColumnLabel( _nColumnPos ), _rxResMetaData->getColumnTypeName( _nColumnPos ), ::rtl::OUString(), _rxResMetaData->isNullable( _nColumnPos ), @@ -135,6 +135,7 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe eComplete ) ); pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) ); + pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos )); return pColumn; } @@ -911,7 +911,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) } break; default: - OSL_ENSURE(0,"Not handled!"); + ; } } return pReturn; @@ -40,7 +40,6 @@ #include "xmlscript/xml_helper.hxx" #include "com/sun/star/io/XInputStream.hpp" #include "com/sun/star/ucb/CommandFailedException.hpp" -#include "com/sun/star/ucb/XContentCreator.hpp" #include "com/sun/star/ucb/ContentInfo.hpp" #include "com/sun/star/ucb/ContentInfoAttribute.hpp" @@ -130,50 +129,46 @@ bool create_folder( if (! create_folder( &parentContent, url.copy( 0, slash ), xCmdEnv, throw_exc )) return false; - Reference<XContentCreator> xCreator( parentContent.get(), UNO_QUERY ); - if (xCreator.is()) + const Any title( ::rtl::Uri::decode( url.copy( slash + 1 ), + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8 ) ); + const Sequence<ContentInfo> infos( + parentContent.queryCreatableContentsInfo() ); + for ( sal_Int32 pos = 0; pos < infos.getLength(); ++pos ) { - const Any title( ::rtl::Uri::decode( url.copy( slash + 1 ), - rtl_UriDecodeWithCharset, - RTL_TEXTENCODING_UTF8 ) ); - const Sequence<ContentInfo> infos( - xCreator->queryCreatableContentsInfo() ); - for ( sal_Int32 pos = 0; pos < infos.getLength(); ++pos ) + // look KIND_FOLDER: + ContentInfo const & info = infos[ pos ]; + if ((info.Attributes & ContentInfoAttribute::KIND_FOLDER) != 0) { - // look KIND_FOLDER: - ContentInfo const & info = infos[ pos ]; - if ((info.Attributes & ContentInfoAttribute::KIND_FOLDER) != 0) - { - // make sure the only required bootstrap property is "Title": - Sequence<beans::Property> const & rProps = info.Properties; - if (rProps.getLength() != 1 || - !rProps[ 0 ].Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM("Title") )) - continue; + // make sure the only required bootstrap property is "Title": + Sequence<beans::Property> const & rProps = info.Properties; + if (rProps.getLength() != 1 || + !rProps[ 0 ].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("Title") )) + continue; - try { - if (parentContent.insertNewContent( - info.Type, - Sequence<OUString>( &StrTitle::get(), 1 ), - Sequence<Any>( &title, 1 ), - ucb_content )) { - if (ret_ucb_content != 0) - *ret_ucb_content = ucb_content; - return true; - } + try { + if (parentContent.insertNewContent( + info.Type, + Sequence<OUString>( &StrTitle::get(), 1 ), + Sequence<Any>( &title, 1 ), + ucb_content )) { + if (ret_ucb_content != 0) + *ret_ucb_content = ucb_content; + return true; } - catch (RuntimeException &) { + } + catch (RuntimeException &) { + throw; + } + catch (CommandFailedException &) { + // Interaction Handler already handled the error + // that has occured... + } + catch (Exception &) { + if (throw_exc) throw; - } - catch (CommandFailedException &) { - // Interaction Handler already handled the error - // that has occured... - } - catch (Exception &) { - if (throw_exc) - throw; - return false; - } + return false; } } } @@ -41,7 +41,7 @@ #include "svl/inettype.hxx" #include "unotools/pathoptions.hxx" -#include <transex3/compilehelp.hxx> +#include <l10ntools/compilehelp.hxx> #include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/util/XMacroExpander.hpp> #include <com/sun/star/uri/XUriReferenceFactory.hpp> @@ -95,12 +95,12 @@ public class SystemEnvironment { this.systemManufacturer = ""; this.cpuManufacturer = ""; this.serialNumber = ""; - this.physmem = ""; - this.sockets = ""; - this.cores = ""; - this.virtcpus = ""; + this.physmem = "0"; + this.sockets = "0"; + this.cores = "0"; + this.virtcpus = "0"; this.cpuname = ""; - this.clockrate = ""; + this.clockrate = "0"; } @@ -173,6 +173,8 @@ public class SystemEnvironment { * @param physmem The physmem to set. */ public void setPhysMem(String physmem) { + if (physmem.length() == 0) + physmem = "0"; this.physmem = physmem; } @@ -181,6 +183,8 @@ public class SystemEnvironment { * @param sockets The sockets to set. */ public void setSockets(String sockets) { + if (sockets.length() == 0) + sockets = "0"; this.sockets = sockets; } @@ -189,6 +193,8 @@ public class SystemEnvironment { * @param cores The cores to set. */ public void setCores(String cores) { + if (cores.length() == 0) + cores ="0"; this.cores = cores; } @@ -197,6 +203,8 @@ public class SystemEnvironment { * @param virtcpus The virtcpus to set. */ public void setVirtCpus(String virtcpus) { + if (virtcpus.length() == 0) + virtcpus = "0"; this.virtcpus = virtcpus; } @@ -213,9 +221,14 @@ public class SystemEnvironment { * @param clockrate The clockrate to set. */ public void setClockRate(String clockrate) { - Float f = Float.parseFloat(clockrate); - Integer nClockrate = f.intValue(); - this.clockrate = nClockrate.toString(); + if (clockrate.length() == 0) + this.clockrate = "0"; + else + { + Float f = Float.parseFloat(clockrate); + Integer nClockrate = f.intValue(); + this.clockrate = nClockrate.toString(); + } } /** @@ -70,6 +70,9 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/window.hxx> + ////////////////////////////////////////////////////////////////////////////// using namespace com::sun::star; @@ -61,7 +61,6 @@ #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XContent.hpp> #include <com/sun/star/ucb/XContentAccess.hpp> -#include <com/sun/star/ucb/XContentCreator.hpp> #include <com/sun/star/ucb/XSimpleFileAccess3.hpp> #include <com/sun/star/util/XMacroExpander.hpp> @@ -480,11 +479,7 @@ void OFileAccess::createFolder( const rtl::OUString& NewFolderURL ) ucbhelper::Content aCnt( aURL.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment ); - Reference< XContentCreator > xCreator = Reference< XContentCreator >( aCnt.get(), UNO_QUERY ); - if ( !xCreator.is() ) - return; - - Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo(); + Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo(); sal_Int32 nCount = aInfo.getLength(); if ( nCount == 0 ) return; @@ -758,56 +753,51 @@ bool OFileAccess::createNewFile( const rtl::OUString & rParentURL, { ucbhelper::Content aParentCnt( rParentURL, mxEnvironment ); - Reference< XContentCreator > xCreator - = Reference< XContentCreator >( aParentCnt.get(), UNO_QUERY ); - if ( xCreator.is() ) - { - Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo(); - sal_Int32 nCount = aInfo.getLength(); - if ( nCount == 0 ) - return false; + Sequence< ContentInfo > aInfo = aParentCnt.queryCreatableContentsInfo(); + sal_Int32 nCount = aInfo.getLength(); + if ( nCount == 0 ) + return false; - for ( sal_Int32 i = 0; i < nCount; ++i ) + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + const ContentInfo & rCurr = aInfo[i]; + if ( ( rCurr.Attributes + & ContentInfoAttribute::KIND_DOCUMENT ) && + ( rCurr.Attributes + & ContentInfoAttribute::INSERT_WITH_INPUTSTREAM ) ) { - const ContentInfo & rCurr = aInfo[i]; - if ( ( rCurr.Attributes - & ContentInfoAttribute::KIND_DOCUMENT ) && - ( rCurr.Attributes - & ContentInfoAttribute::INSERT_WITH_INPUTSTREAM ) ) - { - // Make sure the only required bootstrap property is - // "Title", - const Sequence< Property > & rProps = rCurr.Properties; - if ( rProps.getLength() != 1 ) - continue; + // Make sure the only required bootstrap property is + // "Title", + const Sequence< Property > & rProps = rCurr.Properties; + if ( rProps.getLength() != 1 ) + continue; - if ( !rProps[ 0 ].Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) - continue; + if ( !rProps[ 0 ].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + continue; - Sequence<rtl::OUString> aNames(1); - rtl::OUString* pNames = aNames.getArray(); - pNames[0] = rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); - Sequence< Any > aValues(1); - Any* pValues = aValues.getArray(); - pValues[0] = makeAny( rtl::OUString( rTitle ) ); + Sequence<rtl::OUString> aNames(1); + rtl::OUString* pNames = aNames.getArray(); + pNames[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "Title" ) ); + Sequence< Any > aValues(1); + Any* pValues = aValues.getArray(); + pValues[0] = makeAny( rtl::OUString( rTitle ) ); - try - { - ucbhelper::Content aNew; - if ( aParentCnt.insertNewContent( - rCurr.Type, aNames, aValues, data, aNew ) ) - return true; // success. - else - continue; - } - catch ( CommandFailedException const & ) - { - // Interaction Handler already handled the - // error that has occured... + try + { + ucbhelper::Content aNew; + if ( aParentCnt.insertNewContent( + rCurr.Type, aNames, aValues, data, aNew ) ) + return true; // success. + else continue; - } + } + catch ( CommandFailedException const & ) + { + // Interaction Handler already handled the + // error that has occured... + continue; } } } @@ -33,14 +33,13 @@ #include "fpsmartcontent.hxx" /** === begin UNO includes === **/ -#include <com/sun/star/ucb/XContentCreator.hpp> #include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/ucb/ContentInfo.hpp> #include <com/sun/star/ucb/ContentInfoAttribute.hpp> +#include <com/sun/star/ucb/XContent.hpp> /** === end UNO includes === **/ -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX #include <comphelper/processfactory.hxx> -#endif #include <ucbhelper/commandenvironment.hxx> #include <tools/solar.h> #include <tools/debug.hxx> @@ -282,25 +281,21 @@ namespace svt sal_Bool bRet = sal_False; try { - Reference< XContentCreator > xCreator = Reference< XContentCreator >( m_pContent->get(), UNO_QUERY ); - if ( xCreator.is() ) + Sequence< ContentInfo > aInfo = m_pContent->queryCreatableContentsInfo(); + const ContentInfo* pInfo = aInfo.getConstArray(); + sal_Int32 nCount = aInfo.getLength(); + for ( sal_Int32 i = 0; i < nCount; ++i, ++pInfo ) { - Sequence< ContentInfo > aInfo = xCreator->queryCreatableContentsInfo(); - const ContentInfo* pInfo = aInfo.getConstArray(); - sal_Int32 nCount = aInfo.getLength(); - for ( sal_Int32 i = 0; i < nCount; ++i, ++pInfo ) + // Simply look for the first KIND_FOLDER... + if ( pInfo->Attributes & ContentInfoAttribute::KIND_FOLDER ) { - // Simply look for the first KIND_FOLDER... - if ( pInfo->Attributes & ContentInfoAttribute::KIND_FOLDER ) - { - bRet = sal_True; - break; - } + bRet = sal_True; + break; } - - // now we're definately valid - m_eState = VALID; } + + // now we're definately valid + m_eState = VALID; } catch( Exception& ) { @@ -165,23 +165,15 @@ </Section> <Paragraph id="BDB2"> - <Text id="BDB2a" xml:lang="en-US">The Berkeley database engine has been upgraded in this version of ${PRODUCTNAME}. The database engine - upgrade introduces an incompatibility with user data for installed extensions for ${PRODUCTNAME} versions prior to 3.2 that may - require your action if you downgrade your version of ${PRODUCTNAME}. - </Text> + <Text id="BDB2a" xml:lang="en-US">The Berkeley database engine has been upgraded in this version of ${PRODUCTNAME}. The database engine upgrade introduces an incompatibility with user data for installed extensions for ${PRODUCTNAME} versions prior to 3.2 that may require your action if you downgrade your version of ${PRODUCTNAME}.</Text> </Paragraph> <Paragraph id="BDB3"> - <Text id="BDB3a" xml:lang="en-US">This version of ${PRODUCTNAME} will convert your extension database to the new Berkeley - database format when extensions are installed or removed. After this conversion, the database can no longer be read - by earlier versions of ${PRODUCTNAME}. Downgrading to an earlier version may result in a dysfunctional installation. - </Text> + <Text id="BDB3a" xml:lang="en-US">This version of ${PRODUCTNAME} will convert your extension database to the new Berkeley database format when extensions are installed or removed. After this conversion, the database can no longer be read by earlier versions of ${PRODUCTNAME}. Downgrading to an earlier version may result in a dysfunctional installation.</Text> </Paragraph> <Paragraph id="BDB4"> - <Text id="BDB4a" xml:lang="en-US">If you downgrade to an earlier version of ${PRODUCTNAME}, you must remove the user - data directory {user data}/uno_packages, for example ~/.openoffice.org/3/user/uno_packages, and reinstall all extensions. - </Text> + <Text id="BDB4a" xml:lang="en-US">If you downgrade to an earlier version of ${PRODUCTNAME}, you must remove the user data directory {user data}/uno_packages, for example ~/.openoffice.org/3/user/uno_packages, and reinstall all extensions.</Text> </Paragraph> @@ -69,7 +69,6 @@ #include <com/sun/star/ucb/TransferInfo.hpp> #include <com/sun/star/ucb/XCommandProcessor.hpp> #include <com/sun/star/ucb/XContent.hpp> -#include <com/sun/star/ucb/XContentCreator.hpp> #include <com/sun/star/ucb/XContentAccess.hpp> #include <com/sun/star/ucb/XAnyCompareFactory.hpp> #include <com/sun/star/ucb/XAnyCompare.hpp> @@ -794,12 +793,12 @@ String SfxDocumentTemplates::GetDefaultTemplatePath INetURLObject aTemplateObj( pImp->GetRootURL() ); aTemplateObj.insertName( aGroupName, false, - INetURLObject::LAST_SEGMENT, true, - INetURLObject::ENCODE_ALL ); + INetURLObject::LAST_SEGMENT, true, + INetURLObject::ENCODE_ALL ); aTemplateObj.insertName( aTitle, false, - INetURLObject::LAST_SEGMENT, true, - INetURLObject::ENCODE_ALL ); + INetURLObject::LAST_SEGMENT, true, + INetURLObject::ENCODE_ALL ); ::rtl::OUString aResult; @@ -869,7 +869,7 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest = new ::comphelper::OInteractionRequest( makeAny( aUpdateRequest ) ); pRequest->addContinuation( new ::comphelper::OInteractionApprove ); - pRequest->addContinuation( new ::comphelper::OInteractionDisapprove ); + pRequest->addContinuation( new ::comphelper::OInteractionAbort ); typedef ::comphelper::OInteraction< XInteractionAskLater > OInteractionAskLater; OInteractionAskLater* pLater = new OInteractionAskLater; @@ -952,27 +952,27 @@ sal_uInt32 SfxObjectShell::HandleFilter( SfxMedium* pMedium, SfxObjectShell* pDo if ( !pFORequest->isAbort() ) { - SfxAllItemSet aNewParams( pDoc->GetPool() ); - TransformParameters( SID_OPENDOC, - pFORequest->getFilterOptions(), - aNewParams, - NULL ); - - SFX_ITEMSET_ARG( &aNewParams, - pFilterOptions, - SfxStringItem, - SID_FILE_FILTEROPTIONS, - sal_False ); - if ( pFilterOptions ) - pSet->Put( *pFilterOptions ); - - SFX_ITEMSET_ARG( &aNewParams, - pFilterData, - SfxUnoAnyItem, - SID_FILTER_DATA, - sal_False ); - if ( pFilterData ) - pSet->Put( *pFilterData ); + SfxAllItemSet aNewParams( pDoc->GetPool() ); + TransformParameters( SID_OPENDOC, + pFORequest->getFilterOptions(), + aNewParams, + NULL ); + + SFX_ITEMSET_ARG( &aNewParams, + pFilterOptions, + SfxStringItem, + SID_FILE_FILTEROPTIONS, + sal_False ); + if ( pFilterOptions ) + pSet->Put( *pFilterOptions ); + + SFX_ITEMSET_ARG( &aNewParams, + pFilterData, + SfxUnoAnyItem, + SID_FILTER_DATA, + sal_False ); + if ( pFilterData ) + pSet->Put( *pFilterData ); } else bAbort = TRUE; @@ -1796,14 +1796,14 @@ sal_Bool SfxObjectShell::SaveTo_Impl #define CHAR_POINTER(THE_OUSTRING) ::rtl::OUStringToOString (THE_OUSTRING, RTL_TEXTENCODING_UTF8).pData->buffer // Header for a single-valued ASCII EA data item typedef struct _EA_ASCII_header { - USHORT usAttr; /* value: EAT_ASCII */ - USHORT usLen; /* length of data */ - CHAR szType[_MAX_PATH]; /* ASCII data fits in here ... */ + USHORT usAttr; /* value: EAT_ASCII */ + USHORT usLen; /* length of data */ + CHAR szType[_MAX_PATH]; /* ASCII data fits in here ... */ } EA_ASCII_HEADER; - char filePath[_MAX_PATH]; - char fileExt[_MAX_PATH]; - char docType[_MAX_PATH]; - int rc; + char filePath[_MAX_PATH]; + char fileExt[_MAX_PATH]; + char docType[_MAX_PATH]; + int rc; oslFileError eRet; ::rtl::OUString aSystemFileURL; const ::rtl::OUString aFileURL = rMedium.GetName(); @@ -3435,7 +3435,7 @@ sal_Bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& sal_Bool StoragesOfUnknownMediaTypeAreCopied_Impl( const uno::Reference< embed::XStorage >& xSource, - const uno::Reference< embed::XStorage >& xTarget ) + const uno::Reference< embed::XStorage >& xTarget ) { OSL_ENSURE( xSource.is() && xTarget.is(), "Source and/or target storages are not available!\n" ); if ( !xSource.is() || !xTarget.is() || xSource == xTarget ) @@ -186,6 +186,7 @@ public: // <-- SvxNumberFormat(const SvxNumberFormat& rFormat); SvxNumberFormat(SvStream &rStream); + virtual ~SvxNumberFormat(); SvStream& Store(SvStream &rStream, FontToSubsFontConverter pConverter); @@ -66,7 +66,6 @@ namespace sdr { namespace contact { public: ViewObjectContactOfUnoControl( ObjectContact& _rObjectContact, ViewContactOfUnoControl& _rViewContact ); - /// determines whether an XControl already exists, and is currently visible bool isControlVisible() const; @@ -56,6 +56,7 @@ #include "unopolyhelper.hxx" #include <uno/mapping.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <com/sun/star/document/XActionLockable.hpp> // --------------------------- // - EnhancedCustomShapeEngine - @@ -360,7 +361,8 @@ com::sun::star::awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds { com::sun::star::awt::Rectangle aTextRect; SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) ); - if ( pSdrObjCustomShape && pSdrObjCustomShape->GetModel() && !pSdrObjCustomShape->GetModel()->isLocked() ) + ::com::sun::star::uno::Reference< ::com::sun::star::document::XActionLockable > xLockable( mxShape, ::com::sun::star::uno::UNO_QUERY ); + if ( pSdrObjCustomShape && pSdrObjCustomShape->GetModel() && xLockable.is() && !xLockable->isActionLocked() ) { if ( pSdrObjCustomShape ) { @@ -1177,6 +1177,11 @@ SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule, USHORT _nWhich ) : { } +SfxPoolItem* SvxNumBulletItem::Create(SvStream &s, USHORT n) const +{ + return SfxPoolItem::Create(s, n ); +} + /* -----------------27.10.98 10:41------------------- * * --------------------------------------------------*/ @@ -1210,11 +1215,6 @@ SfxPoolItem* SvxNumBulletItem::Clone( SfxItemPool * ) const /* -----------------08.12.98 10:43------------------- * * --------------------------------------------------*/ -SfxPoolItem* SvxNumBulletItem::Create(SvStream &rStream, USHORT) const -{ - SvxNumRule aRule(rStream); - return new SvxNumBulletItem(aRule, Which() ); -} USHORT SvxNumBulletItem::GetVersion( USHORT /*nFileVersion*/ ) const { return NUMITEM_VERSION_03; @@ -357,6 +357,18 @@ BOOL __EXPORT OutlinerView::MouseButtonDown( const MouseEvent& rMEvt ) aDDStartPosRef=pEditView->GetWindow()->PixelToLogic( aDDStartPosPix,pOwner->GetRefMapMode()); return TRUE; } + + // special case for outliner view in impress, check if double click hits the page icon for toggle + if( (nPara == EE_PARA_NOT_FOUND) && (pOwner->ImplGetOutlinerMode() == OUTLINERMODE_OUTLINEVIEW) && (eTarget == MouseText) && (rMEvt.GetClicks() == 2) ) + { + ESelection aSel( pEditView->GetSelection() ); + nPara = aSel.nStartPara; + Paragraph* pPara = pOwner->pParaList->GetParagraph( nPara ); + if( (pPara && pOwner->pParaList->HasChilds(pPara)) && pPara->HasFlag(PARAFLAG_ISPAGE) ) + { + ImpToggleExpand( pPara ); + } + } return pEditView->MouseButtonDown( rMEvt ); } @@ -1644,14 +1656,14 @@ USHORT OutlinerView::GetSelectedScriptType() const return pEditView->GetSelectedScriptType(); } -String OutlinerView::GetSurroundingText() const
-{
- DBG_CHKTHIS(OutlinerView,0);
- return pEditView->GetSurroundingText();
-}
-
-Selection OutlinerView::GetSurroundingTextSelection() const
-{
- DBG_CHKTHIS(OutlinerView,0);
- return pEditView->GetSurroundingTextSelection();
-}
+String OutlinerView::GetSurroundingText() const +{ + DBG_CHKTHIS(OutlinerView,0); + return pEditView->GetSurroundingText(); +} + +Selection OutlinerView::GetSurroundingTextSelection() const +{ + DBG_CHKTHIS(OutlinerView,0); + return pEditView->GetSurroundingTextSelection(); +} @@ -68,11 +68,10 @@ namespace sdr // no need to correct if no extra text range if(aTextRange != aObjectRange) { - const double fExtraTextRotation(GetCustomShapeObj().GetExtraTextRotation()); const GeoStat& rGeoStat(GetCustomShapeObj().GetGeoStat()); // only correct when rotation and/or shear is used - if(rGeoStat.nShearWink || rGeoStat.nDrehWink || !basegfx::fTools::equalZero(fExtraTextRotation)) + if(rGeoStat.nShearWink || rGeoStat.nDrehWink ) { // text range needs to be corrected by // aObjectRange.getCenter() - aRotObjectRange.getCenter() since it's @@ -96,11 +95,6 @@ namespace sdr aRotMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000); } - if(!basegfx::fTools::equalZero(fExtraTextRotation)) - { - aRotMatrix.rotate((360.0 - fExtraTextRotation) * F_PI180); - } - aRotMatrix.translate(aObjectRange.getMinimum().getX(), aObjectRange.getMinimum().getY()); aRotObjectRange.transform(aRotMatrix); @@ -189,6 +183,16 @@ namespace sdr aTextRange.getMinY() - aObjectRange.getMinimum().getY()); } + if(!basegfx::fTools::equalZero(fExtraTextRotation)) + { + basegfx::B2DVector aTranslation( + ( aTextRange.getWidth() / 2 ) + ( aTextRange.getMinX() - aObjectRange.getMinimum().getX() ), + ( aTextRange.getHeight() / 2 ) + ( aTextRange.getMinY() - aObjectRange.getMinimum().getY() ) ); + aTextBoxMatrix.translate( -aTranslation.getX(), -aTranslation.getY() ); + aTextBoxMatrix.rotate((360.0 - fExtraTextRotation) * F_PI180); + aTextBoxMatrix.translate( aTranslation.getX(), aTranslation.getY() ); + } + if(rGeoStat.nShearWink) { aTextBoxMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000)); @@ -199,11 +203,6 @@ namespace sdr aTextBoxMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000); } - if(!basegfx::fTools::equalZero(fExtraTextRotation)) - { - aTextBoxMatrix.rotate((360.0 - fExtraTextRotation) * F_PI180); - } - // give text it's target position aTextBoxMatrix.translate(aObjectRange.getMinimum().getX(), aObjectRange.getMinimum().getY()); } @@ -238,6 +238,8 @@ namespace sdr { namespace contact { getGraphics() const { return m_xControlView->getGraphics(); } inline void draw( const Point& _rTopLeft ) const { m_xControlView->draw( _rTopLeft.X(), _rTopLeft.Y() ); } + void invalidate() const; + public: inline const Reference< XControl >& getControl() const { return m_xControl; } }; @@ -298,6 +300,15 @@ namespace sdr { namespace contact { } //-------------------------------------------------------------------- + void ControlHolder::invalidate() const + { + Window* pWindow = VCLUnoHelper::GetWindow( m_xControl->getPeer() ); + OSL_ENSURE( pWindow, "ControlHolder::invalidate: no implementation access!" ); + if ( pWindow ) + pWindow->Invalidate(); + } + + //-------------------------------------------------------------------- ::basegfx::B2DVector ControlHolder::getZoom() const { // no check whether we're valid, this is the responsibility of the caller @@ -1666,6 +1677,8 @@ namespace sdr { namespace contact { double fRotate, fShearX; _rViewInformation.getObjectToViewTransformation().decompose( aScale, aTranslate, fRotate, fShearX ); #endif + const bool bHadControl = m_pVOCImpl->getExistentControl().is(); + // force control here to make it a VCL ChildWindow. Will be fetched // and used below by getExistentControl() m_pVOCImpl->ensureControl( &_rViewInformation.getObjectToViewTransformation() ); @@ -1676,6 +1689,9 @@ namespace sdr { namespace contact { Reference< XControlModel > xControlModel( rViewContactOfUnoControl.GetSdrUnoObj().GetUnoControlModel() ); const ControlHolder& rControl( m_pVOCImpl->getExistentControl() ); + if ( !bHadControl && rControl.is() && rControl.isVisible() ) + rControl.invalidate(); + // check if we already have an XControl. if ( !xControlModel.is() || !rControl.is() ) // use the default mechanism. This will create a ControlPrimitive2D without @@ -746,8 +746,8 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rS if (!aFnt.IsTransparent()) { SfxItemSet aAttr(*pFillAttr->GetPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST); - pFillAttr->Put(XFillStyleItem(XFILL_SOLID)); - pFillAttr->Put(XFillColorItem(String(), aFnt.GetFillColor())); + aAttr.Put(XFillStyleItem(XFILL_SOLID)); + aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor())); pText->SetMergedItemSet(aAttr); } sal_uInt32 nWink = aFnt.GetOrientation(); @@ -446,14 +446,6 @@ DictionaryEntry::DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUStrin m_nConversionPropertyType = 1; } -DictionaryEntry::DictionaryEntry() - : m_aTerm() - , m_aMapping() - , m_nConversionPropertyType( linguistic2::ConversionPropertyType::OTHER ) - , m_bNewEntry( sal_True ) -{ -} - DictionaryEntry::~DictionaryEntry() { } @@ -61,7 +61,6 @@ namespace textconversiondlgs struct DictionaryEntry { - DictionaryEntry(); DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType , sal_Bool bNewEntry = sal_False ); @@ -1,4 +1,4 @@ -su sysui : l10n offapi xml2cmp rdbmaker transex3 setup_native NULL +su sysui : l10n offapi xml2cmp rdbmaker l10ntools setup_native NULL su sysui\source\win32\QuickStart nmake - w su_win32_quickstart NULL su sysui\source\win32\QuickStart\so nmake - w su_win32_quickstart_so su_win32_quickstart.w NULL su sysui\desktop\icons nmake - w su_iconsw NULL @@ -49,7 +49,6 @@ import com.sun.star.ucb.OpenMode; import com.sun.star.ucb.XCommandProcessor; import com.sun.star.ucb.XContent; import com.sun.star.ucb.XContentAccess; -import com.sun.star.ucb.XContentCreator; import com.sun.star.ucb.XContentIdentifier; import com.sun.star.ucb.XContentIdentifierFactory; import com.sun.star.ucb.XContentProvider; @@ -139,12 +138,16 @@ public class CheckTransientDocumentsDocumentContent extends ComplexTestCase { } } // create a folder - XContent xNewFolder = null; log.println("Create new folder "+ folderName); ContentInfo contentInfo = new ContentInfo(); contentInfo.Type = "application/vnd.sun.star.tdoc-folder"; - XContentCreator xContentCreator = (XContentCreator)UnoRuntime.queryInterface(XContentCreator.class, xContent); - xNewFolder = xContentCreator.createNewContent(contentInfo); + + command.Name = "createNewContent"; + command.Argument = contentInfo; + + result = xCommandProcessor.execute(command, 0, null); + XContent xNewFolder = (XContent)UnoRuntime.queryInterface(XContent.class, result); + XCommandProcessor xFolderCommandProcessor = (XCommandProcessor)UnoRuntime.queryInterface(XCommandProcessor.class, xNewFolder); log.println("Got the new folder: " + utils.getImplName(xNewFolder)); diff --git a/ucb/source/core/cmdenv.cxx b/ucb/source/core/cmdenv.cxx new file mode 100644 index 000000000000..0ac11b82a3dd --- /dev/null +++ b/ ucb/source/core/cmdenv.cxx@@ -0,0 +1,194 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_ucb.hxx" + +#include "cppuhelper/factory.hxx" +#include "com/sun/star/lang/IllegalArgumentException.hpp" + +#include "cmdenv.hxx" + +/************************************************************************** + TODO + ************************************************************************** + + *************************************************************************/ +using namespace com::sun::star; +using namespace ucb_cmdenv; + +//========================================================================= +//========================================================================= +// +// UcbCommandEnvironment Implementation. +// +//========================================================================= +//========================================================================= + +UcbCommandEnvironment::UcbCommandEnvironment( + const uno::Reference< lang::XMultiServiceFactory >& /*xSMgr*/ ) +//: m_xSMgr( xSMgr ) +{ +} + +//========================================================================= +// virtual +UcbCommandEnvironment::~UcbCommandEnvironment() +{ +} + +//========================================================================= +// +// XInitialization methods. +// +//========================================================================= + +// virtual +void SAL_CALL UcbCommandEnvironment::initialize( + const uno::Sequence< uno::Any >& aArguments ) + throw( uno::Exception, + uno::RuntimeException ) +{ + if ( ( aArguments.getLength() < 2 ) || + !( aArguments[ 0 ] >>= m_xIH ) || + !( aArguments[ 1 ] >>= m_xPH )) + throw lang::IllegalArgumentException(); +} + +//========================================================================= +// +// XServiceInfo methods. +// +//========================================================================= + +// virtual +::rtl::OUString SAL_CALL UcbCommandEnvironment::getImplementationName() + throw ( uno::RuntimeException ) +{ + return getImplementationName_Static(); +} + +//========================================================================= +// virtual +sal_Bool SAL_CALL +UcbCommandEnvironment::supportsService( const ::rtl::OUString& ServiceName ) + throw ( uno::RuntimeException ) +{ + uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames(); + const rtl::OUString * pArray = aSNL.getConstArray(); + for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + { + if ( pArray[ i ] == ServiceName ) + return sal_True; + } + return sal_False; +} + +//========================================================================= +// virtual +uno::Sequence< ::rtl::OUString > SAL_CALL +UcbCommandEnvironment::getSupportedServiceNames() + throw ( uno::RuntimeException ) +{ + return getSupportedServiceNames_Static(); +} + +//========================================================================= +// static +rtl::OUString UcbCommandEnvironment::getImplementationName_Static() +{ + return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.ucb.CommandEnvironment" ) ); +} + +//========================================================================= +// static +uno::Sequence< rtl::OUString > +UcbCommandEnvironment::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aSNS( 1 ); + aSNS.getArray()[ 0 ] + = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.ucb.CommandEnvironment" ) ); + return aSNS; +} + +//========================================================================= +// +// XCommandInfo methods. +// +//========================================================================= + +// virtual +uno::Reference< task::XInteractionHandler > SAL_CALL +UcbCommandEnvironment::getInteractionHandler() + throw ( uno::RuntimeException ) +{ + return m_xIH; +} + +//========================================================================= +// virtual +uno::Reference< ucb::XProgressHandler > SAL_CALL +UcbCommandEnvironment::getProgressHandler() + throw ( uno::RuntimeException ) +{ + return m_xPH; +} + +//========================================================================= +// +// Service factory implementation. +// +//========================================================================= + +static uno::Reference< uno::XInterface > SAL_CALL +UcbCommandEnvironment_CreateInstance( + const uno::Reference< lang::XMultiServiceFactory> & rSMgr ) + throw( uno::Exception ) +{ + lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >( + new UcbCommandEnvironment( rSMgr ) ); + return uno::Reference< uno::XInterface >::query( pX ); +} + +//========================================================================= +// static +uno::Reference< lang::XSingleServiceFactory > +UcbCommandEnvironment::createServiceFactory( + const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr ) +{ + return uno::Reference< lang::XSingleServiceFactory >( + cppu::createOneInstanceFactory( + rxServiceMgr, + UcbCommandEnvironment::getImplementationName_Static(), + UcbCommandEnvironment_CreateInstance, + UcbCommandEnvironment::getSupportedServiceNames_Static() ) ); +} diff --git a/ucb/source/core/cmdenv.hxx b/ucb/source/core/cmdenv.hxx new file mode 100644 index 000000000000..62c550b7ca51 --- /dev/null +++ b/ ucb/source/core/cmdenv.hxx@@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CMDENV_HXX +#define INCLUDED_CMDENV_HXX + +#include "cppuhelper/implbase3.hxx" + +#include "com/sun/star/lang/XInitialization.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/XSingleServiceFactory.hpp" +#include "com/sun/star/ucb/XCommandEnvironment.hpp" + +namespace ucb_cmdenv { + +class UcbCommandEnvironment : + public cppu::WeakImplHelper3< com::sun::star::lang::XInitialization, + com::sun::star::lang::XServiceInfo, + com::sun::star::ucb::XCommandEnvironment > +{ + com::sun::star::uno::Reference< + com::sun::star::task::XInteractionHandler > m_xIH; + com::sun::star::uno::Reference< + com::sun::star::ucb::XProgressHandler > m_xPH; + +public: + UcbCommandEnvironment( + const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); + virtual ~UcbCommandEnvironment(); + + // XInitialization + virtual void SAL_CALL + initialize( const com::sun::star::uno::Sequence< + com::sun::star::uno::Any >& aArguments ) + throw( com::sun::star::uno::Exception, + com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw ( com::sun::star::uno::RuntimeException ); + + virtual sal_Bool SAL_CALL + supportsService( const ::rtl::OUString& ServiceName ) + throw ( com::sun::star::uno::RuntimeException ); + + virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw ( com::sun::star::uno::RuntimeException ); + + // XCommandEnvironment + virtual com::sun::star::uno::Reference< + com::sun::star::task::XInteractionHandler > SAL_CALL + getInteractionHandler() + throw ( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XProgressHandler > SAL_CALL + getProgressHandler() + throw ( com::sun::star::uno::RuntimeException ); + + // Non-UNO interfaces + static rtl::OUString + getImplementationName_Static(); + static com::sun::star::uno::Sequence< rtl::OUString > + getSupportedServiceNames_Static(); + + static com::sun::star::uno::Reference< + com::sun::star::lang::XSingleServiceFactory > + createServiceFactory( const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory > & rxServiceMgr ); +private: + //com::sun::star::uno::Reference< + // com::sun::star::lang::XMultiServiceFactory > m_xSMgr; +}; + +} // namespace ucb_cmdenv + +#endif // INCLUDED_CMDENV_HXX @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -48,7 +48,8 @@ SLOFILES=\ $(SLO)$/ucbstore.obj \ $(SLO)$/ucbprops.obj \ $(SLO)$/provprox.obj \ - $(SLO)$/ucbcmds.obj + $(SLO)$/ucbcmds.obj \ + $(SLO)$/cmdenv.obj LIB1TARGET=$(SLB)$/_$(TARGET).lib LIB1OBJFILES=$(SLOFILES) @@ -59,7 +60,7 @@ SHL1STDLIBS=\ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) \ - $(UCBHELPERLIB) + $(UCBHELPERLIB) SHL1LIBS=\ $(LIB1TARGET) \ $(SLB)$/regexp.lib @@ -41,11 +41,10 @@ #include <cppuhelper/exc_hlp.hxx> #include <rtl/ustring.h> #include <rtl/ustring.hxx> -#ifndef __COM_SUN_STAR_LANG_XINTERFACE_HPP_ #include <com/sun/star/uno/XInterface.hpp> -#endif #include <com/sun/star/beans/PropertyState.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/io/XActiveDataSink.hpp> @@ -53,13 +52,12 @@ #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/ucb/CommandEnvironment.hpp> #include <com/sun/star/ucb/CommandFailedException.hpp> #include <com/sun/star/ucb/ContentInfoAttribute.hpp> #include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp> -#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> -#endif #include <com/sun/star/ucb/NameClash.hpp> #include <com/sun/star/ucb/NameClashException.hpp> #include <com/sun/star/ucb/OpenCommandArgument2.hpp> @@ -79,7 +77,7 @@ using namespace com::sun::star; -namespace ucb_commands +namespace { //========================================================================= @@ -182,51 +180,6 @@ void SAL_CALL InteractionHandlerProxy::handle( //========================================================================= // -// class CommandEnvironment. -// -//========================================================================= - -class CommandEnvironment : - public cppu::WeakImplHelper1< ucb::XCommandEnvironment > -{ - uno::Reference< task::XInteractionHandler > m_xIH; - uno::Reference< ucb::XProgressHandler > m_xPH; - -public: - CommandEnvironment( - const uno::Reference< task::XInteractionHandler > & xIH, - const uno::Reference< ucb::XProgressHandler > & xPH ) - : m_xIH( xIH ), m_xPH( xPH ) {} - - // XCommandEnvironment methods. - virtual uno::Reference< task::XInteractionHandler > SAL_CALL - getInteractionHandler() - throw ( uno::RuntimeException ); - virtual uno::Reference< ucb::XProgressHandler > SAL_CALL - getProgressHandler() - throw ( uno::RuntimeException ); -}; - -//========================================================================= -// virtual -uno::Reference< task::XInteractionHandler > SAL_CALL -CommandEnvironment::getInteractionHandler() - throw ( uno::RuntimeException ) -{ - return m_xIH; -} - -//========================================================================= -// virtual -uno::Reference< ucb::XProgressHandler > SAL_CALL -CommandEnvironment::getProgressHandler() - throw ( uno::RuntimeException ) -{ - return m_xPH; -} - -//========================================================================= -// // class ActiveDataSink. // //========================================================================= @@ -389,7 +342,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle ) //========================================================================= //========================================================================= -static rtl::OUString createDesiredName( +rtl::OUString createDesiredName( const rtl::OUString & rSourceURL, const rtl::OUString & rNewTitle ) { rtl::OUString aName( rNewTitle ); @@ -438,13 +391,13 @@ static rtl::OUString createDesiredName( return rtl::OUString( aName ); } -static rtl::OUString createDesiredName( +rtl::OUString createDesiredName( const ucb::GlobalTransferCommandArgument & rArg ) { return createDesiredName( rArg.SourceURL, rArg.NewTitle ); } -static rtl::OUString createDesiredName( +rtl::OUString createDesiredName( const ucb::TransferInfo & rArg ) { return createDesiredName( rArg.SourceURL, rArg.NewTitle ); @@ -453,7 +406,7 @@ static rtl::OUString createDesiredName( //========================================================================= enum NameClashContinuation { NOT_HANDLED, ABORT, OVERWRITE, NEW_NAME, UNKNOWN }; -static NameClashContinuation interactiveNameClashResolve( +NameClashContinuation interactiveNameClashResolve( const uno::Reference< ucb::XCommandEnvironment > & xEnv, const rtl::OUString & rTargetURL, const rtl::OUString & rClashingName, @@ -528,7 +481,7 @@ static NameClashContinuation interactiveNameClashResolve( } //========================================================================= -static bool setTitle( +bool setTitle( const uno::Reference< ucb::XCommandProcessor > & xCommandProcessor, const uno::Reference< ucb::XCommandEnvironment > & xEnv, const rtl::OUString & rNewTitle ) @@ -576,7 +529,7 @@ static bool setTitle( } //========================================================================= -static uno::Reference< ucb::XContent > createNew( +uno::Reference< ucb::XContent > createNew( const TransferCommandContext & rContext, const uno::Reference< ucb::XContent > & xTarget, sal_Bool bSourceIsFolder, @@ -590,10 +543,12 @@ static uno::Reference< ucb::XContent > createNew( // ////////////////////////////////////////////////////////////////////// - uno::Reference< ucb::XContentCreator > xCreator( - xTarget, uno::UNO_QUERY ); + // First, try it using "CreatabeleContentsInfo" property and + // "createNewContent" command -> the "new" way. - if ( !xCreator.is() ) + uno::Reference< ucb::XCommandProcessor > xCommandProcessorT( + xTarget, uno::UNO_QUERY ); + if ( !xCommandProcessorT.is() ) { uno::Any aProps = uno::makeAny(beans::PropertyValue( @@ -606,24 +561,77 @@ static uno::Reference< ucb::XContent > createNew( ucb::IOErrorCode_CANT_CREATE, uno::Sequence< uno::Any >(&aProps, 1), rContext.xOrigEnv, - rtl::OUString::createFromAscii( "Target is no XContentCreator!" ), + rtl::OUString::createFromAscii( "Target is no XCommandProcessor!" ), rContext.xProcessor ); // Unreachable } - uno::Sequence< ucb::ContentInfo > aTypesInfo - = xCreator->queryCreatableContentsInfo(); + uno::Sequence< beans::Property > aPropsToObtain( 1 ); + aPropsToObtain[ 0 ].Name + = rtl::OUString::createFromAscii( "CreatableContentsInfo" ); + aPropsToObtain[ 0 ].Handle + = -1; - sal_Int32 nCount = aTypesInfo.getLength(); - if ( !nCount ) + ucb::Command aGetPropsCommand( + rtl::OUString::createFromAscii( "getPropertyValues" ), + -1, + uno::makeAny( aPropsToObtain ) ); + + uno::Reference< sdbc::XRow > xRow; + xCommandProcessorT->execute( aGetPropsCommand, 0, rContext.xEnv ) >>= xRow; + + uno::Sequence< ucb::ContentInfo > aTypesInfo; + bool bGotTypesInfo = false; + + if ( xRow.is() ) { - uno::Any aProps - = uno::makeAny(beans::PropertyValue( + uno::Any aValue = xRow->getObject( + 1, uno::Reference< container::XNameAccess >() ); + if ( aValue.hasValue() && ( aValue >>= aTypesInfo ) ) + { + bGotTypesInfo = true; + } + } + + uno::Reference< ucb::XContentCreator > xCreator; + + if ( !bGotTypesInfo ) + { + // Second, try it using XContentCreator interface -> the "old" way (not + // providing the chance to supply an XCommandEnvironment. + + xCreator.set( xTarget, uno::UNO_QUERY ); + + if ( !xCreator.is() ) + { + uno::Any aProps + = uno::makeAny(beans::PropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Folder")), -1, uno::makeAny(rContext.aArg.TargetURL), beans::PropertyState_DIRECT_VALUE)); + ucbhelper::cancelCommandExecution( + ucb::IOErrorCode_CANT_CREATE, + uno::Sequence< uno::Any >(&aProps, 1), + rContext.xOrigEnv, + rtl::OUString::createFromAscii( "Target is no XContentCreator!" ), + rContext.xProcessor ); + // Unreachable + } + + aTypesInfo = xCreator->queryCreatableContentsInfo(); + } + + sal_Int32 nCount = aTypesInfo.getLength(); + if ( !nCount ) + { + uno::Any aProps + = uno::makeAny(beans::PropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Folder")), + -1, + uno::makeAny(rContext.aArg.TargetURL), + beans::PropertyState_DIRECT_VALUE)); ucbhelper::cancelCommandExecution( ucb::IOErrorCode_CANT_CREATE, uno::Sequence< uno::Any >(&aProps, 1), @@ -680,7 +688,7 @@ static uno::Reference< ucb::XContent > createNew( !!( nAttribs & ucb::ContentInfoAttribute::KIND_FOLDER ) ) && - ( !!bSourceIsDocument == + ( !!bSourceIsDocument == !!( nAttribs & ucb::ContentInfoAttribute::KIND_DOCUMENT ) ) ) @@ -710,7 +718,25 @@ static uno::Reference< ucb::XContent > createNew( // ////////////////////////////////////////////////////////////// - xNew = xCreator->createNewContent( aTypesInfo[ n ] ); + if ( !xCreator.is() ) + { + // First, try it using "CreatabeleContentsInfo" property and + // "createNewContent" command -> the "new" way. + ucb::Command aCreateNewCommand( + rtl::OUString::createFromAscii( "createNewContent" ), + -1, + uno::makeAny( aTypesInfo[ n ] ) ); + + xCommandProcessorT->execute( aCreateNewCommand, 0, rContext.xEnv ) + >>= xNew; + } + else + { + // Second, try it using XContentCreator interface -> the "old" + // way (not providing the chance to supply an XCommandEnvironment. + + xNew = xCreator->createNewContent( aTypesInfo[ n ] ); + } if ( !xNew.is() ) { @@ -739,7 +765,7 @@ static uno::Reference< ucb::XContent > createNew( } //========================================================================= -static void transferProperties( +void transferProperties( const TransferCommandContext & rContext, const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorS, const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorN ) @@ -904,7 +930,7 @@ static void transferProperties( } //========================================================================= -static uno::Reference< io::XInputStream > getInputStream( +uno::Reference< io::XInputStream > getInputStream( const TransferCommandContext & rContext, const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorS ) throw( uno::Exception ) @@ -992,7 +1018,7 @@ static uno::Reference< io::XInputStream > getInputStream( } //========================================================================= -static uno::Reference< sdbc::XResultSet > getResultSet( +uno::Reference< sdbc::XResultSet > getResultSet( const TransferCommandContext & rContext, const uno::Reference< ucb::XCommandProcessor > & xCommandProcessorS ) throw( uno::Exception ) @@ -1038,7 +1064,7 @@ static uno::Reference< sdbc::XResultSet > getResultSet( } //========================================================================= -static void handleNameClashRename( +void handleNameClashRename( const TransferCommandContext & rContext, const uno::Reference< ucb::XContent > & xNew, const uno::Reference< @@ -1217,7 +1243,7 @@ static void handleNameClashRename( } //========================================================================= -static void globalTransfer( +void globalTransfer_( const TransferCommandContext & rContext, const uno::Reference< ucb::XContent > & xSource, const uno::Reference< ucb::XContent > & xTarget, @@ -1632,7 +1658,7 @@ static void globalTransfer( rtl::OUString(), // NewTitle; rContext.aArg.NameClash ); // NameClash - ucb_commands::TransferCommandContext aSubCtx( + TransferCommandContext aSubCtx( rContext.xSMgr, rContext.xProcessor, rContext.xEnv, @@ -1649,10 +1675,10 @@ static void globalTransfer( aSubCtx.aArg.SourceURL = xChild->getIdentifier()->getContentIdentifier(); - ucb_commands::globalTransfer( aSubCtx, - xChild, - xNew, - xChildRow ); + globalTransfer_( aSubCtx, + xChild, + xNew, + xChildRow ); } } while ( xResultSet->next() ); @@ -1695,7 +1721,7 @@ static void globalTransfer( } } -} /* namescpace ucb_commands */ +} /* namescpace */ //========================================================================= // @@ -1706,8 +1732,7 @@ static void globalTransfer( uno::Reference< ucb::XCommandInfo > UniversalContentBroker::getCommandInfo() { - return uno::Reference< ucb::XCommandInfo >( - new ucb_commands::CommandProcessorInfo() ); + return uno::Reference< ucb::XCommandInfo >( new CommandProcessorInfo() ); } //========================================================================= @@ -1717,14 +1742,24 @@ void UniversalContentBroker::globalTransfer( throw( uno::Exception ) { // Use own command environment with own interaction handler intercepting - // some interaction requests that shell not be handled by the user-supplied + // some interaction requests that shall not be handled by the user-supplied // interaction handler. uno::Reference< ucb::XCommandEnvironment > xLocalEnv; if (xEnv.is()) - xLocalEnv.set( new ucb_commands::CommandEnvironment( - new ucb_commands::InteractionHandlerProxy( - xEnv->getInteractionHandler() ), - xEnv->getProgressHandler() ) ); + { + uno::Reference< beans::XPropertySet > const xProps( + m_xSMgr, uno::UNO_QUERY_THROW ); + uno::Reference< uno::XComponentContext > xCtx; + xCtx.set( xProps->getPropertyValue( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), + uno::UNO_QUERY_THROW ); + + xLocalEnv.set( ucb::CommandEnvironment::create( + xCtx, + new InteractionHandlerProxy( xEnv->getInteractionHandler() ), + xEnv->getProgressHandler() ) ); + } ////////////////////////////////////////////////////////////////////// // @@ -1862,27 +1897,27 @@ void UniversalContentBroker::globalTransfer( uno::Any aExc; rtl::OUString aNewTitle; - ucb_commands::NameClashContinuation eCont - = ucb_commands::interactiveNameClashResolve( + NameClashContinuation eCont + = interactiveNameClashResolve( xEnv, // always use original environment! rArg.TargetURL, // target folder URL - ucb_commands::createDesiredName( - aTransferArg ), // clashing name + createDesiredName( + aTransferArg ), // clashing name aExc, aNewTitle ); switch ( eCont ) { - case ucb_commands::NOT_HANDLED: + case NOT_HANDLED: // Not handled. cppu::throwException( aExc ); // break; - case ucb_commands::UNKNOWN: + case UNKNOWN: // Handled, but not clear, how... // fall-thru intended. - case ucb_commands::ABORT: + case ABORT: throw ucb::CommandFailedException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( @@ -1892,13 +1927,13 @@ void UniversalContentBroker::globalTransfer( aExc ); // break; - case ucb_commands::OVERWRITE: + case OVERWRITE: aTransferArg.NameClash = ucb::NameClash::OVERWRITE; bRetry = true; break; - case ucb_commands::NEW_NAME: + case NEW_NAME: aTransferArg.NewTitle = aNewTitle; bRetry = true; break; @@ -2015,7 +2050,7 @@ void UniversalContentBroker::globalTransfer( // Unreachable } - ucb_commands::TransferCommandContext aTransferCtx( + TransferCommandContext aTransferCtx( m_xSMgr, this, xLocalEnv, xEnv, rArg ); if ( rArg.NewTitle.getLength() == 0 ) @@ -2025,12 +2060,12 @@ void UniversalContentBroker::globalTransfer( if ( aBaseURI.getLength() ) { aTransferCtx.aArg.NewTitle - = ucb_commands::createDesiredName( aBaseURI, rtl::OUString() ); + = createDesiredName( aBaseURI, rtl::OUString() ); } } // Do it! - ucb_commands::globalTransfer( aTransferCtx, xSource, xTarget, xRow ); + globalTransfer_( aTransferCtx, xSource, xTarget, xRow ); ////////////////////////////////////////////////////////////////////// // @@ -37,6 +37,7 @@ #include "ucbstore.hxx" #include "ucbprops.hxx" #include "provprox.hxx" +#include "cmdenv.hxx" using namespace rtl; using namespace com::sun::star::uno; @@ -46,7 +47,7 @@ using namespace com::sun::star::registry; //========================================================================= static sal_Bool writeInfo( void * pRegistryKey, const OUString & rImplementationName, - Sequence< OUString > const & rServiceNames ) + Sequence< OUString > const & rServiceNames ) { OUString aKeyName( OUString::createFromAscii( "/" ) ); aKeyName += rImplementationName; @@ -124,7 +125,15 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( void *, void * pRegistryKey ) writeInfo( pRegistryKey, UcbContentProviderProxyFactory::getImplementationName_Static(), - UcbContentProviderProxyFactory::getSupportedServiceNames_Static() ); + UcbContentProviderProxyFactory::getSupportedServiceNames_Static() ) && + + ////////////////////////////////////////////////////////////////////// + // Command Environment. + ////////////////////////////////////////////////////////////////////// + + writeInfo( pRegistryKey, + ucb_cmdenv::UcbCommandEnvironment::getImplementationName_Static(), + ucb_cmdenv::UcbCommandEnvironment::getSupportedServiceNames_Static() ); } //========================================================================= @@ -179,6 +188,17 @@ extern "C" void * SAL_CALL component_getFactory( } ////////////////////////////////////////////////////////////////////// + // Command Environment. + ////////////////////////////////////////////////////////////////////// + + else if ( ucb_cmdenv::UcbCommandEnvironment::getImplementationName_Static(). + compareToAscii( pImplName ) == 0 ) + { + xFactory + = ucb_cmdenv::UcbCommandEnvironment::createServiceFactory( xSMgr ); + } + + ////////////////////////////////////////////////////////////////////// if ( xFactory.is() ) { @@ -49,7 +49,6 @@ #include <com/sun/star/beans/PropertySetInfoChange.hpp> #include <com/sun/star/ucb/ContentAction.hpp> #include <com/sun/star/ucb/NameClash.hpp> -#include <com/sun/star/ucb/ContentInfoAttribute.hpp> #include "filglob.hxx" #include "filid.hxx" #include "filrow.hxx" @@ -437,6 +436,15 @@ BaseContent::execute( const Command& aCommand, if(!xRow->wasNull()) aAny <<= CasePreservingURL; } + else if( ! aCommand.Name.compareToAscii( "createNewContent" ) ) + { + ucb::ContentInfo aArg; + if ( !( aCommand.Argument >>= aArg ) ) + m_pMyShell->installError( CommandId, + TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT ); + else + aAny <<= createNewContent( aArg ); + } else m_pMyShell->installError( CommandId, TASKHANDLER_UNSUPPORTED_COMMAND ); @@ -529,9 +537,9 @@ BaseContent::getContentType() // Who am I ? Sequence< beans::Property > seq(1); seq[0] = beans::Property( rtl::OUString::createFromAscii("IsDocument"), - -1, - getCppuType( static_cast< sal_Bool* >(0) ), - 0 ); + -1, + getCppuType( static_cast< sal_Bool* >(0) ), + 0 ); Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq ); sal_Bool IsDocument = xRow->getBoolean( 1 ); @@ -637,27 +645,7 @@ BaseContent::queryCreatableContentsInfo( void ) throw( RuntimeException ) { - Sequence< ContentInfo > seq(2); - - // file - seq[0].Type = m_pMyShell->FileContentType; - seq[0].Attributes = ContentInfoAttribute::INSERT_WITH_INPUTSTREAM - | ContentInfoAttribute::KIND_DOCUMENT; - - Sequence< beans::Property > props( 1 ); - props[0] = beans::Property( - rtl::OUString::createFromAscii( "Title" ), - -1, - getCppuType( static_cast< rtl::OUString* >( 0 ) ), - beans::PropertyAttribute::MAYBEVOID - | beans::PropertyAttribute::BOUND ); - seq[0].Properties = props; - - // folder - seq[1].Type = m_pMyShell->FolderContentType; - seq[1].Attributes = ContentInfoAttribute::KIND_FOLDER; - seq[1].Properties = props; - return seq; + return m_pMyShell->queryCreatableContentsInfo(); } @@ -688,18 +676,18 @@ BaseContent::createNewContent( { Sequence< beans::Property > seq(1); seq[0] = beans::Property( rtl::OUString::createFromAscii("IsDocument"), - -1, - getCppuType( static_cast< sal_Bool* >(0) ), - 0 ); + -1, + getCppuType( static_cast< sal_Bool* >(0) ), + 0 ); Reference< sdbc::XRow > xRow = getPropertyValues( -1,seq ); IsDocument = xRow->getBoolean( 1 ); if ( xRow->wasNull() ) { IsDocument = false; -// OSL_ENSURE( false, -// "BaseContent::createNewContent - Property value was null!" ); -// return Reference< XContent >(); +// OSL_ENSURE( false, +// "BaseContent::createNewContent - Property value was null!" ); +// return Reference< XContent >(); } } catch ( sdbc::SQLException const & ) @@ -42,21 +42,21 @@ namespace fileaccess { #define TASKHANDLING_WRONG_DELETE_ARGUMENT 5 #define TASKHANDLING_WRONG_TRANSFER_ARGUMENT 6 #define TASKHANDLING_WRONG_INSERT_ARGUMENT 7 +#define TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT 8 +#define TASKHANDLING_UNSUPPORTED_OPEN_MODE 9 -#define TASKHANDLING_UNSUPPORTED_OPEN_MODE 8 +#define TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND 10 +#define TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND 11 -#define TASKHANDLING_DELETED_STATE_IN_OPEN_COMMAND 9 -#define TASKHANDLING_INSERTED_STATE_IN_OPEN_COMMAND 10 +#define TASKHANDLING_OPEN_FILE_FOR_PAGING 12 +#define TASKHANDLING_NOTCONNECTED_FOR_PAGING 13 +#define TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING 14 +#define TASKHANDLING_IOEXCEPTION_FOR_PAGING 15 +#define TASKHANDLING_READING_FILE_FOR_PAGING 16 -#define TASKHANDLING_OPEN_FILE_FOR_PAGING 11 -#define TASKHANDLING_NOTCONNECTED_FOR_PAGING 12 -#define TASKHANDLING_BUFFERSIZEEXCEEDED_FOR_PAGING 13 -#define TASKHANDLING_IOEXCEPTION_FOR_PAGING 14 -#define TASKHANDLING_READING_FILE_FOR_PAGING 15 - -#define TASKHANDLING_OPEN_FOR_INPUTSTREAM 16 -#define TASKHANDLING_OPEN_FOR_STREAM 17 -#define TASKHANDLING_OPEN_FOR_DIRECTORYLISTING 18 +#define TASKHANDLING_OPEN_FOR_INPUTSTREAM 17 +#define TASKHANDLING_OPEN_FOR_STREAM 18 +#define TASKHANDLING_OPEN_FOR_DIRECTORYLISTING 19 #define TASKHANDLING_NOFRESHINSERT_IN_INSERT_COMMAND 22 #define TASKHANDLING_NONAMESET_INSERT_COMMAND 23 @@ -286,7 +286,8 @@ namespace fileaccess { errorCode == TASKHANDLING_WRONG_OPEN_ARGUMENT || errorCode == TASKHANDLING_WRONG_DELETE_ARGUMENT || errorCode == TASKHANDLING_WRONG_TRANSFER_ARGUMENT || - errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT ) + errorCode == TASKHANDLING_WRONG_INSERT_ARGUMENT || + errorCode == TASKHANDLING_WRONG_CREATENEWCONTENT_ARGUMENT ) { IllegalArgumentException excep; excep.ArgumentPosition = 0; @@ -655,15 +656,15 @@ namespace fileaccess { aAny <<= excep; cancelCommandExecution( aAny,xEnv ); } -// ioErrorCode = IOErrorCode_ALREADY_EXISTING; -// cancelCommandExecution( -// ioErrorCode, -// generateErrorArguments(aUncPath), -// xEnv, -// rtl::OUString( -// RTL_CONSTASCII_USTRINGPARAM( -// "the folder exists")), -// xComProc ); +// ioErrorCode = IOErrorCode_ALREADY_EXISTING; +// cancelCommandExecution( +// ioErrorCode, +// generateErrorArguments(aUncPath), +// xEnv, +// rtl::OUString( +// RTL_CONSTASCII_USTRINGPARAM( +// "the folder exists")), +// xComProc ); } else if( errorCode == TASKHANDLING_ENSUREDIR_FOR_WRITE || errorCode == TASKHANDLING_CREATEDIRECTORY_MKDIR ) @@ -814,20 +815,20 @@ namespace fileaccess { errorCode == TASKHANDLING_TRANSFER_BY_MOVE_SOURCESTAT ) { ioErrorCode = IOErrorCode_NOT_EXISTING; - aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "source file/folder does not exist")); break; } else { ioErrorCode = IOErrorCode_GENERAL; - aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "a general error during transfer command")); break; } default: ioErrorCode = IOErrorCode_GENERAL; - aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + aMsg = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "a general error during transfer command")); break; } @@ -33,11 +33,11 @@ #include "filtask.hxx" #include "filglob.hxx" -/*********************************************************************************/ -/* */ -/* TaskHandling */ -/* */ -/*********************************************************************************/ +/******************************************************************************/ +/* */ +/* TaskHandling */ +/* */ +/******************************************************************************/ using namespace fileaccess; @@ -70,7 +70,9 @@ TaskManager::startTask( TaskMap::iterator it = m_aTaskMap.find( CommandId ); if( it != m_aTaskMap.end() ) { - throw DuplicateCommandIdentifierException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); + throw DuplicateCommandIdentifierException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), + uno::Reference< uno::XInterface >() ); } m_aTaskMap[ CommandId ] = TaskHandling( xCommandEnv ); } @@ -91,7 +93,8 @@ TaskManager::endTask( sal_Int32 CommandId, sal_Int32 MinorCode = it->second.getMinorErrorCode(); bool isHandled = it->second.isHandled(); - Reference< XCommandEnvironment > xComEnv = it->second.getCommandEnvironment(); + Reference< XCommandEnvironment > xComEnv + = it->second.getCommandEnvironment(); m_aTaskMap.erase( it ); @@ -122,17 +125,6 @@ TaskManager::abort( sal_Int32 CommandId ) } -bool SAL_CALL TaskManager::isAborted( sal_Int32 CommandId ) -{ - osl::MutexGuard aGuard( m_aMutex ); - TaskMap::iterator it = m_aTaskMap.find( CommandId ); - if( it == m_aTaskMap.end() || it->second.isAborted() ) - return false; - else - return true; -} - - void SAL_CALL TaskManager::clearError( sal_Int32 CommandId ) { osl::MutexGuard aGuard( m_aMutex ); @@ -178,45 +170,9 @@ TaskManager::getCommandId( void ) -uno::Reference< task::XInteractionHandler > SAL_CALL -TaskManager::getInteractionHandler( sal_Int32 CommandId ) -{ - osl::MutexGuard aGuard( m_aMutex ); - TaskMap::iterator it = m_aTaskMap.find( CommandId ); - if( it == m_aTaskMap.end() ) - return uno::Reference< task::XInteractionHandler >( 0 ); - else - return it->second.getInteractionHandler(); -} - - - -uno::Reference< XProgressHandler > SAL_CALL -TaskManager::getProgressHandler( sal_Int32 CommandId ) -{ - osl::MutexGuard aGuard( m_aMutex ); - TaskMap::iterator it = m_aTaskMap.find( CommandId ); - if( it == m_aTaskMap.end() ) - return uno::Reference< XProgressHandler >( 0 ); - else - return it->second.getProgressHandler(); -} - - -uno::Reference< XCommandEnvironment > SAL_CALL -TaskManager::getCommandEnvironment( sal_Int32 CommandId ) -{ - osl::MutexGuard aGuard( m_aMutex ); - TaskMap::iterator it = m_aTaskMap.find( CommandId ); - if( it == m_aTaskMap.end() ) - return uno::Reference< XCommandEnvironment >( 0 ); - else - return it->second.getCommandEnvironment(); -} - - -void SAL_CALL TaskManager::handleTask( sal_Int32 CommandId, - const uno::Reference< task::XInteractionRequest >& request ) +void SAL_CALL TaskManager::handleTask( + sal_Int32 CommandId, + const uno::Reference< task::XInteractionRequest >& request ) { osl::MutexGuard aGuard( m_aMutex ); TaskMap::iterator it = m_aTaskMap.find( CommandId ); @@ -229,8 +185,3 @@ void SAL_CALL TaskManager::handleTask( sal_Int32 CommandId, it->second.setHandled(); } } - - - - - @@ -40,9 +40,7 @@ #include <com/sun/star/ucb/XProgressHandler.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> -#ifndef _FILERROR_HXX_ #include "filerror.hxx" -#endif namespace fileaccess @@ -52,11 +50,8 @@ namespace fileaccess /* * This implementation is inherited by class fileaccess::shell. * The relevant methods in this class all have as first argument the CommandId, - * so if necessary, every method has acess to its relevant XInteractionHandler and - * XProgressHandler, simply by calling directly the method - * getInteractionHandler( CommandId ) - * and - * getProgressHandler(); + * so if necessary, every method has access to its relevant XInteractionHandler and + * XProgressHandler. */ @@ -95,11 +90,6 @@ namespace fileaccess m_bAbort = true; } - bool SAL_CALL isAborted() - { - return m_bAbort; - } - void setHandled() { m_bHandled = true; @@ -182,7 +172,6 @@ namespace fileaccess sal_Int32 SAL_CALL getCommandId( void ); void SAL_CALL abort( sal_Int32 CommandId ); - bool SAL_CALL isAborted( sal_Int32 CommandId ); /** @@ -234,16 +223,6 @@ namespace fileaccess void SAL_CALL clearError( sal_Int32 ); - - com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > SAL_CALL - getInteractionHandler( sal_Int32 CommandId ); - - com::sun::star::uno::Reference< com::sun::star::ucb::XProgressHandler > SAL_CALL - getProgressHandler( sal_Int32 CommandId ); - - com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > SAL_CALL - getCommandEnvironment( sal_Int32 CommandId ); - }; } // end namespace TaskHandling @@ -46,23 +46,18 @@ #include <com/sun/star/ucb/NameClash.hpp> #include <com/sun/star/ucb/XContentIdentifier.hpp> #include <com/sun/star/lang/XComponent.hpp> -#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_ #include <com/sun/star/ucb/XContentAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBBUTE_HPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/io/XTruncate.hpp> #include <com/sun/star/ucb/OpenCommandArgument.hpp> #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp> #include <com/sun/star/ucb/TransferInfo.hpp> +#include <com/sun/star/ucb/ContentInfoAttribute.hpp> #include <com/sun/star/beans/PropertyChangeEvent.hpp> #include <com/sun/star/beans/XPropertiesChangeListener.hpp> #include <rtl/string.hxx> -#ifndef _FILERROR_HXX_ #include "filerror.hxx" -#endif #include "filglob.hxx" #include "filcmd.hxx" #include "filinpstr.hxx" @@ -188,9 +183,10 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF IsHidden( rtl::OUString::createFromAscii( "IsHidden" ) ), ContentType( rtl::OUString::createFromAscii( "ContentType" ) ), IsReadOnly( rtl::OUString::createFromAscii( "IsReadOnly" ) ), + CreatableContentsInfo( rtl::OUString::createFromAscii( "CreatableContentsInfo" ) ), FolderContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" ) ), FileContentType( rtl::OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-file" ) ), - m_sCommandInfo( 8 ) + m_sCommandInfo( 9 ) { // Title m_aDefaultProperties.insert( MyProperty( true, @@ -294,7 +290,7 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF | beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ) ); - // Remote + // Hidden m_aDefaultProperties.insert( MyProperty( true, @@ -312,7 +308,6 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF #endif - // ContentType uno::Any aAny; aAny <<= rtl::OUString(); @@ -358,6 +353,17 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF | beans::PropertyAttribute::BOUND ) ); + // CreatableContentsInfo + m_aDefaultProperties.insert( MyProperty( true, + CreatableContentsInfo, + -1 , + getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + uno::Any(), + beans::PropertyState_DEFAULT_VALUE, + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) ); + // Commands m_sCommandInfo[0].Name = rtl::OUString::createFromAscii( "getCommandInfo" ); m_sCommandInfo[0].Handle = -1; @@ -391,6 +397,9 @@ shell::shell( const uno::Reference< lang::XMultiServiceFactory >& xMultiServiceF m_sCommandInfo[7].Handle = -1; m_sCommandInfo[7].ArgType = getCppuType( static_cast< InsertCommandArgument* > ( 0 ) ); + m_sCommandInfo[7].Name = rtl::OUString::createFromAscii( "createNewContent" ); + m_sCommandInfo[7].Handle = -1; + m_sCommandInfo[7].ArgType = getCppuType( static_cast< ucb::ContentInfo * > ( 0 ) ); if(m_bWithConfig) { @@ -1597,7 +1606,7 @@ shell::remove( sal_Int32 CommandId, nError = aDirectory.getNextItem( aItem ); while( nError == osl::FileBase::E_None ) { - nError = aItem.getFileStatus( aStatus ); + nError = aItem.getFileStatus( aStatus ); if( nError != osl::FileBase::E_None || ! aStatus.isValid( nMask ) ) { installError( CommandId, @@ -1623,7 +1632,7 @@ shell::remove( sal_Int32 CommandId, nError = aDirectory.getNextItem( aItem ); } - aDirectory.close(); + aDirectory.close(); if( ! whileSuccess ) return sal_False; // error code is installed @@ -2297,9 +2306,9 @@ shell::commit( const shell::ContentMap::iterator& it, sal_Bool isDirectory,isFile,isVolume,isRemoveable,isRemote,isFloppy,isCompactDisc; - sal_Int64 dirSize = 0;
-
- if( aFileStatus.isValid( FileStatusMask_FileSize ) )
+ sal_Int64 dirSize = 0; + + if( aFileStatus.isValid( FileStatusMask_FileSize ) ) dirSize = aFileStatus.getFileSize(); if( aFileStatus.isValid( FileStatusMask_Type ) ) @@ -2320,7 +2329,7 @@ shell::commit( const shell::ContentMap::iterator& it, isFile = osl::FileStatus::Regular == aFileStatus2.getFileType(); - if( aFileStatus2.isValid( FileStatusMask_FileSize ) )
+ if( aFileStatus2.isValid( FileStatusMask_FileSize ) ) dirSize = aFileStatus2.getFileSize(); } else @@ -2346,17 +2355,17 @@ shell::commit( const shell::ContentMap::iterator& it, osl::FileStatus::Regular == aFileStatus.getFileType(); } - aAny <<= isVolume; it1 = properties.find( MyProperty( IsVolume ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isVolume ) ); - aAny <<= isDirectory; it1 = properties.find( MyProperty( IsFolder ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isDirectory ) ); - aAny <<= isFile; it1 = properties.find( MyProperty( IsDocument ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isFile ) ); osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); if( isVolume && @@ -2369,44 +2378,51 @@ shell::commit( const shell::ContentMap::iterator& it, isCompactDisc = aVolumeInfo.getCompactDiscFlag(); isFloppy = aVolumeInfo.getFloppyDiskFlag(); - aAny <<= isRemote; it1 = properties.find( MyProperty( IsRemote ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isRemote ) ); - aAny <<= isRemoveable; it1 = properties.find( MyProperty( IsRemoveable ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isRemoveable ) ); - aAny <<= isCompactDisc; it1 = properties.find( MyProperty( IsCompactDisc ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isCompactDisc ) ); - aAny <<= isFloppy; it1 = properties.find( MyProperty( IsFloppy ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( isFloppy ) ); } else { sal_Bool dummy = false; aAny <<= dummy; it1 = properties.find( MyProperty( IsRemote ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( aAny ); + it1 = properties.find( MyProperty( IsRemoveable ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( aAny ); + it1 = properties.find( MyProperty( IsCompactDisc ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( aAny ); + it1 = properties.find( MyProperty( IsFloppy ) ); - if( it1 != properties.end() ) it1->setValue( aAny ); + if( it1 != properties.end() ) + it1->setValue( aAny ); } } - - it1 = properties.find( MyProperty( Size ) ); - if( it1 != properties.end() ) + else { - aAny <<= dirSize;
- it1->setValue( aAny ); + isDirectory = sal_False; } + it1 = properties.find( MyProperty( Size ) ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( dirSize ) ); it1 = properties.find( MyProperty( IsReadOnly ) ); if( it1 != properties.end() ) @@ -2415,8 +2431,7 @@ shell::commit( const shell::ContentMap::iterator& it, { sal_uInt64 Attr = aFileStatus.getAttributes(); sal_Bool readonly = ( Attr & Attribute_ReadOnly ) != 0; - aAny <<= readonly; - it1->setValue( aAny ); + it1->setValue( uno::makeAny( readonly ) ); } } @@ -2427,13 +2442,11 @@ shell::commit( const shell::ContentMap::iterator& it, { sal_uInt64 Attr = aFileStatus.getAttributes(); sal_Bool ishidden = ( Attr & Attribute_Hidden ) != 0; - aAny <<= ishidden; - it1->setValue( aAny ); + it1->setValue( uno::makeAny( ishidden ) ); } } it1 = properties.find( MyProperty( DateModified ) ); - if( it1 != properties.end() ) { if( aFileStatus.isValid( FileStatusMask_ModifyTime ) ) @@ -2441,7 +2454,7 @@ shell::commit( const shell::ContentMap::iterator& it, TimeValue temp = aFileStatus.getModifyTime(); // Convert system time to local time (for EA) - TimeValue myLocalTime; + TimeValue myLocalTime; osl_getLocalTimeFromSystemTime( &temp, &myLocalTime ); oslDateTime myDateTime; @@ -2455,11 +2468,16 @@ shell::commit( const shell::ContentMap::iterator& it, aDateTime.Day = myDateTime.Day; aDateTime.Month = myDateTime.Month; aDateTime.Year = myDateTime.Year; - aAny <<= aDateTime; - it1->setValue( aAny ); + it1->setValue( uno::makeAny( aDateTime ) ); } } + it1 = properties.find( MyProperty( CreatableContentsInfo ) ); + if( it1 != properties.end() ) + it1->setValue( uno::makeAny( + isDirectory || !aFileStatus.isValid( FileStatusMask_Type ) + ? queryCreatableContentsInfo() + : uno::Sequence< ucb::ContentInfo >() ) ); } @@ -2494,8 +2512,8 @@ shell::getv( { // Assume failure aIsRegular = false; - osl::FileBase::RC result = osl::FileBase::E_INVAL; - osl::DirectoryItem aTargetItem; + osl::FileBase::RC result = osl::FileBase::E_INVAL; + osl::DirectoryItem aTargetItem; osl::DirectoryItem::get( aFileStatus.getLinkTargetURL(), aTargetItem ); if ( aTargetItem.is() ) { @@ -3000,6 +3018,31 @@ shell::copyPersistentSet( const rtl::OUString& srcUnqPath, } // end for( sal_Int... } +uno::Sequence< ucb::ContentInfo > shell::queryCreatableContentsInfo() +{ + uno::Sequence< ucb::ContentInfo > seq(2); + + // file + seq[0].Type = FileContentType; + seq[0].Attributes = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM + | ucb::ContentInfoAttribute::KIND_DOCUMENT; + + uno::Sequence< beans::Property > props( 1 ); + props[0] = beans::Property( + rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< rtl::OUString* >( 0 ) ), + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::BOUND ); + seq[0].Properties = props; + + // folder + seq[1].Type = FolderContentType; + seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER; + seq[1].Properties = props; + return seq; +} + /*******************************************************************************/ /* */ /* some misceancellous static functions */ @@ -54,21 +54,18 @@ #include <com/sun/star/ucb/XCommandProcessor.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XInputStream.hpp> -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_protected #include <com/sun/star/beans/XPropertySetInfo.hpp> -#endif #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp> #include <com/sun/star/ucb/NumberedSortingInfo.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ucb/XContentProvider.hpp> -#ifndef _COM_SUN_STAR_UCB_XDYNAMICRESULTSET_HPP__ #include <com/sun/star/ucb/XDynamicResultSet.hpp> -#endif #include <com/sun/star/beans/XPropertyContainer.hpp> #include <com/sun/star/beans/XPropertyAccess.hpp> #include <com/sun/star/ucb/XPropertySetRegistryFactory.hpp> #include <com/sun/star/ucb/TransferInfo.hpp> +#include <com/sun/star/ucb/ContentInfo.hpp> #include "filtask.hxx" #include "filnot.hxx" @@ -307,7 +304,7 @@ namespace fileaccess { /********************************************************************************/ - /* transfer-commandos */ + /* transfer-commands */ /********************************************************************************/ /** @@ -398,6 +395,9 @@ namespace fileaccess { void SAL_CALL insertDefaultProperties( const rtl::OUString& aUnqPath ); + com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > + queryCreatableContentsInfo(); + /******************************************************************************/ /* */ @@ -416,7 +416,6 @@ namespace fileaccess { com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMultiServiceFactory; com::sun::star::uno::Reference< com::sun::star::ucb::XPropertySetRegistry > m_xFileRegistry; - private: /********************************************************************************/ @@ -580,6 +579,7 @@ namespace fileaccess { const rtl::OUString IsHidden; const rtl::OUString ContentType; const rtl::OUString IsReadOnly; + const rtl::OUString CreatableContentsInfo; public: @@ -106,19 +106,6 @@ using namespace com::sun::star::sdbc; FTPContent::FTPContent( const Reference< XMultiServiceFactory >& rxSMgr, FTPContentProvider* pProvider, - const Reference< XContentIdentifier >& Identifier) - : ContentImplHelper(rxSMgr,pProvider,Identifier), - m_pFCP(pProvider), - m_aFTPURL(Identifier->getContentIdentifier(), - pProvider), - m_bInserted(false), - m_bTitleSet(false) -{ -} - - -FTPContent::FTPContent( const Reference< XMultiServiceFactory >& rxSMgr, - FTPContentProvider* pProvider, const Reference< XContentIdentifier >& Identifier, const FTPURL& aFTPURL) : ContentImplHelper(rxSMgr,pProvider,Identifier), @@ -175,9 +162,9 @@ XINTERFACE_IMPL_6( FTPContent, //========================================================================= XTYPEPROVIDER_IMPL_6( FTPContent, - XTypeProvider, - XServiceInfo, - XContent, + XTypeProvider, + XServiceInfo, + XContent, XCommandProcessor, XContentCreator, XChild); @@ -231,7 +218,7 @@ void SAL_CALL FTPContent::abort( sal_Int32 /*CommandId*/ ) /***************************************************************************/ /* */ -/* Interne Implklasse */ +/* Internal implementation class. */ /* */ /***************************************************************************/ @@ -376,66 +363,85 @@ Any SAL_CALL FTPContent::execute( // return aRet; // } - if(action == THROWAUTHENTICATIONREQUEST) { + switch (action) + { + case NOACTION: + break; + + case THROWAUTHENTICATIONREQUEST: ucbhelper::cancelCommandExecution( aRet, Reference<XCommandEnvironment>(0)); - } else if(action == THROWACCESSDENIED) { - Sequence<Any> seq(1); - PropertyValue value; - value.Name = - rtl::OUString::createFromAscii("Uri"); - value.Handle = -1; - value.Value <<= m_aFTPURL.ident(false,false); - value.State = PropertyState_DIRECT_VALUE; - seq[0] <<= value; - ucbhelper::cancelCommandExecution( - IOErrorCode_ACCESS_DENIED, - seq, - Environment); - } else if(action == THROWINTERACTIVECONNECT) { - InteractiveNetworkConnectException - excep; - excep.Server = m_aFTPURL.host(); - aRet <<= excep; - ucbhelper::cancelCommandExecution( - aRet, - Environment); - } else if(action == THROWRESOLVENAME) { - InteractiveNetworkResolveNameException - excep; - excep.Server = m_aFTPURL.host(); - aRet <<= excep; - ucbhelper::cancelCommandExecution( - aRet, - Environment); - } else if(action == THROWNOFILE) { - Sequence<Any> seq(1); - PropertyValue value; - value.Name = - rtl::OUString::createFromAscii("Uri"); - value.Handle = -1; - value.Value <<= m_aFTPURL.ident(false,false); - value.State = PropertyState_DIRECT_VALUE; - seq[0] <<= value; - ucbhelper::cancelCommandExecution( - IOErrorCode_NO_FILE, - seq, - Environment); - } else if(action == THROWQUOTE || - action == THROWGENERAL) { + break; + + case THROWACCESSDENIED: + { + Sequence<Any> seq(1); + PropertyValue value; + value.Name = rtl::OUString::createFromAscii("Uri"); + value.Handle = -1; + value.Value <<= m_aFTPURL.ident(false,false); + value.State = PropertyState_DIRECT_VALUE; + seq[0] <<= value; + ucbhelper::cancelCommandExecution( + IOErrorCode_ACCESS_DENIED, + seq, + Environment); + break; + } + case THROWINTERACTIVECONNECT: + { + InteractiveNetworkConnectException excep; + excep.Server = m_aFTPURL.host(); + aRet <<= excep; + ucbhelper::cancelCommandExecution( + aRet, + Environment); + break; + } + case THROWRESOLVENAME: + { + InteractiveNetworkResolveNameException excep; + excep.Server = m_aFTPURL.host(); + aRet <<= excep; + ucbhelper::cancelCommandExecution( + aRet, + Environment); + break; + } + case THROWNOFILE: + { + Sequence<Any> seq(1); + PropertyValue value; + value.Name = rtl::OUString::createFromAscii("Uri"); + value.Handle = -1; + value.Value <<= m_aFTPURL.ident(false,false); + value.State = PropertyState_DIRECT_VALUE; + seq[0] <<= value; + ucbhelper::cancelCommandExecution( + IOErrorCode_NO_FILE, + seq, + Environment); + break; + } + case THROWQUOTE: + case THROWGENERAL: ucbhelper::cancelCommandExecution( IOErrorCode_GENERAL, Sequence<Any>(0), Environment); + break; } - if(aCommand.Name.compareToAscii("getPropertyValues") == 0) { Sequence<Property> Properties; if(!(aCommand.Argument >>= Properties)) { - aRet <<= IllegalArgumentException(); + aRet <<= IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >(this), + -1); ucbhelper::cancelCommandExecution(aRet,Environment); } @@ -446,7 +452,11 @@ Any SAL_CALL FTPContent::execute( Sequence<PropertyValue> propertyValues; if( ! ( aCommand.Argument >>= propertyValues ) ) { - aRet <<= IllegalArgumentException(); + aRet <<= IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >(this), + -1); ucbhelper::cancelCommandExecution(aRet,Environment); } @@ -464,7 +474,11 @@ Any SAL_CALL FTPContent::execute( { InsertCommandArgument aInsertArgument; if ( ! ( aCommand.Argument >>= aInsertArgument ) ) { - aRet <<= IllegalArgumentException(); + aRet <<= IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >(this), + -1); ucbhelper::cancelCommandExecution(aRet,Environment); } insert(aInsertArgument,Environment); @@ -476,7 +490,12 @@ Any SAL_CALL FTPContent::execute( else if(aCommand.Name.compareToAscii( "open" ) == 0) { OpenCommandArgument2 aOpenCommand; if ( !( aCommand.Argument >>= aOpenCommand ) ) { - aRet <<= IllegalArgumentException(); + aRet <<= IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >(this), + -1); + ucbhelper::cancelCommandExecution(aRet,Environment); } @@ -529,7 +548,10 @@ Any SAL_CALL FTPContent::execute( } } else { - aRet <<= UnsupportedDataSinkException(); + aRet <<= UnsupportedDataSinkException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >(this), + aOpenCommand.Sink); ucbhelper::cancelCommandExecution(aRet,Environment); } } @@ -557,17 +579,39 @@ Any SAL_CALL FTPContent::execute( aOpenCommand.Mode == OpenMode::DOCUMENT_SHARE_DENY_WRITE) { // Unsupported OpenMode - aRet <<= UnsupportedOpenModeException(); + aRet <<= UnsupportedOpenModeException( + rtl::OUString(), + static_cast< cppu::OWeakObject * >(this), + static_cast< sal_Int16 >(aOpenCommand.Mode)); ucbhelper::cancelCommandExecution(aRet,Environment); } else { - // IllegalArgumentException:: No OpenMode - aRet <<= IllegalArgumentException(); + aRet <<= IllegalArgumentException( + rtl::OUString::createFromAscii( + "Unexpected OpenMode!" ), + static_cast< cppu::OWeakObject * >(this), + -1); + ucbhelper::cancelCommandExecution(aRet,Environment); } - } - else { - aRet <<= UnsupportedCommandException(); + } else if(aCommand.Name.compareToAscii("createNewContent") == 0) { + ContentInfo aArg; + if (!(aCommand.Argument >>= aArg)) { + ucbhelper::cancelCommandExecution( + makeAny( + IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >(this), + -1)), + Environment); + // Unreachable + } + aRet <<= createNewContent(aArg); + } else { + aRet <<= UnsupportedCommandException( + aCommand.Name, + static_cast< cppu::OWeakObject * >(this)); ucbhelper::cancelCommandExecution(aRet,Environment); } @@ -578,8 +622,11 @@ Any SAL_CALL FTPContent::execute( else if(e.code() == CURLE_COULDNT_RESOLVE_HOST ) action = THROWRESOLVENAME; else if(e.code() == CURLE_FTP_USER_PASSWORD_INCORRECT || +#if LIBCURL_VERSION_NUM>=0x070d01 /* 7.13.1 */ + e.code() == CURLE_LOGIN_DENIED || +#endif e.code() == CURLE_BAD_PASSWORD_ENTERED || - e.code() == CURLE_FTP_WEIRD_PASS_REPLY ) + e.code() == CURLE_FTP_WEIRD_PASS_REPLY) action = THROWAUTHENTICATIONREQUEST; else if(e.code() == CURLE_FTP_ACCESS_DENIED) action = THROWACCESSDENIED; @@ -588,7 +635,7 @@ Any SAL_CALL FTPContent::execute( else if(e.code() == CURLE_FTP_COULDNT_RETR_FILE) action = THROWNOFILE; else - // nothing known about the course of the error + // nothing known about the cause of the error action = THROWGENERAL; } } @@ -605,6 +652,14 @@ Sequence<ContentInfo > SAL_CALL FTPContent::queryCreatableContentsInfo( ) throw (RuntimeException) { + return queryCreatableContentsInfo_Static(); +} + +// static +Sequence<ContentInfo > +FTPContent::queryCreatableContentsInfo_Static( ) + throw (RuntimeException) +{ Sequence< ContentInfo > seq(2); seq[0].Type = FTP_FILE; @@ -627,7 +682,6 @@ FTPContent::queryCreatableContentsInfo( ) return seq; } - Reference<XContent > SAL_CALL FTPContent::createNewContent( const ContentInfo& Info ) throw (RuntimeException) @@ -697,7 +751,7 @@ sal_Int32 InsertData::read(sal_Int8 *dest,sal_Int32 nBytesRequested) sal_Int32 m = 0; if(m_xInputStream.is()) { - Sequence<sal_Int8> seq(nBytesRequested); + Sequence<sal_Int8> seq(nBytesRequested); m = m_xInputStream->readBytes(seq,nBytesRequested); rtl_copyMemory(dest,seq.getConstArray(),m); } @@ -798,6 +852,9 @@ Reference< XRow > FTPContent::getPropertyValues( const rtl::OUString& Name = seqProp[i].Name; if(Name.compareToAscii("Title") == 0) xRow->appendString(seqProp[i],aDirEntry.m_aName); + else if(Name.compareToAscii("CreatableContentsInfo") == 0) + xRow->appendObject(seqProp[i], + makeAny(queryCreatableContentsInfo())); else if(aDirEntry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) { if(Name.compareToAscii("ContentType") == 0) xRow->appendString(seqProp[i], @@ -838,9 +895,6 @@ Reference< XRow > FTPContent::getPropertyValues( Sequence<Any> FTPContent::setPropertyValues( const Sequence<PropertyValue>& seqPropVal) { - Sequence<Property> props = - getProperties(Reference<XCommandEnvironment>(0)); - Sequence<Any> ret(seqPropVal.getLength()); Sequence<PropertyChangeEvent > evt; @@ -879,11 +933,20 @@ Sequence<Any> FTPContent::setPropertyValues( ret[i] <<= excep; } } else { - // either not unknown or illegal + Sequence<Property> props = + getProperties(Reference<XCommandEnvironment>(0)); + + // either unknown or read-only ret[i] <<= UnknownPropertyException(); for(sal_Int32 j = 0; j < props.getLength(); ++j) if(props[j].Name == seqPropVal[i].Name) { - ret[i] <<= IllegalAccessException(); + ret[i] <<= IllegalAccessException( + rtl::OUString::createFromAscii( + "Property is read-only!"), + //props[j].Attributes & PropertyAttribute::READONLY + // ? "Property is read-only!" + // : "Access denied!"), + static_cast< cppu::OWeakObject * >( this )); break; } } @@ -57,19 +57,6 @@ namespace ftp //========================================================================= - struct ContentProperties - { - ::rtl::OUString aTitle; // Title - ::rtl::OUString aContentType; // ContentType - sal_Bool bIsDocument; // IsDocument - sal_Bool bIsFolder; // IsFolder - - ContentProperties() - : bIsDocument( sal_True ), bIsFolder( sal_False ) {} - }; - -//========================================================================= - class FTPContentProvider; //========================================================================= @@ -84,12 +71,6 @@ namespace ftp ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, FTPContentProvider* pProvider, const ::com::sun::star::uno::Reference< - ::com::sun::star::ucb::XContentIdentifier >& Identifier); - - FTPContent( const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, - FTPContentProvider* pProvider, - const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier, const FTPURL& FtpUrl); @@ -156,6 +137,11 @@ namespace ftp ::com::sun::star::uno::RuntimeException); + static com::sun::star::uno::Sequence< + com::sun::star::ucb::ContentInfo > + queryCreatableContentsInfo_Static( ) + throw (com::sun::star::uno::RuntimeException); + private: FTPContentProvider *m_pFCP; @@ -49,7 +49,7 @@ using namespace ftp; uno::Sequence< beans::Property > FTPContent::getProperties( const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/) { - #define PROPS_COUNT 7 + #define PROPS_COUNT 8 static const beans::Property aPropsInfoTable[] = { @@ -91,7 +91,7 @@ uno::Sequence< beans::Property > FTPContent::getProperties( beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateCreated" ) ), -1, - getCppuType( static_cast< util::DateTime* >( 0 ) ), + getCppuType( static_cast< util::DateTime * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), @@ -101,10 +101,19 @@ uno::Sequence< beans::Property > FTPContent::getProperties( getCppuBooleanType(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY + ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "CreatableContentsInfo" ) ), + -1, + getCppuType( + static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) }; - return uno::Sequence< beans::Property >( aPropsInfoTable,PROPS_COUNT); + return uno::Sequence< beans::Property >( aPropsInfoTable, PROPS_COUNT ); } //========================================================================= @@ -112,7 +121,7 @@ uno::Sequence< beans::Property > FTPContent::getProperties( uno::Sequence< ucb::CommandInfo > FTPContent::getCommands( const uno::Reference< ucb::XCommandEnvironment > & /*xEnv*/ ) { -// osl::MutexGuard aGuard( m_aMutex ); +// osl::MutexGuard aGuard( m_aMutex ); //================================================================= // @@ -120,7 +129,7 @@ uno::Sequence< ucb::CommandInfo > FTPContent::getCommands( // //================================================================= - #define COMMAND_COUNT 7 + #define COMMAND_COUNT 8 static const ucb::CommandInfo aCommandInfoTable[] = { @@ -167,10 +176,15 @@ uno::Sequence< ucb::CommandInfo > FTPContent::getCommands( ucb::CommandInfo( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete" ) ), -1, - getCppuType( static_cast< sal_Bool * >( 0 ) ) + getCppuBooleanType() + ), + ucb::CommandInfo( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), + -1, + getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) ) }; - return uno::Sequence<ucb::CommandInfo>(aCommandInfoTable,COMMAND_COUNT); + return uno::Sequence< ucb::CommandInfo >( aCommandInfoTable, COMMAND_COUNT ); } @@ -974,18 +974,6 @@ sal_Bool FTPDirectoryParser::parseUNIX ( } /* - * parseUNKNOWN. - */ -sal_Bool FTPDirectoryParser::parseUNKNOWN ( - FTPDirentry &rEntry, - const sal_Char *pBuffer, - sal_uInt32 nLength) -{ - setPath (rEntry.m_aName, pBuffer,sal_Int32 (nLength)); - return sal_True; -} - -/* * parseUNIX_isSizeField. */ sal_Bool FTPDirectoryParser::parseUNIX_isSizeField ( @@ -146,11 +146,6 @@ namespace ftp { FTPDirentry &rEntry, const sal_Char *pBuffer ); - static sal_Bool parseUNKNOWN ( - FTPDirentry &rEntry, - const sal_Char *pBuffer, - sal_uInt32 nLength); - private: @@ -56,8 +56,8 @@ FTPInputStream::FTPInputStream(FILE* tmpfl) : m_tmpfl(tmpfl ? tmpfl : tmpfile()) { fseek(m_tmpfl,0,SEEK_END); -// fpos_t pos; -// fgetpos(m_tmpfl,&pos); +// fpos_t pos; +// fgetpos(m_tmpfl,&pos); long pos = ftell(m_tmpfl); rewind(m_tmpfl); m_nLength = sal_Int64(pos); @@ -119,14 +119,17 @@ sal_Int32 SAL_CALL FTPInputStream::readBytes(Sequence< sal_Int8 >& aData, long bpos,epos; bpos = ftell(m_tmpfl); - fread(aData.getArray(),nBytesToRead,1,m_tmpfl); + if (fread(aData.getArray(),nBytesToRead,1,m_tmpfl) != 1) + throw IOException(); + epos = ftell(m_tmpfl); return sal_Int32(epos-bpos); } -sal_Int32 SAL_CALL FTPInputStream::readSomeBytes( Sequence< sal_Int8 >& aData,sal_Int32 nMaxBytesToRead ) +sal_Int32 SAL_CALL FTPInputStream::readSomeBytes( Sequence< sal_Int8 >& aData, + sal_Int32 nMaxBytesToRead ) throw( NotConnectedException, BufferSizeExceededException, IOException, @@ -101,7 +101,6 @@ bool XInteractionApproveImpl::isSelected() const } - // XInteractionDisapproveImpl XInteractionDisapproveImpl::XInteractionDisapproveImpl() @@ -156,13 +155,6 @@ void SAL_CALL XInteractionDisapproveImpl::select() } -bool XInteractionDisapproveImpl::isSelected() const -{ - return m_bSelected; -} - - - // XInteractionRequestImpl XInteractionRequestImpl::XInteractionRequestImpl(const rtl::OUString& aName) @@ -234,12 +226,6 @@ XInteractionRequestImpl::getContinuations( ) } -bool XInteractionRequestImpl::aborted() const -{ - return p2->isSelected(); -} - - bool XInteractionRequestImpl::approved() const { return p1->isSelected(); @@ -118,8 +118,6 @@ namespace ftp { virtual void SAL_CALL select() throw (com::sun::star::uno::RuntimeException); - bool isSelected() const; - private: bool m_bSelected; @@ -166,8 +164,6 @@ namespace ftp { getContinuations( ) throw (com::sun::star::uno::RuntimeException); - bool aborted() const; - bool approved() const; private: @@ -38,7 +38,7 @@ #include "com/sun/star/ucb/XCommandProcessor.hpp" #include "com/sun/star/sdbc/XRow.hpp" #include "ftpresultsetI.hxx" - +#include "ftpcontent.hxx" using namespace std; @@ -96,6 +96,10 @@ ResultSetI::ResultSetI(const Reference<XMultiServiceFactory>& xMSF, else if(Name.compareToAscii("DateCreated") == 0) xRow->appendTimestamp(seqProp[i], dirvec[n].m_aDate); + else if(Name.compareToAscii("CreatableContentsInfo") == 0) + xRow->appendObject( + seqProp[i], + makeAny(FTPContent::queryCreatableContentsInfo_Static())); else xRow->appendVoid(seqProp[i]); } @@ -163,19 +163,18 @@ void FTPURL::parse(const rtl::OUString& url) rtl::OString aIdent(url.getStr(), url.getLength(), RTL_TEXTENCODING_UTF8); - char *buffer = new char[1+aIdent.getLength()]; - - const char* p2 = aIdent.getStr(); rtl::OString lower = aIdent.toAsciiLowerCase(); if(lower.getLength() < 6 || strncmp("ftp://",lower.getStr(),6)) throw malformed_exception(); + char *buffer = new char[1+aIdent.getLength()]; + const char* p2 = aIdent.getStr(); p2 += 6; char ch; - char *p1 = buffer; // determine "username:password@host:port" + char *p1 = buffer; // determine "username:password@host:port" while((ch = *p2++) != '/' && ch) *p1++ = ch; *p1 = 0; @@ -393,7 +392,7 @@ namespace ftp { #define SET_DATA_CONTAINER \ - curl_easy_setopt(curl,CURLOPT_NOBODY,false); \ + curl_easy_setopt(curl,CURLOPT_NOBODY,false); \ MemoryContainer data; \ curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,memory_write); \ curl_easy_setopt(curl,CURLOPT_WRITEDATA,&data) @@ -590,6 +589,12 @@ rtl::OUString FTPURL::net_title() const // the client should retry after getting the correct // username + password throw curl_exception(err); +#if LIBCURL_VERSION_NUM>=0x070d01 /* 7.13.1 */ + else if(err == CURLE_LOGIN_DENIED) + // the client should retry after getting the correct + // username + password + throw curl_exception(err); +#endif else if(try_more && err == CURLE_FTP_ACCESS_DENIED) { // We were either denied access when trying to login to // an FTP server or when trying to change working directory @@ -665,8 +670,8 @@ void FTPURL::insert(bool replaceExisting,void* stream) const throw(curl_exception) { if(!replaceExisting) { -// FTPDirentry aDirentry(direntry()); -// if(aDirentry.m_nMode == INETCOREFTP_FILEMODE_UNKNOWN) +// FTPDirentry aDirentry(direntry()); +// if(aDirentry.m_nMode == INETCOREFTP_FILEMODE_UNKNOWN) // throw curl_exception(FILE_EXIST_DURING_INSERT); throw curl_exception(FILE_MIGHT_EXIST_DURING_INSERT); } // else @@ -716,8 +721,8 @@ void FTPURL::mkdir(bool ReplaceExisting) const FTPDirentry aDirentry(direntry()); if(!ReplaceExisting) { -// if(aDirentry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) -// throw curl_exception(FOLDER_EXIST_DURING_INSERT); +// if(aDirentry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) +// throw curl_exception(FOLDER_EXIST_DURING_INSERT); throw curl_exception(FOLDER_MIGHT_EXIST_DURING_INSERT); } else if(aDirentry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) slist = curl_slist_append(slist,aDel.getStr()); @@ -402,6 +402,7 @@ static util::DateTime getDateFromUnix (time_t t) uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *pInfo, const uno::Reference< lang::XMultiServiceFactory >& rSMgr, + const uno::Reference< ucb::XCommandEnvironment > & xEnv, const uno::Sequence< beans::Property >& rProperties) { rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( rSMgr ); @@ -499,6 +500,10 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo * else xRow->appendVoid( rProp ); } + else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) + { + xRow->appendObject( rProp, uno::makeAny( queryCreatableContentsInfo( xEnv ) ) ); + } #ifdef DEBUG else { @@ -520,7 +525,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( if (!pInfo) ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv); - return getPropertyValuesFromGFileInfo(pInfo, m_xSMgr, rProperties); + return getPropertyValuesFromGFileInfo(pInfo, m_xSMgr, xEnv, rProperties); } static lang::IllegalAccessException @@ -663,7 +668,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) || rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) || rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) || - rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) + rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) || + rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) { aRet[ n ] <<= getReadOnlyException( static_cast< cppu::OWeakObject * >(this) ); } @@ -944,6 +950,14 @@ uno::Any SAL_CALL Content::execute( ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv ); aRet <<= setPropertyValues( aProperties, xEnv ); } + else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) + && isFolder( xEnv ) ) + { + ucb::ContentInfo arg; + if ( !( aCommand.Argument >>= arg ) ) + ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv ); + aRet <<= createNewContent( arg ); + } else if (aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "insert" ) )) { ucb::InsertCommandArgument arg; @@ -956,8 +970,8 @@ uno::Any SAL_CALL Content::execute( sal_Bool bDeletePhysical = sal_False; aCommand.Argument >>= bDeletePhysical; - //If no delete physical, try and trashcan it, if that doesn't work go - //ahead and try and delete it anyway + //If no delete physical, try and trashcan it, if that doesn't work go + //ahead and try and delete it anyway if (!bDeletePhysical && !g_file_trash(getGFile(), NULL, NULL)) bDeletePhysical = true; @@ -1079,36 +1093,50 @@ void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Refer ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv); } -com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo() - throw( com::sun::star::uno::RuntimeException ) +uno::Sequence< ucb::ContentInfo > Content::queryCreatableContentsInfo( + const uno::Reference< ucb::XCommandEnvironment >& xEnv) + throw( uno::RuntimeException ) +{ + if ( isFolder( xEnv ) ) + { + uno::Sequence< ucb::ContentInfo > seq(2); + + // Minimum set of props we really need + uno::Sequence< beans::Property > props( 1 ); + props[0] = beans::Property( + rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< rtl::OUString* >( 0 ) ), + beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND ); + + // file + seq[0].Type = rtl::OUString::createFromAscii( GIO_FILE_TYPE ); + seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM | + ucb::ContentInfoAttribute::KIND_DOCUMENT ); + seq[0].Properties = props; + + // folder + seq[1].Type = rtl::OUString::createFromAscii( GIO_FOLDER_TYPE ); + seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER; + seq[1].Properties = props; + + return seq; + } + else + { + return uno::Sequence< ucb::ContentInfo >(); + } +} + +uno::Sequence< ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo() + throw( uno::RuntimeException ) { - uno::Sequence< ucb::ContentInfo > seq(2); - - // Minimum set of props we really need - uno::Sequence< beans::Property > props( 1 ); - props[0] = beans::Property( - rtl::OUString::createFromAscii( "Title" ), - -1, - getCppuType( static_cast< rtl::OUString* >( 0 ) ), - beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND ); - - // file - seq[0].Type = rtl::OUString::createFromAscii( GIO_FILE_TYPE ); - seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM | - ucb::ContentInfoAttribute::KIND_DOCUMENT ); - seq[0].Properties = props; - - // folder - seq[1].Type = rtl::OUString::createFromAscii( GIO_FOLDER_TYPE ); - seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER; - seq[1].Properties = props; - - return seq; + return queryCreatableContentsInfo( uno::Reference< ucb::XCommandEnvironment >() ); } -com::sun::star::uno::Reference< com::sun::star::ucb::XContent > - SAL_CALL Content::createNewContent( const com::sun::star::ucb::ContentInfo& Info ) - throw( com::sun::star::uno::RuntimeException ) +uno::Reference< ucb::XContent > + SAL_CALL Content::createNewContent( const ucb::ContentInfo& Info ) + throw( uno::RuntimeException ) { bool create_document; const char *name; @@ -1223,6 +1251,9 @@ uno::Sequence< beans::Property > Content::getProperties( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ), -1, getCppuBooleanType(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), + beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ), + -1, getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ) }; @@ -1232,7 +1263,7 @@ uno::Sequence< beans::Property > Content::getProperties( uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< ucb::XCommandEnvironment > & xEnv) { - static ucb::CommandInfo aDocumentCommandInfoTable[] = + static ucb::CommandInfo aCommandInfoTable[] = { // Required commands ucb::CommandInfo @@ -1262,11 +1293,14 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< uc // Folder Only, omitted if not a folder ucb::CommandInfo ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), - -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ) + -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ), + ucb::CommandInfo + ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), + -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) ) }; - const int nProps = sizeof (aDocumentCommandInfoTable) / sizeof (aDocumentCommandInfoTable[0]); - return uno::Sequence< ucb::CommandInfo >(aDocumentCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 1); + const int nProps = sizeof (aCommandInfoTable) / sizeof (aCommandInfoTable[0]); + return uno::Sequence< ucb::CommandInfo >(aCommandInfoTable, isFolder(xEnv) ? nProps : nProps - 2); } XTYPEPROVIDER_COMMON_IMPL( Content ); @@ -145,6 +145,7 @@ public: static com::sun::star::uno::Reference< com::sun::star::sdbc::XRow > getPropertyValuesFromGFileInfo( GFileInfo *pInfo, const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr, + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > & xEnv, const com::sun::star::uno::Sequence< com::sun::star::beans::Property >& rProperties); virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property > @@ -189,6 +190,11 @@ public: SAL_CALL createNewContent( const com::sun::star::ucb::ContentInfo& Info ) throw( com::sun::star::uno::RuntimeException ); + com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > + queryCreatableContentsInfo( + const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv) + throw( com::sun::star::uno::RuntimeException ); + GFile* getGFile(); }; @@ -240,7 +240,7 @@ uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues( sal_uInt32 nInde if ( getResult( nIndex ) ) { uno::Reference< sdbc::XRow > xRow = Content::getPropertyValuesFromGFileInfo( - maResults[ nIndex ]->pInfo, m_xSMgr, getResultSet()->getProperties()); + maResults[ nIndex ]->pInfo, m_xSMgr, getResultSet()->getEnvironment(), getResultSet()->getProperties()); maResults[ nIndex ]->xRow = xRow; return xRow; @@ -39,9 +39,7 @@ #include "osl/doublecheckedlocking.h" -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ #include <com/sun/star/beans/PropertyValue.hpp> -#endif #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertySetInfoChange.hpp> #include <com/sun/star/beans/PropertySetInfoChangeEvent.hpp> @@ -50,14 +48,10 @@ #include <com/sun/star/lang/IllegalAccessException.hpp> #include <com/sun/star/ucb/ContentInfoAttribute.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp> -#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> -#endif #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> #include <com/sun/star/ucb/InteractiveNetworkConnectException.hpp> -#ifndef _COM_SUN_STAR_UCB_INTERACTIVENETWORKGENBERALEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveNetworkGeneralException.hpp> -#endif #include <com/sun/star/ucb/InteractiveNetworkReadException.hpp> #include <com/sun/star/ucb/InteractiveNetworkResolveNameException.hpp> #include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp> @@ -79,9 +73,7 @@ #include <com/sun/star/ucb/NameClashException.hpp> #include <ucbhelper/contentidentifier.hxx> #include <ucbhelper/propertyvalueset.hxx> -#ifndef _UCBHELPER_INTERACTIONREQUEST_HXX #include <ucbhelper/interactionrequest.hxx> -#endif #include <ucbhelper/cancelcommandexecution.hxx> #include <ucbhelper/simpleauthenticationrequest.hxx> @@ -98,10 +90,10 @@ extern "C" { // missing in the header: doh. # include <libgnomevfs/gnome-vfs-module-callback.h> } -#include "content.hxx" -#include "provider.hxx" -#include "directory.hxx" -#include "stream.hxx" +#include "gvfs_content.hxx" +#include "gvfs_provider.hxx" +#include "gvfs_directory.hxx" +#include "gvfs_stream.hxx" using namespace gvfs; using namespace com::sun::star; @@ -398,6 +390,13 @@ uno::Any SAL_CALL Content::execute( g_warning ("Open falling through ..."); #endif + } else if ( COMMAND_IS( aCommand, "createNewContent" ) && isFolder( xEnv ) ) { + ucb::ContentInfo arg; + if ( !( aCommand.Argument >>= arg ) ) + ucbhelper::cancelCommandExecution ( getBadArgExcept (), xEnv ); + + aRet <<= createNewContent( arg ); + } else if ( COMMAND_IS( aCommand, "insert" ) ) { ucb::InsertCommandArgument arg; if ( !( aCommand.Argument >>= arg ) ) @@ -452,32 +451,45 @@ void SAL_CALL Content::abort( sal_Int32 /*CommandId*/ ) // XContentCreator methods. // -uno::Sequence< ucb::ContentInfo > SAL_CALL -Content::queryCreatableContentsInfo() - throw( uno::RuntimeException ) +uno::Sequence< ucb::ContentInfo > Content::queryCreatableContentsInfo( + const uno::Reference< ucb::XCommandEnvironment >& xEnv) + throw( uno::RuntimeException ) { - uno::Sequence< ucb::ContentInfo > seq(2); - - // Minimum set of props we really need - uno::Sequence< beans::Property > props( 1 ); - props[0] = beans::Property( - rtl::OUString::createFromAscii( "Title" ), - -1, - getCppuType( static_cast< rtl::OUString* >( 0 ) ), - beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND ); - - // file - seq[0].Type = rtl::OUString::createFromAscii( GVFS_FILE_TYPE ); - seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM | - ucb::ContentInfoAttribute::KIND_DOCUMENT ); - seq[0].Properties = props; - - // folder - seq[1].Type = rtl::OUString::createFromAscii( GVFS_FOLDER_TYPE ); - seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER; - seq[1].Properties = props; - - return seq; + if ( isFolder( xEnv ) ) + { + uno::Sequence< ucb::ContentInfo > seq(2); + + // Minimum set of props we really need + uno::Sequence< beans::Property > props( 1 ); + props[0] = beans::Property( + rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< rtl::OUString* >( 0 ) ), + beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::BOUND ); + + // file + seq[0].Type = rtl::OUString::createFromAscii( GVFS_FILE_TYPE ); + seq[0].Attributes = ( ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM | + ucb::ContentInfoAttribute::KIND_DOCUMENT ); + seq[0].Properties = props; + + // folder + seq[1].Type = rtl::OUString::createFromAscii( GVFS_FOLDER_TYPE ); + seq[1].Attributes = ucb::ContentInfoAttribute::KIND_FOLDER; + seq[1].Properties = props; + + return seq; + } + else + { + return uno::Sequence< ucb::ContentInfo >(); + } +} + +uno::Sequence< ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo() + throw( uno::RuntimeException ) +{ + return queryCreatableContentsInfo( uno::Reference< ucb::XCommandEnvironment >() ); } uno::Reference< ucb::XContent > SAL_CALL @@ -487,7 +499,7 @@ Content::createNewContent( const ucb::ContentInfo& Info ) bool create_document; const char *name; - if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( GVFS_FILE_TYPE ) ) ) + if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( GVFS_FILE_TYPE ) ) ) create_document = true; else if ( Info.Type.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( GVFS_FOLDER_TYPE ) ) ) create_document = false; @@ -515,11 +527,11 @@ Content::createNewContent( const ucb::ContentInfo& Info ) uno::Reference< ucb::XContentIdentifier > xId ( new ::ucbhelper::ContentIdentifier( m_xSMgr, aURL ) ); - try { + try { return new ::gvfs::Content( m_xSMgr, m_pProvider, xId, !create_document ); } catch ( ucb::ContentCreationException & ) { return uno::Reference< ucb::XContent >(); - } + } } rtl::OUString Content::getParentURL() @@ -676,7 +688,10 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( g_warning ("FIXME: Requested mime-type - an expensive op. indeed!"); #endif xRow->appendVoid( rProp ); - } else { + } else if (rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) + xRow->appendObject( rProp, uno::makeAny( queryCreatableContentsInfo( xEnv ) ) ); + + else { xRow->appendVoid( rProp ); } } @@ -757,7 +772,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( getInfo( xEnv ); - osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); gnome_vfs_file_info_copy( &newInfo, &m_info ); @@ -769,16 +784,16 @@ uno::Sequence< uno::Any > Content::setPropertyValues( beans::PropertyChangeEvent aEvent; aEvent.Source = static_cast< cppu::OWeakObject * >( this ); - aEvent.Further = sal_False; - aEvent.PropertyHandle = -1; - // aEvent.PropertyName = fill in later ... - // aEvent.OldValue = - // aEvent.NewValue = + aEvent.Further = sal_False; + aEvent.PropertyHandle = -1; + // aEvent.PropertyName = fill in later ... + // aEvent.OldValue = + // aEvent.NewValue = - int nCount = rValues.getLength(); + int nCount = rValues.getLength(); const beans::PropertyValue* pValues = rValues.getConstArray(); - for ( sal_Int32 n = 0; n < nCount; ++n ) { + for ( sal_Int32 n = 0; n < nCount; ++n ) { const beans::PropertyValue& rValue = pValues[ n ]; #ifdef DEBUG @@ -788,7 +803,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) || rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsDocument" ) ) || rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsFolder" ) ) || - rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) ) + rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) || + rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) aRet[ n ] <<= getReadOnlyException( this ); else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { @@ -919,7 +935,7 @@ void Content::insert( const uno::Reference< ucb::XCommandEnvironment > &xEnv ) throw( uno::Exception ) { - osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); + osl::ClearableGuard< osl::Mutex > aGuard( m_aMutex ); #ifdef DEBUG g_warning( "Insert '%s' (%d) (0x%x:%d)", getURI(), bReplaceExisting, @@ -1004,9 +1020,9 @@ void Content::insert( } if (m_bTransient) { - m_bTransient = sal_False; + m_bTransient = sal_False; aGuard.clear(); - inserted(); + inserted(); } } @@ -1319,8 +1335,8 @@ uno::Sequence< beans::Property > Content::getProperties( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), // FIXME: Too expensive for now (?) // beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), -// -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ), -// beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), +// -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ), +// beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ), -1, getCppuType( static_cast< const sal_Int64 * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), @@ -1335,6 +1351,9 @@ uno::Sequence< beans::Property > Content::getProperties( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsHidden" ) ), -1, getCppuBooleanType(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), + beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreatableContentsInfo" ) ), + -1, getCppuType( static_cast< const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ) }; @@ -1347,7 +1366,7 @@ uno::Sequence< beans::Property > Content::getProperties( uno::Sequence< ucb::CommandInfo > Content::getCommands( const uno::Reference< ucb::XCommandEnvironment > & xEnv ) { - static ucb::CommandInfo aDocumentCommandInfoTable[] = { + static ucb::CommandInfo aCommandInfoTable[] = { // Required commands ucb::CommandInfo ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCommandInfo" ) ), @@ -1373,17 +1392,19 @@ uno::Sequence< ucb::CommandInfo > Content::getCommands( ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "open" ) ), -1, getCppuType( static_cast<ucb::OpenCommandArgument2 * >( 0 ) ) ), - // Folder only + // Folder Only, omitted if not a folder ucb::CommandInfo ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), - -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ) + -1, getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ), + ucb::CommandInfo + ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), + -1, getCppuType( static_cast<ucb::ContentInfo * >( 0 ) ) ) }; - int num = 7; - - if ( isFolder( xEnv ) ) - num += 1; - return uno::Sequence< ucb::CommandInfo >(aDocumentCommandInfoTable, num ); + const int nProps + = sizeof( aCommandInfoTable ) / sizeof( aCommandInfoTable[ 0 ] ); + return uno::Sequence< ucb::CommandInfo >( + aCommandInfoTable, isFolder( xEnv ) ? nProps : nProps - 2 ); } rtl::OUString @@ -82,11 +82,11 @@ class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator { //========================================================================= -// Internals +// Internals //========================================================================= private: typedef rtl::Reference< Content > ContentRef; - typedef std::list< ContentRef > ContentRefList; + typedef std::list< ContentRef > ContentRefList; // Instance data ContentProvider *m_pProvider; // No need for a ref, base class holds object @@ -98,7 +98,7 @@ private: ::com::sun::star::uno::Any getBadArgExcept (); GnomeVFSResult getInfo ( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); - sal_Bool isFolder ( const ::com::sun::star::uno::Reference< + sal_Bool isFolder ( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); sal_Bool exchangeIdentity( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& xNewId); @@ -110,7 +110,7 @@ private: // End Internal helpers // For ucbhelper - virtual ::rtl::OUString getParentURL(); + virtual ::rtl::OUString getParentURL(); // For ucbhelper virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property > getProperties( const com::sun::star::uno::Reference< @@ -122,8 +122,8 @@ private: public: // Command "getPropertyValues" - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > - getPropertyValues( const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > + getPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rProperties, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); @@ -136,22 +136,22 @@ private: const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >& xEnv ); - // Command "insert" - void insert( const ::com::sun::star::uno::Reference< + // Command "insert" + void insert( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > & xInputStream, - sal_Bool bReplaceExisting, - const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& xEnv ) + sal_Bool bReplaceExisting, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( ::com::sun::star::uno::Exception ); // Command "transfer" void transfer( const ::com::sun::star::ucb::TransferInfo & rArgs, const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& xEnv ) + com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( ::com::sun::star::uno::Exception ); // Command "delete" - void destroy( sal_Bool bDeletePhysical ) + void destroy( sal_Bool bDeletePhysical ) throw( ::com::sun::star::uno::Exception ); // "open" helpers @@ -170,12 +170,12 @@ private: createInputStream( const ::com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( ::com::sun::star::uno::Exception ); - sal_Bool feedSink( ::com::sun::star::uno::Reference< + sal_Bool feedSink( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> aSink, const ::com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ); - ::com::sun::star::uno::Any mapVFSException( const GnomeVFSResult result, + ::com::sun::star::uno::Any mapVFSException( const GnomeVFSResult result, sal_Bool bWrite ); void cancelCommandExecution(const GnomeVFSResult result, @@ -192,27 +192,27 @@ public: rtl::OUString getOUURI (); //========================================================================= -// Externals +// Externals //========================================================================= public: - Content( const ::com::sun::star::uno::Reference< + Content( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier) throw ( ::com::sun::star::ucb::ContentCreationException ); - Content( const ::com::sun::star::uno::Reference< + Content( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxSMgr, ContentProvider *pProvider, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentIdentifier >& Identifier, sal_Bool isFolder) throw ( ::com::sun::star::ucb::ContentCreationException ); - virtual ~Content(); + virtual ~Content(); - // XInterface - XINTERFACE_DECL() + // XInterface + XINTERFACE_DECL() // XTypeProvider XTYPEPROVIDER_DECL() @@ -220,40 +220,47 @@ public: // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL - getSupportedServiceNames() + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); - // XContent - virtual rtl::OUString SAL_CALL - getContentType() + // XContent + virtual rtl::OUString SAL_CALL + getContentType() throw( com::sun::star::uno::RuntimeException ); - // XCommandProcessor - virtual com::sun::star::uno::Any SAL_CALL - execute( const com::sun::star::ucb::Command& aCommand, + // XCommandProcessor + virtual com::sun::star::uno::Any SAL_CALL + execute( const com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& xEnv ) throw( com::sun::star::uno::Exception, com::sun::star::ucb::CommandAbortedException, com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL - abort( sal_Int32 CommandId ) + virtual void SAL_CALL + abort( sal_Int32 CommandId ) throw( com::sun::star::uno::RuntimeException ); - ////////////////////////////////////////////////////////////////////// - // Additional interfaces - ////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// + // Additional interfaces + ////////////////////////////////////////////////////////////////////// - // XContentCreator + // XContentCreator virtual com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > SAL_CALL - queryCreatableContentsInfo() + queryCreatableContentsInfo() + throw( com::sun::star::uno::RuntimeException ); + virtual com::sun::star::uno::Reference< + com::sun::star::ucb::XContent > SAL_CALL + createNewContent( const com::sun::star::ucb::ContentInfo& Info ) throw( com::sun::star::uno::RuntimeException ); - virtual com::sun::star::uno::Reference< - com::sun::star::ucb::XContent > SAL_CALL - createNewContent( const com::sun::star::ucb::ContentInfo& Info ) + + + com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > + queryCreatableContentsInfo( + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment >& xEnv) throw( com::sun::star::uno::RuntimeException ); }; @@ -40,7 +40,7 @@ #include <ucbhelper/contentidentifier.hxx> #include <ucbhelper/providerhelper.hxx> -#include "directory.hxx" +#include "gvfs_directory.hxx" #include <libgnomevfs/gnome-vfs-utils.h> #include <libgnomevfs/gnome-vfs-directory.h> @@ -96,7 +96,7 @@ struct ResultListEntry gnome_vfs_file_info_copy (&aInfo, fileInfo); } - ~ResultListEntry() + ~ResultListEntry() { gnome_vfs_file_info_clear (&aInfo); } @@ -33,7 +33,7 @@ #include <rtl/ref.hxx> #include <ucbhelper/resultset.hxx> #include <ucbhelper/resultsethelper.hxx> -#include "content.hxx" +#include "gvfs_content.hxx" namespace gvfs { @@ -44,11 +44,11 @@ class DynamicResultSet : public ::ucbhelper::ResultSetImplHelper com::sun::star::ucb::XCommandEnvironment > m_xEnv; private: - virtual void initStatic(); - virtual void initDynamic(); + virtual void initStatic(); + virtual void initDynamic(); public: - DynamicResultSet( const com::sun::star::uno::Reference< + DynamicResultSet( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSMgr, const rtl::Reference< Content >& rxContent, const com::sun::star::ucb::OpenCommandArgument2& rCommand, @@ -33,8 +33,8 @@ #include <ucbhelper/contentidentifier.hxx> #include <libgnomevfs/gnome-vfs-init.h> -#include "provider.hxx" -#include "content.hxx" +#include "gvfs_provider.hxx" +#include "gvfs_content.hxx" using namespace com::sun::star; using namespace gvfs; @@ -30,7 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_ucb.hxx" -#include "stream.hxx" +#include "gvfs_stream.hxx" #include <rtl/memory.h> #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp> @@ -187,9 +187,9 @@ sal_Int32 SAL_CALL Stream::available( ) } void SAL_CALL Stream::closeInput( void ) - throw( NotConnectedException, - IOException, - RuntimeException ) + throw( NotConnectedException, + IOException, + RuntimeException ) { osl::MutexGuard aGuard( m_aMutex ); m_bInputStreamCalled = false; @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -62,10 +62,10 @@ PKGCONFIG_LIBS!:=-Wl,--export-dynamic $(PKGCONFIG_LIBS:s/ -llinc//:s/ -lbonobo-a DLLPRE = SLOFILES=\ - $(SLO)$/content.obj \ - $(SLO)$/directory.obj \ - $(SLO)$/stream.obj \ - $(SLO)$/provider.obj + $(SLO)$/gvfs_content.obj \ + $(SLO)$/gvfs_directory.obj \ + $(SLO)$/gvfs_stream.obj \ + $(SLO)$/gvfs_provider.obj SHL1NOCHECK=TRUE SHL1TARGET=$(TARGET)$(UCPGVFS_MAJOR).uno @@ -41,7 +41,7 @@ ************************************************************************** - Root Folder vs. 'normal' Folder - - root doesn't support command 'delete' + - root doesn't support command 'delete' - root doesn't support command 'insert' - root needs not created via XContentCreator - queryContent with root folder id ( HIERARCHY_ROOT_FOLDER_URL ) always returns a value != 0 @@ -457,8 +457,8 @@ uno::Any SAL_CALL HierarchyContent::execute( aRet <<= getCommandInfo( Environment ); } - else if ( isFolder() && aCommand.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "open" ) ) ) + else if ( aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "open" ) ) && isFolder() ) { ////////////////////////////////////////////////////////////////// // open command for a folder content @@ -481,9 +481,9 @@ uno::Any SAL_CALL HierarchyContent::execute( = new DynamicResultSet( m_xSMgr, this, aOpenCommand ); aRet <<= xSet; } - else if ( ( m_eKind != ROOT ) && !isReadOnly() && - aCommand.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "insert" ) ) ) + else if ( aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "insert" ) ) && + ( m_eKind != ROOT ) && !isReadOnly() ) { ////////////////////////////////////////////////////////////////// // insert @@ -508,9 +508,9 @@ uno::Any SAL_CALL HierarchyContent::execute( : ucb::NameClash::ERROR; insert( nNameClash, Environment ); } - else if ( ( m_eKind != ROOT ) && !isReadOnly() && - aCommand.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "delete" ) ) ) + else if ( aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "delete" ) ) && + ( m_eKind != ROOT ) && !isReadOnly() ) { ////////////////////////////////////////////////////////////////// // delete @@ -546,13 +546,13 @@ uno::Any SAL_CALL HierarchyContent::execute( // Remove own and all children's Additional Core Properties. removeAdditionalPropertySet( sal_True ); } - else if ( isFolder() && !isReadOnly() && - aCommand.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) ) + else if ( aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "transfer" ) ) && + isFolder() && !isReadOnly() ) { ////////////////////////////////////////////////////////////////// // transfer - // ( Not available at link objects ) + // ( Not available at link objects ) ////////////////////////////////////////////////////////////////// ucb::TransferInfo aInfo; @@ -571,6 +571,31 @@ uno::Any SAL_CALL HierarchyContent::execute( transfer( aInfo, Environment ); } + else if ( aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) && + isFolder() && !isReadOnly() ) + { + ////////////////////////////////////////////////////////////////// + // createNewContent + // ( Not available at link objects ) + ////////////////////////////////////////////////////////////////// + + ucb::ContentInfo aInfo; + if ( !( aCommand.Argument >>= aInfo ) ) + { + OSL_ENSURE( sal_False, "Wrong argument type!" ); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable + } + + aRet <<= createNewContent( aInfo ); + } else { ////////////////////////////////////////////////////////////////// @@ -607,54 +632,7 @@ uno::Sequence< ucb::ContentInfo > SAL_CALL HierarchyContent::queryCreatableContentsInfo() throw( uno::RuntimeException ) { - if ( isFolder() ) - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - - uno::Sequence< ucb::ContentInfo > aSeq( 2 ); - - // Folder. - aSeq.getArray()[ 0 ].Type - = rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE ); - aSeq.getArray()[ 0 ].Attributes - = ucb::ContentInfoAttribute::KIND_FOLDER; - - uno::Sequence< beans::Property > aFolderProps( 1 ); - aFolderProps.getArray()[ 0 ] = beans::Property( - rtl::OUString::createFromAscii( "Title" ), - -1, - getCppuType( static_cast< const rtl::OUString * >( 0 ) ), - beans::PropertyAttribute::BOUND ); - aSeq.getArray()[ 0 ].Properties = aFolderProps; - - // Link. - aSeq.getArray()[ 1 ].Type - = rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ); - aSeq.getArray()[ 1 ].Attributes - = ucb::ContentInfoAttribute::KIND_LINK; - - uno::Sequence< beans::Property > aLinkProps( 2 ); - aLinkProps.getArray()[ 0 ] = beans::Property( - rtl::OUString::createFromAscii( "Title" ), - -1, - getCppuType( static_cast< const rtl::OUString * >( 0 ) ), - beans::PropertyAttribute::BOUND ); - aLinkProps.getArray()[ 1 ] = beans::Property( - rtl::OUString::createFromAscii( "TargetURL" ), - -1, - getCppuType( static_cast< const rtl::OUString * >( 0 ) ), - beans::PropertyAttribute::BOUND ); - aSeq.getArray()[ 1 ].Properties = aLinkProps; - - return aSeq; - } - else - { - OSL_ENSURE( sal_False, - "queryCreatableContentsInfo called on non-folder object!" ); - - return uno::Sequence< ucb::ContentInfo >( 0 ); - } + return m_aProps.getCreatableContentsInfo(); } //========================================================================= @@ -1026,7 +1004,7 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues( xRow->appendString ( rProp, rData.getContentType() ); } else if ( rProp.Name.equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) + RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { xRow->appendString ( rProp, rData.getTitle() ); } @@ -1041,6 +1019,12 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues( xRow->appendBoolean( rProp, rData.getIsFolder() ); } else if ( rProp.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) + { + xRow->appendObject( + rProp, uno::makeAny( rData.getCreatableContentsInfo() ) ); + } + else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "TargetURL" ) ) ) { // TargetURL is only supported by links. @@ -1123,6 +1107,15 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues( // @@@ Might actually be read-only! beans::PropertyAttribute::BOUND ), rData.getTargetURL() ); + xRow->appendObject( + beans::Property( + rtl::OUString::createFromAscii( "CreatableContentsInfo" ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ), + uno::makeAny( rData.getCreatableContentsInfo() ) ); // Append all Additional Core Properties. @@ -1162,10 +1155,10 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( beans::PropertyChangeEvent aEvent; aEvent.Source = static_cast< cppu::OWeakObject * >( this ); aEvent.Further = sal_False; -// aEvent.PropertyName = +// aEvent.PropertyName = aEvent.PropertyHandle = -1; -// aEvent.OldValue = -// aEvent.NewValue = +// aEvent.OldValue = +// aEvent.NewValue = const beans::PropertyValue* pValues = rValues.getConstArray(); sal_Int32 nCount = rValues.getLength(); @@ -1210,6 +1203,15 @@ uno::Sequence< uno::Any > HierarchyContent::setPropertyValues( static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) + { + // Read-only property! + aRet[ n ] <<= lang::IllegalAccessException( + rtl::OUString::createFromAscii( + "Property is read-only!" ), + static_cast< cppu::OWeakObject * >( this ) ); + } + else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { if ( isReadOnly() ) @@ -1953,3 +1955,58 @@ void HierarchyContent::transfer( } } +//========================================================================= +//========================================================================= +// +// HierarchyContentProperties Implementation. +// +//========================================================================= +//========================================================================= + +uno::Sequence< ucb::ContentInfo > +HierarchyContentProperties::getCreatableContentsInfo() const +{ + if ( getIsFolder() ) + { + uno::Sequence< ucb::ContentInfo > aSeq( 2 ); + + // Folder. + aSeq.getArray()[ 0 ].Type + = rtl::OUString::createFromAscii( HIERARCHY_FOLDER_CONTENT_TYPE ); + aSeq.getArray()[ 0 ].Attributes + = ucb::ContentInfoAttribute::KIND_FOLDER; + + uno::Sequence< beans::Property > aFolderProps( 1 ); + aFolderProps.getArray()[ 0 ] = beans::Property( + rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ); + aSeq.getArray()[ 0 ].Properties = aFolderProps; + + // Link. + aSeq.getArray()[ 1 ].Type + = rtl::OUString::createFromAscii( HIERARCHY_LINK_CONTENT_TYPE ); + aSeq.getArray()[ 1 ].Attributes + = ucb::ContentInfoAttribute::KIND_LINK; + + uno::Sequence< beans::Property > aLinkProps( 2 ); + aLinkProps.getArray()[ 0 ] = beans::Property( + rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ); + aLinkProps.getArray()[ 1 ] = beans::Property( + rtl::OUString::createFromAscii( "TargetURL" ), + -1, + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ); + aSeq.getArray()[ 1 ].Properties = aLinkProps; + + return aSeq; + } + else + { + return uno::Sequence< ucb::ContentInfo >( 0 ); + } +} @@ -101,6 +101,9 @@ public: sal_Bool getIsDocument() const { return !getIsFolder(); } + com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > + getCreatableContentsInfo() const; + const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; } private: @@ -117,7 +120,7 @@ class HierarchyContent : public ::ucbhelper::ContentImplHelper, { enum ContentKind { LINK, FOLDER, ROOT }; enum ContentState { TRANSIENT, // created via CreateNewContent, - // but did not process "insert" yet + // but did not process "insert" yet PERSISTENT, // processed "insert" DEAD // processed "delete" }; @@ -198,7 +201,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow > getPropertyValues( const ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::Property >& rProperties ); + ::com::sun::star::beans::Property >& rProperties ); ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > setPropertyValues( const ::com::sun::star::uno::Sequence< @@ -270,7 +273,7 @@ public: execute( const com::sun::star::ucb::Command& aCommand, sal_Int32 CommandId, const com::sun::star::uno::Reference< - com::sun::star::ucb::XCommandEnvironment >& Environment ) + com::sun::star::ucb::XCommandEnvironment >& Environment ) throw( com::sun::star::uno::Exception, com::sun::star::ucb::CommandAbortedException, com::sun::star::uno::RuntimeException ); @@ -300,7 +303,7 @@ public: getPropertyValues( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr, const ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::Property >& rProperties, + ::com::sun::star::beans::Property >& rProperties, const HierarchyContentProperties& rData, HierarchyContentProvider* pProvider, const ::rtl::OUString& rContentId ); @@ -39,25 +39,28 @@ Props/Commands: - root folder folder link link - (new) (new) + root folder folder link link + (new) (new) ---------------------------------------------------------------- - ContentType x x x x x - IsDocument x x x x x - IsFolder x x x x x - Title x x x x x - TargetURL x x + ContentType x x x x x + IsDocument x x x x x + IsFolder x x x x x + Title x x x x x + TargetURL x x + CreatableContentsInfo x x x x x - getCommandInfo x x x x x - getPropertySetInfo x x x x x - getPropertyValues x x x x x - setPropertyValues x x x x x - insert x x - delete x x - open x x - transfer x x + getCommandInfo x x x x x + getPropertySetInfo x x x x x + getPropertyValues x x x x x + setPropertyValues x x x x x + createNewContent x x + insert x x + delete x x + open x x + transfer x x *************************************************************************/ + #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -76,6 +79,12 @@ using namespace hierarchy_ucp; // //========================================================================= +#define MAKEPROPSEQUENCE( a ) \ + uno::Sequence< beans::Property >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + +#define MAKECMDSEQUENCE( a ) \ + uno::Sequence< ucb::CommandInfo >( a, sizeof( a ) / sizeof( a[ 0 ] ) ) + //========================================================================= // // IMPORTENT: If any property data ( name / type / ... ) are changed, then @@ -143,13 +152,20 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties( getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY - ) + ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "CreatableContentsInfo" ) ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) /////////////////////////////////////////////////////////// // New properties /////////////////////////////////////////////////////////// }; - return uno::Sequence< - beans::Property >( aLinkPropertyInfoTable, 5 ); + return MAKEPROPSEQUENCE( aLinkPropertyInfoTable ); } else { @@ -195,13 +211,20 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties( -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND - ) + ), + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "CreatableContentsInfo" ) ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) /////////////////////////////////////////////////////////// // New properties /////////////////////////////////////////////////////////// }; - return uno::Sequence< - beans::Property >( aLinkPropertyInfoTable, 5 ); + return MAKEPROPSEQUENCE( aLinkPropertyInfoTable ); } } else if ( m_eKind == FOLDER ) @@ -248,16 +271,23 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties( getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY - ) + ), /////////////////////////////////////////////////////////// // Optional standard properties /////////////////////////////////////////////////////////// + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "CreatableContentsInfo" ) ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) /////////////////////////////////////////////////////////// // New properties /////////////////////////////////////////////////////////// }; - return uno::Sequence< - beans::Property >( aFolderPropertyInfoTable, 4 ); + return MAKEPROPSEQUENCE( aFolderPropertyInfoTable ); } else { @@ -294,16 +324,23 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties( -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND - ) + ), /////////////////////////////////////////////////////////// // Optional standard properties /////////////////////////////////////////////////////////// + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "CreatableContentsInfo" ) ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) /////////////////////////////////////////////////////////// // New properties /////////////////////////////////////////////////////////// }; - return uno::Sequence< - beans::Property >( aFolderPropertyInfoTable, 4 ); + return MAKEPROPSEQUENCE( aFolderPropertyInfoTable ); } } else @@ -314,6 +351,9 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties( // //================================================================= + // Currently no difference between reonly /read-write + // -> all props ar read-only + static beans::Property aRootFolderPropertyInfoTable[] = { /////////////////////////////////////////////////////////////// @@ -346,16 +386,23 @@ uno::Sequence< beans::Property > HierarchyContent::getProperties( getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY - ) + ), /////////////////////////////////////////////////////////////// // Optional standard properties /////////////////////////////////////////////////////////////// + beans::Property( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "CreatableContentsInfo" ) ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ) /////////////////////////////////////////////////////////////// // New properties /////////////////////////////////////////////////////////////// }; - return uno::Sequence< - beans::Property >( aRootFolderPropertyInfoTable, 4 ); + return MAKEPROPSEQUENCE( aRootFolderPropertyInfoTable ); } } @@ -416,8 +463,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands( // New commands /////////////////////////////////////////////////////////// }; - return uno::Sequence< - ucb::CommandInfo >( aLinkCommandInfoTable, 4 ); + return MAKECMDSEQUENCE( aLinkCommandInfoTable ); } else { @@ -470,8 +516,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands( // New commands /////////////////////////////////////////////////////////// }; - return uno::Sequence< - ucb::CommandInfo >( aLinkCommandInfoTable, 6 ); + return MAKECMDSEQUENCE( aLinkCommandInfoTable ); } } else if ( m_eKind == FOLDER ) @@ -529,8 +574,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands( // New commands /////////////////////////////////////////////////////////// }; - return uno::Sequence< - ucb::CommandInfo >( aFolderCommandInfoTable, 5 ); + return MAKECMDSEQUENCE( aFolderCommandInfoTable ); } else { @@ -589,13 +633,18 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), -1, getCppuType( static_cast< ucb::TransferInfo * >( 0 ) ) + ), + ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), + -1, + getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) ) /////////////////////////////////////////////////////////// // New commands /////////////////////////////////////////////////////////// }; - return uno::Sequence< - ucb::CommandInfo >( aFolderCommandInfoTable, 8 ); + return MAKECMDSEQUENCE( aFolderCommandInfoTable ); } } else @@ -653,8 +702,7 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands( // New commands /////////////////////////////////////////////////////////// }; - return uno::Sequence< - ucb::CommandInfo >( aRootFolderCommandInfoTable, 5 ); + return MAKECMDSEQUENCE( aRootFolderCommandInfoTable ); } else { @@ -703,13 +751,18 @@ uno::Sequence< ucb::CommandInfo > HierarchyContent::getCommands( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "transfer" ) ), -1, getCppuType( static_cast< ucb::TransferInfo * >( 0 ) ) + ), + ucb::CommandInfo( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "createNewContent" ) ), + -1, + getCppuType( static_cast< ucb::ContentInfo * >( 0 ) ) ) /////////////////////////////////////////////////////////// // New commands /////////////////////////////////////////////////////////// }; - return uno::Sequence< - ucb::CommandInfo >( aRootFolderCommandInfoTable, 6 ); + return MAKECMDSEQUENCE( aRootFolderCommandInfoTable ); } } } @@ -55,9 +55,7 @@ #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/ucb/ContentInfoAttribute.hpp> #include <com/sun/star/ucb/InsertCommandArgument.hpp> -#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> -#endif #include <com/sun/star/ucb/MissingInputStreamException.hpp> #include <com/sun/star/ucb/NameClash.hpp> #include <com/sun/star/ucb/NameClashException.hpp> @@ -105,17 +103,60 @@ ContentProperties::ContentProperties( const rtl::OUString& rContentType ) bEncrypted( sal_False ), bHasEncryptedEntries( sal_False ) { - bIsFolder = rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_FOLDER_CONTENT_TYPE ) ) - || rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_FOLDER_CONTENT_TYPE ) ); + bIsFolder = rContentType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( PACKAGE_FOLDER_CONTENT_TYPE ) ) + || rContentType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_FOLDER_CONTENT_TYPE ) ); bIsDocument = !bIsFolder; OSL_ENSURE( bIsFolder || - rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_STREAM_CONTENT_TYPE ) ) || - rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_STREAM_CONTENT_TYPE ) ), + rContentType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( PACKAGE_STREAM_CONTENT_TYPE ) ) + || rContentType.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( PACKAGE_ZIP_STREAM_CONTENT_TYPE ) ), "ContentProperties::ContentProperties - Unknown type!" ); } //========================================================================= + +uno::Sequence< ucb::ContentInfo > +ContentProperties::getCreatableContentsInfo( PackageUri const & rUri ) const +{ + if ( bIsFolder ) + { + uno::Sequence< beans::Property > aProps( 1 ); + aProps.getArray()[ 0 ] = beans::Property( + rtl::OUString::createFromAscii( "Title" ), + -1, + getCppuType( static_cast< const rtl::OUString * >( 0 ) ), + beans::PropertyAttribute::BOUND ); + + uno::Sequence< ucb::ContentInfo > aSeq( 2 ); + + // Folder. + aSeq.getArray()[ 0 ].Type + = Content::getContentType( rUri.getScheme(), sal_True ); + aSeq.getArray()[ 0 ].Attributes + = ucb::ContentInfoAttribute::KIND_FOLDER; + aSeq.getArray()[ 0 ].Properties = aProps; + + // Stream. + aSeq.getArray()[ 1 ].Type + = Content::getContentType( rUri.getScheme(), sal_False ); + aSeq.getArray()[ 1 ].Attributes + = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM + | ucb::ContentInfoAttribute::KIND_DOCUMENT; + aSeq.getArray()[ 1 ].Properties = aProps; + + return aSeq; + } + else + { + return uno::Sequence< ucb::ContentInfo >( 0 ); + } +} + +//========================================================================= //========================================================================= // // Content Implementation. @@ -166,9 +207,9 @@ Content* Content::create( ucb::ContentInfo aInfo; if ( bFolder || aURI.isRootFolder() ) - aInfo.Type = GetContentType( aURI.getScheme(), sal_True ); + aInfo.Type = getContentType( aURI.getScheme(), sal_True ); else - aInfo.Type = GetContentType( aURI.getScheme(), sal_False ); + aInfo.Type = getContentType( aURI.getScheme(), sal_False ); return new Content( rxSMgr, pProvider, xId, xPackage, aURI, aInfo ); } @@ -188,9 +229,9 @@ Content* Content::create( PackageUri aURI( Identifier->getContentIdentifier() ); if ( !Info.Type.equalsIgnoreAsciiCase( - GetContentType( aURI.getScheme(), sal_True ) ) && + getContentType( aURI.getScheme(), sal_True ) ) && !Info.Type.equalsIgnoreAsciiCase( - GetContentType( aURI.getScheme(), sal_False ) ) ) + getContentType( aURI.getScheme(), sal_False ) ) ) return 0; uno::Reference< container::XHierarchicalNameAccess > xPackage; @@ -210,7 +251,7 @@ Content* Content::create( //========================================================================= // static -::rtl::OUString Content::GetContentType( +::rtl::OUString Content::getContentType( const ::rtl::OUString& aScheme, sal_Bool bFolder ) { return ( rtl::OUString::createFromAscii( "application/" ) @@ -294,7 +335,7 @@ uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType ) aRet = cppu::queryInterface( rType, static_cast< ucb::XContentCreator * >( this ) ); - return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType ); + return aRet.hasValue() ? aRet : ContentImplHelper::queryInterface( rType ); } //========================================================================= @@ -609,7 +650,7 @@ uno::Any SAL_CALL Content::execute( { ////////////////////////////////////////////////////////////////// // transfer - // ( Not available at stream objects ) + // ( Not available at stream objects ) ////////////////////////////////////////////////////////////////// ucb::TransferInfo aInfo; @@ -628,11 +669,36 @@ uno::Any SAL_CALL Content::execute( transfer( aInfo, Environment ); } else if ( aCommand.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "createNewContent" ) ) && + isFolder() ) + { + ////////////////////////////////////////////////////////////////// + // createNewContent + // ( Not available at stream objects ) + ////////////////////////////////////////////////////////////////// + + ucb::ContentInfo aInfo; + if ( !( aCommand.Argument >>= aInfo ) ) + { + OSL_ENSURE( sal_False, "Wrong argument type!" ); + ucbhelper::cancelCommandExecution( + uno::makeAny( lang::IllegalArgumentException( + rtl::OUString::createFromAscii( + "Wrong argument type!" ), + static_cast< cppu::OWeakObject * >( this ), + -1 ) ), + Environment ); + // Unreachable + } + + aRet <<= createNewContent( aInfo ); + } + else if ( aCommand.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "flush" ) ) ) { ////////////////////////////////////////////////////////////////// // flush - // ( Not available at stream objects ) + // ( Not available at stream objects ) ////////////////////////////////////////////////////////////////// if( !flushData() ) @@ -693,43 +759,7 @@ uno::Sequence< ucb::ContentInfo > SAL_CALL Content::queryCreatableContentsInfo() throw( uno::RuntimeException ) { - if ( isFolder() ) - { - osl::Guard< osl::Mutex > aGuard( m_aMutex ); - - uno::Sequence< beans::Property > aProps( 1 ); - aProps.getArray()[ 0 ] = beans::Property( - rtl::OUString::createFromAscii( "Title" ), - -1, - getCppuType( static_cast< const rtl::OUString * >( 0 ) ), - beans::PropertyAttribute::BOUND ); - - uno::Sequence< ucb::ContentInfo > aSeq( 2 ); - - // Folder. - aSeq.getArray()[ 0 ].Type - = GetContentType( m_aUri.getScheme(), sal_True ); - aSeq.getArray()[ 0 ].Attributes - = ucb::ContentInfoAttribute::KIND_FOLDER; - aSeq.getArray()[ 0 ].Properties = aProps; - - // Stream. - aSeq.getArray()[ 1 ].Type - = GetContentType( m_aUri.getScheme(), sal_False ); - aSeq.getArray()[ 1 ].Attributes - = ucb::ContentInfoAttribute::INSERT_WITH_INPUTSTREAM - | ucb::ContentInfoAttribute::KIND_DOCUMENT; - aSeq.getArray()[ 1 ].Properties = aProps; - - return aSeq; - } - else - { - OSL_ENSURE( sal_False, - "queryCreatableContentsInfo called on non-folder object!" ); - - return uno::Sequence< ucb::ContentInfo >( 0 ); - } + return m_aProps.getCreatableContentsInfo( m_aUri ); } //========================================================================= @@ -746,16 +776,16 @@ Content::createNewContent( const ucb::ContentInfo& Info ) return uno::Reference< ucb::XContent >(); if ( !Info.Type.equalsIgnoreAsciiCase( - GetContentType( m_aUri.getScheme(), sal_True ) ) && + getContentType( m_aUri.getScheme(), sal_True ) ) && !Info.Type.equalsIgnoreAsciiCase( - GetContentType( m_aUri.getScheme(), sal_False ) ) ) + getContentType( m_aUri.getScheme(), sal_False ) ) ) return uno::Reference< ucb::XContent >(); rtl::OUString aURL = m_aUri.getUri(); aURL += rtl::OUString::createFromAscii( "/" ); if ( Info.Type.equalsIgnoreAsciiCase( - GetContentType( m_aUri.getScheme(), sal_True ) ) ) + getContentType( m_aUri.getScheme(), sal_True ) ) ) aURL += rtl::OUString::createFromAscii( "New_Folder" ); else aURL += rtl::OUString::createFromAscii( "New_Stream" ); @@ -871,6 +901,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( xRow->appendBoolean( rProp, rData.bIsFolder ); } else if ( rProp.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) + { + xRow->appendObject( + rProp, uno::makeAny( + rData.getCreatableContentsInfo( + PackageUri( rContentId ) ) ) ); + } + else if ( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) { xRow->appendString ( rProp, rData.aMediaType ); @@ -978,6 +1016,16 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::READONLY ), rData.bIsFolder ); + xRow->appendObject( + beans::Property( + rtl::OUString::createFromAscii( "CreatableContentsInfo" ), + -1, + getCppuType( static_cast< + const uno::Sequence< ucb::ContentInfo > * >( 0 ) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY ), + uno::makeAny( + rData.getCreatableContentsInfo( PackageUri( rContentId ) ) ) ); xRow->appendString( beans::Property( rtl::OUString::createFromAscii( "MediaType" ), @@ -1069,10 +1117,10 @@ uno::Sequence< uno::Any > Content::setPropertyValues( beans::PropertyChangeEvent aEvent; aEvent.Source = static_cast< cppu::OWeakObject * >( this ); aEvent.Further = sal_False; -// aEvent.PropertyName = +// aEvent.PropertyName = aEvent.PropertyHandle = -1; -// aEvent.OldValue = -// aEvent.NewValue = +// aEvent.OldValue = +// aEvent.NewValue = const beans::PropertyValue* pValues = rValues.getConstArray(); sal_Int32 nCount = rValues.getLength(); @@ -1116,6 +1164,15 @@ uno::Sequence< uno::Any > Content::setPropertyValues( static_cast< cppu::OWeakObject * >( this ) ); } else if ( rValue.Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "CreatableContentsInfo" ) ) ) + { + // Read-only property! + aRet[ n ] <<= lang::IllegalAccessException( + rtl::OUString::createFromAscii( + "Property is read-only!" ), + static_cast< cppu::OWeakObject * >( this ) ); + } + else if ( rValue.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Title" ) ) ) { if ( m_aUri.isRootFolder() ) @@ -1181,7 +1238,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aEvent.NewValue = uno::makeAny( aNewValue ); m_aProps.aMediaType = aNewValue; - nChanged++; + nChanged++; bStore = sal_True; m_nModifiedProps |= MEDIATYPE_MODIFIED; } @@ -1219,7 +1276,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aEvent.NewValue = uno::makeAny( bNewValue ); m_aProps.bCompressed = bNewValue; - nChanged++; + nChanged++; bStore = sal_True; m_nModifiedProps |= COMPRESSED_MODIFIED; } @@ -1256,7 +1313,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues( aEvent.NewValue = uno::makeAny( bNewValue ); m_aProps.bEncrypted = bNewValue; - nChanged++; + nChanged++; bStore = sal_True; m_nModifiedProps |= ENCRYPTED_MODIFIED; } @@ -1483,7 +1540,7 @@ uno::Any Content::open( uno::Reference< ucb::XDynamicResultSet > xSet = new DynamicResultSet( m_xSMgr, this, rArg, xEnv ); return uno::makeAny( xSet ); - } + } else { ////////////////////////////////////////////////////////////////// @@ -1506,7 +1563,7 @@ uno::Any Content::open( rtl::OUString aURL = m_xIdentifier->getContentIdentifier(); uno::Reference< io::XOutputStream > xOut( rArg.Sink, uno::UNO_QUERY ); if ( xOut.is() ) - { + { // PUSH: write data into xOut uno::Reference< io::XInputStream > xIn = getInputStream(); @@ -1560,14 +1617,14 @@ uno::Any Content::open( { // closeOutput, readSomeBytes, writeBytes } - } + } else - { + { uno::Reference< io::XActiveDataSink > xDataSink( rArg.Sink, uno::UNO_QUERY ); - if ( xDataSink.is() ) + if ( xDataSink.is() ) { - // PULL: wait for client read + // PULL: wait for client read uno::Reference< io::XInputStream > xIn = getInputStream(); if ( !xIn.is() ) @@ -1598,7 +1655,7 @@ uno::Any Content::open( // Done. xDataSink->setInputStream( xIn ); } - else + else { // Note: aOpenCommand.Sink may contain an XStream // implementation. Support for this type of @@ -1612,7 +1669,7 @@ uno::Any Content::open( xEnv ); // Unreachable } - } + } } return uno::Any(); @@ -1931,8 +1988,8 @@ void Content::transfer( ////////////////////////////////////////////////////////////////////// rtl::OUString aType = xSource->isFolder() - ? GetContentType( m_aUri.getScheme(), sal_True ) - : GetContentType( m_aUri.getScheme(), sal_False ); + ? getContentType( m_aUri.getScheme(), sal_True ) + : getContentType( m_aUri.getScheme(), sal_False ); ucb::ContentInfo aContentInfo; aContentInfo.Type = aType; aContentInfo.Attributes = 0; @@ -2413,14 +2470,14 @@ sal_Bool Content::loadData( if ( xEnumAccess.is() ) { // folder - rProps.aContentType = GetContentType( rURI.getScheme(), sal_True ); + rProps.aContentType = getContentType( rURI.getScheme(), sal_True ); rProps.bIsDocument = sal_False; rProps.bIsFolder = sal_True; } else { // stream - rProps.aContentType = GetContentType( rURI.getScheme(), sal_False ); + rProps.aContentType = getContentType( rURI.getScheme(), sal_False ); rProps.bIsDocument = sal_True; rProps.bIsFolder = sal_False; } @@ -2611,8 +2668,8 @@ sal_Bool Content::storeData( const uno::Reference< io::XInputStream >& xStream ) if ( !xNA->hasByHierarchicalName( m_aUri.getPath() ) ) { -// if ( !bCreate ) -// return sal_True; +// if ( !bCreate ) +// return sal_True; try { @@ -2956,4 +3013,3 @@ uno::Reference< container::XEnumeration > Content::getIterator() return xIter; } - @@ -34,9 +34,7 @@ #include <list> #include <rtl/ref.hxx> -#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFRERURLEXCEPTION_HPP_ #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> -#endif #include <com/sun/star/ucb/XContentCreator.hpp> #include <ucbhelper/contenthelper.hxx> #include "pkguri.hxx" @@ -100,6 +98,9 @@ struct ContentProperties bHasEncryptedEntries( sal_False ) {} ContentProperties( const ::rtl::OUString& rContentType ); + + com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo > + getCreatableContentsInfo( PackageUri const & rUri ) const; }; //========================================================================= @@ -110,7 +111,7 @@ class Content : public ::ucbhelper::ContentImplHelper, public com::sun::star::ucb::XContentCreator { enum ContentState { TRANSIENT, // created via CreateNewContent, - // but did not process "insert" yet + // but did not process "insert" yet PERSISTENT, // processed "insert" DEAD // processed "delete" }; @@ -119,7 +120,7 @@ class Content : public ::ucbhelper::ContentImplHelper, ContentProperties m_aProps; ContentState m_eState; com::sun::star::uno::Reference< - com::sun::star::container::XHierarchicalNameAccess > m_xPackage; + com::sun::star::container::XHierarchicalNameAccess > m_xPackage; ContentProvider* m_pProvider; sal_uInt32 m_nModifiedProps; @@ -130,7 +131,7 @@ private: const com::sun::star::uno::Reference< com::sun::star::ucb::XContentIdentifier >& Identifier, const ::com::sun::star::uno::Reference< - com::sun::star::container::XHierarchicalNameAccess >& Package, + com::sun::star::container::XHierarchicalNameAccess >& Package, const PackageUri& rUri, const ContentProperties& rProps ); |