Hello!
I tried to draw polyline.... But on Windows... the end point is not
drawn... the main problem is WinAPI LineTo() function. MSDN says:
The *LineTo* function draws a line from the current position up to,
but not including, the specified point.
I think WinAPI Polyline() function uses LineTo() to draw a polyline. I
see a hack in VCL module in WinSalgraphics::drawLine():
// we must paint the endpoint
But there is no such hack for drawPolyLine() function. A possible
solution is same as for drawLine():
------------------------------------------------------------------------
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -1346,10 +1346,45 @@ void WinSalGraphics::drawPolyLine( sal_uLong
nPoints, const SalPoint* pPtAry )
"WinSalGraphics::DrawPolyLine(): POINT != SalPoint" );
POINT* pWinPtAry = (POINT*)pPtAry;
+
+ // we assume there are at least 2 points (Polyline requres at least
2 point, see MSDN)
+ // we must paint the endpoint for last line
+ BOOL bPaintEnd = TRUE;
+ if ( pWinPtAry[nPoints-2].x == pWinPtAry[nPoints-1].x )
+ {
+ bPaintEnd = FALSE;
+ if ( pWinPtAry[nPoints-2].y <= pWinPtAry[nPoints-1].y )
+ pWinPtAry[nPoints-1].y++;
+ else
+ pWinPtAry[nPoints-1].y--;
+ }
+ if ( pWinPtAry[nPoints-2].y == pWinPtAry[nPoints-1].y )
+ {
+ bPaintEnd = FALSE;
+ if ( pWinPtAry[nPoints-2].x <= pWinPtAry[nPoints-1].x )
+ pWinPtAry[nPoints-1].x++;
+ else
+ pWinPtAry[nPoints-1].x--;
+ }
+
// Wegen Windows 95 und der Beschraenkung auf eine maximale Anzahl
// von Punkten
if ( !Polyline( mhDC, pWinPtAry, (int)nPoints ) && (nPoints >
MAX_64KSALPOINTS) )
Polyline( mhDC, pWinPtAry, MAX_64KSALPOINTS );
+
+ if ( bPaintEnd && !mbPrinter )
+ {
+ if ( mbXORMode )
+ {
+ HBRUSH hBrush = CreateSolidBrush( mnPenColor );
+ HBRUSH hOldBrush = SelectBrush( mhDC, hBrush );
+ PatBlt( mhDC, (int)(pWinPtAry[nPoints-1].x),
(int)(pWinPtAry[nPoints-1].y), (int)1, (int)1, PATINVERT );
+ SelectBrush( mhDC, hOldBrush );
+ DeleteBrush( hBrush );
+ }
+ else
+ SetPixel( mhDC, (int)(pWinPtAry[nPoints-1].x),
(int)(pWinPtAry[nPoints-1].y), mnPenColor );
+ }
}
// -----------------------------------------------------------------------
------------------------------------------------------------------------
--
Best Regards,
Dmitry
--
Best Regards,
Dmitry
begin:vcard
fn:Dmitry Ashkadov
n:Ashkadov;Dmitry
email;internet:dmitry.ashkadov@gmail.com
note:JID: dmitryash@jabber.mipt.ru
version:2.1
end:vcard
Context
- [Libreoffice] DrawPolyLine on Windows · Dmitry. A. Ashkadov
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.