summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/lineinfo.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/gdi/lineinfo.cxx')
-rw-r--r--vcl/source/gdi/lineinfo.cxx109
1 files changed, 106 insertions, 3 deletions
diff --git a/vcl/source/gdi/lineinfo.cxx b/vcl/source/gdi/lineinfo.cxx
index 98f16713a145..7aa50811106b 100644
--- a/vcl/source/gdi/lineinfo.cxx
+++ b/vcl/source/gdi/lineinfo.cxx
@@ -34,6 +34,10 @@
#include <tools/vcompat.hxx>
#include <tools/debug.hxx>
#include <vcl/lineinfo.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <numeric>
DBG_NAME( LineInfo )
@@ -49,7 +53,8 @@ ImplLineInfo::ImplLineInfo() :
mnDashLen ( 0 ),
mnDotCount ( 0 ),
mnDotLen ( 0 ),
- mnDistance ( 0 )
+ mnDistance ( 0 ),
+ meLineJoin ( basegfx::B2DLINEJOIN_ROUND )
{
}
@@ -63,7 +68,8 @@ ImplLineInfo::ImplLineInfo( const ImplLineInfo& rImplLineInfo ) :
mnDashLen ( rImplLineInfo.mnDashLen ),
mnDotCount ( rImplLineInfo.mnDotCount ),
mnDotLen ( rImplLineInfo.mnDotLen ),
- mnDistance ( rImplLineInfo.mnDistance )
+ mnDistance ( rImplLineInfo.mnDistance ),
+ meLineJoin ( rImplLineInfo.meLineJoin )
{
}
@@ -209,6 +215,19 @@ void LineInfo::SetDistance( long nDistance )
// -----------------------------------------------------------------------
+void LineInfo::SetLineJoin(basegfx::B2DLineJoin eLineJoin)
+{
+ DBG_CHKTHIS( LineInfo, NULL );
+
+ if(eLineJoin != mpImplLineInfo->meLineJoin)
+ {
+ ImplMakeUnique();
+ mpImplLineInfo->meLineJoin = eLineJoin;
+ }
+}
+
+// -----------------------------------------------------------------------
+
SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo )
{
VersionCompat aCompat( rIStm, STREAM_READ );
@@ -225,6 +244,12 @@ SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo )
rIStm >> rImplLineInfo.mnDistance;
}
+ if( aCompat.GetVersion() >= 3 )
+ {
+ // version 3
+ rIStm >> nTmp16; rImplLineInfo.meLineJoin = (basegfx::B2DLineJoin) nTmp16;
+ }
+
return rIStm;
}
@@ -232,7 +257,7 @@ SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo )
SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo )
{
- VersionCompat aCompat( rOStm, STREAM_WRITE, 2 );
+ VersionCompat aCompat( rOStm, STREAM_WRITE, 3 );
// version 1
rOStm << (UINT16) rImplLineInfo.meStyle << rImplLineInfo.mnWidth;
@@ -242,6 +267,9 @@ SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo )
rOStm << rImplLineInfo.mnDotCount << rImplLineInfo.mnDotLen;
rOStm << rImplLineInfo.mnDistance;
+ // since version3
+ rOStm << (UINT16) rImplLineInfo.meLineJoin;
+
return rOStm;
}
@@ -259,3 +287,78 @@ SvStream& operator<<( SvStream& rOStm, const LineInfo& rLineInfo )
{
return( rOStm << *rLineInfo.mpImplLineInfo );
}
+
+// -----------------------------------------------------------------------
+
+bool LineInfo::isDashDotOrFatLineUsed() const
+{
+ return (LINE_DASH == GetStyle() || GetWidth() > 1);
+}
+
+// -----------------------------------------------------------------------
+
+void LineInfo::applyToB2DPolyPolygon(
+ basegfx::B2DPolyPolygon& io_rLinePolyPolygon,
+ basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const
+{
+ o_rFillPolyPolygon.clear();
+
+ if(io_rLinePolyPolygon.count())
+ {
+ if(LINE_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);
+ }
+
+ const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0));
+
+ if(fAccumulated > 0.0)
+ {
+ basegfx::B2DPolyPolygon aResult;
+
+ for(sal_uInt32 c(0); c < io_rLinePolyPolygon.count(); c++)
+ {
+ basegfx::B2DPolyPolygon aLineTraget;
+ basegfx::tools::applyLineDashing(
+ io_rLinePolyPolygon.getB2DPolygon(c),
+ fDotDashArray,
+ &aLineTraget);
+ aResult.append(aLineTraget);
+ }
+
+ io_rLinePolyPolygon = aResult;
+ }
+ }
+
+ if(GetWidth() > 1 && io_rLinePolyPolygon.count())
+ {
+ const double fHalfLineWidth((GetWidth() * 0.5) + 0.5);
+
+ for(sal_uInt32 a(0); a < io_rLinePolyPolygon.count(); a++)
+ {
+ o_rFillPolyPolygon.append(basegfx::tools::createAreaGeometry(
+ io_rLinePolyPolygon.getB2DPolygon(a),
+ fHalfLineWidth,
+ GetLineJoin()));
+ }
+
+ io_rLinePolyPolygon.clear();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------