sd/source/console/PresenterAccessibility.cxx | 6 - sd/source/console/PresenterController.cxx | 90 +++++++++++++++------------ sd/source/console/PresenterPaneBase.cxx | 5 - sd/source/console/PresenterPaneBase.hxx | 1 4 files changed, 52 insertions(+), 50 deletions(-)
New commits: commit fbe9b2b6b080f25e258bf2134322067019cba473 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed May 14 16:30:41 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 15 06:50:44 2025 +0200 sd: Extract helper method to replace placeholders It will be reused in an upcoming commit. Change-Id: I894dad466522ec388a7057246af487214ddef7af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185323 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sd/source/console/PresenterController.cxx b/sd/source/console/PresenterController.cxx index 55114cacca01..bfa766f4a8fb 100644 --- a/sd/source/console/PresenterController.cxx +++ b/sd/source/console/PresenterController.cxx @@ -272,16 +272,59 @@ void PresenterController::GetSlides (const sal_Int32 nOffset) } } +namespace +{ +OUString lcl_replacePlaceholders(const OUString& rTemplate, std::u16string_view sCurrentSlideNumber, + std::u16string_view sCurrentSlideName, std::u16string_view sSlideCount) +{ + // Placeholders + static constexpr OUStringLiteral sCurrentSlideNumberPlaceholder(u"CURRENT_SLIDE_NUMBER"); + static constexpr OUStringLiteral sCurrentSlideNamePlaceholder(u"CURRENT_SLIDE_NAME"); + static constexpr OUStringLiteral sSlideCountPlaceholder(u"SLIDE_COUNT"); + + OUStringBuffer sResult; + sResult.ensureCapacity(rTemplate.getLength()); + + sal_Int32 nIndex (0); + while (true) + { + sal_Int32 nStartIndex = rTemplate.indexOf('%', nIndex); + if (nStartIndex < 0) + { + // Add the remaining part of the string. + sResult.append(rTemplate.subView(nIndex)); + break; + } + else + { + // Add the part preceding the next %. + sResult.append(rTemplate.subView(nIndex, nStartIndex-nIndex)); + + // Get the placeholder + ++nStartIndex; + const sal_Int32 nEndIndex (rTemplate.indexOf('%', nStartIndex+1)); + const std::u16string_view sPlaceholder (rTemplate.subView(nStartIndex, nEndIndex-nStartIndex)); + nIndex = nEndIndex+1; + + // Replace the placeholder with its current value. + if (sPlaceholder == sCurrentSlideNumberPlaceholder) + sResult.append(sCurrentSlideNumber); + else if (sPlaceholder == sCurrentSlideNamePlaceholder) + sResult.append(sCurrentSlideName); + else if (sPlaceholder == sSlideCountPlaceholder) + sResult.append(sSlideCount); + } + } + + return sResult.makeStringAndClear(); +} +} + void PresenterController::UpdatePaneTitles() { if ( ! mxSlideShowController.is()) return; - // Get placeholders and their values. - static constexpr OUStringLiteral sCurrentSlideNumberPlaceholder (u"CURRENT_SLIDE_NUMBER"); - static constexpr OUStringLiteral sCurrentSlideNamePlaceholder (u"CURRENT_SLIDE_NAME"); - static constexpr OUStringLiteral sSlideCountPlaceholder (u"SLIDE_COUNT"); - // Get string for slide count. const OUString sSlideCount = OUString::number(mxSlideShowController->getSlideCount()); @@ -323,41 +366,8 @@ void PresenterController::UpdatePaneTitles() if (sTemplate.isEmpty()) continue; - OUStringBuffer sResult; - sResult.ensureCapacity(sTemplate.getLength()); - - sal_Int32 nIndex (0); - while (true) - { - sal_Int32 nStartIndex = sTemplate.indexOf('%', nIndex); - if (nStartIndex < 0) - { - // Add the remaining part of the string. - sResult.append(sTemplate.subView(nIndex)); - break; - } - else - { - // Add the part preceding the next %. - sResult.append(sTemplate.subView(nIndex, nStartIndex-nIndex)); - - // Get the placeholder - ++nStartIndex; - const sal_Int32 nEndIndex (sTemplate.indexOf('%', nStartIndex+1)); - const std::u16string_view sPlaceholder (sTemplate.subView(nStartIndex, nEndIndex-nStartIndex)); - nIndex = nEndIndex+1; - - // Replace the placeholder with its current value. - if (sPlaceholder == sCurrentSlideNumberPlaceholder) - sResult.append(sCurrentSlideNumber); - else if (sPlaceholder == sCurrentSlideNamePlaceholder) - sResult.append(sCurrentSlideName); - else if (sPlaceholder == sSlideCountPlaceholder) - sResult.append(sSlideCount); - } - } - - rxPane->msTitle = sResult.makeStringAndClear(); + rxPane->msTitle = lcl_replacePlaceholders(sTemplate, sCurrentSlideNumber, sCurrentSlideName, + sSlideCount); if (rxPane->mxPane.is()) rxPane->mxPane->SetTitle(rxPane->msTitle); } commit 529785d458488aa6d176a68ce02f227cdaa7c4c5 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed May 14 16:13:56 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 15 06:50:38 2025 +0200 sd a11: Drop PresenterPaneBase::GetTitle Instead, pass the value of SharedPaneDescriptor::msTitle to as the accessible name, which is the same, as PresenterPaneBase::msName gets set to the same value. Change-Id: Ia916ecdfd7a44d81975bcd5ea195a42575a6eb8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185322 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sd/source/console/PresenterAccessibility.cxx b/sd/source/console/PresenterAccessibility.cxx index 8ede63632980..3631bb279232 100644 --- a/sd/source/console/PresenterAccessibility.cxx +++ b/sd/source/console/PresenterAccessibility.cxx @@ -163,7 +163,7 @@ void PresenterAccessible::UpdateAccessibilityHierarchy() UpdateAccessibilityHierarchy( pPreviewPane ? pPreviewPane->mxContentWindow : Reference<awt::XWindow>(), pPreviewPane ? pPreviewPane->mxBorderWindow : Reference<awt::XWindow>(), - (pPreviewPane&&pPreviewPane->mxPane.is()) ? pPreviewPane->mxPane->GetTitle() : OUString(), + pPreviewPane ? pPreviewPane->msTitle : OUString(), pNotesPane ? pNotesPane->mxContentWindow : Reference<awt::XWindow>(), pNotesPane ? pNotesPane->mxBorderWindow : Reference<awt::XWindow>(), pNotesView.is() @@ -233,9 +233,7 @@ void PresenterAccessible::NotifyCurrentSlideChange () { PresenterPaneContainer::SharedPaneDescriptor pPreviewPane (GetPreviewPane()); mpAccessiblePreview->SetAccessibleName( - pPreviewPane&&pPreviewPane->mxPane.is() - ? pPreviewPane->mxPane->GetTitle() - : OUString()); + pPreviewPane ? pPreviewPane->msTitle : OUString()); } // Play some focus ping-pong to trigger AT tools. diff --git a/sd/source/console/PresenterPaneBase.cxx b/sd/source/console/PresenterPaneBase.cxx index bd60b2082377..aa9daf666eb3 100644 --- a/sd/source/console/PresenterPaneBase.cxx +++ b/sd/source/console/PresenterPaneBase.cxx @@ -94,11 +94,6 @@ void PresenterPaneBase::SetTitle (const OUString& rsTitle) mpPresenterController->GetPaintManager()->Invalidate(mxBorderWindow); } -const OUString& PresenterPaneBase::GetTitle() const -{ - return msTitle; -} - const rtl::Reference<PresenterPaneBorderPainter>& PresenterPaneBase::GetPaneBorderPainter() const { diff --git a/sd/source/console/PresenterPaneBase.hxx b/sd/source/console/PresenterPaneBase.hxx index a7308c8e721b..746be4ac9b0e 100644 --- a/sd/source/console/PresenterPaneBase.hxx +++ b/sd/source/console/PresenterPaneBase.hxx @@ -64,7 +64,6 @@ public: const css::uno::Reference<css::awt::XWindow>& GetBorderWindow() const; void SetTitle (const OUString& rsTitle); - const OUString& GetTitle() const; const rtl::Reference<PresenterPaneBorderPainter>& GetPaneBorderPainter() const; void initialize(const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,