Compare commits

...

9 Commits

Author SHA1 Message Date
3816162555 Merge commit '3fb166f99a211e85474c121009019d06710722f8' into develop 2018-09-10 18:43:15 +03:00
3fb166f99a OdfFormatWriter - fix repeated rows 2018-09-10 18:15:35 +03:00
d8121d1a12 [ios][x2t] fixed array check 2018-09-06 19:11:47 +03:00
a76bf57051 fix bug #38817 2018-09-06 13:46:47 +03:00
97b92cf75c . 2018-09-05 18:39:32 +03:00
506de8e9e1 fix bug #38678 2018-09-05 18:38:55 +03:00
fb34d57ee6 DocFormatReader - fix footnotes for doc1995; optimization convert 2018-09-05 14:45:24 +03:00
da2d997838 . 2018-09-03 19:50:02 +03:00
76d68fa70f Fix bug #38544
Fix the problem with calculating transformation matrix for the EMF. Add support of EMR_STRETCHBLT field.
2018-09-03 18:07:10 +03:00
28 changed files with 454 additions and 156 deletions

View File

@ -58,7 +58,8 @@ namespace DocFileFormat
}
else
{
short cch = reader->ReadInt16();
short cch = reader->ReadInt16();
unsigned char *chars = reader->ReadBytes(18, true);
@ -67,13 +68,34 @@ namespace DocFileFormat
newObject->m_AuthorIndex = reader->ReadUInt16();
//skip 4 bytes
reader->ReadBytes(4, false);
unsigned int skip = reader->ReadUInt32();
newObject->m_BookmarkId = reader->ReadInt32();
newObject->m_BookmarkId = reader->ReadInt32(); //-1 - comment is on a length zero text range in the Main Document
RELEASEARRAYOBJECTS(chars);
}
return static_cast<ByteStructure*>(newObject);
}
ByteStructure* AnnotationReferenceExDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
{
AnnotationReferenceExDescriptor *newObject = new AnnotationReferenceExDescriptor();
if (reader->nWordVersion > 0)
{
}
else
{
m_nDTTM = reader->ReadUInt32();
reader->ReadUInt16(); //padding1
m_nDepth = reader->ReadUInt32();
m_nDiatrdParent = reader->ReadUInt32();
unsigned int flag = reader->ReadUInt32();
m_fInkAtn = GETBIT(flag, 1);
}
return static_cast<ByteStructure*>(newObject);
}
}

View File

@ -46,21 +46,6 @@ namespace DocFileFormat
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
inline std::wstring GetUserInitials() const
{
return m_UserInitials;
}
inline unsigned short GetAuthorIndex() const
{
return m_AuthorIndex;
}
inline int GetBookmarkId() const
{
return m_BookmarkId;
}
AnnotationReferenceDescriptor() : m_AuthorIndex(0), m_BookmarkId(0)
{
}
@ -71,13 +56,35 @@ namespace DocFileFormat
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
private:
/// The initials of the user who left the annotation.
std::wstring m_UserInitials;
/// An index into the string table of comment author names.
unsigned short m_AuthorIndex;
/// Identifies a bookmark.
int m_BookmarkId;
};
class AnnotationReferenceExDescriptor: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 18;
static const int STRUCTURE_SIZE_OLD = 0;
static const int GetSize(int nWordVersion)
{
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
AnnotationReferenceExDescriptor() : m_nDTTM(0), m_nDepth(0), m_nDiatrdParent(0), m_fInkAtn(false)
{
}
virtual ~AnnotationReferenceExDescriptor()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
unsigned int m_nDTTM;
unsigned int m_nDepth;
unsigned int m_nDiatrdParent;
bool m_fInkAtn;
};
}

View File

@ -39,13 +39,8 @@ namespace DocFileFormat
class BookmarkFirst: public ByteStructure
{
private:
/// An unsigned integer that specifies a zero-based index into the PlcfBkl or PlcfBkld
/// that is paired with the PlcfBkf or PlcfBkfd containing this FBKF.
/// The entry found at said index specifies the location of the end of the bookmark associated with this FBKF.
/// Ibkl MUST be unique for all FBKFs inside a given PlcfBkf or PlcfBkfd.
short ibkl;
/// A BKC that specifies further information about the bookmark associated with this FBKF.
short bkc;
short ibkl;
short bkc;
public:
static const int STRUCTURE_SIZE = 4;
@ -78,4 +73,32 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
};
class AtnBookmarkFirst: public ByteStructure
{
public:
unsigned short bmc;
unsigned int lTag;
static const int STRUCTURE_SIZE = 10;
AtnBookmarkFirst()
{
}
virtual ~AtnBookmarkFirst()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
AtnBookmarkFirst *newObject = new AtnBookmarkFirst();
newObject->bmc = reader->ReadUInt16(); //0x0100
newObject->lTag = reader->ReadUInt32();
unsigned int lTagOld = reader->ReadUInt32();
return static_cast<ByteStructure*>( newObject );
}
};
}

View File

@ -75,7 +75,7 @@ namespace DocFileFormat
convertSprms( dynamic_cast<CharacterPropertyExceptions*>( chpx )->grpprl, _rPr );
// apend revision changes
if (_revisionData->Type == Changed)
if ((_revisionData) && (_revisionData->Type == Changed))
{
XMLTools::XMLElement rPrChange( L"w:rPrChange");

View File

@ -52,8 +52,6 @@ namespace DocFileFormat
{
m_context->_docx->RegisterComments();
int index = 0;
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin( L"w:comments", TRUE );
@ -63,33 +61,60 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" );
m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" );
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" );
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 w15 w16se wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr;
size_t count = m_document->AnnotationsReferencePlex->Elements.size();
for (size_t i = 0; i < count; ++i)
for (size_t index = 0; index < count; ++index)
{
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
AnnotationReferenceExDescriptor* atrdPost10 = m_document->AnnotationsReferenceExPlex ? static_cast<AnnotationReferenceExDescriptor*>(m_document->AnnotationsReferenceExPlex->Elements[index]) : NULL;
unsigned short index_author = atrdPre10->GetAuthorIndex();
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
if (index_author < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
if (atrdPre10->m_BookmarkId < 0)
{
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 + count + 1024 ));
}
else
{
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
}
if (atrdPost10)
{
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
}
if (atrdPre10->m_AuthorIndex < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
{
m_pXmlWriter->WriteAttribute( L"w:author",
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( index_author ) ));
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->m_AuthorIndex ) ));
}
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->m_UserInitials);
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
@ -116,8 +141,6 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeEnd(L"w:comment" );
++index;
}
m_pXmlWriter->WriteNodeEnd( L"w:comments" );

View File

@ -45,7 +45,7 @@ namespace DocFileFormat
{
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller) : _skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL),
AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_endnoteNr(0), _commentNr(0), _caller(caller)
_endnoteNr(0), _commentNr(1), _caller(caller)
{
m_document = NULL;
m_context = context;
@ -506,7 +506,7 @@ namespace DocFileFormat
}
//write text
for (unsigned int i = 0; i < chars->size(); ++i)
for (size_t i = 0; i < chars->size(); ++i)
{
wchar_t c = chars->at(i), code = c;
@ -526,7 +526,20 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement elem(L"w:br");
if (textType == L"instrText")
{
m_pXmlWriter->WriteNodeEnd(L"w:r");
m_pXmlWriter->WriteNodeBegin(L"w:r");
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, NULL, _lastValidPapx, false);
if (rPr)
{
rPr->_webHidden = _writeWebHidden;
chpx->Convert(rPr);
RELEASEOBJECT(rPr);
}
}
XMLTools::XMLElement elem(L"w:br");
elem.AppendAttribute(L"w:type", L"textWrapping");
elem.AppendAttribute(L"w:clear", L"all");
@ -1013,6 +1026,11 @@ namespace DocFileFormat
if ((m_document->FootnoteReferenceCharactersPlex != NULL) && (m_document->FootnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( L"w:footnoteReference", true );
FootnoteDescriptor* desc = dynamic_cast<FootnoteDescriptor*>(m_document->FootnoteReferenceCharactersPlex->Elements[_footnoteNr]);
if (desc && desc->aFtnIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
}
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(_footnoteNr++ ) );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -1024,6 +1042,11 @@ namespace DocFileFormat
else if ((m_document->EndnoteReferenceCharactersPlex != NULL) && (m_document->EndnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( L"w:endnoteReference", true );
EndnoteDescriptor* desc = dynamic_cast<EndnoteDescriptor*>(m_document->EndnoteReferenceCharactersPlex->Elements[_footnoteNr]);
if (desc && desc->aEndIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
}
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(_endnoteNr++ ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -1041,10 +1064,10 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"w:annotationRef", true );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
else
else if ((m_document->AnnotationsReferencePlex) && (_commentNr <= m_document->AnnotationsReferencePlex->Elements.size()))
{
m_pXmlWriter->WriteNodeBegin( L"w:commentReference", true );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr ));
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr++ ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
}
@ -1196,7 +1219,7 @@ namespace DocFileFormat
// add the parts
for (unsigned int i = 0; i < splitIndices->size(); ++i)
for (size_t i = 0; i < splitIndices->size(); ++i)
{
int cch = splitIndices->at( i ) - startIndex;

View File

@ -37,21 +37,14 @@ namespace DocFileFormat
{
class EndnoteDescriptor: public ByteStructure
{
private:
short aEndIdx;
public:
static const int STRUCTURE_SIZE = 2;
EndnoteDescriptor():
aEndIdx(0)
{
}
EndnoteDescriptor(): aEndIdx(0) {}
virtual ~EndnoteDescriptor()
{
}
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
EndnoteDescriptor *newObject = new EndnoteDescriptor();
@ -60,5 +53,7 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
short aEndIdx;
};
}

View File

@ -560,8 +560,7 @@ namespace DocFileFormat
m_FibWord97.fcPlcffndRef = reader.ReadInt32();
m_FibWord97.lcbPlcffndRef = reader.ReadInt32();
m_FibWord97.lcbPlcfandTxt = reader.ReadInt32();//112
m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//112
m_FibWord97.lcbPlcffndTxt = reader.ReadInt32();
m_FibWord97.fcPlcfandRef = reader.ReadInt32();

View File

@ -37,21 +37,15 @@ namespace DocFileFormat
{
class FootnoteDescriptor: public ByteStructure
{
private:
short aFtnIdx;
public:
static const int STRUCTURE_SIZE = 2;
FootnoteDescriptor():
aFtnIdx(0)
{
}
FootnoteDescriptor() : aFtnIdx(0) {}
virtual ~FootnoteDescriptor()
{
}
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
FootnoteDescriptor *newObject = new FootnoteDescriptor();
@ -60,5 +54,7 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
short aFtnIdx;
};
}

View File

@ -79,7 +79,7 @@ namespace DocFileFormat
drawing.dgglbl = (DrawingType)oStearmReader.ReadByte();
drawing.container = static_cast<DrawingContainer*>(RecordFactory::ReadRecord (&oStearmReader, 0));
for (unsigned int i = 0; i < drawing.container->Children.size(); ++i)
for (size_t i = 0; i < drawing.container->Children.size(); ++i)
{
Record* groupChild = drawing.container->Children[i];
if (groupChild)
@ -140,7 +140,7 @@ namespace DocFileFormat
GroupContainer* group = iter->container->FirstChildWithType<GroupContainer>();
if (group)
{
for (unsigned int i = 1; i < group->Children.size(); ++i)
for (size_t i = 1; i < group->Children.size(); ++i)
{
Record* groupChild = group->Children[i];

View File

@ -48,6 +48,7 @@ namespace DocFileFormat
std::vector<ByteStructure*> Elements;
bool m_bIsValid;
std::map<int, int> mapCP;
public:
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, int nWordVersion)
: m_bIsValid(false), CP_LENGTH(/*nWordVersion == 2 ? 2 :*/ 4)
@ -77,7 +78,10 @@ namespace DocFileFormat
for (int i = 0; i < (n + 1); ++i)
{
CharacterPositions.push_back(reader.ReadInt32());
int val = reader.ReadInt32();
mapCP.insert(std::make_pair(val, (int)CharacterPositions.size()));
CharacterPositions.push_back(val);
}
// read the n structs
@ -96,9 +100,9 @@ namespace DocFileFormat
~Plex()
{
for (std::vector<ByteStructure*>::iterator iter = Elements.begin(); iter != Elements.end(); ++iter)
for (size_t i = 0; i < Elements.size(); ++i)
{
RELEASEOBJECT(*iter);
RELEASEOBJECT(Elements[i]);
}
}
@ -109,15 +113,14 @@ namespace DocFileFormat
{
int index = -1;
for (int i = 0; i < (int)CharacterPositions.size(); ++i)
std::map<int, int>::iterator pFind = mapCP.find(cp);
if (pFind != mapCP.end())
{
if (CharacterPositions[i] == cp)
{
index = i;
break;
}
index = pFind->second;
}
if ((index >= 0) && (index < (int)Elements.size()))
return this->Elements[index];
@ -128,13 +131,11 @@ namespace DocFileFormat
{
bool result = false;
for (int i = 0; i < (int)CharacterPositions.size(); ++i)
std::map<int, int>::const_iterator pFind = mapCP.find(cp);
if (pFind != mapCP.end())
{
if (CharacterPositions[i] == cp)
{
result = true;
break;
}
result = true;
}
return result;
@ -142,7 +143,7 @@ namespace DocFileFormat
inline int operator [] (unsigned int index) const
{
if (index < CharacterPositions.size())
if (index < (unsigned int)CharacterPositions.size())
return CharacterPositions[index];
return -1;

View File

@ -156,9 +156,8 @@ namespace DocFileFormat
}break;
//div id
case sprmTIpgp:
case sprmTIpgp:// = PGPInfo.ipgpSelf (PGPInfo structure describes the border and margin properties)
{
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
//borders 80 exceptions

View File

@ -85,7 +85,7 @@ namespace DocFileFormat
IndividualFootnotesPlex(NULL), FootnoteReferenceCharactersPlex(NULL), IndividualEndnotesPlex(NULL),
EndnoteReferenceCharactersPlex(NULL), FieldsPlex(NULL), FootnoteDocumentFieldsPlex(NULL),
EndnoteDocumentFieldsPlex(NULL), HeadersAndFootersDocumentFieldsPlex(NULL), HeaderStoriesPlex(NULL),
AnnotationsReferencePlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
AnnotationsReferencePlex(NULL), AnnotationsReferenceExPlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
TextboxIndividualPlex(NULL),AssocNames(NULL), BookmarkAnnotNames(NULL), Captions(NULL), AutoCaptions(NULL), ListPlex(NULL),
OfficeDrawingPlex(NULL), OfficeDrawingPlexHeader(NULL), SectionPlex(NULL), BookmarkStartPlex(NULL), BookmarkEndPlex(NULL),
AutoTextPlex(NULL), AllPapxFkps(NULL), AllChpxFkps(NULL), AllPapx(NULL), AllPapxVector(NULL), AllSepx(NULL), Styles(NULL), listTable(NULL),
@ -318,8 +318,8 @@ namespace DocFileFormat
// Read all needed PLCFs
if (FIB->m_RgLw97.ccpFtn > 0)
{
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
FootnoteReferenceCharactersPlex = new Plex<FootnoteDescriptor>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion);
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
}
if (nWordVersion > 0 && FIB->m_FibWord97.lcbPlcPad > 0)
@ -329,8 +329,8 @@ namespace DocFileFormat
if (FIB->m_RgLw97.ccpEdn > 0)
{
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
EndnoteReferenceCharactersPlex = new Plex<EndnoteDescriptor>(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, nWordVersion);
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
}
if (FIB->m_RgLw97.ccpHdr > 0)
@ -343,6 +343,11 @@ namespace DocFileFormat
AnnotationsReferencePlex = new Plex<AnnotationReferenceDescriptor>(AnnotationReferenceDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, nWordVersion);
IndividualCommentsPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, nWordVersion);
}
if (FIB->m_FibWord2002.lcbAtrdExtra > 0)
{
AnnotationsReferenceExPlex = new Plex<AnnotationReferenceExDescriptor>(AnnotationReferenceExDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord2002.fcAtrdExtra, FIB->m_FibWord2002.lcbAtrdExtra, nWordVersion);
}
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, nWordVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, nWordVersion);
@ -356,7 +361,7 @@ namespace DocFileFormat
TextboxBreakPlex = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, nWordVersion);
TextboxBreakPlexHeader = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, nWordVersion);
@ -368,18 +373,19 @@ namespace DocFileFormat
BookmarkStartEndCPs.push_back(std::make_pair(BookmarkStartPlex->CharacterPositions[i], BookmarkEndPlex->CharacterPositions[pBookmark->GetIndex()]));
}
}
for (size_t i = 0; i < AnnotStartPlex->Elements.size(); ++i)
for (size_t i = 0; AnnotStartPlex && i < AnnotStartPlex->Elements.size(); ++i)
{
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
if (pBookmark)
{
short end = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() && end < AnnotEndPlex->CharacterPositions.size())
short ind = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() -1 )
{
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[end]));
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[i + 1]));
}
}
}
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, nWordVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, nWordVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, nWordVersion);
@ -435,7 +441,7 @@ namespace DocFileFormat
std::unordered_map<int, int> fonts_charsets;
bool bFontsCodePage = false;
for ( size_t i = 0; !bFontsCodePage && i < FontTable->Data.size(); ++i)
for ( size_t i = 0; FIB->m_FibWord97.lcbClx > 0 && !bFontsCodePage && i < FontTable->Data.size(); ++i)
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( FontTable->Data[i]);
if (!font) continue;
@ -488,13 +494,13 @@ namespace DocFileFormat
if (BookmarkNames)
{
for (unsigned int i = 0; i < BookmarkStartEndCPs.size(); ++i)
for (size_t i = 0; i < BookmarkStartEndCPs.size(); ++i)
{
WideString* bookmarkName = static_cast<WideString*>(BookmarkNames->operator[]( i ));
if ( ( bookmarkName != NULL ) && ( *bookmarkName == L"_PictureBullets" ) )
{
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
for (size_t j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
{
if ( Text->at( j ) == 1 )
{
@ -540,7 +546,7 @@ namespace DocFileFormat
{
AllSepx = new std::map<int, SectionPropertyExceptions*>();
for (unsigned int i = 0; i < SectionPlex->Elements.size(); ++i)
for (size_t i = 0; i < SectionPlex->Elements.size(); ++i)
{
//Read the SED
SectionDescriptor* sed = static_cast<SectionDescriptor*>(SectionPlex->Elements.at(i));
@ -869,6 +875,7 @@ namespace DocFileFormat
RELEASEOBJECT(HeaderStoriesPlex);
RELEASEOBJECT(IndividualCommentsPlex);
RELEASEOBJECT(AnnotationsReferencePlex);
RELEASEOBJECT(AnnotationsReferenceExPlex);
RELEASEOBJECT(TextboxBreakPlex);
RELEASEOBJECT(TextboxBreakPlexHeader);
RELEASEOBJECT(OfficeDrawingPlex);

View File

@ -224,6 +224,7 @@ namespace DocFileFormat
Plex<FieldCharacter> *EndnoteDocumentFieldsPlex;
Plex<FieldCharacter> *HeadersAndFootersDocumentFieldsPlex;
Plex<AnnotationReferenceDescriptor> *AnnotationsReferencePlex;
Plex<AnnotationReferenceExDescriptor> *AnnotationsReferenceExPlex;
Plex<EmptyStructure> *AutoTextPlex;
// Each character position specifies the beginning of a range of text that constitutes the contents of an AutoText item

View File

@ -301,7 +301,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
ods_context->start_rows();
for (size_t row = 0 ; row < oox_sheet->m_oSheetData->m_arrItems.size(); row++)
{
convert(oox_sheet->m_oSheetData->m_arrItems[row]);
convert(oox_sheet->m_oSheetData->m_arrItems[row], row > 0 ? oox_sheet->m_oSheetData->m_arrItems[row - 1] : NULL);
if ( oox_sheet->m_oSheetData->m_arrItems[row] )
delete oox_sheet->m_oSheetData->m_arrItems[row];

View File

@ -1410,7 +1410,31 @@ std::wstring CDrawingConverter::ObjectToVML (const std::wstring& sXml)
HRESULT CDrawingConverter::AddObject(const std::wstring& bsXml, std::wstring** pMainProps)
{
std::wstring sBegin(L"<main xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:p=\"urn:schemas-microsoft-com:office:powerpoint\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\">");
std::wstring sBegin(L"<main \
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:p=\"urn:schemas-microsoft-com:office:powerpoint\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:x=\"urn:schemas-microsoft-com:office:excel\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" \
xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\" \
xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" \
mc:Ignorable=\"w14 w15 wp14\">");
std::wstring sEnd(L"</main>");
std::wstring strXml = sBegin + bsXml + sEnd;
@ -2385,6 +2409,25 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
XmlMacroReadAttributeBase(oNodeShape, L"strokecolor", sStrokeColor);
XmlMacroReadAttributeBase(oNodeShape, L"strokeweight", sStrokeWeight);
XmlMacroReadAttributeBase(oNodeShape, L"stroked", sStroked);
XmlUtils::CXmlNode oNodeStroke = oNodeShape.ReadNode(L"v:stroke");
if (oNodeStroke.IsValid())
{
nullable_string sStrokeOn;
XmlMacroReadAttributeBase(oNodeStroke, L"on", sStrokeOn);
if (sStrokeOn.is_init())
{
sStroked.reset();
sStroked = sStrokeOn;
}
nullable_string sStrokeColor1;
XmlMacroReadAttributeBase(oNodeStroke, L"strokecolor", sStrokeColor1);
if (sStrokeColor1.is_init())
{
sStrokeColor1.reset();
sStrokeColor = sStrokeColor1;
}
}
//textFill
strRPr += L"<w14:textFill>";
@ -2532,8 +2575,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
strRPr += L"<w14:noFill/>";
bStroked = false;
}
}
}
if (sStrokeColor.is_init())
{
color = NS_DWC_Common::getColorFromString(*sStrokeColor);
@ -4460,9 +4502,21 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::
pSpPr->ln->w = size;
pPPTShape->m_bIsStroked = true;
}
XmlUtils::CXmlNode oNodeStroke = oNode.ReadNode(L"v:stroke");
nullable_string sStroked;
XmlMacroReadAttributeBase(oNode, L"stroked", sStroked);
if (oNodeStroke.IsValid())
{
nullable_string sStrokeOn;
XmlMacroReadAttributeBase(oNodeStroke, L"on", sStrokeOn);
if (sStrokeOn.is_init())
{
sStroked.reset();
sStroked = sStrokeOn;
}
}
if (sStroked.is_init())
{
if (*sStroked == L"false" || *sStroked == L"f")
@ -4483,16 +4537,8 @@ void CDrawingConverter::CheckPenShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils::
pSpPr->ln->Fill.Fill = new PPTX::Logic::NoFill();
}
XmlUtils::CXmlNode oNodeStroke = oNode.ReadNode(L"v:stroke");
if (oNodeStroke.IsValid())
{
nullable_string sStrokeOn;
XmlMacroReadAttributeBase(oNodeStroke, L"on", sStrokeOn);
if (sStrokeOn.is_init())
{
sStroked.reset();
sStroked = sStrokeOn;
}
sStrokeColor.reset();
XmlMacroReadAttributeBase(oNodeStroke, L"strokecolor", sStrokeColor);
if (sStrokeColor.is_init())

View File

@ -1 +1 @@
2.4.546.0
2.4.547.0

View File

@ -458,12 +458,12 @@ namespace MetaFile
{
// oOther слева, текущая матрица справа
double dM11 = oOther.M11 * M11 + oOther.M12 * M21;
double dM12 = oOther.M11 * M21 + oOther.M12 * M22;
double dM12 = oOther.M11 * M12 + oOther.M12 * M22;
double dM21 = oOther.M21 * M11 + oOther.M22 * M21;
double dM22 = oOther.M21 * M21 + oOther.M22 * M22;
double dM22 = oOther.M21 * M12 + oOther.M22 * M22;
double dDx = oOther.Dx * M11 + oOther.Dy * M21 + Dx;
double dDy = oOther.Dx * M21 + oOther.Dy * M22 + Dy;
double dDy = oOther.Dx * M12 + oOther.Dy * M22 + Dy;
M11 = dM11;
M12 = dM12;
@ -476,12 +476,12 @@ namespace MetaFile
{
// oOther справа, текущая матрица слева
double dM11 = M11 * oOther.M11 + M12 * oOther.M21;
double dM12 = M11 * oOther.M21 + M12 * oOther.M22;
double dM12 = M11 * oOther.M12 + M12 * oOther.M22;
double dM21 = M21 * oOther.M11 + M22 * oOther.M21;
double dM22 = M21 * oOther.M21 + M22 * oOther.M22;
double dM22 = M21 * oOther.M12 + M22 * oOther.M22;
double dDx = Dx * oOther.M11 + Dy * oOther.M21 + oOther.Dx;
double dDy = Dx * oOther.M21 + Dy * oOther.M22 + oOther.Dy;
double dDy = Dx * oOther.M12 + Dy * oOther.M22 + oOther.Dy;
M11 = dM11;
M12 = dM12;

View File

@ -434,6 +434,28 @@ namespace MetaFile
return *this;
}
CDataStream& operator>>(TEmfStretchBLT& oBitmap)
{
*this >> oBitmap.Bounds;
*this >> oBitmap.xDest;
*this >> oBitmap.yDest;
*this >> oBitmap.cxDest;
*this >> oBitmap.cyDest;
*this >> oBitmap.BitBltRasterOperation;
*this >> oBitmap.xSrc;
*this >> oBitmap.ySrc;
*this >> oBitmap.XformSrc;
*this >> oBitmap.BkColorSrc;
*this >> oBitmap.UsageSrc;
*this >> oBitmap.offBmiSrc;
*this >> oBitmap.cbBmiSrc;
*this >> oBitmap.offBitsSrc;
*this >> oBitmap.cbBitsSrc;
*this >> oBitmap.cxSrc;
*this >> oBitmap.cySrc;
return *this;
}
CDataStream& operator>>(TEmfSetDiBitsToDevice& oBitmap)
{
*this >> oBitmap.Bounds;

View File

@ -229,6 +229,7 @@ static const struct ActionNamesEmf
case EMR_BITBLT: Read_EMR_BITBLT(); break;
case EMR_STRETCHDIBITS: Read_EMR_STRETCHDIBITS(); break;
case EMR_SETDIBITSTODEVICE: Read_EMR_SETDIBITSTODEVICE(); break;
case EMR_STRETCHBLT: Read_EMR_STRETCHBLT(); break;
//-----------------------------------------------------------
// 2.3.2 Clipping
//-----------------------------------------------------------
@ -376,24 +377,8 @@ static const struct ActionNamesEmf
}
void CEmfFile::TranslatePoint(int nX, int nY, double& dX, double &dY)
{
TEmfWindow* pWindow = m_pDC->GetWindow();
TEmfWindow* pViewport = m_pDC->GetViewport();
dX = (double)((double)(nX - pWindow->lX) * m_pDC->GetPixelWidth()) + pViewport->lX;
dY = (double)((double)(nY - pWindow->lY) * m_pDC->GetPixelHeight()) + pViewport->lY;
// Координаты приходят уже с примененной матрицей. Поэтому сначала мы умножаем на матрицу преобразования,
// вычитаем начальные координаты и умножаем на обратную матрицу преобразования.
TRect* pBounds = GetDCBounds();
double dT = pBounds->nTop;
double dL = pBounds->nLeft;
TEmfXForm* pInverse = GetInverseTransform();
TEmfXForm* pTransform = GetTransform();
pTransform->Apply(dX, dY);
dX -= dL;
dY -= dT;
pInverse->Apply(dX, dY);
dX = (double)nX;
dY = (double)nY;
}
bool CEmfFile::ReadImage(unsigned int offBmi, unsigned int cbBmi, unsigned int offBits, unsigned int cbBits, unsigned int ulSkip, BYTE** ppBgraBuffer, unsigned int* pulWidth, unsigned int* pulHeight)
{
@ -943,6 +928,27 @@ static const struct ActionNamesEmf
if (pBgraBuffer)
delete[] pBgraBuffer;
}
void CEmfFile::Read_EMR_STRETCHBLT()
{
TEmfStretchBLT oBitmap;
m_oStream >> oBitmap;
BYTE* pBgraBuffer = NULL;
unsigned int ulWidth, ulHeight;
unsigned int unSkip = 108; // sizeof(TEmfStretchBLT) + 8 неправильно считает, из-з TXForm, там double, а в Emf они по 4 байта
if (ReadImage(oBitmap.offBmiSrc, oBitmap.cbBmiSrc, oBitmap.offBitsSrc, oBitmap.cbBitsSrc, unSkip, &pBgraBuffer, &ulWidth, &ulHeight))
{
if (m_pOutput)
{
ProcessRasterOperation(oBitmap.BitBltRasterOperation, &pBgraBuffer, ulWidth, ulHeight);
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
}
}
if (pBgraBuffer)
delete[] pBgraBuffer;
}
void CEmfFile::Read_EMR_EOF()
{
unsigned int ulCount, ulOffset, ulSizeLast;

View File

@ -142,7 +142,14 @@ namespace MetaFile
}
TXForm* GetTransform()
{
return m_pDC->GetTransform();
TRect* pBounds = GetDCBounds();
double dT = pBounds->nTop;
double dL = pBounds->nLeft;
TXForm oShiftXForm(1, 0, 0, 1, -dL, -dT);
m_oTransform.Copy(m_pDC->GetFinalTransform());
m_oTransform.Multiply(oShiftXForm, MWT_RIGHTMULTIPLY);
return &m_oTransform;
}
unsigned int GetMiterLimit()
{
@ -218,6 +225,7 @@ namespace MetaFile
void Read_EMR_STRETCHDIBITS();
void Read_EMR_BITBLT();
void Read_EMR_SETDIBITSTODEVICE();
void Read_EMR_STRETCHBLT();
void Read_EMR_EOF();
void Read_EMR_UNKNOWN();
void Read_EMR_SAVEDC();
@ -313,6 +321,7 @@ namespace MetaFile
CEmfDC* m_pDC;
CEmfPlayer m_oPlayer;
CEmfPath* m_pPath;
TEmfXForm m_oTransform;
friend class CEmfPlayer;
};

View File

@ -257,6 +257,7 @@ namespace MetaFile
m_oTransform.Init();
m_oInverseTransform.Init();
m_oTextColor.Init();
m_oFinalTransform.Init();
m_oBgColor.Init();
m_ulTextAlign = TA_TOP | TA_LEFT | TA_NOUPDATECP;
m_ulBgMode = TRANSPARENT;
@ -287,13 +288,14 @@ namespace MetaFile
pNewDC->m_pPalette = m_pPalette;
pNewDC->m_oTransform.Copy(&m_oTransform);
pNewDC->m_oInverseTransform.Copy(&m_oInverseTransform);
pNewDC->m_oFinalTransform.Copy(&m_oFinalTransform);
pNewDC->m_oTextColor.Copy(&m_oTextColor);
pNewDC->m_oBgColor.Copy(&m_oBgColor);
pNewDC->m_ulTextAlign = m_ulTextAlign;
pNewDC->m_ulBgMode = m_ulBgMode;
pNewDC->m_ulMiterLimit = m_ulMiterLimit;
pNewDC->m_ulFillMode = m_ulFillMode;
pNewDC->m_ulStretchMode = m_ulStretchMode;
pNewDC->m_ulStretchMode = m_ulStretchMode;
pNewDC->m_ulRop2Mode = m_ulRop2Mode;
pNewDC->m_dPixelHeight = m_dPixelHeight;
pNewDC->m_dPixelWidth = m_dPixelWidth;
@ -358,6 +360,8 @@ namespace MetaFile
break;
}
}
UpdateFinalTransform();
}
unsigned int CEmfDC::GetMapMode()
{
@ -371,6 +375,10 @@ namespace MetaFile
{
return &m_oInverseTransform;
}
TEmfXForm* CEmfDC::GetFinalTransform()
{
return &m_oFinalTransform;
}
void CEmfDC::MultiplyTransform(TEmfXForm& oForm, unsigned int ulMode)
{
m_oTransform.Multiply(oForm, ulMode);
@ -394,6 +402,8 @@ namespace MetaFile
m_oInverseTransform.M22 = pT->M22 / dDet;
m_oInverseTransform.Dx = pT->Dy * pT->M21 / dDet - pT->Dx * pT->M22 / dDet;
m_oInverseTransform.Dy = pT->Dx * pT->M12 / dDet - pT->Dy * pT->M11 / dDet;
UpdateFinalTransform();
}
void CEmfDC::SetTextColor(TEmfColor& oColor)
{
@ -511,12 +521,15 @@ namespace MetaFile
m_oWindow.lX = oPoint.x;
m_oWindow.lY = oPoint.y;
UpdatePixelMetrics();
UpdateFinalTransform();
}
void CEmfDC::SetWindowExtents(TEmfSizeL& oPoint)
{
m_oWindow.ulW = oPoint.cx;
m_oWindow.ulH = oPoint.cy;
UpdatePixelMetrics();
UpdateFinalTransform();
}
TEmfWindow* CEmfDC::GetWindow()
{
@ -527,12 +540,14 @@ namespace MetaFile
m_oViewport.lX = oPoint.x;
m_oViewport.lY = oPoint.y;
UpdatePixelMetrics();
UpdateFinalTransform();
}
void CEmfDC::SetViewportExtents(TEmfSizeL& oPoint)
{
m_oViewport.ulW = oPoint.cx;
m_oViewport.ulH = oPoint.cy;
UpdatePixelMetrics();
UpdateFinalTransform();
}
TEmfWindow* CEmfDC::GetViewport()
{
@ -561,6 +576,44 @@ namespace MetaFile
return true;
}
void CEmfDC::UpdateFinalTransform()
{
TEmfWindow* pWindow = GetWindow();
TEmfWindow* pViewPort = GetViewport();
int nWindowX = pWindow->lX;
int nWindowY = pWindow->lY;
double dPixelW = GetPixelWidth();
double dPixelH = GetPixelHeight();
// Вообще отрицательных высоты и ширины быть не должно, но если так встречается, то
// мы считаем, что это не перевернутая система координат, а просто сдвинутая
if (pWindow->ulH < 0)
{
if (dPixelH < 0)
dPixelH = -dPixelH;
nWindowY += pWindow->ulH;
}
if (pWindow->ulW < 0)
{
if (dPixelW < 0)
dPixelW = -dPixelW;
nWindowY += pWindow->ulW;
}
TEmfXForm oWindowXForm(1, 0, 0, 1, -nWindowX, -nWindowY);
TEmfXForm oViewportXForm(dPixelW, 0, 0, dPixelH, pViewPort->lX, pViewPort->lY);
m_oFinalTransform.Init();
m_oFinalTransform.Multiply(oWindowXForm, MWT_RIGHTMULTIPLY);
m_oFinalTransform.Multiply(m_oTransform, MWT_RIGHTMULTIPLY);
m_oFinalTransform.Multiply(oViewportXForm, MWT_RIGHTMULTIPLY);
}
void CEmfDC::SetRop2Mode(unsigned int& nMode)
{
m_ulRop2Mode = nMode;
@ -611,4 +664,4 @@ namespace MetaFile
{
return m_unArcDirection;
}
}
}

View File

@ -90,6 +90,7 @@ namespace MetaFile
unsigned int GetMapMode();
TEmfXForm* GetTransform();
TEmfXForm* GetInverseTransform();
TEmfXForm* GetFinalTransform();
void MultiplyTransform(TEmfXForm& oForm, unsigned int ulMode);
void SetTextColor(TEmfColor& oColor);
TEmfColor& GetTextColor();
@ -140,6 +141,7 @@ namespace MetaFile
void SetPixelWidth(double dPixelW);
void SetPixelHeight(double dPixelH);
bool UpdatePixelMetrics();
void UpdateFinalTransform();
private:
@ -150,6 +152,7 @@ namespace MetaFile
CEmfLogPalette* m_pPalette;
TEmfXForm m_oTransform;
TEmfXForm m_oInverseTransform;
TEmfXForm m_oFinalTransform;
TEmfColor m_oTextColor;
TEmfColor m_oBgColor;
unsigned int m_ulTextAlign;

View File

@ -402,6 +402,7 @@ namespace MetaFile
int cyDest;
};
#define TEmfXForm TXForm
//struct TEmfXForm
//{
@ -487,6 +488,27 @@ namespace MetaFile
// }
//};
struct TEmfStretchBLT
{
TEmfRectL Bounds;
int xDest;
int yDest;
int cxDest;
int cyDest;
unsigned int BitBltRasterOperation;
int xSrc;
int ySrc;
TXForm XformSrc;
TEmfColor BkColorSrc;
unsigned int UsageSrc;
unsigned int offBmiSrc;
unsigned int cbBmiSrc;
unsigned int offBitsSrc;
unsigned int cbBitsSrc;
int cxSrc;
int cySrc;
};
struct TEmfEmrText
{
TEmfPointL Reference;

View File

@ -388,7 +388,7 @@ bool EncryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYP
CFB_Mode<Blowfish>::Encryption encryption(key.ptr, key.size, iv.ptr);
encryption.ProcessData(data_out.ptr, data_inp.ptr, data_inp.size);
}
else if (algorithm == CRYPT_METHOD::DES)
else if (algorithm == CRYPT_METHOD::DES_CBC)
{
DES::Encryption desEncryption(key.ptr, key.size == 7 ? 8 : key.size);
StreamTransformation *modeEncryption = new CipherModeFinalTemplate_ExternalCipher<CBC_Encryption>(desEncryption, iv.ptr );
@ -403,6 +403,21 @@ bool EncryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRYP
delete modeEncryption;
}
else if (algorithm == CRYPT_METHOD::DES_ECB)
{
DES::Encryption desEncryption(key.ptr, key.size == 7 ? 8 : key.size);
StreamTransformation *modeEncryption = new CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>(desEncryption, iv.ptr );
if (!data_out.ptr)
{
data_out = _buf(data_inp.size);
}
StreamTransformationFilter stfEncryption(*modeEncryption, new ArraySink( data_out.ptr, data_out.size), padding);
stfEncryption.Put( data_inp.ptr, data_inp.size );
stfEncryption.MessageEnd();
delete modeEncryption;
}
else //AES
{
StreamTransformation *modeEncryption = NULL;
@ -463,7 +478,7 @@ bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRY
CFB_Mode<Blowfish>::Decryption decryption(key.ptr, key.size, iv.ptr);
decryption.ProcessData(data_out.ptr, data_inp.ptr, data_inp.size);
}
else if (algorithm == CRYPT_METHOD::DES)
else if (algorithm == CRYPT_METHOD::DES_CBC)
{
DES::Decryption desDecryption(key.ptr, key.size == 7 ? 8 : key.size);
StreamTransformation *modeDecryption = new CipherModeFinalTemplate_ExternalCipher<CBC_Decryption>(desDecryption, iv.ptr );
@ -474,6 +489,17 @@ bool DecryptCipher(_buf & key, _buf & iv, _buf & data_inp, _buf & data_out, CRY
delete modeDecryption;
}
else if (algorithm == CRYPT_METHOD::DES_ECB)
{
DES::Decryption desDecryption(key.ptr, key.size == 7 ? 8 : key.size);
StreamTransformation *modeDecryption = new CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>(desDecryption, iv.ptr );
StreamTransformationFilter stfDecryptor(*modeDecryption, new ArraySink( data_out.ptr, data_out.size), padding);
stfDecryptor.Put( data_inp.ptr, data_inp.size );
stfDecryptor.MessageEnd();
delete modeDecryption;
}
else //AES
{
StreamTransformation *modeDecryption = NULL;

View File

@ -56,7 +56,8 @@ namespace CRYPT_METHOD
AES_CFB,
AES_ECB,
Blowfish_CFB,
DES
DES_CBC,
DES_ECB
};
}
namespace CRYPT

View File

@ -298,7 +298,7 @@ bool ReadXmlEncryptionInfo(const std::string & xml_string, _ecmaCryptData & cryp
}
else if (keyData.cipherAlgorithm == "DES")
{
cryptData.cipherAlgorithm = CRYPT_METHOD::DES;
cryptData.cipherAlgorithm = CRYPT_METHOD::DES_ECB;
}
if (keyData.hashAlgorithm == "SHA1") cryptData.hashAlgorithm = CRYPT_METHOD::SHA1;
if (keyData.hashAlgorithm == "SHA224") cryptData.hashAlgorithm = CRYPT_METHOD::SHA224;
@ -339,10 +339,16 @@ bool WriteXmlEncryptionInfo(const _ecmaCryptData & cryptData, std::string & xml_
case CRYPT_METHOD::AES_CFB:
keyData.cipherAlgorithm = "AES";
keyData.cipherChaining = "ChainingModeCFB";
case CRYPT_METHOD::DES:
break;
case CRYPT_METHOD::DES_CBC:
keyData.cipherAlgorithm = "DES";
keyData.cipherChaining = "ChainingModeCBC";
break;
case CRYPT_METHOD::DES_ECB:
keyData.cipherAlgorithm = "DES";
keyData.cipherChaining = "ChainingModeECB";
break;
break;
}
@ -608,7 +614,12 @@ bool ECMACryptFile::EncryptOfficeFile(const std::wstring &file_name_inp, const s
_ecmaCryptData cryptData;
//cryptData.bAgile = true;
//cryptData.cipherAlgorithm = CRYPT_METHOD::DES;
//cryptData.cipherAlgorithm = CRYPT_METHOD::DES_ECB;
//cryptData.hashAlgorithm = CRYPT_METHOD::SHA512;
//cryptData.keySize = 0x08;
//cryptData.hashSize = 0x40;
//cryptData.blockSize = 0x10;
//cryptData.saltSize = 0x10;
//cryptData.hashAlgorithm = CRYPT_METHOD::SHA1;
//cryptData.keySize = 0x08;
//cryptData.hashSize = 0x14;

View File

@ -46,7 +46,7 @@ namespace NSUnicodeConverter
const char* DisplayName;
};
#define UNICODE_CONVERTER_ENCODINGS_COUNT 52
#define UNICODE_CONVERTER_ENCODINGS_COUNT 53
static const EncodindId Encodings[UNICODE_CONVERTER_ENCODINGS_COUNT] =
{
{ 0, 28596, "ISO-8859-6", "Arabic (ISO 8859-6)" },
@ -118,7 +118,9 @@ namespace NSUnicodeConverter
{ 49, 1201, "UTF-16BE", "Unicode (UTF-16 Big Endian)" },
{ 50, 12000, "UTF-32LE", "Unicode (UTF-32)" },
{ 51, 12001, "UTF-32BE", "Unicode (UTF-32 Big Endian)" }
{ 51, 12001, "UTF-32BE", "Unicode (UTF-32 Big Endian)" },
{ 52, 950, "EUC-JP", "Japanese (EUC-JP)" }
};
static std::map<int, std::string> create_mapEncodingsICU()
@ -161,6 +163,7 @@ namespace NSUnicodeConverter
m[1255] = "windows-1255";
m[932] = "Shift_JIS";
m[950] = "EUC-JP";
m[949] = "KS_C_5601-1987";
m[51949] = "EUC-KR";