Kaydet (Commit) 66c803eb authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i123379# various SVG marker corrections

(cherry picked from commit ff1eee61)

Conflicts:
	basegfx/inc/basegfx/polygon/b2dpolygontools.hxx

Change-Id: I818657573a1e673e312702a4b45e7bb6394250d2
üst d6116890
...@@ -3226,6 +3226,88 @@ namespace basegfx ...@@ -3226,6 +3226,88 @@ namespace basegfx
return true; return true;
} }
B2DVector getTangentEnteringPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex)
{
B2DVector aRetval(0.0, 0.0);
const sal_uInt32 nCount(rCandidate.count());
if(nIndex >= nCount)
{
// out of range
return aRetval;
}
// start immediately at prev point compared to nIndex
const bool bClosed(rCandidate.isClosed());
sal_uInt32 nPrev(bClosed ? (nIndex + nCount - 1) % nCount : nIndex ? nIndex - 1 : nIndex);
if(nPrev == nIndex)
{
// no previous, done
return aRetval;
}
B2DCubicBezier aSegment;
// go backward in the polygon; if closed, maximal back to start index (nIndex); if not closed,
// until zero. Use nIndex as stop criteria
while(nPrev != nIndex)
{
// get BezierSegment and tangent at the *end* of segment
rCandidate.getBezierSegment(nPrev, aSegment);
aRetval = aSegment.getTangent(1.0);
if(!aRetval.equalZero())
{
// if we have a tangent, return it
return aRetval;
}
// prepare index before checked one
nPrev = bClosed ? (nPrev + nCount - 1) % nCount : nPrev ? nPrev - 1 : nIndex;
}
return aRetval;
}
B2DVector getTangentLeavingPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex)
{
B2DVector aRetval(0.0, 0.0);
const sal_uInt32 nCount(rCandidate.count());
if(nIndex >= nCount)
{
// out of range
return aRetval;
}
// start at nIndex
const bool bClosed(rCandidate.isClosed());
sal_uInt32 nCurrent(nIndex);
B2DCubicBezier aSegment;
// go forward; if closed, do this until once around and back at start index (nIndex); if not
// closed, until last point (nCount - 1). Use nIndex as stop criteria
do
{
// get BezierSegment and tangent at the *beginning* of segment
rCandidate.getBezierSegment(nCurrent, aSegment);
aRetval = aSegment.getTangent(0.0);
if(!aRetval.equalZero())
{
// if we have a tangent, return it
return aRetval;
}
// prepare next index
nCurrent = bClosed ? (nCurrent + 1) % nCount : nCurrent + 1 < nCount ? nCurrent + 1 : nIndex;
}
while(nCurrent != nIndex);
return aRetval;
}
} // end of namespace tools } // end of namespace tools
} // end of namespace basegfx } // end of namespace basegfx
......
...@@ -439,6 +439,14 @@ namespace basegfx ...@@ -439,6 +439,14 @@ namespace basegfx
*/ */
bool containsOnlyHorizontalAndVerticalEdges(const B2DPolygon& rCandidate); bool containsOnlyHorizontalAndVerticalEdges(const B2DPolygon& rCandidate);
/// get the tangent with which the given point is entered seen from the previous
/// polygon path data. Take into account all stuff like closed state, zero-length edges and others.
BASEGFX_DLLPUBLIC B2DVector getTangentEnteringPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex);
/// get the tangent with which the given point is left seen from the following
/// polygon path data. Take into account all stuff like closed state, zero-length edges and others.
BASEGFX_DLLPUBLIC B2DVector getTangentLeavingPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex);
} // end of namespace tools } // end of namespace tools
} // end of namespace basegfx } // end of namespace basegfx
......
...@@ -248,14 +248,6 @@ namespace svgio ...@@ -248,14 +248,6 @@ namespace svgio
basegfx::B2DHomMatrix& rMarkerTransform, basegfx::B2DHomMatrix& rMarkerTransform,
basegfx::B2DRange& rClipRange, basegfx::B2DRange& rClipRange,
const SvgMarkerNode& rMarker) const; const SvgMarkerNode& rMarker) const;
void add_singleMarker(
drawinglayer::primitive2d::Primitive2DSequence& rTarget,
const drawinglayer::primitive2d::Primitive2DSequence& rMarkerPrimitives,
const basegfx::B2DHomMatrix& rMarkerTransform,
const basegfx::B2DRange& rClipRange,
const SvgMarkerNode& rMarker,
const basegfx::B2DPolygon& rCandidate,
const sal_uInt32 nIndex) const;
void add_markers( void add_markers(
const basegfx::B2DPolyPolygon& rPath, const basegfx::B2DPolyPolygon& rPath,
drawinglayer::primitive2d::Primitive2DSequence& rTarget) const; drawinglayer::primitive2d::Primitive2DSequence& rTarget) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment