desktop/source/lib/init.cxx    |   35 ++++++++++++++++++++++++++---------
 include/sfx2/dinfdlg.hxx       |    5 ++++-
 sfx2/sdi/sfx.sdi               |    2 +-
 sfx2/source/dialog/dinfdlg.cxx |   15 +++++++++++----
 sfx2/source/doc/objserv.cxx    |    8 +++++---
 5 files changed, 47 insertions(+), 18 deletions(-)

New commits:
commit 2d9396250b62a9b681c07996efd7145fd0fe5617
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 22 20:45:40 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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166454

diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 4d7487f554f4..c117cb548ea1 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -74,6 +74,7 @@ private:
     OUString                     m_Keywords;
     OUString                     m_Subject;
     OUString                     m_Title;
+    sal_Int64                    m_nFileSize;
     bool                         m_bHasTemplate;
     bool                         m_bDeleteUserData;
     bool                         m_bUseUserData;
@@ -87,7 +88,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;
 
@@ -124,6 +125,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 ea3340c426a3..388ec66fff71 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3327,7 +3327,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 ec37a70828e0..defda82085b6 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -179,6 +179,7 @@ SfxDocumentInfoItem::SfxDocumentInfoItem()
     , m_isAutoloadEnabled(false)
     , m_EditingCycles(0)
     , m_EditingDuration(0)
+    , m_nFileSize(-1)
     , m_bHasTemplate( true )
     , m_bDeleteUserData( false )
     , m_bUseUserData( true )
@@ -189,7 +190,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() )
@@ -209,6 +210,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 )
@@ -261,6 +263,7 @@ SfxDocumentInfoItem::SfxDocumentInfoItem( const 
SfxDocumentInfoItem& rItem )
     , m_Keywords( rItem.getKeywords() )
     , 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 )
@@ -1011,9 +1014,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 b5bde70a3ca6..1591b27d6d74 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -640,13 +640,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 );
                 if ( !GetSlotState( SID_DOCTEMPLATE ) )
                     // templates not supported
                     aDocInfoItem.SetTemplate(false);
@@ -662,7 +664,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)
                     {
@@ -679,7 +681,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();
                     }
commit 7e1ca157d2c5e9a77a5545d72014bc90ca8b7735
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Wed Apr 3 00:08:45 2024 +0530
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Apr 22 20:45:31 2024 +0200

    LOK: set creation date when online creates file from template
    
    problem:
    when online created file using WOPI clients, creation dates were never set.
    in online files are created using templates, even empty files are created 
using
    an empty template
    
    Change-Id: I3f022427745de7204faac9418620e2a87f9cf684
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165711
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166453
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 50f8bb24a378..81366621ec15 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3366,6 +3366,19 @@ static void lo_registerCallback (LibreOfficeKit* pThis,
     pApp->m_pCallbackData = pLib->mpCallbackData = pData;
 }
 
+static SfxObjectShell* getSfxObjectShell(LibreOfficeKitDocument* pThis)
+{
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+    if (!pDocument)
+        return nullptr;
+
+    SfxBaseModel* pBaseModel = 
dynamic_cast<SfxBaseModel*>(pDocument->mxComponent.get());
+    if (!pBaseModel)
+        return nullptr;
+
+    return pBaseModel->GetObjectShell();
+}
+
 static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const 
char* pFormat, const char* pFilterOptions)
 {
     comphelper::ProfileZone aZone("doc_saveAs");
@@ -3515,6 +3528,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, 
const char* sUrl, const cha
         const uno::Sequence<OUString> aOptionSeq = 
comphelper::string::convertCommaSeparated(aFilterOptions);
         std::vector<OUString> aFilteredOptionVec;
         bool bTakeOwnership = false;
+        bool bCreateFromTemplate = false;
         MediaDescriptor aSaveMediaDescriptor;
         for (const auto& rOption : aOptionSeq)
         {
@@ -3522,10 +3536,21 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, 
const char* sUrl, const cha
                 bTakeOwnership = true;
             else if (rOption == "NoFileSync")
                 aSaveMediaDescriptor["NoFileSync"] <<= true;
+            else if (rOption == "FromTemplate")
+                bCreateFromTemplate = true;
             else
                 aFilteredOptionVec.push_back(rOption);
         }
 
+        if (bCreateFromTemplate && bTakeOwnership)
+        {
+            if (SfxObjectShell* pObjectShell = getSfxObjectShell(pThis))
+            {
+                DateTime now( ::DateTime::SYSTEM );
+                
pObjectShell->getDocProperties()->setCreationDate(now.GetUNODateTime());
+            }
+        }
+
         aSaveMediaDescriptor["Overwrite"] <<= true;
         aSaveMediaDescriptor["FilterName"] <<= aFilterName;
 
@@ -5925,15 +5950,7 @@ static void addLocale(boost::property_tree::ptree& 
rValues, css::lang::Locale co
 
 static char* getDocReadOnly(LibreOfficeKitDocument* pThis)
 {
-    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-    if (!pDocument)
-        return nullptr;
-
-    SfxBaseModel* pBaseModel = 
dynamic_cast<SfxBaseModel*>(pDocument->mxComponent.get());
-    if (!pBaseModel)
-        return nullptr;
-
-    SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
+    SfxObjectShell* pObjectShell = getSfxObjectShell(pThis);
     if (!pObjectShell)
         return nullptr;
 

Reply via email to