starmath/source/ElementsDockingWindow.cxx |   33 ++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

New commits:
commit dab143489838c0b91eadc8bf7f9d7e2537336751
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Dec 6 20:19:11 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Dec 7 10:04:09 2022 +0000

    Resolves: tdf#152392 use sidebar text color for COL_AUTO in examples
    
    Change-Id: I5f5c1a6c79c65bd1d4bf2de4af02bef5d60ee5c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143745
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/starmath/source/ElementsDockingWindow.cxx 
b/starmath/source/ElementsDockingWindow.cxx
index e768726eada5..16a22d27aa00 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -493,6 +493,37 @@ Color SmElementsControl::GetControlBackground()
     return rStyleSettings.GetFieldColor();
 }
 
+namespace
+{
+    // SmTmpDevice::GetTextColor assumes a fg/bg of 
svtools::FONTCOLOR/svtools::DOCCOLOR
+    // here replace COL_AUTO with the desired fg color, alternatively could 
add something
+    // to SmTmpDevice to override its defaults
+    class AutoColorVisitor : public SmDefaultingVisitor
+    {
+    private:
+        Color m_aAutoColor;
+    public:
+        AutoColorVisitor(SmNode* pNode, Color aAutoColor)
+            : m_aAutoColor(aAutoColor)
+        {
+            DefaultVisit(pNode);
+        }
+        virtual void DefaultVisit(SmNode* pNode) override
+        {
+            if (pNode->GetFont().GetColor() == COL_AUTO)
+                pNode->GetFont().SetColor(m_aAutoColor);
+            size_t nNodes = pNode->GetNumSubNodes();
+            for (size_t i = 0; i < nNodes; ++i)
+            {
+                SmNode* pChild = pNode->GetSubNode(i);
+                if (!pChild)
+                    continue;
+                DefaultVisit(pChild);
+            }
+        }
+    };
+}
+
 void SmElementsControl::addElement(const OUString& aElementVisual, const 
OUString& aElementSource, const OUString& aHelpText)
 {
     std::unique_ptr<SmNode> pNode = maParser->ParseExpression(aElementVisual);
@@ -509,6 +540,8 @@ void SmElementsControl::addElement(const OUString& 
aElementVisual, const OUStrin
     pNode->SetSize(Fraction(10,8));
     pNode->Arrange(*pDevice, maFormat);
 
+    AutoColorVisitor(pNode.get(), GetTextColor());
+
     Size aSize = pDevice->LogicToPixel(Size(pNode->GetWidth(), 
pNode->GetHeight()));
     aSize.extendBy(10, 0); // Add 5 pixels from both sides to accommodate 
extending parts of italics
     pDevice->SetOutputSizePixel(aSize);

Reply via email to