summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2010-10-06 23:54:46 +0200
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-10-06 23:54:46 +0200
commit58a4049174516149403791afb9216e8b54bf0c90 (patch)
treedbe0957153c78b17135559d2c57cf7d572013b3a /oox
parent72c9c9b3aa5cf2ffc61cf4eadbc819922723a356 (diff)
fate#307731, fate#307730: Adds dotted and dashed border lines
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/helper/helper.hxx4
-rw-r--r--oox/inc/oox/xls/stylesbuffer.hxx12
-rw-r--r--oox/source/drawingml/table/tablecell.cxx6
-rw-r--r--oox/source/drawingml/table/tableproperties.cxx2
-rw-r--r--oox/source/drawingml/table/tablerow.cxx2
-rw-r--r--oox/source/xls/stylesbuffer.cxx87
6 files changed, 63 insertions, 50 deletions
diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx
index 7943f7357824..6ed5b977d875 100644
--- a/oox/inc/oox/helper/helper.hxx
+++ b/oox/inc/oox/helper/helper.hxx
@@ -97,6 +97,10 @@ const sal_Int32 API_RGB_TRANSPARENT = -1; /// Transparent color fo
const sal_Int32 API_RGB_BLACK = 0x000000; /// Black color for API calls.
const sal_Int32 API_RGB_WHITE = 0xFFFFFF; /// White color for API calls.
+const sal_Int16 API_LINE_SOLID = 0;
+const sal_Int16 API_LINE_DOTTED = 1;
+const sal_Int16 API_LINE_DASHED = 2;
+
const sal_Int16 API_LINE_NONE = 0;
const sal_Int16 API_LINE_HAIR = 2;
const sal_Int16 API_LINE_THIN = 35;
diff --git a/oox/inc/oox/xls/stylesbuffer.hxx b/oox/inc/oox/xls/stylesbuffer.hxx
index b47d9d00efc4..33801524f72a 100644
--- a/oox/inc/oox/xls/stylesbuffer.hxx
+++ b/oox/inc/oox/xls/stylesbuffer.hxx
@@ -33,7 +33,7 @@
#include <com/sun/star/table/CellHoriJustify.hpp>
#include <com/sun/star/table/CellOrientation.hpp>
#include <com/sun/star/table/CellVertJustify.hpp>
-#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
#include "oox/helper/containerhelper.hxx"
#include "oox/helper/graphichelper.hxx"
#include "oox/drawingml/color.hxx"
@@ -517,10 +517,12 @@ struct BorderModel
/** Contains API attributes of a complete cell border. */
struct ApiBorderData
{
- typedef ::com::sun::star::table::TableBorder ApiTableBorder;
- typedef ::com::sun::star::table::BorderLine ApiBorderLine;
+ typedef ::com::sun::star::table::BorderLine2 ApiBorderLine;
- ApiTableBorder maBorder; /// Left/right/top/bottom line format.
+ ApiBorderLine maLeft; /// Left line format
+ ApiBorderLine maRight; /// Right line format
+ ApiBorderLine maTop; /// Top line format
+ ApiBorderLine maBottom; /// Bottom line format
ApiBorderLine maTLtoBR; /// Diagonal top-left to bottom-right line format.
ApiBorderLine maBLtoTR; /// Diagonal bottom-left to top-right line format.
bool mbBorderUsed; /// True = left/right/top/bottom line format used.
@@ -583,7 +585,7 @@ private:
/** Converts border line data to an API struct, returns true, if the line is marked as used. */
bool convertBorderLine(
- ::com::sun::star::table::BorderLine& rBorderLine,
+ ::com::sun::star::table::BorderLine2& rBorderLine,
const BorderLineModel& rModel );
private:
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index ee3ac495f4d6..27db7aa21cdc 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -37,7 +37,7 @@
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/table/XTable.hpp>
#include <com/sun/star/table/XMergeableCellRange.hpp>
-#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
@@ -48,7 +48,7 @@ using namespace ::oox::core;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
-using ::com::sun::star::table::BorderLine;
+using ::com::sun::star::table::BorderLine2;
using ::com::sun::star::drawing::LineStyle;
namespace oox { namespace drawingml { namespace table {
@@ -76,7 +76,7 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
Reference< XPropertySet >& rxPropSet, oox::drawingml::LineProperties& rLineProperties,
sal_Int32 nPropId )
{
- BorderLine aBorderLine( 0, 0, 0, 0 );
+ BorderLine2 aBorderLine( 0, 0, 0, 0, API_LINE_SOLID );
if( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill ) )
{
Color aColor = rLineProperties.maLineFill.getBestSolidColor();
diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx
index 136754fbccc3..277b9b23541a 100644
--- a/oox/source/drawingml/table/tableproperties.cxx
+++ b/oox/source/drawingml/table/tableproperties.cxx
@@ -32,7 +32,7 @@
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/table/XMergeableCellRange.hpp>
-#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
#include "oox/core/namespaces.hxx"
#include "oox/core/xmlfilterbase.hxx"
#include "oox/helper/propertyset.hxx"
diff --git a/oox/source/drawingml/table/tablerow.cxx b/oox/source/drawingml/table/tablerow.cxx
index 8986a6e35d08..a8c1b2532f1a 100644
--- a/oox/source/drawingml/table/tablerow.cxx
+++ b/oox/source/drawingml/table/tablerow.cxx
@@ -34,7 +34,7 @@
#include "oox/helper/propertyset.hxx"
#include <com/sun/star/table/XTable.hpp>
#include <com/sun/star/table/XMergeableCellRange.hpp>
-#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
using rtl::OUString;
using namespace ::oox::core;
diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx
index 922ea548afed..48e311be87d5 100644
--- a/oox/source/xls/stylesbuffer.cxx
+++ b/oox/source/xls/stylesbuffer.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/table/CellVertJustify2.hpp>
#include <com/sun/star/table/CellJustifyMethod.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
#include <rtl/tencinfo.h>
#include <rtl/ustrbuf.hxx>
#include "properties.hxx"
@@ -71,6 +72,7 @@ using ::com::sun::star::awt::FontDescriptor;
using ::com::sun::star::awt::XDevice;
using ::com::sun::star::awt::XFont2;
using ::com::sun::star::table::BorderLine;
+using ::com::sun::star::table::BorderLine2;
using ::com::sun::star::table::TableBorder;
using ::com::sun::star::text::XText;
using ::com::sun::star::style::XStyle;
@@ -1504,6 +1506,15 @@ void Protection::writeToPropertyMap( PropertyMap& rPropMap ) const
// ============================================================================
+namespace {
+
+bool lcl_isBorder(const ::com::sun::star::table::BorderLine& rBorder)
+{
+ return (rBorder.InnerLineWidth > 0) || (rBorder.OuterLineWidth > 0);
+}
+
+}
+
BorderLineModel::BorderLineModel( bool bDxf ) :
mnStyle( XML_none ),
mbUsed( !bDxf )
@@ -1551,10 +1562,10 @@ ApiBorderData::ApiBorderData() :
bool ApiBorderData::hasAnyOuterBorder() const
{
return
- (maBorder.IsTopLineValid && (maBorder.TopLine.OuterLineWidth > 0)) ||
- (maBorder.IsBottomLineValid && (maBorder.BottomLine.OuterLineWidth > 0)) ||
- (maBorder.IsLeftLineValid && (maBorder.LeftLine.OuterLineWidth > 0)) ||
- (maBorder.IsRightLineValid && (maBorder.RightLine.OuterLineWidth > 0));
+ ( ( lcl_isBorder( maTop ) && maTop.OuterLineWidth > 0 ) ) ||
+ ( ( lcl_isBorder( maBottom ) && maBottom.OuterLineWidth > 0 ) ) ||
+ ( ( lcl_isBorder( maLeft ) && maLeft.OuterLineWidth > 0 ) ) ||
+ ( ( lcl_isBorder( maRight ) && maRight.OuterLineWidth > 0 ) );
}
namespace {
@@ -1592,7 +1603,10 @@ bool operator==( const TableBorder& rLeft, const TableBorder& rRight )
bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight )
{
return
- (rLeft.maBorder == rRight.maBorder) &&
+ (rLeft.maLeft == rRight.maLeft) &&
+ (rLeft.maRight == rRight.maRight) &&
+ (rLeft.maTop == rRight.maTop) &&
+ (rLeft.maBottom == rRight.maBottom) &&
(rLeft.maTLtoBR == rRight.maTLtoBR) &&
(rLeft.maBLtoTR == rRight.maBLtoTR) &&
(rLeft.mbBorderUsed == rRight.mbBorderUsed) &&
@@ -1616,7 +1630,7 @@ inline sal_Int32 lclGetBorderLineWidth( const BorderLine& rBorderLine )
return rBorderLine.OuterLineWidth + rBorderLine.LineDistance + rBorderLine.InnerLineWidth;
}
-const BorderLine* lclGetThickerLine( const BorderLine& rBorderLine1, sal_Bool bValid1, const BorderLine& rBorderLine2, sal_Bool bValid2 )
+const BorderLine2* lclGetThickerLine( const BorderLine2& rBorderLine1, sal_Bool bValid1, const BorderLine2& rBorderLine2, sal_Bool bValid2 )
{
if( bValid1 && bValid2 )
return (lclGetBorderLineWidth( rBorderLine1 ) < lclGetBorderLineWidth( rBorderLine2 )) ? &rBorderLine2 : &rBorderLine1;
@@ -1754,21 +1768,10 @@ void Border::finalizeImport()
maApiData.mbBorderUsed = maModel.maLeft.mbUsed || maModel.maRight.mbUsed || maModel.maTop.mbUsed || maModel.maBottom.mbUsed;
maApiData.mbDiagUsed = maModel.maDiagonal.mbUsed;
- maApiData.maBorder.IsLeftLineValid = convertBorderLine( maApiData.maBorder.LeftLine, maModel.maLeft );
- maApiData.maBorder.IsRightLineValid = convertBorderLine( maApiData.maBorder.RightLine, maModel.maRight );
- maApiData.maBorder.IsTopLineValid = convertBorderLine( maApiData.maBorder.TopLine, maModel.maTop );
- maApiData.maBorder.IsBottomLineValid = convertBorderLine( maApiData.maBorder.BottomLine, maModel.maBottom );
-
- if( !mbDxf )
- {
- maApiData.maBorder.IsVerticalLineValid = maApiData.maBorder.IsLeftLineValid || maApiData.maBorder.IsRightLineValid;
- if( const BorderLine* pVertLine = lclGetThickerLine( maApiData.maBorder.LeftLine, maApiData.maBorder.IsLeftLineValid, maApiData.maBorder.RightLine, maApiData.maBorder.IsRightLineValid ) )
- maApiData.maBorder.VerticalLine = *pVertLine;
-
- maApiData.maBorder.IsHorizontalLineValid = maApiData.maBorder.IsTopLineValid || maApiData.maBorder.IsBottomLineValid;
- if( const BorderLine* pHorLine = lclGetThickerLine( maApiData.maBorder.TopLine, maApiData.maBorder.IsTopLineValid, maApiData.maBorder.BottomLine, maApiData.maBorder.IsBottomLineValid ) )
- maApiData.maBorder.HorizontalLine = *pHorLine;
- }
+ convertBorderLine( maApiData.maLeft, maModel.maLeft );
+ convertBorderLine( maApiData.maRight, maModel.maRight );
+ convertBorderLine( maApiData.maTop, maModel.maTop );
+ convertBorderLine( maApiData.maBottom, maModel.maBottom );
if( maModel.mbDiagTLtoBR )
convertBorderLine( maApiData.maTLtoBR, maModel.maDiagonal );
@@ -1779,7 +1782,12 @@ void Border::finalizeImport()
void Border::writeToPropertyMap( PropertyMap& rPropMap ) const
{
if( maApiData.mbBorderUsed )
- rPropMap[ PROP_TableBorder ] <<= maApiData.maBorder;
+ {
+ rPropMap[ PROP_LeftBorder ] <<= maApiData.maLeft;
+ rPropMap[ PROP_RightBorder ] <<= maApiData.maRight;
+ rPropMap[ PROP_TopBorder ] <<= maApiData.maTop;
+ rPropMap[ PROP_BottomBorder ] <<= maApiData.maBottom;
+ }
if( maApiData.mbDiagUsed )
{
rPropMap[ PROP_DiagonalTLBR ] <<= maApiData.maTLtoBR;
@@ -1787,29 +1795,18 @@ void Border::writeToPropertyMap( PropertyMap& rPropMap ) const
}
}
-namespace {
-
-bool lcl_isBorder(const ::com::sun::star::table::BorderLine& rBorder)
-{
- return (rBorder.InnerLineWidth > 0) || (rBorder.OuterLineWidth > 0);
-}
-
-}
-
bool Border::hasBorder() const
{
- const ApiBorderData::ApiTableBorder& rTabBorder = maApiData.maBorder;
-
- if (rTabBorder.IsBottomLineValid && lcl_isBorder(rTabBorder.BottomLine))
+ if (lcl_isBorder(maApiData.maBottom))
return true;
- if (rTabBorder.IsTopLineValid && lcl_isBorder(rTabBorder.TopLine))
+ if (lcl_isBorder(maApiData.maTop))
return true;
- if (rTabBorder.IsLeftLineValid && lcl_isBorder(rTabBorder.LeftLine))
+ if (lcl_isBorder(maApiData.maLeft))
return true;
- if (rTabBorder.IsRightLineValid && lcl_isBorder(rTabBorder.RightLine))
+ if (lcl_isBorder(maApiData.maRight))
return true;
return false;
@@ -1828,15 +1825,25 @@ BorderLineModel* Border::getBorderLine( sal_Int32 nElement )
return 0;
}
-bool Border::convertBorderLine( BorderLine& rBorderLine, const BorderLineModel& rModel )
+bool Border::convertBorderLine( BorderLine2& rBorderLine, const BorderLineModel& rModel )
{
rBorderLine.Color = rModel.maColor.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK );
switch( rModel.mnStyle )
{
case XML_dashDot: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break;
case XML_dashDotDot: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break;
- case XML_dashed: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break;
- case XML_dotted: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break;
+ case XML_dashed:
+ {
+ lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
+ rBorderLine.LineStyle = API_LINE_DASHED;
+ break;
+ }
+ case XML_dotted:
+ {
+ lclSetBorderLineWidth( rBorderLine, API_LINE_THIN );
+ rBorderLine.LineStyle = API_LINE_DOTTED;
+ break;
+ }
case XML_double: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN, API_LINE_THIN, API_LINE_THIN ); break;
case XML_hair: lclSetBorderLineWidth( rBorderLine, API_LINE_HAIR ); break;
case XML_medium: lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM ); break;