diff options
author | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-03-25 15:51:50 +0100 |
---|---|---|
committer | Cédric Bosdonnat <cedricbosdo@openoffice.org> | 2011-03-28 11:20:08 +0200 |
commit | fe551ada2d874b067cf57e80811d9b91e61b5457 (patch) | |
tree | 91929e0c884813e8d1b0039aa68050af7e0a021d /editeng | |
parent | b4000b20f09b70b4792d050bc1804025b059bdef (diff) |
Moved SvxBorder* into editeng namespace to avoid duplicate DOUBLE on windows
Diffstat (limited to 'editeng')
-rwxr-xr-x | editeng/inc/editeng/bolnitem.hxx | 12 | ||||
-rwxr-xr-x | editeng/inc/editeng/borderline.hxx | 250 | ||||
-rwxr-xr-x | editeng/inc/editeng/boxitem.hxx | 36 | ||||
-rw-r--r-- | editeng/qa/items/borderline_test.cxx | 2 | ||||
-rw-r--r-- | editeng/source/items/borderline.cxx | 46 | ||||
-rw-r--r-- | editeng/source/items/frmitems.cxx | 1 | ||||
-rw-r--r-- | editeng/source/rtf/rtfitem.cxx | 1 |
7 files changed, 183 insertions, 165 deletions
diff --git a/editeng/inc/editeng/bolnitem.hxx b/editeng/inc/editeng/bolnitem.hxx index ede5a5e80972..df843ea10f83 100755 --- a/editeng/inc/editeng/bolnitem.hxx +++ b/editeng/inc/editeng/bolnitem.hxx @@ -42,10 +42,12 @@ /* [Description] -This Item transports a SvxBorderLine. +This Item transports a editeng::SvxBorderLine. */ -class SvxBorderLine; +namespace editeng { + class SvxBorderLine; +} class EDITENG_DLLPUBLIC SvxLineItem : public SfxPoolItem { @@ -71,11 +73,11 @@ public: virtual bool ScaleMetrics( long nMult, long nDiv ); virtual bool HasMetrics() const; - const SvxBorderLine* GetLine () const { return pLine; } - void SetLine ( const SvxBorderLine *pNew ); + const editeng::SvxBorderLine* GetLine () const { return pLine; } + void SetLine ( const editeng::SvxBorderLine *pNew ); private: - SvxBorderLine* pLine; + editeng::SvxBorderLine* pLine; }; diff --git a/editeng/inc/editeng/borderline.hxx b/editeng/inc/editeng/borderline.hxx index 587e8839f0ae..92f9960ef79b 100755 --- a/editeng/inc/editeng/borderline.hxx +++ b/editeng/inc/editeng/borderline.hxx @@ -45,132 +45,136 @@ // ============================================================================ -enum SvxBorderStyle -{ - SOLID, - DOTTED, - DASHED, - DOUBLE, - THINTHICK_SMALLGAP, - THINTHICK_MEDIUMGAP, - THINTHICK_LARGEGAP, - THICKTHIN_SMALLGAP, - THICKTHIN_MEDIUMGAP, - THICKTHIN_LARGEGAP, - EMBOSSED, - ENGRAVED, - OUTSET, - INSET, - NO_STYLE = -1 -}; - -class EDITENG_DLLPUBLIC SvxBorderLine -{ -protected: - Color aColor; - - long m_nWidth; - bool m_bMirrorWidths; - BorderWidthImpl m_aWidthImpl; - long m_nMult; - long m_nDiv; - - SvxBorderStyle m_nStyle; - sal_uInt16 nOutWidth; - sal_uInt16 nInWidth; - sal_uInt16 nDistance; - - bool m_bUseLeftTop; - Color (*m_pColorOutFn)( Color ); - Color (*m_pColorInFn)( Color ); - Color (*m_pColorGapFn)( Color ); - -public: - SvxBorderLine( const Color *pCol = 0, - long nWidth = 0, SvxBorderStyle nStyle = SOLID, - bool bUseLeftTop = false, - Color (*pColorOutFn)( Color ) = &darkColor, - Color (*pColorInFn)( Color ) = &darkColor, - Color (*pColorGapFn)( Color ) = NULL ); - SvxBorderLine( const SvxBorderLine& r ); - - SvxBorderLine& operator=( const SvxBorderLine& r ); - - const Color& GetColor() const { return aColor; } - Color GetColorOut( bool bLeftOrTop = true ) const; - Color GetColorIn( bool bLeftOrTop = true ) const; - bool HasGapColor() const { return m_pColorGapFn != NULL; } - Color GetColorGap() const; - - void SetWidth( long nWidth = 0 ) { m_nWidth = nWidth; } - /** Guess the style and width from the three lines widths values. - - When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed - using the three values to match the best possible style among the following: - - SvxBorderLine::DOUBLE - - SvxBorderLine::THINTHICK_SMALLGAP - - SvxBorderLine::THINTHICK_MEDIUMGAP - - SvxBorderLine::THINTHICK_LARGEGAP - - SvxBorderLine::THICKTHIN_SMALLGAP - - SvxBorderLine::THICKTHIN_MEDIUMGAP - - SvxBorderLine::THICKTHIN_LARGEGAP - - If no styles matches the width, then the width is set to 0. - - There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt, - \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and - SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and - SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens - also for thick-thin styles. - - \param nStyle the border style used to guess the width. - \param nIn the width of the inner line in 1th pt - \param nOut the width of the outer line in 1th pt - \param nDist the width of the gap between the lines in 1th pt - */ - void GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 ); - - // TODO Hacky method to mirror lines in only a few cases - void SetMirrorWidths( bool bMirror = true ) { m_bMirrorWidths = bMirror; } - long GetWidth( ) const { return m_nWidth; } - sal_uInt16 GetOutWidth() const; - sal_uInt16 GetInWidth() const; - sal_uInt16 GetDistance() const; - - SvxBorderStyle GetStyle() const { return m_nStyle; } - - void SetColor( const Color &rColor ) { aColor = rColor; } - void SetColorOutFn( Color (*pColorOutFn)( Color ) ) { m_pColorOutFn = pColorOutFn; } - void SetColorInFn( Color (*pColorInFn)( Color ) ) { m_pColorInFn = pColorInFn; } - void SetColorGapFn( Color (*pColorGapFn)( Color ) ) { m_pColorGapFn = pColorGapFn; } - void SetUseLeftTop( bool bUseLeftTop ) { m_bUseLeftTop = bUseLeftTop; } - void SetStyle( SvxBorderStyle nNew ); - void ScaleMetrics( long nMult, long nDiv ); - - sal_Bool operator==( const SvxBorderLine &rCmp ) const; - - String GetValueString( SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit, - const IntlWrapper* pIntl, - sal_Bool bMetricStr = sal_False ) const; - - bool HasPriority( const SvxBorderLine& rOtherLine ) const; - - bool isEmpty() const { return m_aWidthImpl.IsEmpty( ) || m_nStyle == NO_STYLE || m_nWidth == 0; } - bool isDouble() const { return m_aWidthImpl.IsDouble(); } - sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); } - - static Color darkColor( Color aMain ); - static Color lightColor( Color aMain ); - - static Color threeDLightColor( Color aMain ); - static Color threeDMediumColor( Color aMain ); - static Color threeDDarkColor( Color aMain ); - - static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle ); -}; +namespace editeng { + + enum SvxBorderStyle + { + SOLID, + DOTTED, + DASHED, + DOUBLE, + THINTHICK_SMALLGAP, + THINTHICK_MEDIUMGAP, + THINTHICK_LARGEGAP, + THICKTHIN_SMALLGAP, + THICKTHIN_MEDIUMGAP, + THICKTHIN_LARGEGAP, + EMBOSSED, + ENGRAVED, + OUTSET, + INSET, + NO_STYLE = -1 + }; + + class EDITENG_DLLPUBLIC SvxBorderLine + { + protected: + Color aColor; + + long m_nWidth; + bool m_bMirrorWidths; + BorderWidthImpl m_aWidthImpl; + long m_nMult; + long m_nDiv; + + SvxBorderStyle m_nStyle; + sal_uInt16 nOutWidth; + sal_uInt16 nInWidth; + sal_uInt16 nDistance; + + bool m_bUseLeftTop; + Color (*m_pColorOutFn)( Color ); + Color (*m_pColorInFn)( Color ); + Color (*m_pColorGapFn)( Color ); + + public: + SvxBorderLine( const Color *pCol = 0, + long nWidth = 0, SvxBorderStyle nStyle = SOLID, + bool bUseLeftTop = false, + Color (*pColorOutFn)( Color ) = &darkColor, + Color (*pColorInFn)( Color ) = &darkColor, + Color (*pColorGapFn)( Color ) = NULL ); + SvxBorderLine( const SvxBorderLine& r ); + + SvxBorderLine& operator=( const SvxBorderLine& r ); + + const Color& GetColor() const { return aColor; } + Color GetColorOut( bool bLeftOrTop = true ) const; + Color GetColorIn( bool bLeftOrTop = true ) const; + bool HasGapColor() const { return m_pColorGapFn != NULL; } + Color GetColorGap() const; + + void SetWidth( long nWidth = 0 ) { m_nWidth = nWidth; } + /** Guess the style and width from the three lines widths values. + + When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed + using the three values to match the best possible style among the following: + - SvxBorderLine::DOUBLE + - SvxBorderLine::THINTHICK_SMALLGAP + - SvxBorderLine::THINTHICK_MEDIUMGAP + - SvxBorderLine::THINTHICK_LARGEGAP + - SvxBorderLine::THICKTHIN_SMALLGAP + - SvxBorderLine::THICKTHIN_MEDIUMGAP + - SvxBorderLine::THICKTHIN_LARGEGAP + + If no styles matches the width, then the width is set to 0. + + There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt, + \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and + SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and + SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens + also for thick-thin styles. + + \param nStyle the border style used to guess the width. + \param nIn the width of the inner line in 1th pt + \param nOut the width of the outer line in 1th pt + \param nDist the width of the gap between the lines in 1th pt + */ + void GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 ); + + // TODO Hacky method to mirror lines in only a few cases + void SetMirrorWidths( bool bMirror = true ) { m_bMirrorWidths = bMirror; } + long GetWidth( ) const { return m_nWidth; } + sal_uInt16 GetOutWidth() const; + sal_uInt16 GetInWidth() const; + sal_uInt16 GetDistance() const; + + SvxBorderStyle GetStyle() const { return m_nStyle; } + + void SetColor( const Color &rColor ) { aColor = rColor; } + void SetColorOutFn( Color (*pColorOutFn)( Color ) ) { m_pColorOutFn = pColorOutFn; } + void SetColorInFn( Color (*pColorInFn)( Color ) ) { m_pColorInFn = pColorInFn; } + void SetColorGapFn( Color (*pColorGapFn)( Color ) ) { m_pColorGapFn = pColorGapFn; } + void SetUseLeftTop( bool bUseLeftTop ) { m_bUseLeftTop = bUseLeftTop; } + void SetStyle( SvxBorderStyle nNew ); + void ScaleMetrics( long nMult, long nDiv ); + + sal_Bool operator==( const SvxBorderLine &rCmp ) const; + + String GetValueString( SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit, + const IntlWrapper* pIntl, + sal_Bool bMetricStr = sal_False ) const; + + bool HasPriority( const SvxBorderLine& rOtherLine ) const; + + bool isEmpty() const { return m_aWidthImpl.IsEmpty( ) || m_nStyle == NO_STYLE || m_nWidth == 0; } + bool isDouble() const { return m_aWidthImpl.IsDouble(); } + sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); } + + static Color darkColor( Color aMain ); + static Color lightColor( Color aMain ); + + static Color threeDLightColor( Color aMain ); + static Color threeDMediumColor( Color aMain ); + static Color threeDDarkColor( Color aMain ); + + static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle ); + }; // ============================================================================ +} // namespace editeng + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/inc/editeng/boxitem.hxx b/editeng/inc/editeng/boxitem.hxx index 8456bb74ab57..46597705fc92 100755 --- a/editeng/inc/editeng/boxitem.hxx +++ b/editeng/inc/editeng/boxitem.hxx @@ -52,10 +52,10 @@ namespace rtl { class OUString; } class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem { - SvxBorderLine *pTop, - *pBottom, - *pLeft, - *pRight; + editeng::SvxBorderLine *pTop, + *pBottom, + *pLeft, + *pRight; sal_uInt16 nTopDist, nBottomDist, nLeftDist, @@ -87,15 +87,15 @@ public: virtual bool ScaleMetrics( long nMult, long nDiv ); virtual bool HasMetrics() const; - const SvxBorderLine* GetTop() const { return pTop; } - const SvxBorderLine* GetBottom() const { return pBottom; } - const SvxBorderLine* GetLeft() const { return pLeft; } - const SvxBorderLine* GetRight() const { return pRight; } + const editeng::SvxBorderLine* GetTop() const { return pTop; } + const editeng::SvxBorderLine* GetBottom() const { return pBottom; } + const editeng::SvxBorderLine* GetLeft() const { return pLeft; } + const editeng::SvxBorderLine* GetRight() const { return pRight; } - const SvxBorderLine* GetLine( sal_uInt16 nLine ) const; + const editeng::SvxBorderLine* GetLine( sal_uInt16 nLine ) const; //The Pointers are being copied! - void SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine ); + void SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine ); sal_uInt16 GetDistance( sal_uInt16 nLine ) const; sal_uInt16 GetDistance() const; @@ -106,9 +106,9 @@ public: // Line width plus Space plus inward distance //bIgnoreLine = TRUE -> Also return distance, when no Line is set sal_uInt16 CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine = sal_False ) const; - static com::sun::star::table::BorderLine2 SvxLineToLine( const SvxBorderLine* pLine, sal_Bool bConvert ); - static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert); - static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert); + static com::sun::star::table::BorderLine2 SvxLineToLine( const editeng::SvxBorderLine* pLine, sal_Bool bConvert ); + static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, editeng::SvxBorderLine& rSvxLine, sal_Bool bConvert); + static sal_Bool LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, editeng::SvxBorderLine& rSvxLine, sal_Bool bConvert); }; inline void SvxBoxItem::SetDistance( sal_uInt16 nNew ) @@ -140,8 +140,8 @@ inline void SvxBoxItem::SetDistance( sal_uInt16 nNew ) class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem { - SvxBorderLine* pHori; //inner horizontal Line - SvxBorderLine* pVert; //inner vertical Line + editeng::SvxBorderLine* pHori; //inner horizontal Line + editeng::SvxBorderLine* pVert; //inner vertical Line bool mbEnableHor; /// true = Enable inner horizontal line. bool mbEnableVer; /// true = Enable inner vertical line. @@ -194,11 +194,11 @@ public: virtual bool ScaleMetrics( long nMult, long nDiv ); virtual bool HasMetrics() const; - const SvxBorderLine* GetHori() const { return pHori; } - const SvxBorderLine* GetVert() const { return pVert; } + const editeng::SvxBorderLine* GetHori() const { return pHori; } + const editeng::SvxBorderLine* GetVert() const { return pVert; } //The Pointers are being copied! - void SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine ); + void SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine ); sal_Bool IsTable() const { return mbEnableHor && mbEnableVer; } void SetTable( sal_Bool bNew ) { mbEnableHor = mbEnableVer = bNew; } diff --git a/editeng/qa/items/borderline_test.cxx b/editeng/qa/items/borderline_test.cxx index 995ccef56d31..5d67b62f82f1 100644 --- a/editeng/qa/items/borderline_test.cxx +++ b/editeng/qa/items/borderline_test.cxx @@ -44,6 +44,8 @@ #define THINTHICKLG_OUT_WIDTH long( 30 ) #define THINTHICKLG_DIST_WIDTH long( 40 ) +using namespace editeng; + namespace { class BorderLineTest : public CppUnit::TestFixture diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx index da0ece104f00..de24284b92ce 100644 --- a/editeng/source/items/borderline.cxx +++ b/editeng/source/items/borderline.cxx @@ -39,6 +39,31 @@ // class SvxBorderLine -------------------------------------------------- +namespace { + + Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark ) + { + basegfx::BColor color = aMain.getBColor( ); + basegfx::BColor hsl = basegfx::tools::rgb2hsl( color ); + + int nCoef = 0; + if ( hsl.getZ( ) >= 0.5 ) + nCoef = nLight; + else if ( 0.5 > hsl.getZ() && hsl.getZ() >= 0.25 ) + nCoef = nMedium; + else + nCoef = nDark; + + double L = hsl.getZ() * 255.0 + nCoef; + hsl.setZ( L / 255.0 ); + color = basegfx::tools::hsl2rgb( hsl ); + + return Color( color ); + } +} // Anonymous namespace + +namespace editeng { + Color SvxBorderLine::darkColor( Color aMain ) { return aMain; @@ -56,25 +81,6 @@ Color SvxBorderLine::lightColor( Color aMain ) return Color( color ); } -Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark ) -{ - basegfx::BColor color = aMain.getBColor( ); - basegfx::BColor hsl = basegfx::tools::rgb2hsl( color ); - - int nCoef = 0; - if ( hsl.getZ( ) >= 0.5 ) - nCoef = nLight; - else if ( 0.5 > hsl.getZ() && hsl.getZ() >= 0.25 ) - nCoef = nMedium; - else - nCoef = nDark; - - double L = hsl.getZ() * 255.0 + nCoef; - hsl.setZ( L / 255.0 ); - color = basegfx::tools::hsl2rgb( hsl ); - - return Color( color ); -} Color SvxBorderLine::threeDLightColor( Color aMain ) { @@ -484,4 +490,6 @@ bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const } } +} // namespace editeng + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index cc7bf3b743d3..6f2a8ca1989c 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -94,6 +94,7 @@ #include <editeng/memberids.hrc> #include <editeng/editerr.hxx> +using namespace ::editeng; using namespace ::rtl; using namespace ::com::sun::star; diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index bfc5b6c00ebc..7f94d5a721e4 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -95,6 +95,7 @@ #define BRACELEFT '{' #define BRACERIGHT '}' +using namespace editeng; // Some helper functions // char |