diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2022-12-23 13:02:57 -0500 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-01-29 13:22:28 +0000 |
commit | e2d646665c4cb4c7eeb0a73cb5f460838589bef0 (patch) | |
tree | 42987bdec2a8e09af3b6cf70ad2b244c01d92136 /sfx2 | |
parent | e3e259d551c0c8b7c106191f2c258e5929db1b29 (diff) |
lok: support per-user timezone
This adds support for user-specific timezone.
When none is provided during loading, the
system default is used.
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: Ie863450687eb82bc475268a09c9112e9fd50020f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144816
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
(cherry picked from commit abaf8c0af1c6c7fe01276fdf2ae62419c7b0f654)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146211
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 42 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 4 |
2 files changed, 46 insertions, 0 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 794dcc00b300..53c2abace8b5 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -76,6 +76,8 @@ namespace LanguageTag g_defaultLanguageTag("en-US", true); LanguageTag g_loadLanguageTag("en-US", true); //< The language used to load. LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN; +bool g_isDefaultTimezoneSet = false; +OUString g_DefaultTimezone; } int SfxLokHelper::createView(SfxViewFrame* pViewFrame, ViewShellDocId docId) @@ -339,6 +341,46 @@ void SfxLokHelper::setDeviceFormFactor(std::u16string_view rDeviceFormFactor) g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN; } +void SfxLokHelper::setDefaultTimezone(bool isSet, const OUString& rTimezone) +{ + g_isDefaultTimezoneSet = isSet; + g_DefaultTimezone = rTimezone; +} + +std::pair<bool, OUString> SfxLokHelper::getDefaultTimezone() +{ + return { g_isDefaultTimezoneSet, g_DefaultTimezone }; +} + +void SfxLokHelper::setViewTimezone(int nId, bool isSet, const OUString& rTimezone) +{ + std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl(); + + for (SfxViewShell* pViewShell : rViewArr) + { + if (pViewShell->GetViewShellId() == ViewShellId(nId)) + { + pViewShell->SetLOKTimezone(isSet, rTimezone); + return; + } + } +} + +std::pair<bool, OUString> SfxLokHelper::getViewTimezone(int nId) +{ + std::vector<SfxViewShell*>& rViewArr = SfxGetpApp()->GetViewShells_Impl(); + + for (SfxViewShell* pViewShell : rViewArr) + { + if (pViewShell->GetViewShellId() == ViewShellId(nId)) + { + return pViewShell->GetLOKTimezone(); + } + } + + return {}; +} + /* * Used for putting a whole JSON string into a string value * e.g { key: "{JSON}" } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 1d494878a0a2..cd4ffe676f2b 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1083,6 +1083,10 @@ SfxViewShell::SfxViewShell maLOKLanguageTag = SfxLokHelper::getDefaultLanguage(); maLOKLocale = SfxLokHelper::getDefaultLanguage(); + const auto [isTimezoneSet, aTimezone] = SfxLokHelper::getDefaultTimezone(); + maLOKIsTimezoneSet = isTimezoneSet; + maLOKTimezone = aTimezone; + maLOKDeviceFormFactor = SfxLokHelper::getDeviceFormFactor(); vcl::Window* pFrameWin = pViewFrame->GetWindow().GetFrameWindow(); |