[Libreoffice-commits] .: Branch 'libreoffice-3-5' - unotools/inc unotools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 22 09:22:50 PDT 2012


 unotools/inc/unotools/ucbhelper.hxx     |    7 +++++++
 unotools/source/ucbhelper/ucbhelper.cxx |   23 ++++++++++++++---------
 2 files changed, 21 insertions(+), 9 deletions(-)

New commits:
commit fc08156b06c82a1a2b9d64b57caaf434485d4d3e
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Aug 22 09:11:23 2012 +0200

    fdo#46249: UCBContentHelper::GetTitle must not fail for void property
    
    This was a regression introduced with 2af9040d38af7c7353855415dbea0134585058f3
    "Cleaned up utl::UCBContentHelper."  GetSize exhibited the same problem and has
    also been fixed.  IsYounger exhibits a similar problem, but has not been
    addressed, as it is unclear what to return in case no dates can be compared; it
    is only used in one place (handling SID_EDITDOC in
    SfxViewFrame::ExecReload_Impl, sfx2/source/view/viewfrm.cxx) where, it appears,
    only contents for which DateModified /does/ yield a non-void value are relevant.
    
    (cherry picked from commit 27c7682e5e5859eb353443d6091143694a56bee8)
    
    Conflicts:
    	unotools/source/ucbhelper/ucbhelper.cxx
    
    Change-Id: I748745a1d7f361f8f91be87d7356983ee7261b1e
    Reviewed-on: https://gerrit.libreoffice.org/452
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/unotools/inc/unotools/ucbhelper.hxx b/unotools/inc/unotools/ucbhelper.hxx
index 358d8e1..3ff576b 100644
--- a/unotools/inc/unotools/ucbhelper.hxx
+++ b/unotools/inc/unotools/ucbhelper.hxx
@@ -47,6 +47,10 @@ UNOTOOLS_DLLPUBLIC bool IsDocument(rtl::OUString const & url);
 
 UNOTOOLS_DLLPUBLIC bool IsFolder(rtl::OUString const & url);
 
+/// @param title must not be null
+/// @return true iff title has been set (i.e., if obtaining the "Title" property
+///     of the given content yields a non-void value without raising a
+///     non-RuntimeException; RuntimeExceptions are passed through)
 UNOTOOLS_DLLPUBLIC bool GetTitle(
     rtl::OUString const & url, rtl::OUString * title);
 
@@ -62,6 +66,9 @@ UNOTOOLS_DLLPUBLIC bool MakeFolder(
     ucbhelper::Content & parent, rtl::OUString const & title,
     ucbhelper::Content & result, bool exclusive = false);
 
+/// @return the value of the "Size" property of the given content, or zero if
+///     obtaining the property yields a void value or raises a
+///     non-RuntimeException (RuntimeExceptions are passed through)
 UNOTOOLS_DLLPUBLIC sal_Int64 GetSize(rtl::OUString const & url);
 
 UNOTOOLS_DLLPUBLIC bool IsYounger(
diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx
index daee93f..4747d5e 100644
--- a/unotools/source/ucbhelper/ucbhelper.cxx
+++ b/unotools/source/ucbhelper/ucbhelper.cxx
@@ -200,11 +200,10 @@ bool utl::UCBContentHelper::GetTitle(
 {
     assert(title != 0);
     try {
-        *title = content(url).
-            getPropertyValue(
-                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"))).
-            get<rtl::OUString>();
-        return true;
+        return
+            content(url).getPropertyValue(
+                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")))
+            >>= *title;
     } catch (css::uno::RuntimeException const &) {
         throw;
     } catch (css::ucb::CommandAbortedException const &) {
@@ -341,10 +340,16 @@ bool utl::UCBContentHelper::MakeFolder(
 
 sal_Int64 utl::UCBContentHelper::GetSize(rtl::OUString const & url) {
     try {
-        return
-            content(url).getPropertyValue(
-                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size"))).
-            get<sal_Int64>();
+        sal_Int64 n = 0;
+        bool ok =
+            (content(url).getPropertyValue(
+                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size")))
+             >>= n);
+        SAL_INFO_IF(
+            !ok, "unotools",
+            "UCBContentHelper::GetSize(" << url
+                << "): Size cannot be determined");
+        return n;
     } catch (css::uno::RuntimeException const &) {
         throw;
     } catch (css::ucb::CommandAbortedException const &) {


More information about the Libreoffice-commits mailing list