summaryrefslogtreecommitdiff
path: root/xmloff/source
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-01-12 23:30:44 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:57:17 +0100
commitb624e6e6cf2ecfc6e6e983af45212fce5e731006 (patch)
tree1deb43c8ce1fe134fd337cc00077cbfcb169e177 /xmloff/source
parent9818095b8ee55ce45e2ff5b9b0d92b7e1484a45d (diff)
ODF export of new border types
Diffstat (limited to 'xmloff/source')
-rwxr-xr-xxmloff/source/style/PageMasterExportPropMapper.cxx5
-rwxr-xr-xxmloff/source/style/PageMasterImportPropMapper.cxx3
-rwxr-xr-xxmloff/source/style/bordrhdl.cxx240
-rwxr-xr-xxmloff/source/text/txtexppr.cxx8
-rwxr-xr-xxmloff/source/text/txtimppr.cxx1
5 files changed, 93 insertions, 164 deletions
diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx
index 38c74d128356..6a9b9d1d7a2f 100755
--- a/xmloff/source/style/PageMasterExportPropMapper.cxx
+++ b/xmloff/source/style/PageMasterExportPropMapper.cxx
@@ -46,11 +46,12 @@ using namespace ::xmloff::token;
//______________________________________________________________________________
-inline sal_Bool lcl_HasSameLineWidth( const table::BorderLine& rLine1, const table::BorderLine& rLine2 )
+inline sal_Bool lcl_HasSameLineWidth( const table::BorderLine2& rLine1, const table::BorderLine2& rLine2 )
{
return (rLine1.InnerLineWidth == rLine2.InnerLineWidth) &&
(rLine1.OuterLineWidth == rLine2.OuterLineWidth) &&
- (rLine1.LineDistance == rLine2.LineDistance);
+ (rLine1.LineDistance == rLine2.LineDistance) &&
+ (rLine1.LineWidth == rLine2.LineWidth);
}
inline sal_Bool operator==( const table::BorderLine2& rLine1, const table::BorderLine2& rLine2 )
diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx
index ad3350767d96..e8c82edb7f5b 100755
--- a/xmloff/source/style/PageMasterImportPropMapper.cxx
+++ b/xmloff/source/style/PageMasterImportPropMapper.cxx
@@ -214,6 +214,7 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >&
aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
+ aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
pBorders[i]->maValue <<= aBorderLine;
}
}
@@ -236,6 +237,7 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >&
aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
+ aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
pHeaderBorders[i]->maValue <<= aBorderLine;
}
}
@@ -258,6 +260,7 @@ void PageMasterImportPropertyMapper::finished(::std::vector< XMLPropertyState >&
aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
+ aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
pFooterBorders[i]->maValue <<= aBorderLine;
}
}
diff --git a/xmloff/source/style/bordrhdl.cxx b/xmloff/source/style/bordrhdl.cxx
index 7800f8ee3eb7..9d328a0b1063 100755
--- a/xmloff/source/style/bordrhdl.cxx
+++ b/xmloff/source/style/bordrhdl.cxx
@@ -43,65 +43,25 @@ using ::rtl::OUStringBuffer;
using namespace ::com::sun::star;
using namespace ::xmloff::token;
-const sal_Int16 API_LINE_SOLID = 0;
-const sal_Int16 API_LINE_DOTTED = 1;
-const sal_Int16 API_LINE_DASHED = 2;
+const sal_uInt16 API_LINE_SOLID = 0;
+const sal_uInt16 API_LINE_DOTTED = 1;
+const sal_uInt16 API_LINE_DASHED = 2;
+const sal_uInt16 API_LINE_DOUBLE = 3;
+const sal_uInt16 API_LINE_THINTHICK_SMALLGAP = 4;
+const sal_uInt16 API_LINE_THINTHICK_MEDIUMGAP = 5;
+const sal_uInt16 API_LINE_THINTHICK_LARGEGAP = 6;
+const sal_uInt16 API_LINE_THICKTHIN_SMALLGAP = 7;
+const sal_uInt16 API_LINE_THICKTHIN_MEDIUMGAP = 8;
+const sal_uInt16 API_LINE_THICKTHIN_LARGEGAP = 9;
+const sal_uInt16 API_LINE_EMBOSSED = 10;
+const sal_uInt16 API_LINE_ENGRAVED = 11;
+const sal_uInt16 API_LINE_OUTSET = 12;
+const sal_uInt16 API_LINE_INSET = 13;
+const sal_uInt16 API_LINE_NONE = USHRT_MAX;
-// copied from svx/boxitem.hxx
#define DEF_LINE_WIDTH_0 1
#define DEF_LINE_WIDTH_1 35
#define DEF_LINE_WIDTH_2 88
-#define DEF_LINE_WIDTH_3 141
-#define DEF_LINE_WIDTH_4 176
-
-#define DEF_MAX_LINE_WIDHT DEF_LINE_WIDTH_4
-#define DEF_MAX_LINE_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE0_OUT DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE0_IN DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE0_DIST DEF_LINE_WIDTH_1
-
-#define DEF_DOUBLE_LINE1_OUT DEF_LINE_WIDTH_1
-#define DEF_DOUBLE_LINE1_IN DEF_LINE_WIDTH_1
-#define DEF_DOUBLE_LINE1_DIST DEF_LINE_WIDTH_1
-
-#define DEF_DOUBLE_LINE2_OUT DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE2_IN DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE2_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE3_OUT DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE3_IN DEF_LINE_WIDTH_1
-#define DEF_DOUBLE_LINE3_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE4_OUT DEF_LINE_WIDTH_1
-#define DEF_DOUBLE_LINE4_IN DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE4_DIST DEF_LINE_WIDTH_1
-
-#define DEF_DOUBLE_LINE5_OUT DEF_LINE_WIDTH_3
-#define DEF_DOUBLE_LINE5_IN DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE5_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE6_OUT DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE6_IN DEF_LINE_WIDTH_3
-#define DEF_DOUBLE_LINE6_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE7_OUT DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE7_IN DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE7_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE8_OUT DEF_LINE_WIDTH_1
-#define DEF_DOUBLE_LINE8_IN DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE8_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE9_OUT DEF_LINE_WIDTH_2
-#define DEF_DOUBLE_LINE9_IN DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE9_DIST DEF_LINE_WIDTH_2
-
-#define DEF_DOUBLE_LINE10_OUT DEF_LINE_WIDTH_3
-#define DEF_DOUBLE_LINE10_IN DEF_LINE_WIDTH_0
-#define DEF_DOUBLE_LINE10_DIST DEF_LINE_WIDTH_2
-
-// finished copy
#define SVX_XML_BORDER_STYLE_NONE 0
#define SVX_XML_BORDER_STYLE_SOLID 1
@@ -115,16 +75,16 @@ const sal_Int16 API_LINE_DASHED = 2;
SvXMLEnumMapEntry pXML_BorderStyles[] =
{
- { XML_NONE, SVX_XML_BORDER_STYLE_NONE },
- { XML_HIDDEN, SVX_XML_BORDER_STYLE_NONE },
- { XML_SOLID, SVX_XML_BORDER_STYLE_SOLID },
- { XML_DOUBLE, SVX_XML_BORDER_STYLE_DOUBLE },
- { XML_DOTTED, SVX_XML_BORDER_STYLE_DOTTED },
- { XML_DASHED, SVX_XML_BORDER_STYLE_DASHED },
- { XML_GROOVE, SVX_XML_BORDER_STYLE_SOLID },
- { XML_RIDGE, SVX_XML_BORDER_STYLE_SOLID },
- { XML_INSET, SVX_XML_BORDER_STYLE_SOLID },
- { XML_OUTSET, SVX_XML_BORDER_STYLE_SOLID },
+ { XML_NONE, API_LINE_NONE },
+ { XML_HIDDEN, API_LINE_NONE },
+ { XML_SOLID, API_LINE_SOLID },
+ { XML_DOUBLE, API_LINE_DOUBLE },
+ { XML_DOTTED, API_LINE_DOTTED },
+ { XML_DASHED, API_LINE_DASHED },
+ { XML_GROOVE, API_LINE_ENGRAVED },
+ { XML_RIDGE, API_LINE_EMBOSSED },
+ { XML_INSET, API_LINE_INSET },
+ { XML_OUTSET, API_LINE_OUTSET },
{ XML_TOKEN_INVALID, 0 }
};
@@ -137,89 +97,21 @@ SvXMLEnumMapEntry pXML_NamedBorderWidths[] =
};
// mapping tables to map external xml input to intarnal box line widths
-// Ein Eintrag besteht aus vier USHORTs. Der erste ist die Gesamtbreite,
-// die anderen sind die 3 Einzelbreiten
-
-#define SBORDER_ENTRY( n ) \
- DEF_LINE_WIDTH_##n, DEF_LINE_WIDTH_##n, 0, 0
-#define DBORDER_ENTRY( n ) \
- DEF_DOUBLE_LINE##n##_OUT + DEF_DOUBLE_LINE##n##_IN + \
- DEF_DOUBLE_LINE##n##_DIST, \
- DEF_DOUBLE_LINE##n##_OUT, \
- DEF_DOUBLE_LINE##n##_IN, \
- DEF_DOUBLE_LINE##n##_DIST
-
-#define TDBORDER_ENTRY( n ) \
- DEF_DOUBLE_LINE##n##_OUT, \
- DEF_DOUBLE_LINE##n##_OUT, \
- DEF_DOUBLE_LINE##n##_IN, \
- DEF_DOUBLE_LINE##n##_DIST
-
-
-static sal_uInt16 const aSBorderWidths[] =
+static sal_uInt16 const aBorderWidths[] =
{
- SBORDER_ENTRY( 0 ), SBORDER_ENTRY( 1 ), SBORDER_ENTRY( 2 ),
- SBORDER_ENTRY( 3 ), SBORDER_ENTRY( 4 )
-};
-
-static sal_uInt16 const aDBorderWidths[] =
-{
- DBORDER_ENTRY( 0 ),
- DBORDER_ENTRY( 7 ),
- DBORDER_ENTRY( 1 ),
- DBORDER_ENTRY( 8 ),
- DBORDER_ENTRY( 4 ),
- DBORDER_ENTRY( 9 ),
- DBORDER_ENTRY( 3 ),
- DBORDER_ENTRY( 10 ),
- DBORDER_ENTRY( 2 ),
- DBORDER_ENTRY( 6 ),
- DBORDER_ENTRY( 5 )
+ DEF_LINE_WIDTH_0,
+ DEF_LINE_WIDTH_1,
+ DEF_LINE_WIDTH_2
};
void lcl_frmitems_setXMLBorderStyle( table::BorderLine2 & rBorderLine, sal_uInt16 nStyle )
{
- sal_Int16 eStyle = API_LINE_SOLID;
- switch ( nStyle )
- {
- case SVX_XML_BORDER_STYLE_DOTTED:
- eStyle = API_LINE_DOTTED;
- break;
- case SVX_XML_BORDER_STYLE_DASHED:
- eStyle = API_LINE_DASHED;
- break;
- default:
- break;
- }
- rBorderLine.LineStyle = eStyle;
-}
+ sal_Int16 eStyle = -1; // None
+ if ( nStyle != API_LINE_NONE )
+ eStyle = sal_Int16( nStyle );
-void lcl_frmitems_setXMLBorderWidth( table::BorderLine &rBorderLine,
- sal_uInt16 nWidth, sal_Bool bDouble )
-{
- if( bDouble )
- {
- const sal_uInt16 *aWidths = aDBorderWidths;
- sal_uInt16 nSize = sizeof( aDBorderWidths );
- sal_uInt16 i = (nSize / sizeof(sal_uInt16)) - 4;
- while( i>0 &&
- nWidth <= ((aWidths[i] + aWidths[i-4]) / 2) )
- {
- i -= 4;
- }
-
- rBorderLine.OuterLineWidth = aWidths[i+1];
- rBorderLine.InnerLineWidth = aWidths[i+2];
- rBorderLine.LineDistance = aWidths[i+3];
- }
- else
- {
- rBorderLine.OuterLineWidth = 0 == nWidth ? DEF_LINE_WIDTH_0 : nWidth;
- rBorderLine.InnerLineWidth = 0;
- rBorderLine.LineDistance = 0;
-
- }
+ rBorderLine.LineStyle = eStyle;
}
@@ -278,7 +170,23 @@ sal_Bool XMLBorderWidthHdl::exportXML( OUString& rStrExpValue, const uno::Any& r
if(!(rValue >>= aBorderLine))
return sal_False;
- if( aBorderLine.LineDistance == 0 && aBorderLine.InnerLineWidth == 0)
+ bool bDouble = false;
+ switch ( aBorderLine.LineStyle )
+ {
+ case API_LINE_DOUBLE:
+ case API_LINE_THINTHICK_SMALLGAP:
+ case API_LINE_THINTHICK_MEDIUMGAP:
+ case API_LINE_THINTHICK_LARGEGAP:
+ case API_LINE_THICKTHIN_SMALLGAP:
+ case API_LINE_THICKTHIN_MEDIUMGAP:
+ case API_LINE_THICKTHIN_LARGEGAP:
+ bDouble = true;
+ break;
+ default:
+ break;
+ }
+
+ if( ( aBorderLine.LineDistance == 0 && aBorderLine.InnerLineWidth == 0 ) || !bDouble )
return sal_False;
rUnitConverter.convertMeasure( aOut, aBorderLine.InnerLineWidth );
@@ -363,7 +271,6 @@ sal_Bool XMLBorderHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue
}
// first of all, delete an empty line
- sal_Bool bDouble = SVX_XML_BORDER_STYLE_DOUBLE == nStyle;
if( (bHasStyle && SVX_XML_BORDER_STYLE_NONE == nStyle) ||
(bHasWidth && USHRT_MAX == nNamedWidth && 0 == nWidth) )
{
@@ -375,22 +282,17 @@ sal_Bool XMLBorderHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue
{
if( USHRT_MAX != nNamedWidth )
{
- const sal_uInt16 *aWidths = bDouble ? aDBorderWidths
- : aSBorderWidths;
- sal_uInt16 nNWidth = nNamedWidth * 4;
- aBorderLine.OuterLineWidth = aWidths[nNWidth+1];
- aBorderLine.InnerLineWidth = aWidths[nNWidth+2];
- aBorderLine.LineDistance = aWidths[nNWidth+3];
+ aBorderLine.LineWidth = aBorderWidths[nNamedWidth];
}
else
{
- lcl_frmitems_setXMLBorderWidth( aBorderLine, nWidth, bDouble );
+ aBorderLine.LineWidth = nWidth;
lcl_frmitems_setXMLBorderStyle( aBorderLine, nStyle );
}
}
else
{
- lcl_frmitems_setXMLBorderWidth( aBorderLine, 0, bDouble );
+ aBorderLine.LineWidth = 0;
lcl_frmitems_setXMLBorderStyle( aBorderLine, nStyle );
}
@@ -410,13 +312,7 @@ sal_Bool XMLBorderHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue
if(!(rValue >>= aBorderLine))
return sal_False;
- sal_Int32 nWidth = aBorderLine.OuterLineWidth;
- const sal_uInt16 nDistance = aBorderLine.LineDistance;
- if( 0 != nDistance )
- {
- nWidth += nDistance;
- nWidth += aBorderLine.InnerLineWidth;
- }
+ sal_Int32 nWidth = aBorderLine.LineWidth;
if( nWidth == 0 )
{
@@ -424,7 +320,8 @@ sal_Bool XMLBorderHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue
}
else
{
- rUnitConverter.convertMeasure( aOut, nWidth );
+ rUnitConverter.convertMeasure( aOut, nWidth,
+ MAP_100TH_MM, MAP_POINT );
aOut.append( sal_Unicode( ' ' ) );
@@ -437,11 +334,32 @@ sal_Bool XMLBorderHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue
case API_LINE_DOTTED:
eStyleToken = XML_DOTTED;
break;
+ case API_LINE_DOUBLE:
+ case API_LINE_THINTHICK_SMALLGAP:
+ case API_LINE_THINTHICK_MEDIUMGAP:
+ case API_LINE_THINTHICK_LARGEGAP:
+ case API_LINE_THICKTHIN_SMALLGAP:
+ case API_LINE_THICKTHIN_MEDIUMGAP:
+ case API_LINE_THICKTHIN_LARGEGAP:
+ eStyleToken = XML_DOUBLE;
+ break;
+ case API_LINE_EMBOSSED:
+ eStyleToken = XML_EMBOSSED;
+ break;
+ case API_LINE_ENGRAVED:
+ eStyleToken = XML_ENGRAVED;
+ break;
+ case API_LINE_OUTSET:
+ eStyleToken = XML_OUTSET;
+ break;
+ case API_LINE_INSET:
+ eStyleToken = XML_INSET;
+ break;
case API_LINE_SOLID:
default:
- eStyleToken = XML_SOLID;
+ break;
}
- aOut.append( GetXMLToken((0 == nDistance) ? eStyleToken : XML_DOUBLE) );
+ aOut.append( GetXMLToken( eStyleToken ) );
aOut.append( sal_Unicode( ' ' ) );
diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index d0c78829bf92..169ec68b6698 100755
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -698,12 +698,15 @@ void XMLTextExportPropertySetMapper::ContextFilter(
if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth &&
aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance &&
aLeft.LineStyle == aRight.LineStyle &&
+ aLeft.LineWidth == aRight.LineWidth &&
aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth &&
aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance &&
aLeft.LineStyle == aTop.LineStyle &&
+ aLeft.LineWidth == aTop.LineWidth &&
aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth &&
aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance &&
- aLeft.LineStyle == aBottom.LineStyle )
+ aLeft.LineStyle == aBottom.LineStyle &&
+ aLeft.LineWidth == aBottom.LineWidth )
{
pLeftBorderWidthState->mnIndex = -1;
pLeftBorderWidthState->maValue.clear();
@@ -774,11 +777,14 @@ void XMLTextExportPropertySetMapper::ContextFilter(
if( aLeft.Color == aRight.Color && aLeft.InnerLineWidth == aRight.InnerLineWidth &&
aLeft.OuterLineWidth == aRight.OuterLineWidth && aLeft.LineDistance == aRight.LineDistance &&
aLeft.LineStyle == aRight.LineStyle &&
+ aLeft.LineWidth == aRight.LineWidth &&
aLeft.Color == aTop.Color && aLeft.InnerLineWidth == aTop.InnerLineWidth &&
aLeft.OuterLineWidth == aTop.OuterLineWidth && aLeft.LineDistance == aTop.LineDistance &&
aLeft.LineStyle == aTop.LineStyle &&
+ aLeft.LineWidth == aTop.LineWidth &&
aLeft.Color == aBottom.Color && aLeft.InnerLineWidth == aBottom.InnerLineWidth &&
aLeft.OuterLineWidth == aBottom.OuterLineWidth && aLeft.LineDistance == aBottom.LineDistance &&
+ aLeft.LineWidth == aBottom.LineWidth &&
aLeft.LineStyle == aBottom.LineStyle )
{
pLeftBorderState->mnIndex = -1;
diff --git a/xmloff/source/text/txtimppr.cxx b/xmloff/source/text/txtimppr.cxx
index 886e5756abd4..04a43fd07a15 100755
--- a/xmloff/source/text/txtimppr.cxx
+++ b/xmloff/source/text/txtimppr.cxx
@@ -446,6 +446,7 @@ void XMLTextImportPropertyMapper::finished(
aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
+ aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
pBorders[i]->maValue <<= aBorderLine;
}