ucb/source/ucp/gio/gio_content.cxx |   52 ++++++++++++++++++++++++-------------
 ucb/source/ucp/gio/gio_content.hxx |    9 ++----
 2 files changed, 38 insertions(+), 23 deletions(-)

New commits:
commit 6d3dd64391e67e6cfe406dea047e13227ea94c4b
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon Apr 29 11:45:46 2019 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Mon Apr 29 13:46:42 2019 +0200

    tdf#123472: Propagate getGFileInfo failure less aggressively
    
    ...from Content::getPropertyValues.  
ca0308797df86ebece19260f3ca438a0cb437208
    "tdf#121337: Fail on GIO error in GIO UCP getPropertyValue" had made
    Content::getPropertyValues fail for every getGFileInfo failure.  However, 
when
    saving to a not-yet exisiting file, SfxMedium::Transfer_Impl
    (sfx2/source/doc/docfile.cxx) requests the properties "Title" and "ObjectId"
    from the Content representing the not-yet existing file, and apparently 
expects
    those requests not to fail.  So restructure Content::getPropertyValues to 
only
    call getGFileInfo when actually needed (that covers not failing for the 
unknown-
    anyway "ObjecdtId" property), and handle "Title" specially by not failing 
for
    a non-existing file.  (The documentation at 
offapi/com/sun/star/ucb/Content.idl
    says for the "getPropertyValues" command that: "The execution will not be
    aborted, if there are properties requested, that are unknown to the 
content."
    But that leaves it somewhat unclear whether failure to obtain a known 
property
    should be propagated.  It apparently should be in the context of tfd#121337
    fixed previously, but apparently not for "Title" here.)
    
    Change-Id: I12a9a5bd93d661922ea3b7b19a84a7e73e7e4b50
    Reviewed-on: https://gerrit.libreoffice.org/71515
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/ucb/source/ucp/gio/gio_content.cxx 
b/ucb/source/ucp/gio/gio_content.cxx
index d3a910c02c4a..e3f2c0cb0222 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -432,12 +432,11 @@ static util::DateTime getDateFromUnix (time_t t)
         return util::DateTime();
 }
 
-uno::Reference< sdbc::XRow > Content::getPropertyValuesFromGFileInfo(GFileInfo 
*pInfo,
-    const uno::Reference< uno::XComponentContext >& rxContext,
-    const uno::Reference< ucb::XCommandEnvironment > & xEnv,
-    const uno::Sequence< beans::Property >& rProperties)
+uno::Reference< sdbc::XRow > Content::getPropertyValues(
+                const uno::Sequence< beans::Property >& rProperties,
+                const uno::Reference< ucb::XCommandEnvironment >& xEnv )
 {
-    rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new 
::ucbhelper::PropertyValueSet( rxContext );
+    rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new 
::ucbhelper::PropertyValueSet( m_xContext );
 
     sal_Int32 nProps;
     const beans::Property* pProps;
@@ -445,12 +444,14 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
     nProps = rProperties.getLength();
     pProps = rProperties.getConstArray();
 
+    GFileInfo *pInfo = nullptr;
     for( sal_Int32 n = 0; n < nProps; ++n )
     {
         const beans::Property& rProp = pProps[ n ];
 
         if ( rProp.Name == "IsDocument" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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 ||
                                                g_file_info_get_file_type( 
pInfo ) == G_FILE_TYPE_UNKNOWN ) );
@@ -459,6 +460,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "IsFolder" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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 ));
             else
@@ -466,6 +468,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "Title" )
         {
+            getFileInfo(xEnv, &pInfo, false);
             if (pInfo != nullptr && g_file_info_has_attribute(pInfo, 
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
             {
                 const char *pName = g_file_info_get_display_name(pInfo);
@@ -476,6 +479,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "IsReadOnly" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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) );
             else
@@ -483,6 +487,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "DateCreated" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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)) );
             else
@@ -490,6 +495,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "DateModified" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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)) );
             else
@@ -497,6 +503,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "Size" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && g_file_info_has_attribute( pInfo, 
G_FILE_ATTRIBUTE_STANDARD_SIZE) )
                 xRow->appendLong( rProp, ( g_file_info_get_size( pInfo ) ));
             else
@@ -509,6 +516,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "IsCompactDisc" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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) 
);
             else
@@ -516,6 +524,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "IsRemoveable" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && 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 
) );
             else
@@ -527,6 +536,7 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
         }
         else if ( rProp.Name == "IsHidden" )
         {
+            getFileInfo(xEnv, &pInfo, true);
             if (pInfo != nullptr && g_file_info_has_attribute( pInfo, 
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) )
                 xRow->appendBoolean( rProp, ( g_file_info_get_is_hidden ( 
pInfo ) ) );
             else
@@ -547,19 +557,6 @@ uno::Reference< sdbc::XRow > 
Content::getPropertyValuesFromGFileInfo(GFileInfo *
     return uno::Reference< sdbc::XRow >( xRow.get() );
 }
 
-uno::Reference< sdbc::XRow > Content::getPropertyValues(
-                const uno::Sequence< beans::Property >& rProperties,
-                const uno::Reference< ucb::XCommandEnvironment >& xEnv )
-{
-    GError * err = nullptr;
-    GFileInfo *pInfo = getGFileInfo(xEnv, &err);
-    if (pInfo == nullptr && !mbTransient) {
-        ucbhelper::cancelCommandExecution(mapGIOError(err), xEnv);
-    }
-    assert(err == nullptr);
-    return getPropertyValuesFromGFileInfo(pInfo, m_xContext, xEnv, 
rProperties);
-}
-
 static lang::IllegalAccessException
 getReadOnlyException( const uno::Reference< uno::XInterface >& rContext )
 {
@@ -646,6 +643,25 @@ bool Content::exchangeIdentity( const uno::Reference< 
ucb::XContentIdentifier >&
     return false;
 }
 
+void Content::getFileInfo(
+    css::uno::Reference<css::ucb::XCommandEnvironment> const & env, GFileInfo 
** info, bool fail)
+{
+    assert(info != nullptr);
+    if (*info == nullptr)
+    {
+        GError * err = nullptr;
+        *info = getGFileInfo(env, &err);
+        if (*info == nullptr && !mbTransient && fail)
+        {
+            ucbhelper::cancelCommandExecution(mapGIOError(err), env);
+        }
+        else if (err != nullptr)
+        {
+            g_error_free(err);
+        }
+    }
+}
+
 uno::Sequence< uno::Any > Content::setPropertyValues(
     const uno::Sequence< beans::PropertyValue >& rValues,
     const uno::Reference< ucb::XCommandEnvironment >& xEnv )
diff --git a/ucb/source/ucp/gio/gio_content.hxx 
b/ucb/source/ucp/gio/gio_content.hxx
index a60ae47a738c..8ba80fc4d53f 100644
--- a/ucb/source/ucp/gio/gio_content.hxx
+++ b/ucb/source/ucp/gio/gio_content.hxx
@@ -116,6 +116,10 @@ private:
 
     bool exchangeIdentity(const css::uno::Reference< 
css::ucb::XContentIdentifier >&  xNewId);
 
+    void getFileInfo(
+        css::uno::Reference<css::ucb::XCommandEnvironment> const & env, 
GFileInfo ** info,
+        bool fail);
+
 public:
     /// @throws css::ucb::ContentCreationException
     Content( const css::uno::Reference<
@@ -130,11 +134,6 @@ public:
 
     virtual ~Content() override;
 
-    css::uno::Reference< css::sdbc::XRow > getPropertyValuesFromGFileInfo(
-        GFileInfo *pInfo, const css::uno::Reference< 
css::uno::XComponentContext >& rxContext,
-        const css::uno::Reference< css::ucb::XCommandEnvironment > & xEnv,
-        const css::uno::Sequence< css::beans::Property >& rProperties);
-
     virtual css::uno::Sequence< css::beans::Property >
         getProperties( const css::uno::Reference<
             css::ucb::XCommandEnvironment > & xEnv ) override;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to