diff --git a/ASCOfficeDocFile/DocDocxConverter/ContentTypes.h b/ASCOfficeDocFile/DocDocxConverter/ContentTypes.h index eb599fc2a5..99bda5b387 100644 --- a/ASCOfficeDocFile/DocDocxConverter/ContentTypes.h +++ b/ASCOfficeDocFile/DocDocxConverter/ContentTypes.h @@ -163,6 +163,7 @@ namespace OpenXmlRelationshipTypes static const wchar_t* GlossaryDocument = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"; static const wchar_t* Package = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; static const wchar_t* VbaProject = L"http://schemas.microsoft.com/office/2006/relationships/vbaProject"; + static const wchar_t* Hyperlink = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; } namespace MicrosoftWordRelationshipTypes diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index 213ad1010c..59a665ce54 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -685,9 +685,9 @@ namespace DocFileFormat if ( _bContentWrite ) { - m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true ); - m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" ); - m_pXmlWriter->WriteNodeEnd( L"", true ); + m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true ); + m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" ); + m_pXmlWriter->WriteNodeEnd( L"", true ); _fieldLevels.back().bBegin = true; } @@ -702,12 +702,12 @@ namespace DocFileFormat { _writeWebHidden = true; std::wstring _writeTocLink =f1.substr(d + 9); - d = (int)_writeTocLink.find(L" "); + d = (int)_writeTocLink.find(L" "); _writeTocLink = _writeTocLink.substr(0, d); - _writeAfterRun = std::wstring (L""); + _writeAfterRun += std::wstring (L"\" w:history=\"1\">"); break; //cp = cpFieldSep1; @@ -717,7 +717,28 @@ namespace DocFileFormat _skipRuns = 5; //with separator } } - else if ( bEMBED || bLINK || bQUOTE) + //else if ( bHYPERLINK ) + //{//todooo - выделение гиперссылки отдельно + // std::vector arRefs; + // boost::algorithm::split(arRefs, f, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on); + // + // std::wstring sLink = arRefs[2]; + // m_pXmlWriter->WriteNodeBegin( L"w:hyperlink", true ); + + // int relID = m_context->_docx->RegisterHyperlink(_caller, sLink); + // m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) ); + // m_pXmlWriter->WriteAttribute( L"w:history", 1 ); + // m_pXmlWriter->WriteNodeEnd( L"", true, false ); + + // if (arRefs.size() > 2) + // { + // writeTextElement(arRefs[3].substr(1, arRefs[3].length() - 2), textType); + // } + // m_pXmlWriter->WriteNodeEnd( L"w:hyperlink", false, true ); + + // _skipRuns = 1; + //} + else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE) { int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture); int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator); @@ -840,19 +861,21 @@ namespace DocFileFormat else if (TextMark::FieldEndMark == code) { if (!_fieldLevels.empty()) - { - _fieldLevels.back().bEnd = true; - - if (_fieldLevels.back().bBegin == true && !text.empty()) + { + if (!text.empty()) { writeTextElement(text, textType); text.clear(); - } + } + if (_fieldLevels.back().bBegin) + { + _fieldLevels.back().bEnd = true; - XMLTools::XMLElement elem( L"w:fldChar" ); - elem.AppendAttribute( L"w:fldCharType", L"end" ); + XMLTools::XMLElement elem( L"w:fldChar" ); + elem.AppendAttribute( L"w:fldCharType", L"end" ); - m_pXmlWriter->WriteString( elem.GetXMLString()); + m_pXmlWriter->WriteString( elem.GetXMLString()); + } _fieldLevels.pop_back(); } @@ -1151,20 +1174,7 @@ namespace DocFileFormat if ( fc >= nMinVal ) { ret = m_document->AllPapx->find(nMinVal)->second; -//? if (!ret && m_document->AllPapx->size() > 0) -//? { -//? map::iterator it = m_document->AllPapx->end(); -//? it--; -//? do -//? { -//? if (it->first < nMinVal && it->second) -//? break; -//? it--; -//? } -//? while(it != m_document->AllPapx->begin()); -//? -//? ret = it->second; -//? } + _lastValidPapx = ret; } } @@ -1215,8 +1225,8 @@ namespace DocFileFormat TableInfo tai( papx, m_document->nWordVersion ); //build the table grid - std::vector grid, grid_write; - buildTableGrid( cp, nestingLevel, grid, grid_write ); + std::vector grid; + buildTableGrid( cp, nestingLevel, grid); //find first row end int fcRowEnd = findRowEndFc( cp, nestingLevel ); @@ -1227,7 +1237,7 @@ namespace DocFileFormat m_pXmlWriter->WriteNodeBegin( L"w:tbl" ); //Convert it - TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid, &grid_write ); + TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid); row1Tapx.Convert( tpMapping ); @@ -1240,7 +1250,7 @@ namespace DocFileFormat //only convert the cells with the given nesting level while ( tai.iTap == nestingLevel ) { - cp = writeTableRow( cp, &grid, &grid_write, nestingLevel ); + cp = writeTableRow( cp, &grid, nestingLevel ); //?fc = m_document->FindFileCharPos(cp ); fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp ); papx = findValidPapx( fc ); @@ -1253,7 +1263,7 @@ namespace DocFileFormat //convert until the end of table is reached while ( tai.fInTable ) { - cp = writeTableRow( cp, &grid, &grid_write, nestingLevel ); + cp = writeTableRow( cp, &grid, nestingLevel ); fc = m_document->FindFileCharPos( cp ); papx = findValidPapx( fc ); @@ -1268,12 +1278,11 @@ namespace DocFileFormat } // Builds a list that contains the width of the several columns of the table. - bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector& grid, std::vector& grid_write) + bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector& grid) { ParagraphPropertyExceptions* backup = _lastValidPapx; - std::vector boundaries; - std::vector boundaries_all; + std::map boundaries; int cp = initialCp; int fc = m_document->FindFileCharPos( cp ); @@ -1284,8 +1293,12 @@ namespace DocFileFormat int fcRowEnd = findRowEndFc( cp, cp, nestingLevel ); ParagraphPropertyExceptions* papx_prev = NULL; + short max_boundary = -1; + short count_column = 0; + while ( tai.fInTable ) { + short current_count_column = 0; //check all SPRMs of this TAPX for ( std::list::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ ) { @@ -1294,43 +1307,33 @@ namespace DocFileFormat switch(iter->OpCode) { - case sprmTDefTable: - case sprmOldTDefTable: - { - unsigned char itcMac = iter->Arguments[0]; - - while(boundaries.size() < itcMac + 1) - boundaries.push_back(-0x7fff); - - short boundary0 = -0x7fff; - for (unsigned char i = 0; i < itcMac; i++) + case sprmTDefTable: + case sprmOldTDefTable: { - short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize ); - short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize ); + //SprmTDefTable tdef(iter->Arguments, iter->argumentsSize); + //int itcMac = tdef.numberOfColumns; - if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1) - { - if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff) - { - boundaries[i] = boundary1; - boundaries[i+1] = boundary2; - } - } - if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() ) - { - boundaries_all.push_back( boundary1 ); - } + unsigned char itcMac = iter->Arguments[0]; - if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() ) + short boundary1, boundary2; + for (unsigned char i = 0; i < itcMac; i++) { - boundaries_all.push_back( boundary2 ); + boundary1 = FormatUtils::BytesToInt16( iter->Arguments + 1, i * 2 , iter->argumentsSize ); + boundary2 = FormatUtils::BytesToInt16( iter->Arguments + 1, ( i + 1 ) * 2, iter->argumentsSize ); + + AddBoundary(boundary1, boundary2, boundaries); } - boundary0 = boundary1; - }break; - } + if (max_boundary < boundary2) + max_boundary = boundary2; + + AddBoundary(boundary2, max_boundary, boundaries); + }break; } } + if (current_count_column > count_column) + count_column = current_count_column; + //get the next papx papx = findValidPapx( fcRowEnd ); tai = TableInfo( papx, m_document->nWordVersion ); @@ -1341,21 +1344,11 @@ namespace DocFileFormat papx_prev = papx; } - //build the grid based on the boundaries - sort( boundaries_all.begin(), boundaries_all.end() ); - if ( !boundaries.empty() ) { - for ( size_t i = 0; i < ( boundaries.size() - 1 ); i++ ) + for ( std::map::iterator it = boundaries.begin(); it != boundaries.end(); ++it) { - grid_write.push_back( boundaries[i + 1] - boundaries[i] ); - } - } - if ( !boundaries_all.empty() ) - { - for ( size_t i = 0; i < ( boundaries_all.size() - 1 ); i++ ) - { - grid.push_back( boundaries_all[i + 1] - boundaries_all[i] ); + grid.push_back( it->second ); } } _lastValidPapx = backup; @@ -1363,6 +1356,40 @@ namespace DocFileFormat return true; } + void DocumentMapping::AddBoundary(short boundary1, short boundary2, std::map &boundaries) + { + if (boundary2 - boundary1 < 10) + return; + + std::map::iterator pFind = boundaries.find(boundary1); + + while(true) + { + if (pFind == boundaries.end()) + { + boundaries.insert(std::make_pair(boundary1, boundary2 - boundary1)); + break; + } + else if (pFind->second != boundary2 - boundary1) + { + if (pFind->second > boundary2 - boundary1) + { + short new_size = boundary2 - boundary1; + boundary1 = boundary2; + boundary2 = pFind->second + pFind->first; + pFind->second = new_size; + } + else + { + boundary1 = pFind->second + pFind->first; + } + pFind = boundaries.find(boundary1); + } + else + break; + } + } + // Finds the FC of the next row end mark. int DocumentMapping::findRowEndFc(int initialCp, int& rowEndCp, unsigned int nestingLevel ) { @@ -1480,7 +1507,7 @@ namespace DocFileFormat } /// Writes the table row that starts at the given cp value and ends at the next row end mark - int DocumentMapping::writeTableRow(int initialCp, std::vector* grid, std::vector* grid_write, unsigned int nestingLevel) + int DocumentMapping::writeTableRow(int initialCp, std::vector* grid, unsigned int nestingLevel) { int cp = initialCp; int fc = m_document->FindFileCharPos( cp ); @@ -1510,7 +1537,7 @@ namespace DocFileFormat //Write until the first "inner trailer paragraph" is reached while ( !( ( m_document->Text->at( cp ) == TextMark::ParagraphEnd ) && ( tai.fInnerTtp ) ) && tai.fInTable ) { - cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel ); + cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel ); cellIndex++; //each cell has it's own PAPX @@ -1527,7 +1554,7 @@ namespace DocFileFormat while ( !( ( m_document->Text->at( cp ) == TextMark::CellOrRowMark ) && ( tai.fTtp ) ) && tai.fInTable ) { - cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel ); + cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel ); cellIndex++; //each cell has it's own PAPX @@ -1550,7 +1577,7 @@ namespace DocFileFormat } /// Writes the table cell that starts at the given cp value and ends at the next cell end mark - int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector* grid, std::vector* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel ) + int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel ) { int cp = initialCp; int cpCellEnd = findCellEndCp( initialCp, nestingLevel ); @@ -1558,7 +1585,7 @@ namespace DocFileFormat //start w:tc m_pXmlWriter->WriteNodeBegin( L"w:tc" ); - TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex ); + TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex ); if ( tapx != NULL ) { diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h index be404510fd..054fd1e0a6 100644 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.h @@ -110,15 +110,15 @@ namespace DocFileFormat // Writes the table starts at the given cp value int writeTable ( int initialCp, unsigned int nestingLevel ); // Builds a list that contains the width of the several columns of the table. - bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector& grid, std::vector& grid_write ); + bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector& grid); // Finds the FC of the next row end mark. int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel ); // Finds the FC of the next row end mark. int findRowEndFc ( int initialCp, unsigned int nestingLevel ); // Writes the table row that starts at the given cp value and ends at the next row end mark - int writeTableRow ( int initialCp, std::vector* grid, std::vector* grid_write, unsigned int nestingLevel ); + int writeTableRow ( int initialCp, std::vector* grid, unsigned int nestingLevel ); // Writes the table cell that starts at the given cp value and ends at the next cell end mark - int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector* grid, std::vector* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel ); + int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel ); int findCellEndCp ( int initialCp, unsigned int nestingLevel ); bool writeBookmarks ( int cp ); @@ -135,6 +135,8 @@ namespace DocFileFormat // Searches the given vector for the next FieldEnd character. int searchNextTextMark( std::vector* chars, int initialCp, wchar_t mark ); Symbol getSymbol ( const CharacterPropertyExceptions* chpx ); + + void AddBoundary(short boundary1, short boundary2, std::map &boundaries); //---------------------------------------------------------------------------------------------------------------------- bool m_bInternalXmlWriter; diff --git a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp index 6b2ba264e7..e2fb7b35d9 100644 --- a/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/FormattedDiskPagePAPX.cpp @@ -128,21 +128,22 @@ namespace DocFileFormat if ( bx.wordOffset != 0 ) { unsigned char padbyte = 0; - unsigned char cw = bytes[bx.wordOffset * 2] * 2; + unsigned char cw = bytes[bx.wordOffset * 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] * 2; + cw = bytes[bx.wordOffset * 2 + 1]; } if ( cw != 0 ) { + int sz = cw * 2; //read the bytes for papx - unsigned char* papx = new unsigned char[cw]; - memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), cw ); + unsigned char* papx = new unsigned char[sz]; + memcpy( papx, ( bytes + (bx.wordOffset * 2) + padbyte + 1 ), sz ); //parse PAPX and fill grppapx - grppapx[i] = new ParagraphPropertyExceptions( papx, cw, dataStream, nWordVersion ); + grppapx[i] = new ParagraphPropertyExceptions( papx, sz, dataStream, nWordVersion ); RELEASEARRAYOBJECTS( papx ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp index 9d6fac4c2f..327ae90286 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.cpp @@ -473,7 +473,10 @@ namespace DocFileFormat return AddPart( mapping, L"word", fileName, VMLPictureMapping::GetContentType( blipType ), OpenXmlRelationshipTypes::Image ); } - + int OpenXmlPackage::RegisterHyperlink(const IMapping* mapping, const std::wstring& link) + { + return AddPart(mapping, L"", link, L"", OpenXmlRelationshipTypes::Hyperlink, L"External"); + } int OpenXmlPackage::RegisterOLEObject(const IMapping* mapping, const std::wstring& objectType) { std::wstring fileName = ( std::wstring( L"embeddings/oleObject" ) + FormatUtils::IntToWideString( ++_oleCounter ) + OleObjectMapping::GetTargetExt(objectType)); diff --git a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h index f9a63601e1..0a9c8d5bc8 100644 --- a/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h +++ b/ASCOfficeDocFile/DocDocxConverter/OpenXmlPackage.h @@ -177,6 +177,7 @@ namespace DocFileFormat int RegisterEndnotes(); int RegisterComments(); int RegisterImage ( const IMapping* mapping, Global::BlipType blipType ); + int RegisterHyperlink ( const IMapping* mapping, const std::wstring& link); int RegisterOLEObject ( const IMapping* mapping, const std::wstring& objectType ); int RegisterPackage ( const IMapping* mapping, const std::wstring& objectType); int RegisterExternalOLEObject( const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri ); diff --git a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp index 7da9e6385b..474bb13e3d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/PropertyExceptions.cpp @@ -60,7 +60,7 @@ namespace DocFileFormat } void PropertyExceptions::ReadExceptions(unsigned char* bytes, int size, int nWordVersion) { - RELEASEOBJECT( grpprl ); + RELEASEOBJECT( grpprl ); grpprl = new std::list(); diff --git a/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h b/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h index e206972f86..2379b79097 100644 --- a/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h +++ b/ASCOfficeDocFile/DocDocxConverter/SprmTDefTable.h @@ -177,8 +177,6 @@ namespace DocFileFormat } } - private: - unsigned char numberOfColumns; /// An array of 16-bit signed integer that specifies horizontal distance in twips. diff --git a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp index 5b27957aef..64c4df88f9 100644 --- a/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/StyleSheetMapping.cpp @@ -171,7 +171,7 @@ namespace DocFileFormat if ( (*iter)->tapx != NULL ) { std::vector tableGrid; - TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, NULL, false); + TablePropertiesMapping* tpMapping = new TablePropertiesMapping (m_pXmlWriter, sheet, &tableGrid, false); (*iter)->tapx->Convert( tpMapping ); RELEASEOBJECT( tpMapping ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp index b9abf48b5b..f469b53e22 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.cpp @@ -35,7 +35,7 @@ namespace DocFileFormat { - TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector* grid, const std::vector* grid_write, int gridIndex, int cellIndex) : + TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector* grid, int gridIndex, int cellIndex) : PropertiesMapping(pWriter) { _width = 0; @@ -141,6 +141,10 @@ namespace DocFileFormat } break; + case sprmTDxaCol: + { + }break; + case sprmTCellPadding: { unsigned char first = iter->Arguments[0]; diff --git a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h index f7be60834c..6a36377f60 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/TableCellPropertiesMapping.h @@ -58,7 +58,7 @@ namespace DocFileFormat public: virtual ~TableCellPropertiesMapping(); - TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector* grid, const std::vector* grid_write, int gridIndex, int cellIndex); + TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector* grid, int gridIndex, int cellIndex); virtual void Apply( IVisitable* visited ); inline int GetGridSpan() const @@ -91,6 +91,6 @@ namespace DocFileFormat BorderCode* _brcRight; BorderCode* _brcBottom; - int _gridSpan; + int _gridSpan; }; } diff --git a/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp index 9ab306615a..80d619b135 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TableMapping.cpp @@ -106,7 +106,7 @@ namespace DocFileFormat cellElements.clear(); } - void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, const std::vector* grid_write, int& gridIndex, int nCellIndex) + void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, int& gridIndex, int nCellIndex) { if (NULL != mapping) { @@ -123,7 +123,7 @@ namespace DocFileFormat documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" ); //convert the properties - TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, grid_write, gridIndex, nCellIndex); + TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex); if ( tapx != NULL ) { @@ -193,7 +193,7 @@ namespace DocFileFormat cells.clear(); } - void TableRow::Convert(IMapping* mapping, const std::vector* grid, const std::vector* grid_write) + void TableRow::Convert(IMapping* mapping, const std::vector* grid) { if ( mapping != NULL ) { @@ -234,7 +234,7 @@ namespace DocFileFormat { for ( std::list::iterator iter = cells.begin(); iter != cells.end(); iter++ ) { - iter->Convert( mapping, &tapx, grid, grid_write, gridIndex, nCellIndex++); + iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++); } } @@ -516,8 +516,8 @@ namespace DocFileFormat SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx; //build the table grid - std::vector grid, grid_write; - documentMapping->buildTableGrid( cpStart, depth, grid, grid_write ); + std::vector grid; + documentMapping->buildTableGrid( cpStart, depth, grid); //find first row end int fcRowEnd = documentMapping->findRowEndFc( cpStart, depth ); @@ -530,7 +530,7 @@ namespace DocFileFormat documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" ); //Convert it - TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid, &grid_write ); + TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid); row1Tapx.Convert( &tpMapping ); @@ -539,7 +539,7 @@ namespace DocFileFormat for ( std::list::iterator iter = rows.begin(); iter != rows.end(); iter++ ) { - iter->Convert( mapping, &grid, &grid_write ); + iter->Convert( mapping, &grid ); } //close w:tbl diff --git a/ASCOfficeDocFile/DocDocxConverter/TableMapping.h b/ASCOfficeDocFile/DocDocxConverter/TableMapping.h index 9cd2b1ed81..839dc8ea3e 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TableMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/TableMapping.h @@ -58,7 +58,7 @@ namespace DocFileFormat void AddItem( const ITableCellElement& _tableCellElement ); bool IsEmpty() const; void Clear(); - void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, const std::vector* grid_write, int& gridIndex, int cellIndex ); + void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector* grid, int& gridIndex, int cellIndex ); ~TableCell(); private: @@ -81,7 +81,7 @@ namespace DocFileFormat void AddCell( const TableCell& _tableCell ); bool IsEmpty() const; void Clear(); - void Convert( IMapping* mapping, const std::vector* grid, const std::vector* grid_write ); + void Convert( IMapping* mapping, const std::vector* grid); ~TableRow(); private: diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp index ab0c7e2f67..15f5e27c12 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.cpp @@ -34,8 +34,8 @@ namespace DocFileFormat { - TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector* grid, std::vector* grid_write, bool isTableStyleNeeded ): - PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), _grid_write(grid_write), + TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector* grid, bool isTableStyleNeeded ): + PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(styles), _isTableStyleNeeded(isTableStyleNeeded) { @@ -511,7 +511,7 @@ namespace DocFileFormat bWriteGridCol = true; else { - for ( size_t i = 0, nSize = _grid_write->size(); i < nSize; i++ ) + for ( size_t i = 0, nSize = _grid->size(); i < nSize; i++ ) { if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0) { @@ -522,10 +522,10 @@ namespace DocFileFormat } if(true == bWriteGridCol) { - for ( size_t i = 0; i < _grid_write->size(); i++ ) + for ( size_t i = 0; i < _grid->size(); i++ ) { XMLTools::XMLElement gridCol( L"w:gridCol"); - XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid_write->at( i ) ) ); + XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid->at( i ) ) ); gridCol.AppendAttribute( gridColW ); _tblGrid->AppendChild( gridCol ); } diff --git a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h index 570746bd3b..a9bf3edfce 100644 --- a/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/TablePropertiesMapping.h @@ -71,7 +71,7 @@ namespace DocFileFormat class TablePropertiesMapping: public PropertiesMapping, public IMapping { public: - TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector* grid, std::vector* grid_write, bool isTableStyleNeeded = true ); + TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector* grid, bool isTableStyleNeeded = true ); virtual ~TablePropertiesMapping(); void Apply( IVisitable* visited ); @@ -83,7 +83,6 @@ namespace DocFileFormat StyleSheet* _styles; std::vector* _grid; - std::vector* _grid_write; BorderCode* brcLeft; BorderCode* brcTop; diff --git a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h index 9d51fb0cff..d13d2f54b3 100644 --- a/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h +++ b/ASCOfficeDocFile/DocDocxConverter/WordprocessingDocument.h @@ -39,6 +39,7 @@ namespace DocFileFormat { friend class Converter; friend class MainDocumentMapping; + friend class DocumentMapping; friend class CommandTableMapping; friend class StyleSheetMapping; friend class NumberingMapping;