Commit 0e37afed authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

правка багов по результатам тестирования

DocFormatReader - картинки маркированных списков
parent 0e5a581f
...@@ -77,22 +77,73 @@ namespace ASCDocFormatUtils ...@@ -77,22 +77,73 @@ namespace ASCDocFormatUtils
class FormatUtils class FormatUtils
{ {
public: public:
static inline std::wstring XmlEncode(std::wstring data) static inline bool IsUnicodeSymbol( wchar_t symbol )
{
bool result = false;
if ( ( 0x0009 == symbol ) || ( 0x000A == symbol ) || ( 0x000D == symbol ) ||
( ( 0x0020 <= symbol ) && ( 0xD7FF >= symbol ) ) || ( ( 0xE000 <= symbol ) && ( symbol <= 0xFFFD ) ) ||
( ( 0x10000 <= symbol ) && symbol ) )
{
result = true;
}
return result;
}
static inline std::wstring XmlEncode(std::wstring data, bool bDeleteNoUnicode = false)
{ {
std::wstring buffer; std::wstring buffer;
buffer.reserve(data.size()); buffer.reserve(data.size());
for(size_t pos = 0; pos != data.size(); ++pos)
if(bDeleteNoUnicode)
{ {
switch(data[pos]) for(size_t pos = 0; pos != data.size(); ++pos)
{ {
case '&': buffer.append(_T("&amp;")); break; switch(data[pos])
case '\"': buffer.append(_T("&quot;")); break; {
case '\'': buffer.append(_T("&apos;")); break; case '&': buffer.append(_T("&amp;")); break;
case '<': buffer.append(_T("&lt;")); break; case '\"': buffer.append(_T("&quot;")); break;
case '>': buffer.append(_T("&gt;")); break; case '\'': buffer.append(_T("&apos;")); break;
default: buffer.append(&data[pos], 1); break; case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
default:
{
if ( false == IsUnicodeSymbol( data[pos] ) )
{
wchar_t symbol1 = data[pos];
if(0xD800 <= symbol1 && symbol1 <= 0xDFFF && pos + 1 < data.size())
{
pos++;
wchar_t symbol2 = data[pos];
if (symbol1 < 0xDC00 && symbol2 >= 0xDC00 && symbol2 <= 0xDFFF)
{
buffer.append(&data[pos-1], 2);
}
}
}
else
buffer.append(&data[pos], 1);
}break;
}
}
}
else
{
for(size_t pos = 0; pos != data.size(); ++pos)
{
switch(data[pos])
{
case '&': buffer.append(_T("&amp;")); break;
case '\"': buffer.append(_T("&quot;")); break;
case '\'': buffer.append(_T("&apos;")); break;
case '<': buffer.append(_T("&lt;")); break;
case '>': buffer.append(_T("&gt;")); break;
default: buffer.append(&data[pos], 1); break;
}
} }
} }
return buffer; return buffer;
} }
......
...@@ -35,14 +35,14 @@ namespace DocFileFormat ...@@ -35,14 +35,14 @@ namespace DocFileFormat
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter ); FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
m_pXmlWriter->WriteNodeBegin( _T( "w:font" ), TRUE ); m_pXmlWriter->WriteNodeBegin( _T( "w:font" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:name" ), FormatUtils::XmlEncode(font->xszFtn).c_str() ); m_pXmlWriter->WriteAttribute( _T( "w:name" ), FormatUtils::XmlEncode(font->xszFtn, true).c_str());
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE ); m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
//alternative name //alternative name
if ( ( font->xszAlt != wstring( _T( "" ) ) ) && ( font->xszAlt.length() > 0 ) ) if ( ( font->xszAlt != wstring( _T( "" ) ) ) && ( font->xszAlt.length() > 0 ) )
{ {
m_pXmlWriter->WriteNodeBegin( _T( "w:altName" ), TRUE ); m_pXmlWriter->WriteNodeBegin( _T( "w:altName" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt).c_str() ); m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(font->xszAlt, true).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE ); m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "w:altName" ) ); m_pXmlWriter->WriteNodeEnd( _T( "w:altName" ) );
} }
......
...@@ -187,9 +187,16 @@ namespace DocFileFormat ...@@ -187,9 +187,16 @@ namespace DocFileFormat
if (sz_obj > 4) if (sz_obj > 4)
{ {
UserType = reader.ReadLengthPrefixedAnsiString(); //todooo сделать по нормальному CompObjHeader - psc3a.doc
ClipboardFormat = reader.ReadLengthPrefixedAnsiString(); //UserType = reader.ReadLengthPrefixedAnsiString();
Program = reader.ReadLengthPrefixedAnsiString();
//sz_obj = reader.GetSize() - reader.GetPosition();
//if (sz_obj > 4)
// ClipboardFormat = reader.ReadLengthPrefixedAnsiString();
//sz_obj = reader.GetSize() - reader.GetPosition();
//if (sz_obj > 4)
// Program = reader.ReadLengthPrefixedAnsiString();
} }
delete pCompStream; delete pCompStream;
} }
......
...@@ -46,7 +46,7 @@ namespace DocFileFormat ...@@ -46,7 +46,7 @@ namespace DocFileFormat
if (lcb > 10000000) if (lcb > 10000000)
return; return;
if (lcb > sz) if (lcb > sz && sz != 2) //bullet picture
{ {
unsigned char* bytes = reader.ReadBytes(sz - fc - 4, false); unsigned char* bytes = reader.ReadBytes(sz - fc - 4, false);
if ( bytes ) if ( bytes )
...@@ -56,7 +56,7 @@ namespace DocFileFormat ...@@ -56,7 +56,7 @@ namespace DocFileFormat
return; return;
} }
if (lcb > 0) if (lcb >= 10)
{ {
unsigned short cbHeader = reader.ReadUInt16(); unsigned short cbHeader = reader.ReadUInt16();
......
...@@ -69,7 +69,7 @@ namespace DocFileFormat ...@@ -69,7 +69,7 @@ namespace DocFileFormat
// <w:name val="" /> // <w:name val="" />
m_pXmlWriter->WriteNodeBegin( _T( "w:name" ), TRUE ); m_pXmlWriter->WriteNodeBegin( _T( "w:name" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(getStyleName( *iter )).c_str() ); m_pXmlWriter->WriteAttribute( _T( "w:val" ), FormatUtils::XmlEncode(getStyleName( *iter ), true ).c_str());
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE ); m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// <w:basedOn val="" /> // <w:basedOn val="" />
......
...@@ -140,6 +140,10 @@ namespace DocFileFormat ...@@ -140,6 +140,10 @@ namespace DocFileFormat
{ {
m_pXmlWriter->WriteAttribute( _T( "o:ole" ), _T( "" ) ); m_pXmlWriter->WriteAttribute( _T( "o:ole" ), _T( "" ) );
} }
else if (m_isBulletPicture)
{
m_pXmlWriter->WriteAttribute( _T( "o:bullet" ), true );
}
std::list<OptionEntry>::iterator end = options.end(); std::list<OptionEntry>::iterator end = options.end();
for (std::list<OptionEntry>::iterator iter = options.begin(); iter != end; ++iter) for (std::list<OptionEntry>::iterator iter = options.begin(); iter != end; ++iter)
......
...@@ -41,6 +41,8 @@ namespace DocFileFormat ...@@ -41,6 +41,8 @@ namespace DocFileFormat
// Path // Path
if (!pShape->Path.empty()) if (!pShape->Path.empty())
m_pXmlWriter->WriteAttribute( _T("path"), pShape->Path.c_str() ); m_pXmlWriter->WriteAttribute( _T("path"), pShape->Path.c_str() );
else if (_isBulletPicture)
m_pXmlWriter->WriteAttribute( _T("path"), _T("m@4@5l@4@11@9@11@9@5xe"));
//Default fill / stroke //Default fill / stroke
...@@ -87,6 +89,16 @@ namespace DocFileFormat ...@@ -87,6 +89,16 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "v:formulas" ) ); m_pXmlWriter->WriteNodeEnd( _T( "v:formulas" ) );
} }
else if (_isBulletPicture)
{
m_pXmlWriter->WriteString(_T("<v:formulas><v:f eqn=\"if lineDrawn pixelLineWidth 0\"/>\
<v:f eqn=\"sum @0 1 0\"/><v:f eqn=\"sum 0 0 @1\"/>\
<v:f eqn=\"prod @2 1 2\"/><v:f eqn=\"prod @3 21600 pixelWidth\"/>\
<v:f eqn=\"prod @3 21600 pixelHeight\"/><v:f eqn=\"sum @0 0 1\"/>\
<v:f eqn=\"prod @6 1 2\"/><v:f eqn=\"prod @7 21600 pixelWidth\"/>\
<v:f eqn=\"sum @8 21600 0\"/><v:f eqn=\"prod @7 21600 pixelHeight\"/>\
<v:f eqn=\"sum @10 21600 0\"/></v:formulas>"));
}
// Path // Path
m_pXmlWriter->WriteNodeBegin( _T( "v:path" ), true ); m_pXmlWriter->WriteNodeBegin( _T( "v:path" ), true );
......
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