summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-01-07 13:40:44 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:57:17 +0100
commit1f98f6e1a4be668a07b72c91fb1e835c92983fe5 (patch)
tree406082e2e2b168d3f0dcfdb933ff227bd9a5537f /editeng
parent95ef468983dc8a3dd03dfb6fb9de4a44d5255c1c (diff)
Switching the order of the SetLinesWidth arguments
Diffstat (limited to 'editeng')
-rwxr-xr-xediteng/inc/editeng/borderline.hxx2
-rw-r--r--editeng/qa/items/borderline_test.cxx33
-rw-r--r--editeng/source/items/borderline.cxx21
-rw-r--r--editeng/source/items/frmitems.cxx30
-rw-r--r--editeng/source/rtf/rtfitem.cxx5
5 files changed, 68 insertions, 23 deletions
diff --git a/editeng/inc/editeng/borderline.hxx b/editeng/inc/editeng/borderline.hxx
index d7f6e0b648..ed9f29277c 100755
--- a/editeng/inc/editeng/borderline.hxx
+++ b/editeng/inc/editeng/borderline.hxx
@@ -175,7 +175,7 @@ public:
\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 SetLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nIn, sal_uInt16 nOut, sal_uInt16 nDist );
+ 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; }
diff --git a/editeng/qa/items/borderline_test.cxx b/editeng/qa/items/borderline_test.cxx
index 22e76b8488..e7ea1a1dee 100644
--- a/editeng/qa/items/borderline_test.cxx
+++ b/editeng/qa/items/borderline_test.cxx
@@ -52,12 +52,16 @@ class BorderLineTest : public CppUnit::TestFixture
void testGuessWidthNoMatch();
void testGuessWidthThinthickSmallgap();
void testGuessWidthThinthickLargegap();
+ void testGuessWidthNostyleDouble();
+ void testGuessWidthNostyleSingle();
CPPUNIT_TEST_SUITE(BorderLineTest);
CPPUNIT_TEST(testGuessWidthDouble);
CPPUNIT_TEST(testGuessWidthNoMatch);
CPPUNIT_TEST(testGuessWidthThinthickSmallgap);
CPPUNIT_TEST(testGuessWidthThinthickLargegap);
+ CPPUNIT_TEST(testGuessWidthNostyleDouble);
+ CPPUNIT_TEST(testGuessWidthNostyleSingle);
CPPUNIT_TEST_SUITE_END();
};
@@ -67,7 +71,7 @@ void BorderLineTest::testGuessWidthDouble()
{
// Normal double case
SvxBorderLine line;
- line.SetLinesWidths( DOUBLE, TEST_WIDTH, TEST_WIDTH, TEST_WIDTH );
+ line.GuessLinesWidths( DOUBLE, TEST_WIDTH, TEST_WIDTH, TEST_WIDTH );
CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetStyle() );
CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
}
@@ -75,7 +79,7 @@ void BorderLineTest::testGuessWidthDouble()
void BorderLineTest::testGuessWidthNoMatch()
{
SvxBorderLine line;
- line.SetLinesWidths( DOUBLE,
+ line.GuessLinesWidths( DOUBLE,
1, 2, 3 );
CPPUNIT_ASSERT_EQUAL( DOUBLE, line.GetStyle() );
CPPUNIT_ASSERT_EQUAL( long( 0 ), line.GetWidth() );
@@ -84,9 +88,9 @@ void BorderLineTest::testGuessWidthNoMatch()
void BorderLineTest::testGuessWidthThinthickSmallgap()
{
SvxBorderLine line;
- line.SetLinesWidths( DOUBLE,
- THINTHICKSG_IN_WIDTH,
+ line.GuessLinesWidths( DOUBLE,
THINTHICKSG_OUT_WIDTH,
+ THINTHICKSG_IN_WIDTH,
THINTHICKSG_DIST_WIDTH );
CPPUNIT_ASSERT_EQUAL( THINTHICK_SMALLGAP, line.GetStyle() );
CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
@@ -95,14 +99,33 @@ void BorderLineTest::testGuessWidthThinthickSmallgap()
void BorderLineTest::testGuessWidthThinthickLargegap()
{
SvxBorderLine line;
- line.SetLinesWidths( DOUBLE,
+ line.GuessLinesWidths( DOUBLE,
+ THINTHICKLG_OUT_WIDTH,
THINTHICKLG_IN_WIDTH,
+ THINTHICKLG_DIST_WIDTH );
+ CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetStyle() );
+ CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
+}
+
+void BorderLineTest::testGuessWidthNostyleDouble()
+{
+ SvxBorderLine line;
+ line.GuessLinesWidths( NO_STYLE,
THINTHICKLG_OUT_WIDTH,
+ THINTHICKLG_IN_WIDTH,
THINTHICKLG_DIST_WIDTH );
CPPUNIT_ASSERT_EQUAL( THINTHICK_LARGEGAP, line.GetStyle() );
CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
}
+void BorderLineTest::testGuessWidthNostyleSingle()
+{
+ SvxBorderLine line;
+ line.GuessLinesWidths( NO_STYLE, TEST_WIDTH );
+ CPPUNIT_ASSERT_EQUAL( SOLID, line.GetStyle() );
+ CPPUNIT_ASSERT_EQUAL( TEST_WIDTH, line.GetWidth() );
+}
+
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/editeng/source/items/borderline.cxx b/editeng/source/items/borderline.cxx
index 87a21ba901..0e25bba482 100644
--- a/editeng/source/items/borderline.cxx
+++ b/editeng/source/items/borderline.cxx
@@ -99,6 +99,7 @@ SvxBorderLine::SvxBorderLine( const Color *pCol, long nWidth,
Color (*pColorOutFn)( Color ), Color (*pColorInFn)( Color ),
Color (*pColorGapFn)( Color ) )
: m_nWidth( nWidth )
+, m_bMirrorWidths( false )
, m_aWidthImpl( SvxBorderLine::getWidthImpl( nStyle ) )
, m_nMult( 1 )
, m_nDiv( 1 )
@@ -216,7 +217,9 @@ SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
{
aColor = r.aColor;
+ m_nWidth = r.m_nWidth;
m_aWidthImpl = r.m_aWidthImpl;
+ m_bMirrorWidths = r.m_bMirrorWidths;
m_nStyle = r.m_nStyle;
m_bUseLeftTop = r.m_bUseLeftTop;
m_pColorOutFn = r.m_pColorOutFn;
@@ -233,8 +236,14 @@ void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
m_nDiv = nDiv;
}
-void SvxBorderLine::SetLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nIn, sal_uInt16 nOut, sal_uInt16 nDist )
+void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn, sal_uInt16 nDist )
{
+ if ( nStyle == NO_STYLE ) {
+ nStyle = SOLID;
+ if ( nOut > 0 && nIn > 0 )
+ nStyle = DOUBLE;
+ }
+
if ( nStyle == DOUBLE )
{
static SvxBorderStyle aDoubleStyles[] =
@@ -276,17 +285,17 @@ void SvxBorderLine::SetLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nIn, sal_u
sal_uInt16 SvxBorderLine::GetOutWidth() const
{
- sal_uInt16 nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
+ sal_uInt16 nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
if ( m_bMirrorWidths )
- nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
+ nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
return nOut;
}
sal_uInt16 SvxBorderLine::GetInWidth() const
{
- sal_uInt16 nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
+ sal_uInt16 nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
if ( m_bMirrorWidths )
- nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
+ nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
return nIn;
}
@@ -300,6 +309,8 @@ sal_uInt16 SvxBorderLine::GetDistance() const
sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
{
return ( ( aColor == rCmp.aColor ) &&
+ ( m_nWidth == rCmp.m_nWidth ) &&
+ ( m_bMirrorWidths == rCmp.m_bMirrorWidths ) &&
( m_aWidthImpl == rCmp.m_aWidthImpl ) &&
( m_nStyle == rCmp.GetStyle() ) &&
( m_bUseLeftTop == rCmp.m_bUseLeftTop ) &&
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 5d523f8762..ffb6c1b6fa 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -1724,13 +1724,16 @@ namespace
{
sal_Bool
-lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
+lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert, sal_Bool bGuessWidth)
{
rSvxLine.SetColor( Color(rLine.Color));
- rSvxLine.SetLinesWidths( rSvxLine.GetStyle(),
- sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth ),
- sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth ),
- sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance ) : rLine.LineDistance ));
+ if ( bGuessWidth )
+ {
+ rSvxLine.GuessLinesWidths( rSvxLine.GetStyle(),
+ 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 ));
+ }
sal_Bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
return bRet;
@@ -1741,7 +1744,7 @@ lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_B
// -----------------------------------------------------------------------
sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
{
- return lcl_lineToSvxLine(rLine, rSvxLine, bConvert);
+ return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, sal_True);
}
sal_Bool
@@ -1794,8 +1797,15 @@ SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, Svx
break;
}
rSvxLine.SetStyle( nStyle );
+
+ sal_Bool bGuessWidth = true;
+ if ( rLine->LineWidth )
+ {
+ rSvxLine.SetWidth( bConvert? MM100_TO_TWIP_UNSIGNED( rLine->LineWidth ) : rLine->LineWidth );
+ bGuessWidth = false;
+ }
- return lcl_lineToSvxLine(rLine, rSvxLine, bConvert);
+ return lcl_lineToSvxLine(rLine, rSvxLine, bConvert, bGuessWidth);
}
// -----------------------------------------------------------------------
@@ -2224,7 +2234,7 @@ SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
Color aColor;
rStrm >> aColor >> nOutline >> nInline >> _nDistance;
SvxBorderLine aBorder( &aColor );
- aBorder.SetLinesWidths( SOLID, nInline, nOutline, _nDistance );
+ aBorder.GuessLinesWidths( NO_STYLE, nOutline, nInline, _nDistance );
pAttr->SetLine( &aBorder, aLineMap[cLine] );
}
@@ -2598,7 +2608,7 @@ SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const
Color aColor;
rStrm >> aColor >> nOutline >> nInline >> nDistance;
SvxBorderLine aBorder( &aColor );
- aBorder.SetLinesWidths( SOLID, nInline, nOutline, nDistance );
+ aBorder.GuessLinesWidths( NO_STYLE, nOutline, nInline, nDistance );
switch( cLine )
{
@@ -3204,7 +3214,7 @@ SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const
if( nOutline )
{
SvxBorderLine aLine( &aColor );
- aLine.SetLinesWidths( SOLID, nInline, nOutline, nDistance );
+ aLine.GuessLinesWidths( NO_STYLE, nOutline, nInline, nDistance );
_pLine->SetLine( &aLine );
}
return _pLine;
diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
index 057cd2ec7d..85ee6b9416 100644
--- a/editeng/source/rtf/rtfitem.cxx
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -1766,8 +1766,9 @@ SETBORDER:
break;
}
nDistWidth = sal_uInt16( nTokenValue );
- aBrd.SetLinesWidths( SOLID, nInWidth,
- nOutWidth, nDistWidth );
+
+ aBrd.GuessLinesWidths( NO_STYLE, nOutWidth,
+ nInWidth, nDistWidth );
SetBorderLine( nBorderTyp, aAttr, aBrd );
break;
}