[Libreoffice-commits] core.git: include/vcl vcl/source

panoskorovesis (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 9 09:47:26 UTC 2021


 include/vcl/filter/SvmReader.hxx    |    1 
 include/vcl/metaact.hxx             |    1 
 vcl/source/filter/svm/SvmReader.cxx |   48 +++++++++++++++++++++++++++++++++++-
 3 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 6cd8eeb66443dda80cf88205f33f184314d85c49
Author:     panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Thu Jul 8 12:07:49 2021 +0300
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Fri Jul 9 11:46:53 2021 +0200

    Add Handler for MetaPolyPolygon Read
    
    The handler separates the MetaPolyPolygonAction::Read from metaact.hxx
    Read implementation is now in SvmReader.hxx
    
    Change-Id: Iad883a65c4c018c9a6852a8b05011b5609f477a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118608
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

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: */


More information about the Libreoffice-commits mailing list