Kaydet (Commit) 8722f0e7 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

rhbz#895690: Make GIO UCP less brittle, so saving docs works again

966d20e3 "CMIS ucp: write documents back to CMIS
server" had introduced changes to sfx2/source/doc/docfile.cxx in LO 3.6 that
changed the exact commands that this code issued for UCP content nodes.  The GIO
UCP was not prepared to handle that, causing saving of documents via it to fail
with rather obscure error messages:

* For one, docfile.cxx started to call "getPropertyValues" to obtain the "Title"
  of a non-existent content.  That lead to an InteractiveAugmentedIOException
  instead of silently returning a void value.

* For another, docfile.cxx started to call "transfer" on a folder content whose
  URL did not have a trailing slash, so the code computed a wrong URL for the
  child element, resulting in various problems depending on context.

Change-Id: I1a9c0c094f5320456940e3af4c802711828ab5ac
üst 07c6e767
...@@ -405,7 +405,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo * ...@@ -405,7 +405,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
if ( rProp.Name == "IsDocument" ) if ( rProp.Name == "IsDocument" )
{ {
if (g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE)) if (pInfo != 0 && g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE))
xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_REGULAR || xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_REGULAR ||
g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_UNKNOWN ) ); g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_UNKNOWN ) );
else else
...@@ -413,45 +413,45 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo * ...@@ -413,45 +413,45 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
} }
else if ( rProp.Name == "IsFolder" ) else if ( rProp.Name == "IsFolder" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_TYPE) )
xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_DIRECTORY )); xRow->appendBoolean( rProp, ( g_file_info_get_file_type( pInfo ) == G_FILE_TYPE_DIRECTORY ));
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
} }
else if ( rProp.Name == "Title" ) else if ( rProp.Name == "Title" )
{ {
if (g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME)) if (pInfo != 0 && g_file_info_has_attribute(pInfo, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
{ {
const char *pName = g_file_info_get_display_name(pInfo); const char *pName = g_file_info_get_display_name(pInfo);
xRow->appendString( rProp, rtl::OUString(pName, strlen(pName), RTL_TEXTENCODING_UTF8) ); xRow->appendString( rProp, rtl::OUString(pName, strlen(pName), RTL_TEXTENCODING_UTF8) );
} }
else else
xRow->appendVoid( rProp ); xRow->appendVoid(rProp);
} }
else if ( rProp.Name == "IsReadOnly" ) else if ( rProp.Name == "IsReadOnly" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ) )
xRow->appendBoolean( rProp, !g_file_info_get_attribute_boolean( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) ); xRow->appendBoolean( rProp, !g_file_info_get_attribute_boolean( pInfo, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
} }
else if ( rProp.Name == "DateCreated" ) else if ( rProp.Name == "DateCreated" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CREATED ) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CREATED ) )
xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CREATED)) ); xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CREATED)) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
} }
else if ( rProp.Name == "DateModified" ) else if ( rProp.Name == "DateModified" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED ) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED ) )
xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED)) ); xRow->appendTimestamp( rProp, getDateFromUnix(g_file_info_get_attribute_uint64(pInfo, G_FILE_ATTRIBUTE_TIME_CHANGED)) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
} }
else if ( rProp.Name == "Size" ) else if ( rProp.Name == "Size" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_SIZE) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_SIZE) )
xRow->appendLong( rProp, ( g_file_info_get_size( pInfo ) )); xRow->appendLong( rProp, ( g_file_info_get_size( pInfo ) ));
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
...@@ -463,14 +463,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo * ...@@ -463,14 +463,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
} }
else if ( rProp.Name == "IsCompactDisc" ) else if ( rProp.Name == "IsCompactDisc" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT ) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT ) )
xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) ); xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
} }
else if ( rProp.Name == "IsRemoveable" ) else if ( rProp.Name == "IsRemoveable" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) )
xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) ); xRow->appendBoolean( rProp, g_file_info_get_attribute_boolean(pInfo, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT ) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
...@@ -481,7 +481,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo * ...@@ -481,7 +481,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo *
} }
else if ( rProp.Name == "IsHidden" ) else if ( rProp.Name == "IsHidden" )
{ {
if( g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) ) if (pInfo != 0 && g_file_info_has_attribute( pInfo, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) )
xRow->appendBoolean( rProp, ( g_file_info_get_is_hidden ( pInfo ) ) ); xRow->appendBoolean( rProp, ( g_file_info_get_is_hidden ( pInfo ) ) );
else else
xRow->appendVoid( rProp ); xRow->appendVoid( rProp );
...@@ -506,11 +506,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues( ...@@ -506,11 +506,7 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
const uno::Sequence< beans::Property >& rProperties, const uno::Sequence< beans::Property >& rProperties,
const uno::Reference< ucb::XCommandEnvironment >& xEnv ) const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{ {
GError *pError = NULL; GFileInfo *pInfo = getGFileInfo(xEnv);
GFileInfo *pInfo = getGFileInfo(xEnv, &pError);
if (!pInfo)
ucbhelper::cancelCommandExecution(mapGIOError(pError), xEnv);
return getPropertyValuesFromGFileInfo(pInfo, m_xContext, xEnv, rProperties); return getPropertyValuesFromGFileInfo(pInfo, m_xContext, xEnv, rProperties);
} }
...@@ -1063,6 +1059,9 @@ void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Refer ...@@ -1063,6 +1059,9 @@ void Content::transfer( const ucb::TransferInfo& aTransferInfo, const uno::Refer
throw( uno::Exception ) throw( uno::Exception )
{ {
rtl::OUString sDest = m_xIdentifier->getContentIdentifier(); rtl::OUString sDest = m_xIdentifier->getContentIdentifier();
if (!sDest.endsWith("/")) {
sDest += "/";
}
if (aTransferInfo.NewTitle.getLength()) if (aTransferInfo.NewTitle.getLength())
sDest += aTransferInfo.NewTitle; sDest += aTransferInfo.NewTitle;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment