sd/source/ui/dlg/headerfooterdlg.cxx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
New commits: commit 6ff74883ec3e6ca6b1552968306556f8a921aa23 Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Tue Feb 27 09:57:35 2024 -0500 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Tue Mar 12 18:49:31 2024 +1030 tdf#159927 sd headerfooterdlg: detect existing date/time language Sometimes it was hard to change an existing foreign language to your own language for Impress' header/footer fields. The function was only checking the first master slide for the date/time language. If it didn't have one, then the default locale was selected. However, although all pages share the same date/time language, it is not necessary for all (or even the first) master slide to have a date/time field. So check through all the master slides until one with a date/time is found. Obviously if none have one defined things still work OK, because that is effectively how it was working beforehand. I don't have much hope for a successful unit test. I'll try to develop it as a follow-up to this patch. Change-Id: Ida44957013978720ad12fadc9b4ebc88bc10ea40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164045 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> (cherry picked from commit 62323124f54885c6de4ac4fa38052d380309a5a1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164506 Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 703cc8d674d81573a1e6191a12cec4012cca22f7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164671 (cherry picked from commit 2dd2471290acf4d1229cca7b43719e57242cd59e) diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx index 0c0786d3eebb..1f5ada44cf33 100644 --- a/sd/source/ui/dlg/headerfooterdlg.cxx +++ b/sd/source/ui/dlg/headerfooterdlg.cxx @@ -151,7 +151,8 @@ private: void FillFormatList(sal_Int32 nSelectedPos); void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet ); - void GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage ); + // returns true if the page has a date/time field item + bool GetOrSetDateTimeLanguage(LanguageType& rLanguage, bool bSet, SdPage* pPage); public: HeaderFooterTabPage(weld::Container* pParent, SdDrawDocument* pDoc, SdPage* pActualPage, bool bHandoutMode ); @@ -535,25 +536,29 @@ void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, boo } else { - // get the language from the first master page - // or set it to all master pages - sal_uInt16 nPageCount = bSet ? mpDoc->GetMasterSdPageCount( PageKind::Notes ) : 1; + const sal_uInt16 nPageCount = mpDoc->GetMasterSdPageCount(PageKind::Standard); sal_uInt16 nPage; for( nPage = 0; nPage < nPageCount; nPage++ ) { - GetOrSetDateTimeLanguage( rLanguage, bSet, mpDoc->GetMasterSdPage( nPage, PageKind::Standard ) ); + SdPage* pMasterSlide = mpDoc->GetMasterSdPage(nPage, PageKind::Standard); + bool bHasDateFieldItem = GetOrSetDateTimeLanguage(rLanguage, bSet, pMasterSlide); + + // All pages must use the same language. If getting the language, only need to find one. + if (!bSet && bHasDateFieldItem) + break; } } } -void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, bool bSet, SdPage* pPage ) +bool HeaderFooterTabPage::GetOrSetDateTimeLanguage(LanguageType& rLanguage, bool bSet, + SdPage* pPage) { if( !pPage ) - return; + return false; SdrTextObj* pObj = static_cast<SdrTextObj*>(pPage->GetPresObj( PresObjKind::DateTime )); if( !pObj ) - return; + return false; Outliner* pOutl = mpDoc->GetInternalOutliner(); pOutl->Init( OutlinerMode::TextObject ); @@ -623,6 +628,7 @@ void HeaderFooterTabPage::GetOrSetDateTimeLanguage( LanguageType &rLanguage, boo pOutl->Clear(); pOutl->Init( nOutlMode ); + return bHasDateFieldItem; } PresLayoutPreview::PresLayoutPreview()