Commit ccdec36c authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix bugs

parent 8db0107a
......@@ -220,6 +220,34 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"concave-star6" ,L"" ,0 ,0 ,0 },
{L"signet" ,L"" ,0 ,0 ,0 },
{L"doorplate" ,L"" ,0 ,0 ,0 },
{L"" ,L"round1Rect" ,0 ,0 ,0 },
{L"" ,L"round2DiagRect" ,0 ,0 ,0 },
{L"" ,L"mathPlus" ,0 ,0 ,0 },
{L"" ,L"mathMinus" ,0 ,0 ,0 },
{L"" ,L"mathMultiply" ,0 ,0 ,0 },
{L"" ,L"mathDivide" ,0 ,0 ,0 },
{L"" ,L"mathEqual" ,0 ,0 ,0 },
{L"" ,L"mathNotEqual" ,0 ,0 ,0 },
{L"" ,L"plaque" ,0 ,0 ,0 },
{L"" ,L"decagon" ,0 ,0 ,0 },
{L"" ,L"dodecagon" ,0 ,0 ,0 },
{L"" ,L"star7" ,0 ,0 ,0 },
{L"" ,L"star10" ,0 ,0 ,0 },
{L"" ,L"star16" ,0 ,0 ,0 },
{L"" ,L"star32" ,0 ,0 ,0 },
{L"" ,L"diagStripe" ,0 ,0 ,0 },
{L"" ,L"teardrop" ,0 ,0 ,0 },
{L"" ,L"arc" ,0 ,0 ,0 },
{L"" ,L"chord" ,0 ,0 ,0 },
{L"" ,L"heptagon" ,0 ,0 ,0 },
{L"" ,L"wave" ,0 ,0 ,0 },
{L"" ,L"doubleWave" ,0 ,0 ,0 },
{L"" ,L"corner" ,0 ,0 ,0 },
{L"" ,L"accentBorderCallout3",0 ,0 ,0 },
{L"" ,L"accentBorderCallout2",0 ,0 ,0 },
{L"" ,L"accentBorderCallout1",0 ,0 ,0 },
{L"" ,L"halfFrame" ,0 ,0 ,0 }
};
static const _shape_converter _OO_OOX_wordart[]=
......@@ -277,6 +305,6 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"mso-spt166" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
{L"mso-spt174" ,L"textCanUp" ,0 ,0 ,0 },
{L"mso-spt175" ,L"textCanDown" ,0 ,0 ,0 },
{L"mso-spt188" ,L"textDoubleWave1" ,0 ,0 ,0 }
{L"mso-spt188" ,L"textDoubleWave1" ,0 ,0 ,0 },
};
\ No newline at end of file
......@@ -262,9 +262,18 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
{
std::vector<svg_path::_polyline> o_Polyline;
bool res = svg_path::parseSvgD(o_Polyline, draw_enhanced_geometry_attlist_.draw_enhanced_path_.get(), true);
bool res = false;
if (o_Polyline.size()>0)
try
{
res = svg_path::parseSvgD(o_Polyline, draw_enhanced_geometry_attlist_.draw_enhanced_path_.get(), true);
}
catch(...)
{
res = false;
}
if (o_Polyline.size() > 1 && res )
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
......@@ -273,17 +282,31 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
int pos = draw_enhanced_geometry_attlist_.drawooo_sub_view_size_->find(L" ");
if (pos >= 0)
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
int w = boost::lexical_cast<int>(draw_enhanced_geometry_attlist_.drawooo_sub_view_size_->substr(0, pos));
int h = boost::lexical_cast<int>(draw_enhanced_geometry_attlist_.drawooo_sub_view_size_->substr(pos + 1));
int w = boost::lexical_cast<int>(splitted[0]);
int h = boost::lexical_cast<int>(splitted[1]);
shape->additional_.push_back(odf_reader::_property(L"custom_path_w", w));
shape->additional_.push_back(odf_reader::_property(L"custom_path_h", h));
}
else if (splitted.size() == 4)
{///???? rect ???
int l = boost::lexical_cast<int>(splitted[0]);
int t = boost::lexical_cast<int>(splitted[1]);
int r = boost::lexical_cast<int>(splitted[2]);
int b = boost::lexical_cast<int>(splitted[3]);
}
}
}
else if (!draw_type_oox_index_)
{
draw_type_oox_index_ = 0;
}
}
else if (draw_enhanced_geometry_attlist_.draw_modifiers_)
{
......
......@@ -202,10 +202,12 @@ namespace svg_path
while(nPos < nLen)
{
bool bRelative(false);
bool bMoveTo(false);
bool bRelative (false);
bool bMoveTo (false);
const wchar_t aCurrChar(rSvgDStatement[nPos]);
aCurrPoly.command.clear();
switch(aCurrChar)
{
case 'z' :
......@@ -230,7 +232,6 @@ namespace svg_path
case 'M' :
{
bMoveTo = true;
// FALLTHROUGH intended
}
case 'l' :
case 'L' :
......@@ -239,28 +240,26 @@ namespace svg_path
{
bRelative = true;
}
aCurrPoly.command=L"a:lnTo";
if(bMoveTo)
// new polygon start, finish old one
if(aCurrPoly.points.size() > 0)
{
aCurrPoly.command=L"a:moveTo";
// new polygon start, finish old one
if(aCurrPoly.points.size()>0)
// add current polygon
if(bIsClosed)
{
// add current polygon
if(bIsClosed)
{
//closeWithGeometryChange(aCurrPoly);
}
Polyline.push_back(aCurrPoly);
// reset import values
bIsClosed = false;
aCurrPoly.points.clear();
//closeWithGeometryChange(aCurrPoly);
}
Polyline.push_back(aCurrPoly);
// reset import values
bIsClosed = false;
if(bMoveTo) aCurrPoly.command = L"a:moveTo";
else aCurrPoly.command = L"a:lnTo";
aCurrPoly.points.clear();
}
nPos++;
skipSpaces(nPos, rSvgDStatement, nLen);
aCurrPoly.command.clear();
while(nPos < nLen && isOnNumberChar(rSvgDStatement, nPos))
{
......@@ -280,19 +279,20 @@ namespace svg_path
nLastY = nY;
// add point
aCurrPoly.points.push_back(_point(nX, nY));
if(bMoveTo) aCurrPoly.command = L"a:moveTo";
else aCurrPoly.command = L"a:lnTo";
aCurrPoly.points.push_back(_point(nX, nY));
Polyline.push_back(aCurrPoly);
aCurrPoly.points.clear();
}
aCurrPoly.points.clear();
}
}break;
case 'h' :
{
bRelative = true;
// FALLTHROUGH intended
}
case 'H' ://горизонт линия
{
aCurrPoly.command=L"a:lnTo";
nPos++;
skipSpaces(nPos, rSvgDStatement, nLen);
......@@ -311,6 +311,7 @@ namespace svg_path
nLastX = nX;
// add point
aCurrPoly.command = L"a:lnTo";
aCurrPoly.points.push_back(_point(nX, nY));
Polyline.push_back(aCurrPoly);
aCurrPoly.points.clear();
......@@ -325,7 +326,6 @@ namespace svg_path
}
case 'V' ://вертикальная линия
{
aCurrPoly.command =L"a:lnTo";
nPos++;
skipSpaces(nPos, rSvgDStatement, nLen);
......@@ -344,6 +344,7 @@ namespace svg_path
nLastY = nY;
// add point
aCurrPoly.command = L"a:lnTo";
aCurrPoly.points.push_back(_point(nX, nY));
Polyline.push_back(aCurrPoly);
aCurrPoly.points.clear();
......@@ -358,7 +359,6 @@ namespace svg_path
}
case 'S' :
{
aCurrPoly.command=L"a:cubicBezTo";
nPos++;
skipSpaces(nPos, rSvgDStatement, nLen);
......@@ -370,8 +370,8 @@ namespace svg_path
if(!importDoubleAndSpaces(nX2, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY2, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false;
if(bRelative)
{
......@@ -385,11 +385,12 @@ namespace svg_path
nX1 =((2.0 * nLastX) - nLastControlX);
nY1 =((2.0 * nLastY) - nLastControlY);
aCurrPoly.command = L"a:cubicBezTo";
// append curved edge
aCurrPoly.points.push_back(_point(nX1, nY1));
aCurrPoly.points.push_back(_point(nX2, nY2));
aCurrPoly.points.push_back(_point(nX, nY));
Polyline.push_back(aCurrPoly);
aCurrPoly.points.clear();
......@@ -406,11 +407,9 @@ namespace svg_path
case 'c' :
{
bRelative = true;
// FALLTHROUGH intended
}
case 'C' :
{
aCurrPoly.command = L"a:cubicBezTo";
nPos++;
skipSpaces(nPos, rSvgDStatement, nLen);
......@@ -420,12 +419,12 @@ namespace svg_path
double nX1, nY1;
double nX2, nY2;
if(!importDoubleAndSpaces(nX1, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY1, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX2, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY2, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX1, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY1, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX2, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY2, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nX, nPos, rSvgDStatement, nLen)) return false;
if(!importDoubleAndSpaces(nY, nPos, rSvgDStatement, nLen)) return false;
if(bRelative)
{
......@@ -437,7 +436,8 @@ namespace svg_path
nY += nLastY;
}
// append curved edge
aCurrPoly.command = L"a:cubicBezTo";
// append curved edge
aCurrPoly.points.push_back(_point(nX1, nY1));
aCurrPoly.points.push_back(_point(nX2, nY2));
aCurrPoly.points.push_back(_point(nX, nY));
......@@ -459,7 +459,6 @@ namespace svg_path
//case 'q' :
//{
// bRelative = true;
// // FALLTHROUGH intended
//}
//case 'Q' :
//{
......@@ -510,7 +509,6 @@ namespace svg_path
//case 't' :
//{
// bRelative = true;
// // FALLTHROUGH intended
//}
//case 'T' :
//{
......@@ -584,7 +582,6 @@ namespace svg_path
//case 'a' :
//{
// bRelative = true;
// // FALLTHROUGH intended
//}
//case 'A' :
//{
......@@ -754,7 +751,7 @@ namespace svg_path
}
}
if(aCurrPoly.points.size() > 0 || bIsClosed)
if ((aCurrPoly.points.size() > 0 || bIsClosed) && !aCurrPoly.command.empty())
{
// end-process last poly
if(bIsClosed)
......@@ -795,7 +792,7 @@ namespace svg_path
aCurrPoly.points.clear();
aCurrPoly.command = L"a:lnTo";
}
if (Polyline.size()>2 && closed)
if (Polyline.size() > 2 && closed)
{
//замкнем
Polyline.push_back(Polyline[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment