summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-01-04 13:41:04 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:57:31 +0100
commit6447abcac76e61c880715e94a37f3563de4676ec (patch)
tree8468ec51b075bf0c4738cb731a7f7ed91564ed0d /svtools
parentbffee3e11a1ba1749e8edb5d5c68b1087ff3dcab (diff)
Fixed units mess in SvxBorderLine and BorderLineImpl
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/ctrlbox.hxx25
-rw-r--r--svtools/source/control/ctrlbox.cxx36
2 files changed, 40 insertions, 21 deletions
diff --git a/svtools/inc/svtools/ctrlbox.hxx b/svtools/inc/svtools/ctrlbox.hxx
index c01fd8f4ab4e..a2d85aef749f 100644
--- a/svtools/inc/svtools/ctrlbox.hxx
+++ b/svtools/inc/svtools/ctrlbox.hxx
@@ -394,16 +394,33 @@ SVT_DLLPUBLIC inline Color sameDistColor( Color /*rMain*/, Color rDefault )
return rDefault;
}
+/**
+ Class computing border widths shared between Line style listbox and the
+ SvxBorderLine implementation.
+
+ This class doesn't know anything about units: it all depends on the different
+ values set. A border is composed of 2 lines separated by a gap. The computed
+ widths are the ones of each line and the gap and they can either be fix or vary.
+
+ The #m_nflags member will define which widths will vary (value 0 means that all
+ widths are fixed). The available flags are:
+ - CHANGE_LINE1
+ - CHANGE_LINE2
+ - CHANGE_DIST
+
+ For each line, the rate member is used as a multiplication factor is the width
+ isn't fixed. Otherwise it is the width in the unit expected by the client code.
+ */
class SVT_DLLPUBLIC BorderWidthImpl
{
- USHORT m_nFlags;
+ sal_uInt16 m_nFlags;
double m_nRate1;
double m_nRate2;
double m_nRateGap;
public:
- BorderWidthImpl( USHORT nFlags = CHANGE_LINE1, double nRate1 = 0.0,
+ BorderWidthImpl( sal_uInt16 nFlags = CHANGE_LINE1, double nRate1 = 0.0,
double nRate2 = 0.0, double nRateGap = 0.0 );
BorderWidthImpl& operator= ( const BorderWidthImpl& r );
@@ -437,14 +454,14 @@ public:
void SetNone( const XubString& sNone );
using LineListBox::InsertEntry;
+ /** Insert a listbox entry with all widths in Twips. */
void InsertEntry( BorderWidthImpl aWidthImpl,
sal_uInt16 nStyle, long nMinWidth = 0,
Color (*pColor1Fn)(Color) = &sameColor,
Color (*pColor2Fn)( Color ) = &sameColor,
Color (*pColorDistFn)( Color, Color ) = &sameDistColor );
- sal_uInt16 GetSelectedStyle( );
- long GetWidthFromStyle( long nLine1, long nLine2, long nDistance, sal_uInt16 nStyle );
+ ULONG GetSelectedStyle( );
virtual sal_uInt16 GetEntryPos( long nLine1, long nLine2 = 0, long nDistance = 0,
sal_uInt16 nStyle = STYLE_SOLID ) const;
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index f9f11afe1041..0c558aeaaa25 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -53,6 +53,9 @@
#define EXTRAFONTSIZE 5
#define MAXPREVIEWWIDTH 100
+#define TWIPS_TO_PT100(val) (val * 5)
+#define PT100_TO_TWIPS(val) (val / 5)
+
using namespace ::com::sun::star;
// ========================================================================
@@ -877,6 +880,9 @@ long BorderWidthImpl::GuessWidth( long nLine1, long nLine2, long nGap )
return long( nWidth );
}
+/** Utility class storing the border line width, style and colors. The widths
+ are defined in Twips.
+ */
class ImpLineStyleListData
{
private:
@@ -894,21 +900,28 @@ public:
long nMinWidth=0, Color ( *pColor1Fn ) ( Color ) = &sameColor,
Color ( *pColor2Fn ) ( Color ) = &sameColor, Color ( *pColorDistFn ) ( Color, Color ) = &sameDistColor );
- long GetLine1ForWidth( long nWidth ) { return m_aWidthImpl.GetLine1( nWidth ); }
- long GetLine2ForWidth( long nWidth ) { return m_aWidthImpl.GetLine2( nWidth ); }
- long GetDistForWidth( long nWidth ) { return m_aWidthImpl.GetGap( nWidth ); }
+ /** Returns the computed width of the line 1 in 100th of pt. */
+ long GetLine1ForWidth( long nWidth ) { return TWIPS_TO_PT100( m_aWidthImpl.GetLine1( nWidth ) ); }
+
+ /** Returns the computed width of the line 2 in 100th of pt. */
+ long GetLine2ForWidth( long nWidth ) { return TWIPS_TO_PT100( m_aWidthImpl.GetLine2( nWidth ) ); }
- long GetTotalWidth( long nWidth );
+ /** Returns the computed width of the gap in 100th of pt. */
+ long GetDistForWidth( long nWidth ) { return TWIPS_TO_PT100( m_aWidthImpl.GetGap( nWidth ) ); }
Color GetColorLine1( const Color& aMain );
Color GetColorLine2( const Color& aMain );
Color GetColorDist( const Color& aMain, const Color& rDefault );
+ /** Returns the minimum width in 100th of pt */
long GetMinWidth( );
sal_uInt16 GetStyle( );
+ /** Guess the width based on all the lines computed widths in 100th of pt.
+ The result value is expressed in Twips. */
long GuessWidth( long nLine1, long nLine2, long nDist )
- { return m_aWidthImpl.GuessWidth( nLine1, nLine2, nDist ); }
+ { return m_aWidthImpl.GuessWidth( PT100_TO_TWIPS( nLine1 ),
+ PT100_TO_TWIPS( nLine2 ), PT100_TO_TWIPS( nDist ) ); }
};
ImpLineStyleListData::ImpLineStyleListData( BorderWidthImpl aWidthImpl,
@@ -925,7 +938,7 @@ ImpLineStyleListData::ImpLineStyleListData( BorderWidthImpl aWidthImpl,
long ImpLineStyleListData::GetMinWidth( )
{
- return m_nMinWidth;
+ return TWIPS_TO_PT100( m_nMinWidth );
}
Color ImpLineStyleListData::GetColorLine1( const Color& rMain )
@@ -1036,17 +1049,6 @@ sal_uInt16 LineStyleListBox::GetSelectedStyle( )
return GetStylePos( nSelEntry, m_nWidth );
}
-long LineStyleListBox::GetWidthFromStyle( long nLine1, long nLine2, long nDistance, sal_uInt16 nStyle )
-{
- long nResult = 0;
- ImpLineStyleListData* pData = m_pStyleList->GetObject( nStyle );
- if ( pData )
- {
- nResult = pData->GuessWidth( nLine1, nLine2, nDistance );
- }
- return nResult;
-}
-
sal_uInt16 LineStyleListBox::GetEntryPos( long /*nLine1*/, long /*nLine2*/,
long /*nDistance*/, sal_uInt16 nStyle ) const
{