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

Resolves: #i122132# Some simple extensions to exporter

(cherry picked from commit 3454d186)

Conflicts:
	filter/source/svg/svgwriter.cxx

Change-Id: I2f9d96ffce0d51695a665b58a776807bab5d277e
üst d7cebf0f
...@@ -402,6 +402,7 @@ namespace drawinglayer ...@@ -402,6 +402,7 @@ namespace drawinglayer
if(rB2DPolygon.count() && !mnSvtGraphicStrokeCount) if(rB2DPolygon.count() && !mnSvtGraphicStrokeCount)
{ {
basegfx::B2DPolygon aLocalPolygon(rB2DPolygon);
basegfx::BColor aStrokeColor; basegfx::BColor aStrokeColor;
basegfx::B2DPolyPolygon aStartArrow; basegfx::B2DPolyPolygon aStartArrow;
basegfx::B2DPolyPolygon aEndArrow; basegfx::B2DPolyPolygon aEndArrow;
...@@ -419,29 +420,37 @@ namespace drawinglayer ...@@ -419,29 +420,37 @@ namespace drawinglayer
// SvtGraphicStroke has NO entry for stroke color(!) // SvtGraphicStroke has NO entry for stroke color(!)
mpOutputDevice->SetLineColor(Color(aStrokeColor)); mpOutputDevice->SetLineColor(Color(aStrokeColor));
if(!rB2DPolygon.isClosed()) if(!aLocalPolygon.isClosed())
{ {
double fPolyLength(0.0); double fPolyLength(0.0);
double fStart(0.0);
double fEnd(0.0);
if(pStart && pStart->isActive()) if(pStart && pStart->isActive())
{ {
fPolyLength = basegfx::tools::getLength(rB2DPolygon); fPolyLength = basegfx::tools::getLength(aLocalPolygon);
aStartArrow = basegfx::tools::createAreaGeometryForLineStartEnd( aStartArrow = basegfx::tools::createAreaGeometryForLineStartEnd(
rB2DPolygon, pStart->getB2DPolyPolygon(), true, pStart->getWidth(), aLocalPolygon, pStart->getB2DPolyPolygon(), true, pStart->getWidth(),
fPolyLength, pStart->isCentered() ? 0.5 : 0.0, 0); fPolyLength, pStart->isCentered() ? 0.5 : 0.0, &fStart);
} }
if(pEnd && pEnd->isActive()) if(pEnd && pEnd->isActive())
{ {
if(basegfx::fTools::equalZero(fPolyLength)) if(basegfx::fTools::equalZero(fPolyLength))
{ {
fPolyLength = basegfx::tools::getLength(rB2DPolygon); fPolyLength = basegfx::tools::getLength(aLocalPolygon);
} }
aEndArrow = basegfx::tools::createAreaGeometryForLineStartEnd( aEndArrow = basegfx::tools::createAreaGeometryForLineStartEnd(
rB2DPolygon, pEnd->getB2DPolyPolygon(), false, pEnd->getWidth(), aLocalPolygon, pEnd->getB2DPolyPolygon(), false, pEnd->getWidth(),
fPolyLength, pEnd->isCentered() ? 0.5 : 0.0, 0); fPolyLength, pEnd->isCentered() ? 0.5 : 0.0, &fEnd);
}
if(0.0 != fStart || 0.0 != fEnd)
{
// build new poly, consume something from old poly
aLocalPolygon = basegfx::tools::getSnippetAbsolute(aLocalPolygon, fStart, fPolyLength - fEnd, fPolyLength);
} }
} }
...@@ -517,14 +526,12 @@ namespace drawinglayer ...@@ -517,14 +526,12 @@ namespace drawinglayer
// concept of PDF export and SvtGraphicStroke usage does simply not // concept of PDF export and SvtGraphicStroke usage does simply not
// allow handling such definitions. The only clean way would be to // allow handling such definitions. The only clean way would be to
// add the transformation to SvtGraphicStroke and to handle it there // add the transformation to SvtGraphicStroke and to handle it there
basegfx::B2DPolygon aB2DPolygon(rB2DPolygon); aLocalPolygon.transform(maCurrentTransformation);
aB2DPolygon.transform(maCurrentTransformation);
aStartArrow.transform(maCurrentTransformation); aStartArrow.transform(maCurrentTransformation);
aEndArrow.transform(maCurrentTransformation); aEndArrow.transform(maCurrentTransformation);
pRetval = new SvtGraphicStroke( pRetval = new SvtGraphicStroke(
Polygon(aB2DPolygon), Polygon(aLocalPolygon),
PolyPolygon(aStartArrow), PolyPolygon(aStartArrow),
PolyPolygon(aEndArrow), PolyPolygon(aEndArrow),
mfCurrentUnifiedTransparence, mfCurrentUnifiedTransparence,
......
...@@ -2805,6 +2805,14 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, ...@@ -2805,6 +2805,14 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( rPoly.GetSize() ) if( rPoly.GetSize() )
{ {
const LineInfo& rLineInfo = pA->GetLineInfo();
if(rLineInfo.GetWidth())
{
sal_Int32 nStrokeWidth = ImplMap(rLineInfo.GetWidth());
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, OUString::valueOf( nStrokeWidth ) );
}
mpContext->AddPaintAttr( mpVDev->GetLineColor(), Color( COL_TRANSPARENT ) ); mpContext->AddPaintAttr( mpVDev->GetLineColor(), Color( COL_TRANSPARENT ) );
ImplAddLineAttr( pA->GetLineInfo() ); ImplAddLineAttr( pA->GetLineInfo() );
ImplWritePolyPolygon( rPoly, sal_True ); ImplWritePolyPolygon( rPoly, sal_True );
...@@ -3043,83 +3051,109 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, ...@@ -3043,83 +3051,109 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
aStroke.getEndArrow( aEndArrow ); aStroke.getEndArrow( aEndArrow );
// Currently no support for strokes with start/end arrow(s) // Currently no support for strokes with start/end arrow(s)
sal_Bool bSkip = ( !aStartArrow.Count() && !aEndArrow.Count() ); // added that support
Polygon aPoly;
if( bSkip )
{
Polygon aPoly;
aStroke.getPath(aPoly); aStroke.getPath(aPoly);
if(mapCurShape.get()) if(mapCurShape.get())
{
if(1 != mapCurShape->maShapePolyPoly.Count()
|| !mapCurShape->maShapePolyPoly[0].IsEqual(aPoly))
{ {
if(1 != mapCurShape->maShapePolyPoly.Count() // this path action is not covering the same path than the already existing
|| !mapCurShape->maShapePolyPoly[0].IsEqual(aPoly)) // fill polypolygon, so write out the fill polygon
{ ImplWriteShape( *mapCurShape );
// this path action is not covering the same path than the already existing mapCurShape.reset();
// fill polypolygon, so write out the fill polygon
ImplWriteShape( *mapCurShape );
mapCurShape.reset();
}
} }
}
if( !mapCurShape.get() ) if( !mapCurShape.get() )
{ {
mapCurShape.reset( new SVGShapeDescriptor );
if( pElementId ) mapCurShape.reset( new SVGShapeDescriptor );
{
mapCurShape->maId = *pElementId + "_" + OUString::valueOf(nEntryCount++);
}
aStroke.getPath( aPoly ); if( pElementId )
mapCurShape->maShapePolyPoly = aPoly; {
mapCurShape->maId = *pElementId + "_" + OUString::valueOf(nEntryCount++);
} }
mapCurShape->maShapeLineColor = mpVDev->GetLineColor(); mapCurShape->maShapePolyPoly = aPoly;
mapCurShape->maShapeLineColor.SetTransparency( (sal_uInt8) FRound( aStroke.getTransparency() * 255.0 ) );
mapCurShape->mnStrokeWidth = FRound( aStroke.getStrokeWidth() );
aStroke.getDashArray( mapCurShape->maDashArray );
} }
// support for LineJoin mapCurShape->maShapeLineColor = mpVDev->GetLineColor();
mapCurShape->maShapeLineColor.SetTransparency( (sal_uInt8) FRound( aStroke.getTransparency() * 255.0 ) );
mapCurShape->mnStrokeWidth = FRound( aStroke.getStrokeWidth() );
aStroke.getDashArray( mapCurShape->maDashArray );
// added support for LineJoin
switch(aStroke.getJoinType()) switch(aStroke.getJoinType())
{ {
default: /* SvtGraphicStroke::joinMiter, SvtGraphicStroke::joinNone */ default: /* SvtGraphicStroke::joinMiter, SvtGraphicStroke::joinNone */
{ {
mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_MITER; mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_MITER;
break; break;
} }
case SvtGraphicStroke::joinRound: case SvtGraphicStroke::joinRound:
{ {
mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_ROUND; mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_ROUND;
break; break;
} }
case SvtGraphicStroke::joinBevel: case SvtGraphicStroke::joinBevel:
{ {
mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_BEVEL; mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_BEVEL;
break; break;
} }
} }
// support for LineCap // added support for LineCap
switch(aStroke.getCapType()) switch(aStroke.getCapType())
{ {
default: /* SvtGraphicStroke::capButt */ default: /* SvtGraphicStroke::capButt */
{ {
mapCurShape->maLineCap = com::sun::star::drawing::LineCap_BUTT; mapCurShape->maLineCap = com::sun::star::drawing::LineCap_BUTT;
break; break;
} }
case SvtGraphicStroke::capRound: case SvtGraphicStroke::capRound:
{ {
mapCurShape->maLineCap = com::sun::star::drawing::LineCap_ROUND; mapCurShape->maLineCap = com::sun::star::drawing::LineCap_ROUND;
break; break;
}
case SvtGraphicStroke::capSquare:
{
mapCurShape->maLineCap = com::sun::star::drawing::LineCap_SQUARE;
break;
}
} }
case SvtGraphicStroke::capSquare:
if(mapCurShape.get() &&(aStartArrow.Count() || aEndArrow.Count()))
{ {
mapCurShape->maLineCap = com::sun::star::drawing::LineCap_SQUARE; ImplWriteShape( *mapCurShape );
break;
} mapCurShape->maShapeFillColor = mapCurShape->maShapeLineColor;
mapCurShape->maShapeLineColor = Color(COL_TRANSPARENT);
mapCurShape->mnStrokeWidth = 0;
mapCurShape->maDashArray.clear();
mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_MITER;
mapCurShape->maLineCap = com::sun::star::drawing::LineCap_BUTT;
if(aStartArrow.Count())
{
mapCurShape->maShapePolyPoly = aStartArrow;
mapCurShape->maId = *pElementId + "_" + OUString::valueOf(nEntryCount++);
ImplWriteShape( *mapCurShape );
}
if(aEndArrow.Count())
{
mapCurShape->maShapePolyPoly = aEndArrow;
mapCurShape->maId = *pElementId + "_" + OUString::valueOf(nEntryCount++);
ImplWriteShape( *mapCurShape );
}
mapCurShape.reset();
} }
// write open shape in every case // write open shape in every case
...@@ -3130,6 +3164,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, ...@@ -3130,6 +3164,8 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
} }
// skip rest of comment // skip rest of comment
sal_Bool bSkip = true;
while( bSkip && ( ++nCurAction < nCount ) ) while( bSkip && ( ++nCurAction < nCount ) )
{ {
pAction = rMtf.GetAction( nCurAction ); pAction = rMtf.GetAction( nCurAction );
......
...@@ -4040,20 +4040,34 @@ void MetaCommentAction::Move( long nXMove, long nYMove ) ...@@ -4040,20 +4040,34 @@ void MetaCommentAction::Move( long nXMove, long nYMove )
{ {
SvtGraphicStroke aStroke; SvtGraphicStroke aStroke;
aMemStm >> aStroke; aMemStm >> aStroke;
Polygon aPath; Polygon aPath;
aStroke.getPath( aPath ); aStroke.getPath( aPath );
aPath.Move( nXMove, nYMove ); aPath.Move( nXMove, nYMove );
aStroke.setPath( aPath ); aStroke.setPath( aPath );
PolyPolygon aStartArrow;
aStroke.getStartArrow(aStartArrow);
aStartArrow.Move(nXMove, nYMove);
aStroke.setStartArrow(aStartArrow);
PolyPolygon aEndArrow;
aStroke.getEndArrow(aEndArrow);
aEndArrow.Move(nXMove, nYMove);
aStroke.setEndArrow(aEndArrow);
aDest << aStroke; aDest << aStroke;
} }
else else
{ {
SvtGraphicFill aFill; SvtGraphicFill aFill;
aMemStm >> aFill; aMemStm >> aFill;
PolyPolygon aPath; PolyPolygon aPath;
aFill.getPath( aPath ); aFill.getPath( aPath );
aPath.Move( nXMove, nYMove ); aPath.Move( nXMove, nYMove );
aFill.setPath( aPath ); aFill.setPath( aPath );
aDest << aFill; aDest << aFill;
} }
delete[] mpData; delete[] mpData;
......
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