sd/source/ui/tools/SlideshowLayerRenderer.cxx | 73 +++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-)
New commits: commit 38844eb676b28edafd31a57b9c1a9aa2a0dde4fb Author: Marco Cecchetti <marco.cecche...@collabora.com> AuthorDate: Sun Nov 3 18:22:38 2024 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Nov 11 10:21:44 2024 +0100 lok: slideshow: send fill, line, font colors for an animated layer We improved the information collected when a layer to be animated is renderered. When the fill style is solid we send the fill color for the animated shape, so that on the client we can check per each texel if it is part of the shape fill and in case substitute the original fill color with the color computed by the animation. The same is done for the line color. Moreover, in case the animated object is a paragraph, we send the font color. Change-Id: Iffca357879ef13489c5d943fb5c6faeeaca0d1b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176169 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 18b4f88703bc..ca831bd2ad27 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -18,6 +18,10 @@ #include <svx/svdpagv.hxx> #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <svx/unoshape.hxx> +#include <svx/xfillit0.hxx> +#include <svx/xlineit0.hxx> +#include <svx/xflclit.hxx> +#include <svx/xlnclit.hxx> #include <vcl/virdev.hxx> #include <tools/json_writer.hxx> @@ -705,8 +709,51 @@ void writeBoundingBox(::tools::JsonWriter& aJsonWriter, SdrObject* pObject) aJsonWriter.put("height", aRect.GetHeight()); } +uno::Reference<text::XTextRange> +getParagraphFromShape(int nPara, uno::Reference<beans::XPropertySet> const& xShape) +{ + uno::Reference<text::XText> xText + = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); + if (!xText.is()) + return {}; + + uno::Reference<container::XEnumerationAccess> paraEnumAccess(xText, uno::UNO_QUERY); + if (!paraEnumAccess.is()) + return {}; + uno::Reference<container::XEnumeration> paraEnum(paraEnumAccess->createEnumeration()); + if (!paraEnum.is()) + return {}; + + for (int i = 0; i < nPara; ++i) + paraEnum->nextElement(); + + uno::Reference<text::XTextRange> xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW); + + return xParagraph; +} + +void writeFontColor(::tools::JsonWriter& aJsonWriter, SdrObject* pObject, sal_Int32 nParagraph) +{ + uno::Reference<drawing::XShape> xShape = GetXShapeForSdrObject(pObject); + uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY_THROW); + if (!xShapePropSet.is()) + return; + + uno::Reference<text::XTextRange> xParagraph = getParagraphFromShape(nParagraph, xShapePropSet); + if (!xParagraph.is()) + return; + + uno::Reference<beans::XPropertySet> xPropSet(xParagraph->getStart(), uno::UNO_QUERY_THROW); + if (!xPropSet) + return; + + Color aCharColor; + xPropSet->getPropertyValue("CharColor") >>= aCharColor; + aJsonWriter.put("fontColor", "#" + aCharColor.AsRGBHEXString()); +} + void writeAnimated(::tools::JsonWriter& aJsonWriter, AnimationLayerInfo const& rLayerInfo, - SdrObject* pObject) + SdrObject* pObject, sal_Int32 nParagraph = -1) { aJsonWriter.put("type", "animated"); { @@ -720,6 +767,28 @@ void writeAnimated(::tools::JsonWriter& aJsonWriter, AnimationLayerInfo const& r aJsonWriter.put("type", "bitmap"); writeContentNode(aJsonWriter); writeBoundingBox(aJsonWriter, pObject); + + if (nParagraph < 0) + { + drawing::FillStyle aFillStyle + = pObject->GetProperties().GetItem(XATTR_FILLSTYLE).GetValue(); + if (aFillStyle == drawing::FillStyle::FillStyle_SOLID) + { + auto aFillColor = pObject->GetProperties().GetItem(XATTR_FILLCOLOR).GetColorValue(); + aJsonWriter.put("fillColor", "#" + aFillColor.AsRGBHEXString()); + } + drawing::LineStyle aLineStyle + = pObject->GetProperties().GetItem(XATTR_LINESTYLE).GetValue(); + if (aLineStyle == drawing::LineStyle::LineStyle_SOLID) + { + auto aLineColor = pObject->GetProperties().GetItem(XATTR_LINECOLOR).GetColorValue(); + aJsonWriter.put("lineColor", "#" + aLineColor.AsRGBHEXString()); + } + } + else + { + writeFontColor(aJsonWriter, pObject, nParagraph); + } } } @@ -758,7 +827,7 @@ void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg, RenderPass const& rRen auto aParagraphInfoIterator = rInfo.maParagraphInfos.find(nParagraph); if (aParagraphInfoIterator != rInfo.maParagraphInfos.end()) { - writeAnimated(aJsonWriter, aParagraphInfoIterator->second, pObject); + writeAnimated(aJsonWriter, aParagraphInfoIterator->second, pObject, nParagraph); } } else if (rInfo.moObjectInfo)