summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-01-13 13:18:25 -0500
committerAndras Timar <andras.timar@collabora.com>2014-01-29 22:33:16 +0000
commit9a19e8d838753128504274e1885eb3ce8ec1dbb8 (patch)
treeba7783a8d2ddfa3a4f2fedd9fc4075e1b8a0990b /svtools
parent33ada1f20a2cdd6d52e6cb6e81aa0477ec0df563 (diff)
fdo#73487, fdo#73886: Overhaul cell borders to make them look sane.
Change-Id: Ie563f272b60ec8b6b8a4ff0df7256902997610c1 Reviewed-on: https://gerrit.libreoffice.org/7597 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrlbox.cxx116
1 files changed, 46 insertions, 70 deletions
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 33c15d63125e..06a4a9c77477 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -43,6 +43,8 @@
#include <rtl/bootstrap.hxx>
+#include <com/sun/star/table/BorderLineStyle.hpp>
+
#if OSL_DEBUG_LEVEL > 1
#include <cstdio>
#endif
@@ -59,6 +61,21 @@
using namespace ::com::sun::star;
+namespace {
+
+class ApplyScale : std::unary_function<double, void>
+{
+ double mfScale;
+public:
+ ApplyScale( double fScale ) : mfScale(fScale) {}
+ void operator() ( double& rVal )
+ {
+ rVal *= mfScale;
+ }
+};
+
+}
+
// ========================================================================
// ColorListBox
// ========================================================================
@@ -551,7 +568,13 @@ void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, lo
sal_uInt16 nOldAA = rDev.GetAntialiasing();
rDev.SetAntialiasing( nOldAA & ~ANTIALIASING_ENABLE_B2DDRAW );
- basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing( rPolygon, nDashing, rDev.GetMapMode().GetMapUnit() );
+ long nPix = rDev.PixelToLogic(Size(1, 1)).Width();
+ basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing(rPolygon, nDashing, nPix);
+
+ // Handle problems of width 1px in Pixel mode: 0.5px gives a 1px line
+ if (rDev.GetMapMode().GetMapUnit() == MAP_PIXEL && nWidth == nPix)
+ nWidth = 0;
+
for ( sal_uInt32 i = 0; i < aPolygons.count( ); i++ )
{
basegfx::B2DPolygon aDash = aPolygons.getB2DPolygon( i );
@@ -562,11 +585,6 @@ void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, lo
aVector.normalize( );
const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
- // Handle problems of width 1px in Pixel mode: 0.5px gives a 1px line
- long nPix = rDev.PixelToLogic( Size( 0, 1 ) ).Height();
- if ( rDev.GetMapMode().GetMapUnit() == MAP_PIXEL && nWidth == nPix )
- nWidth = 0;
-
const basegfx::B2DVector aWidthOffset( double( nWidth ) / 2 * aPerpendicular);
basegfx::B2DPolygon aDashPolygon;
aDashPolygon.append( aStart + aWidthOffset );
@@ -583,90 +601,48 @@ void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, lo
namespace svtools
{
- std::vector < double > GetDashing( sal_uInt16 nDashing, MapUnit eUnit )
+ std::vector < double > GetDashing( sal_uInt16 nDashing )
{
::std::vector < double >aPattern;
switch ( nDashing )
{
case STYLE_DOTTED:
- if ( eUnit == MAP_TWIP )
- {
- aPattern.push_back( 30.0 );
- aPattern.push_back( 110.0 );
- }
- else if ( eUnit == MAP_100TH_MM )
- {
- aPattern.push_back( 50 );
- aPattern.push_back( 200 );
- }
- else if ( eUnit == MAP_PIXEL )
- {
- aPattern.push_back( 1.0 );
- aPattern.push_back( 3.0 );
- }
- break;
+ aPattern.push_back( 1.0 );
+ aPattern.push_back( 2.0 );
+ break;
case STYLE_DASHED:
- if ( eUnit == MAP_TWIP )
- {
- aPattern.push_back( 110 );
- aPattern.push_back( 110 );
- }
- else if ( eUnit == MAP_100TH_MM )
- {
- aPattern.push_back( 200 );
- aPattern.push_back( 200 );
- }
- else if ( eUnit == MAP_PIXEL )
- {
- aPattern.push_back( 10 );
- aPattern.push_back( 20 );
- }
- break;
+ aPattern.push_back( 16.0 );
+ aPattern.push_back( 5.0 );
+ break;
case STYLE_FINE_DASHED:
- if ( eUnit == MAP_PIXEL )
- {
- aPattern.push_back( 8 );
- aPattern.push_back( 2 );
- }
- else if ( eUnit == MAP_TWIP )
- {
- aPattern.push_back( 120.0 );
- aPattern.push_back( 30.0 );
- }
- break;
+ aPattern.push_back( 6.0 );
+ aPattern.push_back( 2.0 );
+ break;
default:
- break;
+ ;
}
return aPattern;
}
- basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, MapUnit eUnit )
+ std::vector<double> GetLineDashing( sal_uInt16 nDashing, double fScale )
{
- std::vector< double > aPattern = GetDashing( nDashing, eUnit );
- basegfx::B2DPolyPolygon aPolygons;
- if ( ! aPattern.empty() )
- basegfx::tools::applyLineDashing( rPolygon, aPattern, &aPolygons );
- else
- aPolygons.append( rPolygon );
-
- return aPolygons;
+ std::vector<double> aPattern = GetDashing(nDashing);
+ std::for_each(aPattern.begin(), aPattern.end(), ApplyScale(fScale));
+ return aPattern;
}
- basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, MapUnit eUnit, double fScale )
+ basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, double fScale )
{
- std::vector< double > aPattern = GetDashing( nDashing, eUnit );
- std::vector< double >::iterator i = aPattern.begin();
- while( i != aPattern.end() ) {
- (*i) *= fScale;
- ++i;
- }
+ std::vector<double> aPattern = GetDashing(nDashing);
+ std::for_each(aPattern.begin(), aPattern.end(), ApplyScale(fScale));
basegfx::B2DPolyPolygon aPolygons;
- if ( ! aPattern.empty() )
- basegfx::tools::applyLineDashing( rPolygon, aPattern, &aPolygons );
+
+ if (aPattern.empty())
+ aPolygons.append(rPolygon);
else
- aPolygons.append( rPolygon );
+ basegfx::tools::applyLineDashing(rPolygon, aPattern, &aPolygons);
return aPolygons;
}