summaryrefslogtreecommitdiff
path: root/xmloff/source/style/bordrhdl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/style/bordrhdl.cxx')
-rwxr-xr-xxmloff/source/style/bordrhdl.cxx240
1 files changed, 79 insertions, 161 deletions
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( ' ' ) );