Commit 176cc65d authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

исправление ошибки с embedded объктами Excel - msfo2009.doc

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65062 954022d7-b5bf-4e40-9824-e11837661b57
parent f34b4a65
...@@ -471,9 +471,11 @@ namespace DocFileFormat ...@@ -471,9 +471,11 @@ namespace DocFileFormat
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark ); int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
std::wstring f( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) ); std::wstring f( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
std::wstring embed( _T( " EMBED" ) ); std::wstring embed ( _T( " EMBED" ) );
std::wstring link( _T( " LINK" ) ); std::wstring link ( _T( " LINK" ) );
std::wstring form( _T( " FORM" ) ); std::wstring form ( _T( " FORM" ) );
std::wstring excel ( _T( " Excel" ) );
std::wstring mergeformat ( _T( " MERGEFORMAT" ) );
if ( search( f.begin(), f.end(), form.begin(), form.end() ) != f.end() ) if ( search( f.begin(), f.end(), form.begin(), form.end() ) != f.end() )
{ {
...@@ -498,7 +500,58 @@ namespace DocFileFormat ...@@ -498,7 +500,58 @@ namespace DocFileFormat
this->_fldCharCounter++; this->_fldCharCounter++;
} }
else if ((search(f.begin(), f.end(), mergeformat.begin(), mergeformat.end()) != f.end()) ||
(search(f.begin(), f.end(), excel.begin(), excel.end()) != f.end()))
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->m_PieceTable->FileCharacterPositions->operator []( cpPic );
list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
CharacterPropertyExceptions* chpxPic = chpxs->front();
//PictureDescriptor pic(chpxPic, m_document->DataStream, cpFieldEnd - cpPic );
RevisionData oData = RevisionData(chpxPic);
/// <w:rPr>
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &oData, _lastValidPapx, false);
if(rPr)
{
chpxPic->Convert(rPr);
RELEASEOBJECT(rPr);
}
m_pXmlWriter->WriteNodeBegin (_T( "w:object" ), TRUE);
//append the origin attributes
m_pXmlWriter->WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( 0 ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( 0 ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
VMLPictureMapping oVmlMapper (m_context, m_pXmlWriter, true, _caller);
//pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
if ( cpFieldSep < cpFieldEnd )
{
int fcFieldSep = m_document->m_PieceTable->FileCharacterPositions->operator []( cpFieldSep );
list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document->GetStorage() );
OleObjectMapping oleObjectMapping( m_pXmlWriter, m_context, NULL, _caller, oVmlMapper.GetShapeId() );
ole.Convert( &oleObjectMapping );
RELEASEOBJECT( chpxs );
}
m_pXmlWriter->WriteNodeEnd( _T( "w:object" ) );
}
this->_skipRuns = 5;
}
else if ((search(f.begin(), f.end(), embed.begin(), embed.end()) != f.end()) || (search( f.begin(), f.end(), link.begin(), link.end() ) != f.end())) else if ((search(f.begin(), f.end(), embed.begin(), embed.end()) != f.end()) || (search( f.begin(), f.end(), link.begin(), link.end() ) != f.end()))
{ {
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture); int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator); int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
...@@ -508,7 +561,7 @@ namespace DocFileFormat ...@@ -508,7 +561,7 @@ namespace DocFileFormat
int fcPic = m_document->m_PieceTable->FileCharacterPositions->operator []( cpPic ); int fcPic = m_document->m_PieceTable->FileCharacterPositions->operator []( cpPic );
list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1); list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
CharacterPropertyExceptions* chpxPic = chpxs->front(); CharacterPropertyExceptions* chpxPic = chpxs->front();
PictureDescriptor pic(chpxPic, m_document->DataStream); PictureDescriptor pic(chpxPic, m_document->DataStream, cpFieldEnd - cpPic );
RevisionData oData = RevisionData(chpxPic); RevisionData oData = RevisionData(chpxPic);
...@@ -622,7 +675,7 @@ namespace DocFileFormat ...@@ -622,7 +675,7 @@ namespace DocFileFormat
} }
else if ((TextMark::Picture == c) && fSpec) else if ((TextMark::Picture == c) && fSpec)
{ {
PictureDescriptor oPicture (chpx, m_document->DataStream); PictureDescriptor oPicture (chpx, m_document->DataStream, 0x7fffffff);
if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)) if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer))
{ {
......
...@@ -446,7 +446,7 @@ namespace DocFileFormat ...@@ -446,7 +446,7 @@ namespace DocFileFormat
if ((chpxs != NULL) && (!chpxs->empty())) if ((chpxs != NULL) && (!chpxs->empty()))
{ {
PictureDescriptor pict(chpxs->front(), m_document->DataStream); PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc);
if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL)) if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL))
{ {
......
...@@ -37,6 +37,8 @@ namespace DocFileFormat ...@@ -37,6 +37,8 @@ namespace DocFileFormat
bool isContainer = ( version == 0xF ); bool isContainer = ( version == 0xF );
if (typeCode == 0x01f6) return NULL; //орг диаграмм
Record* pRecord = NewRecord (typeCode); Record* pRecord = NewRecord (typeCode);
if (pRecord) if (pRecord)
{ {
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
namespace DocFileFormat namespace DocFileFormat
{ {
/// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset /// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream) : dxaGoal(0), dyaGoal(0), mx(0), my(0), Type(jpg), Name( _T( "" ) ), mfp(), dxaCropLeft(0), dyaCropTop(0), PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size) :
dxaGoal(0), dyaGoal(0), mx(0), my(0), Type(jpg), Name( _T( "" ) ), mfp(), dxaCropLeft(0), dyaCropTop(0),
dxaCropRight(0), dyaCropBottom(0), brcTop(NULL), brcLeft(NULL), brcBottom(NULL), brcRight(NULL), dxaOrigin(0), dyaOrigin(0), dxaCropRight(0), dyaCropBottom(0), brcTop(NULL), brcLeft(NULL), brcBottom(NULL), brcRight(NULL), dxaOrigin(0), dyaOrigin(0),
cProps(0), shapeContainer(NULL), blipStoreEntry(NULL) cProps(0), shapeContainer(NULL), blipStoreEntry(NULL)
{ {
...@@ -13,7 +14,7 @@ namespace DocFileFormat ...@@ -13,7 +14,7 @@ namespace DocFileFormat
if ( fc >= 0 ) if ( fc >= 0 )
{ {
parse( stream, fc ); parse( stream, fc, size );
} }
} }
...@@ -31,7 +32,7 @@ namespace DocFileFormat ...@@ -31,7 +32,7 @@ namespace DocFileFormat
RELEASEOBJECT(shapeContainer); RELEASEOBJECT(shapeContainer);
RELEASEOBJECT(blipStoreEntry); RELEASEOBJECT(blipStoreEntry);
} }
void PictureDescriptor::parse(POLE::Stream* stream, int fc) void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz)
{ {
Clear(); Clear();
...@@ -39,6 +40,16 @@ namespace DocFileFormat ...@@ -39,6 +40,16 @@ namespace DocFileFormat
int lcb = reader.ReadInt32(); int lcb = reader.ReadInt32();
if (lcb > sz)
{
unsigned char* bytes = reader.ReadBytes(sz - fc - 4, false);
if ( bytes )
{
RELEASEARRAYOBJECTS( bytes );
}
return;
}
if (lcb > 0) if (lcb > 0)
{ {
unsigned short cbHeader = reader.ReadUInt16(); unsigned short cbHeader = reader.ReadUInt16();
...@@ -110,11 +121,11 @@ namespace DocFileFormat ...@@ -110,11 +121,11 @@ namespace DocFileFormat
long pos = reader.GetPosition(); long pos = reader.GetPosition();
if( pos < ( fc + lcb ) ) if( pos < ( fc + lcb ))
{ {
Record* rec = RecordFactory::ReadRecord( &reader, 0 ); Record* rec = RecordFactory::ReadRecord( &reader, 0 );
if( typeid(*rec) == typeid(BlipStoreEntry) ) if ((rec) && ( typeid(*rec) == typeid(BlipStoreEntry) ))
{ {
blipStoreEntry = dynamic_cast<BlipStoreEntry*>( rec ); blipStoreEntry = dynamic_cast<BlipStoreEntry*>( rec );
} }
......
...@@ -50,12 +50,12 @@ namespace DocFileFormat ...@@ -50,12 +50,12 @@ namespace DocFileFormat
public: public:
/// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset /// Parses the CHPX for a fcPic an loads the PictureDescriptor at this offset
PictureDescriptor( CharacterPropertyExceptions* chpx, POLE::Stream* stream ); PictureDescriptor( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size );
virtual ~PictureDescriptor(); virtual ~PictureDescriptor();
private: private:
void parse( POLE::Stream* stream, int fc ); void parse( POLE::Stream* stream, int fc, int sz );
/// Returns the fcPic into the "data" stream, where the PIC begins. /// Returns the fcPic into the "data" stream, where the PIC begins.
/// Returns -1 if the CHPX has no fcPic. /// Returns -1 if the CHPX has no fcPic.
static int GetFcPic( const CharacterPropertyExceptions* chpx ); static int GetFcPic( const CharacterPropertyExceptions* chpx );
......
...@@ -54,7 +54,7 @@ namespace DocFileFormat ...@@ -54,7 +54,7 @@ namespace DocFileFormat
{ {
PictureDescriptor* pict = static_cast<PictureDescriptor*>(visited); PictureDescriptor* pict = static_cast<PictureDescriptor*>(visited);
if (pict->shapeContainer || pict->blipStoreEntry) if ((pict->shapeContainer || pict->blipStoreEntry) && pict->shapeContainer->Children.size() > 0)
{ {
Shape* shape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin())); Shape* shape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin()));
list<OptionEntry> options = pict->shapeContainer->ExtractOptions(); list<OptionEntry> options = pict->shapeContainer->ExtractOptions();
......
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