ucb/source/ucp/tdoc/tdoc_docmgr.cxx |   17 +++++++++++++----
 ucb/source/ucp/tdoc/tdoc_docmgr.hxx |    4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 4d85dfd54942e1fc442f3d1a424207ab61b65806
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Oct 27 21:14:28 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Oct 28 14:27:44 2023 +0200

    use more XModel3::getArgs2
    
    to avoid needing to query other, rather expensive properties
    
    Change-Id: I34ebc7a03e468f0a7fa9964954e5690ad336016a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158579
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx 
b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index 0e11f546bb1e..39fa5bc828b5 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -556,13 +556,20 @@ void 
OfficeDocumentsManager::updateStreamDateModified(OUString const & uri) {
 
 
 bool OfficeDocumentsManager::isDocumentPreview(
-        const uno::Reference< frame::XModel > & xModel )
+        const uno::Reference< frame::XModel3 > & xModel )
 {
     if ( !xModel.is() )
         return false;
 
-    bool bIsPreview = ::comphelper::NamedValueCollection::getOrDefault( 
xModel->getArgs(), u"Preview", false );
-    return bIsPreview;
+    uno::Sequence<beans::PropertyValue> props = xModel->getArgs2( { "Preview" 
} );
+    for (const auto & rProp : props)
+        if (rProp.Name == "Preview")
+        {
+            bool bIsPreview = false;
+            rProp.Value >>= bIsPreview;
+            return bIsPreview;
+        }
+    return false;
 }
 
 
@@ -664,11 +671,13 @@ bool OfficeDocumentsManager::isOfficeDocument(
         xStorageBasedDoc( xModel, uno::UNO_QUERY );
     if ( !xStorageBasedDoc.is() )
         return false;
+    uno::Reference< frame::XModel3 > xModel3( xDoc, uno::UNO_QUERY );
+    assert(xModel3 && "anything implementing frame:XModel is expected to 
implement XModel3 as well");
 
     if ( !isWithoutOrInTopLevelFrame( xModel ) )
         return false;
 
-    if ( isDocumentPreview( xModel ) )
+    if ( isDocumentPreview( xModel3 ) )
         return false;
 
     if ( isHelpDocument( xModel ) )
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx 
b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
index 8daf9eba60e4..7115d0fe8e99 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.hxx
@@ -25,7 +25,7 @@
 
 #include <com/sun/star/document/XDocumentEventListener.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
-#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XModel3.hpp>
 #include <com/sun/star/frame/XModuleManager2.hpp>
 #include <com/sun/star/frame/XGlobalEventBroadcaster.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
@@ -133,7 +133,7 @@ namespace tdoc_ucp {
             const css::uno::Reference< css::uno::XInterface > & xDoc );
 
         static bool isDocumentPreview(
-            const css::uno::Reference< css::frame::XModel > & xModel );
+            const css::uno::Reference< css::frame::XModel3 > & xModel );
 
         static bool isWithoutOrInTopLevelFrame(
             const css::uno::Reference< css::frame::XModel > & xModel );

Reply via email to