From a3848e4e6b433e251c5e51f1e29d3c28d54a257c Mon Sep 17 00:00:00 2001 From: panoskorovesis Date: Mon, 2 Aug 2021 19:57:11 +0300 Subject: Add Handler for PolyPolygon Write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handler separates MetaPolyPolygonAction::Write from metaact.hxx Write implementation is now in SvmWriter.hxx Change-Id: I95b68a4ea561bf80fbe83363743ea91e3f973f7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119898 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/source/filter/svm/SvmWriter.cxx | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'vcl') diff --git a/vcl/source/filter/svm/SvmWriter.cxx b/vcl/source/filter/svm/SvmWriter.cxx index 6a3a88f78b79..fc4945274d6e 100644 --- a/vcl/source/filter/svm/SvmWriter.cxx +++ b/vcl/source/filter/svm/SvmWriter.cxx @@ -155,6 +155,13 @@ void SvmWriter::MetaActionHandler(MetaAction* pAction, ImplMetaWriteData* pData) } break; + case MetaActionType::POLYPOLYGON: + { + auto* pMetaAction = static_cast(pAction); + PolyPolygonHandler(pMetaAction); + } + break; + /* default case prevents test failure and will be removed once all the handlers are completed */ default: @@ -292,4 +299,38 @@ void SvmWriter::PolygonHandler(MetaPolygonAction* pAction) if (bHasPolyFlags) pAction->GetPolygon().Write(mrStream); } + +void SvmWriter::PolyPolygonHandler(MetaPolyPolygonAction* pAction) +{ + mrStream.WriteUInt16(static_cast(pAction->GetType())); + + VersionCompatWrite aCompat(mrStream, 2); + + sal_uInt16 nNumberOfComplexPolygons = 0; + sal_uInt16 i, nPolyCount = pAction->GetPolyPolygon().Count(); + + tools::Polygon aSimplePoly; // Version 1 + mrStream.WriteUInt16(nPolyCount); + for (i = 0; i < nPolyCount; i++) + { + const tools::Polygon& rPoly = pAction->GetPolyPolygon().GetObject(i); + if (rPoly.HasFlags()) + nNumberOfComplexPolygons++; + rPoly.AdaptiveSubdivide(aSimplePoly); + WritePolygon(mrStream, aSimplePoly); + } + + mrStream.WriteUInt16(nNumberOfComplexPolygons); // Version 2 + for (i = 0; nNumberOfComplexPolygons && (i < nPolyCount); i++) + { + const tools::Polygon& rPoly = pAction->GetPolyPolygon().GetObject(i); + if (rPoly.HasFlags()) + { + mrStream.WriteUInt16(i); + rPoly.Write(mrStream); + + nNumberOfComplexPolygons--; + } + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit