summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2011-01-12 07:21:06 +0100
committerDavid Tardon <dtardon@redhat.com>2011-01-12 07:31:02 +0100
commit0d209ac289dd5c79da6950b4c01b0cec9b7fbe6d (patch)
tree8016b2320d6c1a7a1f636ac8d464803b8176edbb
parent139fc94dd7ecaa2d8db759ed7344d2ced1b7fe3c (diff)
handle css::table::BorderLine in addition to css::table::BorderLine2
That means that table cell properties are correctly set on OpenXML import again, whoo!
-rw-r--r--editeng/inc/editeng/boxitem.hxx1
-rw-r--r--editeng/source/items/frmitems.cxx161
2 files changed, 90 insertions, 72 deletions
diff --git a/editeng/inc/editeng/boxitem.hxx b/editeng/inc/editeng/boxitem.hxx
index b7b1d065bc..35fd036e30 100644
--- a/editeng/inc/editeng/boxitem.hxx
+++ b/editeng/inc/editeng/boxitem.hxx
@@ -109,6 +109,7 @@ public:
USHORT CalcLineSpace( USHORT nLine, BOOL bIgnoreLine = 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);
};
inline void SvxBoxItem::SetDistance( USHORT nNew )
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index c6a98ce092..092878f8a2 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -1934,41 +1934,97 @@ bool SvxBoxItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
return true;
}
-// -----------------------------------------------------------------------
-sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
+namespace
+{
+
+sal_Bool
+lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
{
rSvxLine.SetColor( Color(rLine.Color));
rSvxLine.SetInWidth( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth ));
rSvxLine.SetOutWidth( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth ));
rSvxLine.SetDistance( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance ) : rLine.LineDistance ));
- const table::BorderLine2* pLine2 = static_cast< const table::BorderLine2* >( &rLine );
+ sal_Bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
+ return bRet;
+}
+
+}
+
+// -----------------------------------------------------------------------
+sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
+{
+ return lcl_lineToSvxLine(rLine, rSvxLine, bConvert);
+}
+
+sal_Bool
+SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
+{
+ const bool bRet(lcl_lineToSvxLine(rLine, rSvxLine, bConvert));
- if ( pLine2 )
+ switch ( rLine.LineStyle )
{
- switch ( pLine2->LineStyle )
- {
- default:
- case table::BorderLineStyle::SOLID:
- rSvxLine.SetStyle( SOLID );
- break;
- case table::BorderLineStyle::DOTTED:
- rSvxLine.SetStyle( DOTTED );
- break;
- case table::BorderLineStyle::DASHED:
- rSvxLine.SetStyle( DASHED );
- break;
- }
+ default:
+ case table::BorderLineStyle::SOLID:
+ rSvxLine.SetStyle( SOLID );
+ break;
+ case table::BorderLineStyle::DOTTED:
+ rSvxLine.SetStyle( DOTTED );
+ break;
+ case table::BorderLineStyle::DASHED:
+ rSvxLine.SetStyle( DASHED );
+ break;
}
- sal_Bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
+
return bRet;
}
// -----------------------------------------------------------------------
+namespace
+{
+
+bool
+lcl_extractBorderLine(const uno::Any& rAny, table::BorderLine2& rLine)
+{
+ if (rAny >>= rLine)
+ return true;
+
+ table::BorderLine aBorderLine;
+ if (rAny >>= aBorderLine)
+ {
+ rLine.Color = aBorderLine.Color;
+ rLine.InnerLineWidth = aBorderLine.InnerLineWidth;
+ rLine.OuterLineWidth = aBorderLine.OuterLineWidth;
+ rLine.LineDistance = aBorderLine.LineDistance;
+ rLine.LineStyle = table::BorderLineStyle::SOLID;
+ return true;
+ }
+
+ return false;
+}
+
+template<typename Item>
+bool
+lcl_setLine(const uno::Any& rAny, Item& rItem, USHORT nLine, const bool bConvert)
+{
+ bool bSet(false);
+ table::BorderLine2 aBorderLine;
+ if (lcl_extractBorderLine(rAny, aBorderLine))
+ {
+ SvxBorderLine aLine;
+ bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
+ if (bSet)
+ rItem.SetLine(&aLine, nLine);
+ }
+ return bSet;
+}
+
+}
+
bool SvxBoxItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
{
- sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
sal_uInt16 nLine = BOX_LINE_TOP;
sal_Bool bDistMember = sal_False;
nMemberId &= ~CONVERT_TWIPS;
@@ -1980,44 +2036,18 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
if (( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ))
{
// 4 Borders and 5 distances
- sal_Int32 nDist = 0;
- SvxBorderLine aLine;
- table::BorderLine2 aBorderLine;
- if ( aSeq[0] >>= aBorderLine )
- {
- sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
- SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT );
- }
- else
- return sal_False;
-
- if ( aSeq[1] >>= aBorderLine )
- {
- sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
- SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT );
- }
- else
- return sal_False;
-
- if ( aSeq[2] >>= aBorderLine )
+ const sal_uInt16 aBorders[] = { BOX_LINE_LEFT, BOX_LINE_RIGHT, BOX_LINE_BOTTOM, BOX_LINE_TOP };
+ for (int n(0); n != SAL_N_ELEMENTS(aBorders); ++n)
{
- sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
- SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM );
- }
- else
- return sal_False;
-
- if ( aSeq[3] >>= aBorderLine )
- {
- sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
- SetLine(bSet ? &aLine : 0, BOX_LINE_TOP );
+ if (!lcl_setLine(aSeq[n], *this, aBorders[n], bConvert))
+ return sal_False;
}
- else
- return sal_False;
+ // WTH are the borders and the distances saved in different order?
sal_uInt16 nLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM, BOX_LINE_LEFT, BOX_LINE_RIGHT };
for ( sal_Int32 n = 4; n < 9; n++ )
{
+ sal_Int32 nDist = 0;
if ( aSeq[n] >>= nDist )
{
if( bConvert )
@@ -2085,7 +2115,7 @@ bool SvxBoxItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
return sal_False;
table::BorderLine2 aBorderLine;
- if( rVal >>= aBorderLine )
+ if( lcl_extractBorderLine(rVal, aBorderLine) )
{
// usual struct
}
@@ -2897,26 +2927,13 @@ bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
if (( rVal >>= aSeq ) && ( aSeq.getLength() == 5 ))
{
// 2 BorderLines, flags, valid flags and distance
- table::BorderLine2 aBorderLine;
- SvxBorderLine aLine;
- sal_Int16 nFlags( 0 );
- sal_Int32 nVal( 0 );
- if ( aSeq[0] >>= aBorderLine )
- {
- sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
- if ( bSet )
- SetLine( &aLine, BOXINFO_LINE_HORI );
- }
- else
+ if (!lcl_setLine(aSeq[0], *this, BOXINFO_LINE_HORI, bConvert))
return sal_False;
- if ( aSeq[1] >>= aBorderLine )
- {
- sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
- if ( bSet )
- SetLine( &aLine, BOXINFO_LINE_VERT );
- }
- else
+ if (!lcl_setLine(aSeq[1], *this, BOXINFO_LINE_VERT, bConvert))
return sal_False;
+
+ sal_Int16 nFlags( 0 );
+ sal_Int32 nVal( 0 );
if ( aSeq[2] >>= nFlags )
{
SetTable ( ( nFlags & 0x01 ) != 0 );
@@ -2946,7 +2963,7 @@ bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
return sal_False;
table::BorderLine2 aBorderLine;
- if( rVal >>= aBorderLine )
+ if( lcl_extractBorderLine(rVal, aBorderLine) )
{
// usual struct
}
@@ -3323,7 +3340,7 @@ bool SvxLineItem::PutValue( const uno::Any& rVal, BYTE nMemId )
if ( nMemId == 0 )
{
table::BorderLine2 aLine;
- if ( rVal >>= aLine )
+ if ( lcl_extractBorderLine(rVal, aLine) )
{
if ( !pLine )
pLine = new SvxBorderLine;