diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-06 20:19:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-07 10:04:09 +0000 |
commit | dab143489838c0b91eadc8bf7f9d7e2537336751 (patch) | |
tree | e3a5f5bf5a03c387aa6f3b9e764486546df67ced | |
parent | c2bcbd36d1913dc1d5ca4bb64fa30740f17bf326 (diff) |
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 <caolanm@redhat.com>
-rw-r--r-- | starmath/source/ElementsDockingWindow.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
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); |