mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Compare commits
163 Commits
v5.0.99.10
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| 2206b3b366 | |||
| a2d37e8a22 | |||
| b13eba5f01 | |||
| a48058c7d5 | |||
| ab76aff379 | |||
| b8b8a14268 | |||
| e5ef749718 | |||
| 5d524369b8 | |||
| e78fc0befc | |||
| d9986d09cd | |||
| bd67f4bf1c | |||
| 475bfaf93d | |||
| 1a8af4d8ed | |||
| cdf8dc7a4c | |||
| d71552bddd | |||
| 548c5ab608 | |||
| 6a01384023 | |||
| d70f36e36d | |||
| f65984f079 | |||
| 5b48a7a330 | |||
| 1496aece57 | |||
| 60cf51ad0d | |||
| 8e7231b322 | |||
| 2b339b6842 | |||
| fb0dbfc231 | |||
| 756613e883 | |||
| ede03fafea | |||
| bdec91bfd5 | |||
| 260c2edd21 | |||
| 3eeec8fc67 | |||
| ba6c7e8151 | |||
| 41a213491e | |||
| b599a6bc43 | |||
| a0fd139027 | |||
| 48852bc618 | |||
| 20b781cb7e | |||
| 704b3b709f | |||
| e4674915c2 | |||
| 51fe936e5f | |||
| d8b177411f | |||
| 717b628055 | |||
| e4f94646b6 | |||
| dcec7447e4 | |||
| 5f12552f78 | |||
| d293769c1f | |||
| b45e772a50 | |||
| fdb7716abc | |||
| f72d6dfe0e | |||
| 23029a6a92 | |||
| eda8e4d13f | |||
| 64f578e59f | |||
| 16c57b50cc | |||
| 83c0ba9dab | |||
| a2443dadeb | |||
| 789bb1d4b3 | |||
| 4138ae5ce2 | |||
| 239b5dbf11 | |||
| c046776b9c | |||
| 055a02570b | |||
| e7bbbec0de | |||
| 1e2e5996f3 | |||
| 875717acd4 | |||
| 033feeaf9d | |||
| de336e5f96 | |||
| 82b3dbdae6 | |||
| d1227f7759 | |||
| 4d134387f9 | |||
| 3f8600dfb7 | |||
| 511f043d63 | |||
| 69a41343c2 | |||
| 578327bab6 | |||
| 52908908a5 | |||
| 24d9b99a44 | |||
| dce58b628f | |||
| f42cb4580c | |||
| 52777e36cb | |||
| 7b7e9f3e6e | |||
| d39fa156e7 | |||
| 48bf40919c | |||
| fd53a987be | |||
| b4d298542a | |||
| bae854027b | |||
| 9723c379dd | |||
| e8d8b2e56c | |||
| adb84b0f05 | |||
| a4ee30d031 | |||
| e05194b277 | |||
| 21f7f6ed5b | |||
| 80863ae25b | |||
| 07562a9582 | |||
| 6da196e426 | |||
| d220cc8c79 | |||
| f53c3d9f50 | |||
| fa98f22e3d | |||
| e01c09bcc9 | |||
| 069544bf6c | |||
| b0f0f656af | |||
| 99191e65b0 | |||
| fb41720817 | |||
| 406c290be4 | |||
| 5ae4d7f819 | |||
| e69c1677b2 | |||
| 4d836c180a | |||
| e08b6542d4 | |||
| e1340c63ec | |||
| 4b122c0b94 | |||
| 867438833b | |||
| 8b80aa94b7 | |||
| f960fc60bb | |||
| 64213746b0 | |||
| 09941c67ac | |||
| c2605bb582 | |||
| ab2703c825 | |||
| 08ce8cb3f5 | |||
| 5efe043ab3 | |||
| f2af1ccd36 | |||
| 113d5b4ca3 | |||
| d3461dd3cb | |||
| e95a0fb765 | |||
| c5ce1e27e4 | |||
| 7ecc7fa1df | |||
| c46cd9e6e5 | |||
| e299e59d11 | |||
| 1e0f4d6fdb | |||
| 4dae8f50fa | |||
| 9cc5ed1db0 | |||
| 6d1dd9c420 | |||
| a038e1562f | |||
| 549e3dc579 | |||
| 8440b18223 | |||
| 9c7a03fdc5 | |||
| 9272b27a69 | |||
| ef57330a79 | |||
| d35619eeae | |||
| b38c552cc5 | |||
| 1b91ee579c | |||
| 337c92e522 | |||
| 8fe1eb7525 | |||
| 1deb2a6905 | |||
| 470eddf2b1 | |||
| 69a787411c | |||
| 22f986295f | |||
| 86d2bde83b | |||
| 07041d60f6 | |||
| a5466ab740 | |||
| dfd54ff53f | |||
| 6ec7d77e19 | |||
| 3813be21c7 | |||
| 356ccba104 | |||
| 68c8c0cb29 | |||
| 3044d1122a | |||
| fb00ba7ecb | |||
| ab0c5703a5 | |||
| e22b63347f | |||
| 9dd115ec56 | |||
| 438ba3aded | |||
| 29b002ca80 | |||
| 34083d996b | |||
| 244d549cf8 | |||
| ef96571879 | |||
| 7a27150de6 | |||
| 2197fddb7b | |||
| d31344d7d3 |
@ -501,7 +501,7 @@ namespace DocFileFormat
|
||||
|
||||
facet.widen((char*)bytes, (char*)bytes + size, &result[0]);
|
||||
|
||||
for (long i=0; i < result.length(); i++)
|
||||
for (size_t i=0; i < result.length(); i++)
|
||||
{
|
||||
STLCollection->push_back(result[i]);
|
||||
}
|
||||
@ -536,7 +536,7 @@ namespace DocFileFormat
|
||||
delete [] pStrUtf16;
|
||||
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
|
||||
}
|
||||
for (long i=0; i < nLength; i++)
|
||||
for (unsigned int i = 0; i < nLength; i++)
|
||||
{
|
||||
STLCollection->push_back(pStrUtf16[i]);
|
||||
}
|
||||
@ -566,7 +566,7 @@ namespace DocFileFormat
|
||||
delete [] pStrUtf32;
|
||||
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
|
||||
}
|
||||
for (long i=0; i < nLength; i++)
|
||||
for (unsigned int i = 0; i < nLength; i++)
|
||||
{
|
||||
STLCollection->push_back(pStrUtf32[i]);
|
||||
}
|
||||
@ -652,7 +652,7 @@ namespace DocFileFormat
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, size, sCodePage.c_str());
|
||||
|
||||
for (long i=0; i < unicode_string.size(); i++)
|
||||
for (size_t i = 0; i < unicode_string.size(); i++)
|
||||
{
|
||||
STLCollection->push_back(unicode_string[i]);
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ namespace XMLTools
|
||||
else
|
||||
{
|
||||
std::string s(m_str.begin(), m_str.end());
|
||||
file.WriteFile((unsigned char*)s.c_str(), s.length());
|
||||
file.WriteFile((unsigned char*)s.c_str(), (DWORD)s.length());
|
||||
}
|
||||
file.CloseFile();
|
||||
return true;
|
||||
|
||||
@ -321,7 +321,7 @@ namespace DocFileFormat
|
||||
|
||||
case sprmCFtcBi :
|
||||
{//default from FontTable
|
||||
SHORT nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
|
||||
size_t nIndex = FormatUtils::BytesToUInt16 (iter->Arguments, 0, iter->argumentsSize);
|
||||
if( nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
FontFamilyName* ffn = static_cast<FontFamilyName*>( _doc->FontTable->operator [] ( nIndex ) );
|
||||
@ -373,7 +373,7 @@ namespace DocFileFormat
|
||||
case sprmOldCFtc:
|
||||
case sprmCRgFtc0:
|
||||
{ // font family
|
||||
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
if( nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
@ -388,7 +388,8 @@ namespace DocFileFormat
|
||||
|
||||
case sprmCRgFtc1:
|
||||
{
|
||||
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
if( nIndex >= 0 && nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
XMLTools::XMLAttribute* eastAsia = new XMLTools::XMLAttribute( L"w:eastAsia" );
|
||||
@ -403,7 +404,8 @@ namespace DocFileFormat
|
||||
|
||||
case sprmCRgFtc2:
|
||||
{
|
||||
int nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t nIndex = FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
if( nIndex>=0 && nIndex < _doc->FontTable->Data.size() )
|
||||
{
|
||||
XMLTools::XMLAttribute* ansi = new XMLTools::XMLAttribute( L"w:hAnsi" );
|
||||
|
||||
@ -88,7 +88,7 @@ namespace DocFileFormat
|
||||
int DocumentMapping::getCurrentSection(int cp)
|
||||
{
|
||||
//if cp is the last char of a section, the next section will start at cp +1
|
||||
int current = 0;
|
||||
size_t current = 0;
|
||||
|
||||
for (std::vector<int>::iterator iter = m_document->SectionPlex->CharacterPositions.begin() + 1; iter != m_document->SectionPlex->CharacterPositions.end(); ++iter)
|
||||
{
|
||||
@ -107,7 +107,7 @@ namespace DocFileFormat
|
||||
{
|
||||
if ( !m_document->ListPlex ) return -1;
|
||||
|
||||
for (int i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
|
||||
for (size_t i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
|
||||
{
|
||||
if ((fc >= m_document->ListPlex->CharacterPositions[i-1]) && (fc_end <= m_document->ListPlex->CharacterPositions[i]))
|
||||
{
|
||||
@ -382,7 +382,7 @@ namespace DocFileFormat
|
||||
int DocumentMapping::writeRun (std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp)
|
||||
{
|
||||
int cp = initialCp;
|
||||
int result_cp = cp + chars->size();
|
||||
int result_cp = cp + (int)chars->size();
|
||||
|
||||
if ((_skipRuns <= 0) && (chars->size() > 0))
|
||||
{
|
||||
@ -559,12 +559,12 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteString(elem.GetXMLString());
|
||||
}
|
||||
else if (TextMark::FieldBeginMark == code)
|
||||
{
|
||||
{//todooo в отдельный mapping
|
||||
int cpFieldStart = initialCp + i;
|
||||
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
|
||||
|
||||
std::wstring f;
|
||||
if (cpFieldEnd < m_document->Text->size())
|
||||
if (cpFieldEnd < (int)m_document->Text->size())
|
||||
f = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
|
||||
|
||||
std::wstring EMBED ( L" EMBED" );
|
||||
@ -599,20 +599,38 @@ namespace DocFileFormat
|
||||
|
||||
if ( bFORM )
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
|
||||
std::wstring FORMTEXT ( L" FORMTEXT" );
|
||||
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
|
||||
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
|
||||
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
|
||||
m_pXmlWriter->WriteNodeEnd( L"", true, false );
|
||||
|
||||
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
|
||||
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
|
||||
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
|
||||
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
|
||||
|
||||
/*if (cpPic < cpFieldEnd)
|
||||
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
|
||||
{
|
||||
int fcPic = _doc.PieceTable.FileCharacterPositions[cpPic];
|
||||
CharacterPropertyExceptions chpxPic = _doc.GetCharacterPropertyExceptions(fcPic, fcPic + 1)[0];
|
||||
NilPicfAndBinData npbd = new NilPicfAndBinData(chpxPic, _doc.DataStream);
|
||||
FormFieldData ffdata = new FormFieldData(npbd.binData);
|
||||
ffdata.Convert(new FormFieldDataMapping(m_pXmlWriter));
|
||||
}*/
|
||||
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
|
||||
if (cpPic < cpFieldEnd)
|
||||
{
|
||||
int fcPic = m_document->FindFileCharPos( cpPic );
|
||||
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
|
||||
|
||||
if (chpxs)
|
||||
{
|
||||
CharacterPropertyExceptions* chpxSep = chpxs->front();
|
||||
|
||||
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
|
||||
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
|
||||
ffdata.Convert(&data_mapping);
|
||||
|
||||
RELEASEOBJECT( chpxs );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
|
||||
|
||||
@ -660,11 +678,11 @@ namespace DocFileFormat
|
||||
|
||||
if (search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end())
|
||||
{
|
||||
int d = f1.find(PAGEREF);
|
||||
int d = (int)f1.find(PAGEREF);
|
||||
|
||||
_writeWebHidden = true;
|
||||
std::wstring _writeTocLink =f1.substr(d + 9);
|
||||
d = _writeTocLink.find(L" ");
|
||||
d = (int)_writeTocLink.find(L" ");
|
||||
_writeTocLink = _writeTocLink.substr(0, d);
|
||||
|
||||
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
|
||||
@ -809,6 +827,13 @@ namespace DocFileFormat
|
||||
{
|
||||
if (_fldCharCounter > 0)
|
||||
{
|
||||
if (_writeInstrText == true && !text.empty())
|
||||
{
|
||||
writeTextElement(text, textType);
|
||||
text.clear();
|
||||
}
|
||||
_writeInstrText = false;
|
||||
|
||||
XMLTools::XMLElement elem( L"w:fldChar" );
|
||||
elem.AppendAttribute( L"w:fldCharType", L"end" );
|
||||
|
||||
@ -1176,7 +1201,8 @@ namespace DocFileFormat
|
||||
TableInfo tai( papx );
|
||||
|
||||
//build the table grid
|
||||
std::vector<short>* grid = buildTableGrid( cp, nestingLevel );
|
||||
std::vector<short> grid, grid_write;
|
||||
buildTableGrid( cp, nestingLevel, grid, grid_write );
|
||||
|
||||
//find first row end
|
||||
int fcRowEnd = findRowEndFc( cp, nestingLevel );
|
||||
@ -1187,7 +1213,7 @@ namespace DocFileFormat
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:tbl" );
|
||||
|
||||
//Convert it
|
||||
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, grid );
|
||||
TablePropertiesMapping *tpMapping = new TablePropertiesMapping( m_pXmlWriter, m_document->Styles, &grid, &grid_write );
|
||||
|
||||
row1Tapx.Convert( tpMapping );
|
||||
|
||||
@ -1200,7 +1226,7 @@ namespace DocFileFormat
|
||||
//only convert the cells with the given nesting level
|
||||
while ( tai.iTap == nestingLevel )
|
||||
{
|
||||
cp = writeTableRow( cp, grid, nestingLevel );
|
||||
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
|
||||
//?fc = m_document->FindFileCharPos(cp );
|
||||
fc = m_document->m_PieceTable->FileCharacterPositions->operator []( cp );
|
||||
papx = findValidPapx( fc );
|
||||
@ -1213,7 +1239,7 @@ namespace DocFileFormat
|
||||
//convert until the end of table is reached
|
||||
while ( tai.fInTable )
|
||||
{
|
||||
cp = writeTableRow( cp, grid, nestingLevel );
|
||||
cp = writeTableRow( cp, &grid, &grid_write, nestingLevel );
|
||||
fc = m_document->FindFileCharPos( cp );
|
||||
|
||||
papx = findValidPapx( fc );
|
||||
@ -1224,18 +1250,16 @@ namespace DocFileFormat
|
||||
//close w:tbl
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:tbl" );
|
||||
|
||||
RELEASEOBJECT( grid );
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
// Builds a list that contains the width of the several columns of the table.
|
||||
std::vector<short>* DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel)
|
||||
bool DocumentMapping::buildTableGrid(int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write)
|
||||
{
|
||||
ParagraphPropertyExceptions* backup = _lastValidPapx;
|
||||
|
||||
std::vector<short> boundaries;
|
||||
std::vector<short>* grid = new std::vector<short>();
|
||||
std::vector<short> boundaries_all;
|
||||
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos( cp );
|
||||
@ -1252,25 +1276,43 @@ namespace DocFileFormat
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = papx->grpprl->begin(); iter != papx->grpprl->end(); iter++ )
|
||||
{
|
||||
//find the tDef SPRM
|
||||
if ( iter->OpCode == sprmTDefTable || iter->OpCode == sprmOldTDefTable)
|
||||
DWORD code = iter->OpCode;
|
||||
|
||||
switch(iter->OpCode)
|
||||
{
|
||||
case sprmTDefTable:
|
||||
case sprmOldTDefTable:
|
||||
{
|
||||
unsigned char itcMac = iter->Arguments[0];
|
||||
|
||||
for (int i = 0; i < itcMac; i++)
|
||||
while(boundaries.size() < itcMac + 1)
|
||||
boundaries.push_back(-0x7fff);
|
||||
|
||||
short boundary0 = -0x7fff;
|
||||
for (unsigned char i = 0; i < itcMac; i++)
|
||||
{
|
||||
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
|
||||
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
|
||||
|
||||
if ( find( boundaries.begin(), boundaries.end(), boundary1 ) == boundaries.end() )
|
||||
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
|
||||
{
|
||||
boundaries.push_back( boundary1 );
|
||||
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 );
|
||||
}
|
||||
|
||||
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
|
||||
|
||||
if ( find( boundaries.begin(), boundaries.end(), boundary2 ) == boundaries.end() )
|
||||
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
|
||||
{
|
||||
boundaries.push_back( boundary2 );
|
||||
boundaries_all.push_back( boundary2 );
|
||||
}
|
||||
boundary0 = boundary1;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1286,19 +1328,25 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
//build the grid based on the boundaries
|
||||
sort( boundaries.begin(), boundaries.end() );
|
||||
sort( boundaries_all.begin(), boundaries_all.end() );
|
||||
|
||||
if ( !boundaries.empty() )
|
||||
{
|
||||
for ( unsigned int i = 0; i < ( boundaries.size() - 1 ); i++ )
|
||||
for ( size_t i = 0; i < ( boundaries.size() - 1 ); i++ )
|
||||
{
|
||||
grid->push_back( boundaries[i + 1] - boundaries[i] );
|
||||
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] );
|
||||
}
|
||||
}
|
||||
|
||||
_lastValidPapx = backup;
|
||||
|
||||
return grid;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Finds the FC of the next row end mark.
|
||||
@ -1418,7 +1466,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<short>* grid, unsigned int nestingLevel)
|
||||
int DocumentMapping::writeTableRow(int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, unsigned int nestingLevel)
|
||||
{
|
||||
int cp = initialCp;
|
||||
int fc = m_document->FindFileCharPos( cp );
|
||||
@ -1448,7 +1496,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, gridIndex, cellIndex, nestingLevel );
|
||||
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
|
||||
cellIndex++;
|
||||
|
||||
//each cell has it's own PAPX
|
||||
@ -1465,7 +1513,7 @@ namespace DocFileFormat
|
||||
while ( !( ( m_document->Text->at( cp ) == TextMark::CellOrRowMark ) && ( tai.fTtp ) )
|
||||
&& tai.fInTable )
|
||||
{
|
||||
cp = writeTableCell( cp, &tapx, grid, gridIndex, cellIndex, nestingLevel );
|
||||
cp = writeTableCell( cp, &tapx, grid, grid_write, gridIndex, cellIndex, nestingLevel );
|
||||
cellIndex++;
|
||||
|
||||
//each cell has it's own PAPX
|
||||
@ -1488,18 +1536,15 @@ 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<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel )
|
||||
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
|
||||
{
|
||||
int cp = initialCp;
|
||||
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
|
||||
|
||||
//start w:tc
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//find cell end
|
||||
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, gridIndex, cellIndex );
|
||||
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
|
||||
|
||||
if ( tapx != NULL )
|
||||
{
|
||||
|
||||
@ -48,6 +48,8 @@
|
||||
#include "OleObjectMapping.h"
|
||||
#include "ConversionContext.h"
|
||||
#include "IMapping.h"
|
||||
#include "FormFieldData.h"
|
||||
#include "FormFieldDataMapping.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
@ -108,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.
|
||||
std::vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
|
||||
bool buildTableGrid( int initialCp, unsigned int nestingLevel, std::vector<short>& grid, std::vector<short>& grid_write );
|
||||
// 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<short>* grid, unsigned int nestingLevel );
|
||||
int writeTableRow ( int initialCp, std::vector<short>* grid, std::vector<short>* grid_write, 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<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
|
||||
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel );
|
||||
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
|
||||
|
||||
bool writeBookmarks ( int cp );
|
||||
|
||||
170
ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp
Normal file
170
ASCOfficeDocFile/DocDocxConverter/FormFieldData.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "FormFieldData.h"
|
||||
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
std::wstring readXstz(VirtualStreamReader *reader)
|
||||
{
|
||||
if (!reader) return L"";
|
||||
|
||||
unsigned short flags, cch, chTerm;
|
||||
|
||||
cch = reader->ReadUInt16();
|
||||
|
||||
std::wstring ret;
|
||||
|
||||
if (cch > 0)
|
||||
{
|
||||
std::shared_ptr<unsigned char>data = std::shared_ptr<unsigned char>(reader->ReadBytes(cch * 2, true));
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
ret = std::wstring((wchar_t*)data.get(), cch );
|
||||
#else
|
||||
ret = convertUtf16ToWString((UTF16*)data.get(), cch );
|
||||
#endif
|
||||
}
|
||||
chTerm = reader->ReadUInt16();
|
||||
|
||||
return ret;
|
||||
};
|
||||
void FormFieldData::_HFD::read(VirtualStreamReader *reader)
|
||||
{
|
||||
if (!reader) return;
|
||||
}
|
||||
void FormFieldData::_FFData::read(VirtualStreamReader *reader)
|
||||
{
|
||||
if (!reader) return;
|
||||
|
||||
bExist = true;
|
||||
|
||||
unsigned short flags;
|
||||
|
||||
version = reader->ReadUInt32();
|
||||
flags = reader->ReadUInt16();
|
||||
|
||||
iType = GETBITS(flags, 0, 1);
|
||||
iRes = GETBITS(flags, 2, 6);
|
||||
fOwnHelp = GETBIT(flags, 7);
|
||||
fOwnStat = GETBIT(flags, 8);
|
||||
fProt = GETBIT(flags, 9);
|
||||
iSize = GETBIT(flags, 10);
|
||||
iTypeTxt = GETBITS(flags, 11, 13);
|
||||
fRecalc = GETBIT(flags, 14);
|
||||
fHasListBox = GETBIT(flags, 15);
|
||||
|
||||
cch_field = reader->ReadUInt16();
|
||||
hps = reader->ReadUInt16();
|
||||
|
||||
xstzName = readXstz(reader);
|
||||
xstzTextDef = readXstz(reader);
|
||||
|
||||
wDef = reader->ReadUInt16();
|
||||
|
||||
xstzTextFormat = readXstz(reader);
|
||||
xstzHelpText = readXstz(reader);
|
||||
xstzStatText = readXstz(reader);
|
||||
xstzEntryMcr = readXstz(reader);
|
||||
xstzExitMcr = readXstz(reader);
|
||||
}
|
||||
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion_ )
|
||||
{
|
||||
binary_data_size = 0;
|
||||
|
||||
if (!chpx) return;
|
||||
|
||||
int fc = -1;
|
||||
bool bNilPICFAndBinData = false;
|
||||
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
|
||||
{
|
||||
switch ( iter->OpCode)
|
||||
{
|
||||
case sprmCFSpec:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case sprmCFFldVanish:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case sprmCPicLocation:
|
||||
{
|
||||
fc = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
|
||||
}
|
||||
break;
|
||||
case sprmCRsidText:
|
||||
{
|
||||
rsid = FormatUtils::IntToFormattedWideString(FormatUtils::BytesToInt32(iter->Arguments, 0, iter->argumentsSize), L"%08x");
|
||||
}
|
||||
break;
|
||||
case sprmCFData:
|
||||
{
|
||||
bNilPICFAndBinData = true; // or bPICFAndOfficeArtData - shape, pic, ole
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fc >= 0 && bNilPICFAndBinData)
|
||||
{
|
||||
VirtualStreamReader reader(stream, fc, bOlderVersion_);
|
||||
|
||||
int sz_stream = reader.GetSize();
|
||||
|
||||
int lcb = reader.ReadUInt32();
|
||||
int cbHeader = reader.ReadUInt16();
|
||||
|
||||
if (cbHeader != 0x44) return;
|
||||
|
||||
//ignored
|
||||
reader.ReadBytes(62, false);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 1:
|
||||
HFD.read(&reader);
|
||||
case 2:
|
||||
FFData.read(&reader);
|
||||
break;
|
||||
default:
|
||||
binary_data_size = lcb - cbHeader;
|
||||
binary_data = std::shared_ptr<unsigned char>(reader.ReadBytes(binary_data_size, true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
126
ASCOfficeDocFile/DocDocxConverter/FormFieldData.h
Normal file
126
ASCOfficeDocFile/DocDocxConverter/FormFieldData.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "IVisitable.h"
|
||||
#include "CharacterPropertyExceptions.h"
|
||||
#include "StructuredStorageReader.h"
|
||||
#include "VirtualStreamReader.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
class FormFieldData : public IVisitable
|
||||
{
|
||||
public:
|
||||
|
||||
struct _HFD
|
||||
{
|
||||
bool bExist = false;
|
||||
|
||||
bool fNew = false;
|
||||
bool fNoHist = false;
|
||||
bool fImageMap = false;
|
||||
bool fLocation = false;
|
||||
bool fTooltip = false;
|
||||
|
||||
std::wstring clsid;
|
||||
|
||||
_UINT32 streamVersion = 0;
|
||||
bool hlstmfHasMoniker = false;
|
||||
bool hlstmfIsAbsolute = false;
|
||||
bool hlstmfSiteGaveDisplayName = false;
|
||||
bool hlstmfHasLocationStr = false;
|
||||
bool hlstmfHasDisplayName = false;
|
||||
bool hlstmfHasGUID = false;
|
||||
bool hlstmfHasCreationTime = false;
|
||||
bool hlstmfHasFrameName = false;
|
||||
bool hlstmfMonikerSavedAsStr = false;
|
||||
bool hlstmfAbsFromGetdataRel = false;
|
||||
|
||||
std::wstring displayName;
|
||||
std::wstring targetFrameName;
|
||||
std::wstring moniker;
|
||||
|
||||
std::wstring oleMoniker_clsid;
|
||||
std::wstring oleMoniker_data;
|
||||
std::wstring location;
|
||||
|
||||
std::wstring guid;
|
||||
_UINT64 fileTime = 0;
|
||||
|
||||
void read(VirtualStreamReader* reader);
|
||||
};
|
||||
struct _FFData
|
||||
{
|
||||
bool bExist = false;
|
||||
_UINT32 version = 0;
|
||||
|
||||
unsigned char iType = 0;
|
||||
unsigned char iRes = 0;
|
||||
bool fOwnHelp = false;
|
||||
bool fOwnStat = false;
|
||||
bool fProt = false;
|
||||
bool iSize = false;
|
||||
unsigned char iTypeTxt = 0;
|
||||
bool fRecalc = false;
|
||||
bool fHasListBox = false;
|
||||
|
||||
unsigned short cch_field = 0;
|
||||
unsigned short hps = 0;
|
||||
std::wstring xstzName;
|
||||
std::wstring xstzTextDef;
|
||||
unsigned short wDef = 0;
|
||||
std::wstring xstzTextFormat;
|
||||
std::wstring xstzHelpText;
|
||||
std::wstring xstzStatText;
|
||||
std::wstring xstzEntryMcr;
|
||||
std::wstring xstzExitMcr;
|
||||
|
||||
//STTB hsttbDropList;
|
||||
void read(VirtualStreamReader* reader);
|
||||
};
|
||||
FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion );
|
||||
virtual ~FormFieldData() {}
|
||||
private:
|
||||
friend class FormFieldDataMapping;
|
||||
|
||||
std::wstring name;
|
||||
std::wstring rsid;
|
||||
|
||||
_FFData FFData;
|
||||
_HFD HFD;
|
||||
|
||||
std::shared_ptr<unsigned char> binary_data;
|
||||
int binary_data_size;
|
||||
|
||||
};
|
||||
}
|
||||
87
ASCOfficeDocFile/DocDocxConverter/FormFieldDataMapping.h
Normal file
87
ASCOfficeDocFile/DocDocxConverter/FormFieldDataMapping.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ConversionContext.h"
|
||||
#include "FormFieldData.h"
|
||||
|
||||
#include "AbstractOpenXmlMapping.h"
|
||||
#include "IMapping.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
class FormFieldDataMapping: public AbstractOpenXmlMapping, public IMapping
|
||||
{
|
||||
public:
|
||||
FormFieldDataMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, IMapping* caller)
|
||||
: AbstractOpenXmlMapping(writer), m_context(NULL),_caller(NULL)
|
||||
{
|
||||
m_context = context;
|
||||
_caller = caller;
|
||||
}
|
||||
|
||||
virtual void Apply(IVisitable* visited)
|
||||
{
|
||||
FormFieldData* ffData = static_cast<FormFieldData*>(visited);
|
||||
|
||||
if ( ffData == NULL ) return;
|
||||
|
||||
if (ffData->FFData.bExist)
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:ffData");
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:name", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.xstzName);
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:name", true, true );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:calcOnExit", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.fRecalc);
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:calcOnExit", true, true );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:textInput");
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:maxLength", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.cch_field);
|
||||
m_pXmlWriter->WriteNodeEnd(L"w:maxLength", true, true );
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:textInput" );
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:ffData" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
ConversionContext* m_context;
|
||||
IMapping* _caller;
|
||||
};
|
||||
}
|
||||
@ -33,6 +33,9 @@
|
||||
|
||||
#include "IMapping.h"
|
||||
|
||||
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
|
||||
#define GETBIT(from, num) ((from & (1 << num)) != 0)
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
class IVisitable
|
||||
|
||||
@ -582,7 +582,7 @@ namespace DocFileFormat
|
||||
// The style id is used for a reverse reference.
|
||||
// It can happen that the reference points to the wrong style.
|
||||
|
||||
if (styleIndex != ListData::ISTD_NIL)
|
||||
if (styleIndex != ListData::ISTD_NIL && styleIndex < m_document->Styles->Styles->size())
|
||||
{
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:pStyle", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId(m_document->Styles->Styles->at(styleIndex))));
|
||||
|
||||
@ -53,62 +53,31 @@ namespace DocFileFormat
|
||||
|
||||
PathParser (const unsigned char* pSegmentInfo, unsigned int pSegmentInfoSize, const unsigned char* pVertices, unsigned int pVerticesSize, std::vector<_guides> & guides)
|
||||
{
|
||||
int offset = 6;
|
||||
|
||||
if ((pSegmentInfo != NULL) && (pSegmentInfoSize > 0))
|
||||
{
|
||||
int offset = 6;
|
||||
|
||||
unsigned short nElems = FormatUtils::BytesToUInt16(pSegmentInfo, 0, pSegmentInfoSize);
|
||||
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pSegmentInfo, 2, pSegmentInfoSize);
|
||||
unsigned short cb = FormatUtils::BytesToUInt16(pSegmentInfo, 4, pSegmentInfoSize);
|
||||
|
||||
// видимо без шапки сразу пишутся все элементы
|
||||
bool headerIs = ((0xfff0 != cb) && (cb > 8) || nElems > nElemsAlloc);
|
||||
if (headerIs)
|
||||
{
|
||||
cb = 2;
|
||||
offset = 0;
|
||||
nElems = pSegmentInfoSize / 2;
|
||||
unsigned short cbElement = 4;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToUInt16(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (cb == 0xfff0)
|
||||
cbElement = 2;
|
||||
|
||||
if (nElems == 0)
|
||||
{
|
||||
if ((0xfff0 != cb) && (8 != cb) && (4 != cb) && (2 != cb))
|
||||
{
|
||||
cb = 0xfff0;
|
||||
offset = 0;
|
||||
nElems = pSegmentInfoSize / 2;
|
||||
}
|
||||
|
||||
if (0xfff0 == cb)
|
||||
{
|
||||
cb = 4;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToUInt16(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((2 != cb) && (1 != cb))
|
||||
cb = 8;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToInt32(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
|
||||
if ((long)pSegmentInfoSize < (long)(cb*nElems)) // Есть несколько файлов с мусором вместо данных
|
||||
m_arSegments.clear();
|
||||
}
|
||||
nElems = (pSegmentInfoSize - offset) / cbElement;
|
||||
}
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
PathSegment oSegment = PathSegment(FormatUtils::BytesToInt32(pSegmentInfo + offset, (i * cbElement), pSegmentInfoSize - offset));
|
||||
m_arSegments.push_back (oSegment);
|
||||
}
|
||||
|
||||
if ((long)pSegmentInfoSize < (long)(cb * nElems)) // Есть несколько файлов с мусором вместо данных
|
||||
m_arSegments.clear();
|
||||
}
|
||||
|
||||
if ((NULL != pVertices) && (pVerticesSize > 0))
|
||||
@ -117,19 +86,23 @@ namespace DocFileFormat
|
||||
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pVertices, 2, pVerticesSize);
|
||||
unsigned short cb = FormatUtils::BytesToUInt16(pVertices, 4, pVerticesSize);
|
||||
|
||||
unsigned short cbElement = cb;
|
||||
|
||||
if (cb == 0xfff0)
|
||||
cbElement = 4;
|
||||
|
||||
for (unsigned short i = 0; i < nElems; ++i)
|
||||
{
|
||||
POINT point;
|
||||
if (0xfff0 == cb)
|
||||
if (cbElement == 4)
|
||||
{
|
||||
cb = 4;
|
||||
point.x = FormatUtils::BytesToInt16(pVertices + 6, (i * cb), pVerticesSize);
|
||||
point.y = FormatUtils::BytesToInt16(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
|
||||
point.x = FormatUtils::BytesToInt16(pVertices + offset, (i * cbElement), pVerticesSize - offset);
|
||||
point.y = FormatUtils::BytesToInt16(pVertices + offset, (i * cbElement) + (cbElement / 2), pVerticesSize - offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
point.x = FormatUtils::BytesToInt32(pVertices + 6, (i * cb), pVerticesSize);
|
||||
point.y = FormatUtils::BytesToInt32(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
|
||||
point.x = FormatUtils::BytesToInt32(pVertices + offset, (i * cbElement), pVerticesSize - offset);
|
||||
point.y = FormatUtils::BytesToInt32(pVertices + offset, (i * cbElement) + (cbElement / 2), pVerticesSize - offset);
|
||||
}
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
|
||||
@ -597,16 +597,12 @@ namespace DocFileFormat
|
||||
|
||||
virtual ~ShapeOptions()
|
||||
{
|
||||
//for (std::vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
|
||||
// RELEASEARRAYOBJECTS( iter->opComplex );
|
||||
}
|
||||
|
||||
ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance)
|
||||
{
|
||||
long pos = Reader->GetPosition();
|
||||
|
||||
//instance is the count of properties stored in this record
|
||||
|
||||
//parse the flags and the simple values
|
||||
for (unsigned int i = 0; i < instance; ++i)
|
||||
{
|
||||
@ -621,9 +617,7 @@ namespace DocFileFormat
|
||||
Options.push_back( entry );
|
||||
}
|
||||
|
||||
//parse the complex values
|
||||
//these values are stored directly at the end
|
||||
//of the OptionEntry arry, sorted by pid
|
||||
//parse the complex values & sorted by pid
|
||||
for (unsigned int i = 0; i < instance; ++i)
|
||||
{
|
||||
if (Options[i]->fComplex && Options[i]->op > 0)
|
||||
|
||||
@ -46,35 +46,35 @@ OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorage
|
||||
|
||||
HRESULT res = S_OK;
|
||||
|
||||
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, "ObjectPool");
|
||||
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, L"ObjectPool");
|
||||
|
||||
if (ObjectPoolStorage)
|
||||
{
|
||||
ObjectId = getOleEntryName( chpx );
|
||||
|
||||
std::string sObjectId( ObjectId.begin(), ObjectId.end() );
|
||||
std::wstring sObjectId( ObjectId.begin(), ObjectId.end() );
|
||||
{
|
||||
std::string name = "ObjectPool/" + sObjectId + "/";
|
||||
processOleStream( name + "Ole" );
|
||||
std::wstring name = L"ObjectPool/" + sObjectId + L"/";
|
||||
processOleStream( name + L"Ole" );
|
||||
|
||||
if ( bLinked )
|
||||
{
|
||||
processLinkInfoStream( name + "LinkInfo" );
|
||||
processLinkInfoStream( name + L"LinkInfo" );
|
||||
}
|
||||
else
|
||||
{
|
||||
processCompObjStream( name + "CompObj" );
|
||||
processCompObjStream( name + L"CompObj" );
|
||||
}
|
||||
|
||||
processPICStream( name + "PIC" );
|
||||
processPICStream( name + L"PIC" );
|
||||
|
||||
processEquationNativeStream( name + "Equation Native" );
|
||||
processEquationNativeStream( name + L"Equation Native" );
|
||||
}
|
||||
delete ObjectPoolStorage;
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processLinkInfoStream( const std::string& linkStream )
|
||||
void OleObject::processLinkInfoStream( const std::wstring& linkStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -125,7 +125,7 @@ void OleObject::processLinkInfoStream( const std::string& linkStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processEquationNativeStream( const std::string& eqStream )
|
||||
void OleObject::processEquationNativeStream( const std::wstring& eqStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -156,7 +156,7 @@ void OleObject::processEquationNativeStream( const std::string& eqStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processPICStream( const std::string& picStream )
|
||||
void OleObject::processPICStream( const std::wstring& picStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -191,7 +191,7 @@ void OleObject::processPICStream( const std::string& picStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processCompObjStream( const std::string& compStream )
|
||||
void OleObject::processCompObjStream( const std::wstring& compStream )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -206,11 +206,11 @@ void OleObject::processCompObjStream( const std::string& compStream )
|
||||
//skip the CompObjHeader
|
||||
reader.ReadBytes( 28, false );
|
||||
|
||||
int sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
unsigned int sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
|
||||
if (sz_obj > 4)
|
||||
{
|
||||
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
|
||||
sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
if (sz_obj > 4)
|
||||
@ -218,7 +218,7 @@ void OleObject::processCompObjStream( const std::string& compStream )
|
||||
|
||||
sz_obj = reader.GetSize() - reader.GetPosition();
|
||||
if (sz_obj > 4)
|
||||
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
|
||||
}
|
||||
delete pCompStream;
|
||||
}
|
||||
@ -228,7 +228,7 @@ void OleObject::processCompObjStream( const std::string& compStream )
|
||||
}
|
||||
}
|
||||
|
||||
void OleObject::processOleStream( const std::string& oleStreamName )
|
||||
void OleObject::processOleStream( const std::wstring& oleStreamName )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -74,11 +74,11 @@ namespace DocFileFormat
|
||||
private:
|
||||
POLE::Storage *oleStorage;
|
||||
|
||||
void processLinkInfoStream ( const std::string& linkStream );
|
||||
void processEquationNativeStream( const std::string& eqStream );
|
||||
void processPICStream ( const std::string& picStream );
|
||||
void processCompObjStream ( const std::string& compStream );
|
||||
void processOleStream ( const std::string& oleStreamName );
|
||||
void 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 );
|
||||
|
||||
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
|
||||
};
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
#include "MainDocumentMapping.h"
|
||||
#include "OleObjectMapping.h"
|
||||
#include "VMLPictureMapping.h"
|
||||
#include "FormFieldDataMapping.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
@ -136,15 +137,17 @@ namespace DocFileFormat
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
file.CreateFileW(fileName);
|
||||
file.WriteFile((BYTE*)data.c_str(), data.size());
|
||||
file.WriteFile((BYTE*)data.c_str(), (_UINT32)data.size());
|
||||
file.CloseFile();
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT OpenXmlPackage::SaveOLEObject( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure )
|
||||
{
|
||||
if (docFile == NULL) return S_FALSE;
|
||||
|
||||
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
|
||||
if (storageOut == NULL) return S_FALSE;
|
||||
|
||||
if (storageOut == NULL || docFile == NULL) return S_FALSE;
|
||||
if (storageOut->open(true, true)==false)
|
||||
{
|
||||
delete storageOut;
|
||||
@ -154,20 +157,19 @@ namespace DocFileFormat
|
||||
POLE::Storage *storageInp = docFile->GetStorage()->GetStorage();
|
||||
|
||||
{
|
||||
std::string id(oleObjectFileStructure.objectID.begin(),oleObjectFileStructure.objectID.end());
|
||||
|
||||
POLE::Stream* oleStorage = new POLE::Stream(storageInp, id);
|
||||
POLE::Stream* oleStorage = new POLE::Stream(storageInp, oleObjectFileStructure.objectID);
|
||||
|
||||
if (oleStorage)
|
||||
{
|
||||
std::string path = "ObjectPool/" + id;
|
||||
std::list<std::string> entries = storageInp->entries(path);
|
||||
for (std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++)
|
||||
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
|
||||
|
||||
std::list<std::wstring> entries = storageInp->entries(path);
|
||||
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++)
|
||||
{
|
||||
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + "/"+ (*it));
|
||||
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + L"/"+ (*it));
|
||||
if (stream_inp == NULL)continue;
|
||||
|
||||
int size = stream_inp->size();
|
||||
POLE::uint64 size = stream_inp->size();
|
||||
|
||||
POLE::Stream *stream_out = new POLE::Stream(storageOut, *it, true, size);
|
||||
|
||||
|
||||
@ -154,7 +154,7 @@ namespace DocFileFormat
|
||||
|
||||
case sprmPFBiDi:
|
||||
{
|
||||
bool val = iter->argumentsSize > 0 ? iter->Arguments[0] : true;
|
||||
bool val = iter->argumentsSize > 0 ? (iter->Arguments[0] != 0) : true;
|
||||
appendFlagElement( _pPr, *iter, L"bidi", val);
|
||||
_isBidi = val;
|
||||
}break;
|
||||
@ -427,7 +427,7 @@ namespace DocFileFormat
|
||||
if (m_document->listTable)
|
||||
{
|
||||
m_document->listTable->appendNumbering( desc );
|
||||
short numId = m_document->listTable->listNumbering.size();
|
||||
short numId = static_cast<short>(m_document->listTable->listNumbering.size());
|
||||
appendValueElement( &numPr, L"numId", numId, true );
|
||||
}
|
||||
}break;
|
||||
@ -485,7 +485,7 @@ namespace DocFileFormat
|
||||
{
|
||||
XMLTools::XMLElement tabs( L"w:tabs" );
|
||||
|
||||
int pos = 0;
|
||||
unsigned int pos = 0;
|
||||
|
||||
//read the removed tabs
|
||||
unsigned char itbdDelMax = iter->Arguments[pos];
|
||||
|
||||
@ -462,57 +462,60 @@ namespace DocFileFormat
|
||||
|
||||
void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc )
|
||||
{
|
||||
std::wstring pattern = getShadingPattern( desc );
|
||||
if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal ))
|
||||
{
|
||||
XMLTools::XMLElement shd( L"w:shd" );
|
||||
|
||||
//fill color
|
||||
XMLTools::XMLAttribute fill( L"w:fill" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvBackAuto )
|
||||
{
|
||||
fill.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( fill );
|
||||
|
||||
//foreground color
|
||||
XMLTools::XMLAttribute color( L"w:color" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvForeAuto )
|
||||
{
|
||||
color.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( color );
|
||||
|
||||
//pattern
|
||||
XMLTools::XMLAttribute val( L"w:val" );
|
||||
val.SetValue( getShadingPattern( desc ));
|
||||
val.SetValue( pattern);
|
||||
shd.AppendAttribute( val );
|
||||
|
||||
if (pattern != L"nil")
|
||||
{
|
||||
//fill color
|
||||
XMLTools::XMLAttribute fill( L"w:fill" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvBackAuto )
|
||||
{
|
||||
fill.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( fill );
|
||||
|
||||
//foreground color
|
||||
XMLTools::XMLAttribute color( L"w:color" );
|
||||
|
||||
if ( desc.shadingType == shadingTypeShd )
|
||||
{
|
||||
if ( desc.cvForeAuto )
|
||||
{
|
||||
color.SetValue( L"auto" );
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
|
||||
}
|
||||
|
||||
shd.AppendAttribute( color );
|
||||
}
|
||||
parent->RemoveChildByName( L"w:shd" );
|
||||
parent->AppendChild( shd );
|
||||
}
|
||||
|
||||
@ -40,19 +40,13 @@ namespace DocFileFormat
|
||||
RELEASEOBJECT( Changes );
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
RevisionData::RevisionData():
|
||||
Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
|
||||
{
|
||||
this->Changes = new std::list<SinglePropertyModifier>();
|
||||
}
|
||||
|
||||
/*========================================================================================================*/
|
||||
|
||||
/// Collects the revision data of a CHPX
|
||||
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ):
|
||||
Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
|
||||
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ) : Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
|
||||
{
|
||||
bool collectRevisionData = true;
|
||||
this->Changes = new std::list<SinglePropertyModifier>();
|
||||
|
||||
@ -174,9 +174,9 @@ namespace DocFileFormat
|
||||
//it's a Word 97 SPRM
|
||||
short val = FormatUtils::BytesToInt16(bytes, 0, size);
|
||||
|
||||
icoFore = (val & 0x1F);
|
||||
icoBack = ((val >> 5) & 0x1F);
|
||||
ipat = (ShadingPattern) ((val >> 10) & 0x3F);
|
||||
icoFore = GETBITS(val, 0, 4);
|
||||
icoBack = GETBITS(val, 5, 9);
|
||||
ipat = (ShadingPattern) GETBITS(val, 10, 15);
|
||||
|
||||
shadingType = shadingTypeShd80;
|
||||
|
||||
@ -209,7 +209,7 @@ namespace DocFileFormat
|
||||
else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); }
|
||||
else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); }
|
||||
|
||||
if (0x00 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); cvBackAuto = true; }
|
||||
if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; }
|
||||
else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); }
|
||||
else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); }
|
||||
else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); }
|
||||
|
||||
@ -41,7 +41,7 @@ namespace DocFileFormat
|
||||
{
|
||||
TC80()
|
||||
{
|
||||
horzMerge = wWidth = 0;
|
||||
wWidth = horzMerge =0;
|
||||
|
||||
textFlow = Global::lrTb;
|
||||
vertMerge = Global::fvmClear;
|
||||
@ -95,13 +95,14 @@ namespace DocFileFormat
|
||||
int pointer = 1;
|
||||
|
||||
// rgdxaCenter
|
||||
|
||||
for (int i = 0; i < numberOfColumns + 1; ++i)
|
||||
{
|
||||
rgdxaCenter.push_back(FormatUtils::BytesToInt16(bytes, pointer, size));
|
||||
int pos = FormatUtils::BytesToInt16(bytes, pointer, size);
|
||||
rgdxaCenter.push_back(pos);
|
||||
pointer += 2;
|
||||
}
|
||||
|
||||
|
||||
// rgTc80
|
||||
|
||||
for (int i = 0; i < numberOfColumns; ++i)
|
||||
|
||||
@ -81,7 +81,7 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
ByteStructure* operator [] ( unsigned int index ) const
|
||||
ByteStructure* operator [] ( size_t index ) const
|
||||
{
|
||||
if ( index < this->Data.size() )
|
||||
{
|
||||
|
||||
@ -61,18 +61,18 @@ namespace DocFileFormat
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isDirectory( const std::string& name )
|
||||
bool isDirectory( const std::wstring& name )
|
||||
{
|
||||
if (!m_pStorage) return false;
|
||||
|
||||
return m_pStorage->isDirectory(name);
|
||||
}
|
||||
|
||||
bool GetStream (const char *path, POLE::Stream** ppStream)
|
||||
bool GetStream (const std::wstring & path, POLE::Stream** ppStream)
|
||||
{
|
||||
if (( m_pStorage != NULL ) && ( path != NULL ))
|
||||
if (( m_pStorage != NULL ) && ( !path.empty() ))
|
||||
{
|
||||
*ppStream = new POLE::Stream(m_pStorage, path);
|
||||
*ppStream = new POLE::Stream(m_pStorage, path.c_str());
|
||||
}
|
||||
if ((*ppStream) && ((*ppStream)->size() > 0))
|
||||
return true;
|
||||
@ -85,15 +85,15 @@ namespace DocFileFormat
|
||||
return m_pStorage;
|
||||
}
|
||||
|
||||
void copy( int indent, std::string path, POLE::Storage * storageOut, bool withRoot = true)
|
||||
void copy( int indent, std::wstring path, POLE::Storage * storageOut, bool withRoot = true)
|
||||
{
|
||||
std::list<std::string> entries, entries_sort;
|
||||
entries = m_pStorage->entries( path );
|
||||
std::list<std::wstring> entries, entries_sort;
|
||||
entries = m_pStorage->entries_with_prefix( path );
|
||||
|
||||
for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
|
||||
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
|
||||
{
|
||||
std::string name = *it;
|
||||
std::string fullname = path + name;
|
||||
std::wstring name = *it;
|
||||
std::wstring fullname = path + name;
|
||||
|
||||
if( m_pStorage->isDirectory( fullname ) )
|
||||
{
|
||||
@ -105,14 +105,14 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
|
||||
for( std::list<std::string>::iterator it = entries_sort.begin(); it != entries_sort.end(); it++ )
|
||||
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); it++ )
|
||||
{
|
||||
std::string name = *it;
|
||||
std::string fullname = path + name;
|
||||
std::wstring name = *it;
|
||||
std::wstring fullname = path + name;
|
||||
|
||||
if( m_pStorage->isDirectory( fullname ) )
|
||||
{
|
||||
copy( indent + 1, fullname + "/", storageOut, withRoot );
|
||||
copy( indent + 1, fullname + L"/", storageOut, withRoot );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -122,17 +122,17 @@ namespace DocFileFormat
|
||||
}
|
||||
|
||||
private:
|
||||
void copy_stream(std::string streamName, POLE::Storage * storageOut, bool withRoot = true)
|
||||
void copy_stream(std::wstring streamName, POLE::Storage * storageOut, bool withRoot = true)
|
||||
{
|
||||
POLE::Stream *stream = new POLE::Stream(m_pStorage, streamName);
|
||||
if (!stream) return;
|
||||
|
||||
stream->seek(0);
|
||||
int size_stream = stream->size();
|
||||
POLE::int64 size_stream = stream->size();
|
||||
|
||||
if (withRoot == false)
|
||||
{
|
||||
int pos = streamName.find("/");
|
||||
int pos = (int)streamName.find(L"/");
|
||||
if (pos >= 0)
|
||||
streamName = streamName.substr(pos + 1);
|
||||
}
|
||||
|
||||
@ -35,13 +35,13 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex) :
|
||||
TableCellPropertiesMapping::TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex) :
|
||||
PropertiesMapping(pWriter)
|
||||
{
|
||||
_width = 0;
|
||||
|
||||
_gridIndex = gridIndex;
|
||||
_grid = tableGrid;
|
||||
_grid = grid;
|
||||
_cellIndex = cellIndex;
|
||||
|
||||
_brcTop = NULL;
|
||||
@ -75,6 +75,8 @@ namespace DocFileFormat
|
||||
TablePropertyExceptions* tapx = static_cast<TablePropertyExceptions*>(visited);
|
||||
int nComputedCellWidth = 0;
|
||||
|
||||
_gridSpan = 1;
|
||||
|
||||
std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend();
|
||||
for (std::list<SinglePropertyModifier>::const_reverse_iterator iter = tapx->grpprl->rbegin(); iter != rend; ++iter)
|
||||
{
|
||||
@ -87,7 +89,7 @@ namespace DocFileFormat
|
||||
int cc = tdef.numberOfColumns;
|
||||
|
||||
_tGrid = tdef.rgdxaCenter;
|
||||
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)]; // NOTE: fix for crash
|
||||
_tcDef = tdef.rgTc80[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)];
|
||||
|
||||
appendValueElement( _tcPr, L"textDirection", FormatUtils::MapValueToWideString( _tcDef.textFlow, &Global::TextFlowMap[0][0], 6, 6 ), false );
|
||||
|
||||
@ -111,13 +113,19 @@ namespace DocFileFormat
|
||||
{
|
||||
appendValueElement( _tcPr, L"noWrap", L"", true );
|
||||
}
|
||||
|
||||
nComputedCellWidth = (short)( tdef.rgdxaCenter[(size_t)(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1) + 1] -
|
||||
tdef.rgdxaCenter[(std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1)] ); // NOTE: fix for crash
|
||||
int ind = (std::min)(_cellIndex, (int)tdef.rgTc80.size() - 1);
|
||||
int ind1 = ind;
|
||||
while (ind1 < tdef.rgdxaCenter.size() - 1)
|
||||
{
|
||||
int sz = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind1 ] ;
|
||||
if (sz > 1)
|
||||
break;
|
||||
ind1++;
|
||||
}
|
||||
nComputedCellWidth = tdef.rgdxaCenter[ ind1 + 1] - tdef.rgdxaCenter[ ind ] ;
|
||||
|
||||
if (!IsTableBordersDefined(tapx->grpprl))
|
||||
{ //borders
|
||||
|
||||
{
|
||||
RELEASEOBJECT(_brcTop);
|
||||
_brcTop = new BorderCode(*_tcDef.brcTop);
|
||||
|
||||
@ -134,8 +142,7 @@ namespace DocFileFormat
|
||||
break;
|
||||
|
||||
case sprmTCellPadding:
|
||||
{ //margins
|
||||
|
||||
{
|
||||
unsigned char first = iter->Arguments[0];
|
||||
unsigned char lim = iter->Arguments[1];
|
||||
unsigned char ftsMargin = iter->Arguments[3];
|
||||
@ -165,7 +172,6 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case sprmTDefTableShd80:
|
||||
{
|
||||
if (!tapx->IsSkipShading97()) // если такой операнд единственный то учитываем его, иначе скипаем его
|
||||
@ -270,24 +276,23 @@ namespace DocFileFormat
|
||||
}
|
||||
}
|
||||
|
||||
//width
|
||||
XMLTools::XMLElement tcW ( L"w:tcW" );
|
||||
XMLTools::XMLAttribute tcWType ( L"w:type", FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) );
|
||||
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width ) );
|
||||
XMLTools::XMLElement tcW ( L"w:tcW" );
|
||||
|
||||
|
||||
tcW.AppendAttribute( tcWType );
|
||||
XMLTools::XMLAttribute tcWVal ( L"w:w", FormatUtils::IntToWideString( _width > 1 ? _width : nComputedCellWidth) );
|
||||
XMLTools::XMLAttribute tcWType ( L"w:type", _width > 1 ? FormatUtils::MapValueToWideString( _ftsWidth, &Global::CellWidthTypeMap[0][0], 4, 5 ) : L"dxa" );
|
||||
|
||||
tcW.AppendAttribute( tcWType );
|
||||
tcW.AppendAttribute( tcWVal );
|
||||
_tcPr->AppendChild( tcW );
|
||||
|
||||
//grid span
|
||||
_gridSpan = 1;
|
||||
|
||||
if ( ( _gridIndex < (int)_grid->size() ) && ( nComputedCellWidth > _grid->at( _gridIndex ) ) )
|
||||
{
|
||||
//check the number of merged cells
|
||||
int w = _grid->at( _gridIndex );
|
||||
|
||||
for ( unsigned int i = _gridIndex + 1; i < _grid->size(); i++ )
|
||||
for ( size_t i = _gridIndex + 1; i < _grid->size(); i++ )
|
||||
{
|
||||
_gridSpan++;
|
||||
|
||||
@ -349,7 +354,7 @@ namespace DocFileFormat
|
||||
|
||||
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)
|
||||
{
|
||||
if (sprmArg)
|
||||
if (sprmArg && cellIndex >= 0)
|
||||
{
|
||||
//shading descriptor can have 10 bytes (Word 2000) or 2 bytes (Word 97)
|
||||
int shdLength = 2;
|
||||
|
||||
@ -58,7 +58,7 @@ namespace DocFileFormat
|
||||
public:
|
||||
|
||||
virtual ~TableCellPropertiesMapping();
|
||||
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* tableGrid, int gridIndex, int cellIndex);
|
||||
TableCellPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, const std::vector<short>* grid, const std::vector<short>* grid_write, int gridIndex, int cellIndex);
|
||||
virtual void Apply( IVisitable* visited );
|
||||
|
||||
inline int GetGridSpan() const
|
||||
@ -71,9 +71,7 @@ namespace DocFileFormat
|
||||
void apppendCellShading (unsigned char* sprmArg, int size, int cellIndex);
|
||||
bool IsTableBordersDefined (const std::list<SinglePropertyModifier>* grpprl) const;
|
||||
bool IsTableCellWidthDefined (const std::list<SinglePropertyModifier>* grpprl) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int _gridIndex;
|
||||
int _cellIndex;
|
||||
|
||||
@ -93,7 +91,6 @@ namespace DocFileFormat
|
||||
BorderCode* _brcRight;
|
||||
BorderCode* _brcBottom;
|
||||
|
||||
/// The grind span of this cell
|
||||
int _gridSpan;
|
||||
int _gridSpan;
|
||||
};
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ namespace DocFileFormat
|
||||
cellElements.clear();
|
||||
}
|
||||
|
||||
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, int& gridIndex, int nCellIndex)
|
||||
void TableCell::Convert(IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, int& gridIndex, int nCellIndex)
|
||||
{
|
||||
if (NULL != mapping)
|
||||
{
|
||||
@ -116,14 +116,14 @@ namespace DocFileFormat
|
||||
ParagraphPropertyExceptions* papxBackup = documentMapping->_lastValidPapx;
|
||||
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
|
||||
|
||||
//start w:tc
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//find cell end
|
||||
//find cell end
|
||||
int cpCellEnd = documentMapping->findCellEndCp(cp, depth);
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, gridIndex, nCellIndex);
|
||||
//start w:tc
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tc" );
|
||||
|
||||
//convert the properties
|
||||
TableCellPropertiesMapping tcpMapping(documentMapping->GetXMLWriter(), grid, grid_write, gridIndex, nCellIndex);
|
||||
|
||||
if ( tapx != NULL )
|
||||
{
|
||||
@ -140,7 +140,7 @@ namespace DocFileFormat
|
||||
(*iter)->Convert( mapping );
|
||||
}
|
||||
|
||||
//end w:tc
|
||||
//end w:tc
|
||||
documentMapping->GetXMLWriter()->WriteNodeEnd( L"w:tc" );
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ namespace DocFileFormat
|
||||
cells.clear();
|
||||
}
|
||||
|
||||
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid)
|
||||
void TableRow::Convert(IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write)
|
||||
{
|
||||
if ( mapping != NULL )
|
||||
{
|
||||
@ -234,7 +234,7 @@ namespace DocFileFormat
|
||||
{
|
||||
for ( std::list<TableCell>::iterator iter = cells.begin(); iter != cells.end(); iter++ )
|
||||
{
|
||||
iter->Convert( mapping, &tapx, grid, gridIndex, nCellIndex++ );
|
||||
iter->Convert( mapping, &tapx, grid, grid_write, gridIndex, nCellIndex++);
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,7 +516,8 @@ namespace DocFileFormat
|
||||
SectionPropertyExceptions* sepxBackup = documentMapping->_lastValidSepx;
|
||||
|
||||
//build the table grid
|
||||
std::vector<short>* grid = documentMapping->buildTableGrid( cpStart, depth );
|
||||
std::vector<short> grid, grid_write;
|
||||
documentMapping->buildTableGrid( cpStart, depth, grid, grid_write );
|
||||
|
||||
//find first row end
|
||||
int fcRowEnd = documentMapping->findRowEndFc( cpStart, depth );
|
||||
@ -529,7 +530,7 @@ namespace DocFileFormat
|
||||
documentMapping->GetXMLWriter()->WriteNodeBegin( L"w:tbl" );
|
||||
|
||||
//Convert it
|
||||
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, grid );
|
||||
TablePropertiesMapping tpMapping( documentMapping->GetXMLWriter(), documentMapping->m_document->Styles, &grid, &grid_write );
|
||||
|
||||
row1Tapx.Convert( &tpMapping );
|
||||
|
||||
@ -538,13 +539,12 @@ namespace DocFileFormat
|
||||
|
||||
for ( std::list<TableRow>::iterator iter = rows.begin(); iter != rows.end(); iter++ )
|
||||
{
|
||||
iter->Convert( mapping, grid );
|
||||
iter->Convert( mapping, &grid, &grid_write );
|
||||
}
|
||||
|
||||
//close w:tbl
|
||||
documentMapping->GetXMLWriter()->WriteNodeEnd( L"w:tbl" );
|
||||
|
||||
RELEASEOBJECT( grid );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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<short>* grid, int& gridIndex, int cellIndex );
|
||||
void Convert( IMapping* mapping, TablePropertyExceptions* tapx, const std::vector<short>* grid, const std::vector<short>* grid_write, 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<short>* grid );
|
||||
void Convert( IMapping* mapping, const std::vector<short>* grid, const std::vector<short>* grid_write );
|
||||
~TableRow();
|
||||
|
||||
private:
|
||||
|
||||
@ -34,15 +34,13 @@
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded ):
|
||||
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(NULL),
|
||||
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(NULL),
|
||||
TablePropertiesMapping::TablePropertiesMapping (XMLTools::CStringXmlWriter* pWriter, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded ):
|
||||
PropertiesMapping(pWriter), _tblPr(NULL), _tblGrid(NULL), _tblBorders(NULL), _grid(grid), _grid_write(grid_write),
|
||||
brcLeft(NULL), brcTop(NULL), brcBottom(NULL), brcRight(NULL), brcHorz(NULL), brcVert(NULL), _styles(styles),
|
||||
_isTableStyleNeeded(isTableStyleNeeded)
|
||||
{
|
||||
_styles = styles;
|
||||
_tblPr = new XMLTools::XMLElement( L"w:tblPr");
|
||||
_tblBorders = new XMLTools::XMLElement( L"w:tblBorders");
|
||||
_grid = grid;
|
||||
}
|
||||
TablePropertiesMapping::~TablePropertiesMapping()
|
||||
{
|
||||
@ -74,6 +72,9 @@ namespace DocFileFormat
|
||||
short marginLeft = 0;
|
||||
short marginRight = 0;
|
||||
|
||||
BYTE itcFirst = 0;
|
||||
BYTE itcLim = 0;
|
||||
|
||||
for ( std::list<SinglePropertyModifier>::iterator iter = tapx->grpprl->begin(); iter != tapx->grpprl->end(); iter++ )
|
||||
{
|
||||
switch( iter->OpCode )
|
||||
@ -120,7 +121,15 @@ namespace DocFileFormat
|
||||
_tblPr->AppendChild( tblW );
|
||||
}
|
||||
break;
|
||||
case sprmTMerge:
|
||||
{
|
||||
itcFirst = iter->Arguments[0];
|
||||
itcLim = iter->Arguments[1];
|
||||
}break;
|
||||
case sprmTSplit:
|
||||
{
|
||||
|
||||
}break;
|
||||
case sprmOldTJc:
|
||||
case sprmTJc:
|
||||
case sprmTJcRow:
|
||||
@ -144,7 +153,7 @@ namespace DocFileFormat
|
||||
|
||||
if ( _isTableStyleNeeded )
|
||||
{
|
||||
int ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
size_t ind = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
|
||||
|
||||
std::wstring id = ind < _styles->Styles->size() ? StyleSheetMapping::MakeStyleId( _styles->Styles->at( ind ) ) : L"";
|
||||
|
||||
@ -486,7 +495,7 @@ namespace DocFileFormat
|
||||
bWriteGridCol = true;
|
||||
else
|
||||
{
|
||||
for ( unsigned int i = 0, nSize = _grid->size(); i < nSize; i++ )
|
||||
for ( size_t i = 0, nSize = _grid_write->size(); i < nSize; i++ )
|
||||
{
|
||||
if(_grid->at(i) % DocFileFormat::gc_nZeroWidth != 0)
|
||||
{
|
||||
@ -497,10 +506,10 @@ namespace DocFileFormat
|
||||
}
|
||||
if(true == bWriteGridCol)
|
||||
{
|
||||
for ( unsigned int i = 0; i < _grid->size(); i++ )
|
||||
for ( size_t i = 0; i < _grid_write->size(); i++ )
|
||||
{
|
||||
XMLTools::XMLElement gridCol( L"w:gridCol");
|
||||
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid->at( i ) ) );
|
||||
XMLTools::XMLAttribute gridColW( L"w:w", FormatUtils::IntToWideString( _grid_write->at( i ) ) );
|
||||
gridCol.AppendAttribute( gridColW );
|
||||
_tblGrid->AppendChild( gridCol );
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ namespace DocFileFormat
|
||||
class TablePropertiesMapping: public PropertiesMapping, public IMapping
|
||||
{
|
||||
public:
|
||||
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, bool isTableStyleNeeded = true );
|
||||
TablePropertiesMapping( XMLTools::CStringXmlWriter* writer, StyleSheet* styles, std::vector<short>* grid, std::vector<short>* grid_write, bool isTableStyleNeeded = true );
|
||||
virtual ~TablePropertiesMapping();
|
||||
void Apply( IVisitable* visited );
|
||||
|
||||
@ -83,6 +83,7 @@ namespace DocFileFormat
|
||||
|
||||
StyleSheet* _styles;
|
||||
std::vector<short>* _grid;
|
||||
std::vector<short>* _grid_write;
|
||||
|
||||
BorderCode* brcLeft;
|
||||
BorderCode* brcTop;
|
||||
|
||||
@ -62,8 +62,9 @@ namespace DocFileFormat
|
||||
|
||||
for (std::list<SinglePropertyModifier>::iterator oSpmIter = papx->grpprl->begin(); oSpmIter != papx->grpprl->end(); ++oSpmIter)
|
||||
{
|
||||
if (oSpmIter->OpCode == sprmTDefTableShd || oSpmIter->OpCode == sprmTDefTableShd2nd ||
|
||||
oSpmIter->OpCode == sprmTDefTableShd2nd || oSpmIter->OpCode == sprmTDefTableShd3rd)
|
||||
if (oSpmIter->OpCode == sprmTDefTableShd ||
|
||||
oSpmIter->OpCode == sprmTDefTableShd2nd ||
|
||||
oSpmIter->OpCode == sprmTDefTableShd3rd)
|
||||
{
|
||||
m_bSkipShading97 = TRUE;
|
||||
}
|
||||
|
||||
@ -159,13 +159,13 @@ namespace DocFileFormat
|
||||
OOX::CDocument docEmbedded(path, path);
|
||||
|
||||
bool res = false;
|
||||
for (int i = 0 ; i < docEmbedded.m_arrItems.size(); i++)
|
||||
for (size_t i = 0 ; i < docEmbedded.m_arrItems.size(); i++)
|
||||
{
|
||||
if (docEmbedded.m_arrItems[i]->getType() == OOX::et_w_p)
|
||||
{
|
||||
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(docEmbedded.m_arrItems[i]);
|
||||
|
||||
for (int j = 0; (paragraph) && (j < paragraph->m_arrItems.size()); j++)
|
||||
for (size_t j = 0; (paragraph) && (j < paragraph->m_arrItems.size()); j++)
|
||||
{
|
||||
if (paragraph->m_arrItems[j]->getType() == OOX::et_m_oMath)
|
||||
{
|
||||
@ -177,7 +177,7 @@ namespace DocFileFormat
|
||||
{
|
||||
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(paragraph->m_arrItems[j]);
|
||||
|
||||
for (int k = 0; (mathPara) && (k < mathPara->m_arrItems.size()); k++)
|
||||
for (size_t k = 0; (mathPara) && (k < mathPara->m_arrItems.size()); k++)
|
||||
{
|
||||
if (mathPara->m_arrItems[k]->getType() == OOX::et_m_oMath)
|
||||
{
|
||||
|
||||
@ -288,6 +288,7 @@ namespace DocFileFormat
|
||||
int ndyTextBottom = -1;
|
||||
|
||||
bool bHavePath = false;
|
||||
int nShapePath = -1;
|
||||
int nAdjValues = 0;
|
||||
int nLTxID = -1;
|
||||
|
||||
@ -361,6 +362,7 @@ namespace DocFileFormat
|
||||
case shapePath :
|
||||
{
|
||||
bHavePath = true;
|
||||
nShapePath = iter->op;
|
||||
}break;
|
||||
case pVertices:
|
||||
{
|
||||
@ -744,7 +746,7 @@ namespace DocFileFormat
|
||||
|
||||
text = FormatUtils::XmlEncode(text);
|
||||
|
||||
if (0 <= text.find(L"\n"))
|
||||
if (std::wstring::npos != text.find(L"\n"))
|
||||
{
|
||||
m_textpath.AppendText(text);
|
||||
}
|
||||
@ -754,7 +756,7 @@ namespace DocFileFormat
|
||||
case gtextFont:
|
||||
{
|
||||
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex.get(), (iter->op)/2);
|
||||
int i = font.size();
|
||||
size_t i = font.size();
|
||||
while (i > 0)
|
||||
{
|
||||
if (font[i-1] != 0) break;
|
||||
@ -1653,7 +1655,7 @@ namespace DocFileFormat
|
||||
}
|
||||
if (!bRelV && m_pSpa)
|
||||
{
|
||||
appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->bx));
|
||||
appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->by));
|
||||
}
|
||||
if (!m_isInlineShape && !bZIndex)
|
||||
{
|
||||
@ -1963,7 +1965,7 @@ namespace DocFileFormat
|
||||
{
|
||||
int index = (DWORD)val - 0x80000000;
|
||||
|
||||
if (index >= 0 && index < m_arrGuides.size())
|
||||
if (index >= 0 && index < (int)m_arrGuides.size())
|
||||
{
|
||||
new_val = m_arrGuides[index].param3;
|
||||
}
|
||||
@ -2130,7 +2132,7 @@ namespace DocFileFormat
|
||||
|
||||
void VMLShapeMapping::ApplyPrimitives(DrawingPrimitives * primitives)
|
||||
{
|
||||
int index = 0;
|
||||
size_t index = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
@ -2142,7 +2144,7 @@ namespace DocFileFormat
|
||||
|
||||
static int currentTextBoxIndex = 1;
|
||||
|
||||
int VMLShapeMapping::ApplyPrimitive(DrawingPrimitives * primitives, int index)
|
||||
size_t VMLShapeMapping::ApplyPrimitive(DrawingPrimitives * primitives, size_t index)
|
||||
{
|
||||
if (!primitives) return index++;
|
||||
if (index >= primitives->size()) return index++;
|
||||
@ -2241,11 +2243,11 @@ namespace DocFileFormat
|
||||
{
|
||||
//strStyle += L"left:" + FormatUtils::IntToWideString( x.ToPoints()) + L"pt;";
|
||||
//strStyle += L"top:" + FormatUtils::IntToWideString( y.ToPoints()) + L"pt;";
|
||||
strStyle += L"width:" + FormatUtils::IntToWideString( w.ToPoints()) + L"pt;";
|
||||
strStyle += L"height:" + FormatUtils::IntToWideString( h.ToPoints()) + L"pt;";
|
||||
strStyle += L"width:" + FormatUtils::IntToWideString( (int)w.ToPoints()) + L"pt;";
|
||||
strStyle += L"height:" + FormatUtils::IntToWideString( (int)h.ToPoints()) + L"pt;";
|
||||
|
||||
strStyle += L"margin-left:" + FormatUtils::IntToWideString( x.ToPoints()) + L"pt;";
|
||||
strStyle += L"margin-top:" + FormatUtils::IntToWideString( y.ToPoints()) + L"pt;";
|
||||
strStyle += L"margin-left:" + FormatUtils::IntToWideString( (int)x.ToPoints()) + L"pt;";
|
||||
strStyle += L"margin-top:" + FormatUtils::IntToWideString( (int)y.ToPoints()) + L"pt;";
|
||||
|
||||
std::wstring xMargin;
|
||||
std::wstring yMargin;
|
||||
|
||||
@ -73,7 +73,7 @@ namespace DocFileFormat
|
||||
private:
|
||||
|
||||
void ApplyPrimitives (DrawingPrimitives * primitives );
|
||||
int ApplyPrimitive (DrawingPrimitives * primitives, int index);
|
||||
size_t ApplyPrimitive (DrawingPrimitives * primitives, size_t index);
|
||||
|
||||
void WritePrimitiveProps(DrawingPrimitive * primitive, bool root);
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ public:
|
||||
if (position + count > stream->size())
|
||||
{
|
||||
if (position > stream->size()) count = 0;
|
||||
else count = stream->size() - position;
|
||||
else count = (unsigned int)(stream->size() - position);
|
||||
}
|
||||
rdBytes = new unsigned char[count];
|
||||
}
|
||||
@ -152,7 +152,7 @@ public:
|
||||
|
||||
virtual unsigned long GetPosition() const
|
||||
{
|
||||
return this->position;
|
||||
return (unsigned long)this->position;
|
||||
}
|
||||
|
||||
virtual unsigned long GetSize() const
|
||||
@ -161,7 +161,7 @@ public:
|
||||
|
||||
if ( stream != NULL )
|
||||
{
|
||||
size = stream->size();
|
||||
size = (unsigned long)stream->size();
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -246,7 +246,7 @@ public:
|
||||
/// The string must have the following structure:
|
||||
/// unsigned char 1-4: Character count (cch)
|
||||
/// unsigned char 5-cch+4: ANSI characters terminated by \0
|
||||
std::wstring ReadLengthPrefixedAnsiString(int max_size)
|
||||
std::wstring ReadLengthPrefixedAnsiString(unsigned int max_size)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
@ -257,8 +257,8 @@ public:
|
||||
if (cch > max_size)
|
||||
{
|
||||
//error ... skip to 0
|
||||
int pos_orinal = GetPosition();
|
||||
int pos = 0;
|
||||
unsigned int pos_orinal = GetPosition();
|
||||
unsigned int pos = 0;
|
||||
|
||||
stringBytes = ReadBytes( max_size, true );
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ namespace DocFileFormat
|
||||
return AVS_ERROR_FILEFORMAT;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false)
|
||||
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false)
|
||||
{
|
||||
Clear();
|
||||
return AVS_ERROR_FILEFORMAT;
|
||||
@ -121,16 +121,16 @@ namespace DocFileFormat
|
||||
|
||||
if (FIB->m_FibBase.fWhichTblStm)
|
||||
{
|
||||
if (!m_pStorage->GetStream ("1Table", &TableStream))
|
||||
if (!m_pStorage->GetStream (L"1Table", &TableStream))
|
||||
{
|
||||
res = m_pStorage->GetStream ("0Table", &TableStream);
|
||||
res = m_pStorage->GetStream (L"0Table", &TableStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_pStorage->GetStream ("0Table", &TableStream))
|
||||
if (!m_pStorage->GetStream (L"0Table", &TableStream))
|
||||
{
|
||||
res = m_pStorage->GetStream ("1Table", &TableStream);
|
||||
res = m_pStorage->GetStream (L"1Table", &TableStream);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +176,8 @@ namespace DocFileFormat
|
||||
POLE::Stream * Summary = NULL;
|
||||
POLE::Stream * DocSummary = NULL;
|
||||
|
||||
m_pStorage->GetStream ("SummaryInformation", &Summary);
|
||||
m_pStorage->GetStream ("DocumentSummaryInformation", &DocSummary);
|
||||
m_pStorage->GetStream (L"SummaryInformation", &Summary);
|
||||
m_pStorage->GetStream (L"DocumentSummaryInformation", &DocSummary);
|
||||
|
||||
document_code_page = ENCODING_WINDOWS_1250;
|
||||
|
||||
@ -206,7 +206,7 @@ namespace DocFileFormat
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
try
|
||||
{
|
||||
m_pStorage->GetStream ("Data", &DataStream);
|
||||
m_pStorage->GetStream (L"Data", &DataStream);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -216,7 +216,7 @@ namespace DocFileFormat
|
||||
if (TableStream->size() < 1 && bOlderVersion)
|
||||
{
|
||||
RELEASEOBJECT(TableStream);
|
||||
m_pStorage->GetStream ("WordDocument", &TableStream);
|
||||
m_pStorage->GetStream (L"WordDocument", &TableStream);
|
||||
}
|
||||
|
||||
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
|
||||
@ -483,7 +483,7 @@ namespace DocFileFormat
|
||||
delete storageOut;
|
||||
return false;
|
||||
}
|
||||
DecryptStream( 0, "/", storageIn, storageOut, Decryptor);
|
||||
DecryptStream( 0, L"/", storageIn, storageOut, Decryptor);
|
||||
|
||||
//std::list<std::string> listStream = storageIn->entries();
|
||||
|
||||
@ -514,59 +514,60 @@ namespace DocFileFormat
|
||||
|
||||
m_pStorage->SetFile(m_sTempDecryptFileName.c_str());
|
||||
|
||||
if (m_pStorage->GetStream ("WordDocument", &WordDocumentStream) == false) return false;
|
||||
if (m_pStorage->GetStream (L"WordDocument", &WordDocumentStream) == false) return false;
|
||||
|
||||
if (FIB->m_FibBase.fWhichTblStm)
|
||||
{
|
||||
if (!m_pStorage->GetStream ("1Table", &TableStream)) m_pStorage->GetStream ("0Table", &TableStream);
|
||||
if (!m_pStorage->GetStream (L"1Table", &TableStream)) m_pStorage->GetStream (L"0Table", &TableStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_pStorage->GetStream ("0Table", &TableStream)) m_pStorage->GetStream ("1Table", &TableStream);
|
||||
if (!m_pStorage->GetStream (L"0Table", &TableStream)) m_pStorage->GetStream (L"1Table", &TableStream);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void WordDocument::DecryptStream( int level, std::string path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
void WordDocument::DecryptStream( int level, std::wstring path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
{
|
||||
std::list<std::string> entries, entries_sort;
|
||||
entries = storageIn->entries( path );
|
||||
std::list<std::wstring> entries, entries_files, entries_dir;
|
||||
entries = storageIn->entries_with_prefix( path );
|
||||
|
||||
for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
|
||||
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
|
||||
{
|
||||
std::string name = *it;
|
||||
std::string fullname = path + name;
|
||||
std::wstring name = *it;
|
||||
std::wstring fullname = path + name;
|
||||
|
||||
if( storageIn->isDirectory( fullname ) )
|
||||
{
|
||||
entries_sort.push_back(name);
|
||||
entries_dir.push_back(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries_sort.push_front(name);
|
||||
entries_files.push_front(name);
|
||||
}
|
||||
}
|
||||
for( std::list<std::string>::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it )
|
||||
for( std::list<std::wstring>::iterator it = entries_dir.begin(); it != entries_dir.end(); ++it )
|
||||
{
|
||||
std::string name = *it;
|
||||
std::string fullname = path + name;
|
||||
std::wstring fullname = path + *it;
|
||||
|
||||
if( storageIn->isDirectory( fullname ) )
|
||||
{
|
||||
DecryptStream( level + 1, fullname + "/", storageIn, storageOut, Decryptor );
|
||||
}
|
||||
else
|
||||
{
|
||||
DecryptStream(fullname, storageIn, storageOut, Decryptor );
|
||||
}
|
||||
DecryptStream( level + 1, fullname + L"/", storageIn, storageOut, Decryptor );
|
||||
|
||||
}
|
||||
//if (bSortFiles)
|
||||
entries_files.sort();
|
||||
|
||||
for( std::list<std::wstring>::iterator it = entries_files.begin(); it != entries_files.end(); ++it )
|
||||
{
|
||||
std::wstring fullname = path + *it;
|
||||
DecryptStream(fullname, storageIn, storageOut, Decryptor );
|
||||
}
|
||||
}
|
||||
bool WordDocument::DecryptStream(std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
bool WordDocument::DecryptStream(std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
{
|
||||
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
|
||||
if (!stream) return false;
|
||||
|
||||
stream->seek(0);
|
||||
int size_stream = stream->size();
|
||||
POLE::uint64 size_stream = stream->size();
|
||||
|
||||
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
|
||||
if (!streamNew) return false;
|
||||
@ -577,7 +578,7 @@ namespace DocFileFormat
|
||||
unsigned char* data_store = NULL;
|
||||
int size_data_store = 0;
|
||||
|
||||
if ( std::wstring::npos != streamName.find("WordDocument") )
|
||||
if ( std::wstring::npos != streamName.find(L"WordDocument") )
|
||||
{
|
||||
size_data_store = 68;
|
||||
data_store = new unsigned char[size_data_store];
|
||||
@ -586,8 +587,10 @@ namespace DocFileFormat
|
||||
if (data_store)
|
||||
memcpy(data_store, data_stream, size_data_store);
|
||||
|
||||
int size_block = 0x200;
|
||||
for (int pos = 0, block = 0 ; pos < size_stream; pos += size_block, block++)
|
||||
size_t size_block = 0x200;
|
||||
unsigned long block = 0;
|
||||
|
||||
for (POLE::uint64 pos = 0; pos < size_stream; pos += size_block, block++)
|
||||
{
|
||||
if (pos + size_block > size_stream)
|
||||
size_block = size_stream - pos;
|
||||
|
||||
@ -107,8 +107,8 @@ namespace DocFileFormat
|
||||
private:
|
||||
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
|
||||
|
||||
bool DecryptStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
void DecryptStream (int level, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
bool DecryptStream (std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
void DecryptStream (int level, std::wstring streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
|
||||
inline OfficeArtContent* GetOfficeArt ()
|
||||
{
|
||||
|
||||
@ -71,7 +71,7 @@ namespace ImageHelper
|
||||
__BITMAPINFOHEADER * header = (__BITMAPINFOHEADER*)data;
|
||||
if (!header) return result;
|
||||
|
||||
result == Global::msoblipDIB;
|
||||
result = Global::msoblipDIB;
|
||||
|
||||
if (header->biWidth > 100000 || header->biHeight > 100000 || header->biSize != 40)
|
||||
{
|
||||
@ -185,7 +185,7 @@ namespace DocFileFormat
|
||||
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
|
||||
NSDirectory::CreateDirectory( pathWord );
|
||||
|
||||
if (bMacros && docFile->GetStorage()->isDirectory("Macros"))
|
||||
if (bMacros && docFile->GetStorage()->isDirectory(L"Macros"))
|
||||
{
|
||||
std::wstring sVbaProjectFile = pathWord + FILE_SEPARATOR_STR + L"vbaProject.bin";
|
||||
|
||||
@ -193,7 +193,7 @@ namespace DocFileFormat
|
||||
|
||||
if ((storageVbaProject) && (storageVbaProject->open(true, true)))
|
||||
{
|
||||
docFile->GetStorage()->copy(0, "Macros/", storageVbaProject, false);
|
||||
docFile->GetStorage()->copy(0, L"Macros/", storageVbaProject, false);
|
||||
|
||||
storageVbaProject->close();
|
||||
delete storageVbaProject;
|
||||
|
||||
@ -94,6 +94,7 @@ SOURCES += \
|
||||
../../DocDocxConverter/VMLShapeTypeMapping.cpp \
|
||||
../../DocDocxConverter/WordDocument.cpp \
|
||||
../../DocDocxConverter/WordprocessingDocument.cpp \
|
||||
../../DocDocxConverter/FormFieldData.cpp \
|
||||
../../DocDocxConverter/OfficeDrawing/Record.cpp \
|
||||
../../DocDocxConverter/OfficeDrawing/RecordFactory.cpp \
|
||||
../../DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp
|
||||
|
||||
@ -74,6 +74,7 @@
|
||||
#include "../../DocDocxConverter/VMLShapeTypeMapping.cpp"
|
||||
#include "../../DocDocxConverter/WordDocument.cpp"
|
||||
#include "../../DocDocxConverter/WordprocessingDocument.cpp"
|
||||
#include "../../DocDocxConverter/FormFieldData.cpp"
|
||||
#include "../../DocDocxConverter/OfficeDrawing/Record.cpp"
|
||||
#include "../../DocDocxConverter/OfficeDrawing/RecordFactory.cpp"
|
||||
#include "../../DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp"
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
@ -479,6 +479,14 @@
|
||||
RelativePath="..\..\DocDocxConverter\FormattedDiskPagePAPX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\FormFieldData.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\FormFieldData.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\Global.h"
|
||||
>
|
||||
@ -1090,6 +1098,10 @@
|
||||
RelativePath="..\..\DocDocxConverter\FootnotesMapping.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\FormFieldDataMapping.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\DocDocxConverter\HeaderMapping.cpp"
|
||||
>
|
||||
|
||||
@ -29,19 +29,17 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
// DocFormatTest.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
#include "../DocFormatLib/DocFormatLib.h"
|
||||
|
||||
#include "../../OfficeUtils/src/ASCOfficeCriticalSection.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "../../Common/DocxFormat/Source/Base/Base.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../DocFormatLib/DocFormatLib.h"
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#pragma comment(lib,"Shell32.lib")
|
||||
#pragma comment(lib,"Advapi32.lib")
|
||||
#pragma comment(lib,"Rpcrt4.lib")
|
||||
|
||||
#if defined(_WIN64)
|
||||
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
|
||||
@ -49,36 +47,34 @@
|
||||
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
|
||||
#endif
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
HRESULT convert_single(std::wstring srcFileName)
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::wstring sSrcDoc = argv[1];
|
||||
std::wstring sDstDocx;
|
||||
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(sSrcDoc);
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(srcFileName);
|
||||
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
std::wstring dstPath;
|
||||
|
||||
COfficeDocFile docFile;
|
||||
|
||||
docFile.m_sTempFolder = outputDir;
|
||||
|
||||
bool bMacros = true;
|
||||
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", bMacros, NULL);
|
||||
HRESULT hRes = docFile.LoadFromFile( srcFileName, dstTempPath, L"password", bMacros, NULL);
|
||||
|
||||
if (bMacros)
|
||||
{
|
||||
sDstDocx = sSrcDoc + L"-my.docm";
|
||||
dstPath = srcFileName + L"-my.docm";
|
||||
}
|
||||
else
|
||||
{
|
||||
sDstDocx = sSrcDoc + L"-my.docx";
|
||||
dstPath = srcFileName + L"-my.docx";
|
||||
|
||||
}
|
||||
if (hRes == S_OK)
|
||||
{
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), sDstDocx, -1);
|
||||
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath, -1);
|
||||
}
|
||||
|
||||
NSDirectory::DeleteDirectory(dstTempPath);
|
||||
@ -86,3 +82,33 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
return hRes;
|
||||
}
|
||||
|
||||
|
||||
HRESULT convert_directory(std::wstring pathName)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
|
||||
|
||||
for (size_t i = 0; i < arFiles.size(); i++)
|
||||
{
|
||||
convert_single(arFiles[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = -1;
|
||||
if (NSFile::CFileBinary::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_single(argv[1]);
|
||||
}
|
||||
else if (NSDirectory::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_directory(argv[1]);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -442,6 +442,10 @@
|
||||
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
|
||||
>
|
||||
|
||||
@ -55,7 +55,9 @@ namespace Writers
|
||||
oFile.CreateFileW(filePath.GetPath());
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<w:document \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
|
||||
@ -60,16 +60,50 @@ namespace Writers
|
||||
std::wstring rId;
|
||||
SimpleTypes::EHdrFtr eType;
|
||||
};
|
||||
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:hdr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_hdr_End = _T("</w:hdr>");
|
||||
|
||||
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:ftr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
|
||||
<w:ftr xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_ftr_End = _T("</w:ftr>");
|
||||
|
||||
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_footnotes_End = _T("</w:footnotes>");
|
||||
|
||||
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
|
||||
static std::wstring g_string_endnotes_End = _T("</w:endnotes>");
|
||||
|
||||
class HeaderFooterWriter
|
||||
|
||||
@ -355,10 +355,13 @@ class Tab
|
||||
public:
|
||||
BYTE Val;
|
||||
double Pos;
|
||||
BYTE Leader;
|
||||
bool bLeader;
|
||||
Tab()
|
||||
{
|
||||
Val = shd_Nil;
|
||||
Pos = 0;
|
||||
bLeader = false;
|
||||
}
|
||||
};
|
||||
class Tabs
|
||||
@ -1697,7 +1700,7 @@ public:
|
||||
std::vector<std::wstring> arSplit;
|
||||
boost::algorithm::split(arSplit, pComment->UserName, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
for (int i = 0; i < arSplit.size(); i++)
|
||||
for (size_t i = 0; i < arSplit.size(); i++)
|
||||
{
|
||||
sInitials += arSplit[i][0];
|
||||
}
|
||||
@ -1733,7 +1736,7 @@ public:
|
||||
|
||||
bool bFirst = true;
|
||||
int nPrevIndex = 0;
|
||||
for(size_t i = 0; i < sText.length(); i++)
|
||||
for (int i = 0; i < (int)sText.length(); i++)
|
||||
{
|
||||
wchar_t cToken = sText[i];
|
||||
if('\n' == cToken)
|
||||
@ -2337,7 +2340,7 @@ public:
|
||||
{
|
||||
return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty();
|
||||
}
|
||||
std::wstring Write(bool bBandSize, bool bLayout)
|
||||
std::wstring Write()
|
||||
{
|
||||
std::wstring sRes;
|
||||
sRes += L"<w:tblPr>";
|
||||
@ -2361,13 +2364,8 @@ public:
|
||||
sRes += (TableBorders);
|
||||
if(false == Shd.empty())
|
||||
sRes += (Shd);
|
||||
if(bLayout)
|
||||
{
|
||||
if(false == Layout.empty())
|
||||
sRes += (Layout);
|
||||
else if(g_nCurFormatVersion < 4)
|
||||
sRes += L"<w:tblLayout w:type=\"fixed\"/>";
|
||||
}
|
||||
if(false == Layout.empty())
|
||||
sRes += (Layout);
|
||||
if(false == TableCellMar.empty())
|
||||
sRes += (TableCellMar);
|
||||
if(false == Look.empty())
|
||||
@ -2755,7 +2753,7 @@ public:
|
||||
}
|
||||
if(NULL != tblPr)
|
||||
{
|
||||
pCStringWriter->WriteString(tblPr->Write(false, true));
|
||||
pCStringWriter->WriteString(tblPr->Write());
|
||||
}
|
||||
if(NULL != tblGridChange)
|
||||
{
|
||||
|
||||
@ -61,6 +61,13 @@ enum ETblStyleOverrideType
|
||||
tblstyleoverridetypeSwCell = 11,
|
||||
tblstyleoverridetypeWholeTable = 12
|
||||
};
|
||||
|
||||
struct RowHeight
|
||||
{
|
||||
unsigned char HRule = 0;
|
||||
long nHeight = 0;
|
||||
};
|
||||
|
||||
class SdtWraper
|
||||
{
|
||||
public:
|
||||
@ -827,7 +834,23 @@ public:
|
||||
case g_tabtype_clear: sVal = L"clear"; break;
|
||||
default: sVal = L"left"; break;
|
||||
}
|
||||
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"/>");
|
||||
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"");
|
||||
if (oTab.bLeader)
|
||||
{
|
||||
std::wstring sLeader;
|
||||
switch(oTab.Leader)
|
||||
{
|
||||
case SimpleTypes::tabtlcDot : sLeader = (L"dot");break;
|
||||
case SimpleTypes::tabtlcHeavy : sLeader = (L"heavy");break;
|
||||
case SimpleTypes::tabtlcHyphen : sLeader = (L"hyphen");break;
|
||||
case SimpleTypes::tabtlcMiddleDot : sLeader = (L"middleDot");break;
|
||||
case SimpleTypes::tabtlcNone : sLeader = (L"none");break;
|
||||
case SimpleTypes::tabtlcUnderscore : sLeader = (L"underscore");break;
|
||||
default : sLeader = (L"none");break;
|
||||
}
|
||||
pCStringWriter->WriteString(L" w:leader=\"" + sLeader + L"\"");
|
||||
}
|
||||
pCStringWriter->WriteString(L"/>");
|
||||
}
|
||||
pCStringWriter->WriteString(std::wstring(L"</w:tabs>"));
|
||||
}
|
||||
@ -885,6 +908,11 @@ public:
|
||||
pCStringWriter->WriteString(oSectPr.Write());
|
||||
pCStringWriter->WriteString(std::wstring(_T("</w:sectPr>")));
|
||||
}break;
|
||||
case c_oSerProp_pPrType::outlineLvl:
|
||||
{
|
||||
long outlineLvl = m_oBufferedStream.GetLong();
|
||||
pCStringWriter->WriteString(L"<w:outlineLvl w:val=\"" + std::to_wstring(outlineLvl) + L"\"/>");
|
||||
}break;
|
||||
default:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
break;
|
||||
@ -1003,6 +1031,11 @@ public:
|
||||
poTabItem->Val = m_oBufferedStream.GetUChar();
|
||||
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
|
||||
poTabItem->Pos = m_oBufferedStream.GetDouble();
|
||||
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
|
||||
{
|
||||
poTabItem->bLeader = true;
|
||||
poTabItem->Leader = m_oBufferedStream.GetUChar();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -2085,7 +2118,17 @@ public:
|
||||
}
|
||||
else if( c_oSerProp_rowPrType::Height == type )
|
||||
{
|
||||
res = Read2(length, &Binary_tblPrReader::ReadHeight, this, poResult);
|
||||
RowHeight val;
|
||||
res = Read2(length, &Binary_tblPrReader::ReadHeight, this, &val);
|
||||
|
||||
pCStringWriter->WriteString(L"<w:trHeight w:val=\"" + std::to_wstring(val.nHeight) + L"\"");
|
||||
|
||||
switch (val.HRule)
|
||||
{
|
||||
case 1: pCStringWriter->WriteString(L" w:hRule=\"auto\""); break;
|
||||
case 2: pCStringWriter->WriteString(L" w:hRule=\"exact\""); break;
|
||||
}
|
||||
pCStringWriter->WriteString(L"/>");
|
||||
}
|
||||
else if( c_oSerProp_rowPrType::TableHeader == type )
|
||||
{
|
||||
@ -2154,17 +2197,17 @@ public:
|
||||
int ReadHeight(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
XmlUtils::CStringWriter* pCStringWriter = static_cast<XmlUtils::CStringWriter*>(poResult);
|
||||
/*if( c_oSerProp_rowPrType::Height_Rule == type )
|
||||
|
||||
RowHeight* pHeight = static_cast<RowHeight*>(poResult);
|
||||
|
||||
if( c_oSerProp_rowPrType::Height_Rule == type )
|
||||
{
|
||||
Height.HRule = this.stream.GetUChar();
|
||||
pHeight->HRule = m_oBufferedStream.GetUChar();
|
||||
}
|
||||
else */if( c_oSerProp_rowPrType::Height_Value == type )
|
||||
else if( c_oSerProp_rowPrType::Height_Value == type )
|
||||
{
|
||||
double dHeight = m_oBufferedStream.GetDouble();
|
||||
long nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
|
||||
|
||||
pCStringWriter->WriteString(L"<w:trHeight w:val=\"" + std::to_wstring(nHeight) + L"\"/>");
|
||||
pHeight->nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
@ -2800,7 +2843,7 @@ public:
|
||||
{
|
||||
CWiterTblPr oWiterTblPr;
|
||||
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
|
||||
odocStyle->TablePr = oWiterTblPr.Write(true, false);
|
||||
odocStyle->TablePr = oWiterTblPr.Write();
|
||||
}
|
||||
else if(c_oSer_sts::Style_RowPr == type)
|
||||
{
|
||||
@ -2896,7 +2939,7 @@ public:
|
||||
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
|
||||
|
||||
if(false == oWiterTblPr.IsEmpty())
|
||||
ptblStylePr->Writer.WriteString(oWiterTblPr.Write(false, false));
|
||||
ptblStylePr->Writer.WriteString(oWiterTblPr.Write());
|
||||
}
|
||||
else if(c_oSerProp_tblStylePrType::TrPr == type)
|
||||
{
|
||||
@ -3708,6 +3751,33 @@ public:
|
||||
res = Read2(length, &Binary_DocumentTableReader::Read_Background, this, &oBackground);
|
||||
m_oDocumentWriter.m_oBackground.WriteString(oBackground.Write());
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkStart == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkEnd == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else if(c_oSerParType::JsaProject == type)
|
||||
{
|
||||
BYTE* pData = m_oBufferedStream.GetPointer(length);
|
||||
OOX::CPath sJsaProject = OOX::FileTypes::JsaProject.DefaultFileName();
|
||||
std::wstring filePath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word"+ FILE_SEPARATOR_STR + sJsaProject.GetPath();
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(filePath);
|
||||
oFile.WriteFile(pData, length);
|
||||
oFile.CloseFile();
|
||||
|
||||
long lId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), sJsaProject.GetPath(), L"", &lId);
|
||||
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(sJsaProject.GetExtention(false));
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -3846,6 +3916,18 @@ public:
|
||||
SdtWraper oSdt(1);
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkStart == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if ( c_oSerParType::BookmarkEnd == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -4003,6 +4085,19 @@ public:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadFldChar(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Logic::CFldChar* pFldChar = static_cast<OOX::Logic::CFldChar*>(poResult);
|
||||
if ( c_oSer_FldSimpleType::CharType == type )
|
||||
{
|
||||
pFldChar->m_oFldCharType.Init();
|
||||
pFldChar->m_oFldCharType->SetValue((SimpleTypes::EFldCharType)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadFldSimple(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
@ -4228,6 +4323,57 @@ public:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadBookmarkStart(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(poResult);
|
||||
if ( c_oSerBookmark::Id == type )
|
||||
{
|
||||
pBookmarkStart->m_oId.Init();
|
||||
pBookmarkStart->m_oId->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else if ( c_oSerBookmark::Name == type )
|
||||
{
|
||||
pBookmarkStart->m_sName.Init();
|
||||
pBookmarkStart->m_sName->append(m_oBufferedStream.GetString3(length));
|
||||
}
|
||||
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
|
||||
{
|
||||
pBookmarkStart->m_oDisplacedByCustomXml.Init();
|
||||
pBookmarkStart->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else if ( c_oSerBookmark::ColFirst == type )
|
||||
{
|
||||
pBookmarkStart->m_oColFirst.Init();
|
||||
pBookmarkStart->m_oColFirst->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else if ( c_oSerBookmark::ColLast == type )
|
||||
{
|
||||
pBookmarkStart->m_oColLast.Init();
|
||||
pBookmarkStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadBookmarkEnd(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(poResult);
|
||||
if ( c_oSerBookmark::Id == type )
|
||||
{
|
||||
pBookmarkEnd->m_oId.Init();
|
||||
pBookmarkEnd->m_oId->SetValue(m_oBufferedStream.GetLong());
|
||||
}
|
||||
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
|
||||
{
|
||||
pBookmarkEnd->m_oDisplacedByCustomXml.Init();
|
||||
pBookmarkEnd->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
|
||||
int ReadHyperlink(BYTE type, long length, void* poResult)
|
||||
{
|
||||
@ -4421,6 +4567,18 @@ public:
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadMathSSup, this, poResult);
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("</m:sSup>")));
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::BookmarkStart == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
GetRunStringWriter().WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if ( c_oSer_OMathContentType::BookmarkEnd == type )
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
GetRunStringWriter().WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -6629,7 +6787,7 @@ public:
|
||||
//сбрасываем Shd
|
||||
oBinary_tblPrReader.m_sCurTableShd.clear();
|
||||
}
|
||||
else if(c_oSerRunType::fldstart == type)
|
||||
else if(c_oSerRunType::fldstart_deprecated == type)
|
||||
{
|
||||
std::wstring sField(m_oBufferedStream.GetString3(length));
|
||||
sField = XmlUtils::EncodeXmlString(sField);
|
||||
@ -6643,7 +6801,7 @@ public:
|
||||
m_oCur_rPr.Write(&GetRunStringWriter());
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:fldChar w:fldCharType=\"separate\"/>")));
|
||||
}
|
||||
else if(c_oSerRunType::fldend == type)
|
||||
else if(c_oSerRunType::fldend_deprecated == type)
|
||||
{
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:fldChar w:fldCharType=\"end\"/>")));
|
||||
}
|
||||
@ -6692,6 +6850,28 @@ public:
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadEndnoteRef, this, &oEndnoteRef);
|
||||
GetRunStringWriter().WriteString(oEndnoteRef.toXML());
|
||||
}
|
||||
else if ( c_oSerRunType::fldChar == type)
|
||||
{
|
||||
OOX::Logic::CFldChar oFldChar;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadFldChar, this, &oFldChar);
|
||||
GetRunStringWriter().WriteString(oFldChar.toXML());
|
||||
}
|
||||
else if ( c_oSerRunType::instrText == type)
|
||||
{
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:instrText xml:space=\"preserve\">")));
|
||||
std::wstring sText(m_oBufferedStream.GetString3(length));
|
||||
sText = XmlUtils::EncodeXmlString(sText);
|
||||
GetRunStringWriter().WriteString(sText);
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("</w:instrText>")));
|
||||
}
|
||||
else if ( c_oSerRunType::delInstrText == type)
|
||||
{
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("<w:delInstrText xml:space=\"preserve\">")));
|
||||
std::wstring sText(m_oBufferedStream.GetString3(length));
|
||||
sText = XmlUtils::EncodeXmlString(sText);
|
||||
GetRunStringWriter().WriteString(sText);
|
||||
GetRunStringWriter().WriteString(std::wstring(_T("</w:delInstrText>")));
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -6790,7 +6970,7 @@ public:
|
||||
{
|
||||
CWiterTblPr oWiterTblPr;
|
||||
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
|
||||
pCStringWriter->WriteString(oWiterTblPr.Write(false, true));
|
||||
pCStringWriter->WriteString(oWiterTblPr.Write());
|
||||
}
|
||||
else if( c_oSerDocTableType::tblGrid == type )
|
||||
{
|
||||
@ -6862,6 +7042,18 @@ public:
|
||||
SdtWraper oSdt(2);
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkStart == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
pCStringWriter->WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkEnd == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
pCStringWriter->WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -6899,6 +7091,18 @@ public:
|
||||
SdtWraper oSdt(3);
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkStart == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkStart oBookmarkStart;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
|
||||
pCStringWriter->WriteString(oBookmarkStart.toXML());
|
||||
}
|
||||
else if (c_oSerDocTableType::BookmarkEnd == type)
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd oBookmarkEnd;
|
||||
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
|
||||
pCStringWriter->WriteString(oBookmarkEnd.toXML());
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
@ -7064,21 +7268,22 @@ public:
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(nChartIndex) + L".xlsx";
|
||||
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
|
||||
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
|
||||
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
|
||||
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
|
||||
{
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rIdXlsx;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rIdXlsx;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
|
||||
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
|
||||
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
|
||||
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
|
||||
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
}
|
||||
|
||||
//save chart.xml
|
||||
NSStringUtils::CStringBuilder sw;
|
||||
|
||||
@ -144,9 +144,13 @@ namespace MathEquation
|
||||
void AddAccent (MEMBELTYPE eType)
|
||||
{
|
||||
LONG lPos = GetSize() - 1;
|
||||
|
||||
if (lPos < 0) return;
|
||||
|
||||
EquationRun oRun;
|
||||
oRun = arrRun[lPos];
|
||||
RemoveElem(lPos);
|
||||
|
||||
oRun.bAccent = true;
|
||||
oRun.eType = eType;
|
||||
Add(oRun);
|
||||
@ -557,11 +561,11 @@ namespace MathEquation
|
||||
BYTE horAlign;
|
||||
switch(eHorAlign)
|
||||
{
|
||||
case matrixhoralignLeft: horAlign = SimpleTypes::xalignLeft;
|
||||
case matrixhoralignCenter: horAlign = SimpleTypes::xalignCenter;
|
||||
case matrixhoralignRight: horAlign = SimpleTypes::xalignRight;
|
||||
case matrixhoralignEqualSign: horAlign = SimpleTypes::xalignCenter;
|
||||
case matrixhoralignCommaSign: horAlign = SimpleTypes::xalignCenter;
|
||||
case matrixhoralignLeft: horAlign = SimpleTypes::xalignLeft; break;
|
||||
case matrixhoralignCenter: horAlign = SimpleTypes::xalignCenter; break;
|
||||
case matrixhoralignRight: horAlign = SimpleTypes::xalignRight; break;
|
||||
case matrixhoralignEqualSign: horAlign = SimpleTypes::xalignCenter; break;
|
||||
case matrixhoralignCommaSign: horAlign = SimpleTypes::xalignCenter; break;
|
||||
}
|
||||
WriteItemVal(BinDocxRW::c_oSer_OMathBottomNodesType::McJc, horAlign);
|
||||
|
||||
@ -614,7 +618,7 @@ namespace MathEquation
|
||||
nRows = m_aRowsCounter.top();
|
||||
m_aRowsCounter.pop();
|
||||
}
|
||||
int nPos = 0;
|
||||
int nPos = m_oStream.GetPosition();
|
||||
if (!m_aRowsPosCounter.empty())
|
||||
{
|
||||
nPos = m_aRowsPosCounter.top();
|
||||
@ -1675,7 +1679,7 @@ namespace MathEquation
|
||||
|
||||
void WriteEndNode(BinaryEquationWriter* pWriter)
|
||||
{
|
||||
int nCurPos;
|
||||
int nCurPos = -1;
|
||||
if (!m_aBaseStack.empty())
|
||||
{
|
||||
nCurPos = m_aBaseStack.top();
|
||||
@ -1687,14 +1691,20 @@ namespace MathEquation
|
||||
}
|
||||
|
||||
if (bPile && bEqArrayStart)
|
||||
{
|
||||
pWriter->WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if (!bPile && !bEqArrayStart)
|
||||
{
|
||||
pWriter->WriteItemEnd(nCurPos);
|
||||
}
|
||||
else if (!bPile && bEqArrayStart)
|
||||
{
|
||||
pWriter->m_aRowsCounter.push(nRows);
|
||||
bEqArrayStart = false;
|
||||
pWriter->WriteItemEnd(nCurPos);//eqArr
|
||||
|
||||
if (nCurPos > 0)
|
||||
pWriter->WriteItemEnd(nCurPos);//eqArr
|
||||
|
||||
if (!m_aBaseStack.empty())
|
||||
{
|
||||
|
||||
@ -344,7 +344,9 @@ extern int g_nCurFormatVersion;
|
||||
FramePr = 30,
|
||||
SectPr = 31,
|
||||
numPr_Ins = 32,
|
||||
pPrChange = 33
|
||||
pPrChange = 33,
|
||||
outlineLvl = 34,
|
||||
Tab_Item_Leader = 35
|
||||
};}
|
||||
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
|
||||
{
|
||||
@ -474,7 +476,11 @@ extern int g_nCurFormatVersion;
|
||||
MoveFromRangeStart = 18,
|
||||
MoveFromRangeEnd = 19,
|
||||
MoveToRangeStart = 20,
|
||||
MoveToRangeEnd = 21
|
||||
MoveToRangeEnd = 21,
|
||||
JsaProject = 22,
|
||||
BookmarkStart = 23,
|
||||
BookmarkEnd = 24
|
||||
|
||||
};}
|
||||
namespace c_oSerDocTableType{enum c_oSerDocTableType
|
||||
{
|
||||
@ -489,7 +495,9 @@ extern int g_nCurFormatVersion;
|
||||
Cell_Pr = 7,
|
||||
Cell_Content = 8,
|
||||
tblGridChange = 9,
|
||||
Sdt = 10
|
||||
Sdt = 10,
|
||||
BookmarkStart = 11,
|
||||
BookmarkEnd = 12
|
||||
};}
|
||||
namespace c_oSerRunType{enum c_oSerRunType
|
||||
{
|
||||
@ -502,8 +510,8 @@ extern int g_nCurFormatVersion;
|
||||
image = 6,
|
||||
table = 7,
|
||||
Content = 8,
|
||||
fldstart = 9,
|
||||
fldend = 10,
|
||||
fldstart_deprecated = 9,
|
||||
fldend_deprecated = 10,
|
||||
CommentReference = 11,
|
||||
pptxDrawing = 12,
|
||||
object = 14,
|
||||
@ -520,7 +528,10 @@ extern int g_nCurFormatVersion;
|
||||
endnoteRef = 25,
|
||||
footnoteReference = 26,
|
||||
endnoteReference = 27,
|
||||
arPr = 28
|
||||
arPr = 28,
|
||||
fldChar = 29,
|
||||
instrText = 30,
|
||||
delInstrText = 31
|
||||
};}
|
||||
namespace c_oSerVbaProjectTypes{enum c_oSerVbaProjectType
|
||||
{
|
||||
@ -895,7 +906,9 @@ extern int g_nCurFormatVersion;
|
||||
Ins = 62,
|
||||
Del = 63,
|
||||
columnbreak = 64,
|
||||
ARPr = 65
|
||||
ARPr = 65,
|
||||
BookmarkStart = 66,
|
||||
BookmarkEnd = 67
|
||||
};}
|
||||
namespace c_oSer_FramePrType{ enum c_oSer_FramePrType
|
||||
{
|
||||
@ -928,7 +941,8 @@ extern int g_nCurFormatVersion;
|
||||
{
|
||||
Content = 0,
|
||||
Instr = 1,
|
||||
FFData = 2
|
||||
FFData = 2,
|
||||
CharType = 3
|
||||
};}
|
||||
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
|
||||
{
|
||||
@ -1099,6 +1113,14 @@ extern int g_nCurFormatVersion;
|
||||
Name = 6,
|
||||
UserId = 7
|
||||
};}
|
||||
namespace c_oSerBookmark{enum c_oSerBookmark
|
||||
{
|
||||
Id = 0,
|
||||
Name = 1,
|
||||
DisplacedByCustomXml = 2,
|
||||
ColFirst = 3,
|
||||
ColLast = 4
|
||||
};}
|
||||
}
|
||||
|
||||
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
|
||||
|
||||
@ -76,18 +76,6 @@ namespace BinDocxRW
|
||||
{
|
||||
}
|
||||
};
|
||||
class FldStruct
|
||||
{
|
||||
protected:
|
||||
int m_nType;
|
||||
public:
|
||||
std::wstring m_sFld;
|
||||
FldStruct(std::wstring sFld, int nType):m_sFld(sFld),m_nType(nType){}
|
||||
int GetType()
|
||||
{
|
||||
return m_nType;
|
||||
}
|
||||
};
|
||||
class BinaryCommonWriter
|
||||
{
|
||||
public:
|
||||
@ -1024,6 +1012,12 @@ namespace BinDocxRW
|
||||
WritePPrChange(pPr.m_oPPrChange.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if(pPr.m_oOutlineLvl.IsInit() && pPr.m_oOutlineLvl->m_oVal.IsInit())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::outlineLvl);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
|
||||
m_oBcw.m_oStream.WriteLONG(pPr.m_oOutlineLvl->m_oVal->GetValue());
|
||||
}
|
||||
//SectPr
|
||||
if(NULL != m_oBinaryHeaderFooterTableWriter && pPr.m_oSectPr.IsInit())
|
||||
{
|
||||
@ -1185,6 +1179,12 @@ namespace BinDocxRW
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
|
||||
m_oBcw.m_oStream.WriteDouble(TabItem.m_oPos.get().ToMm());
|
||||
}
|
||||
if(false != TabItem.m_oLeader.IsInit())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Tab_Item_Leader);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
|
||||
m_oBcw.m_oStream.WriteBYTE((BYTE)TabItem.m_oLeader->GetValue());
|
||||
}
|
||||
}
|
||||
void WriteNumPr(const OOX::Logic::CNumPr& numPr, const OOX::Logic::CParagraphProperty& pPr)
|
||||
{
|
||||
@ -2104,14 +2104,11 @@ namespace BinDocxRW
|
||||
SimpleTypes::EHeightRule eHRule = SimpleTypes::heightruleAtLeast;
|
||||
if(rowHeight.m_oHRule.IsInit())
|
||||
eHRule = rowHeight.m_oHRule->GetValue();
|
||||
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::Height_Rule);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
|
||||
switch(eHRule)
|
||||
{
|
||||
case SimpleTypes::heightruleAtLeast :
|
||||
case SimpleTypes::heightruleExact :m_oBcw.m_oStream.WriteBYTE(heightrule_AtLeast);break;
|
||||
default :m_oBcw.m_oStream.WriteBYTE(heightrule_Auto);break;
|
||||
}
|
||||
m_oBcw.m_oStream.WriteBYTE(eHRule);
|
||||
|
||||
|
||||
//Value
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::Height_Value);
|
||||
@ -2986,17 +2983,13 @@ namespace BinDocxRW
|
||||
std::wstring m_sCurParStyle;
|
||||
OOX::CSettings* m_oSettings;
|
||||
|
||||
//для fldChar
|
||||
//todo в документации описан случай если нет fldchartypeEnd, у нас работает не так.
|
||||
std::vector<FldStruct*> m_aFldChars;
|
||||
std::wstring m_sFldChar;
|
||||
SimpleTypes::EFldCharType m_eFldState;
|
||||
NSBinPptxRW::CDrawingConverter* m_pOfficeDrawingConverter;
|
||||
std::map<int, bool>* m_mapIgnoreComments;
|
||||
public:
|
||||
Binary_tblPrWriter btblPrs;
|
||||
OOX::Logic::CSectionProperty* pSectPr;
|
||||
OOX::Logic::CBackground * pBackground;
|
||||
OOX::CDocument* poDocument;
|
||||
|
||||
bool m_bWriteSectPr;//Записывать ли свойства верхнего уровня в данном экземпляре BinaryOtherTableWriter
|
||||
//---------------------------------
|
||||
@ -3005,15 +2998,8 @@ namespace BinDocxRW
|
||||
{
|
||||
pBackground = NULL;
|
||||
pSectPr = NULL;
|
||||
poDocument = NULL;
|
||||
m_bWriteSectPr = false;
|
||||
m_eFldState = SimpleTypes::fldchartypeEnd;
|
||||
}
|
||||
~BinaryDocumentTableWriter()
|
||||
{
|
||||
for(size_t i = 0, length = m_aFldChars.size(); i < length; ++i)
|
||||
{
|
||||
RELEASEOBJECT(m_aFldChars[i]);
|
||||
}
|
||||
}
|
||||
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, OOX::IFileContainer *rels, std::vector<std::wstring>& aShapeTypes)
|
||||
{
|
||||
@ -3089,6 +3075,20 @@ namespace BinDocxRW
|
||||
OOX::Logic::CBdo* pBdo = static_cast<OOX::Logic::CBdo*>(item);
|
||||
WriteDocumentContent(pBdo->m_arrItems);
|
||||
}break;
|
||||
case OOX::et_w_bookmarkStart:
|
||||
{
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkStart);
|
||||
WriteBookmarkStart(*pBookmarkStart);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}break;
|
||||
case OOX::et_w_bookmarkEnd:
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkEnd);
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -3109,6 +3109,23 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
//Write JsaProject
|
||||
if (NULL != poDocument)
|
||||
{
|
||||
smart_ptr<OOX::File> pFile = poDocument->Get(OOX::FileTypes::JsaProject);
|
||||
if (pFile.IsInit() && OOX::FileTypes::JsaProject == pFile->type())
|
||||
{
|
||||
OOX::JsaProject& jsaProject = pFile.as<OOX::JsaProject>();
|
||||
BYTE* pData = NULL;
|
||||
DWORD nBytesCount;
|
||||
if(NSFile::CFileBinary::ReadAllBytes(jsaProject.filename().GetPath(), &pData, nBytesCount))
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
|
||||
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void WriteBackground (OOX::Logic::CBackground* pBackground)
|
||||
{
|
||||
@ -3163,24 +3180,6 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
|
||||
}
|
||||
FldStruct* ParseField(const std::wstring& sFld)
|
||||
{
|
||||
std::wstring sFldCopy = sFld;
|
||||
|
||||
boost::algorithm::trim (sFldCopy);
|
||||
boost::algorithm::to_upper (sFldCopy);
|
||||
|
||||
FldStruct* pRes = NULL;
|
||||
int nIndex = 0;
|
||||
|
||||
if(-1 != (nIndex = (int)sFldCopy.find(_T("TOC"))))
|
||||
pRes = new FldStruct(sFldCopy, fieldstruct_toc);
|
||||
else if(-1 != (nIndex = (int)sFldCopy.find(_T("HYPERLINK"))))
|
||||
pRes = new FldStruct(sFldCopy, fieldstruct_hyperlink);
|
||||
else
|
||||
pRes = new FldStruct(sFldCopy, fieldstruct_none);
|
||||
return pRes;
|
||||
}
|
||||
void WriteParagraphContent(const std::vector<OOX::WritingElement *>& Content, bool bHyperlink = false)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
@ -3280,6 +3279,22 @@ namespace BinDocxRW
|
||||
WriteComment(OOX::et_w_commentRangeEnd, pCommentRangeEnd->m_oId);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_bookmarkStart:
|
||||
{
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkStart);
|
||||
WriteBookmarkStart(*pBookmarkStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_bookmarkEnd:
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::BookmarkEnd);
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
//todo moveRange on all levels(body, p ...)
|
||||
// case OOX::et_w_moveFromRangeStart:
|
||||
// {
|
||||
@ -3459,6 +3474,16 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteFldChar(OOX::Logic::CFldChar* pFldChar)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if(pFldChar->m_oFldCharType.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_FldSimpleType::CharType);
|
||||
m_oBcw.m_oStream.WriteBYTE((BYTE)pFldChar->m_oFldCharType->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteFldSimple(OOX::Logic::CFldSimple* pFldSimple)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
@ -3610,7 +3635,7 @@ namespace BinDocxRW
|
||||
m_oBcw.m_oStream.WriteLONG(oDDList.m_oResult->m_oVal->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
for(int i = 0 ; i < oDDList.m_arrListEntry.size(); ++i)
|
||||
for(size_t i = 0 ; i < oDDList.m_arrListEntry.size(); ++i)
|
||||
{
|
||||
ComplexTypes::Word::String* pVal = oDDList.m_arrListEntry[i];
|
||||
if(pVal->m_sVal.IsInit())
|
||||
@ -3681,11 +3706,60 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteBookmarkStart(const OOX::Logic::CBookmarkStart& oBookmarkStart)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (oBookmarkStart.m_oId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::Id);
|
||||
m_oBcw.m_oStream.WriteLONG(oBookmarkStart.m_oId->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oBookmarkStart.m_sName.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::Name);
|
||||
m_oBcw.m_oStream.WriteStringW3(oBookmarkStart.m_sName.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oBookmarkStart.m_oDisplacedByCustomXml.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::DisplacedByCustomXml);
|
||||
m_oBcw.m_oStream.WriteBYTE((BYTE)oBookmarkStart.m_oDisplacedByCustomXml->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oBookmarkStart.m_oColFirst.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::ColFirst);
|
||||
m_oBcw.m_oStream.WriteLONG(oBookmarkStart.m_oColFirst->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oBookmarkStart.m_oColLast.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::ColLast);
|
||||
m_oBcw.m_oStream.WriteLONG(oBookmarkStart.m_oColLast->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteBookmarkEnd(const OOX::Logic::CBookmarkEnd& oBookmarkEnd)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (oBookmarkEnd.m_oId.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::Id);
|
||||
m_oBcw.m_oStream.WriteLONG(oBookmarkEnd.m_oId->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oBookmarkEnd.m_oDisplacedByCustomXml.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerBookmark::DisplacedByCustomXml);
|
||||
m_oBcw.m_oStream.WriteBYTE((BYTE)oBookmarkEnd.m_oDisplacedByCustomXml->GetValue());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
|
||||
void WriteHyperlink(OOX::Logic::CHyperlink* pHyperlink)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
std::wstring sField;
|
||||
std::wstring sLink;
|
||||
if(pHyperlink->m_oId.IsInit())
|
||||
{
|
||||
@ -3698,24 +3772,20 @@ namespace BinDocxRW
|
||||
}
|
||||
}
|
||||
|
||||
if(!sLink.empty())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Hyperlink);
|
||||
WriteHyperlinkContent(sLink, pHyperlink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteParagraphContent(pHyperlink->m_arrItems, true);
|
||||
}
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::Hyperlink);
|
||||
WriteHyperlinkContent(sLink, pHyperlink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
void WriteHyperlinkContent(std::wstring& sLink, OOX::Logic::CHyperlink* pHyperlink)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
//Link
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Link);
|
||||
m_oBcw.m_oStream.WriteStringW3(sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
if(!sLink.empty())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_HyperlinkType::Link);
|
||||
m_oBcw.m_oStream.WriteStringW3(sLink);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
//Anchor
|
||||
if(pHyperlink->m_sAnchor.IsInit())
|
||||
{
|
||||
@ -4118,6 +4188,22 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_bookmarkStart:
|
||||
{
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::BookmarkStart);
|
||||
WriteBookmarkStart(*pBookmarkStart);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_bookmarkEnd:
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::BookmarkEnd);
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -5416,51 +5502,6 @@ namespace BinDocxRW
|
||||
int nCurPos = 0;
|
||||
OOX::Logic::CRunProperty* oCur_rPr = pRun->m_oRunProperty;
|
||||
|
||||
if(NULL != oCur_rPr)
|
||||
{
|
||||
//Заглушка для содержания
|
||||
if(false == bHyperlink)
|
||||
{
|
||||
//Случай если Hyperlink задан как field
|
||||
for(size_t i = 0, length = m_aFldChars.size(); i < length; ++i)
|
||||
{
|
||||
if(fieldstruct_hyperlink == m_aFldChars[i]->GetType())
|
||||
{
|
||||
bHyperlink = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bHyperlink)
|
||||
{
|
||||
bool bInTOC = false;
|
||||
for(size_t i = 0, length = m_aFldChars.size(); i < length; ++i)
|
||||
{
|
||||
if(fieldstruct_toc == m_aFldChars[i]->GetType())
|
||||
{
|
||||
bInTOC = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(bInTOC)
|
||||
{
|
||||
//убираем Runstyle
|
||||
if(oCur_rPr->m_oRStyle.IsInit())
|
||||
oCur_rPr->m_oRStyle.reset();
|
||||
//Если настройки выставлены явно, то убираем их
|
||||
if(oCur_rPr->m_oColor.IsInit() && oCur_rPr->m_oColor->m_oVal.IsInit() && SimpleTypes::hexcolorRGB == oCur_rPr->m_oColor->m_oVal->GetValue())
|
||||
{
|
||||
unsigned char bR = oCur_rPr->m_oColor->m_oVal->Get_R();
|
||||
unsigned char bG = oCur_rPr->m_oColor->m_oVal->Get_G();
|
||||
unsigned char bB = oCur_rPr->m_oColor->m_oVal->Get_B();
|
||||
if(0x00 == bR && 0x00 == bG && 0xFF == bB)
|
||||
oCur_rPr->m_oColor->m_oVal->Set_B(0x00);
|
||||
}
|
||||
if(oCur_rPr->m_oU.IsInit() && oCur_rPr->m_oU->m_oVal.IsInit() && SimpleTypes::underlineSingle == oCur_rPr->m_oU->m_oVal->GetValue())
|
||||
oCur_rPr->m_oU->m_oVal->SetValue(SimpleTypes::underlineNone);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Если первый элемент символ надо выставить в его настройки шрифт
|
||||
if(nIndexStart < (int)pRun->m_arrItems.size() && OOX::et_w_sym == pRun->m_arrItems[nIndexStart]->getType())
|
||||
{
|
||||
@ -5537,51 +5578,21 @@ namespace BinDocxRW
|
||||
case OOX::et_w_fldChar:
|
||||
{
|
||||
OOX::Logic::CFldChar* pFldChar = static_cast<OOX::Logic::CFldChar*>(item);
|
||||
if(pFldChar->m_oFldCharType.IsInit())
|
||||
{
|
||||
if(SimpleTypes::fldchartypeBegin == pFldChar->m_oFldCharType.get().GetValue())
|
||||
{
|
||||
m_eFldState = SimpleTypes::fldchartypeBegin;
|
||||
m_sFldChar.clear();
|
||||
}
|
||||
else if(SimpleTypes::fldchartypeEnd == pFldChar->m_oFldCharType.get().GetValue())
|
||||
{
|
||||
m_eFldState = SimpleTypes::fldchartypeEnd;
|
||||
if(m_aFldChars.size() > 0)
|
||||
{
|
||||
int nIndex = (int)m_aFldChars.size() - 1;
|
||||
FldStruct* pFldStruct = m_aFldChars[nIndex];
|
||||
RELEASEOBJECT(pFldStruct);
|
||||
m_aFldChars.erase(m_aFldChars.begin() + nIndex);
|
||||
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::fldend);
|
||||
m_oBcw.m_oStream.WriteLONG(c_oSerPropLenType::Null);
|
||||
}
|
||||
}
|
||||
else if(SimpleTypes::fldchartypeSeparate == pFldChar->m_oFldCharType.get().GetValue())
|
||||
{
|
||||
m_eFldState = SimpleTypes::fldchartypeSeparate;
|
||||
FldStruct* pFldStruct = ParseField(m_sFldChar);
|
||||
m_aFldChars.push_back(pFldStruct);
|
||||
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::fldstart);
|
||||
m_oBcw.m_oStream.WriteStringW(m_sFldChar);
|
||||
}
|
||||
}
|
||||
int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::fldChar);
|
||||
WriteFldChar(pFldChar);
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
break;
|
||||
case OOX::et_w_delInstrText:
|
||||
{
|
||||
OOX::Logic::CDelInstrText* pInstrText = static_cast<OOX::Logic::CDelInstrText*>(item);
|
||||
WriteText(pInstrText->m_sText, c_oSerRunType::delInstrText);
|
||||
}
|
||||
break;
|
||||
case OOX::et_w_instrText:
|
||||
{
|
||||
OOX::Logic::CInstrText* pInstrText = static_cast<OOX::Logic::CInstrText*>(item);
|
||||
if(SimpleTypes::fldchartypeBegin == m_eFldState)
|
||||
m_sFldChar += pInstrText->m_sText;
|
||||
else
|
||||
{
|
||||
if(!pInstrText->m_sText.empty())
|
||||
{
|
||||
WriteText(pInstrText->m_sText);
|
||||
}
|
||||
}
|
||||
WriteText(pInstrText->m_sText, c_oSerRunType::instrText);
|
||||
}
|
||||
break;
|
||||
case OOX::et_w_nonBreakHyphen:
|
||||
@ -5613,25 +5624,19 @@ namespace BinDocxRW
|
||||
OOX::Logic::CSym* oSym = static_cast<OOX::Logic::CSym*>(item);
|
||||
wchar_t ch = 0x0FFF & oSym->m_oChar->GetValue();
|
||||
std::wstring sText(&ch, 1);
|
||||
WriteText(sText);
|
||||
WriteText(sText, c_oSerRunType::run);
|
||||
break;
|
||||
}
|
||||
case OOX::et_w_delText:
|
||||
{
|
||||
std::wstring& sText = static_cast<OOX::Logic::CDelText*>(item)->m_sText;
|
||||
if(!sText.empty())
|
||||
{
|
||||
WriteDelText(sText);
|
||||
}
|
||||
WriteText(sText, c_oSerRunType::delText);
|
||||
}
|
||||
break;
|
||||
case OOX::et_w_t:
|
||||
{
|
||||
std::wstring& sText = static_cast<OOX::Logic::CText*>(item)->m_sText;
|
||||
if(!sText.empty())
|
||||
{
|
||||
WriteText(sText);
|
||||
}
|
||||
WriteText(sText, c_oSerRunType::run);
|
||||
}
|
||||
break;
|
||||
case OOX::et_w_tab:
|
||||
@ -5721,19 +5726,15 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
void WriteDelText(const std::wstring& text)
|
||||
void WriteText(const std::wstring& text, BYTE type)
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::delText);
|
||||
m_oBcw.m_oStream.WriteStringW(text.c_str());
|
||||
if(NULL != m_oBcw.m_pEmbeddedFontsManager)
|
||||
m_oBcw.m_pEmbeddedFontsManager->CheckString(text);
|
||||
}
|
||||
void WriteText(const std::wstring& text)
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerRunType::run);
|
||||
m_oBcw.m_oStream.WriteStringW(text);
|
||||
if(NULL != m_oBcw.m_pEmbeddedFontsManager)
|
||||
m_oBcw.m_pEmbeddedFontsManager->CheckString(text);
|
||||
if(!text.empty())
|
||||
{
|
||||
m_oBcw.m_oStream.WriteBYTE(type);
|
||||
m_oBcw.m_oStream.WriteStringW(text);
|
||||
if(NULL != m_oBcw.m_pEmbeddedFontsManager)
|
||||
m_oBcw.m_pEmbeddedFontsManager->CheckString(text);
|
||||
}
|
||||
}
|
||||
void WriteDrawingPptx(OOX::WritingElement* item)
|
||||
{
|
||||
@ -6744,6 +6745,20 @@ namespace BinDocxRW
|
||||
OOX::Logic::CBdo* pBdo = static_cast<OOX::Logic::CBdo*>(item);
|
||||
WriteTableContent(pBdo->m_arrItems, pTblPr, nRows, nCols);
|
||||
}
|
||||
else if(OOX::et_w_bookmarkStart == item->getType())
|
||||
{
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkStart);
|
||||
WriteBookmarkStart(*pBookmarkStart);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_bookmarkEnd == item->getType())
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkEnd);
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
void WriteRow(const OOX::Logic::CTr& Row, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nRows, int nCols)
|
||||
@ -6804,6 +6819,20 @@ namespace BinDocxRW
|
||||
OOX::Logic::CBdo* pBdo = static_cast<OOX::Logic::CBdo*>(item);
|
||||
WriteRowContent(pBdo->m_arrItems, pTblPr, nCurRowIndex, nRows, nCols);
|
||||
}
|
||||
else if(OOX::et_w_bookmarkStart == item->getType())
|
||||
{
|
||||
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkStart);
|
||||
WriteBookmarkStart(*pBookmarkStart);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
else if(OOX::et_w_bookmarkEnd == item->getType())
|
||||
{
|
||||
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(item);
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::BookmarkEnd);
|
||||
WriteBookmarkEnd(*pBookmarkEnd);
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
void WriteCell(OOX::Logic::CTc& tc, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nCurColIndex, int nRows, int nCols)
|
||||
@ -7880,6 +7909,7 @@ namespace BinDocxRW
|
||||
|
||||
oBinaryDocumentTableWriter.pSectPr = pFirstSectPr;
|
||||
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
|
||||
oBinaryDocumentTableWriter.poDocument = poDocument;
|
||||
|
||||
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
|
||||
//Write Vba
|
||||
|
||||
@ -658,8 +658,7 @@ namespace BinXlsxRW{
|
||||
std::wstring wb, sheetFrom, sheetTo;
|
||||
int nRow1, nCol1, nRow2, nCol2;
|
||||
if(OOX::Spreadsheet::CCell::parse3DRef(*pStrRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
|
||||
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() &&
|
||||
NULL != pStrRef->m_strCache)
|
||||
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pStrRef->m_strCache)
|
||||
{
|
||||
bool bRow = nRow1 == nRow2;
|
||||
if(bUpdateRange)
|
||||
@ -727,7 +726,7 @@ namespace BinXlsxRW{
|
||||
std::wstring wb, sheetFrom, sheetTo;
|
||||
int nRow1, nCol1, nRow2, nCol2;
|
||||
if(OOX::Spreadsheet::CCell::parse3DRef(*pNumRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
|
||||
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
|
||||
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
|
||||
{
|
||||
bool bRow = nRow1 == nRow2;
|
||||
if(bUpdateRange)
|
||||
|
||||
@ -181,20 +181,22 @@ namespace BinXlsxRW{
|
||||
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
|
||||
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
|
||||
|
||||
writeChartXlsx(sXlsxPath, oChartSpace);
|
||||
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
if (writeChartXlsx(sXlsxPath, oChartSpace))
|
||||
{
|
||||
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
|
||||
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rId;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
|
||||
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
|
||||
long rId;
|
||||
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
|
||||
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
|
||||
|
||||
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
|
||||
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring strFilepath = sFilepath;
|
||||
@ -233,7 +235,7 @@ namespace BinXlsxRW{
|
||||
m_bIsNoBase64 = bIsNoBase64;
|
||||
}
|
||||
|
||||
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
|
||||
bool CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
|
||||
{
|
||||
//анализируем chart
|
||||
BinXlsxRW::ChartWriter helper;
|
||||
@ -252,11 +254,15 @@ namespace BinXlsxRW{
|
||||
helper.toXlsx(oXlsx);
|
||||
//write
|
||||
OOX::CContentTypes oContentTypes;
|
||||
oXlsx.Write(oPath, oContentTypes);
|
||||
//zip
|
||||
COfficeUtils oOfficeUtils(NULL);
|
||||
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
|
||||
bool res = oXlsx.Write(oPath, oContentTypes);
|
||||
if (res)
|
||||
{
|
||||
//zip
|
||||
COfficeUtils oOfficeUtils(NULL);
|
||||
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
|
||||
}
|
||||
//clean
|
||||
NSDirectory::DeleteDirectory(sTempDir);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
@ -72,7 +72,7 @@ namespace BinXlsxRW {
|
||||
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
|
||||
void setIsNoBase64 (bool bIsNoBase64);
|
||||
|
||||
void writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
|
||||
bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
|
||||
};
|
||||
}
|
||||
#endif // #ifndef XLSX_SERIALIZER
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
@ -356,6 +356,10 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
|
||||
>
|
||||
|
||||
@ -154,7 +154,7 @@ namespace cpdoccore
|
||||
if (val)
|
||||
{
|
||||
std::wstring tmp = *val;
|
||||
XmlUtils::GetLower(tmp);
|
||||
tmp = XmlUtils::GetLower(tmp);
|
||||
return optional<bool>::Type((tmp == xml_char_value_type::trueVal));
|
||||
}
|
||||
else
|
||||
|
||||
@ -555,7 +555,6 @@ HEADERS += \
|
||||
../src/docx/xlsx_xf.h \
|
||||
../include/logging.h \
|
||||
../include/cpdoccore/CPColorUtils.h \
|
||||
../include/cpdoccore/CPHash.h \
|
||||
../include/cpdoccore/CPNoncopyable.h \
|
||||
../include/cpdoccore/CPOptional.h \
|
||||
../include/cpdoccore/CPScopedPtr.h \
|
||||
|
||||
@ -224,8 +224,9 @@ public:
|
||||
bool & get_use_image_replace()
|
||||
{
|
||||
bool res = false;
|
||||
if (frames_.size()>0) return frames_.back().use_image_replace;
|
||||
else return res;
|
||||
if (!frames_.empty()) return frames_.back().use_image_replace;
|
||||
else
|
||||
throw;
|
||||
}
|
||||
|
||||
std::wstring & get_text_stream_shape()
|
||||
|
||||
@ -48,13 +48,19 @@ _CP_PTR(oox_axis_content) oox_axis_content::create(int type)
|
||||
|
||||
oox_axis_content::oox_axis_content(int type/*,std::wstring name*/)
|
||||
{
|
||||
//id_ = abs((int)*((_UINT32*)this));
|
||||
id_ = abs((long)this);
|
||||
type_=type; //dimension
|
||||
if (type == 0)
|
||||
{
|
||||
id_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
id_ = abs((long)this);
|
||||
}
|
||||
type_ = type;
|
||||
}
|
||||
void oox_axis_content::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
if (id_ <0 )return;//not activate
|
||||
if (id_ < 1 )return; //not activate, blank axis
|
||||
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
|
||||
@ -153,7 +153,7 @@ void oox_chart_context::serialize(std::wostream & strm)
|
||||
}
|
||||
CP_XML_NODE(L"c:dispBlanksAs")
|
||||
{
|
||||
CP_XML_ATTR(L"val", L"zero");
|
||||
CP_XML_ATTR(L"val", plot_area_.current_chart_->dispBlanksAs_);
|
||||
}
|
||||
CP_XML_NODE(L"c:showDLblsOverMax")
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
#include <boost/functional.hpp>
|
||||
#include <cpdoccore/CPHash.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include "oox_chart_legend.h"
|
||||
|
||||
@ -250,7 +250,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
|
||||
CP_XML_CONTENT(values_[i].numRef_.formula);
|
||||
}
|
||||
|
||||
if (values_[i].numRef_.num_cache_count>0)
|
||||
if (values_[i].numRef_.num_cache_count > 0)
|
||||
{
|
||||
CP_XML_NODE(L"c:numCache")
|
||||
{
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
*/
|
||||
#include <boost/functional.hpp>
|
||||
#include <cpdoccore/CPHash.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include "oox_chart_shape.h"
|
||||
|
||||
@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
|
||||
namespace oox
|
||||
{
|
||||
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
|
||||
base_font_size_(12), fonts_container_(fonts)
|
||||
base_font_size_(12), fonts_container_(fonts), is_need_e_(false)
|
||||
{
|
||||
graphRPR_ = graphic;
|
||||
|
||||
|
||||
@ -106,6 +106,8 @@ namespace oox {
|
||||
|
||||
std::wstring nsRPr_;
|
||||
bool graphRPR_;
|
||||
|
||||
bool is_need_e_;
|
||||
private:
|
||||
std::wstringstream math_stream_;
|
||||
std::wstringstream math_style_stream_;
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <cpdoccore/CPHash.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include "oox_data_labels.h"
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include "oox_layout.h"
|
||||
#include <boost/functional.hpp>
|
||||
#include <cpdoccore/CPHash.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include "../odf/style_text_properties.h"
|
||||
|
||||
|
||||
@ -31,10 +31,10 @@
|
||||
*/
|
||||
|
||||
#include "oox_plot_area.h"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/functional.hpp>
|
||||
#include <cpdoccore/CPHash.h>
|
||||
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include "../odf/style_text_properties.h"
|
||||
|
||||
#include "oox_chart_shape.h"
|
||||
@ -90,7 +90,7 @@ void oox_plot_area::add_chart(int type)
|
||||
|
||||
void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
|
||||
{
|
||||
oox_axis_content_ptr ax=oox_axis_content::create(type);
|
||||
oox_axis_content_ptr ax = oox_axis_content::create(type);
|
||||
ax->content_ = content;
|
||||
|
||||
axis_.push_back(ax);
|
||||
@ -98,21 +98,25 @@ void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
|
||||
|
||||
void oox_plot_area::reset_cross_axis()//обязательно после всех добавлений
|
||||
{
|
||||
BOOST_FOREACH(oox_axis_content_ptr const & ax, axis_)
|
||||
for (size_t i = 0; i < axis_.size(); i++)
|
||||
{
|
||||
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
|
||||
for (size_t j = 0; j < charts_.size(); j++)
|
||||
{
|
||||
ch->add_axis(ax->get_Id());
|
||||
charts_[j]->add_axis(axis_[i]->get_Id());
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
|
||||
{
|
||||
int curr_id = a->get_Id();
|
||||
BOOST_FOREACH(oox_axis_content_ptr const & b, axis_)
|
||||
{
|
||||
if (b->get_Id()==curr_id)continue;
|
||||
b->add_CrossedId(curr_id);
|
||||
for (size_t i = 0; i < axis_.size(); i++)
|
||||
{
|
||||
int curr_id = axis_[i]->get_Id();
|
||||
|
||||
if (curr_id < 1) continue;
|
||||
|
||||
for (size_t j = 0; j < axis_.size(); j++)
|
||||
{
|
||||
if (axis_[j]->get_Id() == curr_id)continue;
|
||||
|
||||
axis_[j]->add_CrossedId(curr_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,18 +134,18 @@ void oox_plot_area::oox_serialize(std::wostream & _Wostream)
|
||||
//CP_XML_NODE(L"c:layout"){}
|
||||
bool axisPresent = true;
|
||||
|
||||
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
|
||||
{
|
||||
ch->oox_serialize(CP_XML_STREAM());
|
||||
for (size_t i = 0; i < charts_.size(); i++)
|
||||
{
|
||||
charts_[i]->oox_serialize(CP_XML_STREAM());
|
||||
|
||||
if (ch->type_ == CHART_TYPE_PIE ||
|
||||
ch->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
|
||||
if (charts_[i]->type_ == CHART_TYPE_PIE ||
|
||||
charts_[i]->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
|
||||
}
|
||||
if (axisPresent)
|
||||
{
|
||||
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
|
||||
{
|
||||
a->oox_serialize(CP_XML_STREAM());
|
||||
for (size_t i = 0; i < axis_.size(); i++)
|
||||
{
|
||||
axis_[i]->oox_serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
shape.oox_serialize(CP_XML_STREAM());
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include "oox_title.h"
|
||||
#include <boost/functional.hpp>
|
||||
#include <cpdoccore/CPHash.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include "../odf/style_text_properties.h"
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ void oox_chart::set_content_series(odf_reader::chart::series & content)
|
||||
}
|
||||
void oox_chart::set_values_series(int ind, std::vector<std::wstring> & val)
|
||||
{
|
||||
if (val.size()<1)return;
|
||||
if (val.empty())return;
|
||||
|
||||
oox_series_ptr & current_ptr = series_.back();
|
||||
current_ptr->setValues (ind, val);
|
||||
@ -74,9 +74,11 @@ void oox_chart::set_properties(std::vector<odf_reader::_property> g)
|
||||
|
||||
_CP_OPT(bool) bStacked;
|
||||
_CP_OPT(bool) bPercent;
|
||||
_CP_OPT(int) iGapWidth;
|
||||
|
||||
odf_reader::GetProperty(g, L"stacked",bStacked);
|
||||
odf_reader::GetProperty(g, L"percentage",bPercent);
|
||||
odf_reader::GetProperty(g, L"stacked", bStacked);
|
||||
odf_reader::GetProperty(g, L"percentage", bPercent);
|
||||
odf_reader::GetProperty(g, L"gap-width", iGapWidth);
|
||||
|
||||
if ( (bStacked) && (bStacked.get()))
|
||||
{
|
||||
@ -87,6 +89,10 @@ void oox_chart::set_properties(std::vector<odf_reader::_property> g)
|
||||
{
|
||||
grouping_ = L"percentStacked";
|
||||
}
|
||||
if (iGapWidth)
|
||||
{
|
||||
dispBlanksAs_ = L"gap";
|
||||
}
|
||||
//solid-type - трехмерные
|
||||
}
|
||||
void oox_chart::oox_serialize_common(std::wostream & _Wostream)
|
||||
@ -128,17 +134,15 @@ void oox_bar_chart::set_properties(std::vector<odf_reader::_property> g)
|
||||
{
|
||||
oox_chart::set_properties(g);
|
||||
|
||||
odf_reader::GetProperty(g, L"vertical",bVertical);
|
||||
odf_reader::GetProperty(g, L"connect-bars",bConnectBars);
|
||||
odf_reader::GetProperty(g, L"vertical", bVertical);
|
||||
odf_reader::GetProperty(g, L"connect-bars", bConnectBars);
|
||||
|
||||
odf_reader::GetProperty(g, L"gap-width",iGapWidth);
|
||||
odf_reader::GetProperty(g, L"overlap",iOverlap);
|
||||
odf_reader::GetProperty(g, L"gap-width", iGapWidth);
|
||||
odf_reader::GetProperty(g, L"overlap", iOverlap);
|
||||
}
|
||||
|
||||
void oox_bar_chart::set_additional_properties(std::vector<odf_reader::_property> g)
|
||||
{
|
||||
odf_reader::GetProperty(g, L"gap-width",iGapWidth);
|
||||
odf_reader::GetProperty(g, L"overlap",iOverlap);
|
||||
}
|
||||
|
||||
void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
|
||||
@ -169,13 +173,13 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:overlap")//-100 to 100
|
||||
{
|
||||
CP_XML_ATTR(L"val",Overlap);
|
||||
CP_XML_ATTR(L"val", Overlap);
|
||||
}
|
||||
if (iGapWidth)
|
||||
{
|
||||
CP_XML_NODE(L"c:gapWidth")
|
||||
{
|
||||
CP_XML_ATTR(L"val",iGapWidth.get());
|
||||
CP_XML_ATTR(L"val", iGapWidth.get());
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
|
||||
@ -63,9 +63,10 @@ public:
|
||||
|
||||
oox_chart()
|
||||
{
|
||||
grouping_ = L"standard";
|
||||
is3D_ = false;
|
||||
type_ = 0;
|
||||
grouping_ = L"standard";
|
||||
is3D_ = false;
|
||||
type_ = 0;
|
||||
dispBlanksAs_ = L"zero";
|
||||
}
|
||||
~oox_chart(){}
|
||||
|
||||
@ -98,9 +99,10 @@ public:
|
||||
|
||||
int type_;
|
||||
bool is3D_;
|
||||
std::vector<int> axisId_; //axId (Axis ID) §21.2.2.9
|
||||
std::wstring dispBlanksAs_;
|
||||
std::vector<int> axisId_; // axId (Axis ID) §21.2.2.9
|
||||
std::wstring grouping_; // clustered | percentStacked | stacked | standard
|
||||
std::vector<oox_series_ptr> series_; //ser (Bar Chart Series) §21.2.2.170
|
||||
std::vector<oox_series_ptr> series_; // ser (Bar Chart Series) §21.2.2.170
|
||||
|
||||
virtual void set_properties(std::vector<odf_reader::_property> g);
|
||||
virtual void set_additional_properties(std::vector<odf_reader::_property> g){}
|
||||
|
||||
@ -753,10 +753,10 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"spd",impl_->transition_.Speed.get());
|
||||
}
|
||||
if (impl_->transition_.Time)
|
||||
/* if (impl_->transition_.Time)
|
||||
{
|
||||
CP_XML_ATTR(L"p14:dur", impl_->transition_.Time.get());
|
||||
}
|
||||
}*/
|
||||
if (impl_->transition_.PageTime)
|
||||
{
|
||||
CP_XML_ATTR(L"advTm", impl_->transition_.PageTime.get());
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include "xlsx_border.h"
|
||||
#include <boost/functional.hpp>
|
||||
#include <cpdoccore/CPHash.h>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include "../odf/style_text_properties.h"
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ public:
|
||||
|
||||
void add_format(std::wstring const & condition, std::wstring const & format)
|
||||
{
|
||||
std::wstring c = condition;
|
||||
XmlUtils::GetLower(c);
|
||||
std::wstring c = XmlUtils::GetLower(condition);
|
||||
|
||||
XmlUtils::replace_all( c, L" ", L"");
|
||||
XmlUtils::replace_all( c, L"\t", L"");
|
||||
|
||||
|
||||
@ -576,11 +576,31 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::process_object(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
|
||||
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
if (drawing.type_anchor == 2) // absolute
|
||||
{
|
||||
//пересчет нужен для оле
|
||||
xlsx_table_position from, to;
|
||||
|
||||
process_position_properties (obj, table_metrics, from, to);
|
||||
|
||||
drawing.from_.type = xlsx_drawing_position::from;
|
||||
drawing.from_.position.col = from.col;
|
||||
drawing.from_.position.colOff = static_cast<size_t>(odf_types::length(from.colOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
drawing.from_.position.row = from.row;
|
||||
drawing.from_.position.rowOff = static_cast<size_t>(odf_types::length(from.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
|
||||
drawing.to_.type = xlsx_drawing_position::to;
|
||||
drawing.to_.position.col = to.col;
|
||||
drawing.to_.position.colOff = static_cast<size_t>(odf_types::length(to.colOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
drawing.to_.position.row = to.row;
|
||||
drawing.to_.position.rowOff = static_cast<size_t>(odf_types::length(to.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
}
|
||||
|
||||
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectProgId = obj.descriptor_;
|
||||
|
||||
@ -602,7 +622,7 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
|
||||
{
|
||||
xlsx_drawings_ptr xlsx_drawings_child(xlsx_drawings::create(true));
|
||||
|
||||
process_objects ( obj.child_objects_, table_metrics, xlsx_drawings_child);
|
||||
process_group_objects ( obj.child_objects_, table_metrics, xlsx_drawings_child);
|
||||
|
||||
std::wstringstream strm;
|
||||
|
||||
@ -620,9 +640,9 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
|
||||
}
|
||||
void xlsx_drawing_context::process_objects(xlsx_table_metrics & table_metrics)
|
||||
{
|
||||
process_objects(impl_->objects_, table_metrics, impl_->get_drawings());
|
||||
process_group_objects(impl_->objects_, table_metrics, impl_->get_drawings());
|
||||
}
|
||||
void xlsx_drawing_context::process_objects(std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_)
|
||||
void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_)
|
||||
{
|
||||
for (size_t i = 0 ; i < objects.size(); i++)
|
||||
{
|
||||
@ -661,7 +681,7 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
|
||||
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
|
||||
case typeMsObject:
|
||||
case typeOleObject:
|
||||
process_object ( obj, drawing, xlsx_drawings_); break;
|
||||
process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,13 +133,13 @@ private:
|
||||
class Impl;
|
||||
_CP_PTR(Impl) impl_;
|
||||
|
||||
void process_objects (std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_group (drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_group_objects (std::vector<drawing_object_description> objects, xlsx_table_metrics & table_metrics, xlsx_drawings_ptr xlsx_drawings_);
|
||||
|
||||
void process_image (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_chart (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_shape (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_object (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
void process_object (drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
|
||||
|
||||
void process_common_properties (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics);
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
if (sheet_rel)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
|
||||
for (size_t i = 0 ; i < xlsx_sheet_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_sheet_rels_[i].rid == rid && xlsx_sheet_rels_[i].ref == ref)
|
||||
present = true;
|
||||
@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
@ -89,7 +89,7 @@ public:
|
||||
{
|
||||
if (inGroup)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
{
|
||||
xlsx_drawings_[i].serialize(strm);
|
||||
}
|
||||
@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
void serialize_objects(std::wostream & strm)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawings_[i].type != typeOleObject && xlsx_drawings_[i].type != typeMsObject) continue;
|
||||
|
||||
@ -129,7 +129,7 @@ public:
|
||||
|
||||
void dump_rels_drawing(rels & Rels)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].type == typeImage ||
|
||||
xlsx_drawing_rels_[i].type == typeMedia ||
|
||||
@ -146,7 +146,7 @@ public:
|
||||
}
|
||||
void dump_rels_sheet(rels & Rels)
|
||||
{
|
||||
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
|
||||
for (size_t i = 0 ; i < xlsx_sheet_rels_.size(); i++)
|
||||
{
|
||||
Rels.add(relationship( xlsx_sheet_rels_[i].rid,
|
||||
mediaitems::get_rel_type(xlsx_sheet_rels_[i].type),
|
||||
|
||||
@ -66,13 +66,27 @@ public:
|
||||
|
||||
struct _field_value
|
||||
{
|
||||
_field_value(const std::wstring &val, const std::wstring &type) : sVal(val), sNode(type) {}
|
||||
_field_value(const std::wstring &val, const std::wstring &type, const bool &sd) : sVal(val), sNode(type), show_details(sd) {}
|
||||
std::wstring sVal;
|
||||
std::wstring sNode;
|
||||
bool show_details;
|
||||
};
|
||||
struct _reference
|
||||
{
|
||||
std::wstring name;
|
||||
int type = -1;
|
||||
std::wstring member_name;
|
||||
int member_type = -1;
|
||||
};
|
||||
struct _group
|
||||
{
|
||||
std::wstring name;
|
||||
std::vector<_field_value> caches;
|
||||
};
|
||||
struct _field
|
||||
{
|
||||
std::wstring name;
|
||||
std::wstring display_name;
|
||||
int type = -1;
|
||||
int hierarchy = -1;
|
||||
int function = -1;
|
||||
@ -80,13 +94,20 @@ public:
|
||||
bool data_layout = false;
|
||||
bool show_empty = false;
|
||||
bool repeat_item_labels = true;
|
||||
int type_groups = 0;
|
||||
int sort = 0;
|
||||
std::wstring source_groups;
|
||||
|
||||
std::vector<int> subtotals;
|
||||
|
||||
std::vector<_field_value> caches;
|
||||
std::vector<_reference> references;
|
||||
int references_field = -1;
|
||||
bool used_in_referenes = false;
|
||||
|
||||
int type_groups = 0;
|
||||
int base_group = -1;
|
||||
std::wstring source_groups;
|
||||
std::vector<_group> groups;
|
||||
std::vector<int> groups_discrete;
|
||||
|
||||
bool bDataFieldEnabled = false;
|
||||
bool bString = false;
|
||||
@ -121,6 +142,11 @@ public:
|
||||
data_on_row = false;
|
||||
identify_categories = false;
|
||||
drill_enabled = true;
|
||||
grand_total = -1;
|
||||
firstDataRow = 0;
|
||||
firstDataCol = 0;
|
||||
bAxisRow = true;
|
||||
bAxisCol = true;
|
||||
}
|
||||
std::wstring name;
|
||||
std::wstring location_ref;
|
||||
@ -140,12 +166,21 @@ public:
|
||||
std::vector<int> col_fields;
|
||||
std::vector<int> data_fields;
|
||||
|
||||
int grand_total = -1;
|
||||
bool identify_categories = false;
|
||||
bool drill_enabled = true;
|
||||
bool ignore_empty_rows = false;
|
||||
|
||||
bool data_on_row = false;
|
||||
bool in_group = false;
|
||||
//-----------------------------------------------------------------------------
|
||||
int firstDataRow = 0;
|
||||
int firstDataCol = 0;
|
||||
bool bAxisRow = true;
|
||||
bool bAxisCol = true;
|
||||
}current_;
|
||||
|
||||
void calc_headers();
|
||||
void sort_fields();
|
||||
|
||||
void serialize_view(std::wostream & strm);
|
||||
@ -257,21 +292,7 @@ private:
|
||||
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
|
||||
{
|
||||
}
|
||||
void xlsx_pivots_context::Impl::sort_fields()
|
||||
{
|
||||
for (size_t i = 0; i < current_.fields.size(); i++)
|
||||
{
|
||||
if (current_.fields[i].type == 7)
|
||||
continue;
|
||||
if (!current_.fields[i].source_groups.empty() && i != current_.fields.size() -1)
|
||||
{
|
||||
current_.fields.push_back(current_.fields[i]);
|
||||
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
void xlsx_pivots_context::Impl::calc_headers()
|
||||
{
|
||||
if (current_.headers.empty()) return;
|
||||
|
||||
@ -314,30 +335,30 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
bool resRow = clear_header_map(mapRowHeader);
|
||||
bool resCol = clear_header_map(mapColHeader);
|
||||
|
||||
size_t firstDataRow, firstDataCol;
|
||||
|
||||
if (resRow == resCol && resCol == false)
|
||||
{
|
||||
firstDataRow = firstDataCol = 1;
|
||||
current_.firstDataRow = current_.firstDataCol = 1;
|
||||
}
|
||||
else if (resRow == false)
|
||||
{
|
||||
current_.bAxisCol = false;
|
||||
clear_header_map2(mapRowHeader, mapColHeader);
|
||||
}
|
||||
else if (resCol == false)
|
||||
{
|
||||
current_.bAxisRow = false;
|
||||
clear_header_map2(mapColHeader, mapRowHeader);
|
||||
}
|
||||
|
||||
if (resRow || resCol)
|
||||
{
|
||||
firstDataCol = mapRowHeader.empty() ? 1 : mapRowHeader.begin()->second - min_col;
|
||||
current_.firstDataCol = mapRowHeader.empty() ? 1 : mapRowHeader.begin()->second - min_col;
|
||||
|
||||
if (mapColHeader.empty())
|
||||
{
|
||||
pFind = mapRowHeader.end(); pFind--;
|
||||
min_row = pFind->first;
|
||||
firstDataRow = 1;
|
||||
current_.firstDataRow = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -347,11 +368,11 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
if (min_row > mapRowHeader.begin()->first)
|
||||
min_row = mapRowHeader.begin()->first;
|
||||
}
|
||||
firstDataRow = mapColHeader.begin()->second - min_row + 1;
|
||||
current_.firstDataRow = mapColHeader.begin()->second - min_row + 1;
|
||||
}
|
||||
}
|
||||
if (firstDataCol < 1) firstDataCol = 1;
|
||||
if (firstDataRow < 1) firstDataRow = 1;
|
||||
if (current_.firstDataCol < 1) current_.firstDataCol = 1;
|
||||
if (current_.firstDataRow < 1) current_.firstDataRow = 1;
|
||||
|
||||
std::vector<std::wstring> split_ref;
|
||||
boost::algorithm::split(split_ref, current_.location_ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
@ -369,14 +390,199 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
|
||||
split_ref[0] = oox::getColAddress(col) + oox::getRowAddress(row);
|
||||
}
|
||||
std::wstring location_data;
|
||||
if (split_ref.size() > 1)
|
||||
{
|
||||
location_data += split_ref[0] + L":" + split_ref[1];
|
||||
current_.location_ref = split_ref[0] + L":" + split_ref[1];
|
||||
}
|
||||
else location_data = current_.location_ref;
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
void xlsx_pivots_context::Impl::sort_fields()
|
||||
{
|
||||
size_t count_skip = 0;
|
||||
for (size_t i = 0; i < current_.fields.size() - count_skip; i++)
|
||||
{
|
||||
if (!current_.fields[i].source_groups.empty() && i != current_.fields.size() - count_skip)
|
||||
{
|
||||
current_.fields.push_back(current_.fields[i]);
|
||||
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
|
||||
i--;
|
||||
count_skip++;
|
||||
}
|
||||
}
|
||||
count_skip = 0;
|
||||
for (size_t i = 0; i < current_.fields.size() - count_skip; i++)
|
||||
{
|
||||
if (current_.fields[i].name.empty() && i != current_.fields.size() - count_skip)
|
||||
{
|
||||
current_.fields.push_back(current_.fields[i]);
|
||||
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
|
||||
i--;
|
||||
count_skip++;
|
||||
}
|
||||
}
|
||||
|
||||
bool bAddRepeateRow = false;
|
||||
bool bAddRepeateCol = false;
|
||||
|
||||
int count_items_col = -1, count_items_row = -1;
|
||||
|
||||
int index_current = 0;
|
||||
for (size_t i = 0; i < current_.fields.size(); i++, index_current++)
|
||||
{
|
||||
if ( current_.fields[i].type_groups > 0 )
|
||||
{
|
||||
current_.fields[i].base_group = 0;
|
||||
|
||||
int index_group = 0;
|
||||
for (size_t k = 0; k < current_.fields.size(); k++)
|
||||
{
|
||||
if (current_.fields[k].type == 7) continue;
|
||||
if (current_.fields[k].name == current_.fields[i].source_groups && !current_.fields[i].source_groups.empty())
|
||||
{
|
||||
if (current_.fields[k].type_groups == 0)
|
||||
current_.fields[k].base_group = index_current; //опорный (если он и базовый - не писать)
|
||||
current_.fields[i].base_group = index_group;
|
||||
|
||||
for (size_t c = 0; !current_.fields[i].groups.empty() && c < current_.fields[k].caches.size(); c++)
|
||||
{
|
||||
for (size_t g = 0; g < current_.fields[i].groups.size(); g++)
|
||||
{
|
||||
for (size_t h = 0; h < current_.fields[i].groups[g].caches.size(); h++)
|
||||
{
|
||||
if (current_.fields[i].groups[g].caches[h].sVal == current_.fields[k].caches[c].sVal)
|
||||
current_.fields[i].groups_discrete.push_back(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
index_group++;
|
||||
}
|
||||
}
|
||||
if ( current_.fields[i].name.empty() &&
|
||||
!current_.fields[i].data_layout)
|
||||
continue;
|
||||
|
||||
switch(current_.fields[i].type)
|
||||
{
|
||||
case 0: // column
|
||||
{
|
||||
if (!current_.fields[i].name.empty())
|
||||
{
|
||||
current_.col_fields.push_back(i);
|
||||
|
||||
if ( count_items_col < 0)
|
||||
{
|
||||
count_items_col = current_.fields[i].caches.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count_items_col != current_.fields[i].caches.size())
|
||||
bAddRepeateCol = true;
|
||||
}
|
||||
}
|
||||
//if (current_.fields[i].data_layout)
|
||||
//{
|
||||
// bAddRepeateCol = false;
|
||||
|
||||
// if ((current_.fields[i].name.empty() && (!current_.identify_categories || current_.fields[i].hierarchy >= 0)) ||
|
||||
// current_.fields[i].used_in_referenes )
|
||||
// {
|
||||
// if ((current_.col_fields.empty()) || (current_.col_fields.back() != -2))
|
||||
// {
|
||||
// bAddRepeateCol = true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (current_.fields[i].caches.empty())
|
||||
// bEmptyColCache = true;
|
||||
|
||||
|
||||
}break;
|
||||
case 1: // data
|
||||
{
|
||||
int index_field = -1;
|
||||
|
||||
for (size_t j = 0; j < i/*current_.fields.size()*/; j++)
|
||||
{
|
||||
if ( current_.fields[j].name == current_.fields[i].name )
|
||||
{
|
||||
current_.fields[j].bDataFieldEnabled = true;
|
||||
index_field = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index_field >= 0)
|
||||
{
|
||||
if (current_.fields[i].caches.empty())
|
||||
{
|
||||
current_.fields[i].type = 7; //skip
|
||||
current_.fields_count--;
|
||||
index_current--;
|
||||
}
|
||||
|
||||
current_.fields[i].references_field = index_field;
|
||||
}
|
||||
|
||||
index_field = i;
|
||||
current_.fields[i].bDataFieldEnabled = true;
|
||||
current_.data_fields.push_back(index_field);
|
||||
}break;
|
||||
case 2: // hidden
|
||||
{
|
||||
}break;
|
||||
case 3: // page
|
||||
{
|
||||
current_.page_fields.push_back(i);
|
||||
}break;
|
||||
case 4: // row
|
||||
{
|
||||
if (!current_.fields[i].name.empty())
|
||||
{
|
||||
current_.row_fields.push_back(i);
|
||||
|
||||
if ( count_items_row < 0)
|
||||
{
|
||||
count_items_row = current_.fields[i].caches.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count_items_row != current_.fields[i].caches.size())
|
||||
bAddRepeateRow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_.fields[i].data_layout)
|
||||
{
|
||||
current_.data_on_row = true;
|
||||
|
||||
bAddRepeateCol = false;
|
||||
|
||||
if ((current_.fields[i].name.empty() && (current_.fields[i].hierarchy >= 0)) ||
|
||||
current_.fields[i].used_in_referenes )
|
||||
{
|
||||
bAddRepeateRow = true;
|
||||
}
|
||||
}
|
||||
|
||||
}break;
|
||||
}
|
||||
|
||||
if (current_.fields[i].name.empty())
|
||||
{
|
||||
current_.fields.erase(current_.fields.begin() + i, current_.fields.begin() + i + 1);
|
||||
current_.fields_count--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol)) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
|
||||
current_.col_fields.push_back(-2);
|
||||
|
||||
if (bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))
|
||||
current_.row_fields.push_back(-2);
|
||||
}
|
||||
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"pivotTableDefinition")
|
||||
@ -413,11 +619,11 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
|
||||
CP_XML_NODE(L"location")
|
||||
{
|
||||
CP_XML_ATTR(L"ref", location_data);
|
||||
CP_XML_ATTR(L"ref", current_.location_ref);
|
||||
|
||||
CP_XML_ATTR(L"firstHeaderRow", 1 );
|
||||
CP_XML_ATTR(L"firstDataRow", firstDataRow);
|
||||
CP_XML_ATTR(L"firstDataCol", firstDataCol);
|
||||
CP_XML_ATTR(L"firstDataRow", current_.firstDataRow);
|
||||
CP_XML_ATTR(L"firstDataCol", current_.firstDataCol);
|
||||
|
||||
if (current_.page_fields.empty() == false)
|
||||
{
|
||||
@ -468,22 +674,42 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
}
|
||||
CP_XML_ATTR(L"defaultSubtotal", 0);
|
||||
|
||||
if (!current_.fields[i].caches.empty() && current_.fields[i].type != 2)
|
||||
if (current_.fields[i].type != 2)
|
||||
{
|
||||
CP_XML_NODE(L"items")
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
|
||||
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
|
||||
{
|
||||
CP_XML_NODE(L"item")
|
||||
{
|
||||
CP_XML_ATTR(L"x", j);
|
||||
if (!current_.fields[i].groups.empty())
|
||||
{
|
||||
CP_XML_NODE(L"items")
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].groups.size());
|
||||
for (size_t j = 0; j < current_.fields[i].groups.size(); j++)
|
||||
{
|
||||
CP_XML_NODE(L"item")
|
||||
{
|
||||
CP_XML_ATTR(L"x", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!current_.fields[i].caches.empty())
|
||||
{
|
||||
CP_XML_NODE(L"items")
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
|
||||
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
|
||||
{
|
||||
CP_XML_NODE(L"item")
|
||||
{
|
||||
if (current_.fields[i].caches[j].show_details == false)
|
||||
{
|
||||
CP_XML_ATTR(L"sd", 0);
|
||||
}
|
||||
CP_XML_ATTR(L"x", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//CP_XML_STREAM() << fields_[i].view_;
|
||||
}
|
||||
}
|
||||
if (!current_.row_fields.empty())
|
||||
@ -537,35 +763,85 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
CP_XML_ATTR(L"count", current_.data_fields.size());
|
||||
for (size_t i = 0; i < current_.data_fields.size(); i++)
|
||||
{
|
||||
CP_XML_NODE(L"dataField")
|
||||
{
|
||||
CP_XML_ATTR(L"fld", current_.data_fields[i]);
|
||||
CP_XML_ATTR(L"baseField", current_.data_fields[i]);
|
||||
//CP_XML_ATTR(L"baseItem", -1);
|
||||
//CP_XML_ATTR(L"name", L"");
|
||||
int ind_field_dirty = current_.data_fields[i];
|
||||
|
||||
int ind_field = current_.data_fields[i];
|
||||
if (ind_field >= 0 && ind_field < current_.fields.size())
|
||||
CP_XML_NODE(L"dataField")
|
||||
{
|
||||
int fld = 0, ind_fld = current_.fields[ind_field_dirty].references_field < 0 ? ind_field_dirty :
|
||||
current_.fields[ind_field_dirty].references_field;
|
||||
for (size_t k = 0; k < ind_fld; k++)
|
||||
{
|
||||
switch(current_.fields[ind_field].function)
|
||||
if (current_.fields[k].type != 7 ) fld++;
|
||||
}
|
||||
|
||||
CP_XML_ATTR(L"fld", fld);
|
||||
if (current_.fields[ind_field_dirty].references.empty())
|
||||
{
|
||||
CP_XML_ATTR(L"baseField", fld);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t base_field = 0, base_item = 0;
|
||||
for (size_t k = 0; k < current_.fields.size(); k++)
|
||||
{
|
||||
case 1: CP_XML_ATTR(L"subtotal", L"average"); break;
|
||||
case 2: CP_XML_ATTR(L"subtotal", L"count"); break;
|
||||
case 3: CP_XML_ATTR(L"subtotal", L"countNums"); break;
|
||||
case 4: CP_XML_ATTR(L"subtotal", L"max"); break;
|
||||
case 5: CP_XML_ATTR(L"subtotal", L"min"); break;
|
||||
case 6: CP_XML_ATTR(L"subtotal", L"product"); break;
|
||||
case 7: CP_XML_ATTR(L"subtotal", L"stdDev"); break;
|
||||
case 8: CP_XML_ATTR(L"subtotal", L"stdDevp"); break;
|
||||
case 9: CP_XML_ATTR(L"subtotal", L"sum"); break;
|
||||
case 10: CP_XML_ATTR(L"subtotal", L"var"); break;
|
||||
case 11: CP_XML_ATTR(L"subtotal", L"varp"); break;
|
||||
if (current_.fields[k].type == 7 ) continue;
|
||||
|
||||
if (current_.fields[k].name == current_.fields[ind_field_dirty].references[0].name)
|
||||
{
|
||||
for (size_t j = 0; j < current_.fields[k].caches.size(); j++)
|
||||
{
|
||||
if (current_.fields[k].caches[j].sVal == current_.fields[ind_field_dirty].references[0].member_name)
|
||||
{
|
||||
base_item = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
base_field++;
|
||||
}
|
||||
CP_XML_ATTR(L"baseField", base_field);
|
||||
CP_XML_ATTR(L"baseItem", base_item);
|
||||
|
||||
switch(current_.fields[ind_field_dirty].references[0].type)
|
||||
{
|
||||
case 1: CP_XML_ATTR(L"showDataAs", L"difference"); break;
|
||||
case 2: CP_XML_ATTR(L"showDataAs", L"percent"); break;
|
||||
case 3: CP_XML_ATTR(L"showDataAs", L"percentDiff"); break;
|
||||
}
|
||||
}
|
||||
std::wstring name;
|
||||
|
||||
if (ind_field_dirty >= 0 && ind_field_dirty < current_.fields.size())
|
||||
{
|
||||
switch(current_.fields[ind_field_dirty].function)
|
||||
{
|
||||
case 1: CP_XML_ATTR(L"subtotal", L"average"); name = L"average "; break;
|
||||
case 2: CP_XML_ATTR(L"subtotal", L"count"); name = L"count "; break;
|
||||
case 3: CP_XML_ATTR(L"subtotal", L"countNums"); name = L"countNums "; break;
|
||||
case 4: CP_XML_ATTR(L"subtotal", L"max"); name = L"max "; break;
|
||||
case 5: CP_XML_ATTR(L"subtotal", L"min"); name = L"min "; break;
|
||||
case 6: CP_XML_ATTR(L"subtotal", L"product"); name = L"product "; break;
|
||||
case 7: CP_XML_ATTR(L"subtotal", L"stdDev"); name = L"stdDev Dev "; break;
|
||||
case 8: CP_XML_ATTR(L"subtotal", L"stdDevp"); name = L"stdDevp "; break;
|
||||
case 9: CP_XML_ATTR(L"subtotal", L"sum"); name = L"sum by "; break;
|
||||
case 10: CP_XML_ATTR(L"subtotal", L"var"); name = L"var "; break;
|
||||
case 11: CP_XML_ATTR(L"subtotal", L"varp"); name = L"varp "; break;
|
||||
case 12:
|
||||
{
|
||||
CP_XML_ATTR(L"subtotal", current_.fields[current_.data_fields[i]].user_function);
|
||||
}break;
|
||||
default: break;
|
||||
}
|
||||
if (current_.fields[ind_field_dirty].display_name.empty())
|
||||
{
|
||||
name += current_.fields[ind_field_dirty].name;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = current_.fields[ind_field_dirty].display_name;
|
||||
}
|
||||
CP_XML_ATTR(L"name", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -665,7 +941,7 @@ void xlsx_pivots_context::Impl::serialize_type_field(CP_ATTR_NODE, _field & fiel
|
||||
}
|
||||
void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
|
||||
{
|
||||
std::map<std::wstring, bool> used_field_name;
|
||||
std::map<std::wstring, bool> used_field_name, used_field_name_lower;
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"pivotCacheDefinition")
|
||||
@ -708,6 +984,7 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
int index_current = 0;
|
||||
|
||||
if (current_.fields.empty() == false)
|
||||
{
|
||||
@ -722,12 +999,24 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
|
||||
|
||||
if (used_field_name.end() != used_field_name.find(current_.fields[i].name))
|
||||
continue;
|
||||
//---------------------------------------------------------------------------
|
||||
used_field_name.insert(std::make_pair(current_.fields[i].name, true)); //дублированые поля
|
||||
|
||||
used_field_name.insert(std::make_pair(current_.fields[i].name, true));
|
||||
std::wstring name = current_.fields[i].name; // в мс "H" и "h" одно имя (
|
||||
|
||||
std::wstring name_lower = XmlUtils::GetLower(name);
|
||||
|
||||
while (used_field_name_lower.end() != used_field_name_lower.find(name_lower))
|
||||
{
|
||||
name += L"_";
|
||||
name_lower = XmlUtils::GetLower(name);
|
||||
}
|
||||
|
||||
used_field_name_lower.insert(std::make_pair(name_lower, true));
|
||||
//---------------------------------------------------------------------------
|
||||
CP_XML_NODE(L"cacheField")
|
||||
{
|
||||
CP_XML_ATTR(L"name", current_.fields[i].name);
|
||||
CP_XML_ATTR(L"name", name);
|
||||
CP_XML_ATTR(L"numFmtId", 0);
|
||||
|
||||
if (!current_.fields[i].source_groups.empty())
|
||||
@ -744,11 +1033,12 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
else if (current_.fields[i].type_groups < 8)
|
||||
{//group by date
|
||||
current_.fields[i].bDate = true;
|
||||
current_.fields[i].bString = false;
|
||||
}
|
||||
//else group by fields
|
||||
|
||||
serialize_type_field(CP_GET_XML_NODE(), current_.fields[i]);
|
||||
if ( current_.fields[i].type_groups == 0 )
|
||||
@ -766,37 +1056,78 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( current_.fields[i].type_groups != 0 )
|
||||
if (current_.fields[i].base_group >= 0)
|
||||
{
|
||||
CP_XML_NODE(L"fieldGroup")
|
||||
{
|
||||
CP_XML_ATTR(L"base", 0);
|
||||
CP_XML_NODE(L"rangePr")
|
||||
{
|
||||
if ( current_.fields[i].type_groups > 0)
|
||||
{
|
||||
switch(current_.fields[i].type_groups)
|
||||
{
|
||||
case 1: CP_XML_ATTR(L"groupBy", L"seconds"); break;
|
||||
case 2: CP_XML_ATTR(L"groupBy", L"minutes"); break;
|
||||
case 3: CP_XML_ATTR(L"groupBy", L"hours"); break;
|
||||
case 4: CP_XML_ATTR(L"groupBy", L"days"); break;
|
||||
case 5: CP_XML_ATTR(L"groupBy", L"months"); break;
|
||||
case 6: CP_XML_ATTR(L"groupBy", L"quarters"); break;
|
||||
case 7: CP_XML_ATTR(L"groupBy", L"years"); break;
|
||||
}
|
||||
CP_XML_ATTR(L"startDate", L"1899-12-31T00:00:00");
|
||||
CP_XML_ATTR(L"endDate", L"1899-12-31T00:00:00");
|
||||
CP_XML_ATTR(L"base", current_.fields[i].base_group);
|
||||
}
|
||||
CP_XML_NODE(L"groupItems")
|
||||
else
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
|
||||
|
||||
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
|
||||
CP_XML_ATTR(L"par", current_.fields[i].base_group);
|
||||
}
|
||||
if (current_.fields[i].type_groups > 0)
|
||||
{
|
||||
if (current_.fields[i].type_groups < 8)
|
||||
{
|
||||
CP_XML_NODE(current_.fields[i].caches[j].sNode)
|
||||
CP_XML_NODE(L"rangePr")
|
||||
{
|
||||
if (current_.fields[i].caches[j].sVal.empty() == false)
|
||||
switch(current_.fields[i].type_groups)
|
||||
{
|
||||
CP_XML_ATTR(L"v", current_.fields[i].caches[j].sVal);
|
||||
case 1: CP_XML_ATTR(L"groupBy", L"seconds"); break;
|
||||
case 2: CP_XML_ATTR(L"groupBy", L"minutes"); break;
|
||||
case 3: CP_XML_ATTR(L"groupBy", L"hours"); break;
|
||||
case 4: CP_XML_ATTR(L"groupBy", L"days"); break;
|
||||
case 5: CP_XML_ATTR(L"groupBy", L"months"); break;
|
||||
case 6: CP_XML_ATTR(L"groupBy", L"quarters"); break;
|
||||
case 7: CP_XML_ATTR(L"groupBy", L"years"); break;
|
||||
}
|
||||
CP_XML_ATTR(L"startDate", L"1899-12-31T00:00:00");
|
||||
CP_XML_ATTR(L"endDate", L"1899-12-31T00:00:00");
|
||||
}
|
||||
}
|
||||
if (!current_.fields[i].groups_discrete.empty())
|
||||
{
|
||||
CP_XML_NODE(L"discretePr")
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].groups_discrete.size());
|
||||
for (size_t j = 0; j < current_.fields[i].groups_discrete.size(); j++)
|
||||
{
|
||||
CP_XML_NODE(L"x")
|
||||
{
|
||||
CP_XML_ATTR(L"v", current_.fields[i].groups_discrete[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"groupItems")
|
||||
{
|
||||
if (!current_.fields[i].groups.empty())
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].groups.size());
|
||||
for (size_t j = 0; j < current_.fields[i].groups.size(); j++)
|
||||
{
|
||||
CP_XML_NODE(L"s")
|
||||
{
|
||||
CP_XML_ATTR(L"v", current_.fields[i].groups[j].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
|
||||
|
||||
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
|
||||
{
|
||||
CP_XML_NODE(current_.fields[i].caches[j].sNode)
|
||||
{
|
||||
if (current_.fields[i].caches[j].sVal.empty() == false)
|
||||
{
|
||||
CP_XML_ATTR(L"v", current_.fields[i].caches[j].sVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -804,6 +1135,8 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index_current++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -903,6 +1236,7 @@ int xlsx_pivots_context::end_table()
|
||||
std::wstringstream cache_strm;
|
||||
std::wstringstream rec_strm;
|
||||
|
||||
impl_->calc_headers();
|
||||
impl_->sort_fields();
|
||||
|
||||
impl_->serialize_view(view_strm);
|
||||
@ -940,10 +1274,18 @@ void xlsx_pivots_context::set_identify_categories(bool val)
|
||||
{
|
||||
impl_->current_.identify_categories = val;
|
||||
}
|
||||
void xlsx_pivots_context::set_ignore_empty_rows(bool val)
|
||||
{
|
||||
impl_->current_.ignore_empty_rows = val;
|
||||
}
|
||||
void xlsx_pivots_context::set_drill(bool val)
|
||||
{
|
||||
impl_->current_.drill_enabled = val;
|
||||
}
|
||||
void xlsx_pivots_context::set_grand_total(int type)
|
||||
{
|
||||
impl_->current_.grand_total = type;
|
||||
}
|
||||
void xlsx_pivots_context::start_field()
|
||||
{
|
||||
Impl::_field f;
|
||||
@ -955,75 +1297,86 @@ void xlsx_pivots_context::set_field_name(std::wstring name)
|
||||
{
|
||||
impl_->current_.fields.back().name = name;
|
||||
}
|
||||
void xlsx_pivots_context::set_field_display(std::wstring name)
|
||||
{
|
||||
impl_->current_.fields.back().display_name = name;
|
||||
}
|
||||
void xlsx_pivots_context::set_field_type(int type, int hierarchy)
|
||||
{
|
||||
impl_->current_.fields.back().type = type;
|
||||
impl_->current_.fields.back().hierarchy = hierarchy;
|
||||
|
||||
if ( impl_->current_.fields.back().name.empty() &&
|
||||
!impl_->current_.fields.back().data_layout)
|
||||
return;
|
||||
//if ( impl_->current_.fields.back().name.empty() &&
|
||||
// !impl_->current_.fields.back().data_layout)
|
||||
// return;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0: // column
|
||||
{
|
||||
if (impl_->current_.fields.back().data_layout)
|
||||
{
|
||||
if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
|
||||
//impl_->current_.fields.back().repeat_item_labels )) //????
|
||||
impl_->current_.col_fields.push_back(-2);
|
||||
}
|
||||
else
|
||||
impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1);
|
||||
}break;
|
||||
case 1: // data
|
||||
{
|
||||
int index_field = -1;
|
||||
|
||||
for (size_t i = 0; i < impl_->current_.fields.size(); i++)
|
||||
{
|
||||
if (impl_->current_.fields[i].name == impl_->current_.fields.back().name &&
|
||||
impl_->current_.fields[i].type != 1)
|
||||
{
|
||||
impl_->current_.fields[i].bDataFieldEnabled = true;
|
||||
index_field = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index_field >= 0)
|
||||
{
|
||||
impl_->current_.fields.back().type = 7;
|
||||
impl_->current_.fields_count--;
|
||||
impl_->current_.data_fields.push_back(index_field);
|
||||
}
|
||||
else
|
||||
{
|
||||
index_field = impl_->current_.fields.size() - 1;
|
||||
impl_->current_.fields.back().bDataFieldEnabled = true;
|
||||
impl_->current_.data_fields.push_back(index_field);
|
||||
}
|
||||
}break;
|
||||
case 2: // hidden
|
||||
break;
|
||||
case 3: // page
|
||||
impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1);
|
||||
break;
|
||||
case 4: // row
|
||||
if (impl_->current_.fields.back().data_layout)
|
||||
{
|
||||
impl_->current_.data_on_row = true;
|
||||
//switch(type)
|
||||
//{
|
||||
// case 0: // column
|
||||
// {
|
||||
// if (impl_->current_.fields.back().data_layout)
|
||||
// {
|
||||
// if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
|
||||
// //impl_->current_.fields.back().repeat_item_labels )) //????
|
||||
// impl_->current_.col_fields.push_back(-2);
|
||||
// }
|
||||
// else
|
||||
// impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1);
|
||||
// }break;
|
||||
// case 1: // data
|
||||
// {
|
||||
// int index_field = -1;
|
||||
//
|
||||
// for (size_t i = 0; i < impl_->current_.fields.size() - 1; i++)
|
||||
// {
|
||||
// if (impl_->current_.fields[i].name == impl_->current_.fields.back().name &&
|
||||
// (impl_->current_.fields[i].type != 1 || !impl_->current_.fields.back().references.empty()))
|
||||
// {
|
||||
// impl_->current_.fields[i].bDataFieldEnabled = true;
|
||||
// index_field = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (index_field >= 0)
|
||||
// {
|
||||
// impl_->current_.fields.back().type = 7; //skip
|
||||
// impl_->current_.fields_count--;
|
||||
//
|
||||
// if (!impl_->current_.fields.back().references.empty())
|
||||
// {
|
||||
// impl_->current_.fields.back().references_field = index_field;
|
||||
// impl_->current_.fields.back().bDataFieldEnabled = true;
|
||||
//
|
||||
// index_field = impl_->current_.fields.size() - 1;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// index_field = impl_->current_.fields.size() - 1;
|
||||
// impl_->current_.fields.back().bDataFieldEnabled = true;
|
||||
// }
|
||||
// impl_->current_.data_fields.push_back(index_field);
|
||||
// }break;
|
||||
// case 2: // hidden
|
||||
// break;
|
||||
// case 3: // page
|
||||
// impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1);
|
||||
// break;
|
||||
// case 4: // row
|
||||
// if (impl_->current_.fields.back().data_layout)
|
||||
// {
|
||||
// impl_->current_.data_on_row = true;
|
||||
|
||||
if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
|
||||
//(impl_->current_.fields.back().repeat_item_labels ||
|
||||
// !impl_->current_.identify_categories ))
|
||||
impl_->current_.row_fields.push_back(-2);
|
||||
// if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
|
||||
// //(impl_->current_.fields.back().repeat_item_labels ||
|
||||
// // !impl_->current_.identify_categories ))
|
||||
// impl_->current_.row_fields.push_back(-2);
|
||||
|
||||
}
|
||||
else
|
||||
impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1);
|
||||
break;
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1);
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
void xlsx_pivots_context::set_field_function(int type)
|
||||
{
|
||||
@ -1058,18 +1411,64 @@ void xlsx_pivots_context::set_field_groups_source(std::wstring name)
|
||||
{
|
||||
impl_->current_.fields.back().source_groups = name;
|
||||
}
|
||||
void xlsx_pivots_context::start_field_group()
|
||||
{
|
||||
impl_->current_.in_group = true;
|
||||
Impl::_group group;
|
||||
impl_->current_.fields.back().groups.push_back(group);
|
||||
}
|
||||
void xlsx_pivots_context::set_field_group_name (std::wstring name)
|
||||
{
|
||||
impl_->current_.fields.back().groups.back().name = name;
|
||||
}
|
||||
void xlsx_pivots_context::end_field_group()
|
||||
{
|
||||
impl_->current_.in_group = false;
|
||||
}
|
||||
void xlsx_pivots_context::set_field_sort(int type)
|
||||
{
|
||||
impl_->current_.fields.back().sort = type + 1;
|
||||
}
|
||||
void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
|
||||
void xlsx_pivots_context::start_field_reference()
|
||||
{
|
||||
Impl::_reference ref;
|
||||
impl_->current_.fields.back().references.push_back(ref);
|
||||
}
|
||||
void xlsx_pivots_context::end_field_reference()
|
||||
{
|
||||
}
|
||||
void xlsx_pivots_context::set_field_ref_name(std::wstring name)
|
||||
{
|
||||
impl_->current_.fields.back().references.back().name = name;
|
||||
|
||||
for (size_t i = 0; i < impl_->current_.fields.size(); i++)
|
||||
{
|
||||
if (impl_->current_.fields[i].name == name)
|
||||
{
|
||||
impl_->current_.fields[i].used_in_referenes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_pivots_context::set_field_ref_type (int type)
|
||||
{
|
||||
impl_->current_.fields.back().references.back().type = type;
|
||||
}
|
||||
void xlsx_pivots_context::set_field_ref_member_name(std::wstring name)
|
||||
{
|
||||
impl_->current_.fields.back().references.back().member_name = name;
|
||||
}
|
||||
void xlsx_pivots_context::set_field_ref_member_type(int type)
|
||||
{
|
||||
impl_->current_.fields.back().references.back().member_type = type;
|
||||
}
|
||||
void xlsx_pivots_context::add_field_cache(int index, std::wstring value, bool show_details)
|
||||
{
|
||||
if (index < 0)
|
||||
index = impl_->current_.fields.back().caches.size();
|
||||
|
||||
while (index > impl_->current_.fields.back().caches.size())
|
||||
{
|
||||
Impl::_field_value f(L"", L"m");
|
||||
Impl::_field_value f(L"", L"m", true);
|
||||
|
||||
impl_->current_.fields.back().caches.push_back(f);
|
||||
impl_->current_.fields.back().bEmpty = true;
|
||||
@ -1130,15 +1529,21 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
|
||||
impl_->current_.fields.back().bString = true;
|
||||
}
|
||||
}
|
||||
impl_->current_.fields.back().caches.push_back(Impl::_field_value(value, node_name));
|
||||
impl_->current_.fields.back().caches.push_back(Impl::_field_value(value, node_name, show_details));
|
||||
|
||||
if (impl_->current_.in_group)
|
||||
{
|
||||
impl_->current_.fields.back().groups.back().caches.push_back(impl_->current_.fields.back().caches.back());
|
||||
}
|
||||
|
||||
}
|
||||
void xlsx_pivots_context::end_field()
|
||||
{
|
||||
if (impl_->current_.fields.back().name.empty())
|
||||
{
|
||||
impl_->current_.fields_count--;
|
||||
impl_->current_.fields.pop_back();
|
||||
}
|
||||
//if (impl_->current_.fields.back().name.empty())
|
||||
//{
|
||||
// impl_->current_.fields_count--;
|
||||
// impl_->current_.fields.pop_back();
|
||||
//}
|
||||
}
|
||||
void xlsx_pivots_context::set_source_range(std::wstring table_name, std::wstring ref)
|
||||
{
|
||||
|
||||
@ -51,17 +51,31 @@ public:
|
||||
|
||||
void start_field ();
|
||||
void set_field_name (std::wstring name);
|
||||
void set_field_display (std::wstring name);
|
||||
void set_field_type (int type, int hierarchy);
|
||||
void set_field_function (int type);
|
||||
void set_field_user_function (std::wstring f);
|
||||
void add_field_subtotal (int function_type);
|
||||
void add_field_cache (int index, std::wstring value);
|
||||
void add_field_cache (int index, std::wstring value, bool show_details = true);
|
||||
void set_field_show_empty (bool val);
|
||||
void set_field_data_layout (bool val);
|
||||
void set_field_sort (int type);
|
||||
void set_repeat_item_labels(bool val);
|
||||
|
||||
void set_field_groups (int type);
|
||||
void set_field_groups_source(std::wstring name);
|
||||
void set_repeat_item_labels(bool val);
|
||||
|
||||
void start_field_group();
|
||||
void set_field_group_name (std::wstring name);
|
||||
void end_field_group();
|
||||
|
||||
void start_field_reference();
|
||||
void set_field_ref_name(std::wstring name);
|
||||
void set_field_ref_type (int type);
|
||||
void set_field_ref_member_name(std::wstring name);
|
||||
void set_field_ref_member_type(int type);
|
||||
void end_field_reference();
|
||||
|
||||
void end_field();
|
||||
|
||||
int get_count();
|
||||
@ -73,7 +87,9 @@ public:
|
||||
void add_button_header(std::wstring ref);
|
||||
|
||||
void set_identify_categories(bool val);
|
||||
void set_ignore_empty_rows(bool val);
|
||||
void set_drill(bool val);
|
||||
void set_grand_total(int type);
|
||||
|
||||
void set_source_range(std::wstring table_name, std::wstring ref);
|
||||
|
||||
@ -98,7 +114,6 @@ public:
|
||||
private:
|
||||
class Impl;
|
||||
_CP_PTR(Impl) impl_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -133,7 +133,8 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
|
||||
xlsx_drawing_context_ (Context->get_drawing_context_handle()),
|
||||
xlsx_comments_context_ (Context->get_comments_context_handle()),
|
||||
table_column_last_width_(0.0),
|
||||
in_cell(false)
|
||||
in_cell(false),
|
||||
bEndTable(false)
|
||||
|
||||
{
|
||||
memset(&group_row_,0,sizeof(_group_row));
|
||||
|
||||
@ -91,6 +91,9 @@ public:
|
||||
void end_row ();
|
||||
|
||||
void add_empty_row(int count);
|
||||
|
||||
void set_end_table(){ bEndTable = true; }
|
||||
bool get_end_table(){ return bEndTable; }
|
||||
|
||||
std::wstring current_row_style () const;
|
||||
std::wstring default_row_cell_style () const;
|
||||
@ -153,6 +156,7 @@ public:
|
||||
friend class xlsx_table_context;
|
||||
|
||||
private:
|
||||
bool bEndTable;
|
||||
xlsx_conversion_context * context_;
|
||||
|
||||
std::wstring tableName_;
|
||||
|
||||
@ -195,7 +195,14 @@ std::wstring cellType2Str(XlsxCellType::type type)
|
||||
|
||||
boost::int64_t convertDate(int Year, int Month, int Day)
|
||||
{
|
||||
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
|
||||
if (Year < 1400 || Year >10000)
|
||||
return - 1;
|
||||
if (Month < 1 || Month > 12)
|
||||
return - 1;
|
||||
if (Day < 1 || Day > 31)
|
||||
return - 1;
|
||||
|
||||
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
|
||||
|
||||
if (Year <= 1900 &&
|
||||
Month <= 2 &&
|
||||
|
||||
@ -401,7 +401,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
std::vector<std::wstring> cell_cash;
|
||||
std::vector<std::wstring> cat_cash;
|
||||
|
||||
calc_cache_series (domain_cell_range_adress_, domain_cash);
|
||||
calc_cache_series (domain_cell_range_adress_, domain_cash);
|
||||
calc_cache_series (series_[i].cell_range_address_, cell_cash);
|
||||
|
||||
if (categories_.size() >0)
|
||||
@ -462,10 +462,19 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
|
||||
std::sort(axises_.begin(), axises_.end(), axises_sort());//file_1_ (1).odp
|
||||
|
||||
bool x_enabled = false;
|
||||
bool y_enabled = false;
|
||||
bool z_enabled = false;
|
||||
bool x_enabled = false;
|
||||
bool y_enabled = false;
|
||||
bool z_enabled = false;
|
||||
bool is3D = false;
|
||||
|
||||
_CP_OPT(bool) boolVal;
|
||||
odf_reader::GetProperty(plot_area_.properties_, L"three-dimensional", boolVal);
|
||||
|
||||
if ((boolVal) && (*boolVal))
|
||||
{
|
||||
is3D = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < axises_.size(); i++)
|
||||
{
|
||||
axis & a = axises_[i];
|
||||
@ -481,6 +490,8 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
|
||||
if (class_ == chart_stock && a.type_ == 3 )
|
||||
a.type_ = 4; //шкала дат.
|
||||
|
||||
if (is3D) a.type_ = 1; // шкала категорий
|
||||
|
||||
x_enabled = true;
|
||||
}
|
||||
@ -499,7 +510,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
}
|
||||
else if (a.dimension_ == L"z")
|
||||
{
|
||||
chart_context.set_3D_chart (true);
|
||||
is3D = true;
|
||||
continue;
|
||||
a.type_ = 2;
|
||||
z_enabled = true;
|
||||
@ -507,6 +518,18 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
|
||||
chart_context.add_axis(a.type_, a);
|
||||
}
|
||||
|
||||
if (is3D)
|
||||
{
|
||||
if (!z_enabled)
|
||||
{
|
||||
chart::axis a;
|
||||
a.type_ = 0; // blank
|
||||
|
||||
chart_context.add_axis(a.type_, a);
|
||||
}
|
||||
chart_context.set_3D_chart (true);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
@ -46,8 +46,7 @@ std::wostream & operator << (std::wostream & _Wostream, const Bool & _Val)
|
||||
}
|
||||
Bool Bool::parse(const std::wstring & Str)
|
||||
{
|
||||
std::wstring tmp = Str;
|
||||
XmlUtils::GetLower(tmp);
|
||||
std::wstring tmp = XmlUtils::GetLower(Str);
|
||||
|
||||
if (tmp == L"0" || tmp == L"false") return Bool(false);
|
||||
else return Bool(true);
|
||||
|
||||
@ -306,7 +306,7 @@ std::wstring draw_object_ole::detectObject(const std::wstring &fileName)
|
||||
return L"";
|
||||
}
|
||||
std::wstring prog;
|
||||
POLE::Stream* pStream = new POLE::Stream(storage, "CompObj");
|
||||
POLE::Stream* pStream = new POLE::Stream(storage, L"CompObj");
|
||||
if ((pStream) && (pStream->size() > 28))
|
||||
{
|
||||
//skip the CompObjHeader
|
||||
|
||||
@ -96,6 +96,7 @@ void math_mrow::oox_convert(oox::math_context & Context)
|
||||
bDPr = true;
|
||||
}
|
||||
|
||||
bool need_e_old = Context.is_need_e_, need_e = false;
|
||||
if (bDPr)
|
||||
{
|
||||
Context.output_stream() << L"<m:d>";
|
||||
@ -115,20 +116,31 @@ void math_mrow::oox_convert(oox::math_context & Context)
|
||||
}
|
||||
Context.output_stream() << Context.math_style_stream().str();
|
||||
Context.output_stream() << L"</m:dPr>";
|
||||
Context.output_stream() << L"<m:e>";
|
||||
|
||||
need_e = true;
|
||||
}
|
||||
else need_e = Context.is_need_e_;
|
||||
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
if (need_e)
|
||||
{
|
||||
Context.output_stream() << L"<m:e>";
|
||||
}
|
||||
|
||||
for (int i = i_start; i < i_end ; i++)
|
||||
{
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
math_element->oox_convert(Context);
|
||||
}
|
||||
|
||||
if (need_e)
|
||||
{
|
||||
Context.output_stream() << L"</m:e>";
|
||||
}
|
||||
if (bDPr)
|
||||
{
|
||||
Context.output_stream() << L"</m:e>";
|
||||
Context.output_stream() << L"</m:d>";
|
||||
}
|
||||
Context.is_need_e_ = need_e_old;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
const wchar_t * math_mfrac::ns = L"math";
|
||||
@ -150,13 +162,23 @@ void math_mfrac::oox_convert(oox::math_context & Context)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool need_e = Context.is_need_e_;
|
||||
if (need_e)
|
||||
{
|
||||
Context.output_stream() << L"<m:e>";
|
||||
}
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
office_math_element* math_element = NULL;
|
||||
|
||||
Context.output_stream() << L"<m:f>";
|
||||
Context.output_stream() << L"<m:num>";
|
||||
|
||||
math_element = dynamic_cast<office_math_element*>(content_[0].get());
|
||||
math_element->oox_convert(Context);
|
||||
Context.output_stream() << L"</m:num>";
|
||||
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
Context.output_stream() << L"<m:den>";
|
||||
math_element = dynamic_cast<office_math_element*>(content_[1].get());
|
||||
@ -164,6 +186,12 @@ void math_mfrac::oox_convert(oox::math_context & Context)
|
||||
Context.output_stream() << L"</m:den>";
|
||||
|
||||
Context.output_stream() << L"</m:f>";
|
||||
|
||||
if (need_e)
|
||||
{
|
||||
Context.output_stream() << L"</m:e>";
|
||||
}
|
||||
Context.is_need_e_ = need_e;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
const wchar_t * math_msqrt::ns = L"math";
|
||||
@ -192,6 +220,8 @@ void math_msqrt::oox_convert(oox::math_context & Context)
|
||||
strm << L"<m:deg/>";
|
||||
|
||||
strm << L"<m:e>";
|
||||
|
||||
Context.is_need_e_ = false;
|
||||
for (size_t i = 0 ; i < content_.size(); i++)
|
||||
{
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
@ -230,6 +260,9 @@ void math_mroot::oox_convert(oox::math_context & Context)
|
||||
math_element = dynamic_cast<office_math_element*>(content_[1].get());
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:deg>";
|
||||
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
strm << L"<m:e>";
|
||||
math_element = dynamic_cast<office_math_element*>(content_[0].get());
|
||||
math_element->oox_convert(Context);
|
||||
@ -295,21 +328,23 @@ void math_mstyle::oox_convert(oox::math_context & Context)
|
||||
}
|
||||
}
|
||||
}
|
||||
bool need_e_old = Context.is_need_e_;
|
||||
Context.is_need_e_ = content_.size() > 1 ? true : need_e_old;
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
|
||||
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
|
||||
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
|
||||
//math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
|
||||
//math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
|
||||
//math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
|
||||
|
||||
if (row_test || munder_test || frac_test)
|
||||
Context.output_stream() << L"<m:e>";
|
||||
//if (row_test || munder_test || frac_test)
|
||||
// Context.output_stream() << L"<m:e>";
|
||||
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
math_element->oox_convert(Context);
|
||||
|
||||
if (row_test || munder_test || frac_test)
|
||||
Context.output_stream() << L"</m:e>";
|
||||
//if (row_test || munder_test || frac_test)
|
||||
// Context.output_stream() << L"</m:e>";
|
||||
|
||||
//office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
//math_element->oox_convert(Context);
|
||||
@ -320,6 +355,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
|
||||
Context.text_properties_->content().style_font_name_ = L"Cambria Math";
|
||||
Context.text_properties_->content().fo_font_size_ = odf_types::length(Context.base_font_size_, odf_types::length::pt);
|
||||
|
||||
Context.is_need_e_ = need_e_old;
|
||||
{
|
||||
std::wstringstream & strm = Context.math_style_stream();
|
||||
strm.str( std::wstring() );
|
||||
|
||||
@ -71,11 +71,15 @@ void math_msub::oox_convert(oox::math_context & Context)
|
||||
strm << L"<m:sSub>";
|
||||
|
||||
strm << L"<m:e>";
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
math_element = dynamic_cast<office_math_element*>(content_[0].get());
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:e>";
|
||||
|
||||
strm << L"<m:sub>";
|
||||
Context.is_need_e_ = false; //??
|
||||
|
||||
math_element = dynamic_cast<office_math_element*>(content_[1].get());
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:sub>";
|
||||
@ -109,6 +113,8 @@ void math_msup::oox_convert(oox::math_context & Context)
|
||||
strm << L"<m:sSup>";
|
||||
|
||||
strm << L"<m:e>";
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
math_element = dynamic_cast<office_math_element*>(content_[0].get());
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:e>";
|
||||
@ -142,6 +148,8 @@ void math_msubsup::oox_convert(oox::math_context & Context)
|
||||
office_math_element* math_element = NULL;
|
||||
|
||||
strm << L"<m:sSubSup>";
|
||||
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
strm << L"<m:e>";
|
||||
math_element = dynamic_cast<office_math_element*>(content_[0].get());
|
||||
@ -328,6 +336,9 @@ void math_mover::oox_convert(oox::math_context & Context)
|
||||
strm << L"<m:limUpp>";
|
||||
strm << L"<m:limUppPr/>";
|
||||
strm << L"<m:e>";
|
||||
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
math_element = dynamic_cast<office_math_element*>(content_[0].get());
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:e>";
|
||||
@ -355,6 +366,13 @@ void math_munder::oox_convert(oox::math_context & Context)
|
||||
{//2 elements
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
bool need_e = Context.is_need_e_;
|
||||
if (need_e)
|
||||
{
|
||||
Context.output_stream() << L"<m:e>";
|
||||
}
|
||||
Context.is_need_e_ = false;
|
||||
|
||||
office_math_element* math_element = NULL;
|
||||
strm << L"<m:limLow>";
|
||||
strm << L"<m:limLowPr/>";
|
||||
@ -367,6 +385,12 @@ void math_munder::oox_convert(oox::math_context & Context)
|
||||
math_element->oox_convert(Context);
|
||||
strm << L"</m:lim>";
|
||||
strm << L"</m:limLow>";
|
||||
|
||||
if (need_e)
|
||||
{
|
||||
Context.output_stream() << L"</m:e>";
|
||||
}
|
||||
Context.is_need_e_ = need_e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,23 +92,30 @@ void math_mtr::oox_convert(oox::math_context & Context)
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
strm << L"<m:mr>";
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
|
||||
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
|
||||
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
|
||||
|
||||
if (row_test || munder_test || frac_test)
|
||||
Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
|
||||
|
||||
bool need_e_old = Context.is_need_e_;
|
||||
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
math_element->oox_convert(Context);
|
||||
|
||||
if (row_test || munder_test || frac_test)
|
||||
strm << L"</m:e>";
|
||||
}
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
//Context.is_need_e_ = content_.size() > 1 ? true : false;
|
||||
Context.is_need_e_ = true;
|
||||
|
||||
//math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
|
||||
//math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
|
||||
//math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
|
||||
//
|
||||
//if (row_test || munder_test || frac_test)
|
||||
// Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
|
||||
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
math_element->oox_convert(Context);
|
||||
|
||||
//if (row_test || munder_test || frac_test)
|
||||
// strm << L"</m:e>";
|
||||
}
|
||||
strm << L"</m:mr>";
|
||||
|
||||
Context.is_need_e_ = need_e_old;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -151,6 +158,7 @@ void math_mtd::oox_convert(oox::math_context & Context)
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
strm << L"<m:e>";
|
||||
Context.is_need_e_ = false;
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
|
||||
|
||||
@ -286,7 +286,7 @@ void math_mtext::oox_convert(oox::math_context & Context)
|
||||
if (text_)
|
||||
{
|
||||
Context.output_stream() << L"<m:r><m:rPr><m:nor/></m:rPr><m:t>";
|
||||
Context.output_stream() << *text_;
|
||||
Context.output_stream() << XmlUtils::EncodeXmlString(*text_);
|
||||
Context.output_stream() << L"</m:t></m:r>";
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,10 +87,6 @@ void content_xml_t::add_child_element( xml::sax * Reader, const std::wstring & N
|
||||
else if ( CP_CHECK_NAME(L"math", L"math") || CP_CHECK_NAME(L"", L"math"))
|
||||
{
|
||||
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"manifest", L"manifest")
|
||||
{
|
||||
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -104,8 +104,7 @@ void styles_container::add_style( const std::wstring & Name,
|
||||
map_[n] = pos;
|
||||
|
||||
// TODO: как правильно??
|
||||
std::wstring lName = Name;
|
||||
XmlUtils::GetLower(lName);
|
||||
std::wstring lName = XmlUtils::GetLower(Name);
|
||||
//if ( boost::algorithm::contains(lName, L"internet_20_link") )
|
||||
if (lName == L"internet_20_link")///???????????????
|
||||
hyperlink_style_pos_ = pos;
|
||||
|
||||
@ -88,8 +88,8 @@ void style_chart_properties::add_attributes( const xml::attributes_wc_ptr & Attr
|
||||
|
||||
_CP_OPT(int) iVal;
|
||||
|
||||
//CP_APPLY_ATTR(L"chart:symbol-type", iVal); if (iVal)content_.push_back(_property(L"symbol-type", iVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:gap-width", iVal); if (iVal)content_.push_back(_property(L"gap-width", iVal.get()));
|
||||
//CP_APPLY_ATTR(L"chart:symbol-type", iVal); if (iVal)content_.push_back(_property(L"symbol-type", iVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:gap-width", iVal); if (iVal)content_.push_back(_property(L"gap-width", iVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:overlap", iVal); if (iVal)content_.push_back(_property(L"overlap", iVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:spline-order", iVal); if (iVal)content_.push_back(_property(L"spline-order", iVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:spline-resolution",iVal); if (iVal)content_.push_back(_property(L"spline-resolution", iVal.get()));
|
||||
@ -100,8 +100,8 @@ void style_chart_properties::add_attributes( const xml::attributes_wc_ptr & Attr
|
||||
|
||||
CP_APPLY_ATTR(L"chart:maximum", dVal); if (dVal)content_.push_back(_property(L"maximum", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:minimum", dVal); if (dVal)content_.push_back(_property(L"minimum", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:origin", dVal); if (dVal)content_.push_back(_property(L"origin", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:interval-major", dVal); if (dVal)content_.push_back(_property(L"interval-major", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:origin", dVal); if (dVal)content_.push_back(_property(L"origin", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:interval-major", dVal); if (dVal)content_.push_back(_property(L"interval-major", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:error-percentage",dVal); if (dVal)content_.push_back(_property(L"error-percentage", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:error-margin", dVal); if (dVal)content_.push_back(_property(L"error-margin", dVal.get()));
|
||||
CP_APPLY_ATTR(L"chart:error-lower-limit",dVal); if (dVal)content_.push_back(_property(L"error-lower-limit", dVal.get()));
|
||||
|
||||
@ -407,7 +407,7 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
|
||||
switch (style_text_underline_style_->get_type())
|
||||
{
|
||||
case line_style::Solid:
|
||||
if (underlineBold) underline = L"thick";
|
||||
if (underlineBold) underline = L"heavy";
|
||||
else underline = L"sng";
|
||||
break;
|
||||
case line_style::Dotted:
|
||||
|
||||
@ -62,9 +62,9 @@ void table_calculation_settings::add_child_element( xml::sax * Reader, const std
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_null_date_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"null-date")
|
||||
{
|
||||
}
|
||||
//else if CP_CHECK_NAME(L"table", L"iteration")
|
||||
//{
|
||||
//}
|
||||
else
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
|
||||
@ -108,6 +108,10 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
Context.get_pivots_context().set_view_target_range(ref);
|
||||
Context.get_pivots_context().set_view_target_table_name(sheet_name);
|
||||
}
|
||||
if (table_grand_total_)
|
||||
{
|
||||
Context.get_pivots_context().set_grand_total(table_grand_total_->get_type());
|
||||
}
|
||||
|
||||
if (table_buttons_)
|
||||
{
|
||||
@ -123,6 +127,9 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
if (table_identify_categories_)
|
||||
Context.get_pivots_context().set_identify_categories(table_identify_categories_->get());
|
||||
|
||||
if (table_ignore_empty_rows_)
|
||||
Context.get_pivots_context().set_ignore_empty_rows(table_ignore_empty_rows_->get());
|
||||
|
||||
if (table_drill_down_ondouble_click_)
|
||||
Context.get_pivots_context().set_drill(table_drill_down_ondouble_click_->get());
|
||||
|
||||
@ -155,6 +162,7 @@ void table_data_pilot_field::add_attributes( const xml::attributes_wc_ptr & Attr
|
||||
CP_APPLY_ATTR(L"loext:ignore-selected-page" , loext_ignore_selected_page_);
|
||||
CP_APPLY_ATTR(L"table:selected-page" , table_selected_page_);
|
||||
CP_APPLY_ATTR(L"table:is-data-layout-field" , table_is_data_layout_field_);
|
||||
CP_APPLY_ATTR(L"tableooo:display-name" , table_display_name_);
|
||||
}
|
||||
|
||||
void table_data_pilot_field::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -175,6 +183,9 @@ void table_data_pilot_field::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
|
||||
Context.get_pivots_context().set_field_name(table_source_field_name_.get_value_or(L""));
|
||||
|
||||
if (table_display_name_)
|
||||
Context.get_pivots_context().set_field_display(*table_display_name_);
|
||||
|
||||
if (table_is_data_layout_field_)
|
||||
Context.get_pivots_context().set_field_data_layout(table_is_data_layout_field_->get());
|
||||
|
||||
@ -217,7 +228,24 @@ void table_data_pilot_field_reference::add_attributes( const xml::attributes_wc_
|
||||
|
||||
void table_data_pilot_field_reference::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
Context.get_pivots_context().start_field_reference();
|
||||
if (table_field_name_)
|
||||
{
|
||||
Context.get_pivots_context().set_field_ref_name(*table_field_name_);
|
||||
}
|
||||
if (table_type_)
|
||||
{
|
||||
Context.get_pivots_context().set_field_ref_type(table_type_->get_type());
|
||||
}
|
||||
if (table_member_name_)
|
||||
{
|
||||
Context.get_pivots_context().set_field_ref_member_name(*table_member_name_);
|
||||
}
|
||||
if (table_member_type_)
|
||||
{
|
||||
Context.get_pivots_context().set_field_ref_member_type(table_member_type_->get_type());
|
||||
}
|
||||
Context.get_pivots_context().end_field_reference();
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_database_source_table::ns = L"table";
|
||||
@ -405,6 +433,8 @@ void table_data_pilot_groups::xlsx_convert(oox::xlsx_conversion_context & Contex
|
||||
{
|
||||
if (table_grouped_by_)
|
||||
Context.get_pivots_context().set_field_groups(table_grouped_by_->get_type());
|
||||
else
|
||||
Context.get_pivots_context().set_field_groups(7);
|
||||
|
||||
if (table_source_field_name_)
|
||||
Context.get_pivots_context().set_field_groups_source(*table_source_field_name_);
|
||||
@ -429,10 +459,16 @@ void table_data_pilot_group::add_child_element( xml::sax * Reader, const std::ws
|
||||
}
|
||||
void table_data_pilot_group::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
Context.get_pivots_context().start_field_group();
|
||||
|
||||
if (table_name_)
|
||||
Context.get_pivots_context().set_field_group_name (*table_name_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
Context.get_pivots_context().end_field_group();
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_members::ns = L"table";
|
||||
@ -462,7 +498,7 @@ void table_data_pilot_member::add_attributes( const xml::attributes_wc_ptr & Att
|
||||
|
||||
void table_data_pilot_member::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_pivots_context().add_field_cache(-1, table_name_.get_value_or(L""));
|
||||
Context.get_pivots_context().add_field_cache(-1, table_name_.get_value_or(L""), table_show_details_ ? table_show_details_->get() : true);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_group_member::ns = L"table";
|
||||
@ -470,12 +506,12 @@ const wchar_t * table_data_pilot_group_member::name = L"data-pilot-group-member"
|
||||
|
||||
void table_data_pilot_group_member::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:name", table_name_);
|
||||
CP_APPLY_ATTR(L"table:name", table_name_);
|
||||
}
|
||||
|
||||
void table_data_pilot_group_member::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
Context.get_pivots_context().add_field_cache(-1, table_name_.get_value_or(L""));
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_subtotals::ns = L"table";
|
||||
|
||||
@ -130,6 +130,7 @@ public:
|
||||
_CP_OPT(odf_types::Bool) loext_ignore_selected_page_;
|
||||
_CP_OPT(std::wstring) table_selected_page_;
|
||||
_CP_OPT(odf_types::Bool) table_is_data_layout_field_;
|
||||
_CP_OPT(std::wstring) table_display_name_;
|
||||
|
||||
office_element_ptr reference_;
|
||||
office_element_ptr level_;
|
||||
|
||||
@ -78,13 +78,16 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
|
||||
|
||||
void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
bool bEndTable = Context.get_table_context().state()->get_end_table();
|
||||
|
||||
if (attlist_.table_number_rows_repeated_ > 1 && empty())
|
||||
{
|
||||
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
|
||||
return;
|
||||
}
|
||||
if (attlist_.table_number_rows_repeated_ > 0xf000 && empty_content_cells())
|
||||
if (attlist_.table_number_rows_repeated_ > 0x0f00 && empty_content_cells() || bEndTable)//0xf000 - conv_KDZO3J3xLIbZ5fC0HR0__xlsx.ods
|
||||
{
|
||||
Context.get_table_context().state()->set_end_table();
|
||||
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
|
||||
return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods
|
||||
}
|
||||
@ -490,7 +493,6 @@ void table_table_column::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
size_t style_ = Context.get_style_manager().xfId(NULL,NULL, &cellFormatProperties, NULL, L"", set_default);
|
||||
|
||||
if (style_>=0)
|
||||
//if (set_default)
|
||||
CP_XML_ATTR(L"style", style_ );
|
||||
}
|
||||
@ -732,7 +734,15 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
int y, m, d;
|
||||
if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
|
||||
{
|
||||
number_val = boost::lexical_cast<std::wstring>(oox::convertDate(y, m, d));
|
||||
boost::int64_t intDate = oox::convertDate(y, m, d);
|
||||
if (intDate > 0)
|
||||
{
|
||||
number_val = boost::lexical_cast<std::wstring>(intDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
str_val = attr.office_date_value_.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -743,11 +753,19 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
if (attr.office_time_value_)
|
||||
{
|
||||
const std::wstring tv = attr.office_time_value_.get();
|
||||
int h,m;
|
||||
int h, m;
|
||||
double s;
|
||||
if (oox::parseTime(tv, h, m, s))
|
||||
{
|
||||
number_val = boost::lexical_cast<std::wstring>(oox::convertTime(h, m, s));
|
||||
boost::int64_t intTime = oox::convertTime(h, m, s);
|
||||
if (intTime > 0)
|
||||
{
|
||||
number_val = boost::lexical_cast<std::wstring>(intTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
str_val = tv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -900,34 +918,262 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
std::wostream & strm = Context.current_sheet().sheetData();
|
||||
|
||||
const int sharedStringId = content_.xlsx_convert(Context, NULL);
|
||||
|
||||
const common_value_and_type_attlist & attr = attlist_.common_value_and_type_attlist_;
|
||||
|
||||
office_value_type::type odf_value_type = office_value_type::Custom;
|
||||
oox::XlsxCellType::type t_val = oox::XlsxCellType::s;
|
||||
std::wstring formula = attlist_.table_formula_.get_value_or(L"");
|
||||
|
||||
std::wstring number_val;
|
||||
_CP_OPT(bool) bool_val;
|
||||
_CP_OPT(std::wstring) str_val;
|
||||
|
||||
std::wstring num_format;
|
||||
|
||||
size_t xfId_last_set = 0;
|
||||
int empty_cell_count = 0;
|
||||
bool skip_next_cell = false;
|
||||
bool is_style_visible = true;
|
||||
bool is_data_visible = false;
|
||||
// вычислить стиль для ячейки
|
||||
|
||||
std::wstring cellStyleName = attlist_.table_style_name_.get_value_or(L"");
|
||||
std::wstring columnStyleName = Context.get_table_context().default_column_cell_style();
|
||||
std::wstring rowStyleName = Context.get_table_context().default_row_cell_style();
|
||||
|
||||
if (attlist_.table_number_columns_repeated_ > 1)
|
||||
columnStyleName.clear(); // могут быть разные стили колонок Book 24.ods
|
||||
|
||||
odf_read_context & odfContext = Context.root()->odf_context();
|
||||
|
||||
style_instance *defaultCellStyle=NULL, *defaultColumnCellStyle = NULL, *defaultRowCellStyle =NULL, *cellStyle = NULL;
|
||||
try
|
||||
{
|
||||
defaultCellStyle = odfContext.styleContainer().style_default_by_type(style_family::TableCell);
|
||||
|
||||
defaultColumnCellStyle = odfContext.styleContainer().style_by_name(columnStyleName, style_family::TableCell, false);
|
||||
defaultRowCellStyle = odfContext.styleContainer().style_by_name(rowStyleName, style_family::TableCell, false);
|
||||
cellStyle = odfContext.styleContainer().style_by_name(cellStyleName, style_family::TableCell, false);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
_CP_LOG << L"[error]: style wrong\n";
|
||||
}
|
||||
|
||||
std::wstring data_style = CalcCellDataStyle(Context, columnStyleName, rowStyleName, cellStyleName);
|
||||
|
||||
// стили не наследуются
|
||||
std::vector<const style_instance *> instances;
|
||||
instances.push_back(defaultCellStyle);
|
||||
|
||||
if (defaultColumnCellStyle)
|
||||
instances.push_back(defaultColumnCellStyle);
|
||||
|
||||
if (defaultRowCellStyle)
|
||||
{
|
||||
if (instances.size() > 1)
|
||||
instances[1] = defaultRowCellStyle;
|
||||
else
|
||||
instances.push_back(defaultRowCellStyle);
|
||||
}
|
||||
|
||||
if (cellStyle)
|
||||
{
|
||||
if (instances.size() > 1)
|
||||
instances[1] = cellStyle;
|
||||
else
|
||||
instances.push_back(cellStyle);
|
||||
}
|
||||
|
||||
text_format_properties_content textFormatProperties = calc_text_properties_content (instances);
|
||||
paragraph_format_properties parFormatProperties = calc_paragraph_properties_content (instances);
|
||||
style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties (instances);
|
||||
|
||||
if (attr.office_value_type_)
|
||||
odf_value_type = attr.office_value_type_->get_type();
|
||||
|
||||
if ((odf_value_type == office_value_type::Float) ||
|
||||
(odf_value_type == office_value_type::Custom && attr.office_value_))
|
||||
{
|
||||
t_val = oox::XlsxCellType::n;
|
||||
number_val = attr.office_value_.get_value_or(L"");
|
||||
}
|
||||
else if (odf_value_type == office_value_type::Percentage)
|
||||
{
|
||||
t_val = oox::XlsxCellType::n;
|
||||
number_val = attr.office_value_.get_value_or(L"");
|
||||
}
|
||||
else if (odf_value_type == office_value_type::Currency)
|
||||
{
|
||||
t_val = oox::XlsxCellType::n;
|
||||
number_val = attr.office_value_.get_value_or(L"");
|
||||
}
|
||||
else if ((odf_value_type == office_value_type::Date) ||
|
||||
(odf_value_type == office_value_type::Custom && attr.office_date_value_))
|
||||
{
|
||||
t_val = oox::XlsxCellType::n;
|
||||
if (attr.office_date_value_)
|
||||
{
|
||||
int y, m, d;
|
||||
if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
|
||||
{
|
||||
boost::int64_t intDate = oox::convertDate(y, m, d);
|
||||
if (intDate > 0)
|
||||
{
|
||||
number_val = boost::lexical_cast<std::wstring>(intDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
str_val = attr.office_date_value_.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((odf_value_type == office_value_type::Time) ||
|
||||
(odf_value_type == office_value_type::Custom && attr.office_time_value_))
|
||||
{
|
||||
t_val = oox::XlsxCellType::n;
|
||||
if (attr.office_time_value_)
|
||||
{
|
||||
const std::wstring tv = attr.office_time_value_.get();
|
||||
int h,m;
|
||||
double s;
|
||||
if (oox::parseTime(tv, h, m, s))
|
||||
{
|
||||
number_val = boost::lexical_cast<std::wstring>(oox::convertTime(h, m, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((odf_value_type == office_value_type::Boolean) ||
|
||||
(odf_value_type == office_value_type::Custom && attr.office_boolean_value_))
|
||||
{
|
||||
t_val = oox::XlsxCellType::b;
|
||||
if (attr.office_boolean_value_) bool_val = oox::parseBoolVal(attr.office_boolean_value_.get());
|
||||
}
|
||||
else if ((odf_value_type == office_value_type::String) ||
|
||||
(odf_value_type == office_value_type::Custom && attr.office_string_value_))
|
||||
{
|
||||
t_val = oox::XlsxCellType::str;
|
||||
if (attr.office_string_value_) str_val = attr.office_string_value_.get();
|
||||
}
|
||||
|
||||
if (!data_style.empty())
|
||||
{
|
||||
office_element_ptr elm = odfContext.numberStyles().find_by_style_name(data_style);
|
||||
number_style_base *num_style = dynamic_cast<number_style_base*>(elm.get());
|
||||
|
||||
if (num_style)
|
||||
{
|
||||
Context.get_num_format_context().start_complex_format();
|
||||
num_style->oox_convert(Context.get_num_format_context());
|
||||
Context.get_num_format_context().end_complex_format();
|
||||
|
||||
num_format = Context.get_num_format_context().get_last_format();
|
||||
}
|
||||
}
|
||||
|
||||
oox::xlsx_cell_format cellFormat;
|
||||
|
||||
cellFormat.set_cell_type(t_val);
|
||||
cellFormat.set_num_format(oox::odf_string_to_build_in(odf_value_type));
|
||||
|
||||
is_style_visible = (!cellStyleName.empty() || defaultColumnCellStyle) ? true : false;
|
||||
|
||||
if ( content_.elements_.size() > 0 ||
|
||||
!formula.empty() ||
|
||||
( t_val == oox::XlsxCellType::n && !number_val.empty()) ||
|
||||
( t_val == oox::XlsxCellType::b && bool_val) ||
|
||||
(( t_val == oox::XlsxCellType::str || oox::XlsxCellType::inlineStr) && str_val)) is_data_visible = true;
|
||||
|
||||
if (attlist_.table_number_columns_repeated_ < 199 && last_cell_) last_cell_ = false;
|
||||
|
||||
int cell_repeated_max = Context.current_table_column() + attlist_.table_number_columns_repeated_ + 1;
|
||||
|
||||
if (cell_repeated_max >= 1024 && cellStyleName.empty() && last_cell_ && !is_data_visible)
|
||||
{//Book 24.ods
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_style_visible)
|
||||
{
|
||||
xfId_last_set = Context.get_style_manager().xfId(&textFormatProperties, &parFormatProperties, &cellFormatProperties, &cellFormat, num_format, false, is_style_visible);
|
||||
}
|
||||
|
||||
for (unsigned int r = 0; r < attlist_.table_number_columns_repeated_; ++r)
|
||||
{
|
||||
Context.start_table_covered_cell();
|
||||
const int xfId = Context.get_current_cell_style_id();
|
||||
Context.start_table_covered_cell ();
|
||||
|
||||
if (is_style_visible)
|
||||
Context.set_current_cell_style_id(xfId_last_set);
|
||||
|
||||
const int sharedStringId = content_.xlsx_convert(Context, &textFormatProperties);
|
||||
|
||||
if (t_val == oox::XlsxCellType::str && sharedStringId >=0)
|
||||
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
|
||||
|
||||
if (skip_next_cell)break;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
// пустые ячейки пропускаем.
|
||||
if ( is_data_visible || ((cellStyle || defaultColumnCellStyle) && is_style_visible))
|
||||
{
|
||||
CP_XML_NODE(L"c")
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_ATTR(L"r", Context.current_cell_address());
|
||||
|
||||
if (xfId >= 0)
|
||||
{
|
||||
CP_XML_ATTR(L"s", xfId);
|
||||
}
|
||||
CP_XML_NODE(L"c")
|
||||
{
|
||||
CP_XML_ATTR(L"r", oox::getCellAddress(Context.current_table_column(), Context.current_table_row()));
|
||||
CP_XML_ATTR(L"t", oox::cellType2Str(t_val));
|
||||
CP_XML_ATTR(L"s", xfId_last_set);
|
||||
|
||||
if (sharedStringId >=0)
|
||||
{
|
||||
CP_XML_NODE(L"v")
|
||||
if (!formula.empty())
|
||||
{
|
||||
CP_XML_CONTENT(sharedStringId);
|
||||
const std::wstring xlsxFormula = formulas_converter.convert(formula);
|
||||
if (!xlsxFormula.empty())
|
||||
{
|
||||
CP_XML_NODE(L"f")
|
||||
{
|
||||
CP_XML_CONTENT(xlsxFormula);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // c
|
||||
|
||||
if (sharedStringId >= 0 && t_val == oox::XlsxCellType::s)
|
||||
{
|
||||
CP_XML_NODE(L"v") { CP_XML_CONTENT(sharedStringId); }
|
||||
}
|
||||
else if ((t_val == oox::XlsxCellType::str || t_val == oox::XlsxCellType::inlineStr) && str_val)
|
||||
{
|
||||
CP_XML_NODE(L"v") { CP_XML_CONTENT(str_val.get()); }
|
||||
}
|
||||
else if (t_val == oox::XlsxCellType::n && !number_val.empty())
|
||||
{
|
||||
CP_XML_NODE(L"v") { CP_XML_CONTENT(number_val);}
|
||||
}
|
||||
else if (t_val == oox::XlsxCellType::b && bool_val)
|
||||
{
|
||||
CP_XML_NODE(L"v") { CP_XML_CONTENT((int)(bool_val.get())); }
|
||||
}
|
||||
}
|
||||
if ( is_data_visible || (cellStyle && is_style_visible && !last_cell_))
|
||||
{
|
||||
Context.non_empty_row();
|
||||
empty_cell_count = 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty_cell_count++;
|
||||
//Уведомление_о_вручении.ods - 13 повторов пустых с cellStyle=NULL - нужные !!!
|
||||
if (empty_cell_count > 19 && last_cell_&& (attlist_.table_number_columns_repeated_> 299 || cellStyle == NULL))
|
||||
{//пишем простыню только если задан стиль тока для этих ячеек
|
||||
skip_next_cell = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_cell_) // Vehicle log book.ods (row = 24 and more)
|
||||
skip_next_cell = true;
|
||||
}
|
||||
|
||||
Context.end_table_covered_cell();
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderThrough=""
|
||||
WarningLevel="3"
|
||||
@ -1111,10 +1111,6 @@
|
||||
RelativePath="..\include\cpdoccore\CPColorUtils.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\cpdoccore\CPHash.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\cpdoccore\CPNoncopyable.h"
|
||||
>
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderThrough=""
|
||||
WarningLevel="3"
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderThrough=""
|
||||
WarningLevel="3"
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
AdditionalIncludeDirectories=""
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
|
||||
@ -44,7 +44,7 @@ namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
|
||||
_mediaitems::item::item( std::wstring const & _oox_ref,
|
||||
_mediaitems::item::item(std::wstring const & _oox_ref,
|
||||
Type _type,
|
||||
std::wstring const & _odf_ref
|
||||
)
|
||||
@ -58,23 +58,31 @@ _mediaitems::item::item( std::wstring const & _oox_ref,
|
||||
|
||||
void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wstring & odf_ref)
|
||||
{
|
||||
std::wstring output_sub_path;//
|
||||
std::wstring output_sub_path;
|
||||
std::wstring output_fileName;
|
||||
int number=0;
|
||||
|
||||
if (type == typeImage)
|
||||
{
|
||||
output_sub_path = L"Pictures/";
|
||||
number= count_image+1;
|
||||
number = count_image + 1;
|
||||
}
|
||||
else
|
||||
else if (type == typeMedia)
|
||||
{
|
||||
output_sub_path = L"Media/";
|
||||
number= count_media+1;
|
||||
number = count_media + 1;
|
||||
}
|
||||
|
||||
|
||||
output_fileName = utils::media::create_file_name(oox_ref, type, number);//guid???
|
||||
else if (type == typeOleObject)
|
||||
{
|
||||
output_sub_path = L"";
|
||||
number = count_object + 1;
|
||||
}
|
||||
else if (type == typeObjectReplacement)
|
||||
{
|
||||
output_sub_path = L"ObjectReplacements/";
|
||||
number = count_image_object + 1;
|
||||
}
|
||||
output_fileName = utils::media::create_file_name(oox_ref, type, number); //guid???
|
||||
|
||||
std::wstring input_path = oox_ref;
|
||||
|
||||
@ -92,16 +100,25 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (output_path .length() < 1)
|
||||
if (output_path.length() < 1)
|
||||
{
|
||||
output_path = ( output_sub_path + output_fileName) ;
|
||||
if ( type == typeImage)
|
||||
{
|
||||
count_image++;
|
||||
}
|
||||
else
|
||||
else if ( type == typeMedia)
|
||||
{
|
||||
count_media++;
|
||||
|
||||
}
|
||||
else if ( type == typeOleObject)
|
||||
{
|
||||
count_object++;
|
||||
}
|
||||
else if ( type == typeObjectReplacement)
|
||||
{
|
||||
count_image_object++;
|
||||
}
|
||||
|
||||
items_.push_back( item(input_path, type, xml::utils::replace_text_to_xml(output_path)) );
|
||||
}
|
||||
|
||||
@ -42,13 +42,14 @@ class rels;
|
||||
class _mediaitems
|
||||
{
|
||||
public:
|
||||
enum Type { typeUnknown = 0, typeImage, typeMedia};
|
||||
//oleObject ???
|
||||
enum Type { typeUnknown = 0, typeImage, typeMedia, typeOleObject, typeObjectReplacement};
|
||||
|
||||
_mediaitems()
|
||||
{
|
||||
count_image =0;
|
||||
count_media =0;
|
||||
count_image = 0;
|
||||
count_media = 0;
|
||||
count_object = 0;
|
||||
count_image_object = 0;
|
||||
}
|
||||
|
||||
struct item
|
||||
@ -66,6 +67,8 @@ public:
|
||||
|
||||
size_t count_image;
|
||||
size_t count_media;
|
||||
size_t count_object;
|
||||
size_t count_image_object;
|
||||
|
||||
void add_or_find(const std::wstring & oox_ref, Type type, std::wstring & odf_ref);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user