summaryrefslogtreecommitdiff
path: root/cppcanvas
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2013-11-27 11:51:32 +0100
committerJan Holesovsky <kendy@collabora.com>2013-11-27 12:02:56 +0100
commitf305861b1be589ff6854be2f72541398b61c637b (patch)
tree6eefeeebea29e9e4b0eda9a6a7a65beea4ac4b19 /cppcanvas
parent507d348454f6fd2d6475d2878bbc56efd9d73ca1 (diff)
EMF+: Line thickness has to be considered when drawing the caps.
Change-Id: I6043ee3c214f453afaef06125993c73be624c07e
Diffstat (limited to 'cppcanvas')
-rw-r--r--cppcanvas/source/inc/implrenderer.hxx3
-rw-r--r--cppcanvas/source/mtfrenderer/emfplus.cxx75
2 files changed, 45 insertions, 33 deletions
diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx
index c649db32c750..3d0c48d48767 100644
--- a/cppcanvas/source/inc/implrenderer.hxx
+++ b/cppcanvas/source/inc/implrenderer.hxx
@@ -282,7 +282,8 @@ static float GetSwapFloat( SvStream& rSt )
double setFont( sal_uInt8 objectId, const ActionFactoryParameters& rParms, OutDevState& rState );
/// Render LineCap, like the start or end arrow of a polygon.
- void EMFPPlusDrawLineCap(const ::basegfx::B2DPolygon& rPolygon, double fPolyLength,
+ /// @return how much we should shorten the original polygon.
+ double EMFPPlusDrawLineCap(const ::basegfx::B2DPolygon& rPolygon, double fPolyLength,
const ::basegfx::B2DPolyPolygon& rLineCap, bool bStart,
const com::sun::star::rendering::StrokeAttributes& rAttributes,
const ActionFactoryParameters& rParms, OutDevState& rState);
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 4907b6f115a1..e7fa98495d5b 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -1319,13 +1319,12 @@ namespace cppcanvas
}
}
-
- void ImplRenderer::EMFPPlusDrawLineCap(const ::basegfx::B2DPolygon& rPolygon, double fPolyLength,
+ double ImplRenderer::EMFPPlusDrawLineCap(const ::basegfx::B2DPolygon& rPolygon, double fPolyLength,
const ::basegfx::B2DPolyPolygon& rLineCap, bool bStart, const rendering::StrokeAttributes& rAttributes,
const ActionFactoryParameters& rParms, OutDevState& rState)
{
if (!rLineCap.count())
- return;
+ return 0.0;
// it seems the line caps in EMF+ are 4*larger than what
// LibreOffice expects, and the mapping in
@@ -1337,7 +1336,7 @@ namespace cppcanvas
basegfx::B2DPolyPolygon aArrow(basegfx::tools::createAreaGeometryForLineStartEnd(
rPolygon, rLineCap, bStart,
- fWidth, fPolyLength, 0.0, NULL));
+ fWidth, fPolyLength, 0, NULL, rAttributes.StrokeWidth));
// createAreaGeometryForLineStartEnd from some reason always sets
// the path as closed, correct it
@@ -1349,6 +1348,8 @@ namespace cppcanvas
maActions.push_back(MtfAction(pAction, rParms.mrCurrActionIndex));
rParms.mrCurrActionIndex += pAction->getActionCount()-1;
}
+
+ return rAttributes.StrokeWidth;
}
void ImplRenderer::EMFPPlusDrawPolygon (const ::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms,
@@ -1378,49 +1379,59 @@ namespace cppcanvas
rendering::StrokeAttributes aPolygonAttributes(aCommonAttributes);
pen->SetStrokeDashing(aPolygonAttributes);
- // render the polygon
- ActionSharedPtr pPolyAction(internal::PolyPolyActionFactory::createPolyPolyAction(aPolyPolygon, rParms.mrCanvas, rState, aPolygonAttributes));
- if( pPolyAction )
- {
- maActions.push_back(MtfAction(pPolyAction, rParms.mrCurrActionIndex));
- rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
- }
+ basegfx::B2DPolyPolygon aFinalPolyPolygon;
- // render line starts & ends
- if (pen->customStartCap || pen->customEndCap)
+ // render line starts & ends if present
+ if (!pen->customStartCap && !pen->customEndCap)
+ aFinalPolyPolygon = aPolyPolygon;
+ else
{
for (sal_uInt32 i = 0; i < aPolyPolygon.count(); ++i)
{
- // break the polypolygon into polygons
basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(i));
- if (aPolygon.isClosed())
- continue;
+ if (!aPolygon.isClosed())
+ {
+ double fStart = 0.0;
+ double fEnd = 0.0;
+ double fPolyLength = basegfx::tools::getLength(aPolygon);
- double fPolyLength = basegfx::tools::getLength(aPolygon);
+ // line start
+ if (pen->customStartCap)
+ {
+ rendering::StrokeAttributes aAttributes(aCommonAttributes);
+ pen->customStartCap->SetAttributes(aAttributes);
- // line start
- if (pen->customStartCap)
- {
- rendering::StrokeAttributes aAttributes(aCommonAttributes);
- pen->customStartCap->SetAttributes(aAttributes);
+ fStart = EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customStartCap->polygon,
+ true, aAttributes, rParms, rState);
+ }
- EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customStartCap->polygon,
- true, aAttributes, rParms, rState);
- }
+ // line end
+ if (pen->customEndCap)
+ {
+ rendering::StrokeAttributes aAttributes(aCommonAttributes);
+ pen->customEndCap->SetAttributes(aAttributes);
- // line end
- if (pen->customEndCap)
- {
- rendering::StrokeAttributes aAttributes(aCommonAttributes);
- pen->customEndCap->SetAttributes(aAttributes);
+ fEnd = EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customEndCap->polygon,
+ false, aAttributes, rParms, rState);
+ }
- EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customEndCap->polygon,
- false, aAttributes, rParms, rState);
+ // build new poly, consume something from the old poly
+ if (fStart != 0.0 || fEnd != 0.0)
+ aPolygon = basegfx::tools::getSnippetAbsolute(aPolygon, fStart, fPolyLength - fEnd, fPolyLength);
}
+
+ aFinalPolyPolygon.append(aPolygon);
}
}
+ // finally render the polygon
+ ActionSharedPtr pPolyAction(internal::PolyPolyActionFactory::createPolyPolyAction(aFinalPolyPolygon, rParms.mrCanvas, rState, aPolygonAttributes));
+ if( pPolyAction )
+ {
+ maActions.push_back(MtfAction(pPolyAction, rParms.mrCurrActionIndex));
+ rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
+ }
}
}