ucb/source/ucp/webdav-curl/DAVTypes.cxx      |   29 ++++++++++++++
 ucb/source/ucp/webdav-curl/DAVTypes.hxx      |   15 +++++++
 ucb/source/ucp/webdav-curl/webdavcontent.cxx |   55 +++++++++++++++++++--------
 vcl/source/outdev/text.cxx                   |    3 +
 4 files changed, 87 insertions(+), 15 deletions(-)

New commits:
commit 6ac3bf96d5c1676810b31d56f9d6eca7512b9026
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Mon Nov 1 17:08:45 2021 +0100
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Mon Nov 1 18:40:47 2021 +0100

    tdf#145496 Add dropped nLineWidth from refactoring
    
    Regression from commit 4fc1b3fb659be916167518b49ffe8193e9033f30
    ("flatten ImplGetTextLines").
    
    Change-Id: Ib9f086243b4e3ae245263492e714de6f81b89ea1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124557
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>
    Tested-by: Jenkins

diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 57a8a1e55568..8557ba2654c8 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -523,7 +523,10 @@ tools::Long OutputDevice::ImplGetTextLines( const 
tools::Rectangle& rRect, const
                 xBI = vcl::unohelper::CreateBreakIterator();
 
             if ( xBI.is() )
+            {
                 nBreakPos = ImplBreakLinesWithIterator(nWidth, rStr, _rLayout, 
xHyph, xBI, bHyphenate, nPos, nBreakPos);
+                nLineWidth = _rLayout.GetTextWidth(rStr, nPos, nBreakPos - 
nPos);
+            }
             else
                 // fallback to something really simple
                 nBreakPos = ImplBreakLinesSimple(nWidth, rStr, _rLayout, nPos, 
nBreakPos, nLineWidth);
commit 044bcca725f07058127fb35e9d3bddada364ff84
Author:     Giuseppe Castagno <giuseppe.casta...@acca-esse.eu>
AuthorDate: Tue Jul 26 11:36:24 2016 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Nov 1 18:40:35 2021 +0100

    ucb: webdav-curl: tdf#101094 (19) OPTIONS: Add mechanism to manage not 
found Web URL: GET
    
    [ port of commit 7f32fddb445ef1c1e17f9028f252c21dd83e03af ]
    
    Change-Id: Ie1412f849df0b9da76ccc41309e8e587c8f36c7c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123471
    Tested-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.cxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
index 839b9e845846..a7864350fbac 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.cxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.cxx
@@ -147,4 +147,33 @@ void DAVOptionsCache::addDAVOptions( DAVOptions & 
rDAVOptions, const sal_uInt32
 }
 
 
+bool DAVOptionsCache::isResourceFound( const OUString & rURL )
+{
+    osl::MutexGuard aGuard( m_aMutex );
+    OUString aEncodedUrl( ucb_impl::urihelper::encodeURI( DecodeURI(rURL) ) );
+    normalizeURLLastChar( aEncodedUrl );
+
+    DAVOptionsMap::iterator it;
+    it = m_aTheCache.find( aEncodedUrl );
+    if ( it != m_aTheCache.end() )
+    {
+        // first check for stale
+        TimeValue t1;
+        osl_getSystemTime( &t1 );
+        if( (*it).second.getStaleTime() < t1.Seconds )
+        {
+            m_aTheCache.erase( it );
+            return true; // to force again OPTIONS method
+        }
+
+        // check if the resource was present on server
+        return (*it).second.isResourceFound();
+    }
+    // this value is needed because some web server don't implement
+    // OPTIONS method, so the resource is considered found,
+    // until detected otherwise
+    return true;
+}
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/ucb/source/ucp/webdav-curl/DAVTypes.hxx 
b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
index d5453295c733..b7bc7004b613 100644
--- a/ucb/source/ucp/webdav-curl/DAVTypes.hxx
+++ b/ucb/source/ucp/webdav-curl/DAVTypes.hxx
@@ -149,6 +149,21 @@ namespace http_dav_ucp
         void removeDAVOptions( const OUString & rURL );
         void addDAVOptions( DAVOptions & rDAVOptions, const sal_uInt32 
nLifeTime );
 
+        /** Check if the DAV options cached value was found
+            by the last OPTIONS method call.
+            If the cached value is found stale, it is removed.
+
+            @param OUString
+                   the resource URL
+
+            @return bool
+                    true if resource was found or if the Web resource DAV 
options
+                    are not present (meaning the resource should be checked for
+                    presence anyway)
+                    false if resource was not found
+        */
+        bool isResourceFound( const OUString & rURL );
+
     private:
 
         /// remove the last '/' in aUrl, if it exists
diff --git a/ucb/source/ucp/webdav-curl/webdavcontent.cxx 
b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
index 962d95fe945f..483d409cb93b 100644
--- a/ucb/source/ucp/webdav-curl/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-curl/webdavcontent.cxx
@@ -2141,26 +2141,51 @@ uno::Any Content::open(
                     DAVResource aResource;
                     std::vector< OUString > aHeaders;
 
-                    uno::Reference< io::XInputStream > xIn
-                        = xResAccess->GET( aHeaders, aResource, xEnv );
-                    m_bDidGetOrHead = true;
-
+                    // check if the resource was present on the server
+                    if( aStaticDAVOptionsCache.isResourceFound( aTargetURL ) )
                     {
-                        osl::MutexGuard aGuard( m_aMutex );
+                        uno::Reference< io::XInputStream > xIn
+                            = xResAccess->GET( aHeaders, aResource, xEnv );
+                        m_bDidGetOrHead = true;
 
-                        // cache headers.
-                        if (!m_xCachedProps)
-                            m_xCachedProps.reset(
-                                new CachableContentProperties( 
ContentProperties( aResource ) ) );
-                        else
-                            m_xCachedProps->addProperties(
-                                aResource.properties );
+                        {
+                            osl::MutexGuard aGuard( m_aMutex );
+
+                            // cache headers.
+                            if (!m_xCachedProps)
+                                m_xCachedProps.reset(
+                                    new CachableContentProperties( 
ContentProperties( aResource ) ) );
+                            else
+                                m_xCachedProps->addProperties(
+                                    aResource.properties );
+
+                            m_xResAccess.reset(
+                                new DAVResourceAccess( *xResAccess ) );
 
-                        m_xResAccess.reset(
-                            new DAVResourceAccess( *xResAccess ) );
+                        }
+
+                        xDataSink->setInputStream( xIn );
                     }
+                    else
+                    {
+                        // return exception as if the resource was not found
+                        uno::Sequence< uno::Any > aArgs( 1 );
+                        aArgs[ 0 ] <<= beans::PropertyValue(
+                            "Uri", -1,
+                            uno::makeAny(aTargetURL),
+                            beans::PropertyState_DIRECT_VALUE);
 
-                    xDataSink->setInputStream( xIn );
+                        ucbhelper::cancelCommandExecution(
+                            uno::makeAny(
+                                ucb::InteractiveAugmentedIOException(
+                                    "Not found!",
+                                    static_cast< cppu::OWeakObject * >( this ),
+                                    task::InteractionClassification_ERROR,
+                                    ucb::IOErrorCode_NOT_EXISTING,
+                                    aArgs ) ),
+                            xEnv );
+                // Unreachable
+                    }
                 }
                 catch ( DAVException const & e )
                 {

Reply via email to