diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-04-03 00:08:45 +0530 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-04-03 14:26:01 +0200 |
commit | 4fcaf961e243fb0f03e42df380d9843ed2f2080c (patch) | |
tree | 89952672dc53e38ba602ea7fc358615a7a0d95d0 /desktop | |
parent | 91dfd7aac814bb47f1bdfc30b882238b42993bf7 (diff) |
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/+/165705
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index bfe4ff5fd699..2c4fba114092 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3382,6 +3382,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"); @@ -3531,6 +3544,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) { @@ -3538,10 +3552,21 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha bTakeOwnership = true; else if (rOption == "NoFileSync") aSaveMediaDescriptor[u"NoFileSync"_ustr] <<= 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[u"Overwrite"_ustr] <<= true; aSaveMediaDescriptor[u"FilterName"_ustr] <<= aFilterName; @@ -5931,15 +5956,7 @@ static void doc_resetSelection(LibreOfficeKitDocument* pThis) 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; |