include/sfx2/dinfdlg.hxx       |    5 ++++-
 sfx2/sdi/sfx.sdi               |    2 +-
 sfx2/source/dialog/dinfdlg.cxx |   15 +++++++++++----
 sfx2/source/doc/objserv.cxx    |    8 +++++---
 4 files changed, 21 insertions(+), 9 deletions(-)

New commits:
commit aa4e10efc6e9ac92b0c652f238526aacbe2096c6
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Mon Apr 15 01:22:45 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Apr 15 16:16:19 2024 +0200

    sw lok: .uno:SetDocumentProperties: add file size parameter
    
    problem:
    in LOK/online to support async save, files in jails may have
    different extensions (ie: .upload, .uploading)
    this caused problem to detect files as original file name may not exist.
    As result property like file size were always set to 0
    
    Change-Id: I552aef203297470d01032659a266210970129e66
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165769
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 874e127f20b5..d4743ed00ef5 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -82,6 +82,7 @@ private:
     OUString                     m_Type;
     OUString                     m_Subject;
     OUString                     m_Title;
+    sal_Int64                    m_nFileSize;
     bool                         m_bHasTemplate;
     bool                         m_bDeleteUserData;
     bool                         m_bUseUserData;
@@ -95,7 +96,7 @@ public:
     SfxDocumentInfoItem( const OUString &rFileName,
         const css::uno::Reference< css::document::XDocumentProperties> & 
i_xDocProps,
         const css::uno::Sequence< css::document::CmisProperty> & i_cmisProps,
-        bool bUseUserData, bool bUseThumbnailSave );
+        bool bUseUserData, bool bUseThumbnailSave, sal_Int64 nFileSize );
     SfxDocumentInfoItem( const SfxDocumentInfoItem& );
     virtual ~SfxDocumentInfoItem() override;
 
@@ -148,6 +149,8 @@ public:
     void        setSubject(const OUString& i_val) { m_Subject = i_val; }
     const OUString& getTitle() const { return m_Title; }
     void        setTitle(const OUString& i_val) { m_Title = i_val; }
+    sal_Int64   getFileSize() const { return m_nFileSize; }
+    void setFileSize(sal_Int64 i_val) { m_nFileSize = i_val; }
 
     /// reset user-specific data (author, modified-by, ...)
     void        resetUserData(const OUString & i_rAuthor);
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 9c2b72d5f443..4dca362cea49 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3382,7 +3382,7 @@ SfxBoolItem PrintPreview SID_PRINTPREVIEW
 
 
 SfxVoidItem SetDocumentProperties SID_DOCINFO
-(SfxDocumentInfoItem Properties SID_DOCINFO, SfxUnoAnyItem UpdatedProperties 
FN_PARAM_1)
+(SfxDocumentInfoItem Properties SID_DOCINFO, SfxUnoAnyItem UpdatedProperties 
FN_PARAM_1, SfxStringItem FileSize FN_PARAM_2)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index fc8754e5f12a..d46a1a2bcc62 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -180,6 +180,7 @@ SfxDocumentInfoItem::SfxDocumentInfoItem()
     , m_isAutoloadEnabled(false)
     , m_EditingCycles(0)
     , m_EditingDuration(0)
+    , m_nFileSize(-1)
     , m_bHasTemplate( true )
     , m_bDeleteUserData( false )
     , m_bUseUserData( true )
@@ -190,7 +191,7 @@ SfxDocumentInfoItem::SfxDocumentInfoItem()
 SfxDocumentInfoItem::SfxDocumentInfoItem( const OUString& rFile,
         const uno::Reference<document::XDocumentProperties>& i_xDocProps,
         const uno::Sequence<document::CmisProperty>& i_cmisProps,
-        bool bIs, bool _bIs )
+        bool bIs, bool _bIs, sal_Int64 _nFileSize )
     : SfxStringItem( SID_DOCINFO, rFile )
     , m_AutoloadDelay( i_xDocProps->getAutoloadSecs() )
     , m_AutoloadURL( i_xDocProps->getAutoloadURL() )
@@ -210,6 +211,7 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const OUString& 
rFile,
                     i_xDocProps->getKeywords()) )
     , m_Subject( i_xDocProps->getSubject() )
     , m_Title( i_xDocProps->getTitle() )
+    , m_nFileSize( _nFileSize )
     , m_bHasTemplate( true )
     , m_bDeleteUserData( false )
     , m_bUseUserData( bIs )
@@ -280,6 +282,7 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const 
SfxDocumentInfoItem& rItem )
     , m_Type(rItem.getType())
     , m_Subject( rItem.getSubject() )
     , m_Title( rItem.getTitle() )
+    , m_nFileSize ( rItem.m_nFileSize )
     , m_bHasTemplate( rItem.m_bHasTemplate )
     , m_bDeleteUserData( rItem.m_bDeleteUserData )
     , m_bUseUserData( rItem.m_bUseUserData )
@@ -1117,9 +1120,13 @@ void SfxDocumentPage::Reset( const SfxItemSet* rSet )
 
     // determine size and type
     OUString aSizeText( m_aUnknownSize );
-    if ( aURL.GetProtocol() == INetProtocol::File ||
-         aURL.isAnyKnownWebDAVScheme() )
-        aSizeText = CreateSizeText( SfxContentHelper::GetSize( 
aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) );
+    // we might already know the size as an optional argument passed to 
.uno:SetDocumentProperties
+    sal_Int64 nSize = rInfoItem.getFileSize();
+    // otherwise, for some protocols we can reliably query for it
+    if (nSize == -1 && (aURL.GetProtocol() == INetProtocol::File || 
aURL.isAnyKnownWebDAVScheme()))
+        nSize = SfxContentHelper::GetSize( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ) );
+    if (nSize != -1)
+        aSizeText = CreateSizeText( nSize );
     m_xShowSizeFT->set_label( aSizeText );
 
     OUString aDescription = SvFileInformationManager::GetDescription( 
INetURLObject(rMainURL) );
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index fedbfb205d92..c37c53c427fd 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -659,13 +659,15 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                     bReadOnly = pROItem->GetValue();
 
                 // URL for dialog
+                const SfxStringItem* pFileSize = 
rReq.GetArg<SfxStringItem>(FN_PARAM_2);
+                sal_Int64 nFileSize = pFileSize ? 
pFileSize->GetValue().toInt64() : -1;
                 const OUString aURL( HasName() ? GetMedium()->GetName() : 
GetFactory().GetFactoryURL() );
 
                 Reference< XCmisDocument > xCmisDoc( GetModel(), 
uno::UNO_QUERY );
                 uno::Sequence< document::CmisProperty> aCmisProperties = 
xCmisDoc->getCmisProperties();
 
                 SfxDocumentInfoItem aDocInfoItem( aURL, getDocProperties(), 
aCmisProperties,
-                    IsUseUserData(), IsUseThumbnailSave() );
+                    IsUseUserData(), IsUseThumbnailSave(), nFileSize );
                 const SfxPoolItemHolder 
aSlotState(GetSlotState(SID_DOCTEMPLATE));
                 if (nullptr == aSlotState.getItem())
                     // templates not supported
@@ -682,7 +684,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                 // creating dialog is done via virtual method; application will
                 // add its own statistics page
                 std::shared_ptr<SfxDocumentInfoDialog> 
xDlg(CreateDocumentInfoDialog(rReq.GetFrameWeld(), aSet));
-                auto aFunc = [this, xDlg, xCmisDoc](sal_Int32 nResult, 
SfxRequest& rRequest)
+                auto aFunc = [this, xDlg, xCmisDoc, nFileSize](sal_Int32 
nResult, SfxRequest& rRequest)
                 {
                     if (RET_OK == nResult)
                     {
@@ -699,7 +701,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                             SetUseThumbnailSave( pDocInfoItem-> 
IsUseThumbnailSave() );
                             // add data from dialog for possible recording 
purpose
                             rRequest.AppendItem( SfxDocumentInfoItem( 
GetTitle(),
-                                getDocProperties(), aNewCmisProperties, 
IsUseUserData(), IsUseThumbnailSave() ) );
+                                getDocProperties(), aNewCmisProperties, 
IsUseUserData(), IsUseThumbnailSave(), nFileSize ) );
                         }
                         rRequest.Done();
                     }

Reply via email to