tdf#148526 sdext,pdfimport: rendering::PathJoinType to B2DLineJoin

Pdfimport is one of the few none render pieces of code to use
css::rendering::PathJoinType, switch to using basegfx::B2DLineJoin
instead.
Use that type consistently instead of throwing in sal_Int8's with it.

Change-Id: Ie1384a06558925c796ce6c83b458b4c150bcecc7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172925
Tested-by: Jenkins
Reviewed-by: David Gilbert <freedesktop@treblig.org>
This commit is contained in:
Dr. David Alan Gilbert 2024-08-28 22:01:08 +01:00 committed by David Gilbert
parent 53d5b3119f
commit 84cc3180c8
6 changed files with 19 additions and 16 deletions

View file

@ -170,7 +170,7 @@ namespace
getCurrentContext().Flatness = nFlatness;
}
virtual void setLineJoin(sal_Int8 nJoin) override
virtual void setLineJoin(basegfx::B2DLineJoin nJoin) override
{
getCurrentContext().LineJoin = nJoin;
}
@ -261,7 +261,7 @@ namespace
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Blend mode is normal",
rendering::BlendMode::NORMAL, rContext.BlendMode );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Join type is round",
rendering::PathJoinType::ROUND, rContext.LineJoin );
basegfx::B2DLineJoin::Round, rContext.LineJoin );
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Cap type is butt",
rendering::PathCapType::BUTT, rContext.LineCap );
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE( "Line miter limit is 10",

View file

@ -20,6 +20,7 @@
#ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_CONTENTSINK_HXX
#define INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_CONTENTSINK_HXX
#include <basegfx/vector/b2enums.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/rendering/ARGBColor.hpp>
@ -117,7 +118,7 @@ namespace pdfi
virtual void setTransformation( const css::geometry::AffineMatrix2D& rMatrix ) = 0;
virtual void setLineDash( const css::uno::Sequence<double>& dashes,
double start ) = 0;
virtual void setLineJoin( sal_Int8 lineJoin ) = 0;
virtual void setLineJoin( basegfx::B2DLineJoin lineJoin ) = 0;
virtual void setLineCap( sal_Int8 lineCap ) = 0;
virtual void setMiterLimit(double) = 0;
virtual void setLineWidth(double) = 0;

View file

@ -27,8 +27,8 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/vector/b2enums.hxx>
#include <com/sun/star/rendering/PathCapType.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp>
#include <unordered_map>
#include <vector>
@ -98,7 +98,7 @@ namespace pdfi
{
css::rendering::ARGBColor LineColor;
css::rendering::ARGBColor FillColor;
sal_Int8 LineJoin;
basegfx::B2DLineJoin LineJoin;
sal_Int8 LineCap;
sal_Int8 BlendMode;
double Flatness;
@ -113,7 +113,7 @@ namespace pdfi
GraphicsContext() :
LineColor(),
FillColor(),
LineJoin(0),
LineJoin(basegfx::B2DLineJoin::NONE),
LineCap(0),
BlendMode(0),
Flatness(0.0),
@ -154,11 +154,11 @@ namespace pdfi
switch (LineJoin)
{
default:
case css::rendering::PathJoinType::MITER:
case basegfx::B2DLineJoin::Miter:
return u"miter"_ustr;
case css::rendering::PathJoinType::ROUND:
case basegfx::B2DLineJoin::Round:
return u"round"_ustr;
case css::rendering::PathJoinType::BEVEL:
case basegfx::B2DLineJoin::Bevel:
return u"bevel"_ustr;
}
}

View file

@ -20,6 +20,7 @@
#ifndef INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_PDFIPROCESSOR_HXX
#define INCLUDED_SDEXT_SOURCE_PDFIMPORT_INC_PDFIPROCESSOR_HXX
#include <com/sun/star/drawing/LineJoint.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <com/sun/star/geometry/RealSize2D.hpp>
@ -100,7 +101,7 @@ namespace pdfi
virtual void setTransformation( const css::geometry::AffineMatrix2D& rMatrix ) override;
virtual void setLineDash( const css::uno::Sequence<double>& dashes,
double start ) override;
virtual void setLineJoin(sal_Int8) override;
virtual void setLineJoin(basegfx::B2DLineJoin) override;
virtual void setLineCap(sal_Int8) override;
virtual void setMiterLimit(double) override;
virtual void setLineWidth(double) override;

View file

@ -35,6 +35,7 @@
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <basegfx/utils/canvastools.hxx>
#include <basegfx/vector/b2enums.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <i18nutil/unicode.hxx>
#include <o3tl/string_view.hxx>
@ -114,7 +115,7 @@ void PDFIProcessor::setLineDash( const uno::Sequence<double>& dashes,
comphelper::sequenceToContainer(rContext.DashArray,dashes);
}
void PDFIProcessor::setLineJoin(sal_Int8 nJoin)
void PDFIProcessor::setLineJoin(basegfx::B2DLineJoin nJoin)
{
getCurrentContext().LineJoin = nJoin;
}

View file

@ -40,7 +40,6 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/rendering/PathCapType.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp>
#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
#include <com/sun/star/geometry/Matrix2D.hpp>
#include <com/sun/star/geometry/AffineMatrix2D.hpp>
@ -52,6 +51,7 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/utils/unopolypolygon.hxx>
#include <basegfx/vector/b2enums.hxx>
#include <vcl/metric.hxx>
#include <vcl/font.hxx>
@ -431,13 +431,13 @@ void LineParser::readLineDash()
void LineParser::readLineJoin()
{
sal_Int8 nJoin(rendering::PathJoinType::MITER);
basegfx::B2DLineJoin nJoin(basegfx::B2DLineJoin::Miter);
switch( readInt32() )
{
default:
case 0: nJoin = rendering::PathJoinType::MITER; break;
case 1: nJoin = rendering::PathJoinType::ROUND; break;
case 2: nJoin = rendering::PathJoinType::BEVEL; break;
case 0: nJoin = basegfx::B2DLineJoin::Miter; break;
case 1: nJoin = basegfx::B2DLineJoin::Round; break;
case 2: nJoin = basegfx::B2DLineJoin::Bevel; break;
}
m_parser.m_pSink->setLineJoin(nJoin);
}