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:11 +0200 |
commit | dd7e03fe7f1d913b8fad2ade6d3c04d02c0cf92c (patch) | |
tree | cb0310950f955195599cd383a9209267eb333a66 /desktop/source/lib | |
parent | 33ca999cb238246709494285bb27d85745e7d112 (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/+/165711
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'desktop/source/lib')
-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 3963b86eab34..9b49a9c934a6 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3354,6 +3354,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"); @@ -3503,6 +3516,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) { @@ -3510,10 +3524,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; @@ -5903,15 +5928,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; |