From 86fcdf240ccdbecd051498d0b1e76a698aab5e89 Mon Sep 17 00:00:00 2001 From: panoskorovesis Date: Sat, 31 Jul 2021 14:11:52 +0300 Subject: Add Handler for Polygon Write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handler separates MetaPolygonHandler::Write from metaact.hxx Write implementation is now in SvmWriter.hxx Change-Id: Iffc665603db1bf1eea6b201e8975900a65f28a33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119738 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- include/vcl/filter/SvmWriter.hxx | 1 + vcl/source/filter/svm/SvmWriter.cxx | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/vcl/filter/SvmWriter.hxx b/include/vcl/filter/SvmWriter.hxx index 891c3853e1ba..393fb19f672f 100644 --- a/include/vcl/filter/SvmWriter.hxx +++ b/include/vcl/filter/SvmWriter.hxx @@ -49,4 +49,5 @@ public: void PieHandler(MetaPieAction* pAction); void ChordHandler(MetaChordAction* pAction); void PolyLineHandler(MetaPolyLineAction* pAction); + void PolygonHandler(MetaPolygonAction* pAction); }; \ No newline at end of file diff --git a/vcl/source/filter/svm/SvmWriter.cxx b/vcl/source/filter/svm/SvmWriter.cxx index eb64c40e7fdd..6a3a88f78b79 100644 --- a/vcl/source/filter/svm/SvmWriter.cxx +++ b/vcl/source/filter/svm/SvmWriter.cxx @@ -148,6 +148,13 @@ void SvmWriter::MetaActionHandler(MetaAction* pAction, ImplMetaWriteData* pData) } break; + case MetaActionType::POLYGON: + { + auto* pMetaAction = static_cast(pAction); + PolygonHandler(pMetaAction); + } + break; + /* default case prevents test failure and will be removed once all the handlers are completed */ default: @@ -269,4 +276,20 @@ void SvmWriter::PolyLineHandler(MetaPolyLineAction* pAction) if (bHasPolyFlags) pAction->GetPolygon().Write(mrStream); } + +void SvmWriter::PolygonHandler(MetaPolygonAction* pAction) +{ + mrStream.WriteUInt16(static_cast(pAction->GetType())); + + VersionCompatWrite aCompat(mrStream, 2); + + tools::Polygon aSimplePoly; // Version 1 + pAction->GetPolygon().AdaptiveSubdivide(aSimplePoly); + WritePolygon(mrStream, aSimplePoly); + + bool bHasPolyFlags = pAction->GetPolygon().HasFlags(); // Version 2 + mrStream.WriteBool(bHasPolyFlags); + if (bHasPolyFlags) + pAction->GetPolygon().Write(mrStream); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3