summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpanoskorovesis <panoskorovesis@outlook.com>2021-07-08 12:07:49 +0300
committerpanoskorovesis <panoskorovesis@outlook.com>2021-07-08 12:07:49 +0300
commitc11866c7667122dd21d4c5dd76d207e3a9ed3fc5 (patch)
treef9edf8a010d5638447248331c4ff6c5f9ecfe4ee
parent77255f4a9ef1f7c6baf4c17f0fc5d582d86db548 (diff)
Add Handler for MetaPolyPolygon Read
The handler separates the MetaPolyPolygonAction::Read from metaact.hxx Read implementation is now in SvmReader.hxx Change-Id: Iad883a65c4c018c9a6852a8b05011b5609f477a2
-rw-r--r--include/vcl/filter/SvmReader.hxx1
-rw-r--r--include/vcl/metaact.hxx1
-rw-r--r--vcl/source/filter/svm/SvmReader.cxx48
3 files changed, 49 insertions, 1 deletions
diff --git a/include/vcl/filter/SvmReader.hxx b/include/vcl/filter/SvmReader.hxx
index 57e97a923df4..0259dd03503c 100644
--- a/include/vcl/filter/SvmReader.hxx
+++ b/include/vcl/filter/SvmReader.hxx
@@ -50,6 +50,7 @@ public:
rtl::Reference<MetaAction> ChordHandler();
rtl::Reference<MetaAction> PolyLineHandler();
rtl::Reference<MetaAction> PolygonHandler();
+ rtl::Reference<MetaAction> PolyPolygonHandler();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index 94d45ee0365f..aca0c4e2c493 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -486,6 +486,7 @@ public:
virtual void Scale( double fScaleX, double fScaleY ) override;
const tools::PolyPolygon& GetPolyPolygon() const { return maPolyPoly; }
+ void SetPolyPolygon(tools::PolyPolygon& rPolyPoly) { maPolyPoly = rPolyPoly; }
};
class SAL_DLLPUBLIC_RTTI MetaTextAction final : public MetaAction
diff --git a/vcl/source/filter/svm/SvmReader.cxx b/vcl/source/filter/svm/SvmReader.cxx
index 4e4242665c6e..ffd17c5761ee 100644
--- a/vcl/source/filter/svm/SvmReader.cxx
+++ b/vcl/source/filter/svm/SvmReader.cxx
@@ -192,7 +192,7 @@ rtl::Reference<MetaAction> SvmReader::MetaActionHandler(ImplMetaReadData* pData)
return PolygonHandler();
break;
case MetaActionType::POLYPOLYGON:
- pAction = new MetaPolyPolygonAction;
+ return PolyPolygonHandler();
break;
case MetaActionType::TEXT:
pAction = new MetaTextAction;
@@ -592,4 +592,50 @@ rtl::Reference<MetaAction> SvmReader::PolygonHandler()
return pAction;
}
+
+rtl::Reference<MetaAction> SvmReader::PolyPolygonHandler()
+{
+ auto pAction = new MetaPolyPolygonAction();
+
+ VersionCompatRead aCompat(mrStream);
+ tools::PolyPolygon aPolyPolygon;
+ ReadPolyPolygon(mrStream, aPolyPolygon); // Version 1
+
+ if (aCompat.GetVersion() < 2) // Version 2
+ {
+ pAction->SetPolyPolygon(aPolyPolygon);
+ return pAction;
+ }
+
+ sal_uInt16 nNumberOfComplexPolygons(0);
+ mrStream.ReadUInt16(nNumberOfComplexPolygons);
+ const size_t nMinRecordSize = sizeof(sal_uInt16);
+ const size_t nMaxRecords = mrStream.remainingSize() / nMinRecordSize;
+ if (nNumberOfComplexPolygons > nMaxRecords)
+ {
+ SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords << " max possible entries, but "
+ << nNumberOfComplexPolygons
+ << " claimed, truncating");
+ nNumberOfComplexPolygons = nMaxRecords;
+ }
+ for (sal_uInt16 i = 0; i < nNumberOfComplexPolygons; ++i)
+ {
+ sal_uInt16 nIndex(0);
+ mrStream.ReadUInt16(nIndex);
+ tools::Polygon aPoly;
+ aPoly.Read(mrStream);
+ if (nIndex >= aPolyPolygon.Count())
+ {
+ SAL_WARN("vcl.gdi", "svm contains polygon index " << nIndex
+ << " outside possible range "
+ << aPolyPolygon.Count());
+ continue;
+ }
+ aPolyPolygon.Replace(aPoly, nIndex);
+ }
+
+ pAction->SetPolyPolygon(aPolyPolygon);
+
+ return pAction;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */