From 49cc7c0f216a40ba1ab7ada500814faa929b2d44 Mon Sep 17 00:00:00 2001 From: Svetlana Kulikova Date: Mon, 23 Nov 2020 18:26:57 +0300 Subject: [PATCH] DrawFootnoteRect --- .../doctrenderer/embed/GraphicsEmbed.cpp | 2 +- DesktopEditor/doctrenderer/graphics.cpp | 33 +++++++++++++++++++ DesktopEditor/doctrenderer/graphics.h | 2 +- .../doctrenderer/js/NativeGraphics.js | 26 --------------- DesktopEditor/doctrenderer/js/test.js | 2 ++ 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp index 5346c4ade7..93250a1bd2 100644 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp +++ b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp @@ -452,7 +452,7 @@ JSSmart CGraphicsEmbed::DrawPolygon(JSSmart oPath, JSSmart CGraphicsEmbed::DrawFootnoteRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h) { - m_pInternal->DrawFootnoteRect(); + m_pInternal->DrawFootnoteRect(x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble()); return NULL; } JSSmart CGraphicsEmbed::toDataURL(JSSmart type) diff --git a/DesktopEditor/doctrenderer/graphics.cpp b/DesktopEditor/doctrenderer/graphics.cpp index d78e2de19a..92d1c9305f 100644 --- a/DesktopEditor/doctrenderer/graphics.cpp +++ b/DesktopEditor/doctrenderer/graphics.cpp @@ -977,6 +977,39 @@ void CGraphics::AddSmartRect(double x, double y, double w, double h, double pen_ { m_pRenderer->AddRect(x, y, w, h); } +void CGraphics::DrawFootnoteRect(double x, double y, double w, double h) +{ + BYTE nPenDashStyle = 0; + m_pRenderer->get_PenDashStyle(&nPenDashStyle); + + bool bIsIntegerGrid = m_pRenderer->get_IntegerGrid(); + if (!bIsIntegerGrid) + m_pRenderer->put_IntegerGrid(true); + + double dash[2] = { 2.0, 2.0 }; + m_pRenderer->put_PenDashStyle(Aggplus::DashStyleCustom); + m_pRenderer->PenDashPattern(dash, 2); + + m_pRenderer->PathCommandEnd(); + + double l = x; + double t = y; + double r = x + w; + double b = y + h; + + drawHorLineExt(1, t, l, r, 0, 0, 0); + drawVerLine (1, l, t, b, 0); + drawVerLine (1, r, t, b, 0); + drawHorLineExt(1, b, l, r, 0, 0, 0); + + m_pRenderer->PathCommandEnd(); + m_pRenderer->Stroke(); + + if (!bIsIntegerGrid) + m_pRenderer->put_IntegerGrid(false); + + m_pRenderer->put_PenDashStyle(nPenDashStyle); +} std::string CGraphics::toDataURL(std::wstring type) { m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img." + type, _CXIMAGE_FORMAT_PNG); diff --git a/DesktopEditor/doctrenderer/graphics.h b/DesktopEditor/doctrenderer/graphics.h index 72a14a7288..cd0af283b2 100644 --- a/DesktopEditor/doctrenderer/graphics.h +++ b/DesktopEditor/doctrenderer/graphics.h @@ -208,7 +208,7 @@ namespace NSGraphics void Drawing_EndCheckBounds() {} void DrawPresentationComment() {} void DrawPolygon() {} - void DrawFootnoteRect() {} + void DrawFootnoteRect(double x, double y, double w, double h); // new methods std::string toDataURL(std::wstring type); }; diff --git a/DesktopEditor/doctrenderer/js/NativeGraphics.js b/DesktopEditor/doctrenderer/js/NativeGraphics.js index 78e496252e..8f521ba123 100644 --- a/DesktopEditor/doctrenderer/js/NativeGraphics.js +++ b/DesktopEditor/doctrenderer/js/NativeGraphics.js @@ -509,32 +509,6 @@ CNativeGraphics.prototype = }, DrawFootnoteRect : function(x, y, w, h) { - var _old = this.m_bIntegerGrid; - if (!_old) - this.SetIntegerGrid(true); - - this.p_dash([1, 1]); - - this._s(); - - var l = x; - var t = y; - var r = x + w; - var b = y + h; - - this.drawHorLineExt(c_oAscLineDrawingRule.Top, t, l, r, 0, 0, 0); - this.drawVerLine(c_oAscLineDrawingRule.Right, l, t, b, 0); - this.drawVerLine(c_oAscLineDrawingRule.Left, r, t, b, 0); - this.drawHorLineExt(c_oAscLineDrawingRule.Top, b, l, r, 0, 0, 0); - - this.ds(); - this._s(); - - this.p_dash(null); - - if (!_old) - this.SetIntegerGrid(false); - this.Native["DrawFootnoteRect"](x, y, w, h); }, // new methods diff --git a/DesktopEditor/doctrenderer/js/test.js b/DesktopEditor/doctrenderer/js/test.js index 7a68e8b37e..c337dcf009 100644 --- a/DesktopEditor/doctrenderer/js/test.js +++ b/DesktopEditor/doctrenderer/js/test.js @@ -91,6 +91,8 @@ MyGraphics._z(); // Рисует замыкание со второй до предпоследней точки MyGraphics.DrawPolygon({Points : [{X : 10, Y : 10}, {X : 20, Y : 20}, {X : 20, Y : 30}, {X : 10, Y : 40}, {X : 0, Y : 30}]}, 3, 0); +MyGraphics.DrawFootnoteRect(30, 30, 90, 90); + MyGraphics.b_color1(255, 0, 0, 255); MyGraphics._s(); MyGraphics.AddClipRect(210, 10, 50, 50);