Resolves: tdf#63955 clip 19km long line to some sane limit
Change-Id: If9757a5fa2bb93b56b9cf9f566972f687a4a3a45 Reviewed-on: https://gerrit.libreoffice.org/17036 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
@@ -20,13 +20,14 @@
|
|||||||
|
|
||||||
#include <sdr/contact/viewcontactofsdrpathobj.hxx>
|
#include <sdr/contact/viewcontactofsdrpathobj.hxx>
|
||||||
#include <svx/svdopath.hxx>
|
#include <svx/svdopath.hxx>
|
||||||
|
#include <svx/svdpage.hxx>
|
||||||
#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
|
#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
|
||||||
#include <basegfx/polygon/b2dpolypolygontools.hxx>
|
#include <basegfx/polygon/b2dpolypolygontools.hxx>
|
||||||
|
#include <basegfx/polygon/b2dpolygonclipper.hxx>
|
||||||
#include <sdr/primitive2d/sdrpathprimitive2d.hxx>
|
#include <sdr/primitive2d/sdrpathprimitive2d.hxx>
|
||||||
#include <basegfx/matrix/b2dhommatrixtools.hxx>
|
#include <basegfx/matrix/b2dhommatrixtools.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace sdr
|
namespace sdr
|
||||||
{
|
{
|
||||||
namespace contact
|
namespace contact
|
||||||
@@ -82,13 +83,40 @@ namespace sdr
|
|||||||
|
|
||||||
// prepare object transformation and unit polygon (direct model data)
|
// prepare object transformation and unit polygon (direct model data)
|
||||||
basegfx::B2DHomMatrix aObjectMatrix;
|
basegfx::B2DHomMatrix aObjectMatrix;
|
||||||
const bool bIsLine(
|
bool bIsLine(
|
||||||
!aUnitPolyPolygon.areControlPointsUsed()
|
!aUnitPolyPolygon.areControlPointsUsed()
|
||||||
&& 1 == nPolyCount
|
&& 1 == nPolyCount
|
||||||
&& 2 == aUnitPolyPolygon.getB2DPolygon(0).count());
|
&& 2 == aUnitPolyPolygon.getB2DPolygon(0).count());
|
||||||
|
|
||||||
if(bIsLine)
|
if(bIsLine)
|
||||||
{
|
{
|
||||||
|
const SdrPage* pPage = GetPathObj().GetPage();
|
||||||
|
if (pPage)
|
||||||
|
{
|
||||||
|
//tdf#63955 if we have an extremely long line then clip it
|
||||||
|
//to a very generous range of -1 page width/height vs +1
|
||||||
|
//page width/height to avoid oom and massive churn
|
||||||
|
//generating a huge polygon chain to cover the length in
|
||||||
|
//applyLineDashing if this line is dashed
|
||||||
|
double fPageWidth = pPage->GetWdt();
|
||||||
|
double fPageHeight = pPage->GetHgt();
|
||||||
|
basegfx::B2DRange aClipRange(-fPageWidth, -fPageHeight,
|
||||||
|
fPageWidth*2, fPageHeight*2);
|
||||||
|
aUnitPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(aUnitPolyPolygon,
|
||||||
|
aClipRange, true, true);
|
||||||
|
nPolyCount = ensureGeometry(aUnitPolyPolygon);
|
||||||
|
|
||||||
|
// re-check that we have't been clipped out to oblivion
|
||||||
|
bIsLine =
|
||||||
|
!aUnitPolyPolygon.areControlPointsUsed()
|
||||||
|
&& 1 == nPolyCount
|
||||||
|
&& 2 == aUnitPolyPolygon.getB2DPolygon(0).count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bIsLine)
|
||||||
|
{
|
||||||
|
|
||||||
// special handling for single line mode (2 points)
|
// special handling for single line mode (2 points)
|
||||||
const basegfx::B2DPolygon aSubPolygon(aUnitPolyPolygon.getB2DPolygon(0));
|
const basegfx::B2DPolygon aSubPolygon(aUnitPolyPolygon.getB2DPolygon(0));
|
||||||
const basegfx::B2DPoint aStart(aSubPolygon.getB2DPoint(0));
|
const basegfx::B2DPoint aStart(aSubPolygon.getB2DPoint(0));
|
||||||
|
Reference in New Issue
Block a user