Kaydet (Commit) ad8875e2 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

EMF+: Set the stroke attributes on the custom line caps.

This finally makes the rendering of the custom line caps nice & complete.

Change-Id: If35ef1c44f34f5d5e6c50789c907105d03e96fca
üst ff98a070
...@@ -37,8 +37,10 @@ ...@@ -37,8 +37,10 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <sal/alloca.h> #include <sal/alloca.h>
#include <com/sun/star/rendering/XCanvas.hpp> #include <com/sun/star/rendering/PathCapType.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp>
#include <com/sun/star/rendering/TexturingMode.hpp> #include <com/sun/star/rendering/TexturingMode.hpp>
#include <com/sun/star/rendering/XCanvas.hpp>
#include <bitmapaction.hxx> #include <bitmapaction.hxx>
#include <implrenderer.hxx> #include <implrenderer.hxx>
...@@ -103,6 +105,16 @@ const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow = 0x00000001; ...@@ -103,6 +105,16 @@ const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow = 0x00000001;
const sal_uInt32 EmfPlusCustomLineCapDataFillPath = 0x00000001; const sal_uInt32 EmfPlusCustomLineCapDataFillPath = 0x00000001;
const sal_uInt32 EmfPlusCustomLineCapDataLinePath = 0x00000002; const sal_uInt32 EmfPlusCustomLineCapDataLinePath = 0x00000002;
const sal_uInt32 EmfPlusLineCapTypeFlat = 0x00000000;
const sal_uInt32 EmfPlusLineCapTypeSquare = 0x00000001;
const sal_uInt32 EmfPlusLineCapTypeRound = 0x00000002;
const sal_uInt32 EmfPlusLineCapTypeTriangle = 0x00000003;
const sal_uInt32 EmfPlusLineJoinTypeMiter = 0x00000000;
const sal_uInt32 EmfPlusLineJoinTypeBevel = 0x00000001;
const sal_uInt32 EmfPlusLineJoinTypeRound = 0x00000002;
const sal_uInt32 EmfPlusLineJoinTypeMiterClipped = 0x00000003;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::basegfx; using namespace ::basegfx;
...@@ -594,9 +606,25 @@ namespace cppcanvas ...@@ -594,9 +606,25 @@ namespace cppcanvas
} }
}; };
/// Convert stroke caps between EMF+ and rendering API
sal_Int8 lcl_convertStrokeCap(sal_uInt32 nEmfStroke)
{
switch (nEmfStroke)
{
case EmfPlusLineCapTypeSquare: return rendering::PathCapType::SQUARE;
case EmfPlusLineCapTypeRound: return rendering::PathCapType::ROUND;
}
// we have no mapping for EmfPlusLineCapTypeTriangle, so return
// BUTT always
return rendering::PathCapType::BUTT;
}
struct EMFPCustomLineCap : public EMFPObject struct EMFPCustomLineCap : public EMFPObject
{ {
sal_uInt32 type; sal_uInt32 type;
sal_uInt32 strokeStartCap, strokeEndCap, strokeJoin;
float miterLimit;
basegfx::B2DPolyPolygon polygon; basegfx::B2DPolyPolygon polygon;
public: public:
...@@ -608,6 +636,22 @@ namespace cppcanvas ...@@ -608,6 +636,22 @@ namespace cppcanvas
{ {
} }
void SetAttributes(rendering::StrokeAttributes& aAttributes)
{
aAttributes.StartCapType = lcl_convertStrokeCap(strokeStartCap);
aAttributes.EndCapType = lcl_convertStrokeCap(strokeEndCap);
switch (strokeJoin)
{
case EmfPlusLineJoinTypeMiter: // fall-through
case EmfPlusLineJoinTypeMiterClipped: aAttributes.JoinType = rendering::PathJoinType::MITER; break;
case EmfPlusLineJoinTypeBevel: aAttributes.JoinType = rendering::PathJoinType::BEVEL; break;
case EmfPlusLineJoinTypeRound: aAttributes.JoinType = rendering::PathJoinType::ROUND; break;
}
aAttributes.MiterLimit = miterLimit;
}
void ReadPath(SvStream& s, ImplRenderer& rR, bool bClosed) void ReadPath(SvStream& s, ImplRenderer& rR, bool bClosed)
{ {
sal_Int32 pathLength; sal_Int32 pathLength;
...@@ -648,13 +692,12 @@ namespace cppcanvas ...@@ -648,13 +692,12 @@ namespace cppcanvas
{ {
sal_uInt32 customLineCapDataFlags, baseCap; sal_uInt32 customLineCapDataFlags, baseCap;
float baseInset; float baseInset;
sal_uInt32 strokeStartCap, strokeEndCap, strokeJoin; float widthScale;
float strokeMiterLimit, widthScale;
float fillHotSpotX, fillHotSpotY, strokeHotSpotX, strokeHotSpotY; float fillHotSpotX, fillHotSpotY, strokeHotSpotX, strokeHotSpotY;
s >> customLineCapDataFlags >> baseCap >> baseInset s >> customLineCapDataFlags >> baseCap >> baseInset
>> strokeStartCap >> strokeEndCap >> strokeJoin >> strokeStartCap >> strokeEndCap >> strokeJoin
>> strokeMiterLimit >> widthScale >> miterLimit >> widthScale
>> fillHotSpotX >> fillHotSpotY >> strokeHotSpotX >> strokeHotSpotY; >> fillHotSpotX >> fillHotSpotY >> strokeHotSpotX >> strokeHotSpotY;
SAL_INFO("cppcanvas.emf", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex << customLineCapDataFlags); SAL_INFO("cppcanvas.emf", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex << customLineCapDataFlags);
...@@ -663,7 +706,7 @@ namespace cppcanvas ...@@ -663,7 +706,7 @@ namespace cppcanvas
SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap); SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap);
SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap); SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap);
SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeJoin: 0x" << std::hex << strokeJoin); SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeJoin: 0x" << std::hex << strokeJoin);
SAL_INFO("cppcanvas.emf", "EMF+\t\tstrokeMiterLimit: " << strokeMiterLimit); SAL_INFO("cppcanvas.emf", "EMF+\t\tmiterLimit: " << miterLimit);
SAL_INFO("cppcanvas.emf", "EMF+\t\twidthScale: " << widthScale); SAL_INFO("cppcanvas.emf", "EMF+\t\twidthScale: " << widthScale);
if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath) if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath)
...@@ -682,11 +725,11 @@ namespace cppcanvas ...@@ -682,11 +725,11 @@ namespace cppcanvas
// no test document to be able to implement it] // no test document to be able to implement it]
sal_Int32 width, height, middleInset, fillState, lineStartCap; sal_Int32 width, height, middleInset, fillState, lineStartCap;
sal_Int32 lineEndCap, lineJoin, lineMiterLimit, widthScale; sal_Int32 lineEndCap, lineJoin, widthScale;
float fillHotSpotX, fillHotSpotY, lineHotSpotX, lineHotSpotY; float fillHotSpotX, fillHotSpotY, lineHotSpotX, lineHotSpotY;
s >> width >> height >> middleInset >> fillState >> lineStartCap s >> width >> height >> middleInset >> fillState >> lineStartCap
>> lineEndCap >> lineJoin >> lineMiterLimit >> widthScale >> lineEndCap >> lineJoin >> miterLimit >> widthScale
>> fillHotSpotX >> fillHotSpotY >> lineHotSpotX >> lineHotSpotY; >> fillHotSpotX >> fillHotSpotY >> lineHotSpotX >> lineHotSpotY;
SAL_INFO("cppcanvas.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)"); SAL_INFO("cppcanvas.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)");
...@@ -1358,13 +1401,23 @@ namespace cppcanvas ...@@ -1358,13 +1401,23 @@ namespace cppcanvas
// line start // line start
if (pen->customStartCap) if (pen->customStartCap)
{
rendering::StrokeAttributes aAttributes(aCommonAttributes);
pen->customStartCap->SetAttributes(aAttributes);
EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customStartCap->polygon, EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customStartCap->polygon,
true, aCommonAttributes, rParms, rState); true, aAttributes, rParms, rState);
}
// line end // line end
if (pen->customEndCap) if (pen->customEndCap)
{
rendering::StrokeAttributes aAttributes(aCommonAttributes);
pen->customEndCap->SetAttributes(aAttributes);
EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customEndCap->polygon, EMFPPlusDrawLineCap(aPolygon, fPolyLength, pen->customEndCap->polygon,
false, aCommonAttributes, rParms, rState); false, aAttributes, rParms, rState);
}
} }
} }
......
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