From 7df5ff1aebcfe007649565d4966e914367c465fd Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Tue, 27 Mar 2018 16:43:48 +0300 Subject: [PATCH] DocFormatReader - add word doc without compound storage(earlier 1995) --- .../DocDocxConverter/AnnotationOwnerList.h | 2 +- .../AnnotationReferenceDescriptor.cpp | 2 +- .../AnnotationReferenceDescriptor.h | 4 +- .../DocDocxConverter/BorderCode.h | 66 +- .../CharacterPropertyExceptions.h | 116 +- .../DocDocxConverter/CommentsMapping.h | 2 +- .../DocDocxConverter/DocumentMapping.cpp | 107 +- .../DocDocxConverter/DocumentProperties.cpp | 2 +- .../DocDocxConverter/EncryptionHeader.cpp | 4 +- .../DocDocxConverter/EndnotesMapping.h | 2 +- .../DocDocxConverter/FileInformationBlock.h | 1421 +++++++++-------- .../DocDocxConverter/FontFamilyName.cpp | 22 +- .../DocDocxConverter/FooterMapping.cpp | 2 +- .../DocDocxConverter/FootnotesMapping.h | 2 +- .../DocDocxConverter/FormFieldData.cpp | 4 +- .../DocDocxConverter/FormFieldData.h | 2 +- .../FormattedDiskPageCHPX.cpp | 12 +- .../DocDocxConverter/FormattedDiskPageCHPX.h | 2 +- .../FormattedDiskPagePAPX.cpp | 101 +- .../DocDocxConverter/FormattedDiskPagePAPX.h | 2 +- ASCOfficeDocFile/DocDocxConverter/Global.h | 23 +- .../DocDocxConverter/HeaderAndFooterTable.cpp | 4 +- .../DocDocxConverter/HeaderMapping.cpp | 2 +- .../ListFormatOverrideTable.h | 2 +- .../DocDocxConverter/ListLevel.cpp | 4 +- .../DocDocxConverter/ListTable.cpp | 2 +- .../DocDocxConverter/MainDocumentMapping.cpp | 2 +- .../DocDocxConverter/MemoryStream.h | 2 +- .../DocDocxConverter/NumberingMapping.cpp | 6 +- .../DocDocxConverter/NumberingMapping.h | 2 +- .../DocDocxConverter/OfficeArtContent.h | 2 +- .../OfficeDrawing/MetafilePictBlip.h | 43 - .../DocDocxConverter/OleObject.cpp | 353 ++-- ASCOfficeDocFile/DocDocxConverter/OleObject.h | 17 +- .../DocDocxConverter/OleObjectMapping.h | 37 +- .../DocDocxConverter/OpenXmlPackage.cpp | 92 +- .../DocDocxConverter/OpenXmlPackage.h | 11 +- .../DocDocxConverter/ParagraphHeight.cpp | 30 +- .../ParagraphPropertyExceptions.cpp | 96 +- .../ParagraphPropertyExceptions.h | 2 +- .../DocDocxConverter/PictureDescriptor.cpp | 12 +- .../DocDocxConverter/PictureDescriptor.h | 6 +- ASCOfficeDocFile/DocDocxConverter/Plex.h | 4 +- .../DocDocxConverter/PropertyExceptions.cpp | 58 +- .../DocDocxConverter/PropertyExceptions.h | 5 +- .../SectionPropertyExceptions.h | 4 +- .../SinglePropertyModifier.cpp | 30 +- .../DocDocxConverter/SinglePropertyModifier.h | 7 +- ASCOfficeDocFile/DocDocxConverter/Spa.cpp | 4 +- ASCOfficeDocFile/DocDocxConverter/Spa.h | 4 +- .../DocDocxConverter/StringTable.h | 49 +- .../DocDocxConverter/StyleSheet.cpp | 137 +- .../StyleSheetDescription.cpp | 40 +- .../DocDocxConverter/StyleSheetDescription.h | 5 +- .../StyleSheetInformation.cpp | 3 +- .../DocDocxConverter/StyleSheetMapping.cpp | 55 +- ASCOfficeDocFile/DocDocxConverter/TableInfo.h | 8 +- .../DocDocxConverter/TableMapping.cpp | 16 +- .../TablePropertyExceptions.h | 10 +- .../DocDocxConverter/TextboxMapping.cpp | 2 +- .../DocDocxConverter/VMLPictureMapping.cpp | 26 +- .../DocDocxConverter/VMLShapeMapping.cpp | 2 +- .../DocDocxConverter/VMLShapeMapping.h | 1 - .../DocDocxConverter/VirtualStreamReader.h | 9 +- .../DocDocxConverter/WideString.h | 2 +- .../DocDocxConverter/WordDocument.cpp | 209 ++- .../DocDocxConverter/WordDocument.h | 11 +- .../WordprocessingDocument.cpp | 2 +- .../DocFormatTest/DocFormatTest.cpp | 9 + Common/OfficeFileFormatChecker.h | 2 + Common/OfficeFileFormatChecker2.cpp | 32 +- Common/OfficeFileFormats.h | 3 +- 72 files changed, 2040 insertions(+), 1336 deletions(-) diff --git a/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h b/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h index acaff00a4a..ece0de88ad 100644 --- a/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h +++ b/ASCOfficeDocFile/DocDocxConverter/AnnotationOwnerList.h @@ -41,7 +41,7 @@ namespace DocFileFormat public: AnnotationOwnerList(FileInformationBlock* fib, POLE::Stream* tableStream) : std::vector() { - VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_bOlderVersion); + VirtualStreamReader reader(tableStream, fib->m_FibWord97.fcGrpXstAtnOwners, fib->m_nWordVersion); if (fib->m_FibWord97.fcGrpXstAtnOwners > reader.GetSize()) return; diff --git a/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp b/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp index 7d0ce4396a..d08ee2b6e8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.cpp @@ -40,7 +40,7 @@ namespace DocFileFormat //read the user initials (LPXCharBuffer9) - if (reader->olderVersion) + if (reader->nWordVersion > 0) { short cch = reader->ReadByte(); diff --git a/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.h b/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.h index f24cf734b6..4a6f5fb4ab 100644 --- a/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.h +++ b/ASCOfficeDocFile/DocDocxConverter/AnnotationReferenceDescriptor.h @@ -41,9 +41,9 @@ namespace DocFileFormat static const int STRUCTURE_SIZE = 30; static const int STRUCTURE_SIZE_OLD = 20; - static const int GetSize(bool bOldVersion) + static const int GetSize(int nWordVersion) { - return bOldVersion ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE; + return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE; } inline std::wstring GetUserInitials() const diff --git a/ASCOfficeDocFile/DocDocxConverter/BorderCode.h b/ASCOfficeDocFile/DocDocxConverter/BorderCode.h index f04bc1b97c..9dae071669 100644 --- a/ASCOfficeDocFile/DocDocxConverter/BorderCode.h +++ b/ASCOfficeDocFile/DocDocxConverter/BorderCode.h @@ -118,70 +118,78 @@ namespace DocFileFormat public: /// Creates a new BorderCode with default values - BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) + BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) { } /// Parses the unsigned char for a BRC BorderCode( unsigned char* bytes, int size ): - cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) + cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) { if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) ) { - this->fNil = true; + fNil = true; } else if ( size == 8 ) { //it's a border code of Word 2000/2003 - this->cv = FormatUtils::BytesToInt32( bytes, 0, size ); - this->ico = std::wstring( Global::ColorIdentifier[0] ); + cv = FormatUtils::BytesToInt32( bytes, 0, size ); + ico = std::wstring( Global::ColorIdentifier[0] ); - this->dptLineWidth = bytes[4]; - this->brcType = bytes[5]; + dptLineWidth = bytes[4]; + brcType = bytes[5]; short val = FormatUtils::BytesToInt16( bytes, 6, size ); - this->dptSpace = val & 0x001F; + dptSpace = val & 0x001F; //not sure if this is correct, the values from the spec are definitly wrong: - this->fShadow = FormatUtils::BitmaskToBool( val, 0x20 ); - this->fFrame = FormatUtils::BitmaskToBool( val, 0x40 ); + fShadow = FormatUtils::BitmaskToBool( val, 0x20 ); + fFrame = FormatUtils::BitmaskToBool( val, 0x40 ); } else if ( size == 4 ) { - //it's a border code of Word 97 unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size ); - this->dptLineWidth = (unsigned char)( val & 0x00FF ); - this->brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 ); + + dptLineWidth = (unsigned char)( val & 0x00FF ); + brcType = (unsigned char)( ( val & 0xFF00 ) >> 8 ); + val = FormatUtils::BytesToUInt16( bytes, 2, size ); - this->ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorIdentifier[0][0], 17, 12 ); - this->dptSpace = ( val & 0x1F00 ) >> 8; + + ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorNameIdentifier[0][0], 17, 12 ); + dptSpace = ( val & 0x1F00 ) >> 8; } - else + else if (size == 2) { - //throw new ByteParseException("Cannot parse the struct BRC, the length of the struct doesn't match"); + unsigned short val = FormatUtils::BytesToUInt16( bytes, 0, size ); + + dptLineWidth = GETBITS(val, 0, 2); + brcType = GETBITS(val, 3, 4); + fShadow = GETBIT(val, 5); + ico = FormatUtils::MapValueToWideString(GETBITS(val, 6, 10), &Global::ColorNameIdentifier[0][0], 17, 12 ); + dptSpace = GETBITS(val, 11, 15); + } } - BorderCode( const BorderCode& bc ) { if ( this != &bc ) { - this->cv = bc.cv; - this->dptLineWidth = bc.dptLineWidth; - this->brcType = bc.brcType; - this->ico = bc.ico; - this->dptSpace = bc.dptSpace; - this->fShadow = bc.fShadow; - this->fFrame = bc.fFrame; - this->fNil = bc.fNil; + cv = bc.cv; + dptLineWidth = bc.dptLineWidth; + brcType = bc.brcType; + ico = bc.ico; + dptSpace = bc.dptSpace; + fShadow = bc.fShadow; + fFrame = bc.fFrame; + fNil = bc.fNil; } } bool operator == ( const BorderCode& bc ) { - if ( ( this->cv == bc.cv ) && ( this->dptLineWidth == bc.dptLineWidth ) && ( this->brcType == bc.brcType ) && - ( this->ico == bc.ico ) && ( this->dptSpace == bc.dptSpace ) && ( this->fShadow == bc.fShadow ) && - ( this->fFrame == bc.fFrame ) && ( this->fNil == bc.fNil ) ) + if ( ( cv == bc.cv ) && ( dptLineWidth == bc.dptLineWidth ) && ( brcType == bc.brcType ) && + ( ico == bc.ico ) && ( dptSpace == bc.dptSpace ) && ( fShadow == bc.fShadow ) && + ( fFrame == bc.fFrame ) && ( fNil == bc.fNil ) ) { return true; } diff --git a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h index 1e21688b35..674607f0fd 100644 --- a/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/CharacterPropertyExceptions.h @@ -35,19 +35,107 @@ namespace DocFileFormat { - class CharacterPropertyExceptions: public PropertyExceptions - { - public: - /// Creates a CHPX wich doesn't modify anything. - /// The grpprl list is empty - CharacterPropertyExceptions(): PropertyExceptions() - { - } + class CharacterPropertyExceptions: public PropertyExceptions + { + public: + /// Creates a CHPX wich doesn't modify anything. + /// The grpprl list is empty + CharacterPropertyExceptions(): PropertyExceptions() + { + } - /// Parses the bytes to retrieve a CHPX - CharacterPropertyExceptions( unsigned char* bytes, int size, bool oldVersion) : - PropertyExceptions( bytes, size, oldVersion ) - { - } - }; + /// Parses the bytes to retrieve a CHPX + CharacterPropertyExceptions( unsigned char* bytes, int size, int nWordVersion) : + PropertyExceptions( bytes, size, nWordVersion ) + { + if (nWordVersion == 2 && size > 0) + { + RELEASEOBJECT( grpprl ); + grpprl = new std::list(); + + MemoryStream oStream(bytes, size); + int pos = 0; + + if (pos + 2 > size) return; + unsigned short fChar = oStream.ReadUInt16(); pos += 2; + + unsigned char val; + val = GETBIT(fChar, 0); grpprl->push_back(SinglePropertyModifier(sprmOldCFBold, 1, &val)); + val = GETBIT(fChar, 1); grpprl->push_back(SinglePropertyModifier(sprmOldCFItalic, 1, &val)); + val = GETBIT(fChar, 2); grpprl->push_back(SinglePropertyModifier(sprmOldCFStrike, 1, &val)); + val = GETBIT(fChar, 3); grpprl->push_back(SinglePropertyModifier(sprmOldCFOutline, 1, &val)); + val = GETBIT(fChar, 4); grpprl->push_back(SinglePropertyModifier(sprmOldCFFldVanish, 1, &val)); + val = GETBIT(fChar, 5); grpprl->push_back(SinglePropertyModifier(sprmOldCFSmallCaps, 1, &val)); + val = GETBIT(fChar, 6); grpprl->push_back(SinglePropertyModifier(sprmOldCFCaps, 1, &val)); + val = GETBIT(fChar, 7); grpprl->push_back(SinglePropertyModifier(sprmOldCFVanish, 1, &val)); + val = GETBIT(fChar, 8); grpprl->push_back(SinglePropertyModifier(sprmOldCFRMark, 1, &val)); + val = GETBIT(fChar, 9); grpprl->push_back(SinglePropertyModifier(sprmOldCFSpec, 1, &val)); + + bool fsIco = GETBIT(fChar, 10); + bool fsFtc = GETBIT(fChar, 11); + bool fsHps = GETBIT(fChar, 12); + bool fsKul = GETBIT(fChar, 13); + bool fsPos = GETBIT(fChar, 14); + bool fsSpace = GETBIT(fChar, 15); + + if (pos + 2 > size) return; + int fff = oStream.ReadUInt16(); pos += 2;//????? + + if (pos + 2 > size) return; + unsigned short ftc = oStream.ReadUInt16(); pos += 2; // Font Code + grpprl->push_back(SinglePropertyModifier(sprmOldCFtc, 2, (unsigned char*)&ftc)); + + if (pos + 1 > size) return; + unsigned char hps = oStream.ReadByte(); pos += 1; // Font size in half points + + if (hps > 0) + { + grpprl->push_back(SinglePropertyModifier(sprmOldCHps, 1, &hps)); + } + + if (pos + 1 > size) return; + unsigned char hpsPos = oStream.ReadByte(); pos += 1; // Sub/Superscript ( signed number, 0 = normal ) + grpprl->push_back(SinglePropertyModifier(sprmOldCHpsPos, 1, &hpsPos)); + + if (pos + 2 > size) return; + unsigned short fText = oStream.ReadUInt16(); pos += 2; + + unsigned short qpsSpace = GETBITS(fText, 0, 5); + unsigned char wSpare2 = GETBITS(fText, 6, 7); + unsigned char ico = GETBITS(fText, 8, 11); + unsigned char kul = GETBITS(fText, 12, 14); + bool fSysVanish = GETBIT(fChar, 15); + + //if (fsKul) + { + grpprl->push_back(SinglePropertyModifier(sprmOldCKul, 1, &kul)); + } + //if (fsIco) + { + grpprl->push_back(SinglePropertyModifier(sprmOldCIco, 1, &ico)); + } + if (pos + 2 > size) return; + unsigned int xxx = oStream.ReadUInt16(); pos += 2;// ??? + + if (pos + 2 > size) return; + unsigned int yyy = oStream.ReadUInt16(); pos += 2;// ??? + + if (pos + 2 > size) return; + unsigned int fcPic = oStream.ReadUInt16(); pos += 2; + grpprl->push_back(SinglePropertyModifier(sprmOldCPicLocation, 4, (BYTE*)&fcPic)); + + if (pos + 2 > size) return; + unsigned short zzz = oStream.ReadUInt16(); pos += 2;// ??? type + + //if (pos + 2 > size) return; + //unsigned short dx = oStream.ReadUInt16(); pos += 2;// ??? + // + //if (pos + 2 > size) return; + //unsigned short dy = oStream.ReadUInt16(); pos += 2;// ??? + + //short scale_complex[6] = {dx, dy, 0, 0, 0, 0}; + //grpprl->push_back(SinglePropertyModifier(sprmOldPicScale, 12, (BYTE*)scale_complex)); + } + } + }; } \ No newline at end of file diff --git a/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h b/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h index 3894922c10..423045c0f8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h @@ -95,7 +95,7 @@ namespace DocFileFormat if (fc < 0) break; ParagraphPropertyExceptions* papx = findValidPapx(fc); - TableInfo tai(papx); + TableInfo tai(papx, m_document->nWordVersion); if ( tai.fInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index 2089bdb097..8a3ceb18a7 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -89,6 +89,11 @@ namespace DocFileFormat //if cp is the last char of a section, the next section will start at cp +1 size_t current = 0; + if (m_document->SectionPlex->CharacterPositions.empty()) + { + return cp; + } + for (std::vector::iterator iter = m_document->SectionPlex->CharacterPositions.begin() + 1; iter != m_document->SectionPlex->CharacterPositions.end(); ++iter) { if (cp < *iter) @@ -533,8 +538,7 @@ namespace DocFileFormat } else if (TextMark::PageBreakOrSectionMark == code) { - //write page break, section breaks are written by writeParagraph() method - if (/*!isSectionEnd(c)*/_isSectionPageBreak == 0) + if (_isSectionPageBreak == 0) { writeTextElement(text, textType); @@ -571,20 +575,21 @@ namespace DocFileFormat std::vector arField; boost::algorithm::split(arField, sFieldString, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on); - std::wstring EMBED ( L" EMBED" ); - std::wstring LINK ( L" LINK" ); - std::wstring FORM ( L" FORM" ); - std::wstring Excel ( L" Excel" ); - std::wstring Word ( L" Word" ); - std::wstring opendocument(L" opendocument" ); - std::wstring Equation ( L" Equation" ); - std::wstring MERGEFORMAT( L" MERGEFORMAT" ); - std::wstring QUOTE ( L" QUOTE" ); + std::wstring EMBED ( L"EMBED" ); + std::wstring embed ( L"embed" ); + std::wstring LINK ( L"LINK" ); + std::wstring FORM ( L"FORM" ); + std::wstring Excel ( L"Excel" ); + std::wstring Word ( L"Word" ); + std::wstring opendocument(L"opendocument" ); + std::wstring Equation ( L"Equation" ); + std::wstring MERGEFORMAT( L"MERGEFORMAT" ); + std::wstring QUOTE ( L"QUOTE" ); std::wstring chart ( L"Chart" ); - std::wstring PBrush ( L" PBrush" ); - std::wstring TOC ( L" TOC" ); - std::wstring HYPERLINK ( L" HYPERLINK" ); - std::wstring PAGEREF ( L" PAGEREF" ); + std::wstring PBrush ( L"PBrush" ); + std::wstring TOC ( L"TOC" ); + std::wstring HYPERLINK ( L"HYPERLINK" ); + std::wstring PAGEREF ( L"PAGEREF" ); std::wstring PAGE ( L"PAGE" ); if (arField.empty() == false) @@ -593,7 +598,8 @@ namespace DocFileFormat f = sFieldString; bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end(); - bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end(); + bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end() || + search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end(); bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end(); bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end(); bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end(); @@ -687,13 +693,6 @@ namespace DocFileFormat } else { - //while ( cpFieldSep2 < cpFieldEnd) - //{ - // cpFieldSep2 = searchNextTextMark(m_document->Text, cpFieldSep1 + 1, TextMark::FieldSeparator); - // std::wstring f1( ( m_document->Text->begin() + cpFieldSep1 ), ( m_document->Text->begin() + cpFieldSep2 + 1 ) ); - // toc.push_back(f1); - // - // if (search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end()) for (size_t i = 1; i < arField.size(); i++) { std::wstring f1 = arField[1]; @@ -746,9 +745,9 @@ namespace DocFileFormat if (!m_shapeIdOwner.empty()) //4571833.doc oVmlMapper.m_shapeId = m_shapeIdOwner; - if (m_document->bOlderVersion) - { - OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion); + if (m_document->nWordVersion > 0) + { + OleObject ole ( chpxObj, m_document); oleWriter.WriteNodeBegin (L"w:object", true); oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) )); @@ -764,7 +763,7 @@ namespace DocFileFormat } else { - PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion); + PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion); oleWriter.WriteNodeBegin (L"w:object", true); oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) ); @@ -782,7 +781,7 @@ namespace DocFileFormat std::list* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) ); CharacterPropertyExceptions* chpxSep = chpxs->front(); - OleObject ole ( chpxSep, m_document->GetStorage(), m_document->bOlderVersion); + OleObject ole ( chpxSep, m_document); OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId ); if (oVmlMapper.m_isEmbedded) @@ -891,7 +890,7 @@ namespace DocFileFormat if (pSpa) { - PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion); + PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->nWordVersion); ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID()); if (pShape) @@ -913,9 +912,9 @@ namespace DocFileFormat } } } - else if ((TextMark::Picture == code) && fSpec ) + else if (TextMark::Picture == code && fSpec) { - PictureDescriptor oPicture (chpx, m_document->bOlderVersion ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->bOlderVersion); + PictureDescriptor oPicture (chpx, m_document->nWordVersion > 0 ? m_document->WordDocumentStream : m_document->DataStream, 0x7fffffff, m_document->nWordVersion); bool isInline = _isTextBoxContent; @@ -951,7 +950,7 @@ namespace DocFileFormat if (oVmlMapper.m_isEmbedded) { - OleObject ole ( chpx, m_document->GetStorage(), m_document->bOlderVersion); + OleObject ole ( chpx, m_document); OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId ); ole.isEquation = oVmlMapper.m_isEquation; @@ -1212,7 +1211,8 @@ namespace DocFileFormat int fc2 = m_document->FindFileCharPos( cp ); int fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + + TableInfo tai( papx, m_document->nWordVersion ); //build the table grid std::vector grid, grid_write; @@ -1221,7 +1221,7 @@ namespace DocFileFormat //find first row end int fcRowEnd = findRowEndFc( cp, nestingLevel ); - TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion); + TablePropertyExceptions row1Tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion); //start table m_pXmlWriter->WriteNodeBegin( L"w:tbl" ); @@ -1244,7 +1244,7 @@ namespace DocFileFormat //?fc = m_document->FindFileCharPos(cp ); fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); } } else @@ -1257,7 +1257,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); } } @@ -1279,7 +1279,7 @@ namespace DocFileFormat int fc = m_document->FindFileCharPos( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); int fcRowEnd = findRowEndFc( cp, cp, nestingLevel ); ParagraphPropertyExceptions* papx_prev = NULL; @@ -1333,7 +1333,7 @@ namespace DocFileFormat //get the next papx papx = findValidPapx( fcRowEnd ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); fcRowEnd = findRowEndFc( cp, cp, nestingLevel ); if (papx_prev && papx_prev == papx ) @@ -1370,7 +1370,7 @@ namespace DocFileFormat int fc = m_document->FindFileCharPos( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( nestingLevel > 1 ) { @@ -1386,7 +1386,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); cp++; } @@ -1409,7 +1409,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); cp++; } } @@ -1428,7 +1428,7 @@ namespace DocFileFormat int fc = m_document->FindFileCharPos( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( nestingLevel > 1 ) { @@ -1448,7 +1448,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); cp++; } @@ -1471,7 +1471,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); cp++; } } @@ -1486,14 +1486,14 @@ namespace DocFileFormat int fc = m_document->FindFileCharPos( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); //start w:tr m_pXmlWriter->WriteNodeBegin( L"w:tr" ); //convert the properties int fcRowEnd = findRowEndFc( cp, nestingLevel ); - TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->bOlderVersion); + TablePropertyExceptions tapx( findValidPapx( fcRowEnd ), m_document->DataStream, m_document->nWordVersion); std::list* chpxs = m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); TableRowPropertiesMapping* trpMapping = new TableRowPropertiesMapping( m_pXmlWriter, *(chpxs->begin()) ); @@ -1517,7 +1517,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos(cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); } } else @@ -1534,7 +1534,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); } } @@ -1576,7 +1576,7 @@ namespace DocFileFormat int fc = m_document->FindFileCharPos( cp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); //cp = writeParagraph(cp); @@ -1615,7 +1615,7 @@ namespace DocFileFormat int fc = m_document->FindFileCharPos( initialCp ); ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); while ( !tai.fInnerTableCell ) { @@ -1624,7 +1624,7 @@ namespace DocFileFormat fc = m_document->FindFileCharPos( cpCellEnd ); papx = findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, m_document->nWordVersion ); } cpCellEnd++; @@ -1821,6 +1821,11 @@ namespace DocFileFormat { SectionPropertyExceptions* ret = NULL; + if (!m_document->AllSepx) + { + return ret; + } + try { ret = m_document->AllSepx->operator [](cp); diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp index f4684de08a..214f887dc9 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentProperties.cpp @@ -48,7 +48,7 @@ namespace DocFileFormat { Initialize(); - VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop, fib->m_bOlderVersion); + VirtualStreamReader tStream( tableStream, fib->m_FibWord97.fcDop, fib->m_nWordVersion); //setDefaultCompatibilityOptions( fib->m_FibBase.nFib ); diff --git a/ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp b/ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp index 5d2ee797c7..c506670a0c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/EncryptionHeader.cpp @@ -37,9 +37,9 @@ namespace DocFileFormat { EncryptionHeader::EncryptionHeader( FileInformationBlock* fib, POLE::Stream* tableStream ) : bStandard(false), bXOR(false), bAES(false) { - VirtualStreamReader tStream( tableStream, 0, fib->m_bOlderVersion); + VirtualStreamReader tStream( tableStream, 0, fib->m_nWordVersion); - if (fib->m_FibBase.fObfuscation || fib->m_bOlderVersion) + if (fib->m_FibBase.fObfuscation || fib->m_nWordVersion > 0) { bXOR = true; diff --git a/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h b/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h index 048024ac3e..9fc3582b23 100644 --- a/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/EndnotesMapping.h @@ -79,7 +79,7 @@ namespace DocFileFormat if (fc < 0) break; ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( tai.fInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h b/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h index d08a66ab40..2b6532bfc5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h +++ b/ASCOfficeDocFile/DocDocxConverter/FileInformationBlock.h @@ -38,8 +38,13 @@ namespace DocFileFormat { typedef enum FibVersion { + Fib1983 = 0x002d, // WinWord 2 + Fib1985 = 0x003F, // +//--------------------------------------------------------- + Fib1989 = 0x0045, // Fib1993 = 0x0065, // Word 6.0 Fib1995 = 0x0068, // Word 7.0 (95) +//--------------------------------------------------------- Fib1996 = 0x0069, // Word 8.0 (97) Fib1997 = 0x00C1, Fib2000 = 0x00D9, @@ -92,408 +97,397 @@ namespace DocFileFormat typedef struct RgLw97 { - RgLw97() : cbMac(0), ccpText(0), ccpFtn(0), ccpHdr(0), ccpAtn(0), ccpEdn(0), ccpTxbx(0), ccpHdrTxbx(0) {} -//---------------------- - int cbMac; - int ccpText; - int ccpFtn; - int ccpHdr; - int ccpAtn; - int ccpEdn; - int ccpTxbx; - int ccpHdrTxbx; + int cbMac = 0; + int ccpText = 0; + int ccpFtn = 0; + int ccpHdr = 0; + int ccpAtn = 0; + int ccpEdn = 0; + int ccpTxbx = 0; + int ccpHdrTxbx = 0; } RgLw97; + + typedef struct FibWord2 + { + unsigned int Spare = 0; + unsigned char rgwSpare0[3]; + + unsigned int fcPlcMcr = 0; + unsigned int lcbPlcMcr = 0; + + unsigned int fcPrEnv = 0; + unsigned int lcbPrEnv = 0; + + unsigned int fcSpare5 = 0; + unsigned int lcbSpare5 = 0; + unsigned int fcSpare6 = 0; + unsigned int lcbSpare6 = 0; + unsigned int wSpare4 = 0; + + unsigned int pnChpFirst = 0; + unsigned int pnPapFirst = 0; + unsigned int cpnBteChp = 0; + unsigned int cpnBtePap = 0; + } FibWord2; typedef struct FibWord97 { - FibWord97() : - fcStshfOrig (0), lcbStshfOrig (0), fcStshf (0), lcbStshf (0), fcPlcffndRef (0), lcbPlcffndRef (0), - fcPlcffndTxt (0), lcbPlcffndTxt (0), fcPlcfandRef (0), lcbPlcfandRef (0), fcPlcfandTxt (0), lcbPlcfandTxt (0), - fcPlcfSed (0), lcbPlcfSed (0), fcPlcPad (0), lcbPlcPad (0), fcPlcfPhe (0), lcbPlcfPhe (0), - fcSttbfGlsy (0), lcbSttbfGlsy (0), fcPlcfGlsy (0), lcbPlcfGlsy (0), fcPlcfHdd (0), lcbPlcfHdd (0), - fcPlcfBteChpx (0), lcbPlcfBteChpx (0), fcPlcfBtePapx (0), lcbPlcfBtePapx (0), fcPlcfSea (0), lcbPlcfSea (0), - fcSttbfFfn (0), lcbSttbfFfn (0), fcPlcfFldMom (0), lcbPlcfFldMom (0), fcPlcfFldHdr (0), lcbPlcfFldHdr (0), - fcPlcfFldFtn (0), lcbPlcfFldFtn (0), fcPlcfFldAtn (0), lcbPlcfFldAtn (0), fcPlcfFldMcr (0), lcbPlcfFldMcr (0), - fcSttbfBkmk (0), lcbSttbfBkmk (0), fcPlcfBkf (0), lcbPlcfBkf (0), fcPlcfBkl (0), lcbPlcfBkl (0), - fcCmds (0), lcbCmds (0), fcSttbfMcr (0), lcbSttbfMcr (0), fcPrDrvr (0), lcbPrDrvr (0), - fcPrEnvPort (0), lcbPrEnvPort (0), fcPrEnvLand (0), lcbPrEnvLand (0), fcWss (0), lcbWss (0), - fcDop (0), lcbDop (0), fcSttbfAssoc (0), lcbSttbfAssoc (0), fcClx (0), lcbClx (0), - fcPlcfPgdFtn (0), lcbPlcfPgdFtn (0), fcAutosaveSource (0), lcbAutosaveSource (0), fcGrpXstAtnOwners (0), lcbGrpXstAtnOwners (0), - fcSttbfAtnBkmk (0), lcbSttbfAtnBkmk (0), fcPlcSpaMom (0), lcbPlcSpaMom (0), fcPlcSpaHdr (0), lcbPlcSpaHdr (0), - fcPlcfAtnBkf (0), lcbPlcfAtnBkf (0), fcPlcfAtnBkl (0), lcbPlcfAtnBkl (0), fcPms (0), lcbPms (0), - fcFormFldSttbs (0), lcbFormFldSttbs (0), fcPlcfendRef (0), lcbPlcfendRef (0), fcPlcfendTxt (0), lcbPlcfendTxt (0), - fcPlcfFldEdn (0), lcbPlcfFldEdn (0), fcDggInfo (0), lcbDggInfo (0), fcSttbfRMark (0), lcbSttbfRMark (0), - fcSttbfCaption (0), lcbSttbfCaption (0), fcSttbfAutoCaption (0), lcbSttbfAutoCaption (0), fcPlcfWkb (0), lcbPlcfWkb (0), - fcPlcfSpl (0), lcbPlcfSpl (0), fcPlcftxbxTxt (0), lcbPlcftxbxTxt (0), fcPlcfFldTxbx (0), lcbPlcfFldTxbx (0), - fcPlcfHdrtxbxTxt (0), lcbPlcfHdrtxbxTxt (0), fcPlcffldHdrTxbx (0), lcbPlcffldHdrTxbx (0), fcStwUser (0), lcbStwUser (0), - fcSttbTtmbd (0), lcbSttbTtmbd (0), fcCookieData (0), lcbCookieData (0), fcPgdMotherOldOld (0), lcbPgdMotherOldOld (0), - fcBkdMotherOldOld (0), lcbBkdMotherOldOld (0), fcPgdFtnOldOld (0), lcbPgdFtnOldOld (0),fcBkdFtnOldOld (0), lcbBkdFtnOldOld (0), - fcPgdEdnOldOld (0), lcbPgdEdnOldOld (0), fcBkdEdnOldOld (0), lcbBkdEdnOldOld (0),fcSttbfIntlFld (0), lcbSttbfIntlFld (0), - fcRouteSlip (0), lcbRouteSlip (0), fcSttbSavedBy (0), lcbSttbSavedBy (0), fcSttbFnm (0), lcbSttbFnm (0), - fcPlfLst (0), lcbPlfLst (0), fcPlfLfo (0), lcbPlfLfo (0), fcPlcfTxbxBkd (0), lcbPlcfTxbxBkd (0), - fcPlcfTxbxHdrBkd (0), lcbPlcfTxbxHdrBkd (0), fcDocUndoWord9 (0), lcbDocUndoWord9 (0),fcRgbUse (0), lcbRgbUse (0), - fcUsp (0), lcbUsp (0), fcUskf (0), lcbUskf (0), fcPlcupcRgbUse (0), lcbPlcupcRgbUse (0), - fcPlcupcUsp (0), lcbPlcupcUsp (0), fcSttbGlsyStyle (0), lcbSttbGlsyStyle (0), fcPlgosl (0), lcbPlgosl (0), - fcPlcocx (0), lcbPlcocx (0), fcPlcfBteLvc (0), lcbPlcfBteLvc (0), dwLowDateTime (0), dwHighDateTime (0), - fcPlcfLvcPre10 (0), lcbPlcfLvcPre10 (0), fcPlcfAsumy (0), lcbPlcfAsumy (0), fcPlcfGram (0), lcbPlcfGram (0), - fcSttbListNames (0), lcbSttbListNames (0), fcSttbfUssr (0), lcbSttbfUssr (0) {} - //----------------------------------------------------------------- - unsigned int fcStshfOrig; - unsigned int lcbStshfOrig; - unsigned int fcStshf; - unsigned int lcbStshf; - unsigned int fcPlcffndRef; - unsigned int lcbPlcffndRef; - unsigned int fcPlcffndTxt; - unsigned int lcbPlcffndTxt; - unsigned int fcPlcfandRef; - unsigned int lcbPlcfandRef; - unsigned int fcPlcfandTxt; - unsigned int lcbPlcfandTxt; - unsigned int fcPlcfSed; - unsigned int lcbPlcfSed; - unsigned int fcPlcPad; - unsigned int lcbPlcPad; - unsigned int fcPlcfPhe; - unsigned int lcbPlcfPhe; - unsigned int fcSttbfGlsy; - unsigned int lcbSttbfGlsy; - unsigned int fcPlcfGlsy; - unsigned int lcbPlcfGlsy; - unsigned int fcPlcfHdd; - unsigned int lcbPlcfHdd; - unsigned int fcPlcfBteChpx; - unsigned int lcbPlcfBteChpx; - unsigned int fcPlcfBtePapx; - unsigned int lcbPlcfBtePapx; - unsigned int fcPlcfSea; - unsigned int lcbPlcfSea; - unsigned int fcSttbfFfn; - unsigned int lcbSttbfFfn; - unsigned int fcPlcfFldMom; - unsigned int lcbPlcfFldMom; - unsigned int fcPlcfFldHdr; - unsigned int lcbPlcfFldHdr; - unsigned int fcPlcfFldFtn; - unsigned int lcbPlcfFldFtn; - unsigned int fcPlcfFldAtn; - unsigned int lcbPlcfFldAtn; - unsigned int fcPlcfFldMcr; - unsigned int lcbPlcfFldMcr; - unsigned int fcSttbfBkmk; - unsigned int lcbSttbfBkmk; - unsigned int fcPlcfBkf; - unsigned int lcbPlcfBkf; - unsigned int fcPlcfBkl; - unsigned int lcbPlcfBkl; - unsigned int fcCmds; - unsigned int lcbCmds; - unsigned int fcSttbfMcr; - unsigned int lcbSttbfMcr; - unsigned int fcPrDrvr; - unsigned int lcbPrDrvr; - unsigned int fcPrEnvPort; - unsigned int lcbPrEnvPort; - unsigned int fcPrEnvLand; - unsigned int lcbPrEnvLand; - unsigned int fcWss; - unsigned int lcbWss; - unsigned int fcDop; - unsigned int lcbDop; - unsigned int fcSttbfAssoc; - unsigned int lcbSttbfAssoc; - unsigned int fcClx; - unsigned int lcbClx; - unsigned int fcPlcfPgdFtn; - unsigned int lcbPlcfPgdFtn; - unsigned int fcAutosaveSource; - unsigned int lcbAutosaveSource; - unsigned int fcGrpXstAtnOwners; - unsigned int lcbGrpXstAtnOwners; - unsigned int fcSttbfAtnBkmk; - unsigned int lcbSttbfAtnBkmk; - unsigned int fcPlcSpaMom; - unsigned int lcbPlcSpaMom; - unsigned int fcPlcSpaHdr; - unsigned int lcbPlcSpaHdr; - unsigned int fcPlcfAtnBkf; - unsigned int lcbPlcfAtnBkf; - unsigned int fcPlcfAtnBkl; - unsigned int lcbPlcfAtnBkl; - unsigned int fcPms; - unsigned int lcbPms; - unsigned int fcFormFldSttbs; - unsigned int lcbFormFldSttbs; - unsigned int fcPlcfendRef; - unsigned int lcbPlcfendRef; - unsigned int fcPlcfendTxt; - unsigned int lcbPlcfendTxt; - unsigned int fcPlcfFldEdn; - unsigned int lcbPlcfFldEdn; - unsigned int fcDggInfo; - unsigned int lcbDggInfo; - unsigned int fcSttbfRMark; - unsigned int lcbSttbfRMark; - unsigned int fcSttbfCaption; - unsigned int lcbSttbfCaption; - unsigned int fcSttbfAutoCaption; - unsigned int lcbSttbfAutoCaption; - unsigned int fcPlcfWkb; - unsigned int lcbPlcfWkb; - unsigned int fcPlcfSpl; - unsigned int lcbPlcfSpl; - unsigned int fcPlcftxbxTxt; - unsigned int lcbPlcftxbxTxt; - unsigned int fcPlcfFldTxbx; - unsigned int lcbPlcfFldTxbx; - unsigned int fcPlcfHdrtxbxTxt; - unsigned int lcbPlcfHdrtxbxTxt; - unsigned int fcPlcffldHdrTxbx; - unsigned int lcbPlcffldHdrTxbx; - unsigned int fcStwUser; - unsigned int lcbStwUser; - unsigned int fcSttbTtmbd; - unsigned int lcbSttbTtmbd; - unsigned int fcCookieData; - unsigned int lcbCookieData; - unsigned int fcPgdMotherOldOld; - unsigned int lcbPgdMotherOldOld; - unsigned int fcBkdMotherOldOld; - unsigned int lcbBkdMotherOldOld; - unsigned int fcPgdFtnOldOld; - unsigned int lcbPgdFtnOldOld; - unsigned int fcBkdFtnOldOld; - unsigned int lcbBkdFtnOldOld; - unsigned int fcPgdEdnOldOld; - unsigned int lcbPgdEdnOldOld; - unsigned int fcBkdEdnOldOld; - unsigned int lcbBkdEdnOldOld; - unsigned int fcSttbfIntlFld; - unsigned int lcbSttbfIntlFld; - unsigned int fcRouteSlip; - unsigned int lcbRouteSlip; - unsigned int fcSttbSavedBy; - unsigned int lcbSttbSavedBy; - unsigned int fcSttbFnm; - unsigned int lcbSttbFnm; - unsigned int fcPlfLst; - unsigned int lcbPlfLst; - unsigned int fcPlfLfo; - unsigned int lcbPlfLfo; - unsigned int fcPlcfTxbxBkd; - unsigned int lcbPlcfTxbxBkd; - unsigned int fcPlcfTxbxHdrBkd; - unsigned int lcbPlcfTxbxHdrBkd; - unsigned int fcDocUndoWord9; - unsigned int lcbDocUndoWord9; - unsigned int fcRgbUse; - unsigned int lcbRgbUse; - unsigned int fcUsp; - unsigned int lcbUsp; - unsigned int fcUskf; - unsigned int lcbUskf; - unsigned int fcPlcupcRgbUse; - unsigned int lcbPlcupcRgbUse; - unsigned int fcPlcupcUsp; - unsigned int lcbPlcupcUsp; - unsigned int fcSttbGlsyStyle; - unsigned int lcbSttbGlsyStyle; - unsigned int fcPlgosl; - unsigned int lcbPlgosl; - unsigned int fcPlcocx; - unsigned int lcbPlcocx; - unsigned int fcPlcfBteLvc; - unsigned int lcbPlcfBteLvc; - unsigned int dwLowDateTime; - unsigned int dwHighDateTime; - unsigned int fcPlcfLvcPre10; - unsigned int lcbPlcfLvcPre10; - unsigned int fcPlcfAsumy; - unsigned int lcbPlcfAsumy; - unsigned int fcPlcfGram; - unsigned int lcbPlcfGram; - unsigned int fcSttbListNames; - unsigned int lcbSttbListNames; - unsigned int fcSttbfUssr; - unsigned int lcbSttbfUssr; + unsigned int fcStshfOrig = 0; + unsigned int lcbStshfOrig = 0; + unsigned int fcStshf = 0; + unsigned int lcbStshf = 0; + unsigned int fcPlcffndRef = 0; + unsigned int lcbPlcffndRef = 0; + unsigned int fcPlcffndTxt = 0; + unsigned int lcbPlcffndTxt = 0; + unsigned int fcPlcfandRef = 0; + unsigned int lcbPlcfandRef = 0; + unsigned int fcPlcfandTxt = 0; + unsigned int lcbPlcfandTxt = 0; + unsigned int fcPlcfSed = 0; + unsigned int lcbPlcfSed = 0; + unsigned int fcPlcPad = 0; + unsigned int lcbPlcPad = 0; + unsigned int fcPlcfPhe = 0; + unsigned int lcbPlcfPhe = 0; + unsigned int fcSttbfGlsy = 0; + unsigned int lcbSttbfGlsy = 0; + unsigned int fcPlcfGlsy = 0; + unsigned int lcbPlcfGlsy = 0; + unsigned int fcPlcfHdd = 0; + unsigned int lcbPlcfHdd = 0; + unsigned int fcPlcfBteChpx = 0; + unsigned int lcbPlcfBteChpx = 0; + unsigned int fcPlcfBtePapx = 0; + unsigned int lcbPlcfBtePapx = 0; + unsigned int fcPlcfSea = 0; + unsigned int lcbPlcfSea = 0; + unsigned int fcSttbfFfn = 0; + unsigned int lcbSttbfFfn = 0; + unsigned int fcPlcfFldMom = 0; + unsigned int lcbPlcfFldMom = 0; + unsigned int fcPlcfFldHdr = 0; + unsigned int lcbPlcfFldHdr = 0; + unsigned int fcPlcfFldFtn = 0; + unsigned int lcbPlcfFldFtn = 0; + unsigned int fcPlcfFldAtn = 0; + unsigned int lcbPlcfFldAtn = 0; + unsigned int fcPlcfFldMcr = 0; + unsigned int lcbPlcfFldMcr = 0; + unsigned int fcSttbfBkmk = 0; + unsigned int lcbSttbfBkmk = 0; + unsigned int fcPlcfBkf = 0; + unsigned int lcbPlcfBkf = 0; + unsigned int fcPlcfBkl = 0; + unsigned int lcbPlcfBkl = 0; + unsigned int fcCmds = 0; + unsigned int lcbCmds = 0; + unsigned int fcSttbfMcr = 0; + unsigned int lcbSttbfMcr = 0; + unsigned int fcPrDrvr = 0; + unsigned int lcbPrDrvr = 0; + unsigned int fcPrEnvPort = 0; + unsigned int lcbPrEnvPort = 0; + unsigned int fcPrEnvLand = 0; + unsigned int lcbPrEnvLand = 0; + unsigned int fcWss = 0; + unsigned int lcbWss = 0; + unsigned int fcDop = 0; + unsigned int lcbDop = 0; + unsigned int fcSttbfAssoc = 0; + unsigned int lcbSttbfAssoc = 0; + unsigned int fcClx = 0; + unsigned int lcbClx = 0; + unsigned int fcPlcfPgdFtn = 0; + unsigned int lcbPlcfPgdFtn = 0; + unsigned int fcAutosaveSource = 0; + unsigned int lcbAutosaveSource = 0; + unsigned int fcGrpXstAtnOwners = 0; + unsigned int lcbGrpXstAtnOwners = 0; + unsigned int fcSttbfAtnBkmk = 0; + unsigned int lcbSttbfAtnBkmk = 0; + unsigned int fcPlcSpaMom = 0; + unsigned int lcbPlcSpaMom = 0; + unsigned int fcPlcSpaHdr = 0; + unsigned int lcbPlcSpaHdr = 0; + unsigned int fcPlcfAtnBkf = 0; + unsigned int lcbPlcfAtnBkf = 0; + unsigned int fcPlcfAtnBkl = 0; + unsigned int lcbPlcfAtnBkl = 0; + unsigned int fcPms = 0; + unsigned int lcbPms = 0; + unsigned int fcFormFldSttbs = 0; + unsigned int lcbFormFldSttbs = 0; + unsigned int fcPlcfendRef = 0; + unsigned int lcbPlcfendRef = 0; + unsigned int fcPlcfendTxt = 0; + unsigned int lcbPlcfendTxt = 0; + unsigned int fcPlcfFldEdn = 0; + unsigned int lcbPlcfFldEdn = 0; + unsigned int fcDggInfo = 0; + unsigned int lcbDggInfo = 0; + unsigned int fcSttbfRMark = 0; + unsigned int lcbSttbfRMark = 0; + unsigned int fcSttbfCaption = 0; + unsigned int lcbSttbfCaption = 0; + unsigned int fcSttbfAutoCaption = 0; + unsigned int lcbSttbfAutoCaption = 0; + unsigned int fcPlcfWkb = 0; + unsigned int lcbPlcfWkb = 0; + unsigned int fcPlcfSpl = 0; + unsigned int lcbPlcfSpl = 0; + unsigned int fcPlcftxbxTxt = 0; + unsigned int lcbPlcftxbxTxt = 0; + unsigned int fcPlcfFldTxbx = 0; + unsigned int lcbPlcfFldTxbx = 0; + unsigned int fcPlcfHdrtxbxTxt = 0; + unsigned int lcbPlcfHdrtxbxTxt = 0; + unsigned int fcPlcffldHdrTxbx = 0; + unsigned int lcbPlcffldHdrTxbx = 0; + unsigned int fcStwUser = 0; + unsigned int lcbStwUser = 0; + unsigned int fcSttbTtmbd = 0; + unsigned int lcbSttbTtmbd = 0; + unsigned int fcCookieData = 0; + unsigned int lcbCookieData = 0; + unsigned int fcPgdMotherOldOld = 0; + unsigned int lcbPgdMotherOldOld = 0; + unsigned int fcBkdMotherOldOld = 0; + unsigned int lcbBkdMotherOldOld = 0; + unsigned int fcPgdFtnOldOld = 0; + unsigned int lcbPgdFtnOldOld = 0; + unsigned int fcBkdFtnOldOld = 0; + unsigned int lcbBkdFtnOldOld = 0; + unsigned int fcPgdEdnOldOld = 0; + unsigned int lcbPgdEdnOldOld = 0; + unsigned int fcBkdEdnOldOld = 0; + unsigned int lcbBkdEdnOldOld = 0; + unsigned int fcSttbfIntlFld = 0; + unsigned int lcbSttbfIntlFld = 0; + unsigned int fcRouteSlip = 0; + unsigned int lcbRouteSlip = 0; + unsigned int fcSttbSavedBy = 0; + unsigned int lcbSttbSavedBy = 0; + unsigned int fcSttbFnm = 0; + unsigned int lcbSttbFnm = 0; + unsigned int fcPlfLst = 0; + unsigned int lcbPlfLst = 0; + unsigned int fcPlfLfo = 0; + unsigned int lcbPlfLfo = 0; + unsigned int fcPlcfTxbxBkd = 0; + unsigned int lcbPlcfTxbxBkd = 0; + unsigned int fcPlcfTxbxHdrBkd = 0; + unsigned int lcbPlcfTxbxHdrBkd = 0; + unsigned int fcDocUndoWord9 = 0; + unsigned int lcbDocUndoWord9 = 0; + unsigned int fcRgbUse = 0; + unsigned int lcbRgbUse = 0; + unsigned int fcUsp = 0; + unsigned int lcbUsp = 0; + unsigned int fcUskf = 0; + unsigned int lcbUskf = 0; + unsigned int fcPlcupcRgbUse = 0; + unsigned int lcbPlcupcRgbUse = 0; + unsigned int fcPlcupcUsp = 0; + unsigned int lcbPlcupcUsp = 0; + unsigned int fcSttbGlsyStyle = 0; + unsigned int lcbSttbGlsyStyle = 0; + unsigned int fcPlgosl = 0; + unsigned int lcbPlgosl = 0; + unsigned int fcPlcocx = 0; + unsigned int lcbPlcocx = 0; + unsigned int fcPlcfBteLvc = 0; + unsigned int lcbPlcfBteLvc = 0; + unsigned int dwLowDateTime = 0; + unsigned int dwHighDateTime = 0; + unsigned int fcPlcfLvcPre10 = 0; + unsigned int lcbPlcfLvcPre10 = 0; + unsigned int fcPlcfAsumy = 0; + unsigned int lcbPlcfAsumy = 0; + unsigned int fcPlcfGram = 0; + unsigned int lcbPlcfGram = 0; + unsigned int fcSttbListNames = 0; + unsigned int lcbSttbListNames = 0; + unsigned int fcSttbfUssr = 0; + unsigned int lcbSttbfUssr = 0; } FibWord97; typedef struct FibWord2000 { - unsigned int fcPlcfTch; - unsigned int lcbPlcfTch; - unsigned int fcRmdThreading; - unsigned int lcbRmdThreading; - unsigned int fcMid; - unsigned int lcbMid; - unsigned int fcSttbRgtplc; - unsigned int lcbSttbRgtplc; - unsigned int fcMsoEnvelope; - unsigned int lcbMsoEnvelope; - unsigned int fcPlcfLad; - unsigned int lcbPlcfLad; - unsigned int fcRgDofr; - unsigned int lcbRgDofr; - unsigned int fcPlcosl; - unsigned int lcbPlcosl; - unsigned int fcPlcfCookieOld; - unsigned int lcbPlcfCookieOld; - unsigned int fcPgdMotherOld; - unsigned int lcbPgdMotherOld; - unsigned int fcBkdMotherOld; - unsigned int lcbBkdMotherOld; - unsigned int fcPgdFtnOld; - unsigned int lcbPgdFtnOld; - unsigned int fcBkdFtnOld; - unsigned int lcbBkdFtnOld; - unsigned int fcPgdEdnOld; - unsigned int lcbPgdEdnOld; - unsigned int fcBkdEdnOld; - unsigned int lcbBkdEdnOld; + unsigned int fcPlcfTch = 0; + unsigned int lcbPlcfTch = 0; + unsigned int fcRmdThreading = 0; + unsigned int lcbRmdThreading = 0; + unsigned int fcMid = 0; + unsigned int lcbMid = 0; + unsigned int fcSttbRgtplc = 0; + unsigned int lcbSttbRgtplc = 0; + unsigned int fcMsoEnvelope = 0; + unsigned int lcbMsoEnvelope = 0; + unsigned int fcPlcfLad = 0; + unsigned int lcbPlcfLad = 0; + unsigned int fcRgDofr = 0; + unsigned int lcbRgDofr = 0; + unsigned int fcPlcosl = 0; + unsigned int lcbPlcosl = 0; + unsigned int fcPlcfCookieOld = 0; + unsigned int lcbPlcfCookieOld = 0; + unsigned int fcPgdMotherOld = 0; + unsigned int lcbPgdMotherOld = 0; + unsigned int fcBkdMotherOld = 0; + unsigned int lcbBkdMotherOld = 0; + unsigned int fcPgdFtnOld = 0; + unsigned int lcbPgdFtnOld = 0; + unsigned int fcBkdFtnOld = 0; + unsigned int lcbBkdFtnOld = 0; + unsigned int fcPgdEdnOld = 0; + unsigned int lcbPgdEdnOld = 0; + unsigned int fcBkdEdnOld = 0; + unsigned int lcbBkdEdnOld = 0; } FibWord2000; typedef struct FibWord2002 { - unsigned int fcPlcfPgp; - unsigned int lcbPlcfPgp; - unsigned int fcPlcfuim; - unsigned int lcbPlcfuim; - unsigned int fcPlfguidUim; - unsigned int lcbPlfguidUim; - unsigned int fcAtrdExtra; - unsigned int lcbAtrdExtra; - unsigned int fcPlrsid; - unsigned int lcbPlrsid; - unsigned int fcSttbfBkmkFactoid; - unsigned int lcbSttbfBkmkFactoid; - unsigned int fcPlcfBkfFactoid; - unsigned int lcbPlcfBkfFactoid; - unsigned int fcPlcfcookie; - unsigned int lcbPlcfcookie; - unsigned int fcPlcfBklFactoid; - unsigned int lcbPlcfBklFactoid; - unsigned int fcFactoidData; - unsigned int lcbFactoidData; - unsigned int fcDocUndo; - unsigned int lcbDocUndo; - unsigned int fcSttbfBkmkFcc; - unsigned int lcbSttbfBkmkFcc; - unsigned int fcPlcfBkfFcc; - unsigned int lcbPlcfBkfFcc; - unsigned int fcPlcfBklFcc; - unsigned int lcbPlcfBklFcc; - unsigned int fcSttbfbkmkBPRepairs; - unsigned int lcbSttbfbkmkBPRepairs; - unsigned int fcPlcfbkfBPRepairs; - unsigned int lcbPlcfbkfBPRepairs; - unsigned int fcPlcfbklBPRepairs; - unsigned int lcbPlcfbklBPRepairs; - unsigned int fcPmsNew; - unsigned int lcbPmsNew; - unsigned int fcODSO; - unsigned int lcbODSO; - unsigned int fcPlcfpmiOldXP; - unsigned int lcbPlcfpmiOldXP; - unsigned int fcPlcfpmiNewXP; - unsigned int lcbPlcfpmiNewXP; - unsigned int fcPlcfpmiMixedXP; - unsigned int lcbPlcfpmiMixedXP; - unsigned int fcPlcffactoid; - unsigned int lcbPlcffactoid; - unsigned int fcPlcflvcOldXP; - unsigned int lcbPlcflvcOldXP; - unsigned int fcPlcflvcNewXP; - unsigned int lcbPlcflvcNewXP; - unsigned int fcPlcflvcMixedXP; - unsigned int lcbPlcflvcMixedXP; + unsigned int fcPlcfPgp = 0; + unsigned int lcbPlcfPgp = 0; + unsigned int fcPlcfuim = 0; + unsigned int lcbPlcfuim = 0; + unsigned int fcPlfguidUim = 0; + unsigned int lcbPlfguidUim = 0; + unsigned int fcAtrdExtra = 0; + unsigned int lcbAtrdExtra = 0; + unsigned int fcPlrsid = 0; + unsigned int lcbPlrsid = 0; + unsigned int fcSttbfBkmkFactoid = 0; + unsigned int lcbSttbfBkmkFactoid = 0; + unsigned int fcPlcfBkfFactoid = 0; + unsigned int lcbPlcfBkfFactoid = 0; + unsigned int fcPlcfcookie = 0; + unsigned int lcbPlcfcookie = 0; + unsigned int fcPlcfBklFactoid = 0; + unsigned int lcbPlcfBklFactoid = 0; + unsigned int fcFactoidData = 0; + unsigned int lcbFactoidData = 0; + unsigned int fcDocUndo = 0; + unsigned int lcbDocUndo = 0; + unsigned int fcSttbfBkmkFcc = 0; + unsigned int lcbSttbfBkmkFcc = 0; + unsigned int fcPlcfBkfFcc = 0; + unsigned int lcbPlcfBkfFcc = 0; + unsigned int fcPlcfBklFcc = 0; + unsigned int lcbPlcfBklFcc = 0; + unsigned int fcSttbfbkmkBPRepairs = 0; + unsigned int lcbSttbfbkmkBPRepairs = 0; + unsigned int fcPlcfbkfBPRepairs = 0; + unsigned int lcbPlcfbkfBPRepairs = 0; + unsigned int fcPlcfbklBPRepairs = 0; + unsigned int lcbPlcfbklBPRepairs = 0; + unsigned int fcPmsNew = 0; + unsigned int lcbPmsNew = 0; + unsigned int fcODSO = 0; + unsigned int lcbODSO = 0; + unsigned int fcPlcfpmiOldXP = 0; + unsigned int lcbPlcfpmiOldXP = 0; + unsigned int fcPlcfpmiNewXP = 0; + unsigned int lcbPlcfpmiNewXP = 0; + unsigned int fcPlcfpmiMixedXP = 0; + unsigned int lcbPlcfpmiMixedXP = 0; + unsigned int fcPlcffactoid = 0; + unsigned int lcbPlcffactoid = 0; + unsigned int fcPlcflvcOldXP = 0; + unsigned int lcbPlcflvcOldXP = 0; + unsigned int fcPlcflvcNewXP = 0; + unsigned int lcbPlcflvcNewXP = 0; + unsigned int fcPlcflvcMixedXP = 0; + unsigned int lcbPlcflvcMixedXP = 0; } FibWord2002; typedef struct FibWord2003 { - unsigned int fcHplxsdr; - unsigned int lcbHplxsdr; - unsigned int fcSttbfBkmkSdt; - unsigned int lcbSttbfBkmkSdt; - unsigned int fcPlcfBkfSdt; - unsigned int lcbPlcfBkfSdt; - unsigned int fcPlcfBklSdt; - unsigned int lcbPlcfBklSdt; - unsigned int fcCustomXForm; - unsigned int lcbCustomXForm; - unsigned int fcSttbfBkmkProt; - unsigned int lcbSttbfBkmkProt; - unsigned int fcPlcfBkfProt; - unsigned int lcbPlcfBkfProt; - unsigned int fcPlcfBklProt; - unsigned int lcbPlcfBklProt; - unsigned int fcSttbProtUser; - unsigned int lcbSttbProtUser; - unsigned int fcPlcfpmiOld; - unsigned int lcbPlcfpmiOld; - unsigned int fcPlcfpmiOldInline; - unsigned int lcbPlcfpmiOldInline; - unsigned int fcPlcfpmiNew; - unsigned int lcbPlcfpmiNew; - unsigned int fcPlcfpmiNewInline; - unsigned int lcbPlcfpmiNewInline; - unsigned int fcPlcflvcOld; - unsigned int lcbPlcflvcOld; - unsigned int fcPlcflvcOldInline; - unsigned int lcbPlcflvcOldInline; - unsigned int fcPlcflvcNew; - unsigned int lcbPlcflvcNew; - unsigned int fcPlcflvcNewInline; - unsigned int lcbPlcflvcNewInline; - unsigned int fcPgdMother; - unsigned int lcbPgdMother; - unsigned int fcBkdMother; - unsigned int lcbBkdMother; - unsigned int fcAfdMother; - unsigned int lcbAfdMother; - unsigned int fcPgdFtn; - unsigned int lcbPgdFtn; - unsigned int fcBkdFtn; - unsigned int lcbBkdFtn; - unsigned int fcAfdFtn; - unsigned int lcbAfdFtn; - unsigned int fcPgdEdn; - unsigned int lcbPgdEdn; - unsigned int fcBkdEdn; - unsigned int lcbBkdEdn; - unsigned int fcAfdEdn; - unsigned int lcbAfdEdn; - unsigned int fcAfd; - unsigned int lcbAfd; + unsigned int fcHplxsdr = 0; + unsigned int lcbHplxsdr = 0; + unsigned int fcSttbfBkmkSdt = 0; + unsigned int lcbSttbfBkmkSdt = 0; + unsigned int fcPlcfBkfSdt = 0; + unsigned int lcbPlcfBkfSdt = 0; + unsigned int fcPlcfBklSdt = 0; + unsigned int lcbPlcfBklSdt = 0; + unsigned int fcCustomXForm = 0; + unsigned int lcbCustomXForm = 0; + unsigned int fcSttbfBkmkProt = 0; + unsigned int lcbSttbfBkmkProt = 0; + unsigned int fcPlcfBkfProt = 0; + unsigned int lcbPlcfBkfProt = 0; + unsigned int fcPlcfBklProt = 0; + unsigned int lcbPlcfBklProt = 0; + unsigned int fcSttbProtUser = 0; + unsigned int lcbSttbProtUser = 0; + unsigned int fcPlcfpmiOld = 0; + unsigned int lcbPlcfpmiOld = 0; + unsigned int fcPlcfpmiOldInline = 0; + unsigned int lcbPlcfpmiOldInline = 0; + unsigned int fcPlcfpmiNew = 0; + unsigned int lcbPlcfpmiNew = 0; + unsigned int fcPlcfpmiNewInline = 0; + unsigned int lcbPlcfpmiNewInline = 0; + unsigned int fcPlcflvcOld = 0; + unsigned int lcbPlcflvcOld = 0; + unsigned int fcPlcflvcOldInline = 0; + unsigned int lcbPlcflvcOldInline = 0; + unsigned int fcPlcflvcNew = 0; + unsigned int lcbPlcflvcNew = 0; + unsigned int fcPlcflvcNewInline = 0; + unsigned int lcbPlcflvcNewInline = 0; + unsigned int fcPgdMother = 0; + unsigned int lcbPgdMother = 0; + unsigned int fcBkdMother = 0; + unsigned int lcbBkdMother = 0; + unsigned int fcAfdMother = 0; + unsigned int lcbAfdMother = 0; + unsigned int fcPgdFtn = 0; + unsigned int lcbPgdFtn = 0; + unsigned int fcBkdFtn = 0; + unsigned int lcbBkdFtn = 0; + unsigned int fcAfdFtn = 0; + unsigned int lcbAfdFtn = 0; + unsigned int fcPgdEdn = 0; + unsigned int lcbPgdEdn = 0; + unsigned int fcBkdEdn = 0; + unsigned int lcbBkdEdn = 0; + unsigned int fcAfdEdn = 0; + unsigned int lcbAfdEdn = 0; + unsigned int fcAfd = 0; + unsigned int lcbAfd = 0; } FibWord2003; typedef struct FibWord2007 { - unsigned int fcPlcfmthd; - unsigned int lcbPlcfmthd; - unsigned int fcSttbfBkmkMoveFrom; - unsigned int lcbSttbfBkmkMoveFrom; - unsigned int fcPlcfBkfMoveFrom; - unsigned int lcbPlcfBkfMoveFrom; - unsigned int fcPlcfBklMoveFrom; - unsigned int lcbPlcfBklMoveFrom; - unsigned int fcSttbfBkmkMoveTo; - unsigned int lcbSttbfBkmkMoveTo; - unsigned int fcPlcfBkfMoveTo; - unsigned int lcbPlcfBkfMoveTo; - unsigned int fcPlcfBklMoveTo; - unsigned int lcbPlcfBklMoveTo; - unsigned int fcSttbfBkmkArto; - unsigned int lcbSttbfBkmkArto; - unsigned int fcPlcfBkfArto; - unsigned int lcbPlcfBkfArto; - unsigned int fcPlcfBklArto; - unsigned int lcbPlcfBklArto; - unsigned int fcArtoData; - unsigned int lcbArtoData; - unsigned int fcOssTheme; - unsigned int lcbOssTheme; - unsigned int fcColorSchemeMapping; - unsigned int lcbColorSchemeMapping; + unsigned int fcPlcfmthd = 0; + unsigned int lcbPlcfmthd = 0; + unsigned int fcSttbfBkmkMoveFrom = 0; + unsigned int lcbSttbfBkmkMoveFrom = 0; + unsigned int fcPlcfBkfMoveFrom = 0; + unsigned int lcbPlcfBkfMoveFrom = 0; + unsigned int fcPlcfBklMoveFrom = 0; + unsigned int lcbPlcfBklMoveFrom = 0; + unsigned int fcSttbfBkmkMoveTo = 0; + unsigned int lcbSttbfBkmkMoveTo = 0; + unsigned int fcPlcfBkfMoveTo = 0; + unsigned int lcbPlcfBkfMoveTo = 0; + unsigned int fcPlcfBklMoveTo = 0; + unsigned int lcbPlcfBklMoveTo = 0; + unsigned int fcSttbfBkmkArto = 0; + unsigned int lcbSttbfBkmkArto = 0; + unsigned int fcPlcfBkfArto = 0; + unsigned int lcbPlcfBkfArto = 0; + unsigned int fcPlcfBklArto = 0; + unsigned int lcbPlcfBklArto = 0; + unsigned int fcArtoData = 0; + unsigned int lcbArtoData = 0; + unsigned int fcOssTheme = 0; + unsigned int lcbOssTheme = 0; + unsigned int fcColorSchemeMapping = 0; + unsigned int lcbColorSchemeMapping = 0; } FibWord2007; struct FibNew @@ -507,13 +501,14 @@ namespace DocFileFormat class FileInformationBlock { public: - bool m_bOlderVersion; + int m_nWordVersion; int m_CodePage; FibBase m_FibBase; RgW97 m_RgW97; RgLw97 m_RgLw97; + FibWord2 m_FibWord2; FibWord97 m_FibWord97; FibWord2000 m_FibWord2000; FibWord2002 m_FibWord2002; @@ -531,216 +526,344 @@ namespace DocFileFormat { if (m_FibBase.nFib > 0 && m_FibBase.nFib <= Fib1995) { - /*m_FibWord97.fcSpare0 = */reader.ReadInt32(); - /*m_FibWord97.fcSpare1 = */reader.ReadInt32(); - /*m_FibWord97.fcSpare2 = */reader.ReadInt32(); - /*m_FibWord97.fcSpare3 = */reader.ReadInt32(); //48 + /*fcSpare0 = */reader.ReadInt32(); + /*fcSpare1 = */reader.ReadInt32(); + /*fcSpare2 = */reader.ReadInt32(); + /*fcSpare3 = */reader.ReadInt32(); //48 m_RgLw97.ccpText = reader.ReadInt32(); m_RgLw97.ccpFtn = reader.ReadInt32(); m_RgLw97.ccpHdr = reader.ReadInt32(); /*m_FibWord97.ccpMcr = */reader.ReadInt32(); m_RgLw97.ccpAtn = reader.ReadInt32(); - m_RgLw97.ccpEdn = reader.ReadInt32(); - m_RgLw97.ccpTxbx = reader.ReadInt32(); - m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); - /*m_FibWord97.ccpSpare2 = */reader.ReadInt32(); //84 - m_FibWord97.fcStshfOrig = reader.ReadInt32(); - m_FibWord97.lcbStshfOrig = reader.ReadInt32(); - m_FibWord97.fcStshf = reader.ReadInt32(); - m_FibWord97.lcbStshf = reader.ReadInt32(); - m_FibWord97.fcPlcffndRef = reader.ReadInt32(); - m_FibWord97.lcbPlcffndRef = reader.ReadInt32(); + if (m_FibBase.nFib > Fib1985) + { + m_RgLw97.ccpEdn = reader.ReadInt32(); + m_RgLw97.ccpTxbx = reader.ReadInt32(); + m_RgLw97.ccpHdrTxbx = reader.ReadInt32(); + } + else + { + /*ccpSpare0 = */ reader.ReadInt32(); + /*ccpSpare1 = */ reader.ReadInt32(); + /*ccpSpare2 = */ reader.ReadInt32(); + } + /*ccpSpare3 = */ reader.ReadInt32(); - m_FibWord97.lcbPlcfandTxt = reader.ReadInt32();//112 + if (m_FibBase.nFib > Fib1985) + { + m_FibWord97.fcStshfOrig = reader.ReadInt32(); + m_FibWord97.lcbStshfOrig = reader.ReadInt32(); + m_FibWord97.fcStshf = reader.ReadInt32(); //88 + m_FibWord97.lcbStshf = reader.ReadInt32(); + m_FibWord97.fcPlcffndRef = reader.ReadInt32(); + m_FibWord97.lcbPlcffndRef = reader.ReadInt32(); - m_FibWord97.lcbPlcffndTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfandTxt = reader.ReadInt32();//112 - m_FibWord97.fcPlcfandRef = reader.ReadInt32(); - m_FibWord97.lcbPlcfandRef = reader.ReadInt32(); + m_FibWord97.lcbPlcffndTxt = reader.ReadInt32(); - m_FibWord97.fcPlcfandTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcfandTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfandRef = reader.ReadInt32(); + m_FibWord97.lcbPlcfandRef = reader.ReadInt32(); - m_FibWord97.fcPlcfSed = reader.ReadInt32(); //136 - m_FibWord97.lcbPlcfSed = reader.ReadInt32(); + m_FibWord97.fcPlcfandTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfandTxt = reader.ReadInt32(); - m_FibWord97.fcPlcPad = reader.ReadInt32(); - m_FibWord97.lcbPlcPad = reader.ReadInt32(); + m_FibWord97.fcPlcfSed = reader.ReadInt32(); //136 + m_FibWord97.lcbPlcfSed = reader.ReadInt32(); - m_FibWord97.fcPlcfPhe = reader.ReadInt32(); - m_FibWord97.lcbPlcfPhe = reader.ReadInt32(); + m_FibWord97.fcPlcPad = reader.ReadInt32(); + m_FibWord97.lcbPlcPad = reader.ReadInt32(); - m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); - m_FibWord97.lcbSttbfGlsy = reader.ReadInt32(); - - m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); - m_FibWord97.lcbPlcfGlsy = reader.ReadInt32(); - m_FibWord97.fcPlcfHdd = reader.ReadInt32(); - m_FibWord97.lcbPlcfHdd = reader.ReadInt32(); + m_FibWord97.fcPlcfPhe = reader.ReadInt32(); + m_FibWord97.lcbPlcfPhe = reader.ReadInt32(); - m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); - m_FibWord97.lcbPlcfBteChpx = reader.ReadInt32(); + m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); + m_FibWord97.lcbSttbfGlsy = reader.ReadInt32(); + + m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); + m_FibWord97.lcbPlcfGlsy = reader.ReadInt32(); + m_FibWord97.fcPlcfHdd = reader.ReadInt32(); + m_FibWord97.lcbPlcfHdd = reader.ReadInt32(); - m_FibWord97.fcPlcfBtePapx = reader.ReadInt32(); - m_FibWord97.lcbPlcfBtePapx = reader.ReadInt32(); + m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBteChpx = reader.ReadInt32(); - m_FibWord97.fcPlcfSea = reader.ReadInt32(); - m_FibWord97.lcbPlcfSea = reader.ReadInt32(); + m_FibWord97.fcPlcfBtePapx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBtePapx = reader.ReadInt32(); - m_FibWord97.fcSttbfFfn = reader.ReadInt32(); - m_FibWord97.lcbSttbfFfn = reader.ReadInt32(); + m_FibWord97.fcPlcfSea = reader.ReadInt32(); + m_FibWord97.lcbPlcfSea = reader.ReadInt32(); - m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); //216 - m_FibWord97.lcbPlcfFldMom = reader.ReadInt32(); + m_FibWord97.fcSttbfFfn = reader.ReadInt32(); + m_FibWord97.lcbSttbfFfn = reader.ReadInt32(); - m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldHdr = reader.ReadInt32(); + m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); //216 + m_FibWord97.lcbPlcfFldMom = reader.ReadInt32(); - m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldFtn = reader.ReadInt32(); + m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldHdr = reader.ReadInt32(); - m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldAtn = reader.ReadInt32(); + m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldFtn = reader.ReadInt32(); - m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldMcr = reader.ReadInt32(); + m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldAtn = reader.ReadInt32(); - m_FibWord97.fcSttbfBkmk = reader.ReadInt32(); - m_FibWord97.lcbSttbfBkmk = reader.ReadInt32(); + m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldMcr = reader.ReadInt32(); - m_FibWord97.fcPlcfBkf = reader.ReadInt32(); - m_FibWord97.lcbPlcfBkf = reader.ReadInt32(); + m_FibWord97.fcSttbfBkmk = reader.ReadInt32(); + m_FibWord97.lcbSttbfBkmk = reader.ReadInt32(); - m_FibWord97.fcPlcfBkl = reader.ReadInt32(); - m_FibWord97.lcbPlcfBkl = reader.ReadInt32(); + m_FibWord97.fcPlcfBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkf = reader.ReadInt32(); - m_FibWord97.fcCmds = reader.ReadInt32(); - m_FibWord97.lcbCmds = reader.ReadInt32(); + m_FibWord97.fcPlcfBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkl = reader.ReadInt32(); - /*m_FibWord97.fcPlcMcr = */reader.ReadInt32(); - /*m_FibWord97.lcbPlcMcr = */reader.ReadInt32(); + m_FibWord97.fcCmds = reader.ReadInt32(); + m_FibWord97.lcbCmds = reader.ReadInt32(); - m_FibWord97.fcSttbfMcr = reader.ReadInt32(); - m_FibWord97.lcbSttbfMcr = reader.ReadInt32(); + /*m_FibWord97.fcPlcMcr = */reader.ReadInt32(); + /*m_FibWord97.lcbPlcMcr = */reader.ReadInt32(); - m_FibWord97.fcPrDrvr = reader.ReadInt32(); - m_FibWord97.lcbPrDrvr = reader.ReadInt32(); + m_FibWord97.fcSttbfMcr = reader.ReadInt32(); + m_FibWord97.lcbSttbfMcr = reader.ReadInt32(); - m_FibWord97.fcPrEnvPort = reader.ReadInt32(); - m_FibWord97.lcbPrEnvPort = reader.ReadInt32(); //316 + m_FibWord97.fcPrDrvr = reader.ReadInt32(); + m_FibWord97.lcbPrDrvr = reader.ReadInt32(); - m_FibWord97.fcPrEnvLand = reader.ReadInt32(); - m_FibWord97.lcbPrEnvLand = reader.ReadInt32(); + m_FibWord97.fcPrEnvPort = reader.ReadInt32(); + m_FibWord97.lcbPrEnvPort = reader.ReadInt32(); //316 - m_FibWord97.fcWss = reader.ReadInt32(); - m_FibWord97.lcbWss = reader.ReadInt32(); + m_FibWord97.fcPrEnvLand = reader.ReadInt32(); + m_FibWord97.lcbPrEnvLand = reader.ReadInt32(); - m_FibWord97.fcDop = reader.ReadInt32(); - m_FibWord97.lcbDop = reader.ReadInt32(); + m_FibWord97.fcWss = reader.ReadInt32(); + m_FibWord97.lcbWss = reader.ReadInt32(); - m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); - m_FibWord97.lcbSttbfAssoc = reader.ReadInt32(); + m_FibWord97.fcDop = reader.ReadInt32(); + m_FibWord97.lcbDop = reader.ReadInt32(); - m_FibWord97.fcClx = reader.ReadInt32(); - m_FibWord97.lcbClx = reader.ReadInt32(); - - m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); - m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt32(); + m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); + m_FibWord97.lcbSttbfAssoc = reader.ReadInt32(); - m_FibWord97.fcAutosaveSource = reader.ReadInt32(); - m_FibWord97.lcbAutosaveSource = reader.ReadInt32(); - m_FibWord97.fcGrpXstAtnOwners = reader.ReadInt32(); - m_FibWord97.lcbGrpXstAtnOwners = reader.ReadInt32(); - - m_FibWord97.fcSttbfAtnBkmk = reader.ReadInt32(); - m_FibWord97.lcbSttbfAtnBkmk = reader.ReadInt32(); - /*m_FibWord97.wSpare4Fib = */reader.ReadInt16(); //392 - /*m_FibWord97.pnChpFirst = */reader.ReadInt16(); - /*m_FibWord97.pnPapFirst = */reader.ReadInt16(); + m_FibWord97.fcClx = reader.ReadInt32(); + m_FibWord97.lcbClx = reader.ReadInt32(); + + m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt32(); - /*m_FibWord97.cpnBteChp = */reader.ReadInt16(); - /*m_FibWord97.cpnBtePap = */reader.ReadInt16(); - - m_FibWord97.fcPlcSpaMom = reader.ReadInt32(); - m_FibWord97.lcbPlcSpaMom = reader.ReadInt32(); + m_FibWord97.fcAutosaveSource = reader.ReadInt32(); + m_FibWord97.lcbAutosaveSource = reader.ReadInt32(); + m_FibWord97.fcGrpXstAtnOwners = reader.ReadInt32(); + m_FibWord97.lcbGrpXstAtnOwners = reader.ReadInt32(); + + m_FibWord97.fcSttbfAtnBkmk = reader.ReadInt32(); + m_FibWord97.lcbSttbfAtnBkmk = reader.ReadInt32(); + + m_FibWord2.wSpare4 = reader.ReadInt16(); //392 + m_FibWord2.pnChpFirst = reader.ReadInt16(); + m_FibWord2.pnPapFirst = reader.ReadInt16(); - m_FibWord97.fcPlcSpaHdr = reader.ReadInt32(); /*fcPlcfdoaHdr*/ - m_FibWord97.lcbPlcSpaHdr = reader.ReadInt32(); /*lcbPlcfdoaHdr*/ + m_FibWord2.cpnBteChp = reader.ReadInt16(); + m_FibWord2.cpnBtePap = reader.ReadInt16(); + + m_FibWord97.fcPlcSpaMom = reader.ReadInt32(); + m_FibWord97.lcbPlcSpaMom = reader.ReadInt32(); - /*m_FibWord97.fcUnused1 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused1 =*/ reader.ReadInt32(); - /*m_FibWord97.fcUnused2 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused2 =*/ reader.ReadInt32(); + m_FibWord97.fcPlcSpaHdr = reader.ReadInt32(); /*fcPlcfdoaHdr*/ + m_FibWord97.lcbPlcSpaHdr = reader.ReadInt32(); /*lcbPlcfdoaHdr*/ - m_FibWord97.fcPlcfAtnBkf = reader.ReadInt32(); - m_FibWord97.lcbPlcfAtnBkf = reader.ReadInt32(); - m_FibWord97.fcPlcfAtnBkl = reader.ReadInt32(); - m_FibWord97.lcbPlcfAtnBkl = reader.ReadInt32(); - m_FibWord97.fcPms = reader.ReadInt32(); - m_FibWord97.lcbPms = reader.ReadInt32(); - m_FibWord97.fcFormFldSttbs/*f*/ = reader.ReadInt32(); - m_FibWord97.lcbFormFldSttbs/*f*/= reader.ReadInt32(); - - m_FibWord97.fcPlcfendRef = reader.ReadInt32(); //466 - m_FibWord97.lcbPlcfendRef = reader.ReadInt32(); - m_FibWord97.fcPlcfendTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcfendTxt = reader.ReadInt32(); - m_FibWord97.fcPlcfFldEdn = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldEdn = reader.ReadInt32(); - /*m_FibWord97.fcPlcfpgdEdn =*/ reader.ReadInt32(); - /*m_FibWord97.lcbPlcfpgdEdn =*/ reader.ReadInt32(); - /*m_FibWord97.fcUnused3 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused3 =*/ reader.ReadInt32(); - m_FibWord97.fcSttbfRMark = reader.ReadInt32(); - m_FibWord97.lcbSttbfRMark = reader.ReadInt32(); - m_FibWord97.fcSttbfCaption = reader.ReadInt32(); - m_FibWord97.lcbSttbfCaption = reader.ReadInt32(); - m_FibWord97.fcSttbfAutoCaption = reader.ReadInt32(); - m_FibWord97.lcbSttbfAutoCaption = reader.ReadInt32(); - m_FibWord97.fcPlcfWkb = reader.ReadInt32(); //530 - m_FibWord97.lcbPlcfWkb = reader.ReadInt32(); - /*m_FibWord97.fcUnused4 =*/ reader.ReadInt32(); - /*m_FibWord97.lcbUnused4 =*/ reader.ReadInt32(); - m_FibWord97.fcPlcftxbxTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcftxbxTxt = reader.ReadInt32(); - m_FibWord97.fcPlcfFldTxbx = reader.ReadInt32(); - m_FibWord97.lcbPlcfFldTxbx = reader.ReadInt32(); - m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadInt32(); - m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadInt32(); - m_FibWord97.fcPlcffldHdrTxbx = reader.ReadInt32(); - m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadInt32(); - m_FibWord97.fcStwUser = reader.ReadInt32(); - m_FibWord97.lcbStwUser = reader.ReadInt32(); - m_FibWord97.fcSttbTtmbd = reader.ReadInt32(); - m_FibWord97.lcbSttbTtmbd = reader.ReadInt32(); - /*m_FibWord97.fcPlcunused = */reader.ReadInt32(); - /*m_FibWord97.lcbUnused = */reader.ReadInt32(); - - m_FibWord97.fcPgdMotherOldOld = reader.ReadInt32(); /*fcpgdMother.fcPgd*/ //602 - m_FibWord97.lcbPgdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbPgd*/ - m_FibWord97.fcBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.fcBkd*/ - m_FibWord97.lcbBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbBkd*/ // ???? size 2 ???? - - m_FibWord97.fcPgdFtnOldOld = reader.ReadInt32(); /*fcPgdFtn.fcPgd*/ - m_FibWord97.lcbPgdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ - m_FibWord97.fcBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ - m_FibWord97.lcbBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + /*m_FibWord97.fcUnused1 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused1 =*/ reader.ReadInt32(); + /*m_FibWord97.fcUnused2 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused2 =*/ reader.ReadInt32(); - m_FibWord97.fcPgdEdnOldOld = reader.ReadInt32(); /*fcpgdFtn.fcPgd*/ - m_FibWord97.lcbPgdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ - m_FibWord97.fcBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ - m_FibWord97.lcbBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ - - m_FibWord97.fcSttbfIntlFld = reader.ReadInt32(); - m_FibWord97.lcbSttbfIntlFld = reader.ReadInt32(); - m_FibWord97.fcRouteSlip = reader.ReadInt32(); //656 - m_FibWord97.lcbRouteSlip = reader.ReadInt32(); - m_FibWord97.fcSttbSavedBy = reader.ReadInt32(); - m_FibWord97.lcbSttbSavedBy = reader.ReadInt32(); - m_FibWord97.fcSttbFnm = reader.ReadInt32(); - m_FibWord97.lcbSttbFnm = reader.ReadInt32(); //676 + m_FibWord97.fcPlcfAtnBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfAtnBkf = reader.ReadInt32(); + m_FibWord97.fcPlcfAtnBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfAtnBkl = reader.ReadInt32(); + m_FibWord97.fcPms = reader.ReadInt32(); + m_FibWord97.lcbPms = reader.ReadInt32(); + m_FibWord97.fcFormFldSttbs/*f*/ = reader.ReadInt32(); + m_FibWord97.lcbFormFldSttbs/*f*/= reader.ReadInt32(); + + m_FibWord97.fcPlcfendRef = reader.ReadInt32(); //466 + m_FibWord97.lcbPlcfendRef = reader.ReadInt32(); + m_FibWord97.fcPlcfendTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfendTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfFldEdn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldEdn = reader.ReadInt32(); + /*m_FibWord97.fcPlcfpgdEdn =*/ reader.ReadInt32(); + /*m_FibWord97.lcbPlcfpgdEdn =*/ reader.ReadInt32(); + /*m_FibWord97.fcUnused3 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused3 =*/ reader.ReadInt32(); + m_FibWord97.fcSttbfRMark = reader.ReadInt32(); + m_FibWord97.lcbSttbfRMark = reader.ReadInt32(); + m_FibWord97.fcSttbfCaption = reader.ReadInt32(); + m_FibWord97.lcbSttbfCaption = reader.ReadInt32(); + m_FibWord97.fcSttbfAutoCaption = reader.ReadInt32(); + m_FibWord97.lcbSttbfAutoCaption = reader.ReadInt32(); + m_FibWord97.fcPlcfWkb = reader.ReadInt32(); //530 + m_FibWord97.lcbPlcfWkb = reader.ReadInt32(); + /*m_FibWord97.fcUnused4 =*/ reader.ReadInt32(); + /*m_FibWord97.lcbUnused4 =*/ reader.ReadInt32(); + m_FibWord97.fcPlcftxbxTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcftxbxTxt = reader.ReadInt32(); + m_FibWord97.fcPlcfFldTxbx = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldTxbx = reader.ReadInt32(); + m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadInt32(); + m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadInt32(); + m_FibWord97.fcPlcffldHdrTxbx = reader.ReadInt32(); + m_FibWord97.lcbPlcffldHdrTxbx = reader.ReadInt32(); + m_FibWord97.fcStwUser = reader.ReadInt32(); + m_FibWord97.lcbStwUser = reader.ReadInt32(); + m_FibWord97.fcSttbTtmbd = reader.ReadInt32(); + m_FibWord97.lcbSttbTtmbd = reader.ReadInt32(); + /*m_FibWord97.fcPlcunused = */reader.ReadInt32(); + /*m_FibWord97.lcbUnused = */reader.ReadInt32(); + + m_FibWord97.fcPgdMotherOldOld = reader.ReadInt32(); /*fcpgdMother.fcPgd*/ //602 + m_FibWord97.lcbPgdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbPgd*/ + m_FibWord97.fcBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.fcBkd*/ + m_FibWord97.lcbBkdMotherOldOld = reader.ReadInt32(); /*fcPgdMother.lcbBkd*/ // ???? size 2 ???? + + m_FibWord97.fcPgdFtnOldOld = reader.ReadInt32(); /*fcPgdFtn.fcPgd*/ + m_FibWord97.lcbPgdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ + m_FibWord97.fcBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ + m_FibWord97.lcbBkdFtnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + + m_FibWord97.fcPgdEdnOldOld = reader.ReadInt32(); /*fcpgdFtn.fcPgd*/ + m_FibWord97.lcbPgdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbPgd*/ + m_FibWord97.fcBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.fcBkd*/ + m_FibWord97.lcbBkdEdnOldOld = reader.ReadInt32(); /*rgfcpgdFtn.lcbBkd*/ + + m_FibWord97.fcSttbfIntlFld = reader.ReadInt32(); + m_FibWord97.lcbSttbfIntlFld = reader.ReadInt32(); + m_FibWord97.fcRouteSlip = reader.ReadInt32(); //656 + m_FibWord97.lcbRouteSlip = reader.ReadInt32(); + m_FibWord97.fcSttbSavedBy = reader.ReadInt32(); + m_FibWord97.lcbSttbSavedBy = reader.ReadInt32(); + m_FibWord97.fcSttbFnm = reader.ReadInt32(); + m_FibWord97.lcbSttbFnm = reader.ReadInt32(); //676 + } + else + { + m_FibWord97.fcStshfOrig = reader.ReadInt32();// 0x58 + m_FibWord97.lcbStshfOrig = reader.ReadInt16(); + m_FibWord97.fcStshf = reader.ReadInt32(); + m_FibWord97.lcbStshf = reader.ReadInt16();//0x62 + + m_FibWord97.fcPlcffndRef = reader.ReadInt32(); + m_FibWord97.lcbPlcffndRef = reader.ReadInt16();//0x68 + + m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//0x6a + m_FibWord97.lcbPlcffndTxt = reader.ReadInt16(); + + m_FibWord97.fcPlcfandRef = reader.ReadInt32();//0x70 + m_FibWord97.lcbPlcfandRef = reader.ReadInt16(); + + m_FibWord97.fcPlcfandTxt = reader.ReadInt32();//0x76 + m_FibWord97.lcbPlcfandTxt = reader.ReadInt16(); + + m_FibWord97.fcPlcfSed = reader.ReadInt32(); //0x7c + m_FibWord97.lcbPlcfSed = reader.ReadInt16(); + + m_FibWord97.fcPlcPad = reader.ReadInt32();//fcPlcfpgd + m_FibWord97.lcbPlcPad = reader.ReadInt16();//cbPlcfpgd + + m_FibWord97.fcPlcfPhe = reader.ReadInt32();// 0x88 + m_FibWord97.lcbPlcfPhe = reader.ReadInt16(); + + m_FibWord97.fcSttbfGlsy = reader.ReadInt32(); + m_FibWord97.lcbSttbfGlsy = reader.ReadInt16(); + + m_FibWord97.fcPlcfGlsy = reader.ReadInt32(); + m_FibWord97.lcbPlcfGlsy = reader.ReadInt16(); + + m_FibWord97.fcPlcfHdd = reader.ReadInt32();// 0x9a + m_FibWord97.lcbPlcfHdd = reader.ReadInt16(); + + m_FibWord97.fcPlcfBteChpx = reader.ReadInt32(); + m_FibWord97.lcbPlcfBteChpx = reader.ReadInt16(); + + m_FibWord97.fcPlcfBtePapx = reader.ReadInt32();// 0xa0 + m_FibWord97.lcbPlcfBtePapx = reader.ReadInt16(); + + m_FibWord97.fcPlcfSea = reader.ReadInt32();// 0xac + m_FibWord97.lcbPlcfSea = reader.ReadInt16(); + + m_FibWord97.fcSttbfFfn = reader.ReadInt32();// 0xb2 + m_FibWord97.lcbSttbfFfn = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldMom = reader.ReadInt32(); // 0xb8=184 + m_FibWord97.lcbPlcfFldMom = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldHdr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldHdr = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldFtn = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldAtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldAtn = reader.ReadInt16(); + + m_FibWord97.fcPlcfFldMcr = reader.ReadInt32(); + m_FibWord97.lcbPlcfFldMcr = reader.ReadInt16(); + + m_FibWord97.fcSttbfBkmk = reader.ReadInt32();// 0xd6 + m_FibWord97.lcbSttbfBkmk = reader.ReadInt16(); + + m_FibWord97.fcPlcfBkf = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkf = reader.ReadInt16(); + + m_FibWord97.fcPlcfBkl = reader.ReadInt32(); + m_FibWord97.lcbPlcfBkl = reader.ReadInt16(); + + m_FibWord97.fcCmds = reader.ReadInt32();// 0xe8 + m_FibWord97.lcbCmds = reader.ReadInt16(); + + m_FibWord2.fcPlcMcr = reader.ReadInt32();// 0xee + m_FibWord2.lcbPlcMcr = reader.ReadInt16(); + + m_FibWord97.fcSttbfMcr = reader.ReadInt32();// 0xf4 + m_FibWord97.lcbSttbfMcr = reader.ReadInt16(); + + m_FibWord2.fcPrEnv = reader.ReadInt32(); // 0xfa + m_FibWord2.lcbPrEnv = reader.ReadInt16(); //316 + + m_FibWord97.fcWss = reader.ReadInt32();// 0x100 + m_FibWord97.lcbWss = reader.ReadInt16(); + + m_FibWord97.fcDop = reader.ReadInt32();// 0x106 + m_FibWord97.lcbDop = reader.ReadInt16(); + + m_FibWord97.fcSttbfAssoc = reader.ReadInt32(); + m_FibWord97.lcbSttbfAssoc = reader.ReadInt16(); + + m_FibWord97.fcClx = reader.ReadInt32(); // 0x112 + m_FibWord97.lcbClx = reader.ReadInt16(); + + m_FibWord97.fcPlcfPgdFtn = reader.ReadInt32(); + m_FibWord97.lcbPlcfPgdFtn = reader.ReadInt16(); + + m_FibWord97.fcAutosaveSource = reader.ReadInt32(); + m_FibWord97.lcbAutosaveSource = reader.ReadInt16(); + + m_FibWord2.fcSpare5 = reader.ReadInt32(); + m_FibWord2.lcbSpare5 = reader.ReadInt16(); + m_FibWord2.fcSpare6 = reader.ReadInt32(); + m_FibWord2.lcbSpare6 = reader.ReadInt16(); + m_FibWord2.wSpare4 = reader.ReadInt16(); + + m_FibWord2.pnChpFirst = reader.ReadInt16(); + m_FibWord2.pnPapFirst = reader.ReadInt16(); + m_FibWord2.cpnBteChp = reader.ReadInt16(); + m_FibWord2.cpnBtePap = reader.ReadInt16(); + } } if (m_FibBase.nFib > Fib1995 || m_FibBase.nFib == 0) { @@ -761,7 +884,6 @@ namespace DocFileFormat cbRgFcLcb = reader.ReadUInt16(); //152 - //Read the FibRgFcLcb97 m_FibWord97.fcStshfOrig = reader.ReadUInt32(); //154 m_FibWord97.lcbStshfOrig = reader.ReadUInt32(); //158 m_FibWord97.fcStshf = reader.ReadUInt32(); //162 @@ -870,22 +992,22 @@ namespace DocFileFormat reader.ReadUInt32(); //546 reader.ReadUInt32(); //550 - m_FibWord97.fcDggInfo = reader.ReadUInt32(); //554 - m_FibWord97.lcbDggInfo = reader.ReadUInt32(); //558 - m_FibWord97.fcSttbfRMark = reader.ReadUInt32(); //562 - m_FibWord97.lcbSttbfRMark = reader.ReadUInt32(); //566 - m_FibWord97.fcSttbfCaption = reader.ReadUInt32(); //570 + m_FibWord97.fcDggInfo = reader.ReadUInt32(); //554 + m_FibWord97.lcbDggInfo = reader.ReadUInt32(); //558 + m_FibWord97.fcSttbfRMark = reader.ReadUInt32(); //562 + m_FibWord97.lcbSttbfRMark = reader.ReadUInt32(); //566 + m_FibWord97.fcSttbfCaption = reader.ReadUInt32(); //570 m_FibWord97.lcbSttbfCaption = reader.ReadUInt32(); //574 m_FibWord97.fcSttbfAutoCaption = reader.ReadUInt32(); //578 m_FibWord97.lcbSttbfAutoCaption = reader.ReadUInt32(); //582 - m_FibWord97.fcPlcfWkb = reader.ReadUInt32(); //586 - m_FibWord97.lcbPlcfWkb = reader.ReadUInt32(); //590 - m_FibWord97.fcPlcfSpl = reader.ReadUInt32(); //594 - m_FibWord97.lcbPlcfSpl = reader.ReadUInt32(); //598 - m_FibWord97.fcPlcftxbxTxt = reader.ReadUInt32(); //602 - m_FibWord97.lcbPlcftxbxTxt = reader.ReadUInt32(); //606 - m_FibWord97.fcPlcfFldTxbx = reader.ReadUInt32(); //610 - m_FibWord97.lcbPlcfFldTxbx = reader.ReadUInt32(); //614 + m_FibWord97.fcPlcfWkb = reader.ReadUInt32(); //586 + m_FibWord97.lcbPlcfWkb = reader.ReadUInt32(); //590 + m_FibWord97.fcPlcfSpl = reader.ReadUInt32(); //594 + m_FibWord97.lcbPlcfSpl = reader.ReadUInt32(); //598 + m_FibWord97.fcPlcftxbxTxt = reader.ReadUInt32(); //602 + m_FibWord97.lcbPlcftxbxTxt = reader.ReadUInt32(); //606 + m_FibWord97.fcPlcfFldTxbx = reader.ReadUInt32(); //610 + m_FibWord97.lcbPlcfFldTxbx = reader.ReadUInt32(); //614 m_FibWord97.fcPlcfHdrtxbxTxt = reader.ReadUInt32(); //618 m_FibWord97.lcbPlcfHdrtxbxTxt = reader.ReadUInt32(); //622 m_FibWord97.fcPlcffldHdrTxbx = reader.ReadUInt32(); //626 @@ -964,7 +1086,7 @@ namespace DocFileFormat m_FibWord2000.fcPlcfTch = reader.ReadUInt32(); //898 m_FibWord2000.lcbPlcfTch = reader.ReadUInt32(); //902 m_FibWord2000.fcRmdThreading = reader.ReadUInt32(); //906 - m_FibWord2000.lcbRmdThreading = reader.ReadUInt32(); //910 + m_FibWord2000.lcbRmdThreading = reader.ReadUInt32(); //910 m_FibWord2000.fcMid = reader.ReadUInt32(); //914 m_FibWord2000.lcbMid = reader.ReadUInt32(); //918 m_FibWord2000.fcSttbRgtplc = reader.ReadUInt32(); //922 @@ -997,58 +1119,58 @@ namespace DocFileFormat //Read also the fibRgFcLcb2002 reader.ReadUInt32(); //1018 reader.ReadUInt32(); //1022 - m_FibWord2002.fcPlcfPgp = reader.ReadUInt32(); //1026 + m_FibWord2002.fcPlcfPgp = reader.ReadUInt32(); //1026 m_FibWord2002.lcbPlcfPgp = reader.ReadUInt32(); //1030 - m_FibWord2002.fcPlcfuim = reader.ReadUInt32(); //1034 + m_FibWord2002.fcPlcfuim = reader.ReadUInt32(); //1034 m_FibWord2002.lcbPlcfuim = reader.ReadUInt32(); //1038 - m_FibWord2002.fcPlfguidUim = reader.ReadUInt32(); //1042 - m_FibWord2002.lcbPlfguidUim = reader.ReadUInt32(); //1046 + m_FibWord2002.fcPlfguidUim = reader.ReadUInt32(); //1042 + m_FibWord2002.lcbPlfguidUim = reader.ReadUInt32(); //1046 m_FibWord2002.fcAtrdExtra = reader.ReadUInt32(); //1050 - m_FibWord2002.lcbAtrdExtra = reader.ReadUInt32(); //1054 - m_FibWord2002.fcPlrsid = reader.ReadUInt32(); //1058 - m_FibWord2002.lcbPlrsid = reader.ReadUInt32(); //1062 + m_FibWord2002.lcbAtrdExtra = reader.ReadUInt32(); //1054 + m_FibWord2002.fcPlrsid = reader.ReadUInt32(); //1058 + m_FibWord2002.lcbPlrsid = reader.ReadUInt32(); //1062 m_FibWord2002.fcSttbfBkmkFactoid = reader.ReadUInt32(); //1066 m_FibWord2002.lcbSttbfBkmkFactoid = reader.ReadUInt32(); //1070 - m_FibWord2002.fcPlcfBkfFactoid = reader.ReadUInt32(); //1074 + m_FibWord2002.fcPlcfBkfFactoid = reader.ReadUInt32(); //1074 m_FibWord2002.lcbPlcfBkfFactoid = reader.ReadUInt32(); //1078 - m_FibWord2002.fcPlcfcookie = reader.ReadUInt32(); //1082 - m_FibWord2002.lcbPlcfcookie = reader.ReadUInt32(); //1086 + m_FibWord2002.fcPlcfcookie = reader.ReadUInt32(); //1082 + m_FibWord2002.lcbPlcfcookie = reader.ReadUInt32(); //1086 m_FibWord2002.fcPlcfBklFactoid = reader.ReadUInt32(); //1090 m_FibWord2002.lcbPlcfBklFactoid = reader.ReadUInt32(); //1094 - m_FibWord2002.fcFactoidData = reader.ReadUInt32(); //1098 + m_FibWord2002.fcFactoidData = reader.ReadUInt32(); //1098 m_FibWord2002.lcbFactoidData = reader.ReadUInt32(); //1102 - m_FibWord2002.fcDocUndo = reader.ReadUInt32(); //1106 + m_FibWord2002.fcDocUndo = reader.ReadUInt32(); //1106 m_FibWord2002.lcbDocUndo = reader.ReadUInt32(); //1110 m_FibWord2002.fcSttbfBkmkFcc = reader.ReadUInt32(); //1114 - m_FibWord2002.lcbSttbfBkmkFcc = reader.ReadUInt32(); //1118 - m_FibWord2002.fcPlcfBkfFcc = reader.ReadUInt32(); //1122 - m_FibWord2002.lcbPlcfBkfFcc = reader.ReadUInt32(); //1126 - m_FibWord2002.fcPlcfBklFcc = reader.ReadUInt32(); //1130 - m_FibWord2002.lcbPlcfBklFcc = reader.ReadUInt32(); //1134 + m_FibWord2002.lcbSttbfBkmkFcc = reader.ReadUInt32(); //1118 + m_FibWord2002.fcPlcfBkfFcc = reader.ReadUInt32(); //1122 + m_FibWord2002.lcbPlcfBkfFcc = reader.ReadUInt32(); //1126 + m_FibWord2002.fcPlcfBklFcc = reader.ReadUInt32(); //1130 + m_FibWord2002.lcbPlcfBklFcc = reader.ReadUInt32(); //1134 m_FibWord2002.fcSttbfbkmkBPRepairs = reader.ReadUInt32(); //1138 m_FibWord2002.lcbSttbfbkmkBPRepairs = reader.ReadUInt32(); //1142 m_FibWord2002.fcPlcfbkfBPRepairs = reader.ReadUInt32(); //1146 m_FibWord2002.lcbPlcfbkfBPRepairs = reader.ReadUInt32(); //1150 m_FibWord2002.fcPlcfbklBPRepairs = reader.ReadUInt32(); //1154 m_FibWord2002.lcbPlcfbklBPRepairs = reader.ReadUInt32(); //1158 - m_FibWord2002.fcPmsNew = reader.ReadUInt32(); //1162 - m_FibWord2002.lcbPmsNew = reader.ReadUInt32(); //1166 + m_FibWord2002.fcPmsNew = reader.ReadUInt32(); //1162 + m_FibWord2002.lcbPmsNew = reader.ReadUInt32(); //1166 m_FibWord2002.fcODSO = reader.ReadUInt32(); //1170 m_FibWord2002.lcbODSO = reader.ReadUInt32(); //1174 m_FibWord2002.fcPlcfpmiOldXP = reader.ReadUInt32(); //1178 m_FibWord2002.lcbPlcfpmiOldXP = reader.ReadUInt32(); //1182 m_FibWord2002.fcPlcfpmiNewXP = reader.ReadUInt32(); //1186 - m_FibWord2002.lcbPlcfpmiNewXP = reader.ReadUInt32(); //1190 - m_FibWord2002.fcPlcfpmiMixedXP = reader.ReadUInt32(); //1194 + m_FibWord2002.lcbPlcfpmiNewXP = reader.ReadUInt32(); //1190 + m_FibWord2002.fcPlcfpmiMixedXP = reader.ReadUInt32(); //1194 m_FibWord2002.lcbPlcfpmiMixedXP = reader.ReadUInt32(); //1198 reader.ReadUInt32(); //1202 reader.ReadUInt32(); //1206 m_FibWord2002.fcPlcffactoid = reader.ReadUInt32(); //1210 - m_FibWord2002.lcbPlcffactoid = reader.ReadUInt32(); //1214 - m_FibWord2002.fcPlcflvcOldXP = reader.ReadUInt32(); //1218 - m_FibWord2002.lcbPlcflvcOldXP = reader.ReadUInt32(); //1222 - m_FibWord2002.fcPlcflvcNewXP = reader.ReadUInt32(); //1226 - m_FibWord2002.lcbPlcflvcNewXP = reader.ReadUInt32(); //1230 + m_FibWord2002.lcbPlcffactoid = reader.ReadUInt32(); //1214 + m_FibWord2002.fcPlcflvcOldXP = reader.ReadUInt32(); //1218 + m_FibWord2002.lcbPlcflvcOldXP = reader.ReadUInt32(); //1222 + m_FibWord2002.fcPlcflvcNewXP = reader.ReadUInt32(); //1226 + m_FibWord2002.lcbPlcflvcNewXP = reader.ReadUInt32(); //1230 m_FibWord2002.fcPlcflvcMixedXP = reader.ReadUInt32(); //1234 m_FibWord2002.lcbPlcflvcMixedXP = reader.ReadUInt32(); //1238 } @@ -1056,46 +1178,46 @@ namespace DocFileFormat { //Read also the fibRgFcLcb2003 m_FibWord2003.fcHplxsdr = reader.ReadUInt32(); - m_FibWord2003.lcbHplxsdr = reader.ReadUInt32(); - m_FibWord2003.fcSttbfBkmkSdt = reader.ReadUInt32(); - m_FibWord2003.lcbSttbfBkmkSdt = reader.ReadUInt32(); + m_FibWord2003.lcbHplxsdr = reader.ReadUInt32(); + m_FibWord2003.fcSttbfBkmkSdt = reader.ReadUInt32(); + m_FibWord2003.lcbSttbfBkmkSdt = reader.ReadUInt32(); m_FibWord2003.fcPlcfBkfSdt = reader.ReadUInt32(); m_FibWord2003.lcbPlcfBkfSdt = reader.ReadUInt32(); m_FibWord2003.fcPlcfBklSdt = reader.ReadUInt32(); m_FibWord2003.lcbPlcfBklSdt = reader.ReadUInt32(); m_FibWord2003.fcCustomXForm = reader.ReadUInt32(); - m_FibWord2003.lcbCustomXForm = reader.ReadUInt32(); - m_FibWord2003.fcSttbfBkmkProt = reader.ReadUInt32(); + m_FibWord2003.lcbCustomXForm = reader.ReadUInt32(); + m_FibWord2003.fcSttbfBkmkProt = reader.ReadUInt32(); m_FibWord2003.lcbSttbfBkmkProt = reader.ReadUInt32(); m_FibWord2003.fcPlcfBkfProt = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfBkfProt = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBkfProt = reader.ReadUInt32(); m_FibWord2003.fcPlcfBklProt = reader.ReadUInt32(); - m_FibWord2003.lcbPlcfBklProt = reader.ReadUInt32(); - m_FibWord2003.fcSttbProtUser = reader.ReadUInt32(); - m_FibWord2003.lcbSttbProtUser = reader.ReadUInt32(); + m_FibWord2003.lcbPlcfBklProt = reader.ReadUInt32(); + m_FibWord2003.fcSttbProtUser = reader.ReadUInt32(); + m_FibWord2003.lcbSttbProtUser = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); m_FibWord2003.fcPlcfpmiOld = reader.ReadUInt32(); m_FibWord2003.lcbPlcfpmiOld = reader.ReadUInt32(); - m_FibWord2003.fcPlcfpmiOldInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiOldInline= reader.ReadUInt32(); m_FibWord2003.lcbPlcfpmiOldInline = reader.ReadUInt32(); m_FibWord2003.fcPlcfpmiNew = reader.ReadUInt32(); m_FibWord2003.lcbPlcfpmiNew = reader.ReadUInt32(); - m_FibWord2003.fcPlcfpmiNewInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcfpmiNewInline= reader.ReadUInt32(); m_FibWord2003.lcbPlcfpmiNewInline = reader.ReadUInt32(); m_FibWord2003.fcPlcflvcOld = reader.ReadUInt32(); m_FibWord2003.lcbPlcflvcOld = reader.ReadUInt32(); - m_FibWord2003.fcPlcflvcOldInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcOldInline= reader.ReadUInt32(); m_FibWord2003.lcbPlcflvcOldInline = reader.ReadUInt32(); m_FibWord2003.fcPlcflvcNew = reader.ReadUInt32(); m_FibWord2003.lcbPlcflvcNew = reader.ReadUInt32(); - m_FibWord2003.fcPlcflvcNewInline = reader.ReadUInt32(); + m_FibWord2003.fcPlcflvcNewInline= reader.ReadUInt32(); m_FibWord2003.lcbPlcflvcNewInline = reader.ReadUInt32(); - m_FibWord2003.fcPgdMother = reader.ReadUInt32(); + m_FibWord2003.fcPgdMother = reader.ReadUInt32(); m_FibWord2003.lcbPgdMother = reader.ReadUInt32(); - m_FibWord2003.fcBkdMother = reader.ReadUInt32(); + m_FibWord2003.fcBkdMother = reader.ReadUInt32(); m_FibWord2003.lcbBkdMother = reader.ReadUInt32(); - m_FibWord2003.fcAfdMother = reader.ReadUInt32(); + m_FibWord2003.fcAfdMother = reader.ReadUInt32(); m_FibWord2003.lcbAfdMother = reader.ReadUInt32(); m_FibWord2003.fcPgdFtn = reader.ReadUInt32(); m_FibWord2003.lcbPgdFtn = reader.ReadUInt32(); @@ -1110,24 +1232,24 @@ namespace DocFileFormat m_FibWord2003.fcAfdEdn = reader.ReadUInt32(); m_FibWord2003.lcbAfdEdn = reader.ReadUInt32(); m_FibWord2003.fcAfd = reader.ReadUInt32(); - m_FibWord2003.lcbAfd = reader.ReadUInt32(); + m_FibWord2003.lcbAfd = reader.ReadUInt32(); } if ( m_FibBase.nFib >= Fib2007 ) { //Read also the fibRgFcLcb2007 - m_FibWord2007.fcPlcfmthd = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfmthd = reader.ReadUInt32(); + m_FibWord2007.fcPlcfmthd = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfmthd = reader.ReadUInt32(); m_FibWord2007.fcSttbfBkmkMoveFrom = reader.ReadUInt32(); m_FibWord2007.lcbSttbfBkmkMoveFrom = reader.ReadUInt32(); m_FibWord2007.fcPlcfBkfMoveFrom = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBkfMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfMoveFrom= reader.ReadUInt32(); m_FibWord2007.fcPlcfBklMoveFrom = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBklMoveFrom = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklMoveFrom= reader.ReadUInt32(); m_FibWord2007.fcSttbfBkmkMoveTo = reader.ReadUInt32(); - m_FibWord2007.lcbSttbfBkmkMoveTo = reader.ReadUInt32(); - m_FibWord2007.fcPlcfBkfMoveTo = reader.ReadUInt32(); + m_FibWord2007.lcbSttbfBkmkMoveTo= reader.ReadUInt32(); + m_FibWord2007.fcPlcfBkfMoveTo = reader.ReadUInt32(); m_FibWord2007.lcbPlcfBkfMoveTo = reader.ReadUInt32(); - m_FibWord2007.fcPlcfBklMoveTo = reader.ReadUInt32(); + m_FibWord2007.fcPlcfBklMoveTo = reader.ReadUInt32(); m_FibWord2007.lcbPlcfBklMoveTo = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); @@ -1135,22 +1257,22 @@ namespace DocFileFormat reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); - m_FibWord2007.fcSttbfBkmkArto = reader.ReadUInt32(); + m_FibWord2007.fcSttbfBkmkArto = reader.ReadUInt32(); m_FibWord2007.lcbSttbfBkmkArto = reader.ReadUInt32(); m_FibWord2007.fcPlcfBkfArto = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBkfArto = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBkfArto = reader.ReadUInt32(); m_FibWord2007.fcPlcfBklArto = reader.ReadUInt32(); - m_FibWord2007.lcbPlcfBklArto = reader.ReadUInt32(); - m_FibWord2007.fcArtoData = reader.ReadUInt32(); - m_FibWord2007.lcbArtoData = reader.ReadUInt32(); + m_FibWord2007.lcbPlcfBklArto = reader.ReadUInt32(); + m_FibWord2007.fcArtoData = reader.ReadUInt32(); + m_FibWord2007.lcbArtoData = reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); - m_FibWord2007.fcOssTheme = reader.ReadUInt32(); - m_FibWord2007.lcbOssTheme = reader.ReadUInt32(); + m_FibWord2007.fcOssTheme = reader.ReadUInt32(); + m_FibWord2007.lcbOssTheme = reader.ReadUInt32(); m_FibWord2007.fcColorSchemeMapping = reader.ReadUInt32(); m_FibWord2007.lcbColorSchemeMapping = reader.ReadUInt32(); } @@ -1168,15 +1290,15 @@ namespace DocFileFormat } FileInformationBlock( VirtualStreamReader reader ) { - m_bOlderVersion = false; + m_nWordVersion = 0; m_CodePage = 1250; unsigned int flag16 = 0; unsigned char flag8 = 0; //read the FIB base - m_FibBase.wIdent = reader.ReadUInt16(); //0 - m_FibBase.nFib = (FibVersion)reader.ReadUInt16(); //2 + m_FibBase.wIdent = reader.ReadUInt16(); //0 + m_FibBase.nFib = (FibVersion)reader.ReadUInt16(); //2 reader.ReadBytes( 2, false ); //4 //nProduct @@ -1185,36 +1307,47 @@ namespace DocFileFormat flag16 = reader.ReadUInt16(); //10 - m_FibBase.fDot = FormatUtils::BitmaskToBool((int)flag16, 0x0001); - m_FibBase.fGlsy = FormatUtils::BitmaskToBool((int)flag16, 0x0002); - m_FibBase.fComplex = FormatUtils::BitmaskToBool((int)flag16, 0x0002); - m_FibBase.fHasPic = FormatUtils::BitmaskToBool((int)flag16, 0x0008); + m_FibBase.fDot = (flag16 & 0x0001) >> 2; + m_FibBase.fGlsy = (flag16 & 0x0002) >> 1; + m_FibBase.fComplex = (flag16 & 0x0004) >> 2; + m_FibBase.fHasPic = (flag16 & 0x0008) >> 3; m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4); m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100); m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200); m_FibBase.fReadOnlyRecommended = FormatUtils::BitmaskToBool((int)flag16, 0x0400); m_FibBase.fWriteReservation = FormatUtils::BitmaskToBool((int)flag16, 0x0800); m_FibBase.fExtChar = FormatUtils::BitmaskToBool((int)flag16, 0x1000); - m_FibBase.fLoadOverwrite = FormatUtils::BitmaskToBool((int)flag16, 0x2000); + m_FibBase.fLoadOverwrite = FormatUtils::BitmaskToBool((int)flag16, 0x2000); m_FibBase.fFarEast = FormatUtils::BitmaskToBool((int)flag16, 0x4000); m_FibBase.fObfuscation = FormatUtils::BitmaskToBool((int)flag16, 0x8000); m_FibBase.nFibBack = reader.ReadUInt16(); //12 - m_FibBase.lKey = reader.ReadInt32(); //14 - m_FibBase.envr = reader.ReadByte(); //18 + + if (m_FibBase.nFib < Fib1989) + { + m_FibWord2.Spare = reader.ReadInt32(); + m_FibWord2.rgwSpare0[0] = reader.ReadUInt16(); + m_FibWord2.rgwSpare0[1] = reader.ReadUInt16(); + m_FibWord2.rgwSpare0[2] = reader.ReadUInt16(); + } + else + { + m_FibBase.lKey = reader.ReadInt32(); //14 + m_FibBase.envr = reader.ReadByte(); //18 + + flag8 = reader.ReadByte(); //19 + + m_FibBase.fMac = FormatUtils::BitmaskToBool((int)flag8, 0x01); + m_FibBase.fEmptySpecial = FormatUtils::BitmaskToBool((int)flag8, 0x02); + m_FibBase.fLoadOverridePage = FormatUtils::BitmaskToBool((int)flag8, 0x04); + m_FibBase.fFutureSavedUndo = FormatUtils::BitmaskToBool((int)flag8, 0x08); + m_FibBase.fWord97Saved = FormatUtils::BitmaskToBool((int)flag8, 0x10); + + reader.ReadBytes( 4, false ); //20 + } - flag8 = reader.ReadByte(); //19 - - m_FibBase.fMac = FormatUtils::BitmaskToBool((int)flag8, 0x01); - m_FibBase.fEmptySpecial = FormatUtils::BitmaskToBool((int)flag8, 0x02); - m_FibBase.fLoadOverridePage = FormatUtils::BitmaskToBool((int)flag8, 0x04); - m_FibBase.fFutureSavedUndo = FormatUtils::BitmaskToBool((int)flag8, 0x08); - m_FibBase.fWord97Saved = FormatUtils::BitmaskToBool((int)flag8, 0x10); - - reader.ReadBytes( 4, false ); //20 - - m_FibBase.fcMin = reader.ReadInt32(); //24 - m_FibBase.fcMac = reader.ReadInt32(); //28 + m_FibBase.fcMin = reader.ReadInt32(); //24 + m_FibBase.fcMac = reader.ReadInt32(); //28 if (m_FibBase.nFib > Fib1995) csw = reader.ReadUInt16(); //32 diff --git a/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp b/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp index d26b256ce6..3454efe814 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FontFamilyName.cpp @@ -69,14 +69,22 @@ namespace DocFileFormat newObject->prq = (unsigned char) FormatUtils::BitmaskToInt ( ffid, 0x03 ); newObject->fTrueType = FormatUtils::BitmaskToBool ( ffid, 0x04 ); newObject->ff = (unsigned char) FormatUtils::BitmaskToInt ( ffid, 0x70 ); - newObject->wWeight = reader->ReadInt16(); - newObject->chs = reader->ReadByte(); //int sz_fonts = 150; //.. нужно генерить уникальное todooo + int szAlt = 0; + if (reader->nWordVersion == 2) + { + newObject->wWeight = reader->ReadByte(); + } + else + { + newObject->wWeight = reader->ReadInt16(); + newObject->chs = reader->ReadByte(); - int szAlt = reader->ReadByte(); + szAlt = reader->ReadByte(); + } - if (!reader->olderVersion) + if (reader->nWordVersion == 0) { //read the 10 bytes panose newObject->panoseSize = 10; @@ -97,7 +105,7 @@ namespace DocFileFormat unsigned char *bytes = reader->ReadBytes( (int)( strEnd - strStart ), true ); - if (reader->olderVersion) + if (reader->nWordVersion > 0) { FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszFtn), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250 ); } @@ -131,7 +139,7 @@ namespace DocFileFormat bytes = reader->ReadBytes( (int)( strEnd - strStart ), true ); - if (reader->olderVersion) + if (reader->nWordVersion > 0) { FormatUtils::GetSTLCollectionFromBytes( &(newObject->xszAlt), bytes, (int)( strEnd - strStart ), ENCODING_WINDOWS_1250); } @@ -151,7 +159,7 @@ namespace DocFileFormat { long strStart = reader->GetPosition(); - if (reader->olderVersion) + if (reader->nWordVersion > 0) {//ansi string only while ( reader->ReadByte() != 0 ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp index 99ba01918b..c568f31f08 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FooterMapping.cpp @@ -71,7 +71,7 @@ namespace DocFileFormat if (fc < 0) break; ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( tai.fInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h b/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h index a6d73e9115..3a88ef5a06 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/FootnotesMapping.h @@ -81,7 +81,7 @@ namespace DocFileFormat if (fc < 0) break; ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( tai.fInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp b/ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp index dba8fa7afa..148953db90 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp @@ -98,7 +98,7 @@ void FormFieldData::_FFData::read(VirtualStreamReader *reader) xstzEntryMcr = readXstz(reader); xstzExitMcr = readXstz(reader); } -FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion_ ) +FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion ) { binary_data_size = 0; @@ -139,7 +139,7 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, if (fc >= 0 && bNilPICFAndBinData) { - VirtualStreamReader reader(stream, fc, bOlderVersion_); + VirtualStreamReader reader(stream, fc, nWordVersion); int sz_stream = reader.GetSize(); diff --git a/ASCOfficeDocFile/DocDocxConverter/FormFieldData.h b/ASCOfficeDocFile/DocDocxConverter/FormFieldData.h index 1c4863d04f..ef8e568eca 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormFieldData.h +++ b/ASCOfficeDocFile/DocDocxConverter/FormFieldData.h @@ -108,7 +108,7 @@ namespace DocFileFormat //STTB hsttbDropList; void read(VirtualStreamReader* reader); }; - FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion ); + FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, int nWordVersion ); virtual ~FormFieldData() {} private: friend class FormFieldDataMapping; diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp index 21da3a07b5..ec1cf63ddc 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.cpp @@ -52,7 +52,7 @@ namespace DocFileFormat /*========================================================================================================*/ - FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ): + FormattedDiskPageCHPX::FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, int nWordVersion ): FormattedDiskPage(), rgb(NULL), grpchpxSize(NULL), grpchpx(NULL) { Type = Character; @@ -80,7 +80,6 @@ namespace DocFileFormat j += 4; } - //create arrays grpchpxSize = crun; rgb = new unsigned char[crun]; grpchpx = new CharacterPropertyExceptions*[grpchpxSize]; @@ -104,11 +103,10 @@ namespace DocFileFormat //read the bytes of chpx chpx = new unsigned char[cb]; - //Array.Copy(bytes, (wordOffset * 2) + 1, chpx, 0, chpx.Length); memcpy( chpx, ( bytes + (wordOffset * 2) + 1 ), cb ); //parse CHPX and fill grpchpx - grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, oldVersion); + grpchpx[i] = new CharacterPropertyExceptions( chpx, cb, nWordVersion); RELEASEARRAYOBJECTS( chpx ); } @@ -139,7 +137,7 @@ namespace DocFileFormat } //there are n offsets and n-1 fkp's in the bin table - if (fib->m_bOlderVersion) + if (fib->m_nWordVersion > 0) { int n = ( ( (int)fib->m_FibWord97.lcbPlcfBteChpx - 8 ) / 6 ) + 1; @@ -162,7 +160,7 @@ namespace DocFileFormat int offset = fkpnr * 512; //parse the FKP and add it to the list - CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) ); + CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_nWordVersion ) ); } } else @@ -178,7 +176,7 @@ namespace DocFileFormat int offset = fkpnr * 512; //parse the FKP and add it to the list - CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_bOlderVersion ) ); + CHPXlist->push_back( new FormattedDiskPageCHPX( wordStream, offset, fib->m_nWordVersion ) ); } } diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h index 3048176a30..095054603f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPageCHPX.h @@ -50,7 +50,7 @@ namespace DocFileFormat public: virtual ~FormattedDiskPageCHPX(); - FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, bool oldVersion ); + FormattedDiskPageCHPX( POLE::Stream* wordStream, int offset, int nWordVersion ); /// Parses the 0Table (or 1Table) for FKP _entries containing CHPX static std::list* GetAllCHPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream ); }; diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp index 48d3d0fa26..1c9f1b6fdb 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp @@ -52,59 +52,53 @@ namespace DocFileFormat /*========================================================================================================*/ - FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex): + FormattedDiskPagePAPX::FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, int nWordVersion, bool fComplex): FormattedDiskPage(), rgbx(NULL), grppapxSize(0), grppapx(NULL) - { - Type = Paragraph; - WordStream = wordStream; + { + Type = Paragraph; + WordStream = wordStream; - //read the 512 bytes (FKP) - unsigned char* bytes = NULL; - bytes = new unsigned char[512]; - - WordStream->seek( offset); - WordStream->read( bytes, 512); + //read the 512 bytes (FKP) + unsigned char* bytes = NULL; + bytes = new unsigned char[512]; - //get the count - crun = bytes[511]; + WordStream->seek( offset); + WordStream->read( bytes, 512); - //create and fill the array with the adresses - rgfcSize = crun + 1; - rgfc = new int[rgfcSize]; + //get the count + crun = bytes[511]; - int j = 0; + //create and fill the array with the adresses + rgfcSize = crun + 1; + rgfc = new int[rgfcSize]; + + int j = 0; - for ( unsigned int i = 0; i < rgfcSize; i++ ) - { - rgfc[i] = FormatUtils::BytesToInt32( bytes, j, 512 ); - j += 4; - } + for ( unsigned int i = 0; i < rgfcSize; i++ ) + { + rgfc[i] = FormatUtils::BytesToInt32( bytes, j, 512 ); + j += 4; + } + rgbx = new BX[crun]; + grppapxSize = crun; + grppapx = new ParagraphPropertyExceptions*[grppapxSize]; - //create arrays - rgbx = new BX[crun]; - grppapxSize = crun; - grppapx = new ParagraphPropertyExceptions*[grppapxSize]; + for ( unsigned int i = 0; i < grppapxSize; i++ ) + { + grppapx[i] = NULL; + } - for ( unsigned int i = 0; i < grppapxSize; i++ ) - { - grppapx[i] = NULL; - } + j = 4 * ( crun + 1 ); - j = 4 * ( crun + 1 ); - - //read the 12 for PHE - unsigned char* phe = NULL; - phe = new unsigned char[12]; - - unsigned char* papx = NULL; + unsigned char phe[12]; - for ( int i = 0; i < crun; i++ ) + for ( unsigned char i = 0; i < crun; i++ ) { BX bx; bx.wordOffset = bytes[j]; j++; - if (fComplex || !oldVersion) + if (fComplex || nWordVersion == 0) { memcpy( phe, ( bytes + j), 12 ); @@ -113,6 +107,15 @@ namespace DocFileFormat j += 12; } + else if (nWordVersion == 2) + { + memcpy( phe, ( bytes + bx.wordOffset * 2 + j + 1), 6); + + //fill the rgbx array + bx.phe = ParagraphHeight( phe, 6, false ); + + j += 1; + } else { memcpy( phe, ( bytes + j), 6); @@ -126,29 +129,26 @@ namespace DocFileFormat if ( bx.wordOffset != 0 ) { - //read first unsigned char of PAPX - //PAPX is stored in a FKP; so the first unsigned char is a count of words unsigned char padbyte = 0; - unsigned char cw = bytes[bx.wordOffset * 2]; - + unsigned char cw = bytes[bx.wordOffset * 2] * 2; //if that unsigned char is zero, it's a pad unsigned char, and the word count is the following unsigned char if ( cw == 0 ) { padbyte = 1; - cw = bytes[bx.wordOffset * 2 + 1]; + cw = bytes[bx.wordOffset * 2 + 1] * 2; } - if ( cw != 0 ) { //read the bytes for papx - papx = new unsigned char[cw * 2]; - memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), ( cw * 2 ) ); + unsigned char* papx = new unsigned char[cw]; + memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), cw ); //parse PAPX and fill grppapx - grppapx[i] = new ParagraphPropertyExceptions( papx, ( cw * 2 ), dataStream, oldVersion ); + grppapx[i] = new ParagraphPropertyExceptions( papx, cw, dataStream, nWordVersion ); RELEASEARRAYOBJECTS( papx ); } + } else { @@ -157,7 +157,6 @@ namespace DocFileFormat } } - RELEASEARRAYOBJECTS( phe ); RELEASEARRAYOBJECTS( bytes ); } @@ -179,7 +178,7 @@ namespace DocFileFormat //there are n offsets and n-1 fkp's in the bin table - if (fib->m_bOlderVersion && fib->m_FibBase.fComplex == false) + if (fib->m_nWordVersion > 0 && fib->m_FibBase.fComplex == false) { int n = ( ( (int)fib->m_FibWord97.lcbPlcfBtePapx - 8 ) / 6 ) + 1; @@ -202,7 +201,7 @@ namespace DocFileFormat int offset = fkpnr * 512; //parse the FKP and add it to the list - PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion, fib->m_FibBase.fComplex) ); + PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_nWordVersion, fib->m_FibBase.fComplex) ); } //if (PAPXlist->back()->rgfc[PAPXlist->back()->rgfcSize-1] < last) @@ -226,7 +225,7 @@ namespace DocFileFormat int offset = fkpnr * 512; //parse the FKP and add it to the list - PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_bOlderVersion, fib->m_FibBase.fComplex) ); + PAPXlist->push_back( new FormattedDiskPagePAPX( wordStream, offset, dataStream, fib->m_nWordVersion, fib->m_FibBase.fComplex) ); } } diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h index a92272dbd4..da7a83f7e6 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.h @@ -63,7 +63,7 @@ namespace DocFileFormat public: virtual ~FormattedDiskPagePAPX(); - FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, bool oldVersion, bool fComplex); + FormattedDiskPagePAPX( POLE::Stream* wordStream, int offset, POLE::Stream* dataStream, int nWordVersion, bool fComplex); /// Parses the 0Table (or 1Table) for FKP _entries containing PAPX static std::list* GetAllPAPXFKPs( FileInformationBlock* fib, POLE::Stream* wordStream, POLE::Stream* tableStream, POLE::Stream* dataStream); /// Returns a list of all PAPX FCs between they given boundaries. diff --git a/ASCOfficeDocFile/DocDocxConverter/Global.h b/ASCOfficeDocFile/DocDocxConverter/Global.h index 0d2a0e9eb5..2b06656418 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Global.h +++ b/ASCOfficeDocFile/DocDocxConverter/Global.h @@ -38,10 +38,30 @@ namespace Global static const wchar_t ColorIdentifier[17][12] = { L"auto", + L"000000",//L"black", + L"0000FF",//L"blue", + L"00FFFF",//L"cyan", + L"00FF00",// L"green", + L"FF00FF",//L"magenta", + L"FF0000",//L"red", + L"FFFF00",//L"yellow", + L"FFFFFF",//L"white", + L"darkBlue", + L"darkCyan", + L"darkGreen", + L"darkMagenta", + L"darkRed", + L"darkYellow", + L"darkGray", + L"lightGray" + }; + static const wchar_t ColorNameIdentifier[17][12] = + { + L"auto", L"black", L"blue", L"cyan", - L"green", + L"green", L"magenta", L"red", L"yellow", @@ -55,7 +75,6 @@ namespace Global L"darkGray", L"lightGray" }; - static const wchar_t UnderlineCode[56][16] = { L"none", diff --git a/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp b/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp index 14ca265c88..e3ecaaf284 100644 --- a/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/HeaderAndFooterTable.cpp @@ -38,7 +38,7 @@ namespace DocFileFormat { HeaderAndFooterTable::HeaderAndFooterTable (FileInformationBlock* fib, POLE::Stream* pTableStream) { - VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_bOlderVersion); + VirtualStreamReader tableReader (pTableStream, fib->m_FibWord97.fcPlcfHdd, fib->m_nWordVersion); if (fib->m_FibWord97.fcPlcfHdd > tableReader.GetSize()) return; @@ -58,7 +58,7 @@ namespace DocFileFormat //the first 6 _entries are about footnote and endnote formatting //so skip these _entries - int pos = (fib->m_FibBase.fComplex || !fib->m_bOlderVersion) ? 6 : 0; + int pos = (fib->m_FibBase.fComplex || !fib->m_nWordVersion) ? 6 : 0; int count = ( tableSize - pos - 2) / 6; diff --git a/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp index 47f8689262..a7a147f070 100644 --- a/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/HeaderMapping.cpp @@ -71,7 +71,7 @@ namespace DocFileFormat if (fc < 0) break; ParagraphPropertyExceptions* papx = findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( tai.fInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h b/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h index 923468b6e9..08a8d2d9b3 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/ListFormatOverrideTable.h @@ -49,7 +49,7 @@ namespace DocFileFormat { if ( fib->m_FibWord97.lcbPlfLfo > 0 ) { - VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_bOlderVersion); + VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLfo, fib->m_nWordVersion); if (fib->m_FibWord97.fcPlfLfo > reader.GetSize()) return; diff --git a/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp b/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp index 7a0b90de83..bc7f1c3643 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ListLevel.cpp @@ -77,7 +77,7 @@ namespace DocFileFormat //this papx has no istd, so use PX to parse it unsigned char *bytes = reader->ReadBytes( cbGrpprlPapx, true ); - PropertyExceptions* px = new PropertyExceptions( bytes, cbGrpprlPapx, reader->olderVersion); + PropertyExceptions* px = new PropertyExceptions( bytes, cbGrpprlPapx, reader->nWordVersion); grpprlPapx = new ParagraphPropertyExceptions( *(px->grpprl) ); RELEASEOBJECT( px ); @@ -85,7 +85,7 @@ namespace DocFileFormat //read the group of chpx sprms bytes = reader->ReadBytes( cbGrpprlChpx, true ); - grpprlChpx = new CharacterPropertyExceptions( bytes, cbGrpprlChpx, reader->olderVersion ); + grpprlChpx = new CharacterPropertyExceptions( bytes, cbGrpprlChpx, reader->nWordVersion ); RELEASEARRAYOBJECTS( bytes ); //read the number text diff --git a/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp b/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp index 5928ef5c77..6ba5e4f03c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ListTable.cpp @@ -45,7 +45,7 @@ namespace DocFileFormat { if ( fib->m_FibWord97.lcbPlfLst > 0 ) { - VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_bOlderVersion); + VirtualStreamReader reader( tableStream, fib->m_FibWord97.fcPlfLst, fib->m_nWordVersion); if (fib->m_FibWord97.fcPlfLst > reader.GetSize()) return; diff --git a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp index 99f0b1b395..b5f9a397b9 100644 --- a/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/MainDocumentMapping.cpp @@ -120,7 +120,7 @@ namespace DocFileFormat if (papx) { - TableInfo tai(papx); + TableInfo tai(papx, m_document->nWordVersion); if (tai.fInTable) { int cpStart = cp; diff --git a/ASCOfficeDocFile/DocDocxConverter/MemoryStream.h b/ASCOfficeDocFile/DocDocxConverter/MemoryStream.h index 458b5f4c3c..8874ed76fa 100644 --- a/ASCOfficeDocFile/DocDocxConverter/MemoryStream.h +++ b/ASCOfficeDocFile/DocDocxConverter/MemoryStream.h @@ -124,7 +124,7 @@ public: if (m_Data) { - rdByte = m_Data[m_Position]; + rdByte = (m_Position < m_Size) ? m_Data[m_Position] : 0; m_Position += sizeof(rdByte); } diff --git a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp index 60be768552..aa8edc9910 100644 --- a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.cpp @@ -338,9 +338,9 @@ namespace DocFileFormat } - std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, bool bOlderVersion) + std::wstring NumberingMapping::GetNumberFormatWideString(int nfc, int nWordVersion) { - if (bOlderVersion && nfc > 5) + if (nWordVersion > 0 && nfc > 5) { if (nfc == 0xff) return std::wstring( L"bullet"); else return std::wstring( L"none"); @@ -633,7 +633,7 @@ namespace DocFileFormat if ((chpxs != NULL) && (!chpxs->empty())) { - PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->FIB->m_bOlderVersion); + PictureDescriptor pict(chpxs->front(), m_document->DataStream, fcEnd - fc, m_document->nWordVersion); if ((pict.mfp.mm > 98) && (pict.shapeContainer != NULL)) { diff --git a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h index 3e118f9493..7c5f441ec2 100644 --- a/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/NumberingMapping.h @@ -65,7 +65,7 @@ namespace DocFileFormat static int FindIndexbyId(const std::list& listData, int id); /// Converts the number format code of the binary format. - static std::wstring GetNumberFormatWideString(int nfc, bool bOlderVersion = false); + static std::wstring GetNumberFormatWideString(int nfc, int nWordVersion = 0); virtual ~NumberingMapping(); diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h b/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h index 3c2b118403..0d4b218958 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeArtContent.h @@ -60,7 +60,7 @@ namespace DocFileFormat OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL) { - VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion); + VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_nWordVersion); if (pFIB->m_FibWord97.fcDggInfo > oStearmReader.GetSize()) return; diff --git a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/MetafilePictBlip.h b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/MetafilePictBlip.h index 347f4b9ddb..36de2ac222 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/MetafilePictBlip.h +++ b/ASCOfficeDocFile/DocDocxConverter/OfficeDrawing/MetafilePictBlip.h @@ -67,7 +67,6 @@ public: BYTE compression; BYTE filter; -public: CMetaHeader() { cbSize = cbSave = 0; @@ -78,48 +77,6 @@ public: } - - //void ToEMFHeader(Gdiplus::ENHMETAHEADER3* pHeader) - //{ - // if (NULL == pHeader) - // return; - - // pHeader->iType = 0x00000001; - // pHeader->nSize = 88; - - // pHeader->rclBounds.left = rcBounds.left; - // pHeader->rclBounds.top = rcBounds.top; - // pHeader->rclBounds.right = rcBounds.right; - // pHeader->rclBounds.bottom = rcBounds.bottom; - - // // нужно перевести в мм - // pHeader->rclFrame.left = rcBounds.left; - // pHeader->rclFrame.top = rcBounds.top; - // pHeader->rclFrame.right = rcBounds.right; - // pHeader->rclFrame.bottom = rcBounds.bottom; - - // pHeader->dSignature = 0x464D4520; - // pHeader->nVersion = 0x00010000; - // pHeader->nBytes = cbSize; - - // pHeader->nRecords = 1; - // pHeader->nHandles = 0; - - // pHeader->sReserved = 0; - - // pHeader->nDescription = 0; - // pHeader->offDescription = 0; - - // pHeader->nPalEntries = 0; - - // pHeader->szlDevice.cx = 200; - // pHeader->szlDevice.cy = 200; - - // // нужно перевести в мм - // pHeader->szlMillimeters.cx = 100; - // pHeader->szlMillimeters.cy = 100; - //} - void ToWMFHeader(WmfPlaceableFileHeader* pHeader) { if (NULL == pHeader) diff --git a/ASCOfficeDocFile/DocDocxConverter/OleObject.cpp b/ASCOfficeDocFile/DocDocxConverter/OleObject.cpp index 7c4d02f4c4..19a3e41ba7 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OleObject.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/OleObject.cpp @@ -32,97 +32,111 @@ #pragma once #include "OleObject.h" +#include "WordDocument.h" namespace DocFileFormat { -OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ ) - : bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_), isEquation(false), isEmbedded (false) +OleObject::OleObject( const CharacterPropertyExceptions* chpx, WordDocument* document) + : bLinked(false), updateMode(NoLink), isEquation(false), isEmbedded (false), oleStorage(NULL) { - if (!docStorage) return; + if (!document) return; if (!chpx) return; + + nWordVersion = document->nWordVersion; + ObjectId = getOleEntryName( chpx ); + + StructuredStorageReader* docStorage = document->GetStorage(); + oleStorage = docStorage->GetStorage(); if (!oleStorage) return; - - HRESULT res = S_OK; + + std::wstring sObjectId( ObjectId.begin(), ObjectId.end() ); + + std::wstring name = L"ObjectPool/" + sObjectId + L"/"; - POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, L"ObjectPool"); - - if (ObjectPoolStorage) + bool bOle = processOleStream( name + L"Ole" ); + bool bCompObj = bLinked ? processLinkInfoStream( name + L"LinkInfo" ): + processCompObjStream( name + L"CompObj" ); + if (bOle || bCompObj) { - ObjectId = getOleEntryName( chpx ); - - std::wstring sObjectId( ObjectId.begin(), ObjectId.end() ); - { - std::wstring name = L"ObjectPool/" + sObjectId + L"/"; - processOleStream( name + L"Ole" ); - - if ( bLinked ) - { - processLinkInfoStream( name + L"LinkInfo" ); - } - else - { - processCompObjStream( name + L"CompObj" ); - } - - processPICStream( name + L"PIC" ); - - processEquationNativeStream( name + L"Equation Native" ); - } - delete ObjectPoolStorage; + processPICStream( name + L"PIC" ); + processMETAStream( name + L"META" ); + processEquationNativeStream( name + L"Equation Native" ); } + else if (nWordVersion > 0) + { + int fc = pictureDesciptor.GetFcPic( chpx ); + + if ( fc >= 0 ) + { + POLE::Stream* pOleStream = document->GetDocumentStream(); + pictureDesciptor.parse( pOleStream, fc, 0xffffff, nWordVersion); + + VirtualStreamReader reader(pOleStream, pOleStream->tell(), nWordVersion); + + int pos = reader.GetPosition(); + + short a1 = reader.ReadInt16(); + short a2 = reader.ReadInt16(); + short a3 = reader.ReadInt16(); + + int lcb = reader.ReadInt32(); + //short a4 = reader.ReadInt16(); + //short a5 = reader.ReadInt16(); + //short a6 = reader.ReadInt16(); + //short a7 = reader.ReadInt16(); + int lcb1 = reader.ReadInt32(); + + ClipboardFormat = Program = reader.ReadLengthPrefixedAnsiString(0xffff); + + short a10 = reader.ReadInt16(); + short a11 = reader.ReadInt16(); + short a12 = reader.ReadInt16(); + short a14 = reader.ReadInt16(); + + //int lcb = 5000;//reader.ReadInt32(); + + int szHeader = reader.GetPosition() - pos; + int szData = reader.ReadInt32(); + if (szData > lcb) + { + szData = szData >> 16; + } + unsigned char* bytes = reader.ReadBytes( szData, true ); + if (bytes) + { + emeddedData = std::string((char*)bytes, szData); + delete []bytes; + } + } + + } + } -void OleObject::processLinkInfoStream( const std::wstring& linkStream ) +bool OleObject::processLinkInfoStream( const std::wstring& linkStream ) { try { - POLE::Stream* pLinkStream = NULL; - HRESULT res = S_OK; + POLE::Stream* pLinkStream = NULL; + HRESULT res = S_OK; - pLinkStream = //oleStorage->stream(linkStream); - new POLE::Stream(oleStorage, linkStream); + pLinkStream = new POLE::Stream(oleStorage, linkStream); - if ( pLinkStream ) - { - VirtualStreamReader reader( pLinkStream, 0, false); + if ( pLinkStream ) + { + VirtualStreamReader reader( pLinkStream, 0, false); + processLinkInfoStream(reader); - //there are two versions of the Link string, one contains ANSI characters, the other contains - //unicode characters. - //Both strings seem not to be standardized: - //The length prefix is a character count EXCLUDING the terminating zero - - //Read the ANSI version - short cch = reader.ReadInt16(); - unsigned char* str = reader.ReadBytes( cch, true ); - FormatUtils::GetSTLCollectionFromBytes( &this->Link, str, cch, ENCODING_WINDOWS_1250 ); - RELEASEARRAYOBJECTS( str ); - - //skip the terminating zero of the ANSI string - //even if the characters are ANSI chars, the terminating zero has 2 bytes - reader.ReadBytes( 2, false ); - - //skip the next 4 bytes (flags?) - reader.ReadBytes( 4, false ); - - //Read the Unicode version - this->Link.clear(); - - cch = reader.ReadInt16(); - str = reader.ReadBytes( ( cch * 2 ), true ); - FormatUtils::GetSTLCollectionFromBytes( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 ); - RELEASEARRAYOBJECTS( str ); - - //skip the terminating zero of the Unicode string - reader.ReadBytes( 2, false ); - - delete pLinkStream; - } + delete pLinkStream; + return true; + } } catch (...) { } + return false; } void OleObject::processEquationNativeStream( const std::wstring& eqStream ) @@ -155,7 +169,32 @@ void OleObject::processEquationNativeStream( const std::wstring& eqStream ) { } } +void OleObject::processMETAStream( const std::wstring& metaStream ) +{ + try + { + HRESULT res = S_OK; + POLE::Stream* pMETAStream = new POLE::Stream(oleStorage, metaStream); + + if ( pMETAStream ) + { + pictureDesciptor.Type = wmf; + VirtualStreamReader reader( pMETAStream, 0, false); + + pictureDesciptor.mfp.mm = reader.ReadUInt16(); + pictureDesciptor.mfp.xExt = reader.ReadUInt16(); + pictureDesciptor.mfp.yExt = reader.ReadUInt16(); + pictureDesciptor.mfp.hMf = reader.ReadUInt16(); + + pictureDesciptor.embeddedDataSize = reader.GetSize() - 8; + pictureDesciptor.embeddedData = reader.ReadBytes( pictureDesciptor.embeddedDataSize, true ); + } + } + catch (...) + { + } +} void OleObject::processPICStream( const std::wstring& picStream ) { try @@ -170,20 +209,54 @@ void OleObject::processPICStream( const std::wstring& picStream ) int sz = reader.GetSize(); - int cbHeader = reader.ReadUInt32(); + int cbHeader = reader.ReadUInt32(); - reader.ReadBytes(4, false); + unsigned char* bytes = NULL; + + pictureDesciptor.mfp.mm = reader.ReadInt16(); + pictureDesciptor.mfp.xExt = reader.ReadInt16(); + pictureDesciptor.mfp.yExt = reader.ReadInt16(); + pictureDesciptor.mfp.hMf = reader.ReadInt16(); - int x = reader.ReadUInt32(); - int y = reader.ReadUInt32(); - pictureDesciptor.dyaGoal = reader.ReadUInt32(); - pictureDesciptor.dxaGoal = reader.ReadUInt32(); + int x = reader.ReadUInt32(); + int y = reader.ReadUInt32(); + + pictureDesciptor.dxaGoal = reader.ReadUInt32(); + pictureDesciptor.dyaGoal = reader.ReadUInt32(); - reader.ReadBytes(20, false); + unsigned char* data = reader.ReadBytes(16, true); + delete []data; pictureDesciptor.mx = reader.ReadUInt32(); pictureDesciptor.my = reader.ReadUInt32(); + pictureDesciptor.dxaCropLeft = reader.ReadInt32(); + pictureDesciptor.dyaCropTop = reader.ReadInt32(); + pictureDesciptor.dxaCropRight = reader.ReadInt32(); + pictureDesciptor.dyaCropBottom = reader.ReadInt32(); + + // borders + int bytesCount = (nWordVersion > 0) ? 2 : 4; + + bytes = reader.ReadBytes( bytesCount, true ); + pictureDesciptor.brcTop = new BorderCode( bytes, bytesCount ); + RELEASEARRAYOBJECTS( bytes ); + + bytes = reader.ReadBytes( bytesCount, true ); + pictureDesciptor.brcLeft = new BorderCode( bytes, bytesCount ); + RELEASEARRAYOBJECTS( bytes ); + + bytes = reader.ReadBytes( bytesCount, true ); + pictureDesciptor.brcBottom = new BorderCode( bytes, bytesCount ); + RELEASEARRAYOBJECTS( bytes ); + + bytes = reader.ReadBytes( bytesCount, true ); + pictureDesciptor.brcRight = new BorderCode( bytes, bytesCount ); + RELEASEARRAYOBJECTS( bytes ); + + int etc = sz - reader.GetPosition(); + unsigned char* data2 = reader.ReadBytes(etc, true); + delete []data2; } } catch (...) @@ -191,7 +264,7 @@ void OleObject::processPICStream( const std::wstring& picStream ) } } -void OleObject::processCompObjStream( const std::wstring& compStream ) +bool OleObject::processCompObjStream( const std::wstring& compStream ) { try { @@ -202,33 +275,20 @@ void OleObject::processCompObjStream( const std::wstring& compStream ) if ( pCompStream ) { VirtualStreamReader reader( pCompStream, 0, false); + processCompObjStream(reader); - //skip the CompObjHeader - reader.ReadBytes( 28, false ); - - unsigned int sz_obj = reader.GetSize() - reader.GetPosition(); - - if (sz_obj > 4) - { - UserType = reader.ReadLengthPrefixedAnsiString(sz_obj); - - sz_obj = reader.GetSize() - reader.GetPosition(); - if (sz_obj > 4) - ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj); - - sz_obj = reader.GetSize() - reader.GetPosition(); - if (sz_obj > 4) - Program = reader.ReadLengthPrefixedAnsiString(sz_obj); - } delete pCompStream; + + return true; } } catch (...) { } + return false; } -void OleObject::processOleStream( const std::wstring& oleStreamName ) +bool OleObject::processOleStream( const std::wstring& oleStreamName ) { try { @@ -237,46 +297,87 @@ void OleObject::processOleStream( const std::wstring& oleStreamName ) pOleStream = new POLE::Stream(oleStorage, oleStreamName); - if ( pOleStream ) + if ( (pOleStream) && (!pOleStream->fail())) { - VirtualStreamReader reader( pOleStream, 0, false ); + VirtualStreamReader reader( pOleStream, 0, false ); + processOleStream(reader); - //skip version - reader.ReadBytes( 4, false ); + delete pOleStream; - //read the embedded/linked flag - int flag = reader.ReadInt32(); - bLinked = FormatUtils::BitmaskToBool( flag, 0x1 ); - - //Link update option - this->updateMode = (LinkUpdateOption)reader.ReadInt32(); - - switch ( this->updateMode ) - { - case NoLink: - { - this->UpdateMode = L"NoLink"; - } - break; - - case Always: - { - this->UpdateMode = L"Always"; - } - break; - - case OnCall: - { - this->UpdateMode = L"OnCall"; - } - break; + return true; } - delete pOleStream; - } } catch (...) { } + + return false; +} + +void OleObject::processOleStream( VirtualStreamReader& reader ) +{ + //skip version + reader.ReadBytes( 4, false ); + + //read the embedded/linked flag + int flag = reader.ReadInt32(); + bLinked = FormatUtils::BitmaskToBool( flag, 0x1 ); + + //Link update option + this->updateMode = (LinkUpdateOption)reader.ReadInt32(); + + switch ( this->updateMode ) + { + case NoLink: UpdateMode = L"NoLink"; break; + case Always: UpdateMode = L"Always"; break; + case OnCall: UpdateMode = L"OnCall"; break; + + } +} +void OleObject::processLinkInfoStream( VirtualStreamReader& reader ) +{ + short cch = reader.ReadInt16(); + unsigned char* str = reader.ReadBytes( cch, true ); + FormatUtils::GetSTLCollectionFromBytes( &this->Link, str, cch, ENCODING_WINDOWS_1250 ); + RELEASEARRAYOBJECTS( str ); + + //skip the terminating zero of the ANSI string + //even if the characters are ANSI chars, the terminating zero has 2 bytes + reader.ReadBytes( 2, false ); + + //skip the next 4 bytes (flags?) + reader.ReadBytes( 4, false ); + + //Read the Unicode version + this->Link.clear(); + + cch = reader.ReadInt16(); + str = reader.ReadBytes( ( cch * 2 ), true ); + FormatUtils::GetSTLCollectionFromBytes( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 ); + RELEASEARRAYOBJECTS( str ); + + //skip the terminating zero of the Unicode string + reader.ReadBytes( 2, false ); +} +void OleObject::processCompObjStream( VirtualStreamReader& reader ) +{ + //skip the CompObjHeader + reader.ReadBytes( 28, false ); + + unsigned int sz_obj = reader.GetSize() - reader.GetPosition(); + + if (sz_obj > 4) + { + UserType = reader.ReadLengthPrefixedAnsiString(sz_obj); + + sz_obj = reader.GetSize() - reader.GetPosition(); + if (sz_obj > 4) + ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj); + + sz_obj = reader.GetSize() - reader.GetPosition(); + if (sz_obj > 4) + Program = reader.ReadLengthPrefixedAnsiString(sz_obj); + } } std::wstring OleObject::getOleEntryName( const CharacterPropertyExceptions* chpx ) diff --git a/ASCOfficeDocFile/DocDocxConverter/OleObject.h b/ASCOfficeDocFile/DocDocxConverter/OleObject.h index dd87d2bdb8..54eafc8425 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OleObject.h +++ b/ASCOfficeDocFile/DocDocxConverter/OleObject.h @@ -32,11 +32,11 @@ #pragma once #include "IVisitable.h" -#include "StructuredStorageReader.h" #include "PictureDescriptor.h" namespace DocFileFormat { + class WordDocument; class OleObject: public IVisitable { friend class OleObjectMapping; @@ -48,7 +48,7 @@ namespace DocFileFormat Always = 1, OnCall = 3 }; - bool bOlderVersion; + int nWordVersion; bool bLinked; // The the value is true, the object is a linked object std::wstring ObjectId; @@ -68,17 +68,22 @@ namespace DocFileFormat PictureDescriptor pictureDesciptor; - OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ ); + OleObject( const CharacterPropertyExceptions* chpx, WordDocument* document); virtual ~OleObject() {} private: POLE::Storage *oleStorage; - void processLinkInfoStream ( const std::wstring& linkStream ); + bool processLinkInfoStream ( const std::wstring& linkStream ); void processEquationNativeStream( const std::wstring& eqStream ); void processPICStream ( const std::wstring& picStream ); - void processCompObjStream ( const std::wstring& compStream ); - void processOleStream ( const std::wstring& oleStreamName ); + void processMETAStream ( const std::wstring& metaStream ); + bool processCompObjStream ( const std::wstring& compStream ); + bool processOleStream ( const std::wstring& oleStreamName ); + + void processOleStream ( VirtualStreamReader& reader ); + void processLinkInfoStream ( VirtualStreamReader& reader ); + void processCompObjStream ( VirtualStreamReader& reader ); std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx ); }; diff --git a/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h b/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h index c2bbdddca6..c46c2ceb40 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/OleObjectMapping.h @@ -156,26 +156,31 @@ namespace DocFileFormat private: inline void copyEmbeddedObject( const OleObject* ole ) { - if ( ole != NULL ) + if ( ole == NULL ) return; + + std::wstring clsid; + std::wstring exelChart = L"Excel.Chart"; + + if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() ) { - std::wstring clsid; - std::wstring exelChart = L"Excel.Chart"; - - if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() ) - { - clsid = ole->ClassId; - } - OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid); - - if (ole->isEquation || ole->isEmbedded) - { - object_descr.data = ole->emeddedData; - } - m_context->_docx->OleObjectsList.push_back(object_descr); + clsid = ole->ClassId; } + OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid); + + if (ole->nWordVersion == 2) + { + object_descr.clsid = ole->ClipboardFormat; + object_descr.bNativeOnly = true; + } + if (ole->isEquation || ole->isEmbedded || ole->nWordVersion == 2) + { + object_descr.data = ole->emeddedData; + } + + m_context->_docx->OleObjectsList.push_back(object_descr); } - private: + ConversionContext* m_context; PictureDescriptor* _pict; diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp index fcc0719dce..9d6fac4c2f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp @@ -135,35 +135,101 @@ namespace DocFileFormat } } - HRESULT OpenXmlPackage::SaveEmbeddedObject( const std::wstring& fileName, const std::string& data ) + bool OpenXmlPackage::SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& object ) { - NSFile::CFileBinary file; - file.CreateFileW(fileName); - file.WriteFile((BYTE*)data.c_str(), (_UINT32)data.size()); - file.CloseFile(); - return S_OK; + if (object.bNativeOnly) + { + POLE::Storage * storageOut = new POLE::Storage(fileName.c_str()); + if ( (storageOut) && (storageOut->open(true, true))) + { + _UINT32 zero = 0, str_size = 0; + //Ole + BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; + POLE::Stream oStream3(storageOut, L"\001Ole", true, 20); + oStream3.write(dataOleInfo, 20); + oStream3.flush(); + //CompObj + BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff + ,0x30,0x08,0x02 + //,0x0a,0x00,0x03 + ,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}; + POLE::Stream oStream1(storageOut, L"\001CompObj", true, 28 + (object.clsid.length() + 5) + + (object.clsid.length() + 5) + + (object.clsid.length() + 5) + 4 * 4); + oStream1.write(dataCompObjHeader, 28); + + str_size = object.clsid.length() + 1; + oStream1.write((BYTE*)&str_size, 4); + oStream1.write((BYTE*)object.clsid.c_str(), object.clsid.length()); + oStream1.write((BYTE*)&zero, 1); + + str_size = object.clsid.length() + 1; + oStream1.write((BYTE*)&str_size, 4); + oStream1.write((BYTE*)object.clsid.c_str(), object.clsid.length()); + oStream1.write((BYTE*)&zero, 1); + + str_size = object.clsid.length() + 1; + oStream1.write((BYTE*)&str_size, 4); + oStream1.write((BYTE*)object.clsid.c_str(), object.clsid.length()); + oStream1.write((BYTE*)&zero, 1); + + _UINT32 nUnicodeMarker = 0x71B239F4; + oStream1.write((BYTE*)&nUnicodeMarker, 4); + + oStream1.write((BYTE*)&zero, 4); // UnicodeUserType + oStream1.write((BYTE*)&zero, 4); // UnicodeClipboardFormat + oStream1.write((BYTE*)&zero, 4); // + oStream1.flush(); + + //ObjInfo + BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x01,0x00};//{0x00,0x00,0x03,0x00,0x0D,0x00}; + POLE::Stream oStream2(storageOut, L"\003ObjInfo", true, 6); + oStream2.write(dataObjInfo, 6); + oStream2.flush(); + + //Ole10Native + size_t nativeDataSize = object.data.length(); + + POLE::Stream streamData(storageOut, L"\001Ole10Native", true, nativeDataSize + 4); + streamData.write((BYTE*)&nativeDataSize, 4); + streamData.write((BYTE*)object.data.c_str(), nativeDataSize); + streamData.flush(); + + storageOut->close(); + delete storageOut; + } + } + else + { + NSFile::CFileBinary file; + file.CreateFileW(fileName); + file.WriteFile((BYTE*)object.data.c_str(), (_UINT32)object.data.size()); + file.CloseFile(); + } + return true; } - HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure ) + + bool OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& object ) { - if (docFile == NULL) return S_FALSE; + if (docFile == NULL) return false; POLE::Storage *storageOut = new POLE::Storage(fileName.c_str()); - if (storageOut == NULL) return S_FALSE; + if (storageOut == NULL) return false; if (storageOut->open(true, true)==false) { delete storageOut; - return S_FALSE; + return false; } POLE::Storage *storageInp = docFile->GetStorage()->GetStorage(); { - POLE::Stream* oleStorage = new POLE::Stream(storageInp, oleObjectFileStructure.objectID); + POLE::Stream* oleStorage = new POLE::Stream(storageInp, object.objectID); if (oleStorage) { - std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID; + std::wstring path = L"ObjectPool/" + object.objectID; std::list entries = storageInp->entries_with_prefix(path); for (std::list::iterator it = entries.begin(); it != entries.end(); ++it) @@ -201,7 +267,7 @@ namespace DocFileFormat storageOut->close(); delete storageOut; - return S_OK; + return true; } void OpenXmlPackage::RegisterDocPr() { diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h index b3f9135509..f9a63601e1 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h @@ -102,17 +102,16 @@ namespace DocFileFormat struct OleObjectFileStructure { + bool bNativeOnly = false; + std::wstring ext; std::wstring objectID; std::wstring clsid; std::string data; - OleObjectFileStructure(){} - - OleObjectFileStructure( const std::wstring& _ext, const std::wstring& _objectID, const std::wstring&/*REFCLSID*/ _clsid ): - ext(_ext), objectID(_objectID), clsid(_clsid){} + ext(_ext), objectID(_objectID), clsid(_clsid){} }; @@ -162,8 +161,8 @@ namespace DocFileFormat void SaveToFile( const std::wstring& outputDir, const std::wstring& fileName, const std::wstring& XMLContent ); void SaveToFile( const std::wstring& outputDir, const std::wstring& fileName, const void* buf, unsigned int size ); - HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure ); - HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data ); + bool SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure ); + bool SaveEmbeddedObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure ); void RegisterDocPr(); void RegisterDocument(); diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphHeight.cpp b/ASCOfficeDocFile/DocDocxConverter/ParagraphHeight.cpp index 1bf038fa67..bcd71a0f17 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphHeight.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphHeight.cpp @@ -52,38 +52,40 @@ namespace DocFileFormat //so used another bit setting if ( size == 12 ) { + unsigned short nFlag = FormatUtils::BytesToInt16( bytes, 0, size ); if ( fTtpMode ) { - fSpare = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 ); - fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 ); - dcpTtpNext = FormatUtils::BytesToInt16( bytes, 0, size ); + fSpare = FormatUtils::BitmaskToBool( nFlag, 0x0001 ); + fUnk = FormatUtils::BitmaskToBool( nFlag, 0x0002 ); + dcpTtpNext = nFlag; dxaCol = FormatUtils::BytesToInt32( bytes, 4, size ); dymTableHeight = FormatUtils::BytesToInt32( bytes, 8, size ); } else { - fVolatile = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 ); - fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 ); - fDiffLines = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0004 ); - clMac = FormatUtils::BytesToUInt16( bytes, 0, size ) & 0x00FF; + fVolatile = FormatUtils::BitmaskToBool( nFlag, 0x0001 ); + fUnk = FormatUtils::BitmaskToBool( nFlag, 0x0002 ); + fDiffLines = FormatUtils::BitmaskToBool( nFlag, 0x0004 ); + clMac = nFlag& 0x00FF; dxaCol = FormatUtils::BytesToInt32( bytes, 4, size ); dymLine = FormatUtils::BytesToInt32( bytes, 8, size ); - dymHeight = FormatUtils::BytesToInt32( bytes, 8, size ); + dymHeight = dymLine; } } else if (size == 6) { - fVolatile = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0001 ); - fUnk = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0002 ); - fDiffLines = FormatUtils::BitmaskToBool( FormatUtils::BytesToInt16( bytes, 0, size ), 0x0004 ); - clMac = FormatUtils::BytesToUChar( bytes, 0, size ) & 0x000F; + unsigned short nFlag = FormatUtils::BytesToInt16( bytes, 0, size ); + + fVolatile = FormatUtils::BitmaskToBool( nFlag, 0x0001 ); + fUnk = FormatUtils::BitmaskToBool( nFlag, 0x0002 ); + fDiffLines = FormatUtils::BitmaskToBool( nFlag, 0x0004 ); + clMac = nFlag & 0x000F; dxaCol = FormatUtils::BytesToInt16( bytes, 2, size ); dymLine = FormatUtils::BytesToInt16( bytes, 4, size ); - dymHeight = FormatUtils::BytesToInt16( bytes, 4, size ); + dymHeight = dymLine; } - } /*========================================================================================================*/ diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp index 2fc394146a..4141b43e9d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.cpp @@ -34,51 +34,59 @@ namespace DocFileFormat { - ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, bool oldVersion): - PropertyExceptions( ( bytes + 2 ), ( size - 2 ), oldVersion) - { - if ( size != 0 ) - { - istd = FormatUtils::BytesToUInt16( bytes, 0, size ); - } + ParagraphPropertyExceptions::ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion): + PropertyExceptions( ( bytes + 2 ), ( size - 2 ), nWordVersion) + { + if (size < 1) return; - VirtualStreamReader *reader = NULL; - - //There is a SPRM that points to an offset in the data stream, - //where a list of SPRM is saved. - for ( std::list::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ ) - { - SinglePropertyModifier sprm( *iter ); - - if( ( sprm.OpCode == sprmPHugePapx ) || ( (int)sprm.OpCode == 0x6646 ) ) - { - unsigned int fc = FormatUtils::BytesToUInt32( sprm.Arguments, 0, sprm.argumentsSize ); - reader = new VirtualStreamReader( dataStream, (int)fc, oldVersion); - - //parse the size of the external grpprl - unsigned char* sizebytes = reader->ReadBytes( 2, true ); - - unsigned int grpprlsize = FormatUtils::BytesToUInt16( sizebytes, 0, 2 ); - - RELEASEARRAYOBJECTS( sizebytes ); - - //parse the external grpprl - unsigned char* grpprlBytes = reader->ReadBytes( grpprlsize, true ); - - PropertyExceptions externalPx( grpprlBytes, grpprlsize, oldVersion ); - - //assign the external grpprl - RELEASEOBJECT( grpprl ); - grpprl = new std::list( *(externalPx.grpprl) ); - - //remove the sprmPHugePapx - grpprl->remove( sprm ); - - RELEASEARRAYOBJECTS( grpprlBytes ); - RELEASEOBJECT( reader ) - - break; + if (nWordVersion == 2) + { + istd = bytes[0]; + + ReadExceptions(( bytes + 7 ), ( size - 7 ), nWordVersion); + + } + else + { + istd = FormatUtils::BytesToUInt16( bytes, 0, size ); + VirtualStreamReader *reader = NULL; + + //There is a SPRM that points to an offset in the data stream, + //where a list of SPRM is saved. + for ( std::list::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ ) + { + SinglePropertyModifier sprm( *iter ); + + if( ( sprm.OpCode == sprmPHugePapx ) || ( (int)sprm.OpCode == 0x6646 ) ) + { + unsigned int fc = FormatUtils::BytesToUInt32( sprm.Arguments, 0, sprm.argumentsSize ); + reader = new VirtualStreamReader( dataStream, (int)fc, nWordVersion); + + //parse the size of the external grpprl + unsigned char* sizebytes = reader->ReadBytes( 2, true ); + + unsigned int grpprlsize = FormatUtils::BytesToUInt16( sizebytes, 0, 2 ); + + RELEASEARRAYOBJECTS( sizebytes ); + + //parse the external grpprl + unsigned char* grpprlBytes = reader->ReadBytes( grpprlsize, true ); + + PropertyExceptions externalPx( grpprlBytes, grpprlsize, nWordVersion ); + + //assign the external grpprl + RELEASEOBJECT( grpprl ); + grpprl = new std::list( *(externalPx.grpprl) ); + + //remove the sprmPHugePapx + grpprl->remove( sprm ); + + RELEASEARRAYOBJECTS( grpprlBytes ); + RELEASEOBJECT( reader ) + + break; + } + } } - } } } diff --git a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h index 5b75d80397..760f9c6d86 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/ParagraphPropertyExceptions.h @@ -59,6 +59,6 @@ namespace DocFileFormat } /// Parses the bytes to retrieve a PAPX - ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, bool oldVersion); + ParagraphPropertyExceptions( unsigned char* bytes, int size, POLE::Stream* dataStream, int nWordVersion); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp index 66786d90c3..0774219f7a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.cpp @@ -44,7 +44,7 @@ namespace DocFileFormat { /// 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, int nWordVersion) : 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), @@ -55,7 +55,7 @@ namespace DocFileFormat if ( fc >= 0 ) { - parse( stream, fc, size, oldVersion); + parse( stream, fc, size, nWordVersion); } } PictureDescriptor::PictureDescriptor() @@ -82,11 +82,11 @@ namespace DocFileFormat RELEASEARRAYOBJECTS(embeddedData); RELEASEARRAYOBJECTS(embeddedDataHeader); } - void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, bool oldVersion) + void PictureDescriptor::parse(POLE::Stream* stream, int fc, int sz, int nWordVersion) { Clear(); - VirtualStreamReader reader(stream, fc, oldVersion); + VirtualStreamReader reader(stream, fc, nWordVersion); int sz_stream = reader.GetSize(); @@ -136,7 +136,7 @@ namespace DocFileFormat int brcl = reader.ReadInt16(); // borders - int bytesCount = oldVersion ? 2 : 4; + int bytesCount = (nWordVersion > 0) ? 2 : 4; bytes = reader.ReadBytes( bytesCount, true ); brcTop = new BorderCode( bytes, bytesCount ); @@ -158,7 +158,7 @@ namespace DocFileFormat dyaOrigin = reader.ReadInt16(); int pos_end = reader.GetPosition(); - if (oldVersion) + if (nWordVersion > 0) { int flag = brcl; diff --git a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h index bbd4076d3b..0427049f7c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h +++ b/ASCOfficeDocFile/DocDocxConverter/PictureDescriptor.h @@ -83,16 +83,16 @@ namespace DocFileFormat public: // 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 ( CharacterPropertyExceptions* chpx, POLE::Stream* stream, int size, int nWordVersion); virtual ~PictureDescriptor(); - void parse( POLE::Stream* stream, int fc, int sz, bool oldVersion); + void parse( POLE::Stream* stream, int fc, int sz, int nWordVersion); - private: // 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 ); + private: void Clear(); diff --git a/ASCOfficeDocFile/DocDocxConverter/Plex.h b/ASCOfficeDocFile/DocDocxConverter/Plex.h index b3715e0b83..b48b5c8da9 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Plex.h +++ b/ASCOfficeDocFile/DocDocxConverter/Plex.h @@ -49,12 +49,12 @@ namespace DocFileFormat bool m_bIsValid; public: - Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, bool oldVersion) + Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, int nWordVersion) : m_bIsValid(false) { if ((lcb > 0) && (NULL != stream)) { - VirtualStreamReader reader(stream, (ULONG)fc, oldVersion); + VirtualStreamReader reader(stream, (ULONG)fc, nWordVersion); if (fc > reader.GetSize()) return; diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp index 3162cf8fc8..52851c53fb 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp @@ -38,22 +38,31 @@ namespace DocFileFormat { PropertyExceptions::~PropertyExceptions() { - RELEASEOBJECT( this->grpprl ); + RELEASEOBJECT( grpprl ); } - PropertyExceptions::PropertyExceptions(): grpprl(NULL) + PropertyExceptions::PropertyExceptions() : grpprl(NULL) { - this->grpprl = new std::list(); + grpprl = new std::list(); } - PropertyExceptions::PropertyExceptions( const std::list& grpprl ) + PropertyExceptions::PropertyExceptions( const std::list& _grpprl ) : grpprl(NULL) { - this->grpprl = new std::list( grpprl ); + grpprl = new std::list( _grpprl ); } - PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ) : grpprl(NULL) + PropertyExceptions::PropertyExceptions( unsigned char* bytes, int size, int nWordVersion ) : grpprl(NULL) { - this->grpprl = new std::list(); + if (nWordVersion == 2) + return; + + ReadExceptions(bytes, size, nWordVersion); + } + void PropertyExceptions::ReadExceptions(unsigned char* bytes, int size, int nWordVersion) + { + RELEASEOBJECT( grpprl ); + + grpprl = new std::list(); if ( ( bytes == NULL ) || ( size == 0 ) ) return; @@ -62,16 +71,16 @@ namespace DocFileFormat int sprmStart = 0; bool goOn = true; - int opCodeSize = (oldVersion ? 1 : 2); + int opCodeSize = (nWordVersion > 0) ? 1 : 2; while ( goOn ) { - if ( ( sprmStart + opCodeSize ) < size ) + if ( ( sprmStart + opCodeSize ) <= size ) { - unsigned short code = oldVersion ? FormatUtils::BytesToUChar ( bytes, sprmStart, size ) : - FormatUtils::BytesToUInt16 ( bytes, sprmStart, size ) ; + unsigned short code = (nWordVersion > 0) ? FormatUtils::BytesToUChar ( bytes, sprmStart, size ) : + FormatUtils::BytesToUInt16 ( bytes, sprmStart, size ) ; - if (oldVersion && code == 0) + if (nWordVersion > 0 && code == 0) { sprmStart++; continue; @@ -79,7 +88,7 @@ namespace DocFileFormat OperationCode opCode = (OperationCode)code; short opSize = -1; - if (oldVersion) + if (nWordVersion > 0) { opSize = (short)SinglePropertyModifier::GetOldOperandSize( (unsigned char)opCode ); } @@ -142,25 +151,32 @@ namespace DocFileFormat } } + if (opSize < 0) + { + break; + } + //length is 2byte for the opCode, lenByte for the length, opSize for the length of the operand int sprmBytesSize = opCodeSize + lenByte + opSize; unsigned char* sprmBytes = NULL; sprmBytes = new unsigned char[sprmBytesSize]; - if ( size >= ( sprmStart + sprmBytesSize ) ) + //if ( size >= ( sprmStart + sprmBytesSize ) ) { - memcpy( sprmBytes, ( bytes + sprmStart ), sprmBytesSize ); + int sz = (std::min)(sprmBytesSize, size - sprmStart); - SinglePropertyModifier sprm( sprmBytes, sprmBytesSize, oldVersion ); + memcpy( sprmBytes, ( bytes + sprmStart ), sz ); + + SinglePropertyModifier sprm( sprmBytes, sz, nWordVersion); grpprl->push_back( sprm ); - sprmStart += sprmBytesSize; - } - else - { - goOn = false; + sprmStart += sz; } + //else + //{ + // goOn = false; + //} RELEASEARRAYOBJECTS( sprmBytes ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h index 81ede09d16..bdd2fb49b5 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.h @@ -33,6 +33,7 @@ #include "IVisitable.h" #include "SinglePropertyModifier.h" +#include "MemoryStream.h" #include @@ -48,6 +49,8 @@ namespace DocFileFormat virtual ~PropertyExceptions(); PropertyExceptions(); PropertyExceptions( const std::list& grpprl ); - PropertyExceptions( unsigned char* bytes, int size, bool oldVersion ); + PropertyExceptions( unsigned char* bytes, int size, int nWordVersion ); + + void ReadExceptions( unsigned char* bytes, int size, int nWordVersion ); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h index a1fbd27f67..d97a4ccd7c 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/SectionPropertyExceptions.h @@ -39,8 +39,8 @@ namespace DocFileFormat { public: /// Parses the bytes to retrieve a SectionPropertyExceptions - SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ): - PropertyExceptions( bytes, size, oldVersion ), isBidi(false) + SectionPropertyExceptions( unsigned char* bytes, int size, int nWordVersion ): + PropertyExceptions( bytes, size, nWordVersion ), isBidi(false) { for ( std::list::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.cpp b/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.cpp index 814b99e8d2..3af306d58a 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.cpp @@ -36,17 +36,20 @@ namespace DocFileFormat { - SinglePropertyModifier::SinglePropertyModifier( bool oldVersion_) : - Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), oldVersion (oldVersion_) + SinglePropertyModifier::SinglePropertyModifier(OperationCode opCode, int argumentsSize, unsigned char* arguments) : + Arguments(NULL), OpCode(opCode), fSpec(false), Type(PAP), argumentsSize(argumentsSize), nWordVersion (2) { + Arguments = new unsigned char[argumentsSize]; + memcpy(Arguments, arguments, argumentsSize); } - SinglePropertyModifier::SinglePropertyModifier(unsigned char* bytes, int size, bool oldVersion_) : - Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), oldVersion (oldVersion_) + SinglePropertyModifier::SinglePropertyModifier(unsigned char* bytes, int size, int nWordVersion_) : + Arguments(NULL), OpCode(sprmPIstd), fSpec(false), Type(PAP), argumentsSize(0), nWordVersion (nWordVersion_) { unsigned char opSize = 0; unsigned char opCodeSize = 0; - if (oldVersion) + + if (nWordVersion > 0) { opCodeSize = 1; //first 1 byte are the operation code ... @@ -132,9 +135,12 @@ namespace DocFileFormat } else { - argumentsSize = opSize; - Arguments = new unsigned char[argumentsSize]; - memcpy( Arguments, ( bytes + opCodeSize ), argumentsSize ); + argumentsSize = min(size - opCodeSize, opSize); + if (argumentsSize > 0) + { + Arguments = new unsigned char[argumentsSize]; + memcpy( Arguments, ( bytes + opCodeSize ), argumentsSize ); + } } } @@ -142,13 +148,13 @@ namespace DocFileFormat { if ( spm.Arguments != NULL ) { - argumentsSize = spm.argumentsSize; + argumentsSize = spm.argumentsSize; Arguments = new unsigned char[argumentsSize]; memcpy( Arguments, spm.Arguments, argumentsSize ); fSpec = spm.fSpec; - OpCode = spm.OpCode; + OpCode = spm.OpCode; Type = spm.Type; - oldVersion = spm.oldVersion; + nWordVersion = spm.nWordVersion; } } @@ -180,7 +186,7 @@ namespace DocFileFormat fSpec = spm.fSpec; Type = spm.Type; argumentsSize = spm.argumentsSize; - oldVersion = spm.oldVersion; + nWordVersion = spm.nWordVersion; Arguments = new unsigned char[argumentsSize]; diff --git a/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.h b/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.h index 2d34e32baa..3d65483938 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.h +++ b/ASCOfficeDocFile/DocDocxConverter/SinglePropertyModifier.h @@ -48,7 +48,7 @@ namespace DocFileFormat class SinglePropertyModifier { public: - bool oldVersion; + int nWordVersion; /// The operation code identifies the property of the /// PAP/CHP/PIC/SEP/TAP which sould be modified OperationCode OpCode; @@ -61,10 +61,11 @@ namespace DocFileFormat /// The Arguments size unsigned int argumentsSize; - SinglePropertyModifier(bool oldVersion); + SinglePropertyModifier( int nWordVersion); /// parses the unsigned char to retrieve a SPRM - SinglePropertyModifier( unsigned char* bytes, int size, bool oldVersion ); + SinglePropertyModifier( unsigned char* bytes, int size, int nWordVersion ); SinglePropertyModifier( const SinglePropertyModifier& spm); + SinglePropertyModifier( OperationCode opCode, int argumentsSize, unsigned char* arguments); bool operator == ( const SinglePropertyModifier& spm ) const; bool operator != ( const SinglePropertyModifier& spm ) const; diff --git a/ASCOfficeDocFile/DocDocxConverter/Spa.cpp b/ASCOfficeDocFile/DocDocxConverter/Spa.cpp index e47a441256..8e8e22f338 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Spa.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/Spa.cpp @@ -69,7 +69,7 @@ namespace DocFileFormat short cb_primitive = reader->ReadInt16(); - if (pos + cb_primitive > length) + if ((cb_primitive < 1) || (pos + cb_primitive > length)) { reader->Seek(reader->GetPosition() - 4, 0); break; @@ -100,7 +100,7 @@ namespace DocFileFormat Spa* pSpa = new Spa(); if (!pSpa) return NULL; - if (reader->olderVersion) + if (reader->nWordVersion > 0) { int fc = reader->ReadInt32(); pSpa->cTxbx = reader->ReadUInt16(); diff --git a/ASCOfficeDocFile/DocDocxConverter/Spa.h b/ASCOfficeDocFile/DocDocxConverter/Spa.h index 97b052c05a..111d8457cf 100644 --- a/ASCOfficeDocFile/DocDocxConverter/Spa.h +++ b/ASCOfficeDocFile/DocDocxConverter/Spa.h @@ -54,9 +54,9 @@ namespace DocFileFormat static const int STRUCTURE_SIZE = 26; static const int STRUCTURE_SIZE_OLD = 6; - static const int GetSize(bool bOldVersion) + static const int GetSize(int nWordVersion) { - return bOldVersion ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE; + return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE; } Spa(); diff --git a/ASCOfficeDocFile/DocDocxConverter/StringTable.h b/ASCOfficeDocFile/DocDocxConverter/StringTable.h index b30f4d86bb..3d3ad8f5a7 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StringTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/StringTable.h @@ -71,12 +71,12 @@ namespace DocFileFormat parse( reader, (unsigned int)reader->GetPosition() ); } - StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, bool older ) : + StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, int nWordVersion ) : code_page(1250), fExtend(false), cbData(0), cbExtra(0) { if ( lcb > 0 ) { - VirtualStreamReader reader( tableStream, fc, older); + VirtualStreamReader reader( tableStream, fc, nWordVersion); parse( &reader, fc, lcb ) ; } @@ -123,25 +123,44 @@ namespace DocFileFormat //read cData long cDataStart = reader->GetPosition(); - unsigned short c = reader->ReadUInt16(); - - if ( c != 0xFFFF ) + unsigned short cb = 0, elem_sz = 0; + + if (reader->nWordVersion == 2) { - if (reader->olderVersion) - this->cbData = (int)c; // all size + cb = reader->ReadByte(); + elem_sz = reader->ReadByte(); + + if (elem_sz > 0) + { + count_elements = cb; + } else - count_elements = c; - + { + this->cbData = cb; + } } - else + else if (reader->nWordVersion == 1) { - //cData is a 4byte signed Integer, so we need to seek back - reader->Seek( (int)( fc + cDataStart ), 0/*STREAM_SEEK_SET*/ ); - - this->cbData = reader->ReadInt32(); + cb = reader->ReadUInt16(); + this->cbData = cb; // all size } + else if (reader->nWordVersion == 0) + { + cb = reader->ReadUInt16(); + if ( cb != 0xFFFF ) + { + count_elements = cb; + } + else + { + //cData is a 4byte signed Integer, so we need to seek back + reader->Seek( (int)( fc + cDataStart ), 0/*STREAM_SEEK_SET*/ ); + this->cbData = reader->ReadInt32(); + } + } + //read cbExtra - if (reader->olderVersion == false) + if (reader->nWordVersion == 0) { this->cbExtra = reader->ReadUInt16(); } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp index 8d6b27594d..6c9d534ffb 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheet.cpp @@ -54,43 +54,130 @@ namespace DocFileFormat /// Parses the streams to retrieve a StyleSheet. StyleSheet::StyleSheet (FileInformationBlock* fib, POLE::Stream* tableStream, POLE::Stream* dataStream) : stshi(NULL), Styles(NULL) { - VirtualStreamReader tableReader( tableStream, fib->m_FibWord97.fcStshf, fib->m_bOlderVersion); + VirtualStreamReader tableReader( tableStream, fib->m_FibWord97.fcStshf, fib->m_nWordVersion); - //read size of the STSHI - int stshiLengthBytesSize = 2; - unsigned char* stshiLengthBytes = tableReader.ReadBytes( stshiLengthBytesSize, true ); - short cbStshi = FormatUtils::BytesToInt16( stshiLengthBytes, 0, stshiLengthBytesSize ); - RELEASEARRAYOBJECTS( stshiLengthBytes ); - - //read the bytes of the STSHI - tableReader.Seek( ( fib->m_FibWord97.fcStshf + 2 ), 0/*STREAM_SEEK_SET*/ ); - unsigned char* stshi = tableReader.ReadBytes( cbStshi, true ); - - //parses STSHI - this->stshi = new StyleSheetInformation( stshi, cbStshi ); - RELEASEARRAYOBJECTS( stshi ); + short cbStshi = fib->m_FibWord97.lcbStshf; + //unsigned char* test = tableReader.ReadBytes( cbStshi, true ); //create list of STDs Styles = new std::vector(); - for ( int i = 0; i < this->stshi->cstd; i++ ) + if (fib->m_nWordVersion < 2) { - //get the cbStd - unsigned short cbStd = tableReader.ReadUInt16(); + //read size of the STSHI + int stshiLengthBytesSize = 2; + unsigned char* stshiLengthBytes = tableReader.ReadBytes( stshiLengthBytesSize, true ); + short cbStshi = FormatUtils::BytesToInt16( stshiLengthBytes, 0, stshiLengthBytesSize ); + RELEASEARRAYOBJECTS( stshiLengthBytes ); + + //read the bytes of the STSHI + tableReader.Seek( ( fib->m_FibWord97.fcStshf + 2 ), 0/*STREAM_SEEK_SET*/ ); + unsigned char* stshi = tableReader.ReadBytes( cbStshi, true ); - if ( cbStd != 0 ) + //parses STSHI + this->stshi = new StyleSheetInformation( stshi, cbStshi ); + RELEASEARRAYOBJECTS( stshi ); + + for ( int i = 0; i < this->stshi->cstd; i++ ) { - //read the STD bytes - unsigned char* std = tableReader.ReadBytes( cbStd, true ); + //get the cbStd + unsigned short cbStd = tableReader.ReadUInt16(); - //parse the STD bytes - Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream, fib->m_bOlderVersion) ); + if ( cbStd != 0 ) + { + //read the STD bytes + unsigned char* std = tableReader.ReadBytes( cbStd, true ); - RELEASEARRAYOBJECTS( std ); + //parse the STD bytes + Styles->push_back( new StyleSheetDescription( std, cbStd, (int)this->stshi->cbSTDBaseInFile, dataStream, fib->m_nWordVersion) ); + + RELEASEARRAYOBJECTS( std ); + } + else + { + Styles->push_back( NULL ); + } } - else + } + else + { + unsigned short i, sz = 0; + tableReader.ReadUInt16(); + + unsigned short sz_names = tableReader.ReadUInt16(); + sz = 2; + while(sz < sz_names) { - Styles->push_back( NULL ); + unsigned short sz_name = tableReader.ReadByte(); sz++; + + StyleSheetDescription* std = new StyleSheetDescription(); + + if (sz_name != 0 && sz_name < 0xff) + { + unsigned char *bytes = tableReader.ReadBytes( sz_name, true ); + FormatUtils::GetSTLCollectionFromBytes( &std->xstzName, bytes, sz_name, ENCODING_WINDOWS_1250 ); + RELEASEARRAYOBJECTS( bytes ); + } + else + { + if (Styles->empty()) + { + std->sti = Normal; + std->xstzName = L"Normal"; + } + } + + Styles->push_back(std); + + sz += sz_name != 0xff ? sz_name : 0; + } + unsigned short sz_chpxs = tableReader.ReadUInt16(); + i = 0; + sz = 2; + while(sz < sz_chpxs) + { + unsigned short sz_chpx = tableReader.ReadByte(); + sz++; + + if (Styles->size() <= i) + { + StyleSheetDescription* std = new StyleSheetDescription(); + Styles->push_back(std); + } + if (sz_chpx != 0 && sz_chpx != 255) + { + unsigned char *bytes = tableReader.ReadBytes( sz_chpx, true ); + Styles->at(i)->chpx = new CharacterPropertyExceptions( bytes, sz_chpx , fib->m_nWordVersion); + RELEASEARRAYOBJECTS( bytes ); + sz += sz_chpx; + } + i++; + } + unsigned short sz_papxs = tableReader.ReadUInt16(); + i = 0; + sz = 2; + while(sz < sz_papxs) + { + unsigned short sz_papx = tableReader.ReadByte(); + sz++; + + if ( sz_papx != 255) + { + unsigned char *bytes = tableReader.ReadBytes( sz_papx, true ); + Styles->at(i)->papx = new ParagraphPropertyExceptions( bytes, sz_papx, tableStream, fib->m_nWordVersion ); + RELEASEARRAYOBJECTS( bytes ); + + sz += sz_papx; + } + i++; + } + unsigned short sz_Estcps = tableReader.ReadUInt16(); + i = 0; + sz = 2; + while(sz < sz_Estcps) + { + Styles->at(i++)->istdBase = tableReader.ReadByte(); + sz += 1; } } } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp index eb800319dc..09f903e3f3 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.cpp @@ -35,7 +35,20 @@ namespace DocFileFormat { /// Creates an empty STD object - StyleSheetDescription::StyleSheetDescription() : papx(NULL), chpx(NULL), tapx(NULL) + StyleSheetDescription::StyleSheetDescription(): papx(NULL), chpx(NULL), tapx(NULL), sti(User), + fAutoRedef(false), + fHidden(false), + f97LidsSet(false), + fCopyLang(false), + fPersonalCompose(false), + fPersonalReply(false), + fPersonal(false), + fNoHtmlExport(false), + fSemiHidden(false), + fLocked(false), + fInternalUse(false), + stk(paragraph_style), + istdBase(0xffffff), cupx (0), istdNext(0xffffff), bchUpe(0) { } @@ -48,8 +61,8 @@ namespace DocFileFormat } /// Parses the bytes to retrieve a StyleSheetDescription - StyleSheetDescription::StyleSheetDescription (unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, bool oldVersion) : - papx(NULL), chpx(NULL), tapx(NULL), + StyleSheetDescription::StyleSheetDescription (unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, int nWordVersion) : + papx(NULL), chpx(NULL), tapx(NULL), sti(User), fAutoRedef(false), fHidden(false), f97LidsSet(false), @@ -60,8 +73,9 @@ namespace DocFileFormat fNoHtmlExport(false), fSemiHidden(false), fLocked(false), - fInternalUse(false) - + fInternalUse(false), + stk(paragraph_style), + istdBase(0xffffff), cupx (0), istdNext(0xffffff), bchUpe(0) { //parsing the base (fix part) @@ -132,7 +146,7 @@ namespace DocFileFormat unsigned char characterCount = bytes[cbStdBase]; int upxOffset = 0; - if (oldVersion) + if (nWordVersion > 0) { name = new unsigned char[characterCount];//characters are zero-terminated, so 1 char has 2 bytes: memcpy( name, ( bytes + cbStdBase + 1 ), ( characterCount ) ); @@ -177,21 +191,21 @@ namespace DocFileFormat { //todooo не реализовано //RELEASEOBJECT( tapx ); - //tapx = new TablePropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion); + //tapx = new TablePropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion); } break; case 1: { RELEASEOBJECT( papx ); - papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion); + papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion); } break; case 2: { RELEASEOBJECT( chpx ); - chpx = new CharacterPropertyExceptions( upxBytes, cbUPX , oldVersion); + chpx = new CharacterPropertyExceptions( upxBytes, cbUPX , nWordVersion); } break; } @@ -204,14 +218,14 @@ namespace DocFileFormat case 0: { RELEASEOBJECT( papx ); - papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion ); + papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion ); } break; case 1: { RELEASEOBJECT( chpx ); - chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, oldVersion); + chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, nWordVersion); } break; } @@ -224,7 +238,7 @@ namespace DocFileFormat case 0: { RELEASEOBJECT( papx ); - papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, oldVersion ); + papx = new ParagraphPropertyExceptions( upxBytes, cbUPX, dataStream, nWordVersion ); } break; } @@ -237,7 +251,7 @@ namespace DocFileFormat case 0: { RELEASEOBJECT( chpx ); - chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, oldVersion); + chpx = new CharacterPropertyExceptions( upxBytes, cbUPX, nWordVersion); } break; } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h index e1b786d66c..0a443a6887 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetDescription.h @@ -385,7 +385,7 @@ namespace DocFileFormat friend class StyleSheetMapping; friend class CharacterPropertiesMapping; - private: + public: /// The name of the style std::wstring xstzName; /// Invariant style identifier @@ -450,11 +450,10 @@ namespace DocFileFormat /// If the style doesn't modify table properties, tapx is null. TablePropertyExceptions* tapx; - public: /// Creates an empty STD object StyleSheetDescription(); virtual ~StyleSheetDescription(); /// Parses the bytes to retrieve a StyleSheetDescription - StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, bool older); + StyleSheetDescription( unsigned char* bytes, int size, int cbStdBase, POLE::Stream* dataStream, int nWordVersion); }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetInformation.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetInformation.cpp index 233f2a588a..cd018b7cfd 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetInformation.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetInformation.cpp @@ -35,7 +35,8 @@ namespace DocFileFormat { /// Parses the bytes to retrieve a StyleSheetInformation - StyleSheetInformation::StyleSheetInformation (unsigned char* bytes, int size) + StyleSheetInformation::StyleSheetInformation (unsigned char* bytes, int size) : + cstd(0), cbSTDBaseInFile(0), fStdStylenamesWritten(false), stiMaxWhenSaved(0), istdMaxFixedWhenSaved(0), nVerBuiltInNamesWhenSaved(0), cbLSD(0) { if ((0 != size) || (NULL != bytes)) { diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp index dd9bfb50bb..5b27957aef 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp @@ -234,41 +234,44 @@ namespace DocFileFormat void StyleSheetMapping::writeRunDefaults( StyleSheet* sheet ) { - m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" ); - m_pXmlWriter->WriteNodeBegin( L"w:rPr" ); + if ((sheet->stshi) && (!sheet->stshi->rgftcStandardChpStsh.empty())) + { + m_pXmlWriter->WriteNodeBegin( L"w:rPrDefault" ); + m_pXmlWriter->WriteNodeBegin( L"w:rPr" ); - //write default fonts - m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE ); + //write default fonts + m_pXmlWriter->WriteNodeBegin( L"w:rFonts", TRUE ); - FontFamilyName* ffnAscii = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) ); - if (ffnAscii) - m_pXmlWriter->WriteAttribute( L"w:ascii", FormatUtils::XmlEncode(ffnAscii->xszFtn, true)); + FontFamilyName* ffnAscii = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[0] ) ); + if (ffnAscii) + m_pXmlWriter->WriteAttribute( L"w:ascii", FormatUtils::XmlEncode(ffnAscii->xszFtn, true)); - FontFamilyName* ffnAsia = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) ); - if (ffnAsia) - m_pXmlWriter->WriteAttribute( L"w:eastAsia", FormatUtils::XmlEncode(ffnAsia->xszFtn, true)); + FontFamilyName* ffnAsia = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[1] ) ); + if (ffnAsia) + m_pXmlWriter->WriteAttribute( L"w:eastAsia", FormatUtils::XmlEncode(ffnAsia->xszFtn, true)); - FontFamilyName* ffnAnsi = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) ); - if (ffnAnsi) - m_pXmlWriter->WriteAttribute( L"w:hAnsi", FormatUtils::XmlEncode(ffnAnsi->xszFtn, true)); + FontFamilyName* ffnAnsi = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[2] ) ); + if (ffnAnsi) + m_pXmlWriter->WriteAttribute( L"w:hAnsi", FormatUtils::XmlEncode(ffnAnsi->xszFtn, true)); - FontFamilyName* ffnComplex = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) ); - if (ffnComplex) - m_pXmlWriter->WriteAttribute( L"w:cs", FormatUtils::XmlEncode(ffnComplex->xszFtn, true)); + FontFamilyName* ffnComplex = static_cast( m_document->FontTable->operator [] ( sheet->stshi->rgftcStandardChpStsh[3] ) ); + if (ffnComplex) + m_pXmlWriter->WriteAttribute( L"w:cs", FormatUtils::XmlEncode(ffnComplex->xszFtn, true)); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - m_pXmlWriter->WriteNodeEnd( L"w:rFonts" ); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + m_pXmlWriter->WriteNodeEnd( L"w:rFonts" ); - LanguageId langid(this->m_document->FIB->m_FibBase.lid); - std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid ); + LanguageId langid(this->m_document->FIB->m_FibBase.lid); + std::wstring langcode = LanguageIdMapping::getLanguageCode( &langid ); - m_pXmlWriter->WriteNodeBegin( L"w:lang", TRUE ); - m_pXmlWriter->WriteAttribute( L"w:val", langcode); - m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); - m_pXmlWriter->WriteNodeEnd( L"w:lang" ); + m_pXmlWriter->WriteNodeBegin( L"w:lang", TRUE ); + m_pXmlWriter->WriteAttribute( L"w:val", langcode); + m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); + m_pXmlWriter->WriteNodeEnd( L"w:lang" ); - m_pXmlWriter->WriteNodeEnd( L"w:rPr" ); - m_pXmlWriter->WriteNodeEnd( L"w:rPrDefault" ); + m_pXmlWriter->WriteNodeEnd( L"w:rPr" ); + m_pXmlWriter->WriteNodeEnd( L"w:rPrDefault" ); + } } /*========================================================================================================*/ diff --git a/ASCOfficeDocFile/DocDocxConverter/TableInfo.h b/ASCOfficeDocFile/DocDocxConverter/TableInfo.h index 57fca496cc..2b347a8e79 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableInfo.h +++ b/ASCOfficeDocFile/DocDocxConverter/TableInfo.h @@ -44,7 +44,7 @@ namespace DocFileFormat bool fInnerTableCell; unsigned int iTap; - TableInfo( ParagraphPropertyExceptions* papx ): + TableInfo( ParagraphPropertyExceptions* papx, int nWordVersion): fInTable(false), fTtp(false), fInnerTtp(false), fInnerTableCell(false), iTap(0) { if ( papx != NULL ) @@ -57,6 +57,12 @@ namespace DocFileFormat case sprmPFInTable: { fInTable = ( iter->Arguments[0] == 1 ) ? (true) : (false); + + if (nWordVersion > 0) + { + iTap = 1; + fInnerTableCell = fInnerTtp = true; + } }break; //case sprmOldPFTtp: diff --git a/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp index 01fac25cbb..73f152d192 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp @@ -215,7 +215,7 @@ namespace DocFileFormat int fcRowEnd = documentMapping->findRowEndFc(cp, depth); TablePropertyExceptions tapx ( documentMapping->findValidPapx( fcRowEnd ), documentMapping->m_document->DataStream, - documentMapping->m_document->FIB->m_bOlderVersion); + documentMapping->m_document->nWordVersion); std::list* chpxs = documentMapping->m_document->GetCharacterPropertyExceptions( fcRowEnd, fcRowEnd + 1 ); TableRowPropertiesMapping trpMapping( documentMapping->GetXMLWriter(), *(chpxs->begin()) ); @@ -315,7 +315,7 @@ namespace DocFileFormat papx = documentMapping->findValidPapx(fc); - TableInfo tai( papx ); + TableInfo tai( papx, documentMapping->m_document->nWordVersion ); return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) && @@ -335,7 +335,7 @@ namespace DocFileFormat papx = documentMapping->findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, documentMapping->m_document->nWordVersion ); return ( ( tai.fInTable ) && ( ( ( documentMapping->m_document->Text->at( _cp ) == 0x0007 ) && ( tai.iTap <= 1 ) && ( tai.fTtp ) ) || @@ -355,7 +355,7 @@ namespace DocFileFormat papx = documentMapping->findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, documentMapping->m_document->nWordVersion ); return ( ( tai.fInTable ) && ( documentMapping->m_document->Text->at( _cp ) == 0x000D ) && ( !IsCellMarker( _cp ) ) && ( !IsRowMarker( _cp ) ) ); @@ -378,7 +378,7 @@ namespace DocFileFormat papx = documentMapping->findValidPapx( fc ); - TableInfo tai( papx ); + TableInfo tai( papx, documentMapping->m_document->nWordVersion ); TableRow tableRow ( documentMapping, _cp ); TableCell tableCell ( documentMapping, _cp ); @@ -390,7 +390,7 @@ namespace DocFileFormat papx = documentMapping->findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, documentMapping->m_document->nWordVersion ); if ( tai.iTap > _depth ) { @@ -405,7 +405,7 @@ namespace DocFileFormat papx = documentMapping->findValidPapx( fc ); - tai = TableInfo( papx ); + tai = TableInfo( papx, documentMapping->m_document->nWordVersion ); paragraphBeginCP = _cp; } @@ -524,7 +524,7 @@ namespace DocFileFormat TablePropertyExceptions row1Tapx( documentMapping->findValidPapx( fcRowEnd ), documentMapping->m_document->DataStream , - documentMapping->m_document->FIB->m_bOlderVersion); + documentMapping->m_document->nWordVersion); //start table documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" ); diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h b/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h index 345d37dad2..455e6a0692 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertyExceptions.h @@ -41,8 +41,8 @@ namespace DocFileFormat { public: /// Parses the bytes to retrieve a TAPX - TablePropertyExceptions(unsigned char* bytes, int size, bool oldVersion) : - PropertyExceptions(bytes, size, oldVersion), m_bSkipShading97 (FALSE) + TablePropertyExceptions(unsigned char* bytes, int size, int nWordVersion) : + PropertyExceptions(bytes, size, nWordVersion), m_bSkipShading97 (FALSE) { //not yet implemented } @@ -53,10 +53,10 @@ namespace DocFileFormat } /// Extracts the TAPX SPRMs out of a PAPX - TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, bool oldVersion) : + TablePropertyExceptions (ParagraphPropertyExceptions* papx, POLE::Stream* dataStream, int nWordVersion) : PropertyExceptions() { - VirtualStreamReader oBinReader(dataStream, 0, oldVersion); + VirtualStreamReader oBinReader(dataStream, 0, nWordVersion); m_bSkipShading97 = FALSE; @@ -87,7 +87,7 @@ namespace DocFileFormat unsigned char* grpprlBytes = oBinReader.ReadBytes(grpprlSize, true); //parse the grpprl - PropertyExceptions externalPx(grpprlBytes, grpprlSize, oldVersion); + PropertyExceptions externalPx(grpprlBytes, grpprlSize, nWordVersion); for (std::list::iterator oIter = externalPx.grpprl->begin(); oIter != externalPx.grpprl->end(); ++oIter) { diff --git a/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp index ea1d63a9c3..23baaeb4a0 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TextboxMapping.cpp @@ -160,7 +160,7 @@ namespace DocFileFormat break; papx_prev = papx; - TableInfo tai( papx ); + TableInfo tai( papx, m_document->nWordVersion ); if ( tai.fInTable ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp index 54c6d8c452..b84a54f9af 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLPictureMapping.cpp @@ -414,6 +414,7 @@ namespace DocFileFormat } strStyle += L"width:" + strWidth + L"pt;" + L"height:" + strHeight + L"pt;"; + m_pXmlWriter->WriteAttribute( L"style", strStyle); if (m_isOlePreview) @@ -425,6 +426,21 @@ namespace DocFileFormat m_pXmlWriter->WriteAttribute( L"o:bullet", L"1" ); } + {//borders color + if (pict->brcTop) + m_pXmlWriter->WriteAttribute( L"o:bordertopcolor", + pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcTop->cv, L"#%06x") : pict->brcTop->ico); + if (pict->brcLeft) + m_pXmlWriter->WriteAttribute( L"o:borderleftcolor", + pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcLeft->cv, L"#%06x") : pict->brcLeft->ico); + if (pict->brcBottom) + m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor", + pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcBottom->cv, L"#%06x") : pict->brcBottom->ico); + if (pict->brcRight) + m_pXmlWriter->WriteAttribute( L"o:borderrightcolor", + pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcRight->cv, L"#%06x") : pict->brcRight->ico); + + } m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE ); if (CopyPicture(pict)) @@ -439,7 +455,7 @@ namespace DocFileFormat writePictureBorder( L"bordertop", pict->brcTop ); writePictureBorder( L"borderleft", pict->brcLeft ); writePictureBorder( L"borderbottom", pict->brcBottom ); - writePictureBorder( L"borderright", pict->brcRight ); + writePictureBorder( L"borderright", pict->brcRight ); } m_pXmlWriter->WriteNodeEnd( L"v:shape" ); @@ -476,12 +492,16 @@ namespace DocFileFormat WmfPlaceableFileHeader oWmfHeader = {}; oMetaHeader.ToWMFHeader(&oWmfHeader); - int lLenHeader = 114 + 22; + int lLenHeader = 22 + (pict->embeddedDataHeader ? 114 : 0); unsigned char *newData = new unsigned char[pict->embeddedDataSize + lLenHeader]; memcpy(newData, (unsigned char *)(&oWmfHeader), 22); - memcpy(newData + 22, pict->embeddedDataHeader, 114 ); + + if (pict->embeddedDataHeader) + { + memcpy(newData + 22, pict->embeddedDataHeader, 114 ); + } memcpy(newData + lLenHeader, pict->embeddedData, pict->embeddedDataSize); diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp index 3c47663d4d..0ece16fc90 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.cpp @@ -1312,7 +1312,7 @@ namespace DocFileFormat //write the blip if (oBlip) { - VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->FIB->m_bOlderVersion); + VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->nWordVersion); switch (oBlip->btWin32) { diff --git a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h index 9b212ef149..e87ef60494 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/VMLShapeMapping.h @@ -40,7 +40,6 @@ #include "VMLShapeTypeMapping.h" #include "TwipsValue.h" #include "EmuValue.h" -#include "MemoryStream.h" #include "RGBColor.h" #include "FixedPointNumber.h" diff --git a/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h b/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h index badec0d67b..250aa67700 100644 --- a/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h +++ b/ASCOfficeDocFile/DocDocxConverter/VirtualStreamReader.h @@ -39,8 +39,8 @@ class VirtualStreamReader : public IBinaryReader { public: - VirtualStreamReader (POLE::Stream* _stream, ULONG _position , bool _olderVersion) : - olderVersion(_olderVersion), stream(_stream), position(_position) + VirtualStreamReader (POLE::Stream* _stream, ULONG _position , int _nWordVersion) : + nWordVersion(_nWordVersion), stream(_stream), position(_position) { if ( stream == NULL )return; @@ -192,7 +192,8 @@ public: unsigned char* xstz = NULL; unsigned char* cch = NULL; - if (olderVersion) + + if (nWordVersion > 0) { int cchSize = 1; cch = ReadBytes( cchSize, true ); @@ -285,7 +286,7 @@ public: return result; } - bool olderVersion; + int nWordVersion; private: POLE::uint64 position; diff --git a/ASCOfficeDocFile/DocDocxConverter/WideString.h b/ASCOfficeDocFile/DocDocxConverter/WideString.h index 4c8ca6596a..241357f5e4 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WideString.h +++ b/ASCOfficeDocFile/DocDocxConverter/WideString.h @@ -59,7 +59,7 @@ namespace DocFileFormat bytes = reader->ReadBytes( length, true ); //It's a real string table - if (reader->olderVersion) + if (reader->nWordVersion > 0) { FormatUtils::GetSTLCollectionFromBytes( newObject, bytes, length, ENCODING_WINDOWS_1250 ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp b/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp index 5cd4383e89..a7011fbc3f 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/WordDocument.cpp @@ -97,10 +97,11 @@ namespace DocFileFormat m_pStorage = NULL; officeArtContent = NULL; - bOlderVersion = false; + nWordVersion = 0; bDocumentCodePage = false; nDocumentCodePage = ENCODING_WINDOWS_1250; + nFontsCodePage = ENCODING_WINDOWS_1250; } WordDocument::~WordDocument() @@ -116,7 +117,7 @@ namespace DocFileFormat namespace DocFileFormat { - long WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password) + int WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password) { m_sFileName = fileName; m_sPassword = password; @@ -131,8 +132,11 @@ namespace DocFileFormat if (m_pStorage->SetFile (m_sFileName.c_str()) == false) { - Clear(); - return AVS_ERROR_FILEFORMAT; + if (false == LoadDocumentFlat()) + { + Clear(); + return AVS_ERROR_FILEFORMAT; + } } //----------------------------------------------------------------------------------------------------------------- if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false) @@ -141,20 +145,30 @@ namespace DocFileFormat return AVS_ERROR_FILEFORMAT; } //------------------------------------------------------------------------------------------------------------------- - FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream,0, false )); + FIB = new FileInformationBlock(VirtualStreamReader(WordDocumentStream, 0, false )); if (FIB->m_FibBase.nFib) { if (FIB->m_FibBase.nFib <= Fib1995) { - bOlderVersion = FIB->m_bOlderVersion = true; + nWordVersion = FIB->m_nWordVersion = 1; + + if (FIB->m_FibBase.nFib <= Fib1989) + { + nWordVersion = FIB->m_nWordVersion = 2; + } } } else { if (FIB->m_FibNew.nFibNew <= Fib1995 && FIB->m_FibNew.nFibNew > 0) { - bOlderVersion = FIB->m_bOlderVersion = true; + nWordVersion = FIB->m_nWordVersion = 1; + + if (FIB->m_FibNew.nFibNew <= Fib1989) + { + nWordVersion = FIB->m_nWordVersion = 2; + } } } bool res = false; @@ -221,7 +235,7 @@ namespace DocFileFormat if (DecryptOfficeFile(&Decryptor) == false) return AVS_ERROR_DRM; } - FIB->reset(VirtualStreamReader(WordDocumentStream, bOlderVersion ? 36 : 68, false)); + FIB->reset(VirtualStreamReader(WordDocumentStream, (nWordVersion > 0) ? 36 : 68, false)); } //------------------------------------------------------------------------------------------------------------------ @@ -255,7 +269,7 @@ namespace DocFileFormat bDocumentCodePage = true; } } - if (!bOlderVersion) + if (nWordVersion == 0) { nDocumentCodePage = ENCODING_UTF16; bDocumentCodePage = true; @@ -272,20 +286,20 @@ namespace DocFileFormat DataStream = NULL; } - if (TableStream->size() < 1 && bOlderVersion) + if (TableStream->size() < 1 && nWordVersion > 0) { RELEASEOBJECT(TableStream); m_pStorage->GetStream (L"WordDocument", &TableStream); } - RevisionAuthorTable = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion); - FontTable = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, bOlderVersion); - BookmarkNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, bOlderVersion); - AutoTextNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, bOlderVersion); - AssocNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAssoc, FIB->m_FibWord97.lcbSttbfAssoc, bOlderVersion); - BookmarkAnnotNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, bOlderVersion); - Captions = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfCaption, FIB->m_FibWord97.lcbSttbfCaption, bOlderVersion); - AutoCaptions = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAutoCaption, FIB->m_FibWord97.lcbSttbfAutoCaption, bOlderVersion); + RevisionAuthorTable = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, nWordVersion); + FontTable = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, nWordVersion); + BookmarkNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, nWordVersion); + AutoTextNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, nWordVersion); + AssocNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAssoc, FIB->m_FibWord97.lcbSttbfAssoc, nWordVersion); + BookmarkAnnotNames = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, nWordVersion); + Captions = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfCaption, FIB->m_FibWord97.lcbSttbfCaption, nWordVersion); + AutoCaptions = new StringTable (TableStream, FIB->m_FibWord97.fcSttbfAutoCaption, FIB->m_FibWord97.lcbSttbfAutoCaption, nWordVersion); if (m_pCallFunc) { @@ -304,46 +318,46 @@ namespace DocFileFormat // Read all needed PLCFs if (FIB->m_RgLw97.ccpFtn > 0) { - IndividualFootnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, bOlderVersion); - FootnoteReferenceCharactersPlex = new Plex(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, bOlderVersion); + IndividualFootnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion); + FootnoteReferenceCharactersPlex = new Plex(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion); } if (FIB->m_FibWord97.lcbPlcPad > 0) { - OutlineListDescriptorPlex = new Plex(OutlineListDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcPad, FIB->m_FibWord97.lcbPlcPad, bOlderVersion); + OutlineListDescriptorPlex = new Plex(OutlineListDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcPad, FIB->m_FibWord97.lcbPlcPad, nWordVersion); } if (FIB->m_RgLw97.ccpEdn > 0) { - IndividualEndnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, bOlderVersion); - EndnoteReferenceCharactersPlex = new Plex(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, bOlderVersion); + IndividualEndnotesPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion); + EndnoteReferenceCharactersPlex = new Plex(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, nWordVersion); } if (FIB->m_RgLw97.ccpHdr > 0) { - HeaderStoriesPlex = new Plex( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, bOlderVersion); + HeaderStoriesPlex = new Plex( EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfHdd, FIB->m_FibWord97.lcbPlcfHdd, nWordVersion); } if (FIB->m_RgLw97.ccpAtn > 0) { - AnnotationsReferencePlex = new Plex(AnnotationReferenceDescriptor::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, bOlderVersion); - IndividualCommentsPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, bOlderVersion); + AnnotationsReferencePlex = new Plex(AnnotationReferenceDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, nWordVersion); + IndividualCommentsPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, nWordVersion); } - OfficeDrawingPlex = new Plex (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, bOlderVersion); - OfficeDrawingPlexHeader = new Plex (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, bOlderVersion); + OfficeDrawingPlex = new Plex (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, nWordVersion); + OfficeDrawingPlexHeader = new Plex (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, nWordVersion); - TextboxIndividualPlex = new Plex (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion); + TextboxIndividualPlex = new Plex (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, nWordVersion); - SectionPlex = new Plex (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, bOlderVersion); + SectionPlex = new Plex (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, nWordVersion); - BookmarkStartPlex = new Plex (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, bOlderVersion); - BookmarkEndPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl, bOlderVersion); + BookmarkStartPlex = new Plex (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, nWordVersion); + BookmarkEndPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkl, FIB->m_FibWord97.lcbPlcfBkl, nWordVersion); - TextboxBreakPlex = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, bOlderVersion); - TextboxBreakPlexHeader = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, bOlderVersion); + TextboxBreakPlex = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, nWordVersion); + TextboxBreakPlexHeader = new Plex (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, nWordVersion); - AnnotStartPlex = new Plex (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, bOlderVersion); - AnnotEndPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, bOlderVersion); + AnnotStartPlex = new Plex (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion); + AnnotEndPlex = new Plex (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, nWordVersion); for (size_t i = 0; i < BookmarkStartPlex->Elements.size(); ++i) @@ -359,15 +373,19 @@ namespace DocFileFormat BookmarkFirst* pBookmark = static_cast(AnnotStartPlex->Elements[i]); if (pBookmark) { - AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[pBookmark->GetIndex()])); + short end = pBookmark->GetIndex(); + if (i < AnnotStartPlex->CharacterPositions.size() && end < AnnotEndPlex->CharacterPositions.size()) + { + AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[end])); + } } } - AutoTextPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion); - FieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion); - FootnoteDocumentFieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion); - EndnoteDocumentFieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, bOlderVersion); - HeadersAndFootersDocumentFieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, bOlderVersion); - ListPlex = new Plex (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, bOlderVersion); + AutoTextPlex = new Plex(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, nWordVersion); + FieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, nWordVersion); + FootnoteDocumentFieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, nWordVersion); + EndnoteDocumentFieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, nWordVersion); + HeadersAndFootersDocumentFieldsPlex = new Plex(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, nWordVersion); + ListPlex = new Plex (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, nWordVersion); if (m_pCallFunc) { @@ -412,11 +430,12 @@ namespace DocFileFormat return AVS_ERROR_FILEFORMAT; } } - if (!bDocumentCodePage && FontTable) + if (FontTable) { std::unordered_map fonts_charsets; + bool bFontsCodePage = false; - for ( std::vector::iterator iter = FontTable->Data.begin();!bDocumentCodePage && iter != FontTable->Data.end(); iter++ ) + for ( std::vector::iterator iter = FontTable->Data.begin(); !bFontsCodePage && iter != FontTable->Data.end(); iter++ ) { FontFamilyName* font = dynamic_cast( *iter ); if (!font) continue; @@ -429,8 +448,8 @@ namespace DocFileFormat { if (aCodePages[i][0] == font->chs && font->chs != 0) { - nDocumentCodePage = aCodePages[i][1]; - bDocumentCodePage = true; + nFontsCodePage = aCodePages[i][1]; + bFontsCodePage = true; break; } } @@ -445,19 +464,26 @@ namespace DocFileFormat m_PieceTable = new PieceTable (FIB, TableStream, WordDocumentStream ); Text = m_PieceTable->GetAllEncodingText (WordDocumentStream); } - else + + if (FIB->m_FibWord97.lcbClx < 1 || ((Text) && (Text->empty()))) { int cb = FIB->m_FibBase.fcMac - FIB->m_FibBase.fcMin; - unsigned char *bytes = new unsigned char[cb]; + if (cb > 0) + { + FIB->m_FibBase.fComplex = false; + unsigned char *bytes = new unsigned char[cb]; - WordDocumentStream->seek (FIB->m_FibBase.fcMin); - WordDocumentStream->read (bytes, cb); + WordDocumentStream->seek (FIB->m_FibBase.fcMin); + WordDocumentStream->read (bytes, cb); - Text = new std::vector(); - FormatUtils::GetSTLCollectionFromBytes >(Text, bytes, cb, nDocumentCodePage); + RELEASEOBJECT(Text); + Text = new std::vector(); - RELEASEARRAYOBJECTS(bytes); + FormatUtils::GetSTLCollectionFromBytes>(Text, bytes, cb, nFontsCodePage != ENCODING_WINDOWS_1250 ? nFontsCodePage : nDocumentCodePage); + + RELEASEARRAYOBJECTS(bytes); + } } if (BookmarkNames) @@ -521,13 +547,13 @@ namespace DocFileFormat int cp = SectionPlex->CharacterPositions[i + 1]; //Get the SEPX - VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, bOlderVersion); + VirtualStreamReader wordReader( WordDocumentStream, sed->fcSepx, nWordVersion); //!!!TODO: cbSepx is the size in bytes of the rest properties part!!! short cbSepx = wordReader.ReadInt16(); unsigned char* bytes = wordReader.ReadBytes( ( cbSepx /*- 2*/ ), true ); - AllSepx->insert( std::pair( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), bOlderVersion ) ) ); + AllSepx->insert( std::pair( cp, new SectionPropertyExceptions( bytes, ( cbSepx /*- 2*/ ), nWordVersion ) ) ); RELEASEARRAYOBJECTS( bytes ); } @@ -549,6 +575,70 @@ namespace DocFileFormat return 0; } + bool WordDocument::LoadDocumentFlat() + { + NSFile::CFileBinary file; + + if (false == file.OpenFile(m_sFileName)) return false; + + DWORD sz_read = 0; + unsigned short wIdent = 0; + file.ReadFile((BYTE*)&wIdent, 2, sz_read); + + if ( wIdent != 0xA5EC && wIdent != 0xA5DC && wIdent != 0xA5DB) + { + file.CloseFile(); + return false; + } + file.SeekFile(0); + + if (m_sTempFolder.empty()) + { + m_sTempFolder = NSFile::CFileBinary::GetTempPath(); + } + m_sTempDecryptFileName = m_sTempFolder + FILE_SEPARATOR_STR + L"~tempFile.doc"; + + POLE::Storage *storageOut = new POLE::Storage(m_sTempDecryptFileName.c_str()); + + if (!storageOut) + { + file.CloseFile(); + return false; + } + + if (!storageOut->open(true, true)) + { + file.CloseFile(); + delete storageOut; + return false; + } + DWORD size_stream = file.GetFileSize(); + + POLE::Stream *streamNew = new POLE::Stream(storageOut, L"WordDocument", true, size_stream); + if (!streamNew) return false; + + unsigned char* data_stream = new unsigned char[size_stream]; + file.ReadFile(data_stream, size_stream, size_stream); + + streamNew->write(data_stream, size_stream); + + RELEASEARRAYOBJECTS(data_stream); + + streamNew->flush(); + + delete streamNew; + + storageOut->close(); + delete storageOut; + file.CloseFile(); + +//reset streams + RELEASEOBJECT(WordDocumentStream); + + m_pStorage->SetFile(m_sTempDecryptFileName.c_str()); + + return true; + } bool WordDocument::DecryptOfficeFile(CRYPT::Decryptor* Decryptor) { if (m_sTempFolder.empty()) @@ -610,6 +700,7 @@ namespace DocFileFormat } return true; } + void WordDocument::DecryptStream( int level, std::wstring path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor) { std::list entries, entries_files, entries_dir; @@ -682,7 +773,7 @@ namespace DocFileFormat if ( std::wstring::npos != streamName_open.find(L"WordDocument") ) { - size_data_store = bOlderVersion ? 36 : 68; + size_data_store = (nWordVersion > 0) ? 36 : 68; data_store = new unsigned char[size_data_store]; } @@ -692,7 +783,7 @@ namespace DocFileFormat size_t size_block = 0x200; unsigned long block = 0; - for (POLE::uint64 pos = /*bOlderVersion ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++) + for (POLE::uint64 pos = /*(nWordVersion > 0) ? size_data_store :*/ 0; pos < size_stream; pos += size_block, block++) { if (pos + size_block > size_stream) size_block = size_stream - pos; @@ -722,7 +813,7 @@ namespace DocFileFormat void WordDocument::Clear() { - bOlderVersion = false; + nWordVersion = 0; if (AllPapxFkps) { diff --git a/ASCOfficeDocFile/DocDocxConverter/WordDocument.h b/ASCOfficeDocFile/DocDocxConverter/WordDocument.h index c878bc98ff..7029c6df5d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordDocument.h +++ b/ASCOfficeDocFile/DocDocxConverter/WordDocument.h @@ -94,17 +94,24 @@ namespace DocFileFormat WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder ); virtual ~WordDocument(); - long LoadDocument (const std::wstring & fileName, const std::wstring & password); + int LoadDocument(const std::wstring & fileName, const std::wstring & password); - bool bOlderVersion; + int nWordVersion; int nDocumentCodePage; bool bDocumentCodePage; + int nFontsCodePage; inline StructuredStorageReader* GetStorage() const { return m_pStorage; } + inline POLE::Stream* GetDocumentStream() const + { + return WordDocumentStream; + } private: + bool LoadDocumentFlat(); + bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor); bool DecryptStream (std::wstring streamName_open, POLE::Storage * storageIn, std::wstring streamName_create, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor, bool bDecrypt); diff --git a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp index d52c436302..8aecb70d96 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.cpp @@ -304,7 +304,7 @@ namespace DocFileFormat if (!iter->data.empty()) { - SaveEmbeddedObject(fileName, iter->data); + SaveEmbeddedObject(fileName, *iter); } else { diff --git a/ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp b/ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp index ef85d20e58..dfbd533561 100644 --- a/ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp +++ b/ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp @@ -31,6 +31,8 @@ */ #include +#include "../../Common/OfficeFileFormatChecker.h" +#include "../../Common/DocxFormat/Source/Base/Base.h" #include "../../Common/DocxFormat/Source/Base/Base.h" #include "../../DesktopEditor/common/Directory.h" #include "../../OfficeUtils/src/OfficeUtils.h" @@ -49,6 +51,13 @@ HRESULT convert_single(std::wstring srcFileName) { + COfficeFileFormatChecker checker; + + if (false == checker.isOfficeFile(srcFileName)) return S_FALSE; + + if (AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC != checker.nFileType && + AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT != checker.nFileType) return S_FALSE; + HRESULT hr = S_OK; std::wstring outputDir = NSDirectory::GetFolderPath(srcFileName); diff --git a/Common/OfficeFileFormatChecker.h b/Common/OfficeFileFormatChecker.h index c398d86d0c..2e95e9a267 100644 --- a/Common/OfficeFileFormatChecker.h +++ b/Common/OfficeFileFormatChecker.h @@ -72,6 +72,8 @@ public: bool isPptFormatFile (POLE::Storage *storage); bool isMS_OFFCRYPTOFormatFile (POLE::Storage * storage); + bool isDocFlatFormatFile (unsigned char* pBuffer,int dwBytes); + bool isRtfFormatFile (unsigned char* pBuffer,int dwBytes); bool isHtmlFormatFile (unsigned char* pBuffer,int dwBytes, bool testCloseTag); bool isPdfFormatFile (unsigned char* pBuffer,int dwBytes); diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index c48112ed78..44a6210a3a 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -145,19 +145,23 @@ bool COfficeFileFormatChecker::isDocFormatFile (POLE::Storage * storage) POLE::Stream stream(storage, L"WordDocument"); unsigned char buffer[10]; - if (stream.read(buffer,10) > 0) + if (stream.read(buffer, 10) > 0) { //ms office 2007 encrypted contains stream WordDocument !! std::list entries = storage->entries(L"DataSpaces"); if (entries.size() > 0) return false; + + if ((buffer[0] == 0xEC && buffer[1] == 0xA5) || // word 1997-2003 + (buffer[0] == 0xDC && buffer[1] == 0xA5)) // word 1995 + { + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC; + } -#if defined FILE_FORMAT_CHECKER_WITH_MACRO if (storage->isDirectory(L"Macros")) { bMacroEnabled = true; } -#endif return true; } @@ -193,14 +197,23 @@ bool COfficeFileFormatChecker::isXlsFormatFile (POLE::Storage * storage) } } } -#if defined FILE_FORMAT_CHECKER_WITH_MACRO if (storage->isDirectory(L"_VBA_PROJECT_CUR")) { bMacroEnabled = true; } -#endif return true; } +bool COfficeFileFormatChecker::isDocFlatFormatFile (unsigned char* pBuffer, int dwBytes) +{ + if (pBuffer == NULL) return false; + + if ((pBuffer[0] == 0xEC && pBuffer[1] == 0xA5) || + (pBuffer[0] == 0xDC && pBuffer[1] == 0xA5) || + (pBuffer[0] == 0xDB && pBuffer[1] == 0xA5)) + return true; + + return false; +} bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage) { @@ -236,8 +249,8 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName) { if ( isDocFormatFile(&storage) ) { - nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC; - return true; + //nFileType внутри + return true; } else if ( isXlsFormatFile(&storage) ) { @@ -335,6 +348,11 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName) { //nFileType } + else if (isDocFlatFormatFile(buffer,sizeRead) ) + { + nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT; // without compaund container + } + //------------------------------------------------------------------------------------------------ file.CloseFile(); diff --git a/Common/OfficeFileFormats.h b/Common/OfficeFileFormats.h index 1411e2d824..fdc46070c6 100644 --- a/Common/OfficeFileFormats.h +++ b/Common/OfficeFileFormats.h @@ -49,6 +49,7 @@ #define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x000d #define AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x000e #define AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x000f +#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0010 #define AVS_OFFICESTUDIO_FILE_PRESENTATION 0x0080 #define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0001 @@ -60,7 +61,7 @@ #define AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0007 #define AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0008 #define AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0009 -#define AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x0010 +#define AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000a #define AVS_OFFICESTUDIO_FILE_SPREADSHEET 0x0100 #define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0001