diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-07-03 21:26:13 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-04 17:55:45 +0200 |
commit | 8b4593948582c3b5b3d013bd751bb19ffd37a31b (patch) | |
tree | d12df351290b85abc5b55440106560aca3bad8e8 /editeng | |
parent | 8dd6a23b6b44902d1c1ae4e24360463ffcf1015d (diff) |
replace enum SvxBorderStyle with css::table::BorderLineSyle
Change-Id: I1dadb53f46b23f92d34061ef78dda872bdbcda67
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/editeng/borderline.hxx | 35 | ||||
-rw-r--r-- | editeng/qa/items/borderline_test.cxx | 18 | ||||
-rw-r--r-- | editeng/source/items/borderline.cxx | 20 | ||||
-rw-r--r-- | editeng/source/items/frmitems.cxx | 83 | ||||
-rw-r--r-- | editeng/source/rtf/rtfitem.cxx | 29 |
5 files changed, 71 insertions, 114 deletions
diff --git a/editeng/inc/editeng/borderline.hxx b/editeng/inc/editeng/borderline.hxx index 0c3bdcbad6a3..e026fc208410 100644 --- a/editeng/inc/editeng/borderline.hxx +++ b/editeng/inc/editeng/borderline.hxx @@ -29,6 +29,8 @@ #ifndef SVX_BORDERLINE_HXX #define SVX_BORDERLINE_HXX +#include <com/sun/star/table/BorderLineStyle.hpp> + #include <tools/color.hxx> #include <svl/poolitem.hxx> #include <editeng/editengdllapi.h> @@ -47,24 +49,8 @@ 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 - }; + // values from ::com::sun::star::table::BorderLineStyle + typedef sal_Int16 SvxBorderStyle; class EDITENG_DLLPUBLIC SvxBorderLine { @@ -89,7 +75,8 @@ namespace editeng { public: SvxBorderLine( const Color *pCol = 0, - long nWidth = 0, SvxBorderStyle nStyle = SOLID, + long nWidth = 0, SvxBorderStyle nStyle = + ::com::sun::star::table::BorderLineStyle::SOLID, bool bUseLeftTop = false, Color (*pColorOutFn)( Color ) = &darkColor, Color (*pColorInFn)( Color ) = &darkColor, @@ -139,14 +126,14 @@ namespace editeng { sal_uInt16 GetInWidth() const; sal_uInt16 GetDistance() const; - SvxBorderStyle GetSvxBorderStyle() const { return m_nStyle; } + SvxBorderStyle GetBorderLineStyle() 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 SetSvxBorderStyle( SvxBorderStyle nNew ); + void SetBorderLineStyle( SvxBorderStyle nNew ); void ScaleMetrics( long nMult, long nDiv ); sal_Bool operator==( const SvxBorderLine &rCmp ) const; @@ -157,7 +144,11 @@ namespace editeng { bool HasPriority( const SvxBorderLine& rOtherLine ) const; - bool isEmpty() const { return m_aWidthImpl.IsEmpty( ) || m_nStyle == NO_STYLE || m_nWidth == 0; } + bool isEmpty() const { + return m_aWidthImpl.IsEmpty() + || m_nStyle == ::com::sun::star::table::BorderLineStyle::NONE + || m_nWidth == 0; + } bool isDouble() const { return m_aWidthImpl.IsDouble(); } sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); } diff --git a/editeng/qa/items/borderline_test.cxx b/editeng/qa/items/borderline_test.cxx index 96de7e7a55f1..f839103a7af1 100644 --- a/editeng/qa/items/borderline_test.cxx +++ b/editeng/qa/items/borderline_test.cxx @@ -34,6 +34,8 @@ #include <editeng/borderline.hxx> +using namespace ::com::sun::star::table::BorderLineStyle; + #define TEST_WIDTH long( 40 ) #define THINTHICKSG_IN_WIDTH long( 15 ) @@ -94,7 +96,7 @@ void BorderLineTest::testGuessWidthDouble() // Normal double case SvxBorderLine line; line.GuessLinesWidths( DOUBLE, TEST_WIDTH, TEST_WIDTH, TEST_WIDTH ); - CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetSvxBorderStyle() ); + CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetBorderLineStyle() ); CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() ); } @@ -103,7 +105,7 @@ void BorderLineTest::testGuessWidthNoMatch() SvxBorderLine line; line.GuessLinesWidths( DOUBLE, TEST_WIDTH + 1, TEST_WIDTH + 2, TEST_WIDTH + 3 ); - CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetSvxBorderStyle() ); + CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetBorderLineStyle() ); CPPUNIT_ASSERT_EQUAL( long( (3 * TEST_WIDTH) + 6 ), line.GetWidth() ); } @@ -114,7 +116,7 @@ void BorderLineTest::testGuessWidthThinthickSmallgap() THINTHICKSG_OUT_WIDTH, THINTHICKSG_IN_WIDTH, THINTHICKSG_DIST_WIDTH ); - CPPUNIT_ASSERT_EQUAL( THINTHICK_SMALLGAP, line.GetSvxBorderStyle() ); + CPPUNIT_ASSERT_EQUAL( THINTHICK_SMALLGAP, line.GetBorderLineStyle() ); CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() ); } @@ -125,26 +127,26 @@ void BorderLineTest::testGuessWidthThinthickLargegap() THINTHICKLG_OUT_WIDTH, THINTHICKLG_IN_WIDTH, THINTHICKLG_DIST_WIDTH ); - CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetSvxBorderStyle() ); + CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetBorderLineStyle() ); CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() ); } void BorderLineTest::testGuessWidthNostyleDouble() { SvxBorderLine line; - line.GuessLinesWidths( NO_STYLE, + line.GuessLinesWidths( NONE, THINTHICKLG_OUT_WIDTH, THINTHICKLG_IN_WIDTH, THINTHICKLG_DIST_WIDTH ); - CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetSvxBorderStyle() ); + CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetBorderLineStyle() ); CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() ); } void BorderLineTest::testGuessWidthNostyleSingle() { SvxBorderLine line; - line.GuessLinesWidths( NO_STYLE, TEST_WIDTH ); - CPPUNIT_ASSERT_EQUAL( SOLID, line.GetSvxBorderStyle() ); + line.GuessLinesWidths( NONE, TEST_WIDTH ); + CPPUNIT_ASSERT_EQUAL( SOLID, line.GetBorderLineStyle() ); CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() ); } diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx index bd19eaed93b1..de53ccb2f912 100644 --- a/editeng/source/items/borderline.cxx +++ b/editeng/source/items/borderline.cxx @@ -32,6 +32,9 @@ #include <editeng/borderline.hxx> #include <editeng/itemtype.hxx> + +using namespace ::com::sun::star::table::BorderLineStyle; + // class SvxBorderLine -------------------------------------------------- namespace { @@ -125,7 +128,7 @@ BorderWidthImpl SvxBorderLine::getWidthImpl( SvxBorderStyle nStyle ) switch ( nStyle ) { // No line: no width - case NO_STYLE: + case NONE: aImpl = BorderWidthImpl( 0, 0.0 ); break; @@ -241,7 +244,8 @@ void SvxBorderLine::ScaleMetrics( long nMult, long nDiv ) void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn, sal_uInt16 nDist ) { - if ( nStyle == NO_STYLE ) { + if (NONE == nStyle) + { nStyle = SOLID; if ( nOut > 0 && nIn > 0 ) nStyle = DOUBLE; @@ -262,7 +266,7 @@ void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sa size_t const len = SAL_N_ELEMENTS(aDoubleStyles); long nWidth = 0; - SvxBorderStyle nTestStyle(NO_STYLE); + SvxBorderStyle nTestStyle(NONE); for (size_t i = 0; i < len && nWidth == 0; ++i) { nTestStyle = aDoubleStyles[i]; @@ -274,13 +278,13 @@ void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sa if ( nWidth > 0 ) { nStyle = nTestStyle; - SetSvxBorderStyle(nStyle); + SetBorderLineStyle(nStyle); m_nWidth = nWidth; } else { // fdo#38542: not a known double, default to something custom... - SetSvxBorderStyle(nStyle); + SetBorderLineStyle(nStyle); m_nWidth = nOut + nIn + nDist; if (nOut + nIn + nDist) { @@ -294,7 +298,7 @@ void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sa } else { - SetSvxBorderStyle(nStyle); + SetBorderLineStyle(nStyle); if (nOut == 0 && nIn > 0) { // If only inner width is given swap inner and outer widths for @@ -344,14 +348,14 @@ sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const ( m_nWidth == rCmp.m_nWidth ) && ( m_bMirrorWidths == rCmp.m_bMirrorWidths ) && ( m_aWidthImpl == rCmp.m_aWidthImpl ) && - ( m_nStyle == rCmp.GetSvxBorderStyle()) && + ( m_nStyle == rCmp.GetBorderLineStyle()) && ( m_bUseLeftTop == rCmp.m_bUseLeftTop ) && ( m_pColorOutFn == rCmp.m_pColorOutFn ) && ( m_pColorInFn == rCmp.m_pColorInFn ) && ( m_pColorGapFn == rCmp.m_pColorGapFn ) ); } -void SvxBorderLine::SetSvxBorderStyle( SvxBorderStyle nNew ) +void SvxBorderLine::SetBorderLineStyle( SvxBorderStyle nNew ) { m_nStyle = nNew; m_aWidthImpl = getWidthImpl( m_nStyle ); diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index d2f9a3cc5199..733ba580c98b 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -89,6 +89,7 @@ using namespace ::editeng; using namespace ::rtl; using namespace ::com::sun::star; +using namespace ::com::sun::star::table::BorderLineStyle; // Conversion for UNO @@ -140,7 +141,7 @@ namespace << l.GetDistance(); if (version >= BORDER_LINE_WITH_STYLE_VERSION) - stream << static_cast<sal_uInt16>(l.GetSvxBorderStyle()); + stream << static_cast<sal_uInt16>(l.GetBorderLineStyle()); return stream; } @@ -148,7 +149,8 @@ namespace /// Creates a border line from a stream. SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version) { - sal_uInt16 nOutline, nInline, nDistance, nStyle = NO_STYLE; + sal_uInt16 nOutline, nInline, nDistance; + sal_uInt16 nStyle = NONE; Color aColor; stream >> aColor >> nOutline >> nInline >> nDistance; @@ -156,7 +158,7 @@ namespace stream >> nStyle; SvxBorderLine border(&aColor); - border.GuessLinesWidths(static_cast<SvxBorderStyle>(nStyle), nOutline, nInline, nDistance); + border.GuessLinesWidths(nStyle, nOutline, nInline, nDistance); return border; } @@ -1691,7 +1693,7 @@ table::BorderLine2 SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, sal_Boo aLine.InnerLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetInWidth() ): pLine->GetInWidth() ); aLine.OuterLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetOutWidth()): pLine->GetOutWidth() ); aLine.LineDistance = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetDistance()): pLine->GetDistance() ); - aLine.LineStyle = pLine->GetSvxBorderStyle(); + aLine.LineStyle = pLine->GetBorderLineStyle(); aLine.LineWidth = sal_uInt32( bConvert ? TWIP_TO_MM100( pLine->GetWidth( ) ) : pLine->GetWidth( ) ); } else @@ -1779,14 +1781,14 @@ lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_B rSvxLine.SetColor( Color(rLine.Color)); if ( bGuessWidth ) { - rSvxLine.GuessLinesWidths( rSvxLine.GetSvxBorderStyle(), + rSvxLine.GuessLinesWidths( rSvxLine.GetBorderLineStyle(), sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth ), sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth ), sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance ) : rLine.LineDistance )); } else { - if (DOUBLE == rSvxLine.GetSvxBorderStyle()) + if (DOUBLE == rSvxLine.GetBorderLineStyle()) { // fdo#46112: divide width by 3 for outer line, gap, inner line rSvxLine.ScaleMetrics(1, 3); } @@ -1807,54 +1809,12 @@ sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rL sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert) { - SvxBorderStyle nStyle = NO_STYLE; - switch ( rLine.LineStyle ) - { - default: - case table::BorderLineStyle::SOLID: - nStyle = SOLID; - break; - case table::BorderLineStyle::DOTTED: - nStyle = DOTTED; - break; - case table::BorderLineStyle::DASHED: - nStyle = DASHED; - break; - case table::BorderLineStyle::DOUBLE: - nStyle = DOUBLE; - break; - case table::BorderLineStyle::THINTHICK_SMALLGAP: - nStyle = THINTHICK_SMALLGAP; - break; - case table::BorderLineStyle::THINTHICK_MEDIUMGAP: - nStyle = THINTHICK_MEDIUMGAP; - break; - case table::BorderLineStyle::THINTHICK_LARGEGAP: - nStyle = THINTHICK_LARGEGAP; - break; - case table::BorderLineStyle::THICKTHIN_SMALLGAP: - nStyle = THICKTHIN_SMALLGAP; - break; - case table::BorderLineStyle::THICKTHIN_MEDIUMGAP: - nStyle = THICKTHIN_MEDIUMGAP; - break; - case table::BorderLineStyle::THICKTHIN_LARGEGAP: - nStyle = THICKTHIN_LARGEGAP; - break; - case table::BorderLineStyle::EMBOSSED: - nStyle = EMBOSSED; - break; - case table::BorderLineStyle::ENGRAVED: - nStyle = ENGRAVED; - break; - case table::BorderLineStyle::OUTSET: - nStyle = OUTSET; - break; - case table::BorderLineStyle::INSET: - nStyle = INSET; - break; - } - rSvxLine.SetSvxBorderStyle( nStyle ); + SvxBorderStyle const nStyle = + (rLine.LineStyle < 0 || INSET < rLine.LineStyle) + ? SOLID // default + : rLine.LineStyle; + + rSvxLine.SetBorderLineStyle( nStyle ); sal_Bool bGuessWidth = sal_True; if ( rLine.LineWidth ) @@ -1984,18 +1944,17 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { drawing::LineStyle eDrawingStyle; rVal >>= eDrawingStyle; - editeng::SvxBorderStyle eBorderStyle = editeng::NO_STYLE; + editeng::SvxBorderStyle eBorderStyle = NONE; switch ( eDrawingStyle ) { default: case drawing::LineStyle_NONE: - eBorderStyle = editeng::NO_STYLE; break; case drawing::LineStyle_SOLID: - eBorderStyle = editeng::SOLID; + eBorderStyle = SOLID; break; case drawing::LineStyle_DASH: - eBorderStyle = editeng::DASHED; + eBorderStyle = DASHED; break; } @@ -2005,7 +1964,7 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { editeng::SvxBorderLine* pLine = const_cast< editeng::SvxBorderLine* >( GetLine( aBorders[n] ) ); if( pLine ) - pLine->SetSvxBorderStyle( eBorderStyle ); + pLine->SetBorderLineStyle( eBorderStyle ); } return sal_True; } @@ -2726,7 +2685,7 @@ SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const Color aColor; rStrm >> aColor >> nOutline >> nInline >> nDistance; SvxBorderLine aBorder( &aColor ); - aBorder.GuessLinesWidths( NO_STYLE, nOutline, nInline, nDistance ); + aBorder.GuessLinesWidths(NONE, nOutline, nInline, nDistance); switch( cLine ) { @@ -3271,7 +3230,7 @@ bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId ) { case MID_FG_COLOR: pLine->SetColor( Color(nVal) ); break; case MID_LINE_STYLE: - pLine->SetSvxBorderStyle(static_cast<SvxBorderStyle>(nVal)); + pLine->SetBorderLineStyle(static_cast<SvxBorderStyle>(nVal)); break; default: OSL_FAIL( "Wrong MemberId" ); @@ -3356,7 +3315,7 @@ SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const if( nOutline ) { SvxBorderLine aLine( &aColor ); - aLine.GuessLinesWidths( NO_STYLE, nOutline, nInline, nDistance ); + aLine.GuessLinesWidths(NONE, nOutline, nInline, nDistance); _pLine->SetLine( &aLine ); } return _pLine; diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx index fc02868e764d..f99bfb59f447 100644 --- a/editeng/source/rtf/rtfitem.cxx +++ b/editeng/source/rtf/rtfitem.cxx @@ -93,6 +93,7 @@ #define BRACELEFT '{' #define BRACERIGHT '}' +using namespace ::com::sun::star; using namespace editeng; // Some helper functions @@ -1468,49 +1469,49 @@ void SvxRTFParser::ReadBorderAttr( int nToken, SfxItemSet& rSet, } case RTF_BRDRDOT: // dotted border - aBrd.SetSvxBorderStyle( DOTTED ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::DOTTED); break; case RTF_BRDRDASH: // dashed border - aBrd.SetSvxBorderStyle( DASHED ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::DASHED); break; case RTF_BRDRHAIR: // hairline border { - aBrd.SetSvxBorderStyle( SOLID ); + aBrd.SetBorderLineStyle( table::BorderLineStyle::SOLID); aBrd.SetWidth( DEF_LINE_WIDTH_0 ); } break; case RTF_BRDRDB: // Double border - aBrd.SetSvxBorderStyle( DOUBLE ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::DOUBLE); break; case RTF_BRDRINSET: // inset border - aBrd.SetSvxBorderStyle( INSET ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::INSET); break; case RTF_BRDROUTSET: // outset border - aBrd.SetSvxBorderStyle( OUTSET ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::OUTSET); break; case RTF_BRDRTNTHSG: // ThinThick Small gap - aBrd.SetSvxBorderStyle( THINTHICK_SMALLGAP ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_SMALLGAP); break; case RTF_BRDRTNTHMG: // ThinThick Medium gap - aBrd.SetSvxBorderStyle( THINTHICK_MEDIUMGAP ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_MEDIUMGAP); break; case RTF_BRDRTNTHLG: // ThinThick Large gap - aBrd.SetSvxBorderStyle( THINTHICK_LARGEGAP ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_LARGEGAP); break; case RTF_BRDRTHTNSG: // ThickThin Small gap - aBrd.SetSvxBorderStyle( THICKTHIN_SMALLGAP ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_SMALLGAP); break; case RTF_BRDRTHTNMG: // ThickThin Medium gap - aBrd.SetSvxBorderStyle( THICKTHIN_MEDIUMGAP ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_MEDIUMGAP); break; case RTF_BRDRTHTNLG: // ThickThin Large gap - aBrd.SetSvxBorderStyle( THICKTHIN_LARGEGAP ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_LARGEGAP); break; case RTF_BRDREMBOSS: // Embossed border - aBrd.SetSvxBorderStyle( EMBOSSED ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::EMBOSSED); break; case RTF_BRDRENGRAVE: // Engraved border - aBrd.SetSvxBorderStyle( ENGRAVED ); + aBrd.SetBorderLineStyle(table::BorderLineStyle::ENGRAVED); break; case RTF_BRDRS: // single thickness border |