summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-08-16 16:41:22 +0200
committerCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-08-16 16:41:22 +0200
commit414d36f7370bce34d3d3765aa4e85dd44603c17f (patch)
tree0b5962c97012028dd0fec3e2e8d0cdb987406424
parentf8d3367eb1783e89b79b41a616b188ccd3f5644b (diff)
CMIS: fix file saving issue
Change-Id: I60cccb841fea5ce493f004c73ecf50468019f860
-rw-r--r--comphelper/source/misc/mediadescriptor.cxx5
-rw-r--r--sfx2/source/doc/docfile.cxx5
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx148
-rw-r--r--ucb/source/ucp/cmis/cmis_url.cxx6
4 files changed, 61 insertions, 103 deletions
diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index 586f6fcb1675..21102f2a773d 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -470,8 +470,9 @@ sal_Bool MediaDescriptor::impl_addInputStream( sal_Bool bLockFile )
css::uno::Reference< css::uno::XInterface >());
// Parse URL! Only the main part has to be used further. E.g. a jumpmark can make trouble
- OUString sNormalizedURL = impl_normalizeURL( sURL );
- return impl_openStreamWithURL( sNormalizedURL, bLockFile );
+ // We need to keep the full URL with Mark to store the Object ID
+ // in CMIS UCB
+ return impl_openStreamWithURL( sURL, bLockFile );
}
#if OSL_DEBUG_LEVEL > 0
catch(const css::uno::Exception& ex)
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index c59675f8d5c5..ebd03eaf3284 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -2492,7 +2492,7 @@ void SfxMedium::Init_Impl()
{
if ( aUrl.HasMark() )
{
- pImp->m_aLogicName = aUrl.GetURLNoMark( INetURLObject::NO_DECODE );
+ // keep the Mark to store the Document ID
GetItemSet()->Put( SfxStringItem( SID_JUMPMARK, aUrl.GetMark() ) );
}
@@ -3007,8 +3007,7 @@ const INetURLObject& SfxMedium::GetURLObject() const
if (!pImp->m_pURLObj)
{
pImp->m_pURLObj = new INetURLObject( pImp->m_aLogicName );
- if (pImp->m_pURLObj->HasMark())
- *pImp->m_pURLObj = INetURLObject( pImp->m_aLogicName ).GetURLNoMark();
+ // keep the Mark to store the Document ID
}
return *pImp->m_pURLObj;
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index c2266fbc98ff..6ac4106e6306 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -415,7 +415,18 @@ namespace cmis
{
if ( !m_pObject.get() )
{
- if ( !m_sObjectPath.isEmpty( ) )
+ if ( !m_sObjectId.isEmpty( ) )
+ {
+ try
+ {
+ m_pObject = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId ) );
+ }
+ catch ( const libcmis::Exception& )
+ {
+ throw libcmis::Exception( "Object not found" );
+ }
+ }
+ else if ( !m_sObjectPath.isEmpty( ) )
{
try
{
@@ -438,7 +449,7 @@ namespace cmis
{
vector< libcmis::ObjectPtr > children = pParentFolder->getChildren( );
for ( vector< libcmis::ObjectPtr >::iterator it = children.begin( );
- it != children.end() && !m_pObject; ++it )
+ it != children.end() && !m_pObject; ++it )
{
if ( ( *it )->getName( ) == sName )
m_pObject = *it;
@@ -449,8 +460,6 @@ namespace cmis
throw libcmis::Exception( "Object not found" );
}
}
- else if (!m_sObjectId.isEmpty( ) )
- m_pObject = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId ) );
else
{
m_pObject = getSession( xEnv )->getRootFolder( );
@@ -467,7 +476,9 @@ namespace cmis
bool bIsFolder = false;
try
{
- bIsFolder = getObject( xEnv )->getBaseType( ) == "cmis:folder";
+ libcmis::ObjectPtr obj = getObject( xEnv );
+ if ( obj )
+ bIsFolder = obj->getBaseType( ) == "cmis:folder";
}
catch ( const libcmis::Exception& e )
{
@@ -539,7 +550,9 @@ namespace cmis
{
try
{
- xRow->appendBoolean( rProp, getObject( xEnv )->getBaseType( ) == "cmis:document" );
+ libcmis::ObjectPtr obj = getObject( xEnv );
+ if ( obj )
+ xRow->appendBoolean( rProp, obj->getBaseType( ) == "cmis:document" );
}
catch ( const libcmis::Exception& )
{
@@ -553,7 +566,11 @@ namespace cmis
{
try
{
- xRow->appendBoolean( rProp, getObject( xEnv )->getBaseType( ) == "cmis:folder" );
+ libcmis::ObjectPtr obj = getObject( xEnv );
+ if ( obj )
+ xRow->appendBoolean( rProp, obj->getBaseType( ) == "cmis:folder" );
+ else
+ xRow->appendBoolean( rProp, sal_False );
}
catch ( const libcmis::Exception& )
{
@@ -633,20 +650,7 @@ namespace cmis
else if ( rProp.Name == "TitleOnServer" )
{
string path;
- try
- {
- vector< string > paths = getObject( xEnv )->getPaths( );
- if ( !paths.empty( ) )
- path = paths.front( );
- else
- path = getObject( xEnv )->getName( );
-
- xRow->appendString( rProp, STD_TO_OUSTR( path ) );
- }
- catch ( const libcmis::Exception& )
- {
- xRow->appendVoid( rProp );
- }
+ xRow->appendString( rProp, m_sObjectPath);
}
else if ( rProp.Name == "IsReadOnly" )
{
@@ -1154,41 +1158,30 @@ namespace cmis
if ( pFolder != NULL )
{
libcmis::ObjectPtr object;
- string newPath;
- if ( m_sObjectId.isEmpty( ) )
+ map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" );
+ if ( it == m_pObjectProps.end( ) )
{
- map< string, libcmis::PropertyPtr >::iterator it = m_pObjectProps.find( "cmis:name" );
- if ( it == m_pObjectProps.end( ) )
- {
- ucbhelper::cancelCommandExecution( uno::makeAny
- ( uno::RuntimeException( "Missing name property",
- static_cast< cppu::OWeakObject * >( this ) ) ),
- xEnv );
- }
- string newName = it->second->getStrings( ).front( );
- newPath = pFolder->getPath( );
- if ( newPath[ newPath.size( ) - 1 ] != '/' )
- newPath += "/";
- newPath += newName;
-
- try
- {
- object = getSession( xEnv )->getObjectByPath( newPath );
- sNewPath = STD_TO_OUSTR( newPath );
- }
- catch ( const libcmis::Exception& )
- {
- // Nothing matched the path
- }
+ ucbhelper::cancelCommandExecution( uno::makeAny
+ ( uno::RuntimeException( "Missing name property",
+ static_cast< cppu::OWeakObject * >( this ) ) ),
+ xEnv );
}
- else
+ string newName = it->second->getStrings( ).front( );
+ string newPath = OUSTR_TO_STDSTR( m_sObjectPath );
+ if ( !newPath.empty( ) && newPath[ newPath.size( ) - 1 ] != '/' )
+ newPath += "/";
+ newPath += newName;
try
{
- object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) );
+ if ( !m_sObjectId.isEmpty( ) )
+ object = getSession( xEnv )->getObject( OUSTR_TO_STDSTR( m_sObjectId) );
+ else
+ object = getSession( xEnv )->getObjectByPath( newPath );
+ sNewPath = STD_TO_OUSTR( newPath );
}
- catch ( libcmis::Exception& )
+ catch ( const libcmis::Exception& )
{
- // Continue
+ // Nothing matched the path
}
if ( NULL != object.get( ) )
@@ -1275,7 +1268,8 @@ namespace cmis
m_pObjectType.reset( );
m_pObjectProps.clear( );
m_bTransient = false;
-
+ uno::Reference< ucb::XContentIdentifier > xId(new ::ucbhelper::ContentIdentifier(m_sURL));
+ m_xIdentifier = xId;
inserted();
}
}
@@ -1548,54 +1542,18 @@ namespace cmis
OUString sRet;
SAL_INFO( "cmisucp", "Content::getParentURL()" );
-
- string parentPath;
- try
- {
- libcmis::ObjectPtr pObj = getObject( uno::Reference< ucb::XCommandEnvironment >() );
- libcmis::Document* document = dynamic_cast< libcmis::Document* >( pObj.get( ) );
- if ( NULL != document )
- {
- vector< boost::shared_ptr< libcmis::Folder > > parents = document->getParents( );
- if ( !parents.empty( ) )
- parentPath = parents.front( )->getPath( );
- }
- else
- {
- libcmis::Folder* folder = dynamic_cast< libcmis::Folder* >( pObj.get( ) );
- if ( NULL != folder )
- {
- libcmis::FolderPtr parentFolder = folder->getFolderParent( );
- if ( NULL != parentFolder )
- parentPath = parentFolder->getPath( );
- }
- }
- }
- catch ( const libcmis::Exception & )
- {
- // We may have an exception if we don't have the rights to
- // get the parents
- }
-
- if ( !parentPath.empty() )
- {
- URL aUrl( m_sURL );
- aUrl.setObjectPath( STD_TO_OUSTR( parentPath ) );
- sRet = aUrl.asString( );
- }
+ OUString parentUrl = OUString( "/" );
+ if ( m_sObjectPath == "/" )
+ return parentUrl;
else
{
- INetURLObject aUrl( m_sURL );
- if ( aUrl.getSegmentCount( ) > 0 )
- {
- URL aCmisUrl( m_sURL );
- aUrl.removeSegment( );
- aCmisUrl.setObjectPath( aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
- sRet = aCmisUrl.asString( );
- }
+ INetURLObject aParentUrl( m_sURL );
+ string sName = OUSTR_TO_STDSTR( aParentUrl.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ) );
+ aParentUrl.removeSegment( );
+ return aParentUrl.GetMainURL( INetURLObject::NO_DECODE );
}
- return sRet;
+ return parentUrl;
}
XTYPEPROVIDER_COMMON_IMPL( Content );
diff --git a/ucb/source/ucp/cmis/cmis_url.cxx b/ucb/source/ucp/cmis/cmis_url.cxx
index ac26167328d0..24680661e913 100644
--- a/ucb/source/ucp/cmis/cmis_url.cxx
+++ b/ucb/source/ucp/cmis/cmis_url.cxx
@@ -38,8 +38,8 @@ namespace cmis
m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
m_sId = aUrl.GetMark( INetURLObject::DECODE_WITH_CHARSET );
- if ( !m_sId.isEmpty( ) )
- m_sPath = OUString( );
+ if ( m_sPath == "/" && m_sBindingUrl.indexOf( "google" ) != -1 )
+ m_sId = "root";
}
OUString& URL::getObjectPath( )
@@ -106,7 +106,7 @@ namespace cmis
while ( nPos != -1 );
sUrl += sEncodedPath;
}
- else if ( !m_sId.isEmpty( ) )
+ if ( !m_sId.isEmpty( ) )
{
sUrl += "#" + rtl::Uri::encode( m_sId,
rtl_UriCharClassRelSegment,