How to get a BColor from a oox::drawingml::Color?

MS Office uses color interpolations in SmartArt diagrams. During import I get a color as oox:drawingml::Color from e.g. <a:schemeClr> element, for example, including color transformations such as tint, shade or lumMod. For calculating an interpolation between two colors, I need the resolved colors with applied color transformations. The oox::drawingml::Color class has a method

::Color getColor( const GraphicHelper& rGraphicHelper, ::Color nPhClr = API_RGB_TRANSPARENT ) const;

for that.
However, that needs a GraphicHelper. I need the interpolation inside the SmartArtDiagram class or inside the DiagramColor struct. How can I get a GraphicHelper there?

Or is there a different way to get the final color of a oox::drawingml::Color?

Hi Regina,

Generally, we would want to write a ComplexColor so we can later change if the document theme changes, but I guess you first want to just resolve the correct color only. We can do ComplexColor conversion later on as you would (currently) need to resolve the color anyway.

To resolve the color you need access to the theme / scheme, so this is why GraphicHelper is needed as that one has the information stored.

I guess the best is to create a new local variable to store the GraphicHelper in SmartArtDiagram and set it on construction. I see in diagram.cxx:575 (I guess this is where it’s constructed.. didn’t search for alternatives):
DiagramPtr pDiagram = std::make_shared<SmartArtDiagram>();

You have core::XmlFilterBase& rFilter as parameter to the loadDiagram function and you can then do:
rFilter.getGraphicHelper() to get the GraphicHelper. And set that to SmartArtDiagram.

Then you can resolve that the way you already described.

As for the struct DiagramColor - where exactly would you need to resolve the color?

Tomaž

It needs to be done in `bool LayoutNode::setupShape( const SmartArtDiagram& rDgm, const ShapePtr& rShape, const svx::diagram::Point* pPresNode, sal_Int32 nCurrIdx ) const`

There it needs to replace the unsuitable method DiagramColor::getColorByIndex(), in ~ #2002 to #2016. If rDgm has a GraphicHelper it could be forwarded to a method in DiagramColor. I’m only wondering what to do if we have to re-layout an already imported diagram.

The ctor of a GraphicHelper requires a const css::uno::Reference< css::frame::XFrame >& rxTargetFrame and a StorageRef xStorage . However, they are not needed for its color parts. Thus I thought about defining a ColorHelper without that and deriving the GraphicHelper from it. Or is there a way to use the ctor with an “empty” rxTargetFrame and “empty” xStorage?

OK, I need to look into this.