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 <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2023-10-28 14:27:44 +02:00
committed by Noel Grandin
parent 4a4e8a7aa2
commit 4d85dfd549
2 changed files with 15 additions and 6 deletions
+13 -4
View File
@@ -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 ) )
+2 -2
View File
@@ -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 );