Compare commits

..

36 Commits

Author SHA1 Message Date
d9986d09cd x2t - fix users file 2017-12-13 19:15:13 +03:00
bd67f4bf1c . 2017-12-13 15:13:37 +03:00
475bfaf93d Merge remote-tracking branch 'origin/hotfix/v5.0.7' into develop 2017-12-13 15:12:19 +03:00
1a8af4d8ed x2t - fix users file 2017-12-13 15:11:16 +03:00
cdf8dc7a4c Changed cef update condition 2017-12-13 12:55:54 +03:00
d71552bddd Merge remote-tracking branch 'origin/hotfix/v5.0.7' into develop
# Conflicts:
#	ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp
2017-12-13 12:40:08 +03:00
548c5ab608 x2t - fix users files 2017-12-13 11:59:49 +03:00
6a01384023 . 2017-12-13 00:01:15 +03:00
d70f36e36d DocFormat - fix users files 2017-12-12 19:41:50 +03:00
f65984f079 . 2017-12-12 19:41:16 +03:00
5b48a7a330 DocFormat - fix users file, add data form field 2017-12-12 19:10:08 +03:00
1496aece57 v8 (mac os) 2017-12-12 19:06:09 +03:00
60cf51ad0d Move ASCDOCUMENTSCORE to separated target 2017-12-12 16:30:44 +03:00
8e7231b322 removed unused code 2017-12-12 12:43:33 +03:00
2b339b6842 Cherrypick from develop 2017-12-12 12:43:03 +03:00
fb0dbfc231 Cherrypick from develop 2017-12-12 12:40:28 +03:00
756613e883 Merge pull request #56 from ONLYOFFICE/hotfix/v5.0.7
for b599a6bc43 to fix build error
2017-12-11 20:17:01 +03:00
ede03fafea for b599a6bc43 to fix build error 2017-12-11 19:52:44 +03:00
bdec91bfd5 Merge remote-tracking branch 'origin/hotfix/v5.0.7' into develop 2017-12-11 18:44:50 +03:00
260c2edd21 . 2017-12-11 18:42:11 +03:00
3eeec8fc67 RtfFormat - fix users file 2017-12-11 18:39:37 +03:00
ba6c7e8151 Merge remote-tracking branch 'origin/feature/v5.0.7.1' into develop 2017-12-11 14:05:03 +03:00
41a213491e fix image content type 2017-12-11 13:45:28 +03:00
b599a6bc43 Add open/save JsaProject.bin for OnlyOffice Macros 2017-12-11 13:31:48 +03:00
a0fd139027 Merge pull request #55 from ONLYOFFICE/feature/v5.0.7.1
Feature/v5.0.7.1
2017-12-06 18:54:01 +03:00
48852bc618 removed unused code 2017-12-06 18:51:58 +03:00
20b781cb7e pdf checker bug 2017-12-06 18:50:09 +03:00
704b3b709f update cef if newer version exist 2017-12-06 18:21:58 +03:00
e4674915c2 Update cef if exist newer version 2017-12-06 17:19:46 +03:00
51fe936e5f ... 2017-12-06 12:18:06 +03:00
d8b177411f x2t - options for check macro in file 2017-12-05 16:56:50 +03:00
717b628055 ... 2017-12-05 14:37:10 +03:00
e4f94646b6 x2t version up 2017-12-05 10:54:43 +03:00
dcec7447e4 XlsFormat - apply theme style from format office 2010 and later 2017-12-04 19:24:27 +03:00
5f12552f78 XlsFormat - theme 2017-12-03 16:09:35 +03:00
e7bbbec0de v5.0.5 2017-11-27 17:06:49 +03:00
105 changed files with 1998 additions and 696 deletions

View File

@ -559,7 +559,7 @@ 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 );
@ -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" );
@ -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" );
@ -1257,20 +1282,20 @@ namespace DocFileFormat
{
case sprmTDefTable:
case sprmOldTDefTable:
{
unsigned char itcMac = iter->Arguments[0];
{
unsigned char itcMac = iter->Arguments[0];
while(boundaries.size() < itcMac + 1)
boundaries.push_back(-0x7fff);
short boundary0 = -0x7fff;
for (unsigned char i = 0; i < itcMac; i++)
{
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
{
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
{
{
if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff)
{
boundaries[i] = boundary1;
@ -1280,12 +1305,12 @@ namespace DocFileFormat
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() )
{
boundaries_all.push_back( boundary1 );
}
}
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
{
{
boundaries_all.push_back( boundary2 );
}
}
boundary0 = boundary1;
}break;
}
@ -1513,11 +1538,11 @@ 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, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
{
int cp = initialCp;
int cp = initialCp;
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
@ -1530,7 +1555,7 @@ namespace DocFileFormat
RELEASEOBJECT( tcpMapping );
//write the paragraphs of the cell
//write the paragraphs of the cell
while ( cp < cpCellEnd )
{
//cp = writeParagraph(cp);
@ -1561,7 +1586,7 @@ namespace DocFileFormat
}
}
//end w:tc
//end w:tc
m_pXmlWriter->WriteNodeEnd( L"w:tc" );
return cp;

View File

@ -48,6 +48,8 @@
#include "OleObjectMapping.h"
#include "ConversionContext.h"
#include "IMapping.h"
#include "FormFieldData.h"
#include "FormFieldDataMapping.h"
namespace DocFileFormat
{

View 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;
}
}
}
}

View 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;
};
}

View 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;
};
}

View File

@ -34,6 +34,7 @@
#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
{

View File

@ -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,26 +86,30 @@ 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;
if (lMinF <= point.x)
{
int index = (DWORD)point.x - 0x80000000;
if (index >= 0 && index < (int)guides.size())
if (index >= 0 && index < guides.size())
{
point.x = guides[index].param3;
}
@ -144,7 +117,7 @@ namespace DocFileFormat
if (lMinF <= point.y)
{
int index = (DWORD)point.y - 0x80000000;
if (index >= 0 && index < (int)guides.size())
if (index >= 0 && index < guides.size())
{
point.y = guides[index].param3;
}

View File

@ -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)

View File

@ -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"
@ -144,9 +145,9 @@ namespace DocFileFormat
{
if (docFile == NULL) return S_FALSE;
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
if (storageOut == NULL) return S_FALSE;
if (storageOut->open(true, true)==false)
{
delete storageOut;

View File

@ -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>();

View File

@ -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:
{
@ -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)
{
@ -2165,7 +2167,7 @@ namespace DocFileFormat
//todooo нарисовать кастомный шейп
}
else
WritePrimitiveProps(primitive, (index==0 ? true : false));
WritePrimitiveProps(primitive, (index==0?true:false));
if (primitive->type == 0x0000)

View File

@ -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

View File

@ -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"

View File

@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
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"
@ -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"
>

View File

@ -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
#pragma comment(lib, "Rpcrt4.lib")
HRESULT convert_single(std::wstring sSrcDoc)
HRESULT convert_single(std::wstring srcFileName)
{
HRESULT hr = S_OK;
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);
std::wstring sDstDocx;
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);

View File

@ -442,6 +442,10 @@
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>

View File

@ -3746,6 +3746,21 @@ public:
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;

View File

@ -477,8 +477,10 @@ extern int g_nCurFormatVersion;
MoveFromRangeEnd = 19,
MoveToRangeStart = 20,
MoveToRangeEnd = 21,
BookmarkStart = 22,
BookmarkEnd = 23
JsaProject = 22,
BookmarkStart = 23,
BookmarkEnd = 24
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{

View File

@ -2992,6 +2992,7 @@ namespace BinDocxRW
Binary_tblPrWriter btblPrs;
OOX::Logic::CSectionProperty* pSectPr;
OOX::Logic::CBackground * pBackground;
OOX::CDocument* poDocument;
bool m_bWriteSectPr;//Записывать ли свойства верхнего уровня в данном экземпляре BinaryOtherTableWriter
//---------------------------------
@ -3000,6 +3001,7 @@ namespace BinDocxRW
{
pBackground = NULL;
pSectPr = NULL;
poDocument = NULL;
m_bWriteSectPr = false;
}
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, OOX::IFileContainer *rels, std::vector<std::wstring>& aShapeTypes)
@ -3110,6 +3112,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)
{
@ -7893,6 +7912,7 @@ namespace BinDocxRW
oBinaryDocumentTableWriter.pSectPr = pFirstSectPr;
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = poDocument;
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
//Write Vba

View File

@ -67,7 +67,9 @@ public:
}
HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros);
long OpenFile(const std::wstring & fileName, const std::wstring & password, bool &bMacros);
bool CloseFile();
private:
int m_Status;
@ -76,8 +78,7 @@ private:
std::wstring m_strTempDirectory;
std::wstring m_sTempDecryptFileName;
long OpenFile(const std::wstring & fileName, const std::wstring & password, bool &bMacros);
bool CloseFile();
std::wstring GetDirectory(std::wstring strFileName);
};

View File

@ -40,6 +40,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
#include "../../Common/Base64.h"
@ -292,7 +293,7 @@ namespace NSBinPptxRW
}
}
}
else if (!strExts.empty())
if (!strExts.empty())
{
m_pContentTypes->AddDefault(strExts.substr(1));
}
@ -1235,7 +1236,7 @@ namespace NSBinPptxRW
m_pWriter->WriteString(strRels);
}
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsNotesMaster, bool bIsVbaProject)
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsNotesMaster, bool bIsVbaProject, bool bIsJsaProject)
{
if (bIsNotesMaster)
{
@ -1266,6 +1267,12 @@ namespace NSBinPptxRW
L"\" Type=\"http://schemas.microsoft.com/office/2006/relationships/vbaProject\" Target=\"vbaProject.bin\"/>";
m_pWriter->WriteString(strRels4);
}
if (bIsJsaProject)
{
std::wstring strRels5 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
L"\" Type=\"" + OOX::FileTypes::JsaProject.RelationType() + L"\" Target=\"" + OOX::FileTypes::JsaProject.DefaultFileName().GetPath() + L"\"/>";
m_pWriter->WriteString(strRels5);
}
}
int CRelsGenerator::GetNextId()
{

View File

@ -425,7 +425,7 @@ namespace NSBinPptxRW
int WriteRels (const std::wstring& bsType, const std::wstring& bsTarget, const std::wstring& bsTargetMode);
int WriteHyperlink (const std::wstring& strLink, const bool& bIsActionInit);
void EndPresentationRels (bool bIsCommentsAuthors = false, bool bIsNotesMaster = false, bool bIsVbaProject = false );
void EndPresentationRels (bool bIsCommentsAuthors = false, bool bIsNotesMaster = false, bool bIsVbaProject = false, bool bIsJsaProject = false );
int GetNextId ();
void CloseRels ();

View File

@ -812,7 +812,7 @@ namespace NSBinPptxRW
++nCurrentRels;
}
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), bNotesMasterPresent, m_oPresentation.m_pVbaProject.is_init());
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), bNotesMasterPresent, m_oPresentation.m_pVbaProject.is_init(), m_oPresentation.m_pJsaProject.is_init());
m_oReader.m_pRels->CloseRels();
oXmlWriter.ClearNoAttack();

View File

@ -63,6 +63,7 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalImage.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalAudio.h"
@ -144,6 +145,8 @@ namespace PPTX
return smart_ptr<OOX::File>(new OOX::OleObject( filename, true ));
else if (relation.Type() == OOX::FileTypes::VbaProject)
return smart_ptr<OOX::File>(new OOX::VbaProject( filename, filename ));
else if (relation.Type() == OOX::FileTypes::JsaProject)
return smart_ptr<OOX::File>(new OOX::JsaProject( filename ));
return smart_ptr<OOX::File>(new OOX::UnknowTypeFile());
}

View File

@ -81,6 +81,10 @@ namespace PPTX
_presentation->m_bMacroEnabled = true;
_presentation->m_pVbaProject = _presentation->Get(OOX::FileTypes::VbaProject).smart_dynamic_cast<OOX::VbaProject>();
}
if (_presentation->IsExist(OOX::FileTypes::JsaProject))
{
_presentation->m_pJsaProject = _presentation->Get(OOX::FileTypes::JsaProject).smart_dynamic_cast<OOX::JsaProject>();
}
}
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = map.m_map.begin(); pPair != map.m_map.end(); ++pPair)

View File

@ -295,6 +295,12 @@ namespace PPTX
oNode.ReadAttributeBase(L"spid", vmlSpid);
result = true;
}
else
{
element.fromXML( oNode );
if (element.is_init())
result = true;
}
}
}
return result;

View File

@ -51,6 +51,7 @@
#include "Theme/ClrScheme.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
namespace PPTX
{
@ -233,6 +234,7 @@ namespace PPTX
}
pWriter->EndRecord();
}
pWriter->WriteRecord2(9, m_pJsaProject);
pWriter->EndRecord();
}
@ -352,9 +354,17 @@ namespace PPTX
m_bMacroEnabled = true;
}break;
case 9:
{
m_pJsaProject = new OOX::JsaProject();
m_pJsaProject->fromPPTY(pReader);
smart_ptr<OOX::File> file = m_pJsaProject.smart_dynamic_cast<OOX::File>();
FileContainer::Add(file);
}break;
default:
{
pReader->Seek(_end_pos);
pReader->SkipRecord();
return;
}
}
@ -468,6 +478,7 @@ namespace PPTX
public:
bool m_bMacroEnabled;
smart_ptr<OOX::VbaProject> m_pVbaProject;
smart_ptr<OOX::JsaProject> m_pJsaProject;
void SetClrMap(Logic::ClrMap map) {m_clrMap = map;}
void SetClrScheme(nsTheme::ClrScheme scheme) {m_clrScheme = scheme;}

View File

@ -1027,7 +1027,16 @@ bool RtfParagraphPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader&
}
}
COMMAND_RTF_BOOL( "intbl", paragraphProps->m_bInTable, sCommand, hasParameter, parameter )
COMMAND_RTF_INT ( "itap", paragraphProps->m_nItap, sCommand, hasParameter, parameter )
else if ( "itap" == sCommand && hasParameter)
{
//if (parameter == 0 && paragraphProps->m_bInTable && paragraphProps->m_nItap > 0)
//{
//
//// paragraphProps->m_bInTable = 0;
//}
//else
paragraphProps->m_nItap = parameter;
}
COMMAND_RTF_BOOL( "keep", paragraphProps->m_bKeep, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "keepn", paragraphProps->m_bKeepNext, sCommand, hasParameter, parameter )
COMMAND_RTF_BOOL( "pagebb", paragraphProps->m_bPageBB, sCommand, hasParameter, parameter )
@ -2283,7 +2292,8 @@ void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oRe
{
// 1 != oItem->m_oProperty.m_bInTable - параграф не в таблице
// PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap - выставлено свойство,что вложенность - nTargetItap - это не таблица( Нужно для чтения параграфов в таблицах )
if ( 1 != oItem->m_oProperty.m_bInTable || ( PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap ) )
if ( ( 1 != oItem->m_oProperty.m_bInTable || 0 == oItem->m_oProperty.m_nItap ) //Платежное_поручение.rtf
|| ( PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap ) )
{
if ( nCurItap > 0 ) //Если до этого были только параграфы в таблицах - завершаем таблицу
{
@ -2292,15 +2302,13 @@ void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oRe
for( int k = (int)aRows.size() - 1; k >= 0 ; k-- )
{
if ( aRowItaps[k] == nCurItap )
{
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
else
if ( aRowItaps[k] != nCurItap )
break;
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
//вычисляем свойства для OOX
oNewTable->CalculateGridProp();
@ -2339,15 +2347,13 @@ void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oRe
for( int k = (int)aRows.size() - 1; k >= 0 ; k-- )
{
if ( aRowItaps[k] == nCurItap )
{
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
else
if ( aRowItaps[k] != nCurItap )
break;
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
//вычисляем свойства для OOX
oNewTable->CalculateGridProp();
@ -2386,7 +2392,7 @@ void RtfParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oRe
//добавляем параграф во временные cell
aCellRenderables.push_back( oItem ); //содержит все параграфы, не разложенные по cell
aItaps.push_back( nCurItap ); //содержит все номера вложенности параграфов
if ( bEndCell )
{
RtfTableCellPtr oNewTableCell ( new RtfTableCell() );
@ -2456,6 +2462,9 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
}
else if ( "cell" == sCommand || "nestcell" == sCommand )
{
if (oReader.m_oState->m_oParagraphProp.m_bInTable == 1 && 0 == oReader.m_oState->m_oParagraphProp.m_nItap )//Платежное_поручение.rtf (ели по другому сбойная строка заменяется параграфами
oReader.m_oState->m_oParagraphProp.m_nItap = 1;
m_oCurParagraph->m_oProperty = oReader.m_oState->m_oParagraphProp;
m_oCurParagraph->m_oOldList = RtfOldListPtr( new RtfOldList() );
*m_oCurParagraph->m_oOldList = oReader.m_oState->m_oCurOldList;

View File

@ -65,7 +65,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Urlmon.lib"
AdditionalDependencies="Urlmon.lib Rpcrt4.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMT.lib"
IgnoreEmbeddedIDL="true"
@ -407,6 +407,10 @@
RelativePath="..\..\ASCOfficeOdfFile\src\odf\svg_parser.cpp"
>
</File>
<File
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>

View File

@ -60,7 +60,7 @@ HRESULT convert_single(std::wstring srcFileName)
std::wstring dstPath;
bool bMacros = true;
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password", L"C:\\Windows\\Fonts", NULL, bMacros);
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password", L"C:\\Windows\\Fonts", L"C:\\Windows\\Temp", NULL, bMacros);
if (bMacros)
{

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of AxisLine record in BIFF8
class AxisLine: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(AxisLine)

View File

@ -35,9 +35,6 @@
namespace XLS
{
// Logical representation of DataFormat record in BIFF8
class DataFormat: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(DataFormat)
@ -47,11 +44,10 @@ public:
~DataFormat();
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeDataFormat;
static const ElementType type = typeDataFormat;
_UINT16 xi;
_UINT16 yi;

View File

@ -31,8 +31,8 @@
*/
#include "ExternSheet.h"
#include <Logic/Biff_structures/XTI.h>
#include <Logic/Biff_structures/BiffString.h>
#include "../Biff_structures/XTI.h"
#include "../Biff_structures/BiffString.h"
namespace XLS
{

View File

@ -138,30 +138,13 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstr
}
else
CP_XML_ATTR(L"i", false);
//if (bCharSet.value())
//{
// CP_XML_NODE(L"charset")
// {
// CP_XML_ATTR(L"val", bCharSet);
// }
//}
switch(sss)
{
case 1: CP_XML_ATTR(L"cap", L"all");break;
case 2: CP_XML_ATTR(L"cap", L"small");break;
}
//if ((fCondense.value()) && (*fCondense.value()))
//{
// CP_XML_NODE(L"condense")
// {
// CP_XML_ATTR(L"val", (int)(*fCondense.value()));
// }
//}
//if ((fExtend.value()) && (fExtend))
// {
// CP_XML_NODE(L"extend")
// {
// CP_XML_ATTR(L"val", fExtend);
// }
// }
if ( (icv < 0x7fff) || color_ext.enabled )
{
if (color_ext.enabled )
@ -236,66 +219,7 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstr
{
CP_XML_NODE(namespace_ + L"rtl");
}
//if ((fOutline.value()) && (fOutline))
// {
// CP_XML_NODE(L"outline")
// {
// CP_XML_ATTR(L"val", fOutline);
// }
// }
//if (font.scheme)
//{
// CP_XML_NODE(L"scheme")
// {
// CP_XML_ATTR(L"val", *font.scheme);
// }
//}
//if ((fShadow.value()) && (fShadow))
// {
// CP_XML_NODE(L"shadow")
// {
// CP_XML_ATTR(L"val", fShadow);
// }
// }
//if ((fStrikeOut.value()) && (fStrikeOut))
//{
// CP_XML_NODE(L"strike")
// {
// CP_XML_ATTR(L"val", fStrikeOut);
// }
//}
// if ((uls.value()) && (*uls.value() > 0))
// {
// CP_XML_NODE(L"u")
// {
//switch(uls)
//{
// case 1: CP_XML_ATTR(L"val", "single");break;
// case 2: CP_XML_ATTR(L"val", "double");break;
// case 33: CP_XML_ATTR(L"val", "singleAccounting");break;
// case 34: CP_XML_ATTR(L"val", "doubleAccounting");break;
//}
// }
// }
// if ((sss.value()) && (*sss.value() > 0))
// {
// CP_XML_NODE(L"vertAlign")
// {
//switch(*sss.value())
//{
// case 1: CP_XML_ATTR(L"val", L"superscript");break;
// case 2: CP_XML_ATTR(L"val", L"subscript");break;
//}
//
// }
// }
}
}
return 0;

View File

@ -36,7 +36,6 @@
namespace XLS
{
// Logical representation of InterfaceEnd record in BIFF8
class InterfaceEnd: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(InterfaceEnd)
@ -47,6 +46,7 @@ public:
BaseObjectPtr clone();
static const ElementType type = typeInterfaceEnd;
void readFields(CFRecord& record);

View File

@ -31,8 +31,7 @@
*/
#include "Theme.h"
#include <fstream>
#include <iostream> // endl
#include "../../../DesktopEditor/common/File.h"
namespace XLS
{
@ -59,13 +58,15 @@ void Theme::readFields(CFRecord& record)
{
//default theme
}
else if (dwThemeVersion == 0)
//else if (dwThemeVersion == 0)
else
{
nThemeDataSize = record.getDataSize() - record.getRdPtr();
pThemeData = boost::shared_array<char>(new char[nThemeDataSize]);
memcpy(pThemeData.get(), record.getCurData<char>(), nThemeDataSize);
record.skipNunBytes(nThemeDataSize);
}
}

View File

@ -32,7 +32,7 @@
#include "TxO.h"
#include <Logic/Biff_records/Font.h>
#include "Font.h"
#include <utils.h>
@ -184,9 +184,9 @@ int TxO::serialize_vml (std::wostream & _stream)
{
iFmt = run->formatRun.ifnt;
Font *font = NULL;
if ((global_info->m_arFonts) && (iFmt >=0 && iFmt < global_info->m_arFonts->size()))
if (iFmt >= 0 && iFmt < global_info->m_arFonts.size())
{
font = dynamic_cast<Font *>(global_info->m_arFonts->at(iFmt).get());
font = dynamic_cast<Font *>(global_info->m_arFonts[iFmt].get());
}
if (font)
{
@ -281,12 +281,11 @@ int TxO::serialize (std::wostream & _stream)
int TxO::serialize_rPr (std::wostream & _stream, int iFmt, std::wstring namespace_)
{
if (!global_info) return 0;
if (!global_info->m_arFonts) return 0;
int sz = global_info->m_arFonts->size();
int sz = global_info->m_arFonts.size();
if (iFmt - 1 >= sz || iFmt < 1) return 0;
Font * font = dynamic_cast<Font*>(global_info->m_arFonts->at(iFmt-1).get());
Font * font = dynamic_cast<Font*>(global_info->m_arFonts[iFmt-1].get());
if (!font) return 0;

View File

@ -35,11 +35,10 @@
namespace XLS
{
XF::XF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell(cell_xf_current_id, style_xf_current_id),
style(cell_xf_current_id, style_xf_current_id),
ixfParent(0)
XF::XF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell (cell_xf_current_id, style_xf_current_id),
style(cell_xf_current_id, style_xf_current_id)
{
ixfParent = 0;
}

View File

@ -32,15 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/FontIndex.h>
#include <Logic/Biff_structures/CellXF.h>
#include <Logic/Biff_structures/StyleXF.h>
#include "../Biff_structures/FontIndex.h"
#include "../Biff_structures/CellXF.h"
#include "../Biff_structures/StyleXF.h"
namespace XLS
{
// Logical representation of XF record in BIFF8
class XF: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(XF)

View File

@ -38,13 +38,12 @@ namespace XLS
struct FillInfoExt
{
FillInfoExt() {enabled = false; xclrType = icv = 0; nTintShade = 0; xclrValue = 0;}
bool enabled;
bool enabled =false;
unsigned char xclrType;
unsigned char icv;
short nTintShade;
unsigned int xclrValue;
unsigned char xclrType = 0;
unsigned char icv = 0;
short nTintShade = 0;
unsigned int xclrValue = 0;
};
struct FillInfo
@ -56,9 +55,9 @@ struct FillInfo
{
}
unsigned char fls;
unsigned char icvFore;
unsigned char icvBack;
unsigned char fls = 0;
unsigned char icvFore = 0;
unsigned char icvBack = 0;
bool operator < (const FillInfo& right) const
{
@ -84,17 +83,17 @@ struct FillInfo
struct BorderInfo
{
unsigned char dgLeft;
unsigned char dgRight;
unsigned char dgTop;
unsigned char dgBottom;
unsigned char dgDiag;
unsigned char grbitDiag;
unsigned char icvLeft;
unsigned char icvRight;
unsigned char icvTop;
unsigned char icvBottom;
unsigned char icvDiag;
unsigned char dgLeft = 0;
unsigned char dgRight = 0;
unsigned char dgTop = 0;
unsigned char dgBottom = 0;
unsigned char dgDiag = 0;
unsigned char grbitDiag = 0;
unsigned char icvLeft = 0;
unsigned char icvRight = 0;
unsigned char icvTop = 0;
unsigned char icvBottom = 0;
unsigned char icvDiag = 0;
FillInfoExt leftFillInfo_;
FillInfoExt rightFillInfo_;

View File

@ -38,10 +38,11 @@ namespace XLS
{
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell_xf_current_id_(cell_xf_current_id),
style_xf_current_id_(style_xf_current_id)
{
alc = alcV = 0;
font_id = 0xFFFF;
}
@ -152,6 +153,91 @@ void CellXF::load(CFRecord& record)
}
}
void CellXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void CellXF::Update(XFProps* xfProps)
{
if (!xfProps) return;
//
// std::wstringstream strm;
// xfProps->serialize_fill(strm);
// fill.ext = strm.str();
}
void CellXF::RegisterFillBorder()
{
for (size_t i = 0; i < ext_props.size(); i++ )
@ -231,6 +317,8 @@ void CellXF::RegisterFillBorder()
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
m_GlobalWorkbookInfo->RegisterFontColorId(font_id, font_color);
}

View File

@ -36,6 +36,8 @@
namespace XLS
{
class XFProps;
class ExtProp;
class CFRecord;
class GlobalWorkbookInfo;
@ -74,19 +76,23 @@ public:
BorderInfo border;
FillInfo fill;
BiffStructurePtrVector ext_props;
FillInfoExt font_color;
size_t font_id;
bool fHasXFExt;
bool fsxButton;
//------------------------------------------------------------------
BiffStructurePtrVector ext_props;
BiffStructurePtrVector xf_props;
size_t border_x_id;
size_t fill_x_id;
size_t& cell_xf_current_id_;
size_t& style_xf_current_id_;
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
};

View File

@ -57,11 +57,11 @@ void List12TableStyleClientInfo::load(CFRecord& record)
unsigned short flags;
record >> flags;
nFirstColumn = GETBITS(flags, 0, 1);
nLastColumn = GETBITS(flags, 1, 2);
nRowStripes = GETBITS(flags, 3, 4);
nColumnStripes = GETBITS(flags, 5, 6);
nDefaultStyle = GETBITS(flags, 9, 10);
fFirstColumn = GETBIT(flags, 0);
fLastColumn = GETBIT(flags, 1);
fRowStripes = GETBIT(flags, 2);
fColumnStripes = GETBIT(flags, 3);
fDefaultStyle = GETBIT(flags, 6);
record >> stListStyleName;
}

View File

@ -51,11 +51,11 @@ public:
virtual void load(CFRecord& record);
unsigned char nFirstColumn;
unsigned char nLastColumn;
unsigned char nRowStripes;
unsigned char nColumnStripes;
unsigned char nDefaultStyle;
bool fFirstColumn;
bool fLastColumn;
bool fRowStripes;
bool fColumnStripes;
bool fDefaultStyle;
XLUnicodeString stListStyleName;
};

View File

@ -37,24 +37,20 @@ namespace XLS
{
LongRGBA::LongRGBA()
: is_alpha(true)
LongRGBA::LongRGBA() : is_alpha(true)
{
}
LongRGBA::LongRGBA(const bool alpha_present)
: is_alpha(alpha_present)
LongRGBA::LongRGBA(const bool alpha_present) : is_alpha(alpha_present)
{
}
LongRGB::LongRGB()
: LongRGBA(false)
LongRGB::LongRGB() : LongRGBA(false)
{
}
BiffStructurePtr LongRGBA::clone()
{
return BiffStructurePtr(new LongRGBA(*this));
@ -78,9 +74,14 @@ void LongRGBA::load(CFRecord& record)
alpha = 0;
record.skipNunBytes(1); // reserved
}
strRGB = STR::toRGB (red, green, blue);
strARGB = STR::toARGB(red, green, blue, alpha);
}
_UINT32 LongRGBA::ToRGBA()
{
return ((unsigned int)( ( (unsigned char)(red) )| ( ( (unsigned char)(green) ) << 8 ) | ( ( (unsigned char)(blue) ) << 16 ) | ( (unsigned char)(alpha) << 24 ) ) );
}
} // namespace XLS

View File

@ -50,7 +50,6 @@ public:
virtual void load(CFRecord& record);
unsigned char red;
unsigned char green;
unsigned char blue;
@ -59,6 +58,8 @@ public:
std::wstring strARGB;
std::wstring strRGB;
_UINT32 ToRGBA();
bool is_alpha;
};

View File

@ -94,7 +94,8 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
{
_Name = field_db->stFieldName.value();
if (std::wstring::npos != _Name.find(L" "))
if (std::wstring::npos != _Name.find(L" ") ||
std::wstring::npos != _Name.find(L":"))
{
_Name = L"'" + _Name + L"'";
}
@ -104,7 +105,13 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
SXOPER* cache = dynamic_cast<SXOPER*>(field->m_arSRCSXOPER[pair->iCache].get());
if (cache)
{
_Name += L"[" + cache->value + L"]";
std::wstring value = cache->value;
if (std::wstring::npos != value.find(L" ") ||
std::wstring::npos != value.find(L":"))
{
value = L"'" + value + L"'";
}
_Name += L"[" + value + L"]";
}
}
}

View File

@ -29,23 +29,29 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "StyleXF.h"
#include "XFProps.h"
#include "ExtProp.h"
#include <Binary/CFRecord.h>
#include "XFProp.h"
#include "ExtProp.h"
#include "XFPropColor.h"
#include "BitMarkedStructs.h"
#include "XFPropBorder.h"
#include "../Biff_records/Font.h"
namespace XLS
{
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell_xf_current_id_(cell_xf_current_id),
style_xf_current_id_(style_xf_current_id)
{
font_id = -1;
font_id = 0xFFFF;
border_x_id = -1;
fill_x_id = -1;
font = NULL;
fill.fls = 0;
}
@ -58,9 +64,9 @@ BiffStructurePtr StyleXF::clone()
void StyleXF::load(CFRecord& record)
{
m_GlobalWorkbookInfo = record.getGlobalWorkbookInfo();
global_info = record.getGlobalWorkbookInfo();
if (m_GlobalWorkbookInfo->Version < 0x0600)
if (global_info->Version < 0x0600)
{
_UINT16 flags1;
_UINT32 flags2;
@ -146,86 +152,153 @@ void StyleXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
FillInfoExt color_out;
{
color_out.enabled = true;
color_out.icv = ext_prop->extPropData.color.icv;
color_out.xclrType = ext_prop->extPropData.color.xclrType;
color_out.nTintShade = ext_prop->extPropData.color.nTintShade;
color_out.xclrValue = ext_prop->extPropData.color.xclrValue;
}
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
fill.foreFillInfo_ = color_out;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
fill.backFillInfo_ = color_out;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.topFillInfo_ = color_out;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.bottomFillInfo_ = color_out;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.leftFillInfo_ = color_out;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.rightFillInfo_ = color_out;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
font_color = color_out;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void StyleXF::Update(XFProps* xfProps)
void StyleXF::Update(XFProp* xfProp)
{
if (!xfProps) return;
if (!xfProp) return;
std::wstringstream strm;
xfProps->serialize_fill(strm);
fill.ext = strm.str();
XFPropColor* color = dynamic_cast<XFPropColor*>(xfProp->xfPropDataBlob.get());
if (color)
{
FillInfoExt color_out;
color_out.enabled = true;
color_out.icv = color->icv;
color_out.xclrType = color->xclrType;
color_out.nTintShade = color->nTintShade;
if (color->xclrType == 3)color_out.xclrValue = color->icv;
else color_out.xclrValue = color->dwRgba.ToRGBA();
switch(xfProp->xfPropType)
{
case 0x0001: fill.foreFillInfo_ = color_out; break;
case 0x0002: fill.backFillInfo_ = color_out; break;
case 0x0005: font_color = color_out; break;
}
return;
}
BIFF_BYTE* byte_ = dynamic_cast<BIFF_BYTE*>(xfProp->xfPropDataBlob.get());
if (byte_)
{
switch(xfProp->xfPropType)
{
case 0x0025:
{
font_id = *byte_->value();
if (font_id >=0 && font_id < global_info->m_arFonts.size())
{
font = dynamic_cast<Font*>(global_info->m_arFonts[font_id].get());
}
}break;
case 0x001C: if (font) font->fItalic = *byte_->value(); break;
case 0x001D: if (font) font->fStrikeOut = *byte_->value(); break;
case 0x001E: if (font) font->fOutline = *byte_->value(); break;
case 0x001F: if (font) font->fShadow = *byte_->value(); break;
case 0x0022: if (font) font->bCharSet = *byte_->value(); break;
}
return;
}
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(xfProp->xfPropDataBlob.get());
if (word)
{
switch(xfProp->xfPropType)
{
case 0x0019: if (font) font->bls = *word->value(); break;
case 0x001A: if (font) font->uls = *word->value(); break;
case 0x001B: if (font) font->sss = *word->value(); break;
}
return;
}
BIFF_DWORD* dword = dynamic_cast<BIFF_DWORD*>(xfProp->xfPropDataBlob.get());
if (dword)
{
switch(xfProp->xfPropType)
{
case 0x0024: if (font) font->dyHeight = *dword->value(); break;
}
return;
}
XFPropBorder *brdr = dynamic_cast<XFPropBorder*>(xfProp->xfPropDataBlob.get());
if (brdr)
{
FillInfoExt color_out;
color_out.enabled = true;
color_out.icv = brdr->color.icv;
color_out.xclrType = brdr->color.xclrType;
color_out.nTintShade = brdr->color.nTintShade;
if (brdr->color.xclrType == 3) color_out.xclrValue = brdr->color.icv;
else color_out.xclrValue = brdr->color.dwRgba.ToRGBA();
switch(xfProp->xfPropType)
{
case 0x0006: border.topFillInfo_ = color_out; break;
case 0x0007: border.bottomFillInfo_ = color_out; break;
case 0x0008: border.leftFillInfo_ = color_out; break;
case 0x0009: border.rightFillInfo_ = color_out; break;
//horiz, vert, diag
}
return;
}
}
void StyleXF::RegisterFillBorder()
{
@ -234,9 +307,15 @@ void StyleXF::RegisterFillBorder()
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
Update (ext_prop);
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
for (size_t i = 0; i < xf_props.size(); i++ )
{
XFProp* xf_prop = dynamic_cast<XFProp*>(xf_props[i].get());
Update (xf_prop);
}
border_x_id = global_info->RegisterBorderId(border);
fill_x_id = global_info->RegisterFillId(fill);
global_info->RegisterFontColorId(font_id, font_color);
}

View File

@ -36,9 +36,10 @@
namespace XLS
{
class XFProps;
class XFProp;
class ExtProp;
class CFRecord;
class Font;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
@ -52,17 +53,10 @@ public:
virtual void load(CFRecord& record);
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
static const ElementType type = typeStyleXF;
int serialize(std::wostream & stream);
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
unsigned char alc;
bool fWrap;
unsigned char alcV;
@ -72,13 +66,22 @@ public:
bool fShrinkToFit;
unsigned char iReadOrder;
//------------------------------------------------------------------
GlobalWorkbookInfoPtr global_info;
BorderInfo border;
FillInfo fill;
FillInfoExt font_color;
size_t font_id;
Font *font;
BiffStructurePtrVector ext_props;
BiffStructurePtrVector xf_props;
void Update(ExtProp* extProp); // xls style
void Update(XFProp* xfProp); //xlsx style
void RegisterFillBorder();
size_t border_x_id;
size_t fill_x_id;

View File

@ -29,16 +29,15 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "XFProp.h"
#include <Binary/CFRecord.h>
#include "XFPropColor.h"
#include "XFPropGradient.h"
#include "XFPropGradientStop.h"
#include "XFPropBorder.h"
#include "BiffString.h"
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "BitMarkedStructs.h"
#include <utils.h>
@ -145,8 +144,7 @@ static void serialize_color_prop(std::wostream & stream, const std::wstring & na
XFPropColor * color = dynamic_cast<XFPropColor*>(val.get());
if (!color) return;
color->node_name = name;
color->serialize(stream);
color->serialize(stream, name);
}
static void serialize_val_prop(std::wostream & stream, const std::wstring & name, BiffStructurePtr & val)
@ -218,7 +216,7 @@ static void serialize_border_prop(std::wostream & stream, const std::wstring & n
}
if (border->dgBorder != 0)
{
border->color.serialize(CP_XML_STREAM());
border->color.serialize(CP_XML_STREAM(), L"color");
}
}
}

View File

@ -32,8 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/FullColorExt.h>
#include <Logic/Biff_structures/XFExtGradient.h>
#include "FullColorExt.h"
#include <simple_xml_writer.h>
@ -59,5 +58,6 @@ public:
unsigned short cb;
BiffStructurePtr xfPropDataBlob;
};
typedef boost::shared_ptr<XFProp> XFPropPtr;
} // namespace XLS

View File

@ -49,7 +49,6 @@ public:
virtual void load(CFRecord& record);
XFPropColor color;
unsigned short dgBorder;
};

View File

@ -47,8 +47,6 @@ BiffStructurePtr XFPropColor::clone()
void XFPropColor::load(CFRecord& record)
{
node_name = L"color";
unsigned char flags;
record >> flags;
@ -58,7 +56,7 @@ void XFPropColor::load(CFRecord& record)
record >> icv >> nTintShade >> dwRgba;
}
int XFPropColor::serialize(std::wostream & stream)
int XFPropColor::serialize(std::wostream & stream, const std::wstring &node_name)
{
if (xclrType > 3 )return 0;//not set
@ -68,11 +66,11 @@ int XFPropColor::serialize(std::wostream & stream)
{
switch(xclrType)
{
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 2:
case 3: CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
//CP_XML_ATTR(L"theme", icv); break;
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 3: CP_XML_ATTR(L"theme", icv); break;
default:
CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
}
if (nTintShade != 0)
{

View File

@ -47,10 +47,9 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeXFPropColor;
int serialize(std::wostream & stream);
int serialize(std::wostream & stream, const std::wstring &sNode);
bool fValidRGBA;
unsigned char xclrType;

View File

@ -32,7 +32,6 @@
#include "XFPropGradientStop.h"
#include <Binary/CFRecord.h>
#include <simple_xml_writer.h>
namespace XLS
@ -59,7 +58,7 @@ int XFPropGradientStop::serialize(std::wostream & stream)
CP_XML_NODE(L"stop")
{
CP_XML_ATTR(L"position", numPosition);
color.serialize(CP_XML_STREAM());
color.serialize(CP_XML_STREAM(), L"color");
}
}
return 0;

View File

@ -29,10 +29,15 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "XFProps.h"
#include <Binary/CFRecord.h>
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "XFProp.h"
#include "XFPropColor.h"
#include "XFPropGradient.h"
#include "XFPropGradientStop.h"
#include "BitMarkedStructs.h"
namespace XLS
{
@ -43,8 +48,6 @@ BiffStructurePtr XFProps::clone()
return BiffStructurePtr(new XFProps(*this));
}
void XFProps::load(CFRecord& record)
{
arXFPropBorder.is_present = false;
@ -54,21 +57,24 @@ void XFProps::load(CFRecord& record)
for(int i = 0; i < cprops; ++i)
{
XFProp prop;
record >> prop;
XFPropPtr prop(new XFProp);
if (!prop) continue;
if (prop.xfPropType >= 0 && prop.xfPropType <= 3)
prop->load(record);
rgExt.push_back(prop);
if (prop->xfPropType >= 0 && prop->xfPropType <= 3)
{
arXFPropFill.push_back(prop);
}
else if (prop.xfPropType == 4)
else if (prop->xfPropType == 4)
{
arXFPropGradient.push_back(prop);
}
else if (prop.xfPropType >= 6 && prop.xfPropType <= 14)
else if (prop->xfPropType >= 6 && prop->xfPropType <= 14)
{
arXFPropBorder.is_present = true;
switch(prop.xfPropType)
switch(prop->xfPropType)
{
case 6: arXFPropBorder.top = prop; break;
case 7: arXFPropBorder.bottom = prop; break;
@ -78,20 +84,20 @@ void XFProps::load(CFRecord& record)
arXFPropBorder.other.push_back(prop);
}
}
else if (prop.xfPropType >= 15 && prop.xfPropType <= 22 || prop.xfPropType == 42)
else if (prop->xfPropType >= 15 && prop->xfPropType <= 22 || prop->xfPropType == 42)
{
arXFPropAlignment.push_back(prop);
}
else if (prop.xfPropType >= 24 && prop.xfPropType <= 37 || prop.xfPropType == 5)
else if (prop->xfPropType >= 24 && prop->xfPropType <= 37 || prop->xfPropType == 5)
{
arXFPropFont.push_back(prop);
}
else if (prop.xfPropType >= 38 && prop.xfPropType <= 41)
else if (prop->xfPropType >= 38 && prop->xfPropType <= 41)
{
bool skip_codes = false;
if (prop.xfPropType == 0x0029)
if (prop->xfPropType == 0x0029)
{
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop.xfPropDataBlob.get());
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop->xfPropDataBlob.get());
if ((word) && (word->value() == (_UINT16)30))
{
skip_codes = true;
@ -101,7 +107,7 @@ void XFProps::load(CFRecord& record)
if (!skip_codes)
arXFPropNumFmt.push_back(prop);
}
else if (prop.xfPropType >= 43 && prop.xfPropType <= 44)
else if (prop->xfPropType >= 43 && prop->xfPropType <= 44)
{
arXFPropProtection.push_back(prop);
}
@ -115,23 +121,23 @@ int XFProps::serialize_fill(std::wostream & stream)
{
if (arXFPropFill.empty()) return 0;
CP_XML_WRITER(stream)
{
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
switch(arXFPropFill[i]->xfPropType)
{
switch(arXFPropFill[i].xfPropType)
{
case 1:
case 0: pPatternType = &arXFPropFill[i]; break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i].xfPropDataBlob.get()); break;
}
case 0: pPatternType = arXFPropFill[i].get(); break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i]->xfPropDataBlob.get()); break;
}
}
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"fill")
{
if (pGradient || arXFPropGradient.size() > 0)
{
if (pGradient || arXFPropGradient.size() > 0)
{
CP_XML_NODE(L"gradientFill")
{
@ -140,26 +146,37 @@ int XFProps::serialize_fill(std::wostream & stream)
for (size_t i = 0 ; i < arXFPropGradient.size(); i++)
{
if (arXFPropGradient[i].xfPropDataBlob == NULL) continue;
arXFPropGradient[i].xfPropDataBlob->serialize(CP_XML_STREAM());
if (arXFPropGradient[i]->xfPropDataBlob == NULL) continue;
arXFPropGradient[i]->xfPropDataBlob->serialize(CP_XML_STREAM());
}
}
}
else if (pPatternType)
else
{
CP_XML_NODE(L"patternFill")
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
if (pPatternType)
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
}
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
arXFPropFill[i].serialize(CP_XML_STREAM());
XFPropColor *pColor = dynamic_cast<XFPropColor*>(arXFPropFill[i]->xfPropDataBlob.get());
if (!pColor) continue;
std::wstring sNode = L"color";
switch(arXFPropFill[i]->xfPropType)
{
case 1: sNode = L"fgColor"; break;
case 2: sNode = L"bgColor"; break;
}
pColor->serialize(CP_XML_STREAM(), sNode);
}
}
}
}
}
return 0;
}
@ -173,7 +190,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
for (size_t i = 0; i < arXFPropFont.size(); i++)
{
arXFPropFont[i].serialize(CP_XML_STREAM());
arXFPropFont[i]->serialize(CP_XML_STREAM());
}
}
}
@ -185,11 +202,11 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
if (dxf)
{
arXFPropNumFmt[i].serialize_attr(CP_GET_XML_NODE());
arXFPropNumFmt[i]->serialize_attr(CP_GET_XML_NODE());
}
else
{
arXFPropNumFmt[i].serialize(CP_XML_STREAM());
arXFPropNumFmt[i]->serialize(CP_XML_STREAM());
}
}
}
@ -202,7 +219,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
for (size_t i = 0; i < arXFPropAlignment.size(); i++)
{
arXFPropAlignment[i].serialize(CP_XML_STREAM());
arXFPropAlignment[i]->serialize(CP_XML_STREAM());
}
}
}
@ -219,7 +236,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
//----------------------------------------
for (size_t i = 0; i < arXFPropBorder.other.size(); i++)
{
arXFPropBorder.other[i].serialize(CP_XML_STREAM());
arXFPropBorder.other[i]->serialize(CP_XML_STREAM());
}
}
}

View File

@ -32,11 +32,13 @@
#pragma once
#include "BiffStructure.h"
#include "XFProp.h"
namespace XLS
{
class XFProp;
typedef boost::shared_ptr<XFProp> XFPropPtr;
class CFRecord;
class XFProps : public BiffStructure
@ -56,27 +58,31 @@ public:
int serialize_fill(std::wostream & stream);
std::vector<XFProp> arXFPropFont;
std::vector<XFProp> arXFPropNumFmt;
std::vector<XFProp> arXFPropFill;
std::vector<XFProp> arXFPropAlignment;
std::vector<XFPropPtr> arXFPropFont;
std::vector<XFPropPtr> arXFPropNumFmt;
std::vector<XFPropPtr> arXFPropFill;
std::vector<XFPropPtr> arXFPropAlignment;
struct _b
{
bool is_present;
bool is_present = false;
_CP_OPT(XFProp) left;
_CP_OPT(XFProp) right;
_CP_OPT(XFProp) top;
_CP_OPT(XFProp) bottom;
std::vector<XFProp> other;
XFPropPtr left;
XFPropPtr right;
XFPropPtr top;
XFPropPtr bottom;
std::vector<XFPropPtr> other;
}arXFPropBorder;
std::vector<XFProp> arXFPropProtection;
std::vector<XFProp> arXFPropGradient;
std::vector<XFPropPtr> arXFPropProtection;
std::vector<XFPropPtr> arXFPropGradient;
//-----------------------------------------------------
BiffStructurePtrVector rgExt;
bool fNewBorder;
bool bPresent;
};
} // namespace XLS

View File

@ -150,16 +150,15 @@ int XLUnicodeRichExtendedString::serialize (std::wostream & _stream)
int XLUnicodeRichExtendedString::serialize_rPr (std::wostream & _stream, int iFmt)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
int sz = pGlobalWorkbookInfoPtr->m_arFonts.size();
if (iFmt -1 > sz || iFmt < 1) return 0;
CP_XML_WRITER(_stream)
{
CP_XML_NODE(L"rPr")
{
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts[iFmt-1].get());
if (font) font->serialize_properties(CP_XML_STREAM(), true);
}

View File

@ -347,12 +347,11 @@ int ATTACHEDLABEL::serialize(std::wostream & _stream, bool isPosition)
int ATTACHEDLABEL::serialize_rPr (std::wostream & _stream, int iFmt, bool rtl, bool defRPr)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
int sz = pGlobalWorkbookInfoPtr->m_arFonts.size();
if (iFmt -1 > sz || iFmt < 1) return 0;
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
Font * font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts[iFmt-1].get());
Text * text_props = dynamic_cast<Text*>(m_TextProperties.get());

View File

@ -259,14 +259,13 @@ int AXS::serialize(std::wostream & _stream)
int AXS::serialize_rPr (std::wostream & _stream, int iFmt, _CP_OPT(unsigned int) color, bool rtl, bool defRPr)
{
if (!pGlobalWorkbookInfoPtr) return 0;
if (!pGlobalWorkbookInfoPtr->m_arFonts) return 0;
if (!pGlobalWorkbookInfoPtr) return 0;
Font * font = NULL;
int sz = pGlobalWorkbookInfoPtr->m_arFonts->size();
int sz = pGlobalWorkbookInfoPtr->m_arFonts.size();
if (iFmt > 0 && iFmt <= sz)
font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts->at(iFmt-1).get());
font = dynamic_cast<Font*>(pGlobalWorkbookInfoPtr->m_arFonts.at(iFmt-1).get());
if (font)
{

View File

@ -31,6 +31,12 @@
*/
#include "CRT.h"
#include "LD.h"
#include "DROPBAR.h"
#include "SS.h"
#include "SHAPEPROPS.h"
#include "DFTTEXT.h"
#include "../Biff_records/ChartFormat.h"
#include "../Biff_records/Begin.h"
#include "../Biff_records/Bar.h"
@ -46,14 +52,9 @@
#include "../Biff_records/CrtLink.h"
#include "../Biff_records/SeriesList.h"
#include "../Biff_records/Chart3d.h"
#include "../Biff_unions/LD.h"
#include "../Biff_unions/DROPBAR.h"
#include "../Biff_records/CrtLine.h"
#include "../Biff_records/LineFormat.h"
#include "../Biff_unions/DFTTEXT.h"
#include "../Biff_records/DataLabExtContents.h"
#include "../Biff_unions/SS.h"
#include "../Biff_unions/SHAPEPROPS.h"
#include "../Biff_records/End.h"
#include "../Biff_records/ValueRange.h"
#include "../Biff_records/Tick.h"
@ -65,6 +66,7 @@
#include "../Biff_records/PlotArea.h"
#include "../Biff_records/DropBar.h"
#include "../Biff_records/CrtMlFrt.h"
#include "../Biff_records/DataFormat.h"
#include "../Biff_records/StartObject.h"
#include "../Biff_records/EndObject.h"

View File

@ -76,11 +76,16 @@ const bool DFTTEXT::loadContent(BinProcessor& proc)
m_DefaultText = elements_.back();
elements_.pop_back();
}
if (proc.optional<DataLabExtContents>())
{
m_DataLabExtContents = elements_.back();
elements_.pop_back();
}
if (!m_DefaultText && !m_DataLabExtContents)
return false;
if (proc.mandatory<ATTACHEDLABEL>())
{
m_ATTACHEDLABEL = elements_.back();
@ -89,10 +94,7 @@ const bool DFTTEXT::loadContent(BinProcessor& proc)
if (proc.optional<EndObject>()) elements_.pop_back();
if (m_DefaultText || m_DataLabExtContents)
return true;
else
return false;
return true;
}
} // namespace XLS

View File

@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of DROPBAR union of records
class DROPBAR: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(DROPBAR)

View File

@ -31,15 +31,17 @@
*/
#include "DROPBAR.h"
#include <Logic/Biff_records/DropBar.h>
#include <Logic/Biff_records/Begin.h>
#include <Logic/Biff_records/LineFormat.h>
#include <Logic/Biff_records/AreaFormat.h>
#include <Logic/Biff_unions/GELFRAME.h>
#include <Logic/Biff_unions/SHAPEPROPS.h>
#include <Logic/Biff_records/End.h>
#include <Logic/Biff_records/StartObject.h>
#include <Logic/Biff_records/EndObject.h>
#include "GELFRAME.h"
#include "SHAPEPROPS.h"
#include "../Biff_records/DropBar.h"
#include "../Biff_records/LineFormat.h"
#include "../Biff_records/AreaFormat.h"
#include "../Biff_records/Begin.h"
#include "../Biff_records/End.h"
#include "../Biff_records/StartObject.h"
#include "../Biff_records/EndObject.h"
namespace XLS
{
@ -72,7 +74,7 @@ const bool DROPBAR::loadContent(BinProcessor& proc)
if (proc.mandatory<Begin>()) elements_.pop_back();
if (proc.mandatory<LineFormat>())
if (proc.optional<LineFormat>())
{
m_LineFormat = elements_.back(); elements_.pop_back();
}
@ -81,11 +83,10 @@ const bool DROPBAR::loadContent(BinProcessor& proc)
elements_.pop_back();
if (proc.mandatory<EndObject>()) elements_.pop_back();
}
if (proc.mandatory<AreaFormat>())
if (proc.optional<AreaFormat>())
{
m_AreaFormat = elements_.back(); elements_.pop_back();
}
if (proc.optional<GELFRAME>())
{
m_GELFRAME = elements_.back(); elements_.pop_back();

View File

@ -276,6 +276,9 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
CP_XML_ATTR(L"id", field->idField);
CP_XML_ATTR(L"name", field->strCaption.value());
if (!field->strTotal.value().empty())
CP_XML_ATTR(L"totalsRowLabel", field->strTotal.value());
if (field->dxfFmtAgg.bExist ||
field->dxfFmtInsertRow.bExist)
{
@ -294,11 +297,11 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
{
CP_XML_NODE(L"tableStyleInfo")
{
CP_XML_ATTR(L"name", table_style->stListStyleName.value());
CP_XML_ATTR(L"showFirstColumn", table_style->nFirstColumn);
CP_XML_ATTR(L"showLastColumn", table_style->nLastColumn);
CP_XML_ATTR(L"showRowStripes", table_style->nRowStripes);
CP_XML_ATTR(L"showColumnStripes", table_style->nColumnStripes);
CP_XML_ATTR(L"name", table_style->stListStyleName.value());
CP_XML_ATTR(L"showFirstColumn", table_style->fFirstColumn);
CP_XML_ATTR(L"showLastColumn", table_style->fLastColumn);
CP_XML_ATTR(L"showRowStripes", table_style->fRowStripes);
CP_XML_ATTR(L"showColumnStripes", table_style->fColumnStripes);
}
}
}

View File

@ -79,7 +79,7 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
Font *font = dynamic_cast<Font *>(elements_.front().get());
if ((font) && (font->correct))
{
m_arFonts.push_back(elements_.front());
global_info->m_arFonts.push_back(elements_.front());
}
elements_.pop_front();
count--;
@ -94,10 +94,10 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
}
//----------------------------------------------------------------------------------------------------
count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally Font follows by Format)
int countFonts = m_arFonts.size();
int countFonts = global_info->m_arFonts.size();
while(count > 0)
{
m_arFonts.insert(m_arFonts.begin()+countFonts, elements_.back());
global_info->m_arFonts.insert(global_info->m_arFonts.begin() + countFonts, elements_.back());
elements_.pop_back();
count--;
}
@ -156,40 +156,40 @@ void FORMATTING::update_xfs()
if (!xfs) return;
//for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
//{
// XLS::Style * style = dynamic_cast<Style*>(st->m_arStyles[i].first.get());
// XLS::StyleExt * styleExt = dynamic_cast<StyleExt*>(st->m_arStyles[i].second.get());
//
// if (styleExt && style)
// {
// if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
// {
// bool bFound = false;
// for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
// {
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
{
XLS::Style *style = dynamic_cast<Style*> (st->m_arStyles[i].first.get());
XLS::StyleExt *styleExt = dynamic_cast<StyleExt*> (st->m_arStyles[i].second.get());
if (styleExt && style)
{
if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
{
bool bFound = false;
for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
{
XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->style.Update(&styleExt->xfProps);
// bFound = true;
// break;
// }
// }
// //for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++)
// //{
// // XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// // if (xf->ind_xf == style->ixfe)
// // {
// // xf->cell.Update(&styleExt->xfProps);
// // bFound = true;
// // break;
// // }
// //}
// }
// }
//}
if (xf->ind_xf == style->ixfe)
{
xf->style.xf_props = styleExt->xfProps.rgExt;
bFound = true;
break;
}
}
//for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++) небывает совпадений
//{
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->cell.xf_props = styleExt->xfProps.rgExt;
// bFound = true;
// break;
// }
//}
}
}
}
xfs->RegisterFillBorder();
}
void FORMATTING::concatinate(FORMATTING* ext)
@ -234,20 +234,23 @@ int FORMATTING::serialize1(std::wostream & stream)
}
}
}
if (m_arFonts.size() > 0)
if (!global_info->m_arFonts.empty())
{
CP_XML_NODE(L"fonts")
{
CP_XML_ATTR(L"count", m_arFonts.size());
for (size_t i = 0 ; i < m_arFonts.size(); i++)
CP_XML_ATTR(L"count", global_info->m_arFonts.size());
for (size_t i = 0; i < global_info->m_arFonts.size(); i++)
{
Font * font = dynamic_cast<Font*>(m_arFonts[i].get());
Font * font = dynamic_cast<Font*>(global_info->m_arFonts[i].get());
std::map<int, FillInfoExt>::iterator it = global_info->fonts_color_ext.find(i);
if (font && (it!=global_info->fonts_color_ext.end()))
if (font && (it != global_info->fonts_color_ext.end()))
{
font->set_color_ext(it->second);
}
m_arFonts[i]->serialize(CP_XML_STREAM());
global_info->m_arFonts[i]->serialize(CP_XML_STREAM());
}
}
}

View File

@ -60,7 +60,7 @@ public:
BaseObjectPtr m_Styles;
BaseObjectPtr m_XFS;
std::vector<BaseObjectPtr> m_arFormats;
std::vector<BaseObjectPtr> m_arFonts;
//std::vector<BaseObjectPtr> m_arFonts; in global
BaseObjectPtr m_Palette;
BaseObjectPtr m_ClrtClient;
std::vector<BaseObjectPtr> m_arDXF;

View File

@ -127,7 +127,8 @@ void SXFMLA::serialize_attr(CP_ATTR_NODE)
global_info->arPivotSxNames = m_arPivotSxNames;
CP_XML_ATTR(L"formula", sx_fmla->fmla.getAssembledFormula());
std::wstring fmla = sx_fmla->fmla.getAssembledFormula();
CP_XML_ATTR(L"formula", fmla);
}

View File

@ -586,7 +586,7 @@ int ChartSheetSubstream::serialize_3D (std::wostream & _stream)
if (ax_parent->iax == 0) //primary axes
{
for (int i = 0 ; i < parent->m_arCRT.size() ; i++)
for (size_t i = 0 ; i < parent->m_arCRT.size() ; i++)
{
CRT* crt = dynamic_cast<CRT*>(parent->m_arCRT[i].get());
if((crt) && (crt->m_Chart3d))

View File

@ -94,8 +94,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
return std::pair<float, float>(width, maxHeight);
}
GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConverter * xls_converter_)
: CodePage(code_page)
GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConverter * converter) : CodePage(code_page), xls_converter(converter)
{
fill_x_ids[FillInfo(0, 0, 0)] = 0;
fill_x_ids[FillInfo(17, 64, 65)] = 1;
@ -105,8 +104,6 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
Version = 0x0600;
xls_converter = xls_converter_;
startAddedSharedStrings = 0;
current_sheet = 0;
cmt_rules = 0;
@ -122,6 +119,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
bVbaProjectExist = false;
bMacrosExist = false;
bThemePresent = false;
idPivotCache = 0;
}
@ -188,9 +186,9 @@ void GlobalWorkbookInfo::GetDigitFontSizePixels()
}
defaultDigitFontSize = std::pair<float, float>(7,8);
if (m_arFonts->size() < 1) return;
if (m_arFonts.empty()) return;
Font * font = dynamic_cast<Font*>(m_arFonts->at(0).get());
Font * font = dynamic_cast<Font*>(m_arFonts[0].get());
if (!font) return;
std::wstring fontName = font->fontName.value();

View File

@ -84,6 +84,7 @@ public:
//-----------------------------------------------------------------------------
bool bVbaProjectExist;
bool bMacrosExist;
bool bThemePresent;
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
@ -96,7 +97,7 @@ public:
std::map<int, int> fonts_charsets;
std::map<int, std::wstring> colors_palette;
std::vector<BaseObjectPtr> *m_arFonts;
std::vector<BaseObjectPtr> m_arFonts;
unsigned int current_sheet;
@ -155,6 +156,8 @@ public:
CApplicationFonts *applicationFonts;
std::wstring fontsDirectory;
std::wstring tempDirectory;
int Version;
int cmt_rules;

View File

@ -333,7 +333,6 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
if (fmts)
{
global_info_->cellStyleDxfs_count = fmts->m_arDXF.size();
global_info_->m_arFonts = &fmts->m_arFonts;
}
}
//else
@ -626,9 +625,7 @@ void GlobalsSubstream::UpdateXti()
ExternSheet* extern_sheet = dynamic_cast<ExternSheet*>(SUPP->m_ExternSheet.get());
if (!extern_sheet) continue;
for (size_t i = 0; i < extern_sheet->rgXTI.size(); i++)
for (size_t i = 0; extern_sheet && i < extern_sheet->rgXTI.size(); i++)
{
XTI* xti = dynamic_cast<XTI*>(extern_sheet->rgXTI[i].get());
if (!xti) continue;
@ -672,9 +669,17 @@ void GlobalsSubstream::UpdateXti()
val.link = XMLSTUFF::xti_indexes2sheet_name(xti->itabFirst, xti->itabLast, info->rgst, val.link);
}
}
global_info_->arXti.push_back(val);
}
if (!extern_sheet && !SUPP->m_arExternName.empty())
{
GlobalWorkbookInfo::_xti val;
val.iSup = s;
val.pNames = &SUPP->arNames;
global_info_->arXti.push_back(val);
}
}
}

View File

@ -36,9 +36,9 @@
#include "../../../Common/OfficeFileErrorDescription.h"
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* pCallBack, bool &bMacros)
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring & fontsPath, const std::wstring & tempPath, const ProgressCallback* pCallBack, bool &bMacros)
{
XlsConverter converter(srcFile, dstPath, password, fontsPath, pCallBack, bMacros);
XlsConverter converter(srcFile, dstPath, password, fontsPath, tempPath, pCallBack, bMacros);
if (converter.isError())
{

View File

@ -33,4 +33,4 @@
struct ProgressCallback;
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring& fontsPath, const ProgressCallback* CallBack, bool & bMacros);
long ConvertXls2Xlsx(const std::wstring & srcFile, const std::wstring & dstPath, const std::wstring & password, const std::wstring& fontsPath, const std::wstring & tempPath, const ProgressCallback* CallBack, bool & bMacros);

View File

@ -75,6 +75,7 @@
#include "../XlsFormat/Logic/Biff_records/IMDATA.h"
#include "../XlsFormat/Logic/Biff_records/Note.h"
#include "../XlsFormat/Logic/Biff_records/WsBool.h"
#include "../XlsFormat/Logic/Biff_records/Theme.h"
#include "../XlsFormat/Logic/Biff_structures/URLMoniker.h"
#include "../XlsFormat/Logic/Biff_structures/FileMoniker.h"
@ -94,9 +95,9 @@
#include <simple_xml_writer.h>
#include <utils.h>
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include <boost/lexical_cast.hpp>
#include <boost/utility.hpp>
//#include <boost/utility.hpp>
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/raster/BgraFrame.h"
@ -127,7 +128,7 @@ typedef struct tagBITMAPCOREHEADER {
} BITMAPCOREHEADER;
#endif
XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* CallBack, bool & bMacros)
XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, const std::wstring & password, const std::wstring & fontsPath, const std::wstring & tempPath, const ProgressCallback* CallBack, bool & bMacros)
{
xlsx_path = xlsxFilePath;
output_document = NULL;
@ -174,6 +175,7 @@ XlsConverter::XlsConverter(const std::wstring & xlsFileName, const std::wstring
xls_global_info->fontsDirectory = fontsPath;
xls_global_info->password = password;
xls_global_info->tempDirectory = tempPath;
XLS::CFStreamCacheReader stream_reader(xls_file->getWorkbookStream(), xls_global_info);
@ -687,9 +689,9 @@ void XlsConverter::convert(XLS::GlobalsSubstream* globals)
{
if (globals == NULL) return;
convert((XLS::FORMATTING*)globals->m_Formating.get());
convert((XLS::THEME*)globals->m_THEME.get());
convert((XLS::FORMATTING*)globals->m_Formating.get());
convert((XLS::SHAREDSTRINGS*)globals->m_SHAREDSTRINGS.get());
@ -1086,9 +1088,45 @@ void XlsConverter::convert(XLS::BACKGROUND * back)
}
void XlsConverter::convert(XLS::THEME* theme)
void XlsConverter::convert(XLS::THEME* THEME_)
{
if (theme == NULL) return;
if (THEME_ == NULL) return;
XLS::Theme *theme = dynamic_cast<XLS::Theme*>(THEME_->m_Theme.get());
if (!theme) return;
if (theme->nThemeDataSize < 1) return;
std::wstring tempThemePath = xls_global_info->tempDirectory + FILE_SEPARATOR_STR + L"theme.temp";
NSFile::CFileBinary file;
if (!file.CreateFileW(tempThemePath)) return;
file.WriteFile((BYTE*)theme->pThemeData.get(), theme->nThemeDataSize);
file.CloseFile();
COfficeUtils OfficeUtils(NULL);
ULONG nBufferSize = 0;
BYTE *pBuffer = NULL;
HRESULT hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme1.xml", &pBuffer, nBufferSize);// todooo - parsing ThemeManager
if (hresult != S_OK || pBuffer == NULL)
hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme/theme1.xml", &pBuffer, nBufferSize);
if (hresult != S_OK || pBuffer == NULL)
hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme/theme/theme1.xml", &pBuffer, nBufferSize);
//??? переписать по нормальному
if (hresult == S_OK && pBuffer != NULL)
{
xls_global_info->bThemePresent = true;
oox::package::theme_content_ptr content = oox::package::theme_content::create((char*)pBuffer, nBufferSize);
output_document->get_xl_files().add_theme(content);
delete []pBuffer;
pBuffer = NULL;
}
}
struct _group_object

View File

@ -102,7 +102,7 @@ namespace ODRAW
class XlsConverter
{
public:
XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, const std::wstring & password, const std::wstring & fontsPath, const ProgressCallback* ffCallBack, bool & bMacros);
XlsConverter(const std::wstring & xlsFileName, const std::wstring & xlsxFilePath, const std::wstring & password, const std::wstring & fontsPath, const std::wstring & tempPath, const ProgressCallback* ffCallBack, bool & bMacros);
~XlsConverter() ;
oox::xlsx_conversion_context * xlsx_context;

View File

@ -201,7 +201,23 @@ void rels_files::add(std::wstring const & Id,
{
return add(relationship(Id, Type, Target, TargetMode));
}
//--------------------------------------------------------------------------------------------
customXml_content::customXml_content()
{
}
_CP_PTR(customXml_content) customXml_content::create()
{
return boost::make_shared<customXml_content>();
}
//--------------------------------------------------------------------------------------------
theme_content::theme_content(char* data, size_t size)
{
content_ = std::string(data, size);
}
_CP_PTR(theme_content) theme_content::create(char* data, size_t size)
{
return boost::make_shared<theme_content>(data, size);
}
//----------------------------------------------------------------------------------------
chart_content::chart_content() : rels_file_(rels_file::create(L""))
{

View File

@ -215,6 +215,22 @@ private:
std::string content_props;
};
//------------------------------------------------------------------------
class theme_content;
typedef _CP_PTR(theme_content) theme_content_ptr;
class theme_content : boost::noncopyable
{
public:
theme_content(char* data, size_t size);
static _CP_PTR(theme_content) create(char* data, size_t size);
std::string content() { return content_; }
friend class xl_theme_files;
private:
std::string content_;
};
//------------------------------------------------------------------------
class document : public element
{
public:

View File

@ -2146,6 +2146,7 @@ void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state
if (drawing_state->wordart.italic) CP_XML_ATTR(L"i", 1);
if (drawing_state->wordart.underline) CP_XML_ATTR(L"u", L"sng");
if (drawing_state->wordart.strike) CP_XML_ATTR(L"strike", L"sngStrike");
//if (drawing_state->wordart.cap) CP_XML_ATTR(L"cap", *cap);
CP_XML_ATTR(L"kern", 10);

View File

@ -137,14 +137,6 @@ _CP_PTR(activeX_content) activeX_content::create()
return boost::make_shared<activeX_content>();
}
//--------------------------------------------------------------------------------------------
customXml_content::customXml_content()
{
}
_CP_PTR(customXml_content) customXml_content::create()
{
return boost::make_shared<customXml_content>();
}
//--------------------------------------------------------------------------------------------
sheet_content::sheet_content() : rels_(rels_file::create(L""))
{
@ -300,11 +292,15 @@ void xl_files::write(const std::wstring & RootPath)
contentTypes.add_override(L"/xl/connections.xml", L"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml");
}
{
theme_files_.set_rels(&rels_files_);
theme_files_.set_main_document( this->get_main_document() );
theme_files_.write(path);
}
if (styles_)
{
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
}
if (workbook_)
@ -329,11 +325,6 @@ void xl_files::write(const std::wstring & RootPath)
contentTypes.add_override(L"/xl/attachedToolbars.bin", L"application/vnd.ms-excel.attachedToolbars");
}
if (theme_)
{
theme_->write(path);
}
if (media_)
{
media_->set_main_document(get_main_document());
@ -398,7 +389,6 @@ void xl_files::set_connections(element_ptr Element)
{
connections_ = Element;
}
void xl_files::add_sheet(int type, sheet_content_ptr sheet)
{
sheets_files_.add_sheet(type, sheet);
@ -422,6 +412,10 @@ void xl_files::set_vml_drawings(element_ptr Element)
xl_drawings* d = dynamic_cast<xl_drawings*>(vml_drawings_.get());
d->vml = true;
}
void xl_files::add_theme(theme_content_ptr theme)
{
theme_files_.add_theme(theme);
}
void xl_files::add_chart(chart_content_ptr chart)
{
charts_files_.add_chart(chart);
@ -702,6 +696,44 @@ void xl_customXml_files::write(const std::wstring & RootPath)
}
}
//----------------------------------------------------------------------------------------
void xl_theme_files::add_theme(theme_content_ptr themeXml)
{
themes_.push_back(themeXml);
}
void xl_theme_files::write(const std::wstring & RootPath)
{
if (themes_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme";
NSDirectory::CreateDirectory(path.c_str());
std::wstring path_rels = path + FILE_SEPARATOR_STR + L"_rels";
NSDirectory::CreateDirectory(path_rels.c_str());
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
for (size_t i = 0; i < themes_.size(); i++)
{
if (!themes_[i])continue;
const std::wstring fileName = std::wstring(L"theme") + std::to_wstring(i + 1) + L".xml";
contentTypes.add_override(std::wstring(L"/xl/theme/") + fileName, kWSConType);
package::simple_element(fileName, themes_[i]->content()).write(path);
if (rels_)
{
const std::wstring id = std::wstring(L"thmId") + std::to_wstring(i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
const std::wstring fileRef = std::wstring(L"theme/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
}
}
//----------------------------------------------------------------------------------------
void xl_externals_files::add_external(external_content_ptr external)
{
externals_.push_back(external);

View File

@ -208,6 +208,21 @@ public:
std::vector<customXml_content_ptr> customXmls_;
rels_files * rels_;
};
class xl_theme_files : public element
{
public:
xl_theme_files(){}
void set_rels(rels_files * rels)
{
rels_ = rels;
}
void add_theme(theme_content_ptr themeXml);
virtual void write(const std::wstring & RootPath);
std::vector<theme_content_ptr> themes_;
rels_files * rels_;
};
class xl_query_table_files : public element
{
public:
@ -344,6 +359,7 @@ public:
void set_vml_drawings (element_ptr Element);
void set_comments (element_ptr Element);
void add_theme (theme_content_ptr theme);
void add_chart (chart_content_ptr chart);
void add_activeX (activeX_content_ptr activeX);
void add_external (external_content_ptr external);
@ -357,6 +373,7 @@ public:
private:
rels_files rels_files_;
sheets_files sheets_files_;
xl_theme_files theme_files_;
xl_charts_files charts_files_;
xl_externals_files externals_files_;
xl_pivot_cache_files pivot_cache_files_;
@ -366,11 +383,10 @@ private:
xl_control_props_files control_props_files_;
xl_table_part_files table_part_files_;
element_ptr theme_;
element_ptr workbook_;
element_ptr connections_;
element_ptr styles_;
element_ptr styles_;
element_ptr sharedStrings_;
element_ptr media_;
element_ptr drawings_;

View File

@ -0,0 +1,62 @@
Add-Type -AssemblyName System.IO.Compression.FileSystem
# ----------------------------------------------------------------------------------------------
# download a file
# ----------------------------------------------------------------------------------------------
function Download-File
{
param ([string]$url,[string]$file)
$downloadRequired = $true
if (Test-Path $file)
{
$localModified = (Get-Item $file).CreationTime
$webRequest = [System.Net.HttpWebRequest]::Create($url)
$webRequest.Method = "HEAD"
$webResponse = $webRequest.GetResponse()
$remoteLastModified = ($webResponse.LastModified) -as [DateTime]
$webResponse.Close()
if ($remoteLastModified -gt $localModified)
{
Write-Host "$file is out of date"
}
else
{
$downloadRequired = $false
}
}
if ($downloadRequired)
{
$clnt = new-object System.Net.WebClient
Write-Host "Downloading from $url to $file"
$clnt.DownloadFile($url, $file)
}
else
{
Write-Host "$file is up to date."
}
return $downloadRequired
}
# ----------------------------------------------------------------------------------------------
# unzip a file
# ----------------------------------------------------------------------------------------------
function RemoveCef
{
param([string]$outpath)
if (Test-Path $outpath)
{
Write-Host "Remove folder $outpath"
Remove-Item $outpath -Force -Recurse
}
}
$output = Download-File -url $args[0] -file $args[1]
if ($output)
{
RemoveCef -outpath $args[2]
}

View File

@ -12,11 +12,7 @@ if defined TARGET (
mkdir "%SCRIPTPATH%%PLATFORM%"
cd "%SCRIPTPATH%%PLATFORM%"
if exist "cef_binary.7z" (
echo "cef_binary.7z already downloaded"
) else (
Powershell.exe Invoke-WebRequest -OutFile cef_binary.7z http://d2ettrnqo7v976.cloudfront.net/cef/3163/%PLATFORM%/cef_binary.7z
)
Powershell.exe -executionpolicy remotesigned -file %SCRIPTPATH%download.ps1 http://d2ettrnqo7v976.cloudfront.net/cef/3163/%PLATFORM%/cef_binary.7z cef_binary.7z cef_binary
SET UNSIP_PROGRAMM="%ProgramFiles%\7-Zip\7z.exe"
SET UNSIP_PROGRAMM2="%ProgramFiles(x86)%\7-Zip\7z.exe"

View File

@ -8,7 +8,7 @@ platform=""
case "$os" in
Linux*) platform="linux" ;;
Darwin*) platform="mac" ;;
Darwin*) platform="mac" ;;
*) exit ;;
esac
@ -35,22 +35,36 @@ echo ""
else
mkdir "build"
fi
cef_binary=cef_binary
cef_arch=$cef_binary.7z
cef_url=http://d2ettrnqo7v976.cloudfront.net/cef/3163/$platform$arch/$cef_arch
if [[ "$platform" == *"linux"* ]]
then
if [[ -f "cef_binary.7z" ]]
then
echo "cef_binary already downloaded"
else
wget http://d2ettrnqo7v976.cloudfront.net/cef/3163/$platform$arch/cef_binary.7z
fi
if [ -d cef_binary ]
then
echo "cef_binary already extracted"
else
7z x -y cef_binary.7z
fi
cp -r -t build/ ./cef_binary/Release/* ./cef_binary/Resources/*
chmod a+xr build/locales
if [[ -f $cef_arch ]]
then
cef_mod_time=$(date -d"$(curl -sI $cef_url | awk '/Last-Modified/ {print ($3, $4, $5, $6, $7, $8)}')" +"%s")
local_mod_time=$(stat -c %Y $cef_arch)
if [[ $cef_mod_time -eq $local_mod_time ]]
then
echo "cef_binary already downloaded"
else
wget $cef_url -O $cef_arch
rm -fr $cef_binary/
fi
else
wget $cef_url
rm -fr $cef_binary/
fi
if [ -d $cef_binary ]
then
echo "cef_binary already extracted"
else
7z x -y $cef_arch
fi
cp -r -t build/ ./$cef_binary/Release/* ./$cef_binary/Resources/*
chmod a+xr build/locales
fi

22
Common/3dParty/v8/build.sh Normal file → Executable file
View File

@ -45,8 +45,6 @@ cp "./out/native/obj.target/third_party/icu/libicui18n.a" "./../$platform$arch/"
cp "./out/native/obj.target/third_party/icu/libicuuc.a" "./../$platform$arch/"
cp "./out/native/obj.target/third_party/icu/libicudata.a" "./../$platform$arch/"
cp "./third_party/icu/linux/icudtl_dat.S" "./../$platform$arch/"
cp "./third_party/icu/source/data/in/icudtl.dat" "./../$platform$arch/"
fi
@ -54,17 +52,15 @@ if [[ "$platform" == *"mac"* ]]
then
CFLAGS="-fPIC" CXXFLAGS="-fPIC -stdlib=libc++" LDFLAGS="-stdlib=libc++" make native
cp "./out/native/libv8_base.a" "./../$platform$arch/"
cp "./out/native/libv8_libbase.a" "./../$platform$arch/"
cp "./out/native/libv8_libplatform.a" "./../$platform$arch/"
cp "./out/native/libv8_nosnapshot.a" "./../$platform$arch/"
cp "./out/native/libv8_external_snapshot.a" "./../$platform$arch/"
ccp "./out/native/obj.target/tools/gyp/libv8_base.a" "./../$platform$arch/"
cp "./out/native/obj.target/tools/gyp/libv8_libbase.a" "./../$platform$arch/"
cp "./out/native/obj.target/tools/gyp/libv8_libplatform.a" "./../$platform$arch/"
cp "./out/native/obj.target/tools/gyp/libv8_nosnapshot.a" "./../$platform$arch/"
cp "./out/native/obj.target/tools/gyp/libv8_external_snapshot.a" "./../$platform$arch/"
cp "./out/native/libicui18n.a" "./../$platform$arch/"
cp "./out/native/libicuuc.a" "./../$platform$arch/"
cp "./out/native/icudtl.dat" "./../$platform$arch/"
cp "./out/native/obj.target/third_party/icu/libicui18n.a" "./../$platform$arch/"
cp "./out/native/obj.target/third_party/icu/libicuuc.a" "./../$platform$arch/"
cp "./out/native/obj.target/third_party/icu/libicudata.a" "./../$platform$arch/"
cp "./out/native/libv8_libsampler.a" "./../$platform$arch/"
cp "./third_party/icu/mac/icudtl_dat.S" "./../$platform$arch/"
cp "./third_party/icu/source/data/in/icudtl.dat" "./../$platform$arch/"
fi

0
Common/3dParty/v8/fetch.sh Normal file → Executable file
View File

View File

@ -22,8 +22,8 @@ core_linux {
}
core_mac {
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libbase -lv8_libplatform -lv8_nosnapshot -lv8_external_snapshot
LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc -lv8_libsampler
LIBS += -L$$CORE_V8_PATH_LIBS -lv8_base -lv8_libplatform -lv8_libbase -lv8_nosnapshot -lv8_external_snapshot
LIBS += -L$$CORE_V8_PATH_LIBS -licui18n -licuuc -licudata
QMAKE_CXXFLAGS += -Wall -Wno-inconsistent-missing-override
QMAKE_CFLAGS += -Wall -Wno-inconsistent-missing-override

View File

@ -147,6 +147,7 @@ HEADERS += docxformatlib.h \
../Source/DocxFormat/Media/Media.h \
../Source/DocxFormat/Media/OleObject.h \
../Source/DocxFormat/Media/Video.h \
../Source/DocxFormat/Media/JsaProject.h \
../Source/DocxFormat/Settings/Settings.h \
../Source/DocxFormat/Settings/WebSettings.h \
../Source/DocxFormat/App.h \

View File

@ -54,6 +54,7 @@
#include "Media/OleObject.h"
#include "Media/ActiveX.h"
#include "Media/VbaProject.h"
#include "Media/JsaProject.h"
#include "HeaderFooter.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Theme.h"

View File

@ -92,7 +92,6 @@ namespace OOX
{
return OOX::et_wp_effectExtent;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
@ -103,7 +102,6 @@ namespace OOX
WritingElement_ReadAttributes_Read_else_if( oReader, _T("b"), m_oB )
WritingElement_ReadAttributes_End( oReader )
}
public:
SimpleTypes::CCoordinate m_oB;
SimpleTypes::CCoordinate m_oL;
SimpleTypes::CCoordinate m_oR;
@ -122,9 +120,38 @@ namespace OOX
virtual ~CPosH()
{
}
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"relativeFrom", m_oRelativeFrom );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("align") == sName )
{
m_oAlign = oNode.GetText();
m_bAlign = true;
}
else if ( _T("posOffset") == sName )
{
m_oPosOffset = oNode.GetText();
m_bAlign = false;
}
else if ( _T("pctPosHOffset") == sName )
{
m_oPctOffset = oNode.GetText();
m_bAlign = false;
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -179,7 +206,6 @@ namespace OOX
{
return OOX::et_wp_positionH;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
// Читаем атрибуты
@ -187,7 +213,6 @@ namespace OOX
WritingElement_ReadAttributes_ReadSingle( oReader, _T("relativeFrom"), m_oRelativeFrom )
WritingElement_ReadAttributes_End( oReader )
}
public:
bool IsAlign() const
{
return m_bAlign;
@ -218,11 +243,38 @@ namespace OOX
virtual ~CPosV()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"relativeFrom", m_oRelativeFrom );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("align") == sName )
{
m_oAlign = oNode.GetText();
m_bAlign = true;
}
else if ( _T("posOffset") == sName )
{
m_oPosOffset = oNode.GetText();
m_bAlign = false;
}
else if ( _T("pctPosVOffset") == sName )
{
m_oPctOffset = oNode.GetText();
m_bAlign = false;
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -276,16 +328,12 @@ namespace OOX
{
return OOX::et_wp_positionV;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("relativeFrom"), m_oRelativeFrom )
WritingElement_ReadAttributes_End( oReader )
}
public:
bool IsAlign() const
{
return m_bAlign;
@ -314,10 +362,27 @@ namespace OOX
virtual ~CSizeRelH()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"relativeFrom", m_oRelativeFrom );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("pctHeight") == sName )
{
m_oPctWidth = oNode.GetText();
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -382,10 +447,27 @@ namespace OOX
virtual ~CSizeRelV()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"relativeFrom", m_oRelativeFrom );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("pctHeight") == sName )
{
m_oPctHeight = oNode.GetText();
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -482,11 +564,29 @@ namespace OOX
virtual ~CWrapSquare()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"distB", m_oDistB );
node.ReadAttributeBase( L"distL", m_oDistL );
node.ReadAttributeBase( L"distR", m_oDistR );
node.ReadAttributeBase( L"distT", m_oDistT );
node.ReadAttributeBase( L"wrapText", m_oWrapText );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("effectExtents") == sName )
m_oEffectExtent = oNode;
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -503,7 +603,7 @@ namespace OOX
m_oEffectExtent = oReader;
}
}
virtual std::wstring toXML() const
virtual std::wstring toXML() const
{
std::wstring sResult = _T("<wp:wrapSquare ");
if(m_oWrapText.IsInit())
@ -566,12 +666,35 @@ namespace OOX
}
m_arrLineTo.clear();
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"edited", m_oEdited );
XmlUtils::CXmlNodes oNodes;
bool bStart = false;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("start") == sName )
{
m_oStart = oNode;
bStart = true;
}
else if ( bStart && _T("lineTo") == sName )
{
ComplexTypes::Drawing::CPoint2D *oPoint = new ComplexTypes::Drawing::CPoint2D(oNode);
if (oPoint) m_arrLineTo.push_back( oPoint );
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -646,12 +769,29 @@ namespace OOX
virtual ~CWrapThrough()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"distL", m_oDistL );
node.ReadAttributeBase( L"distR", m_oDistR );
node.ReadAttributeBase( L"wrapText", m_oWrapText );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("wrapPolygon") == sName )
{
m_oWrapPolygon = oNode;
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -717,9 +857,25 @@ namespace OOX
virtual ~CWrapTight()
{
}
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("wrapPolygon") == sName )
{
m_oWrapPolygon = oNode;
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -785,9 +941,26 @@ namespace OOX
virtual ~CWrapTopBottom()
{
}
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
node.ReadAttributeBase( L"distB", m_oDistB );
node.ReadAttributeBase( L"distT", m_oDistT );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("effectExtents") == sName )
m_oEffectExtent = oNode;
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -862,11 +1035,69 @@ namespace OOX
virtual ~CAnchor()
{
}
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
ReadAttributes(node);
m_eWrapType = anchorwrapUnknown;
// TO DO: Реализовать
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("docPr") == sName )
m_oDocPr = oNode;
else if ( _T("effectExtent") == sName )
m_oEffectExtent = oNode;
else if ( _T("extent") == sName )
m_oExtent = oNode;
else if ( _T("positionH") == sName )
m_oPositionH = oNode;
else if ( _T("positionV") == sName )
m_oPositionV = oNode;
else if ( _T("simplePos") == sName )
m_oSimplePos = oNode;
else if ( _T("sizeRelH") == sName )
m_oSizeRelH = oNode;
else if ( _T("sizeRelV") == sName )
m_oSizeRelV = oNode;
else if ( false == m_eWrapType.IsInit() )
{
if ( _T("wrapNone") == sName )
{
m_oWrapNone = oNode;
m_eWrapType = anchorwrapNone;
}
else if ( _T("wrapSquare") == sName )
{
m_oWrapSquare = oNode;
m_eWrapType = anchorwrapSquare;
}
else if ( _T("wrapThrough") == sName )
{
m_oWrapThrough = oNode;
m_eWrapType = anchorwrapThrough;
}
else if ( _T("wrapTight") == sName )
{
m_oWrapTight = oNode;
m_eWrapType = anchorwrapTight;
}
else if ( _T("wrapTopAndBottom") == sName )
{
m_oWrapTopAndBottom = oNode;
m_eWrapType = anchorwrapTopAndBottom;
}
}
}
m_oGraphic.fromXML(node);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -985,6 +1216,20 @@ namespace OOX
WritingElement_ReadAttributes_Read_else_if( oReader, _T("simplePos"), m_bSimplePos )
WritingElement_ReadAttributes_End( oReader )
}
void ReadAttributes(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( L"allowOverlap", m_oAllowOverlap );
oNode.ReadAttributeBase( L"behindDoc", m_oBehindDoc );
oNode.ReadAttributeBase( L"distB", m_oDistB );
oNode.ReadAttributeBase( L"distL", m_oDistL );
oNode.ReadAttributeBase( L"distR", m_oDistR );
oNode.ReadAttributeBase( L"distT", m_oDistT );
oNode.ReadAttributeBase( L"hidden", m_oHidden );
oNode.ReadAttributeBase( L"layoutInCell", m_oLayoutInCell );
oNode.ReadAttributeBase( L"locked", m_oLocked );
oNode.ReadAttributeBase( L"relativeHeight", m_oRelativeHeight );
oNode.ReadAttributeBase( L"simplePos", m_bSimplePos );
}
public:
nullable<EAnchorWrapType> m_eWrapType;
@ -1031,9 +1276,30 @@ namespace OOX
virtual ~CInline()
{
}
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
ReadAttributes( node );
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring sName = XmlUtils::GetNameNoNS(oNode.GetName());
if ( _T("docPr") == sName )
m_oDocPr = oNode;
else if ( _T("effectExtent") == sName )
m_oEffectExtent = oNode;
else if ( _T("extent") == sName )
m_oExtent = oNode;
}
m_oGraphic.fromXML(node);
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -1090,6 +1356,13 @@ namespace OOX
return OOX::et_wp_inline;
}
private:
void ReadAttributes(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( L"distB", m_oDistB );
oNode.ReadAttributeBase( L"distL", m_oDistL );
oNode.ReadAttributeBase( L"distR", m_oDistR );
oNode.ReadAttributeBase( L"distT", m_oDistT );
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
@ -1148,9 +1421,31 @@ namespace OOX
fromXML( (XmlUtils::CXmlLiteReader&)oReader );
return *this;
}
virtual void fromXML(XmlUtils::CXmlNode& oNode)
virtual void fromXML(XmlUtils::CXmlNode& node)
{
// TO DO: Реализовать
XmlUtils::CXmlNodes oNodes;
if (node.GetNodes(_T("*"), oNodes))
{
int nCount = oNodes.GetCount();
for (int i = 0; i < nCount; ++i)
{
XmlUtils::CXmlNode oNode;
oNodes.GetAt(i, oNode);
std::wstring strName = XmlUtils::GetNameNoNS(oNode.GetName());
if (_T("inline") == strName)
{
m_oInline = oNode;
m_bAnchor = false;
}
else if (_T("anchor") == strName)
{
m_oAnchor = oNode;
m_bAnchor = true;
}
}
}
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{

View File

@ -49,6 +49,7 @@
#include "Media/Audio.h"
#include "Media/Video.h"
#include "Media/VbaProject.h"
#include "Media/JsaProject.h"
#include "External/HyperLink.h"
#include "External/ExternalVideo.h"
#include "External/ExternalAudio.h"
@ -146,6 +147,8 @@ namespace OOX
return smart_ptr<OOX::File>(new OOX::VbaProject( oRootPath, oFileName ));
//else if ( oRelation.Type() == OOX::FileTypes::VbaData)
// return smart_ptr<OOX::File>(new OOX::VbaData( oFileName ));
else if ( oRelation.Type() == FileTypes::JsaProject)
return smart_ptr<OOX::File>(new JsaProject( oFileName ));
return smart_ptr<OOX::File>( new UnknowTypeFile() );
}
@ -238,6 +241,8 @@ namespace OOX
return smart_ptr<OOX::File>(new OOX::VbaProject( oRootPath, oFileName ));
//else if ( pRelation->Type() == FileTypes::VbaData)
// return smart_ptr<OOX::File>(new OOX::VbaData( oFileName ));
else if ( pRelation->Type() == FileTypes::JsaProject)
return smart_ptr<OOX::File>(new JsaProject( oFileName ));
return smart_ptr<OOX::File>( new UnknowTypeFile() );
}

View File

@ -192,6 +192,10 @@ namespace OOX
_T("application/vnd.ms-word.vbaData+xml"),
_T("http://schemas.microsoft.com/office/2006/relationships/wordVbaData"));
const FileType JsaProject(L"", L"jsaProject.bin",
_T(""),
_T("http://schemas.onlyoffice.com/jsaProject"));
const FileType MicrosoftOfficeUnknown(L"embeddings", L"",
_T(""),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"));

View File

@ -142,7 +142,13 @@ namespace OOX
virtual void fromXML(XmlUtils::CXmlNode &oNode)
{
// TO DO: Реализовать CPicture::fromXML(XmlUtils::CXmlNode &oNode)
if ( oNode.IsValid() == false)
return;
m_sXml.Init();
*m_sXml = oNode.GetXml(); //для pptx dll
fromStringXML(m_sXml.get());
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
@ -152,11 +158,15 @@ namespace OOX
m_sXml.Init();
*m_sXml = oReader.GetOuterXml(); //для pptx dll
fromStringXML(m_sXml.get());
}
void fromStringXML(const std::wstring & xml_string)
{
std::wstring sBegin(L"<root 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\">");
std::wstring sEnd(L"</root>");
std::wstring sXml = sBegin + m_sXml.get() + sEnd;
std::wstring sXml = sBegin + xml_string + sEnd;
XmlUtils::CXmlLiteReader oSubReader;

View File

@ -0,0 +1,99 @@
/*
* (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
#ifndef OOX_ONLY_JSA_PROJECT_INCLUDE_H_
#define OOX_ONLY_JSA_PROJECT_INCLUDE_H_
#include "Media.h"
#include "../../XlsxFormat/FileTypes_Spreadsheet.h"
namespace OOX
{
class JsaProject : public Media
{
public:
JsaProject()
{
}
JsaProject(const CPath& filename)
{
read(filename);
}
virtual ~JsaProject()
{
}
virtual const FileType type() const
{
return FileTypes::JsaProject;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(m_filename.GetPath(), &pData, nBytesCount))
{
pWriter->WriteBYTEArray(pData, nBytesCount);
}
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _length = pReader->GetLong();
LONG _end_rec = pReader->GetPos() + _length;
if (_length > 0)
{
BYTE* pData = pReader->GetPointer(_length);
std::wstring filePath = pReader->m_pRels->m_pManager->GetDstFolder() + FILE_SEPARATOR_STR + OOX::FileTypes::JsaProject.DefaultFileName().GetPath();
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath);
oFile.WriteFile(pData, _length);
oFile.CloseFile();
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(OOX::FileTypes::JsaProject.DefaultFileName().GetExtention(false));
set_filename(filePath);
}
pReader->Seek(_end_rec);
}
};
} // namespace OOX
#endif // OOX_ONLY_JSA_PROJECT_INCLUDE_H_

View File

@ -44,6 +44,7 @@
#define AVS_ERROR_FILEFORMAT (AVS_ERROR_FIRST + 0x0004)
#define AVS_ERROR_PASSWORD (AVS_ERROR_FIRST + 0x0005)
#define AVS_ERROR_DRM (AVS_ERROR_FIRST + 0x0006)
#define AVS_ERROR_MACRO (AVS_ERROR_FIRST + 0x0007)
// AVSOfficeUniversalConverter 0x0050 - 0x0075
#define AVS_UNIVERSALDOCUMENTCONVERTER_ERROR_FIRST (AVS_ERROR_FIRST + 0x0050)

View File

@ -42,11 +42,13 @@ namespace POLE
class COfficeFileFormatChecker
{
public:
int nFileType;
int nFileType;
bool bMacroEnabled;
COfficeFileFormatChecker()
{
nFileType = AVS_OFFICESTUDIO_FILE_UNKNOWN;
nFileType = AVS_OFFICESTUDIO_FILE_UNKNOWN;
bMacroEnabled = false;
}
COfficeFileFormatChecker(std::wstring sFileName)
{

View File

@ -34,6 +34,10 @@
#include "../DesktopEditor/common/File.h"
#include "../OfficeUtils/src/OfficeUtils.h"
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
#include "../ASCOfficePPTFile/PPTFormatLib/PPTFormatLib.h"
#endif
#include "3dParty/pole/pole.h"
#include <algorithm>
@ -118,6 +122,9 @@ bool COfficeFileFormatChecker::isPdfFormatFile (unsigned char* pBuffer,int dwByt
if (pBuffer == NULL) return false;
int nTempBufferSize = dwBytes < 20 ? dwBytes : 20;
if (nTempBufferSize < 1)
return false;
char* pTempBuffer = new char[nTempBufferSize];
memcpy ( pTempBuffer, pBuffer, nTempBufferSize );
@ -145,6 +152,12 @@ bool COfficeFileFormatChecker::isDocFormatFile (POLE::Storage * storage)
if (entries.size() > 0)
return false;
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
if (storage->isDirectory(L"Macros"))
{
bMacroEnabled = true;
}
#endif
return true;
}
@ -158,31 +171,37 @@ bool COfficeFileFormatChecker::isXlsFormatFile (POLE::Storage * storage)
POLE::Stream stream(storage, L"Workbook");
if (stream.read(buffer,10) >0)
return true;
if (stream.read(buffer,10) < 1)
{
POLE::Stream stream2(storage, L"Book");
POLE::Stream stream2(storage, L"Book");
if (stream2.read(buffer,10) < 1)
{
POLE::Stream stream3(storage, L"WORKBOOK");
if (stream2.read(buffer,10) > 0)
return true;
if (stream3.read(buffer,10) < 1)
{
POLE::Stream stream4(storage, L"BOOK");
POLE::Stream stream3(storage, L"WORKBOOK");
if (stream4.read(buffer,10) < 1)
{
POLE::Stream stream5(storage, L"book");
if (stream3.read(buffer,10) > 0)
return true;
POLE::Stream stream4(storage, L"BOOK");
if (stream4.read(buffer,10) > 0)
return true;
POLE::Stream stream5(storage, L"book");
if (stream5.read(buffer,10) > 0)
return true;
return false;
if (stream5.read(buffer,10) < 1)
return false;
}
}
}
}
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
if (storage->isDirectory(L"_VBA_PROJECT_CUR"))
{
bMacroEnabled = true;
}
#endif
return true;
}
bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
{
if (storage == NULL) return false;
@ -190,10 +209,10 @@ bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
POLE::Stream stream(storage, L"PowerPoint Document");
unsigned char buffer[10];
if (stream.read(buffer,10) >0)
return true;
if (stream.read(buffer,10) < 1)
return false;
return false;
return true;
}
bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage)
{
@ -227,7 +246,18 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName)
}
else if ( isPptFormatFile(&storage) )
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
#if defined FILE_FORMAT_CHECKER_WITH_MACRO
COfficePPTFile pptFile;
bMacroEnabled = true;
long nResult = pptFile.OpenFile(fileName, L"", bMacroEnabled);
if (nResult != S_OK)
{
return false;
}
pptFile.CloseFile();
#endif
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
return true;
}
else if ( isMS_OFFCRYPTOFormatFile(&storage) )
@ -380,6 +410,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(docmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(dotxFormatLine))
{
@ -388,6 +419,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(dotmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(xlsxFormatLine))
{
@ -396,6 +428,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(xlsmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(xltxFormatLine))
{
@ -404,6 +437,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(xltmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(pptxFormatLine))
{
@ -412,10 +446,12 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(pptmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(ppsmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM;
bMacroEnabled = true;
}
else if (std::string::npos != strContentTypes.find(ppsxFormatLine))
{
@ -428,6 +464,7 @@ bool COfficeFileFormatChecker::isOOXFormatFile(const std::wstring & fileName)
else if (std::string::npos != strContentTypes.find(potmFormatLine))
{
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM;
bMacroEnabled = true;
}
delete []pBuffer;
pBuffer = NULL;

View File

@ -7,7 +7,7 @@
QT -= core
QT -= gui
VERSION = 2.4.489.0
VERSION = 2.4.492.0
DEFINES += INTVER=$$VERSION
TARGET = x2t
@ -60,6 +60,7 @@ DEFINES += DJVU_USE_DYNAMIC_LIBRARY
DEFINES += HTMLRENDERER_USE_DYNAMIC_LIBRARY
DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY
DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY
DEFINES += FILE_FORMAT_CHECKER_WITH_MACRO
core_windows {
INCLUDEPATH += ../../../OfficeUtils/src/zlib-1.2.3

View File

@ -3661,7 +3661,7 @@ namespace NExtractTools
{
bool bMacros = false;
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), NULL, bMacros);
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros);
if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
@ -3696,7 +3696,7 @@ namespace NExtractTools
{
bool bMacros = true;
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), NULL, bMacros);
long hRes = ConvertXls2Xlsx( sFrom, sTo, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros);
if (AVS_ERROR_DRM == hRes)
{
if(!params.getDontSaveAdditional())
@ -3740,7 +3740,7 @@ namespace NExtractTools
bool bMacros = true;
if (ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), NULL, bMacros)== S_OK)
if (ConvertXls2Xlsx( sFrom, sResultXlsxDir, params.getPassword(), params.getFontPath(), sTemp, NULL, bMacros)== S_OK)
{
BinXlsxRW::CXlsxSerializer m_oCXlsxSerializer;
@ -3801,6 +3801,23 @@ namespace NExtractTools
}
//------------------------------------------------------------------------------------------------------------------
int detectMacroInFile(InputParams& oInputParams)
{
int nRes = 0;// no macro
std::wstring sFileFrom = *oInputParams.m_sFileFrom;
COfficeFileFormatChecker OfficeFileFormatChecker;
if (OfficeFileFormatChecker.isOfficeFile(sFileFrom))
{
if (OfficeFileFormatChecker.bMacroEnabled)
{
nRes = AVS_ERROR_MACRO;
}
}
return nRes;
}
int fromInputParams(InputParams& oInputParams)
{
TConversionDirection conversion = oInputParams.getConversionDirection();

View File

@ -199,6 +199,7 @@ namespace NExtractTools
int fromCanvasPdf(const std::wstring &sFrom, int nFormatFrom, const std::wstring &sTo, int nFormatTo, const std::wstring &sTemp, const std::wstring &sThemeDir, bool bFromChanges, bool bPaid, InputParams& params);
int fromInputParams(InputParams& oInputParams);
int detectMacroInFile(InputParams& oInputParams);
X2T_DECL_EXPORT int FromFile(const std::wstring& file);
X2T_DECL_EXPORT int FromXml(const std::wstring& xml);

Some files were not shown because too many files have changed in this diff Show More