[ooo-build-commit] .: svtools/inc svtools/source svtools/util

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Wed Oct 6 15:01:42 PDT 2010


 svtools/inc/borderhelper.hxx       |   49 ++++++++++++
 svtools/inc/ctrlbox.hxx            |   39 +++++++--
 svtools/inc/rtfkeywd.hxx           |    2 
 svtools/source/control/ctrlbox.cxx |  147 +++++++++++++++++++++++++++++++++----
 svtools/util/makefile.mk           |    3 
 5 files changed, 218 insertions(+), 22 deletions(-)

New commits:
commit ffb6f62ac9575de5367cb95a618ad45a00c585a8
Author: Cédric Bosdonnat <cedricbosdo at openoffice.org>
Date:   Wed Oct 6 23:53:00 2010 +0200

    fate#307731, fate#307730: Adds dotted and dashed border lines

diff --git a/svtools/inc/borderhelper.hxx b/svtools/inc/borderhelper.hxx
new file mode 100644
index 0000000..6e9864a
--- /dev/null
+++ b/svtools/inc/borderhelper.hxx
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ctrlbox.hxx,v $
+ * $Revision: 1.15 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BORDERHELPER_HXX
+#define _BORDERHELPER_HXX
+
+#include "svtools/svtdllapi.h"
+
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <vcl/outdev.hxx>
+
+namespace svtools
+{
+    SVT_DLLPUBLIC basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon,
+            USHORT nDashing, MapUnit eUnit );
+
+    SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const Point& rBeg,
+            const Point& rEnd, sal_uInt32 nWidth, USHORT nDashing );
+}
+
+#endif
diff --git a/svtools/inc/ctrlbox.hxx b/svtools/inc/ctrlbox.hxx
index 20bc75c..f997e00 100644
--- a/svtools/inc/ctrlbox.hxx
+++ b/svtools/inc/ctrlbox.hxx
@@ -42,6 +42,10 @@ class ImpColorList;
 class ImpLineList;
 class FontList;
 
+#define STYLE_SOLID     ( ( USHORT ) 0 )
+#define STYLE_DOTTED    ( ( USHORT ) 1 )
+#define STYLE_DASHED    ( ( USHORT ) 2 )
+
 /*************************************************************************
 
 Beschreibung
@@ -243,7 +247,8 @@ class SVT_DLLPUBLIC LineListBox : public ListBox
     FieldUnit		eUnit;
     FieldUnit		eSourceUnit;
 
-    SVT_DLLPRIVATE void			ImpGetLine( long nLine1, long nLine2, long nDistance, Bitmap& rBmp, XubString& rStr );
+    SVT_DLLPRIVATE void			ImpGetLine( long nLine1, long nLine2, long nDistance,
+                                    USHORT nStyle, Bitmap& rBmp, XubString& rStr );
     using Window::ImplInit;
     SVT_DLLPRIVATE void			ImplInit();
     void			UpdateLineColors( void );
@@ -258,24 +263,30 @@ public:
 
     using ListBox::InsertEntry;
     virtual USHORT	InsertEntry( const XubString& rStr, USHORT nPos = LISTBOX_APPEND );
-    virtual USHORT	InsertEntry( long nLine1, long nLine2 = 0, long nDistance = 0, USHORT nPos = LISTBOX_APPEND );
+    virtual USHORT	InsertEntry( long nLine1, long nLine2 = 0, long nDistance = 0,
+                                USHORT nStyle = STYLE_SOLID, USHORT nPos = LISTBOX_APPEND );
     using ListBox::RemoveEntry;
     virtual void	RemoveEntry( USHORT nPos );
     virtual void	Clear();
 
     using ListBox::GetEntryPos;
-    USHORT			GetEntryPos( long nLine1, long nLine2 = 0, long nDistance = 0 ) const;
+    USHORT			GetEntryPos( long nLine1, long nLine2 = 0, long nDistance = 0,
+                                 USHORT nStyle = STYLE_SOLID ) const;
     long			GetEntryLine1( USHORT nPos ) const;
     long			GetEntryLine2( USHORT nPos ) const;
     long			GetEntryDistance( USHORT nPos ) const;
+    USHORT          GetEntryStyle( USHORT nPos ) const;
 
     inline void		SelectEntry( const XubString& rStr, BOOL bSelect = TRUE ) { ListBox::SelectEntry( rStr, bSelect ); }
-    void			SelectEntry( long nLine1, long nLine2 = 0, long nDistance = 0, BOOL bSelect = TRUE );
+    void			SelectEntry( long nLine1, long nLine2 = 0, long nDistance = 0,
+                                 USHORT nStyle = STYLE_SOLID, BOOL bSelect = TRUE );
     long			GetSelectEntryLine1( USHORT nSelIndex = 0 ) const;
     long			GetSelectEntryLine2( USHORT nSelIndex = 0 ) const;
     long			GetSelectEntryDistance( USHORT nSelIndex = 0 ) const;
+    USHORT  		GetSelectEntryStyle( USHORT nSelIndex = 0 ) const;
     inline BOOL		IsEntrySelected( const XubString& rStr ) const { return ListBox::IsEntrySelected( rStr ); }
-    BOOL			IsEntrySelected( long nLine1, long nLine2 = 0, long nDistance = 0 ) const;
+    BOOL			IsEntrySelected( long nLine1, long nLine2 = 0, long nDistance = 0,
+                                     USHORT nStyle1 = STYLE_SOLID ) const;
 
     inline void		SetUnit( FieldUnit eNewUnit ) { eUnit = eNewUnit; }
     inline FieldUnit	GetUnit() const { return eUnit; }
@@ -293,9 +304,9 @@ private:
     void*			GetEntryData( USHORT nPos ) const;
 };
 
-inline void LineListBox::SelectEntry( long nLine1, long nLine2, long nDistance, BOOL bSelect )
+inline void LineListBox::SelectEntry( long nLine1, long nLine2, long nDistance, USHORT nStyle, BOOL bSelect )
 {
-    USHORT nPos = GetEntryPos( nLine1, nLine2, nDistance );
+    USHORT nPos = GetEntryPos( nLine1, nLine2, nDistance, nStyle );
     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
         ListBox::SelectEntryPos( nPos, bSelect );
 }
@@ -327,9 +338,19 @@ inline long LineListBox::GetSelectEntryDistance( USHORT nSelIndex ) const
         return 0;
 }
 
-inline BOOL LineListBox::IsEntrySelected( long nLine1, long nLine2, long nDistance ) const
+inline USHORT LineListBox::GetSelectEntryStyle( USHORT nSelIndex ) const
+{
+    USHORT nStyle = STYLE_SOLID;
+    USHORT nPos = GetSelectEntryPos( nSelIndex );
+    if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+        nStyle = GetEntryStyle( nPos );
+
+    return nStyle;
+}
+
+inline BOOL LineListBox::IsEntrySelected( long nLine1, long nLine2, long nDistance, USHORT nStyle ) const
 {
-    USHORT nPos = GetEntryPos( nLine1, nLine2, nDistance );
+    USHORT nPos = GetEntryPos( nLine1, nLine2, nDistance, nStyle );
     if ( nPos != LISTBOX_ENTRY_NOTFOUND )
         return IsEntryPosSelected( nPos );
     else
diff --git a/svtools/inc/rtfkeywd.hxx b/svtools/inc/rtfkeywd.hxx
index 7fd5f41..a8a4490 100644
--- a/svtools/inc/rtfkeywd.hxx
+++ b/svtools/inc/rtfkeywd.hxx
@@ -70,6 +70,8 @@
 #define OOO_STRING_SVTOOLS_RTF_BRDRCF "\\brdrcf"
 #define OOO_STRING_SVTOOLS_RTF_BRDRDB "\\brdrdb"
 #define OOO_STRING_SVTOOLS_RTF_BRDRDOT "\\brdrdot"
+#define OOO_STRING_SVTOOLS_RTF_BRDRDASH "\\brdrdash"
+#define OOO_STRING_SVTOOLS_RTF_BRDRDASHSM "\\brdrdashsm"
 #define OOO_STRING_SVTOOLS_RTF_BRDRHAIR "\\brdrhair"
 #define OOO_STRING_SVTOOLS_RTF_BRDRL "\\brdrl"
 #define OOO_STRING_SVTOOLS_RTF_BRDRR "\\brdrr"
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index b343189..f1d834b 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -39,8 +39,11 @@
 #include <svtools/svtools.hrc>
 #include <ctrlbox.hxx>
 #include <ctrltool.hxx>
+#include <borderhelper.hxx>
 
 #include <vcl/i18nhelp.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
 
 #define IMGTEXTSPACE    2
 #define EXTRAFONTSIZE   5
@@ -248,6 +251,7 @@ struct ImpLineListData
     long    nLine1;
     long    nLine2;
     long    nDistance;
+    USHORT  nStyle;
 };
 
 DECLARE_LIST( ImpLineList, ImpLineListData* )
@@ -261,8 +265,107 @@ inline const Color& LineListBox::GetPaintColor( void ) const
 
 // -----------------------------------------------------------------------
 
+
+inline void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, long nWidth, USHORT nDashing )
+{
+    USHORT nOldAA = rDev.GetAntialiasing();
+    rDev.SetAntialiasing( nOldAA & !ANTIALIASING_ENABLE_B2DDRAW );
+
+    Color aOldColor = rDev.GetFillColor( );
+    rDev.SetFillColor( rDev.GetLineColor( ) );
+
+    basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing( rPolygon, nDashing, rDev.GetMapMode().GetMapUnit() );
+    for ( sal_uInt32 i = 0; i < aPolygons.count( ); i++ )
+    {
+        basegfx::B2DPolygon aDash = aPolygons.getB2DPolygon( i );
+        basegfx::B2DPoint aStart = aDash.getB2DPoint( 0 );
+        basegfx::B2DPoint aEnd = aDash.getB2DPoint( aDash.count() - 1 );
+
+        basegfx::B2DVector aVector( aEnd - aStart );
+        aVector.normalize( );
+        const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
+
+        const basegfx::B2DVector aWidthOffset( nWidth / 2 * aPerpendicular);
+        basegfx::B2DPolygon aDashPolygon;
+        aDashPolygon.append( aStart + aWidthOffset );
+        aDashPolygon.append( aEnd + aWidthOffset );
+        aDashPolygon.append( aEnd - aWidthOffset );
+        aDashPolygon.append( aStart - aWidthOffset );
+        aDashPolygon.setClosed( true );
+
+        rDev.DrawPolygon( aDashPolygon );
+    }
+
+    rDev.SetFillColor( aOldColor );
+    rDev.SetAntialiasing( nOldAA );
+}
+
+namespace svtools
+{
+    basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, USHORT nDashing, MapUnit eUnit )
+    {
+        ::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;
+            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;
+            default:
+                break;
+        }
+
+        basegfx::B2DPolyPolygon aPolygons;
+        if ( ! aPattern.empty() )
+            basegfx::tools::applyLineDashing( rPolygon, aPattern, &aPolygons );
+        else
+            aPolygons.append( rPolygon );
+
+        return aPolygons;
+    }
+
+    void DrawLine( OutputDevice& rDev, const Point& rP1, const Point& rP2,
+        sal_uInt32 nWidth, USHORT nDashing )
+    {
+        basegfx::B2DPolygon aPolygon;
+        aPolygon.append( basegfx::B2DPoint( rP1.X(), rP1.Y() ) );
+        aPolygon.append( basegfx::B2DPoint( rP2.X(), rP2.Y() ) );
+        lclDrawPolygon( rDev, aPolygon, nWidth, nDashing );
+    }
+}
+
 void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance,
-                            Bitmap& rBmp, XubString& rStr )
+                            USHORT nStyle, Bitmap& rBmp, XubString& rStr )
 {
     Size aSize = GetOutputSizePixel();
     aSize.Width() -= 20;
@@ -289,8 +392,8 @@ void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance,
     // Linien malen
     aSize = aVirDev.PixelToLogic( aSize );
     long nPix = aVirDev.PixelToLogic( Size( 0, 1 ) ).Height();
-    long n1 = nLine1 / 100;
-    long n2 = nLine2 / 100;
+    sal_uInt32 n1 = nLine1 / 100;
+    sal_uInt32 n2 = nLine2 / 100;
     long nDist  = nDistance / 100;
     n1 += nPix-1;
     n1 -= n1%nPix;
@@ -313,13 +416,18 @@ void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance,
         aVirDev.SetFillColor( GetSettings().GetStyleSettings().GetFieldColor() );
         aVirDev.DrawRect( Rectangle( Point(), aSize ) );
 
-        aVirDev.SetFillColor( GetPaintColor() );
-        aVirDev.DrawRect( Rectangle( 0, 0, aSize.Width(), n1-nPix ) );
+        Color oldColor = aVirDev.GetLineColor( );
+        aVirDev.SetLineColor( GetPaintColor( ) );
+
+        double y1 = n1 / 2;
+        svtools::DrawLine( aVirDev, Point( 0, y1 ), Point( aSize.Width( ), y1 ), n1, nStyle );
+
         if ( n2 )
         {
-            aVirDev.DrawRect( Rectangle( 0, n1+nDist,
-                                         aSize.Width(), n1+nDist+n2-nPix ) );
+            double y2 =  n1 + nDist + n2 / 2;
+            svtools::DrawLine( aVirDev, Point( 0, y2 ), Point( aSize.Width(), y2 ), n2, STYLE_SOLID );
         }
+        aVirDev.SetLineColor( oldColor );
         rBmp = aVirDev.GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
     }
     // Twips nach Unit
@@ -410,11 +518,11 @@ USHORT LineListBox::InsertEntry( const XubString& rStr, USHORT nPos )
 // -----------------------------------------------------------------------
 
 USHORT LineListBox::InsertEntry( long nLine1, long nLine2, long nDistance,
-                                USHORT nPos )
+                                USHORT nStyle, USHORT nPos )
 {
     XubString   aStr;
     Bitmap      aBmp;
-    ImpGetLine( nLine1, nLine2, nDistance, aBmp, aStr );
+    ImpGetLine( nLine1, nLine2, nDistance, nStyle, aBmp, aStr );
     nPos = ListBox::InsertEntry( aStr, aBmp, nPos );
     if ( nPos != LISTBOX_ERROR )
     {
@@ -422,6 +530,7 @@ USHORT LineListBox::InsertEntry( long nLine1, long nLine2, long nDistance,
         pData->nLine1    = nLine1;
         pData->nLine2    = nLine2;
         pData->nDistance = nDistance;
+        pData->nStyle    = nStyle;
         pLineList->Insert( pData, nPos );
     }
 
@@ -459,7 +568,7 @@ void LineListBox::Clear()
 // -----------------------------------------------------------------------
 
 USHORT LineListBox::GetEntryPos( long nLine1, long nLine2,
-                                long nDistance ) const
+                                long nDistance, USHORT nStyle ) const
 {
     ULONG n = 0;
     ULONG nCount = pLineList->Count();
@@ -470,7 +579,8 @@ USHORT LineListBox::GetEntryPos( long nLine1, long nLine2,
         {
             if ( (pData->nLine1    == nLine1) &&
                 (pData->nLine2    == nLine2) &&
-                (pData->nDistance == nDistance) )
+                (pData->nDistance == nDistance) &&
+                (pData->nStyle == nStyle) )
             return (USHORT)n;
         }
 
@@ -515,6 +625,18 @@ long LineListBox::GetEntryDistance( USHORT nPos ) const
 
 // -----------------------------------------------------------------------
 
+USHORT LineListBox::GetEntryStyle( USHORT nPos ) const
+{
+    USHORT nStyle = STYLE_SOLID;
+    ImpLineListData* pData = pLineList->GetObject( nPos );
+    if ( pData )
+        nStyle = pData->nStyle;
+
+    return nStyle;
+}
+
+// -----------------------------------------------------------------------
+
 void LineListBox::UpdateLineColors( void )
 {
     if( UpdatePaintLineColor() )
@@ -537,7 +659,8 @@ void LineListBox::UpdateLineColors( void )
             {
                 // exchange listbox data
                 ListBox::RemoveEntry( USHORT( n ) );
-                ImpGetLine( pData->nLine1, pData->nLine2, pData->nDistance, aBmp, aStr );
+                ImpGetLine( pData->nLine1, pData->nLine2, pData->nDistance,
+                        pData->nStyle, aBmp, aStr );
                 ListBox::InsertEntry( aStr, aBmp, USHORT( n ) );
             }
         }
diff --git a/svtools/util/makefile.mk b/svtools/util/makefile.mk
index f9c14a5..1eb74c9 100644
--- a/svtools/util/makefile.mk
+++ b/svtools/util/makefile.mk
@@ -123,7 +123,8 @@ SHL1STDLIBS+= \
         $(VOSLIB)			\
         $(SALLIB)			\
         $(ICUUCLIB)		\
-        $(JVMFWKLIB)
+        $(JVMFWKLIB) \
+        $(BASEGFXLIB)
 
 .IF "$(OS)"=="MACOSX"
 # static libraries go at end


More information about the ooo-build-commit mailing list