summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-03-22 12:14:52 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-03-22 15:17:08 +0100
commitff8b9f6fca5784f62427302026642de0cdb1ef11 (patch)
tree67ba16fc1cb93f054580f25e3a390469d097fabd
parent7bc16436e28153dfdd01e8d49cd193f62098476c (diff)
use dashing info from struct LineInfo in EPS writer (tdf#146804)
It had a random(?) hardcoded '2' as the dashing info. While at it, I've also made few other places use the common implementation of creating the dotdash array instead of doing it manually. Change-Id: Id349ca138c98d08eef47dc0bfe6d162e03fc4a9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131932 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--drawinglayer/source/tools/wmfemfhelper.cxx18
-rw-r--r--include/vcl/lineinfo.hxx5
-rw-r--r--vcl/source/filter/eps/eps.cxx4
-rw-r--r--vcl/source/gdi/lineinfo.cxx42
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx21
-rw-r--r--vcl/source/outdev/line.cxx18
6 files changed, 35 insertions, 73 deletions
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx
index 7f07e472bef8..592e67bab9a5 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -524,23 +524,7 @@ namespace wmfemfhelper
if(bDashDotUsed)
{
- std::vector< double > fDotDashArray;
- const double fDashLen(rLineInfo.GetDashLen());
- const double fDotLen(rLineInfo.GetDotLen());
- const double fDistance(rLineInfo.GetDistance());
-
- for(sal_uInt16 a(0); a < rLineInfo.GetDashCount(); a++)
- {
- fDotDashArray.push_back(fDashLen);
- fDotDashArray.push_back(fDistance);
- }
-
- for(sal_uInt16 b(0); b < rLineInfo.GetDotCount(); b++)
- {
- fDotDashArray.push_back(fDotLen);
- fDotDashArray.push_back(fDistance);
- }
-
+ std::vector< double > fDotDashArray = rLineInfo.GetDotDashArray();
const double fAccumulated(std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0));
const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
std::move(fDotDashArray),
diff --git a/include/vcl/lineinfo.hxx b/include/vcl/lineinfo.hxx
index 73ed0d3a5771..0644359954b9 100644
--- a/include/vcl/lineinfo.hxx
+++ b/include/vcl/lineinfo.hxx
@@ -27,6 +27,8 @@
#include <com/sun/star/drawing/LineCap.hpp>
#include <o3tl/cow_wrapper.hxx>
+#include <vector>
+
class SvStream;
namespace basegfx { class B2DPolyPolygon; }
@@ -84,6 +86,9 @@ public:
void SetDistance( double nDistance );
double GetDistance() const { return mpImplLineInfo->mnDistance; }
+ /// Get an array of "on" and "off" lengths for stroke dashing
+ std::vector< double > GetDotDashArray() const;
+
void SetLineJoin(basegfx::B2DLineJoin eLineJoin);
basegfx::B2DLineJoin GetLineJoin() const { return mpImplLineInfo->meLineJoin; }
diff --git a/vcl/source/filter/eps/eps.cxx b/vcl/source/filter/eps/eps.cxx
index 1a73c682adf1..374b4c78218b 100644
--- a/vcl/source/filter/eps/eps.cxx
+++ b/vcl/source/filter/eps/eps.cxx
@@ -2300,9 +2300,9 @@ void PSWriter::ImplWriteLineInfo( double fLWidth, double fMLimit,
void PSWriter::ImplWriteLineInfo( const LineInfo& rLineInfo )
{
- SvtGraphicStroke::DashArray l_aDashArray;
+ std::vector< double > l_aDashArray;
if ( rLineInfo.GetStyle() == LineStyle::Dash )
- l_aDashArray.push_back( 2 );
+ l_aDashArray = rLineInfo.GetDotDashArray();
const double fLWidth(( ( rLineInfo.GetWidth() + 1 ) + ( rLineInfo.GetWidth() + 1 ) ) * 0.5);
SvtGraphicStroke::JoinType aJoinType(SvtGraphicStroke::joinMiter);
SvtGraphicStroke::CapType aCapType(SvtGraphicStroke::capButt);
diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx
index 94ab3b83df65..85e7c041943e 100644
--- a/vcl/source/gdi/lineinfo.cxx
+++ b/vcl/source/gdi/lineinfo.cxx
@@ -204,6 +204,30 @@ SvStream& WriteLineInfo( SvStream& rOStm, const LineInfo& rLineInfo )
return rOStm;
}
+std::vector< double > LineInfo::GetDotDashArray() const
+{
+ ::std::vector< double > fDotDashArray;
+ if ( GetStyle() != LineStyle::Dash )
+ return fDotDashArray;
+
+ const double fDashLen(GetDashLen());
+ const double fDotLen(GetDotLen());
+ const double fDistance(GetDistance());
+
+ for(sal_uInt16 a(0); a < GetDashCount(); a++)
+ {
+ fDotDashArray.push_back(fDashLen);
+ fDotDashArray.push_back(fDistance);
+ }
+
+ for(sal_uInt16 b(0); b < GetDotCount(); b++)
+ {
+ fDotDashArray.push_back(fDotLen);
+ fDotDashArray.push_back(fDistance);
+ }
+ return fDotDashArray;
+}
+
void LineInfo::applyToB2DPolyPolygon(
basegfx::B2DPolyPolygon& io_rLinePolyPolygon,
basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const
@@ -215,23 +239,7 @@ void LineInfo::applyToB2DPolyPolygon(
if(LineStyle::Dash == GetStyle())
{
- ::std::vector< double > fDotDashArray;
- const double fDashLen(GetDashLen());
- const double fDotLen(GetDotLen());
- const double fDistance(GetDistance());
-
- for(sal_uInt16 a(0); a < GetDashCount(); a++)
- {
- fDotDashArray.push_back(fDashLen);
- fDotDashArray.push_back(fDistance);
- }
-
- for(sal_uInt16 b(0); b < GetDotCount(); b++)
- {
- fDotDashArray.push_back(fDotLen);
- fDotDashArray.push_back(fDistance);
- }
-
+ ::std::vector< double > fDotDashArray = GetDotDashArray();
const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0));
if(fAccumulated > 0.0)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1847eb7d7f78..40eab868a80a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7780,26 +7780,7 @@ void PDFWriterImpl::convertLineInfoToExtLineInfo( const LineInfo& rIn, PDFWriter
rOut.m_eCap = PDFWriter::capButt;
rOut.m_eJoin = PDFWriter::joinMiter;
rOut.m_fMiterLimit = 10;
- rOut.m_aDashArray.clear();
-
- // add DashDot to DashArray
- const int nDashes = rIn.GetDashCount();
- const int nDashLen = rIn.GetDashLen();
- const int nDistance = rIn.GetDistance();
-
- for( int n = 0; n < nDashes; n++ )
- {
- rOut.m_aDashArray.push_back( nDashLen );
- rOut.m_aDashArray.push_back( nDistance );
- }
- const int nDots = rIn.GetDotCount();
- const int nDotLen = rIn.GetDotLen();
-
- for( int n = 0; n < nDots; n++ )
- {
- rOut.m_aDashArray.push_back( nDotLen );
- rOut.m_aDashArray.push_back( nDistance );
- }
+ rOut.m_aDashArray = rIn.GetDotDashArray();
// add LineJoin
switch(rIn.GetLineJoin())
diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx
index 3fb565f5499f..2556a09bff82 100644
--- a/vcl/source/outdev/line.cxx
+++ b/vcl/source/outdev/line.cxx
@@ -232,23 +232,7 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin
if(bDashUsed && aLinePolyPolygon.count())
{
- ::std::vector< double > fDotDashArray;
- const double fDashLen(rInfo.GetDashLen());
- const double fDotLen(rInfo.GetDotLen());
- const double fDistance(rInfo.GetDistance());
-
- for(sal_uInt16 a(0); a < rInfo.GetDashCount(); a++)
- {
- fDotDashArray.push_back(fDashLen);
- fDotDashArray.push_back(fDistance);
- }
-
- for(sal_uInt16 b(0); b < rInfo.GetDotCount(); b++)
- {
- fDotDashArray.push_back(fDotLen);
- fDotDashArray.push_back(fDistance);
- }
-
+ ::std::vector< double > fDotDashArray = rInfo.GetDotDashArray();
const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0));
if(fAccumulated > 0.0)