sd/source/console/PresenterToolBar.cxx |   97 +++++++++++----------------------
 sd/source/console/PresenterToolBar.hxx |    4 -
 2 files changed, 35 insertions(+), 66 deletions(-)

New commits:
commit d6057f8c1da86a3e43812e77f3975e56afaa2365
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 16 10:16:08 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri May 16 20:17:26 2025 +0200

    sd presenter: Drop PresenterToolBar::Context class
    
    It only holds an XCanvas reference and is used to
    pass that one around.
    Instead, just pass the canvas directly.
    
    Change-Id: Ibab2d568c5d6100ff391f9fab2f073d0b94fe2f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185390
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sd/source/console/PresenterToolBar.cxx 
b/sd/source/console/PresenterToolBar.cxx
index 94ef69d61933..ef6299b3655c 100644
--- a/sd/source/console/PresenterToolBar.cxx
+++ b/sd/source/console/PresenterToolBar.cxx
@@ -92,21 +92,12 @@ public:
         const Reference<beans::XPropertySet>& rxProperties,
         const OUString& rsModeName,
         std::shared_ptr<ElementMode> const & rpDefaultMode,
-        ::sdext::presenter::PresenterToolBar::Context const & rContext);
+        const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
 };
 typedef std::shared_ptr<ElementMode> SharedElementMode;
 
 }  // end of anonymous namespace
 
-class PresenterToolBar::Context
-{
-public:
-    Context() = default;
-    Context(const Context&) = delete;
-    Context& operator=(const Context&) = delete;
-    css::uno::Reference<css::rendering::XCanvas> mxCanvas;
-};
-
 //===== PresenterToolBar::Element =============================================
 
 typedef cppu::WeakComponentImplHelper<
@@ -587,23 +578,20 @@ void PresenterToolBar::CreateControls (
     Reference<container::XNameAccess> xEntries (
         PresenterConfigurationAccess::GetConfigurationNode(xToolBarNode, 
u"Entries"_ustr),
         UNO_QUERY);
-    Context aContext;
-    aContext.mxCanvas = mxCanvas;
-    if (xEntries.is()
-        && aContext.mxCanvas.is())
+    if (xEntries.is() && mxCanvas.is())
     {
         PresenterConfigurationAccess::ForAll(
             xEntries,
-            [this, &aContext] (OUString const&, 
uno::Reference<beans::XPropertySet> const& xProps)
+            [this] (OUString const&, uno::Reference<beans::XPropertySet> 
const& xProps)
             {
-                return this->ProcessEntry(xProps, aContext);
+                return this->ProcessEntry(xProps, mxCanvas);
             });
     }
 }
 
 void PresenterToolBar::ProcessEntry (
     const Reference<beans::XPropertySet>& rxProperties,
-    Context const & rContext)
+    const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
 {
     if ( ! rxProperties.is())
         return;
@@ -619,11 +607,11 @@ void PresenterToolBar::ProcessEntry (
     SharedElementMode pSelectedMode = std::make_shared<ElementMode>();
     SharedElementMode pDisabledMode = std::make_shared<ElementMode>();
     SharedElementMode pMouseOverSelectedMode = std::make_shared<ElementMode>();
-    pNormalMode->ReadElementMode(rxProperties, u"Normal"_ustr, pNormalMode, 
rContext);
-    pMouseOverMode->ReadElementMode(rxProperties, u"MouseOver"_ustr, 
pNormalMode, rContext);
-    pSelectedMode->ReadElementMode(rxProperties, u"Selected"_ustr, 
pNormalMode, rContext);
-    pDisabledMode->ReadElementMode(rxProperties, u"Disabled"_ustr, 
pNormalMode, rContext);
-    pMouseOverSelectedMode->ReadElementMode(rxProperties, 
u"MouseOverSelected"_ustr, pSelectedMode, rContext);
+    pNormalMode->ReadElementMode(rxProperties, u"Normal"_ustr, pNormalMode, 
rxCanvas);
+    pMouseOverMode->ReadElementMode(rxProperties, u"MouseOver"_ustr, 
pNormalMode, rxCanvas);
+    pSelectedMode->ReadElementMode(rxProperties, u"Selected"_ustr, 
pNormalMode, rxCanvas);
+    pDisabledMode->ReadElementMode(rxProperties, u"Disabled"_ustr, 
pNormalMode, rxCanvas);
+    pMouseOverSelectedMode->ReadElementMode(rxProperties, 
u"MouseOverSelected"_ustr, pSelectedMode, rxCanvas);
 
     // Create new element.
     ::rtl::Reference<Element> pElement;
@@ -1283,7 +1271,7 @@ void ElementMode::ReadElementMode (
     const Reference<beans::XPropertySet>& rxElementProperties,
     const OUString& rsModeName,
     std::shared_ptr<ElementMode> const & rpDefaultMode,
-    ::sdext::presenter::PresenterToolBar::Context const & rContext)
+    const css::uno::Reference<css::rendering::XCanvas>& rxCanvas)
 {
     try
     {
@@ -1322,7 +1310,7 @@ void ElementMode::ReadElementMode (
     Reference<container::XHierarchicalNameAccess> xIconNode (
         PresenterConfigurationAccess::GetProperty(xProperties, u"Icon"_ustr), 
UNO_QUERY);
     mpIcon = PresenterBitmapContainer::LoadBitmap(
-        xIconNode, u""_ustr, rContext.mxCanvas,
+        xIconNode, u""_ustr, rxCanvas,
         rpDefaultMode != nullptr ? rpDefaultMode->mpIcon : 
SharedBitmapDescriptor());
     }
     catch(Exception&)
diff --git a/sd/source/console/PresenterToolBar.hxx 
b/sd/source/console/PresenterToolBar.hxx
index 9cf00e589f63..530c4f66b92d 100644
--- a/sd/source/console/PresenterToolBar.hxx
+++ b/sd/source/console/PresenterToolBar.hxx
@@ -133,8 +133,6 @@ public:
         const css::uno::Reference<css::drawing::XDrawPage>& rxSlide) override;
 
     virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL 
getCurrentPage() override;
-
-    class Context;
     class Element;
 
 private:
@@ -183,7 +181,7 @@ private:
 
     void ProcessEntry (
         const css::uno::Reference<css::beans::XPropertySet>& rProperties,
-        Context const & rContext);
+        const css::uno::Reference<css::rendering::XCanvas>& rxCanvas);
 
     /** @throws css::lang::DisposedException when the object has already been
         disposed.
commit 2239a785440800707f26d054e30ef77b3b9f4ba2
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 16 09:50:03 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri May 16 20:17:19 2025 +0200

    sd presenter: Reduce var scope
    
    And rename the variable in the else block to
    `aElementSize` as well.
    
    Change-Id: I0973c21a8fc70aa6d806a163babc2f8311539c9d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185389
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sd/source/console/PresenterToolBar.cxx 
b/sd/source/console/PresenterToolBar.cxx
index da261cd2c4fd..94ef69d61933 100644
--- a/sd/source/console/PresenterToolBar.cxx
+++ b/sd/source/console/PresenterToolBar.cxx
@@ -848,9 +848,9 @@ void PresenterToolBar::LayoutPart (
             if (iElement->get() == nullptr)
                 continue;
 
-            const awt::Size aElementSize 
((*iElement)->GetBoundingSize(rxCanvas));
             if (bIsHorizontal)
             {
+                const awt::Size aElementSize 
((*iElement)->GetBoundingSize(rxCanvas));
                 if ((*iElement)->IsFilling())
                 {
                     nY = rBoundingBox.Y1;
@@ -870,16 +870,16 @@ void PresenterToolBar::LayoutPart (
                 else if (iElement == iFirst - 2){
                     iElement = iFirst;
                 }
-                const awt::Size aNewElementSize 
((*iElement)->GetBoundingSize(rxCanvas));
+                const awt::Size aElementSize 
((*iElement)->GetBoundingSize(rxCanvas));
                 if ((*iElement)->IsFilling())
                 {
                     nX = rBoundingBox.X1;
-                    (*iElement)->SetSize(geometry::RealSize2D(rBoundingBox.X2 
- rBoundingBox.X1, aNewElementSize.Height));
+                    (*iElement)->SetSize(geometry::RealSize2D(rBoundingBox.X2 
- rBoundingBox.X1, aElementSize.Height));
                 }
                 else
-                    nX = rBoundingBox.X1 + (rBoundingBox.X2-rBoundingBox.X1 - 
aNewElementSize.Width) / 2;
+                    nX = rBoundingBox.X1 + (rBoundingBox.X2-rBoundingBox.X1 - 
aElementSize.Width) / 2;
                 (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), 
sal_Int32(0.5 + nY)));
-                nY += aNewElementSize.Height + nGap;
+                nY += aElementSize.Height + nGap;
 
                 // return the index as it was before the reversing
                 if (iElement == iFirst)
commit 6f0805563f850b0756d42fd793a63ba91868a74a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri May 16 09:27:16 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri May 16 20:17:13 2025 +0200

    tdf#160094 sd presenter: Deduplicate RTL and non-RTL code paths
    
    The loop body is the same, the only difference is the
    direction of the iteration (forward or backward).
    
    Change-Id: Ie05cbfa549948e76d0e08daff58cb8e20d0f955a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185383
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sd/source/console/PresenterToolBar.cxx 
b/sd/source/console/PresenterToolBar.cxx
index 4444bf1a7fc2..da261cd2c4fd 100644
--- a/sd/source/console/PresenterToolBar.cxx
+++ b/sd/source/console/PresenterToolBar.cxx
@@ -725,42 +725,25 @@ void PresenterToolBar::Layout (
     double nY ((aWindowBox.Height - aTotalSize.Height) / 2);
     bIsHorizontal = true;
 
-    /* push front or back ? ... */
-    /// check whether RTL interface or not
-    if(!AllSettings::GetLayoutRTL()){
-        for (const auto& rxPart : maElementContainer)
-        {
-            geometry::RealRectangle2D aBoundingBox(
-                nX, nY,
-                nX + aPartSizes[rxPart].Width, nY + aTotalSize.Height);
+    auto aFunc = [&](const SharedElementContainerPart& rxPart)
+    {
+        geometry::RealRectangle2D aBoundingBox(nX, nY, nX + 
aPartSizes[rxPart].Width,
+                                               nY + aTotalSize.Height);
 
-            // Add space for gaps between elements.
-            if (rxPart->size() > 1 && bIsHorizontal)
-                aBoundingBox.X2 += (rxPart->size() - 1) * nGapWidth;
+        // Add space for gaps between elements.
+        if (rxPart->size() > 1 && bIsHorizontal)
+            aBoundingBox.X2 += (rxPart->size() - 1) * nGapWidth;
 
-            LayoutPart(rxCanvas, rxPart, aBoundingBox, aPartSizes[rxPart], 
bIsHorizontal);
-            bIsHorizontal = !bIsHorizontal;
-            nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
-        }
-    }
-    else {
-        ElementContainer::reverse_iterator iPart;
-        for (iPart = maElementContainer.rbegin(); iPart != 
maElementContainer.rend(); ++iPart)
-        {
-            geometry::RealRectangle2D aBoundingBox(
-                nX, nY,
-                nX + aPartSizes[*iPart].Width, nY + aTotalSize.Height);
-
-            // Add space for gaps between elements.
-            if ((*iPart)->size() > 1)
-                if (bIsHorizontal)
-                    aBoundingBox.X2 += ((*iPart)->size()-1) * nGapWidth;
-
-            LayoutPart(rxCanvas, *iPart, aBoundingBox, aPartSizes[*iPart], 
bIsHorizontal);
-            bIsHorizontal = !bIsHorizontal;
-            nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
-        }
-    }
+        LayoutPart(rxCanvas, rxPart, aBoundingBox, aPartSizes[rxPart], 
bIsHorizontal);
+        bIsHorizontal = !bIsHorizontal;
+        nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
+    };
+
+    // process in reverse order for RTL
+    if (!AllSettings::GetLayoutRTL())
+        std::for_each(maElementContainer.begin(), maElementContainer.end(), 
aFunc);
+    else
+        std::for_each(maElementContainer.rbegin(), maElementContainer.rend(), 
aFunc);
 
     // The whole window has to be repainted.
     std::shared_ptr<PresenterPaintManager> 
xManager(mpPresenterController->GetPaintManager());

Reply via email to