summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-02-18 10:47:20 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:56:50 +0100
commit87c81ba999a59c94c74845cc63b1b9c71dda6aaa (patch)
treee5ffe8aac942c6601f6afb2d70c90f15c877fddb /writerfilter
parent62b6a47aed2fe695ab3e0ce6e76c91ff6bc6c463 (diff)
Docx import filter now working with new borders and width
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/ConversionHelper.cxx191
1 files changed, 34 insertions, 157 deletions
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index 128096a0a5e1..a1ebac530a46 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -27,6 +27,7 @@
************************************************************************/
#include <ConversionHelper.hxx>
#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/style/NumberingType.hpp>
@@ -37,6 +38,7 @@
#include <functional>
using namespace com::sun::star;
+using namespace com::sun::star::table::BorderLineStyle;
namespace writerfilter {
namespace dmapper{
@@ -140,14 +142,7 @@ void MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType,
if(!bIsOOXML && sal::static_int_cast<sal_uInt32>(nLineColor) < SAL_N_ELEMENTS(aBorderDefColor))
nLineColor = aBorderDefColor[nLineColor];
- enum eBorderCode
- {
- single0, single1, single2, single3, single4, single5,
- double0, double1, double2, double3, double4, double5, double6,
- double7, double8, double9, double10,
- none, dashed, dotted
- } eCodeIdx = none;
-
+ sal_Int16 nLineStyle = NONE;
// Map to our border types, we should use of one equal line
// thickness, or one of smaller thickness. If too small we
// can make the defecit up in additional white space or
@@ -155,187 +150,69 @@ void MakeBorderLine( sal_Int32 nLineThickness, sal_Int32 nLineType,
switch(nLineType)
{
// First the single lines
- case 1: break;
+ case 1:
case 2:
case 5:
+ nLineStyle = SOLID;
+ break;
// Dotted and dashed lines
case 6:
- eCodeIdx = dotted;
- break;
+ nLineStyle = DOTTED;
+ break;
case 7:
- eCodeIdx = dashed;
- break;
+ case 22:
+ nLineStyle = DASHED;
+ break;
// and the unsupported special cases which we map to a single line
case 8:
case 9:
- case 22:
- // or if in necessary by a double line
- case 24:
- case 25:
- if( nLineThickness < 10)
- eCodeIdx = single0;// 1 Twip for us
- else if( nLineThickness < 20)
- eCodeIdx = single5;// 10 Twips for us
- else if (nLineThickness < 50)
- eCodeIdx = single1;// 20 Twips
- else if (nLineThickness < 80)
- eCodeIdx = single2;// 50
- else if (nLineThickness < 100)
- eCodeIdx = single3;// 80
- else if (nLineThickness < 150)
- eCodeIdx = single4;// 100
- // Hack: for the quite thick lines we must paint double lines,
- // because our singles lines don't come thicker than 5 points.
- else if (nLineThickness < 180)
- eCodeIdx = double2;// 150
- else
- eCodeIdx = double5;// 180
- break;
- // then the shading beams which we represent by a double line
- case 23:
- eCodeIdx = double1;
- break;
- // then the double lines, for which we have good matches
- case 3:
+ case 20:
+ nLineStyle = SOLID;
+ break;
+ // Double line
+ case 3:
case 10: //Don't have tripple so use double
- if (nLineThickness < 60)
- eCodeIdx = double0;// 22 Twips for us
- else if (nLineThickness < 135)
- eCodeIdx = double7;// some more space
- else if (nLineThickness < 180)
- eCodeIdx = double1;// 60
- else
- eCodeIdx = double2;// 150
+ case 21:
+ case 23:
+ nLineStyle = DOUBLE;
break;
case 11:
- eCodeIdx = double4;// 90 Twips for us
+ case 13: //Don't have thin thick thin, so use thick thin
+ nLineStyle = THINTHICK_SMALLGAP;
break;
case 12:
- case 13: //Don't have thin thick thin, so use thick thin
- if (nLineThickness < 87)
- eCodeIdx = double8;// 71 Twips for us
- else if (nLineThickness < 117)
- eCodeIdx = double9;// 101
- else if (nLineThickness < 166)
- eCodeIdx = double10;// 131
- else
- eCodeIdx = double5;// 180
+ nLineStyle = THICKTHIN_SMALLGAP;
break;
case 14:
- if (nLineThickness < 46)
- eCodeIdx = double0;// 22 Twips for us
- else if (nLineThickness < 76)
- eCodeIdx = double1;// 60
- else if (nLineThickness < 121)
- eCodeIdx = double4;// 90
- else if (nLineThickness < 166)
- eCodeIdx = double2;// 150
- else
- eCodeIdx = double6;// 180
+ nLineStyle = THINTHICK_MEDIUMGAP;
break;
case 15:
case 16: //Don't have thin thick thin, so use thick thin
- if (nLineThickness < 46)
- eCodeIdx = double0;// 22 Twips for us
- else if (nLineThickness < 76)
- eCodeIdx = double1;// 60
- else if (nLineThickness < 121)
- eCodeIdx = double3;// 90
- else if (nLineThickness < 166)
- eCodeIdx = double2;// 150
- else
- eCodeIdx = double5;// 180
+ nLineStyle = THICKTHIN_MEDIUMGAP;
break;
case 17:
- if (nLineThickness < 46)
- eCodeIdx = double0;// 22 Twips for us
- else if (nLineThickness < 72)
- eCodeIdx = double7;// 52
- else if (nLineThickness < 137)
- eCodeIdx = double4;// 90
- else
- eCodeIdx = double6;// 180
- break;
+ nLineStyle = THINTHICK_LARGEGAP;
+ break;
case 18:
case 19: //Don't have thin thick thin, so use thick thin
- if (nLineThickness < 46)
- eCodeIdx = double0;// 22 Twips for us
- else if (nLineThickness < 62)
- eCodeIdx = double7;// 52
- else if (nLineThickness < 87)
- eCodeIdx = double8;// 71
- else if (nLineThickness < 117)
- eCodeIdx = double9;// 101
- else if (nLineThickness < 156)
- eCodeIdx = double10;// 131
- else
- eCodeIdx = double5;// 180
+ nLineStyle = THICKTHIN_LARGEGAP;
break;
- case 20:
- if (nLineThickness < 46)
- eCodeIdx = single1; // 20 Twips for us
- else
- eCodeIdx = double1;// 60
+ // Embossed and engraved lines
+ case 24:
+ nLineStyle = EMBOSSED;
break;
- case 21:
- eCodeIdx = double1;// 60 Twips for us
+ case 25:
+ nLineStyle = ENGRAVED;
break;
case 0:
case 255:
- eCodeIdx = none;
- break;
default:
- eCodeIdx = single0;
break;
}
- struct BorderDefinition
- {
- sal_Int16 nOut;
- sal_Int16 nIn;
- sal_Int16 nDist;
- sal_Int16 eStyle;
- };
-
-
- static const BorderDefinition aLineTab[] =
- {
- /* 0*/ { LINE_WIDTH_0, 0, 0, API_LINE_SOLID },
- /* 1*/ { LINE_WIDTH_1, 0, 0, API_LINE_SOLID },
- /* 2*/ { LINE_WIDTH_2, 0, 0, API_LINE_SOLID },
- /* 3*/ { LINE_WIDTH_3, 0, 0, API_LINE_SOLID },
- /* 4*/ { LINE_WIDTH_4, 0, 0, API_LINE_SOLID },
- /* 5*/ { LINE_WIDTH_5, 0, 0, API_LINE_SOLID },
- /* 6*/ { DOUBLE_LINE0_OUT, DOUBLE_LINE0_IN, DOUBLE_LINE0_DIST, API_LINE_SOLID },
- /* 7*/ { DOUBLE_LINE1_OUT, DOUBLE_LINE1_IN, DOUBLE_LINE1_DIST, API_LINE_SOLID },
- /* 8*/ { DOUBLE_LINE2_OUT, DOUBLE_LINE2_IN, DOUBLE_LINE2_DIST, API_LINE_SOLID },
- /* 9*/ { DOUBLE_LINE3_OUT, DOUBLE_LINE3_IN, DOUBLE_LINE3_DIST, API_LINE_SOLID },
- /*10*/ { DOUBLE_LINE4_OUT, DOUBLE_LINE4_IN, DOUBLE_LINE4_DIST, API_LINE_SOLID },
- /*11*/ { DOUBLE_LINE5_OUT, DOUBLE_LINE5_IN, DOUBLE_LINE5_DIST, API_LINE_SOLID },
- /*12*/ { DOUBLE_LINE6_OUT, DOUBLE_LINE6_IN, DOUBLE_LINE6_DIST, API_LINE_SOLID },
- /*13*/ { DOUBLE_LINE7_OUT, DOUBLE_LINE7_IN, DOUBLE_LINE7_DIST, API_LINE_SOLID },
- /*14*/ { DOUBLE_LINE8_OUT, DOUBLE_LINE8_IN, DOUBLE_LINE8_DIST, API_LINE_SOLID },
- /*15*/ { DOUBLE_LINE9_OUT, DOUBLE_LINE9_IN, DOUBLE_LINE9_DIST, API_LINE_SOLID },
- /*16*/ { DOUBLE_LINE10_OUT,DOUBLE_LINE10_IN,DOUBLE_LINE10_DIST, API_LINE_SOLID},
- /*17*/ { 0, 0, 0, API_LINE_SOLID },
- /*18*/ { LINE_WIDTH_5, 0, 0, API_LINE_DASHED },
- /*19*/ { LINE_WIDTH_5, 0, 0, API_LINE_DOTTED }
- };
+ rToFill.LineStyle = nLineStyle;
+ rToFill.LineWidth = sal_uInt32( nLineThickness );
rToFill.Color = nLineColor;
- if( nLineType == 1)
- {
- rToFill.InnerLineWidth = 0;
- rToFill.OuterLineWidth = sal_Int16(nLineThickness);
- rToFill.LineDistance = 0;
- rToFill.LineStyle = API_LINE_SOLID;
- }
- else
- {
- rToFill.InnerLineWidth = aLineTab[eCodeIdx].nIn;
- rToFill.OuterLineWidth = aLineTab[eCodeIdx].nOut;
- rToFill.LineDistance = aLineTab[eCodeIdx].nDist;
- rToFill.LineStyle = aLineTab[eCodeIdx].eStyle;
- }
}
void lcl_SwapQuotesInField(::rtl::OUString &rFmt)