diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp index 8eb54ea3e7..5346c4ade7 100644 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp +++ b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.cpp @@ -408,13 +408,7 @@ JSSmart CGraphicsEmbed::EndClipPath() } JSSmart CGraphicsEmbed::StartCheckTableDraw() { - m_pInternal->StartCheckTableDraw(); - return NULL; -} -JSSmart CGraphicsEmbed::EndCheckTableDraw(JSSmart bIsRestore) -{ - m_pInternal->EndCheckTableDraw(bIsRestore->toBool()); - return NULL; + return CJSContext::createBool(m_pInternal->StartCheckTableDraw()); } JSSmart CGraphicsEmbed::SetTextClipRect(JSSmart _l, JSSmart _t, JSSmart _r, JSSmart _b) { diff --git a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h index 2d03ed4fd0..a71ade19a4 100644 --- a/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h +++ b/DesktopEditor/doctrenderer/embed/GraphicsEmbed.h @@ -108,7 +108,6 @@ public: JSSmart StartClipPath(); JSSmart EndClipPath(); JSSmart StartCheckTableDraw(); - JSSmart EndCheckTableDraw(JSSmart bIsRestore); JSSmart SetTextClipRect(JSSmart _l, JSSmart _t, JSSmart _r, JSSmart _b); JSSmart AddSmartRect (JSSmart x, JSSmart y, JSSmart w, JSSmart h, JSSmart pen_w); JSSmart CheckUseFonts2 (JSSmart _transform); diff --git a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp index ae523a6125..7cdafd93fe 100644 --- a/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp +++ b/DesktopEditor/doctrenderer/embed/v8/v8_Graphics.cpp @@ -97,7 +97,6 @@ namespace NSGraphics FUNCTION_WRAPPER_V8 (_StartClipPath, StartClipPath) FUNCTION_WRAPPER_V8 (_EndClipPath, EndClipPath) FUNCTION_WRAPPER_V8 (_StartCheckTableDraw, StartCheckTableDraw) - FUNCTION_WRAPPER_V8_1(_EndCheckTableDraw, EndCheckTableDraw) FUNCTION_WRAPPER_V8_4(_SetTextClipRect, SetTextClipRect) FUNCTION_WRAPPER_V8_5(_AddSmartRect, AddSmartRect) FUNCTION_WRAPPER_V8_1(_CheckUseFonts2, CheckUseFonts2) @@ -201,7 +200,6 @@ namespace NSGraphics NSV8Objects::Template_Set(result, "StartClipPath", _StartClipPath); NSV8Objects::Template_Set(result, "EndClipPath", _EndClipPath); NSV8Objects::Template_Set(result, "StartCheckTableDraw", _StartCheckTableDraw); - NSV8Objects::Template_Set(result, "EndCheckTableDraw", _EndCheckTableDraw); NSV8Objects::Template_Set(result, "SetTextClipRect", _SetTextClipRect); NSV8Objects::Template_Set(result, "AddSmartRect", _AddSmartRect); NSV8Objects::Template_Set(result, "CheckUseFonts2", _CheckUseFonts2); diff --git a/DesktopEditor/doctrenderer/graphics.cpp b/DesktopEditor/doctrenderer/graphics.cpp index 27a7649139..d78e2de19a 100644 --- a/DesktopEditor/doctrenderer/graphics.cpp +++ b/DesktopEditor/doctrenderer/graphics.cpp @@ -777,6 +777,11 @@ void CGraphics::AddClipRect(double x, double y, double w, double h) } void CGraphics::RemoveClipRect() { + if(m_oGrState.Clips.back()) + { + delete m_oGrState.Clips.back(); + m_oGrState.Clips.pop_back(); + } restore(); } void CGraphics::SetClip (double x, double y, double w, double h) @@ -950,6 +955,24 @@ void CGraphics::EndClipPath() { m_pRenderer->EndCommand(c_nClipType); } +bool CGraphics::StartCheckTableDraw() +{ + if(!m_pRenderer->get_IntegerGrid()) + { + Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix(); + if(pMatrix->IsIdentity2()) + { + SaveGrState(); + m_pRenderer->put_IntegerGrid(true); + return true; + } + } + return false; +} +void CGraphics::SetTextClipRect(double _l, double _t, double _r, double _b) +{ + AddClipRect(_l, _t, _r - _l, _b - _t); +} void CGraphics::AddSmartRect(double x, double y, double w, double h, double pen_w) { m_pRenderer->AddRect(x, y, w, h); diff --git a/DesktopEditor/doctrenderer/graphics.h b/DesktopEditor/doctrenderer/graphics.h index e67514f75e..72a14a7288 100644 --- a/DesktopEditor/doctrenderer/graphics.h +++ b/DesktopEditor/doctrenderer/graphics.h @@ -199,9 +199,8 @@ namespace NSGraphics void RestoreGrState(); void StartClipPath(); void EndClipPath(); - void StartCheckTableDraw() {} - void EndCheckTableDraw(bool bIsRestore) {} - void SetTextClipRect(double _l, double _t, double _r, double _b) {} + bool StartCheckTableDraw(); + void SetTextClipRect(double _l, double _t, double _r, double _b); void AddSmartRect (double x, double y, double w, double h, double pen_w); void CheckUseFonts2() {} void UncheckUseFonts2() {} diff --git a/DesktopEditor/doctrenderer/js/NativeGraphics.js b/DesktopEditor/doctrenderer/js/NativeGraphics.js index f78d728bad..78e496252e 100644 --- a/DesktopEditor/doctrenderer/js/NativeGraphics.js +++ b/DesktopEditor/doctrenderer/js/NativeGraphics.js @@ -374,25 +374,6 @@ CNativeGraphics.prototype = }, drawFlowAnchor : function(x, y) { - if (!AscCommon.g_flow_anchor || !AscCommon.g_flow_anchor.asc_complete || (!editor || !editor.ShowParaMarks)) - return; - - if (false === this.m_bIntegerGrid) - { - this.m_oContext.setTransform(1,0,0,1,0,0); - } - - var _x = this.m_oFullTransform.TransformPointX(x,y) >> 0; - var _y = this.m_oFullTransform.TransformPointY(x,y) >> 0; - - this.m_oContext.drawImage(AscCommon.g_flow_anchor, _x, _y); - - if (false === this.m_bIntegerGrid) - { - this.m_oContext.setTransform(this.m_oFullTransform.sx,this.m_oFullTransform.shy,this.m_oFullTransform.shx, - this.m_oFullTransform.sy,this.m_oFullTransform.tx,this.m_oFullTransform.ty); - } - this.Native["drawFlowAnchor"](x, y); }, SavePen : function() @@ -441,67 +422,48 @@ CNativeGraphics.prototype = }, EndCheckTableDraw : function(bIsRestore) { - return this.Native["EndCheckTableDraw"](bIsRestore); + if(bIsRestore) + this.RestoreGrState(); }, SetTextClipRect : function(_l, _t, _r, _b) { - return this.Native["SetTextClipRect"](_l, _t, _r, _b); + this.Native["SetTextClipRect"](_l, _t, _r, _b); }, AddSmartRect : function(x, y, w, h, pen_w) { - return this.Native["AddSmartRect"](x, y, w, h, pen_w); + this.Native["AddSmartRect"](x, y, w, h, pen_w); }, CheckUseFonts2 : function(_transform) { - if (!global_MatrixTransformer.IsIdentity2(_transform)) - { - if (!AscCommon.g_fontManager2) - { - AscCommon.g_fontManager2 = new AscFonts.CFontManager(); - AscCommon.g_fontManager2.Initialize(true); - } - - this.m_oFontManager2 = AscCommon.g_fontManager2; - - if (null == this.m_oLastFont2) - this.m_oLastFont2 = new AscCommon.CFontSetup(); - - this.IsUseFonts2 = true; - } - - this.Native["CheckUseFonts2"](_transform); + // this.Native["CheckUseFonts2"](_transform); }, UncheckUseFonts2 : function() { - this.IsUseFonts2 = false; - - this.Native["UncheckUseFonts2"](); + // this.Native["UncheckUseFonts2"](); }, Drawing_StartCheckBounds : function(x, y, w, h) { - this.Native["Drawing_StartCheckBounds"](x, y, w, h); + // this.Native["Drawing_StartCheckBounds"](x, y, w, h); }, Drawing_EndCheckBounds : function() { - this.Native["Drawing_EndCheckBounds"](); + // this.Native["Drawing_EndCheckBounds"](); }, DrawPresentationComment : function(type, x, y, w, h) { - this.Native["DrawPresentationComment"](type, x, y, w, h); + // this.Native["DrawPresentationComment"](type, x, y, w, h); }, DrawPolygon : function(oPath, lineWidth, shift) { - this.m_oContext.lineWidth = lineWidth; - this.m_oContext.beginPath(); - - var Points = oPath.Points; + this.p_width(lineWidth); + this._s(); + var Points = oPath.Points; var nCount = Points.length; // берем предпоследнюю точку, т.к. последняя совпадает с первой var PrevX = Points[nCount - 2].X, PrevY = Points[nCount - 2].Y; - var _x = Points[nCount - 2].X, - _y = Points[nCount - 2].Y; - var StartX, StartY ; + var _x = Points[nCount - 2].X, _y = Points[nCount - 2].Y; + var StartX, StartY; for (var nIndex = 0; nIndex < nCount; nIndex++) { @@ -542,11 +504,8 @@ CNativeGraphics.prototype = } this._l(StartX, StartY); - this.m_oContext.closePath(); - this.m_oContext.stroke(); - this.m_oContext.beginPath(); - - this.Native["DrawPolygon"](oPath, lineWidth, shift); + this._z(); + this.ds(); }, DrawFootnoteRect : function(x, y, w, h) { diff --git a/DesktopEditor/doctrenderer/js/test.js b/DesktopEditor/doctrenderer/js/test.js index 19eb955c04..7a68e8b37e 100644 --- a/DesktopEditor/doctrenderer/js/test.js +++ b/DesktopEditor/doctrenderer/js/test.js @@ -88,6 +88,9 @@ MyGraphics._s(); MyGraphics.TableRect(110, 10, 90, 90); 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.b_color1(255, 0, 0, 255); MyGraphics._s(); MyGraphics.AddClipRect(210, 10, 50, 50);