Commit 467dadc5 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormat - fix tables world95

parent 1b3a36f3
...@@ -786,7 +786,16 @@ namespace DocFileFormat ...@@ -786,7 +786,16 @@ namespace DocFileFormat
{ {
PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion); PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer)) if (oPicture.embeddedData && oPicture.embeddedDataSize > 0)
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLPictureMapping oVmlMapper(m_context, m_pXmlWriter, false, _caller);
oPicture.Convert (&oVmlMapper);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
else if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer))
{ {
m_pXmlWriter->WriteNodeBegin (_T("w:pict")); m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
...@@ -1112,7 +1121,7 @@ namespace DocFileFormat ...@@ -1112,7 +1121,7 @@ namespace DocFileFormat
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{ {
//find the tDef SPRM //find the tDef SPRM
if ( iter->OpCode == sprmTDefTable ) if ( iter->OpCode == sprmTDefTable || iter->OpCode == sprmOldTDefTable)
{ {
unsigned char itcMac = iter->Arguments[0]; unsigned char itcMac = iter->Arguments[0];
......
...@@ -32,14 +32,22 @@ ...@@ -32,14 +32,22 @@
#include "PictureDescriptor.h" #include "PictureDescriptor.h"
#ifndef MM_ISOTROPIC
#define MM_ISOTROPIC 7
#endif
#ifndef MM_ANISOTROPIC
#define MM_ANISOTROPIC 8
#endif
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, int size, bool oldVersion) PictureDescriptor::PictureDescriptor(CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion)
: :
dxaGoal(0), dyaGoal(0), mx(0), my(0), Type(jpg), Name( _T( "" ) ), mfp(), dxaCropLeft(0), dyaCropTop(0), dxaGoal(0), dyaGoal(0), mx(0), my(0), Type(jpg), 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), embeddedData(NULL), embeddedDataSize(0)
{ {
//Get start and length of the PICT //Get start and length of the PICT
int fc = GetFcPic( chpx ); int fc = GetFcPic( chpx );
...@@ -64,6 +72,8 @@ namespace DocFileFormat ...@@ -64,6 +72,8 @@ namespace DocFileFormat
RELEASEOBJECT(shapeContainer); RELEASEOBJECT(shapeContainer);
RELEASEOBJECT(blipStoreEntry); RELEASEOBJECT(blipStoreEntry);
RELEASEARRAYOBJECTS(embeddedData);
} }
void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, bool oldVersion) void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, bool oldVersion)
{ {
...@@ -90,14 +100,25 @@ namespace DocFileFormat ...@@ -90,14 +100,25 @@ namespace DocFileFormat
if (lcb >= 10) if (lcb >= 10)
{ {
int cbHeader = reader.ReadUInt16(); int cbHeader = reader.ReadUInt16();
mfp.mm = reader.ReadInt16(); mfp.mm = reader.ReadInt16();
mfp.xExt = reader.ReadInt16(); mfp.xExt = reader.ReadInt16();
mfp.yExt = reader.ReadInt16(); mfp.yExt = reader.ReadInt16();
mfp.hMf = reader.ReadInt16(); mfp.hMf = reader.ReadInt16();
if (mfp.mm >= 98 || oldVersion) if (mfp.mm == MM_ISOTROPIC || mfp.mm == MM_ANISOTROPIC)
{
Type = wmf;
mx = my = 200;
dxaGoal = mfp.xExt;
dyaGoal = mfp.yExt;
embeddedDataSize = reader.GetSize() - reader.GetPosition(); //lcb ?
embeddedData = reader.ReadBytes( embeddedDataSize, true );
}
else if (mfp.mm >= 98)
{ {
unsigned char* bytes = reader.ReadBytes(14, true); unsigned char* bytes = reader.ReadBytes(14, true);
rcWinMf = std::vector<unsigned char>(bytes, (bytes + 14)); rcWinMf = std::vector<unsigned char>(bytes, (bytes + 14));
...@@ -118,7 +139,6 @@ namespace DocFileFormat ...@@ -118,7 +139,6 @@ namespace DocFileFormat
short brcl = reader.ReadInt16(); short brcl = reader.ReadInt16();
// borders // borders
int bytesCount = 4; int bytesCount = 4;
bytes = reader.ReadBytes( bytesCount, true ); bytes = reader.ReadBytes( bytesCount, true );
...@@ -154,47 +174,21 @@ namespace DocFileFormat ...@@ -154,47 +174,21 @@ namespace DocFileFormat
} }
} }
if (oldVersion) shapeContainer = dynamic_cast<ShapeContainer*>(RecordFactory::ReadRecord(&reader, 0));
{
////blipStoreEntry = new BlipStoreEntry();
//blipStoreEntry = new BlipStoreEntry(&reader,lcb, Global::msoblipDIB,0,0);
//long pos = reader.GetPosition();
//unsigned char* pPicData = reader.ReadBytes(lcb - pos, true);
//int pos1 = 0;
//BITMAPINFOHEADER *bm = (BITMAPINFOHEADER *)(pPicData + pos1);
//NSFile::CFileBinary f;
//
//f.CreateFile(L"d:\\test.jpg");
//f.WriteFile(pPicData + pos1, lcb - pos - pos1);
//f.CloseFile();
//RELEASEARRAYOBJECTS(pPicData); long pos = reader.GetPosition();
} if( pos < ( fc + lcb ))
else
{ {
//Parse the OfficeDrawing Stuff Record* rec = RecordFactory::ReadRecord( &reader, 0 );
shapeContainer = dynamic_cast<ShapeContainer*>(RecordFactory::ReadRecord(&reader, 0));
long pos = reader.GetPosition();
if( pos < ( fc + lcb )) if ((rec) && ( typeid(*rec) == typeid(BlipStoreEntry) ))
{
blipStoreEntry = dynamic_cast<BlipStoreEntry*>( rec );
}
else
{ {
Record* rec = RecordFactory::ReadRecord( &reader, 0 ); RELEASEOBJECT(rec);
if ((rec) && ( typeid(*rec) == typeid(BlipStoreEntry) ))
{
blipStoreEntry = dynamic_cast<BlipStoreEntry*>( rec );
}
else
{
RELEASEOBJECT(rec);
}
} }
} }
} }
......
...@@ -49,26 +49,26 @@ namespace DocFileFormat ...@@ -49,26 +49,26 @@ namespace DocFileFormat
struct MetafilePicture struct MetafilePicture
{ {
/// Specifies the mapping mode in which the picture is drawn. // Specifies the mapping mode in which the picture is drawn.
short mm; short mm;
/// Specifies the size of the metafile picture for all modes except the MM_ISOTROPIC and MM_ANISOTROPIC modes. // Specifies the size of the metafile picture for all modes except the MM_ISOTROPIC and MM_ANISOTROPIC modes.
/// (For more information about these modes, see the yExt member.) // (For more information about these modes, see the yExt member.)
/// The x-extent specifies the width of the rectangle within which the picture is drawn. // The x-extent specifies the width of the rectangle within which the picture is drawn.
/// The coordinates are in units that correspond to the mapping mode. // The coordinates are in units that correspond to the mapping mode.
short xExt; short xExt;
/// Specifies the size of the metafile picture for all modes except the MM_ISOTROPIC and MM_ANISOTROPIC modes. // Specifies the size of the metafile picture for all modes except the MM_ISOTROPIC and MM_ANISOTROPIC modes.
/// The y-extent specifies the height of the rectangle within which the picture is drawn. // The y-extent specifies the height of the rectangle within which the picture is drawn.
/// The coordinates are in units that correspond to the mapping mode. // The coordinates are in units that correspond to the mapping mode.
/// For MM_ISOTROPIC and MM_ANISOTROPIC modes, which can be scaled, the xExt and yExt members // For MM_ISOTROPIC and MM_ANISOTROPIC modes, which can be scaled, the xExt and yExt members
/// contain an optional suggested size in MM_HIMETRIC units. // contain an optional suggested size in MM_HIMETRIC units.
/// For MM_ANISOTROPIC pictures, xExt and yExt can be zero when no suggested size is supplied. // For MM_ANISOTROPIC pictures, xExt and yExt can be zero when no suggested size is supplied.
/// For MM_ISOTROPIC pictures, an aspect ratio must be supplied even when no suggested size is given. // For MM_ISOTROPIC pictures, an aspect ratio must be supplied even when no suggested size is given.
/// (If a suggested size is given, the aspect ratio is implied by the size.) // (If a suggested size is given, the aspect ratio is implied by the size.)
/// To give an aspect ratio without implying a suggested size, set xExt and yExt to negative values // To give an aspect ratio without implying a suggested size, set xExt and yExt to negative values
/// whose ratio is the appropriate aspect ratio. // whose ratio is the appropriate aspect ratio.
/// The magnitude of the negative xExt and yExt values is ignored; only the ratio is used. // The magnitude of the negative xExt and yExt values is ignored; only the ratio is used.
short yExt; short yExt;
/// Handle to a memory metafile. // Handle to a memory metafile.
short hMf; short hMf;
}; };
...@@ -80,14 +80,15 @@ namespace DocFileFormat ...@@ -80,14 +80,15 @@ namespace DocFileFormat
friend class NumberingMapping; friend class NumberingMapping;
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, int size, bool oldVersion); PictureDescriptor( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, bool oldVersion);
virtual ~PictureDescriptor(); virtual ~PictureDescriptor();
private: private:
void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion); void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion);
/// Returns the fcPic into the "data" stream, where the PIC begins.
/// Returns -1 if the CHPX has no fcPic. // Returns the fcPic into the "data" stream, where the PIC begins.
// Returns -1 if the CHPX has no fcPic.
static int GetFcPic( const CharacterPropertyExceptions* chpx ); static int GetFcPic( const CharacterPropertyExceptions* chpx );
void Clear(); void Clear();
...@@ -95,45 +96,37 @@ namespace DocFileFormat ...@@ -95,45 +96,37 @@ namespace DocFileFormat
static const short MM_SHAPE = 0x0064; // Shape object static const short MM_SHAPE = 0x0064; // Shape object
static const short MM_SHAPEFILE = 0x0066; // Shape file static const short MM_SHAPEFILE = 0x0066; // Shape file
/// Rectangle for window origin and extents when metafile is stored (ignored if 0). std::vector<unsigned char> rcWinMf; // Rectangle for window origin and extents when metafile is stored (ignored if 0).
std::vector<unsigned char> rcWinMf;
/// Horizontal measurement in twips of the rectangle the picture should be imaged within. short dxaGoal; // Horizontal measurement in twips of the rectangle the picture should be imaged within.
short dxaGoal; short dyaGoal; // Vertical measurement in twips of the rectangle the picture should be imaged within.
/// Vertical measurement in twips of the rectangle the picture should be imaged within.
short dyaGoal; unsigned short mx; // Horizontal scaling factor supplied by user expressed in .001% units
/// Horizontal scaling factor supplied by user expressed in .001% units unsigned short my; // Vertical scaling factor supplied by user expressed in .001% units
unsigned short mx;
/// Vertical scaling factor supplied by user expressed in .001% units PictureType Type; // The type of the picture
unsigned short my;
/// The type of the picture MetafilePicture mfp;
PictureType Type;
/// The name of the picture short dxaCropLeft; // The amount the picture has been cropped on the left in twips
std::wstring Name; short dyaCropTop; // The amount the picture has been cropped on the top in twips
/// The data of the windows metafile picture (WMF) short dxaCropRight; // The amount the picture has been cropped on the right in twips
MetafilePicture mfp; short dyaCropBottom; // The amount the picture has been cropped on the bottom in twips
/// The amount the picture has been cropped on the left in twips
short dxaCropLeft; BorderCode *brcTop; // Border above picture
/// The amount the picture has been cropped on the top in twips BorderCode *brcLeft; // Border to the left of the picture
short dyaCropTop; BorderCode *brcBottom; // Border below picture
/// The amount the picture has been cropped on the right in twips BorderCode *brcRight; // Border to the right of the picture
short dxaCropRight;
/// The amount the picture has been cropped on the bottom in twips short dxaOrigin; // horizontal offset of hand annotation origin
short dyaCropBottom; short dyaOrigin; // vertical offset of hand annotation origin
/// Border above picture
BorderCode *brcTop;
/// Border to the left of the picture
BorderCode *brcLeft;
/// Border below picture
BorderCode *brcBottom;
/// Border to the right of the picture
BorderCode *brcRight;
/// Horizontal offset of hand annotation origin
short dxaOrigin;
/// vertical offset of hand annotation origin
short dyaOrigin;
/// unused
short cProps; short cProps;
ShapeContainer* shapeContainer; //------------------
BlipStoreEntry* blipStoreEntry; ShapeContainer * shapeContainer;
BlipStoreEntry * blipStoreEntry;
unsigned char *embeddedData;
short embeddedDataSize;
}; };
} }
...@@ -91,28 +91,32 @@ namespace DocFileFormat ...@@ -91,28 +91,32 @@ namespace DocFileFormat
//some opCode need special treatment //some opCode need special treatment
switch ( opCode ) switch ( opCode )
{ {
case sprmOldTDefTable:
case sprmOldTDefTable10:
case sprmTDefTable: case sprmTDefTable:
case sprmTDefTable10: case sprmTDefTable10:
{ {
//The opSize of the table definition is stored in 2 bytes instead of 1 //The opSize of the table definition is stored in 2 bytes instead of 1
lenByte = 2; lenByte = 2;
opSize = FormatUtils::BytesToInt16( bytes, ( sprmStart + 2 ), size ); opSize = FormatUtils::BytesToInt16( bytes, ( sprmStart + opCodeSize ), size );
//Word adds an additional unsigned char to the opSize to compensate the additional //Word adds an additional unsigned char to the opSize to compensate the additional
//unsigned char needed for the length //unsigned char needed for the length
opSize--; opSize--;
}break; }break;
case sprmOldPChgTabs:
case sprmPChgTabs: case sprmPChgTabs:
{ {
//The tab operand can be bigger than 255 bytes (length unsigned char is set to 255). //The tab operand can be bigger than 255 bytes (length unsigned char is set to 255).
//In this case a special calculation of the opSize is needed //In this case a special calculation of the opSize is needed
lenByte = 1; lenByte = 1;
opSize = bytes[sprmStart + 2]; opSize = bytes[sprmStart + opCodeSize];
if ( opSize == 255 ) if ( opSize == 255 )
{ {
unsigned char itbdDelMax = bytes[sprmStart + 3]; unsigned char itbdDelMax = bytes[sprmStart + opCodeSize + 1];
unsigned char itbdAddMax = bytes[sprmStart + 3 + 2 * itbdDelMax]; unsigned char itbdAddMax = bytes[sprmStart + opCodeSize + 1 + 2 * itbdDelMax];
opSize = (short)( ( itbdDelMax * 4 + itbdAddMax * 3 ) - 1 ); opSize = (short)( ( itbdDelMax * 4 + itbdAddMax * 3 ) - 1 );
} }
}break; }break;
......
...@@ -86,6 +86,8 @@ namespace DocFileFormat ...@@ -86,6 +86,8 @@ namespace DocFileFormat
{ {
switch ( OpCode ) switch ( OpCode )
{ {
case sprmOldTDefTable:
case sprmOldTDefTable10:
case sprmTDefTable: case sprmTDefTable:
case sprmTDefTable10: case sprmTDefTable10:
{ {
...@@ -99,6 +101,7 @@ namespace DocFileFormat ...@@ -99,6 +101,7 @@ namespace DocFileFormat
} }
break; break;
case sprmOldPChgTabs:
case sprmPChgTabs: case sprmPChgTabs:
{ {
argumentsSize = bytes[2]; argumentsSize = bytes[2];
...@@ -205,7 +208,7 @@ namespace DocFileFormat ...@@ -205,7 +208,7 @@ namespace DocFileFormat
} }
static const unsigned char OldOperandSizeTable[] = static const unsigned char OldOperandSizeTable[] =
{ {
0, 0, 2, 255, 1, 1, 1, 1, 1, 1, 1, 1, 255, 1, 1, 255, 2, 2, 2, 2, 4, 2, 2, 255, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 255, 2, 4, 1, 2, 3, 255, 1, 0, 0, 0, 0, 2, 255, 255, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 2, 2, 1, 1, 1, 1, 1, 255, 1, 255, 255, 2, 255, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 255, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 255, 0, 0, 3, 3, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 1, 12, 255, 2, 0, 0, 4, 5, 4, 2, 4, 2, 2, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0 0, 0, 2, 255, 1, 1, 1, 1, 1, 1, 1, 1, 255, 1, 1, 255, 2, 2, 2, 2, 4, 2, 2, 255, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 255, 2, 4, 1, 2, 3, 255, 1, 0, 0, 0, 0, 2, 255, 255, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 3, 2, 2, 1, 1, 1, 1, 1, 255, 1, 255, 255, 2, 255, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 255, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 255, 0, 0, 3, 3, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 1, 1, 12, 255, 2, 255, 255, 4, 5, 4, 2, 4, 2, 2, 5, 4, 0, 0, 0, 0, 0, 0, 0, 0
}; };
unsigned char SinglePropertyModifier::GetOldOperandSize(unsigned char code) unsigned char SinglePropertyModifier::GetOldOperandSize(unsigned char code)
......
...@@ -35,64 +35,73 @@ ...@@ -35,64 +35,73 @@
namespace DocFileFormat namespace DocFileFormat
{ {
class TableInfo class TableInfo
{ {
public: public:
bool fInTable; bool fInTable;
bool fTtp; bool fTtp;
bool fInnerTtp; bool fInnerTtp;
bool fInnerTableCell; bool fInnerTableCell;
unsigned int iTap; unsigned int iTap;
TableInfo( ParagraphPropertyExceptions* papx ): TableInfo( ParagraphPropertyExceptions* papx ):
fInTable(false), fTtp(false), fInnerTtp(false), fInnerTableCell(false), iTap(0) fInTable(false), fTtp(false), fInnerTtp(false), fInnerTableCell(false), iTap(0)
{
if ( papx != NULL )
{ {
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) if ( papx != NULL )
{ {
if ( iter->OpCode == sprmPFInTable ) for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
{ {
this->fInTable = ( iter->Arguments[0] == 1 ) ? (true) : (false); switch(iter->OpCode)
} {
case sprmOldPFInTable:
if ( iter->OpCode == sprmPFTtp ) case sprmPFInTable:
{ {
this->fTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false); fInTable = ( iter->Arguments[0] == 1 ) ? (true) : (false);
} }break;
if ( iter->OpCode == sprmPFInnerTableCell ) //case sprmOldPFTtp:
{ case sprmOldPTtp:
this->fInnerTableCell = ( iter->Arguments[0] == 1 ) ? (true) : (false); case sprmPFTtp:
} {
fTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false);
if ( iter->OpCode == sprmPFInnerTtp ) }break;
{
this->fInnerTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false);
}
if ( iter->OpCode == sprmPItap )
{
this->iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
if ( this->iTap > 0 )
{
this->fInTable = true;
}
}
if ( (int)( iter->OpCode ) == 0x66A )
{
//add value!
this->iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
if ( this->iTap > 0 ) //case sprmOldPFInnerTableCell:
{ case sprmPFInnerTableCell:
this->fInTable = true; {
} fInnerTableCell = ( iter->Arguments[0] == 1 ) ? (true) : (false);
} }break;
}
//case sprmOldPFInnerTtp:
case sprmPFInnerTtp:
{
fInnerTtp = ( iter->Arguments[0] == 1 ) ? (true) : (false);
}break;
//case sprmOldPItap:
case sprmPItap:
{
iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
if ( iTap > 0 )
{
fInTable = true;
}
}break;
}
if ( (int)( iter->OpCode ) == sprmTCnf )//66a
{
//add value!
iTap = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
if ( iTap > 0 )
{
fInTable = true;
}
}
}
}
} }
} };
};
} }
\ No newline at end of file
...@@ -353,7 +353,7 @@ namespace DocFileFormat ...@@ -353,7 +353,7 @@ namespace DocFileFormat
} }
Table::Table( DocumentMapping* _documentMapping, int _cp, unsigned int _depth ): Table::Table( DocumentMapping* _documentMapping, int _cp, unsigned int _depth ):
cpStart(_cp), cpEnd(_cp), depth(_depth), documentMapping(_documentMapping) cpStart(_cp), cpEnd(_cp), depth(_depth), documentMapping(_documentMapping)
{ {
if ( documentMapping != NULL ) if ( documentMapping != NULL )
{ {
...@@ -371,8 +371,8 @@ namespace DocFileFormat ...@@ -371,8 +371,8 @@ namespace DocFileFormat
TableInfo tai( papx ); TableInfo tai( papx );
TableRow tableRow( documentMapping, _cp ); TableRow tableRow ( documentMapping, _cp );
TableCell tableCell( documentMapping, _cp ); TableCell tableCell ( documentMapping, _cp );
do do
{ {
......
...@@ -54,7 +54,7 @@ namespace DocFileFormat ...@@ -54,7 +54,7 @@ namespace DocFileFormat
/// Extracts the TAPX SPRMs out of a PAPX /// Extracts the TAPX SPRMs out of a PAPX
TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, bool oldVersion) : TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, bool oldVersion) :
PropertyExceptions() PropertyExceptions()
{ {
VirtualStreamReader oBinReader(dataStream, 0, oldVersion); VirtualStreamReader oBinReader(dataStream, 0, oldVersion);
...@@ -62,7 +62,7 @@ namespace DocFileFormat ...@@ -62,7 +62,7 @@ namespace DocFileFormat
for (std::list<SinglePropertyModifier>::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter) for (std::list<SinglePropertyModifier>::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter)
{ {
if (oSpmIter->OpCode == sprmTDefTableShd || oSpmIter->OpCode == sprmTDefTableShd2nd || if (oSpmIter->OpCode == sprmTDefTableShd || oSpmIter->OpCode == sprmTDefTableShd2nd ||
oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd3rd) oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd3rd)
{ {
m_bSkipShading97 = TRUE; m_bSkipShading97 = TRUE;
...@@ -72,7 +72,7 @@ namespace DocFileFormat ...@@ -72,7 +72,7 @@ namespace DocFileFormat
{ {
grpprl->push_back(*oSpmIter); grpprl->push_back(*oSpmIter);
} }
else if ((int)(oSpmIter->OpCode) == sprmPTableProps) else if (oSpmIter->OpCode == sprmPTableProps)
{ {
//there is a native TAP in the data stream //there is a native TAP in the data stream
unsigned int fc = FormatUtils::BytesToUInt32(oSpmIter->Arguments, 0, oSpmIter->argumentsSize); unsigned int fc = FormatUtils::BytesToUInt32(oSpmIter->Arguments, 0, oSpmIter->argumentsSize);
......
...@@ -132,149 +132,153 @@ namespace DocFileFormat ...@@ -132,149 +132,153 @@ namespace DocFileFormat
void VMLPictureMapping::Apply( IVisitable* visited ) void VMLPictureMapping::Apply( IVisitable* visited )
{ {
PictureDescriptor* pict = static_cast<PictureDescriptor*>(visited); PictureDescriptor* pict = static_cast<PictureDescriptor*>(visited);
if (!pict) return;
double xScaling = pict->mx / 1000.0;
double yScaling = pict->my / 1000.0;
TwipsValue width( ( pict->dxaGoal - ( pict->dxaCropLeft + pict->dxaCropRight ) ) * xScaling );
TwipsValue height( ( pict->dyaGoal - ( pict->dyaCropTop + pict->dyaCropBottom ) ) * yScaling );
std::wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() );
std::wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() );
std::list<OptionEntry> options;
PictureFrameType type;
if ((pict->shapeContainer || pict->blipStoreEntry) && pict->shapeContainer->Children.size() > 0) 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()));
std::list<OptionEntry> options = pict->shapeContainer->ExtractOptions(); options = pict->shapeContainer->ExtractOptions();
//v:shapetype //v:shapetype
PictureFrameType type;
type.SetType(shape->Instance); type.SetType(shape->Instance);
VMLShapeTypeMapping* vmlShapeTypeMapping = new VMLShapeTypeMapping( m_pXmlWriter, m_isBulletPicture ); VMLShapeTypeMapping* vmlShapeTypeMapping = new VMLShapeTypeMapping( m_pXmlWriter, m_isBulletPicture );
type.Convert( vmlShapeTypeMapping ); type.Convert( vmlShapeTypeMapping );
RELEASEOBJECT( vmlShapeTypeMapping ); RELEASEOBJECT( vmlShapeTypeMapping );
}
else if (pict->embeddedData)
{
type.SetType(msosptPictureFrame);
}
m_pXmlWriter->WriteNodeBegin( _T( "v:shape" ), true );
m_pXmlWriter->WriteAttribute( _T( "type" ), std::wstring( _T( "#" ) + VMLShapeTypeMapping::GenerateTypeId(&type)).c_str());
//v:shape std::wstring style = std::wstring( _T( "width:" ) ) + widthString + std::wstring( _T( "pt;" ) ) + std::wstring( _T( "height:" ) ) + heightString + std::wstring( _T( "pt;" ) );
m_pXmlWriter->WriteNodeBegin( _T( "v:shape" ), true );
m_pXmlWriter->WriteAttribute( _T( "type" ), ( std::wstring( _T( "#" ) ) + VMLShapeTypeMapping::GenerateTypeId( &type ) ).c_str() );
std::wstring style;
double xScaling = pict->mx / 1000.0;
double yScaling = pict->my / 1000.0;
TwipsValue width( ( pict->dxaGoal - ( pict->dxaCropLeft + pict->dxaCropRight ) ) * xScaling );
TwipsValue height( ( pict->dyaGoal - ( pict->dyaCropTop + pict->dyaCropBottom ) ) * yScaling );
std::wstring widthString = FormatUtils::DoubleToWideString( width.ToPoints() );
std::wstring heightString = FormatUtils::DoubleToWideString( height.ToPoints() );
style = std::wstring( _T( "width:" ) ) + widthString + std::wstring( _T( "pt;" ) ) + std::wstring( _T( "height:" ) ) + heightString + std::wstring( _T( "pt;" ) );
m_pXmlWriter->WriteAttribute( _T( "style" ), style.c_str() ); m_pXmlWriter->WriteAttribute( _T( "style" ), style.c_str() );
m_pXmlWriter->WriteAttribute( _T( "id" ), m_ShapeId.c_str() ); m_pXmlWriter->WriteAttribute( _T( "id" ), m_ShapeId.c_str() );
if (m_isOlePreview) if (m_isOlePreview)
{ {
m_pXmlWriter->WriteAttribute( _T( "o:ole" ), _T( "" ) ); m_pXmlWriter->WriteAttribute( _T( "o:ole" ), _T( "" ) );
} }
else if (m_isBulletPicture) else if (m_isBulletPicture)
{ {
m_pXmlWriter->WriteAttribute( _T( "o:bullet" ), _T( "1" ) ); m_pXmlWriter->WriteAttribute( _T( "o:bullet" ), _T( "1" ) );
} }
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)
{
switch ( iter->pid )
{ {
switch ( iter->pid ) case wzEquationXML:
{ {
case wzEquationXML: m_isEquation = true;
{ m_isEmbedded = true;
m_isEquation = true;
m_isEmbedded = true; m_embeddedData = std::string((char*)iter->opComplex, iter->op);
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
if (ParseEmbeddedEquation( m_embeddedData, m_equationXml)) if (ParseEmbeddedEquation( m_embeddedData, m_equationXml))
{
m_isEmbedded = false;
}
}break;
case metroBlob:
{ {
//встроенная неведомая хуйня m_isEmbedded = false;
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
}break;
//BORDERS
case borderBottomColor:
{
RGBColor bottomColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderbottomcolor" ), ( std::wstring( _T( "#" ) ) + bottomColor.SixDigitHexCode ).c_str() );
}
break;
case borderLeftColor:
{
RGBColor leftColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderleftcolor" ), ( std::wstring( _T( "#" ) ) + leftColor.SixDigitHexCode ).c_str() );
}
break;
case borderRightColor:
{
RGBColor rightColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderrightcolor" ), ( std::wstring( _T( "#" ) ) + rightColor.SixDigitHexCode ).c_str() );
}
break;
case borderTopColor:
{
RGBColor topColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:bordertopcolor" ), ( std::wstring( _T( "#" ) ) + topColor.SixDigitHexCode ).c_str() );
} }
break; }break;
case metroBlob:
{
//встроенная неведомая хуйня
m_isEmbedded = true;
m_embeddedData = std::string((char*)iter->opComplex, iter->op);
}break;
//BORDERS
case borderBottomColor:
{
RGBColor bottomColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderbottomcolor" ), ( std::wstring( _T( "#" ) ) + bottomColor.SixDigitHexCode ).c_str() );
}
break;
case borderLeftColor:
{
RGBColor leftColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderleftcolor" ), ( std::wstring( _T( "#" ) ) + leftColor.SixDigitHexCode ).c_str() );
}
break;
case borderRightColor:
{
RGBColor rightColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:borderrightcolor" ), ( std::wstring( _T( "#" ) ) + rightColor.SixDigitHexCode ).c_str() );
}
break;
case borderTopColor:
{
RGBColor topColor( (int)iter->op, RedFirst );
m_pXmlWriter->WriteAttribute( _T( "o:bordertopcolor" ), ( std::wstring( _T( "#" ) ) + topColor.SixDigitHexCode ).c_str() );
}
break;
//CROPPING //CROPPING
case cropFromBottom: case cropFromBottom:
{ {
//cast to signed integer //cast to signed integer
int cropBottom = (int)iter->op; int cropBottom = (int)iter->op;
appendValueAttribute(m_imageData, _T( "cropbottom" ), ( FormatUtils::IntToWideString( cropBottom ) + std::wstring( _T( "f" ) ) ).c_str() ); appendValueAttribute(m_imageData, _T( "cropbottom" ), ( FormatUtils::IntToWideString( cropBottom ) + std::wstring( _T( "f" ) ) ).c_str() );
} }
break; break;
case cropFromLeft: case cropFromLeft:
{ {
//cast to signed integer //cast to signed integer
int cropLeft = (int)iter->op; int cropLeft = (int)iter->op;
appendValueAttribute(m_imageData, _T( "cropleft" ), ( FormatUtils::IntToWideString( cropLeft ) + std::wstring( _T( "f" ) ) ).c_str()); appendValueAttribute(m_imageData, _T( "cropleft" ), ( FormatUtils::IntToWideString( cropLeft ) + std::wstring( _T( "f" ) ) ).c_str());
} }
break; break;
case cropFromRight: case cropFromRight:
{ {
//cast to signed integer //cast to signed integer
int cropRight = (int)iter->op; int cropRight = (int)iter->op;
appendValueAttribute(m_imageData, _T( "cropright" ), ( FormatUtils::IntToWideString( cropRight ) + std::wstring( _T( "f" ) ) ).c_str()); appendValueAttribute(m_imageData, _T( "cropright" ), ( FormatUtils::IntToWideString( cropRight ) + std::wstring( _T( "f" ) ) ).c_str());
}
break;
case cropFromTop:
{
//cast to signed integer
int cropTop = (int)iter->op;
appendValueAttribute(m_imageData, _T( "croptop" ), ( FormatUtils::IntToWideString( cropTop ) + std::wstring( _T( "f" ) ) ).c_str());
}
break;
} }
break;
case cropFromTop:
{
//cast to signed integer
int cropTop = (int)iter->op;
appendValueAttribute(m_imageData, _T( "croptop" ), ( FormatUtils::IntToWideString( cropTop ) + std::wstring( _T( "f" ) ) ).c_str());
}
break;
} }
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE ); m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
if (CopyPicture(pict->blipStoreEntry)) if (CopyPicture(pict))
{ {
//v:imageData //v:imageData
appendValueAttribute(m_imageData, _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str()); appendValueAttribute(m_imageData, _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" )); appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" ));
m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str()); m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str());
} }
//borders //borders
writePictureBorder( _T( "bordertop" ), pict->brcTop ); writePictureBorder( _T( "bordertop" ), pict->brcTop );
writePictureBorder( _T( "borderleft" ), pict->brcLeft ); writePictureBorder( _T( "borderleft" ), pict->brcLeft );
writePictureBorder( _T( "borderbottom" ), pict->brcBottom ); writePictureBorder( _T( "borderbottom" ), pict->brcBottom );
writePictureBorder( _T( "borderright" ), pict->brcRight ); writePictureBorder( _T( "borderright" ), pict->brcRight );
//close v:shape //close v:shape
m_pXmlWriter->WriteNodeEnd( _T( "v:shape" ) ); m_pXmlWriter->WriteNodeEnd( _T( "v:shape" ) );
}
} }
std::wstring VMLPictureMapping::GetShapeId () const std::wstring VMLPictureMapping::GetShapeId () const
...@@ -283,9 +287,11 @@ namespace DocFileFormat ...@@ -283,9 +287,11 @@ namespace DocFileFormat
} }
/// Writes a border element /// Writes a border element
void VMLPictureMapping::writePictureBorder( const wchar_t* name, const BorderCode* brc ) void VMLPictureMapping::writePictureBorder( const std::wstring & name, const BorderCode* brc )
{ {
m_pXmlWriter->WriteNodeBegin( ( std::wstring( _T( "w10:" ) ) + std::wstring( name ) ).c_str(), true ); if (!brc || name.empty()) return;
m_pXmlWriter->WriteNodeBegin( ( std::wstring( _T( "w10:" ) ) + name).c_str(), true );
m_pXmlWriter->WriteAttribute( _T( "type" ), getBorderType( brc->brcType ).c_str() ); m_pXmlWriter->WriteAttribute( _T( "type" ), getBorderType( brc->brcType ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "width" ), FormatUtils::IntToWideString( brc->dptLineWidth ).c_str() ); m_pXmlWriter->WriteAttribute( _T( "width" ), FormatUtils::IntToWideString( brc->dptLineWidth ).c_str() );
m_pXmlWriter->WriteNodeEnd ( _T( "" ), true ); m_pXmlWriter->WriteNodeEnd ( _T( "" ), true );
...@@ -293,12 +299,20 @@ namespace DocFileFormat ...@@ -293,12 +299,20 @@ namespace DocFileFormat
/// Copies the picture from the binary stream to the zip archive /// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image. /// and creates the relationships for the image.
bool VMLPictureMapping::CopyPicture (BlipStoreEntry* oBlipEntry) bool VMLPictureMapping::CopyPicture (PictureDescriptor* pict)
{ {
if (!pict) return false;
bool result = false; bool result = false;
// write the blip BlipStoreEntry* oBlipEntry = pict->blipStoreEntry;
if ((oBlipEntry != NULL) && (oBlipEntry->Blip != NULL))
if (pict->embeddedData && pict->embeddedDataSize > 0)
{
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(Global::msoblipWMF), std::vector<unsigned char>(pict->embeddedData, pict->embeddedData + pict->embeddedDataSize)));
m_nImageId = m_ctx->_docx->RegisterImage(m_caller, Global::msoblipWMF);
result = true;
}
else if ((oBlipEntry != NULL) && (oBlipEntry->Blip != NULL))
{ {
switch (oBlipEntry->btWin32) switch (oBlipEntry->btWin32)
{ {
...@@ -336,9 +350,7 @@ namespace DocFileFormat ...@@ -336,9 +350,7 @@ namespace DocFileFormat
default: default:
{ {
result = false; return false;
return result;
} }
break; break;
} }
......
...@@ -56,13 +56,13 @@ namespace DocFileFormat ...@@ -56,13 +56,13 @@ namespace DocFileFormat
private: private:
/// Writes a border element /// Writes a border element
void writePictureBorder (const wchar_t* name, const BorderCode* brc); void writePictureBorder (const std::wstring & name, const BorderCode* brc);
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const; void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
protected: protected:
/// Copies the picture from the binary stream to the zip archive /// Copies the picture from the binary stream to the zip archive
/// and creates the relationships for the image. /// and creates the relationships for the image.
bool CopyPicture (BlipStoreEntry* oBlipEntry); bool CopyPicture (PictureDescriptor* pict);
public: public:
......
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