mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-26 04:33:24 +08:00
Compare commits
33 Commits
core-win-6
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| dd3b671e57 | |||
| 74bd059607 | |||
| 80fe4c0164 | |||
| 04f7527f9e | |||
| d92aa1f793 | |||
| af4e135fe2 | |||
| a5ef8c01b3 | |||
| 1b7f35b317 | |||
| 4079dea224 | |||
| f4c112d523 | |||
| b082ffe20c | |||
| c589a6c947 | |||
| 15b08aeebf | |||
| 672129c242 | |||
| 92689a7a57 | |||
| 31ebd7b14c | |||
| 1695668a6f | |||
| 77dfd5c12a | |||
| e600fe93b7 | |||
| 889a1f827a | |||
| 8cd55fb9c4 | |||
| 01b9309f09 | |||
| d3a4f00f76 | |||
| f65196d95b | |||
| 3ee5d685c2 | |||
| c0cd75dbd5 | |||
| a69453af4b | |||
| 3adcfecfb9 | |||
| a7d2191649 | |||
| db50e87fe0 | |||
| 36bdc7376a | |||
| 1321211336 | |||
| 8c834c5041 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -13,6 +13,11 @@ Common/3dParty/cef/win_32
|
||||
Common/3dParty/cef/linux_64
|
||||
Common/3dParty/cef/linux_32
|
||||
Common/3dParty/cef/mac_64
|
||||
Common/3dParty/curl/win_64
|
||||
Common/3dParty/curl/win_32
|
||||
Common/3dParty/curl/linux_64
|
||||
Common/3dParty/curl/linux_32
|
||||
Common/3dParty/curl/mac_64
|
||||
Common/3dParty/v8/v8
|
||||
Common/3dParty/v8/depot_tools
|
||||
Common/3dParty/v8/win_64
|
||||
@ -40,6 +45,8 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_i.c
|
||||
ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c
|
||||
ASCOfficeXlsFile2/win32/dlldata.c
|
||||
OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
|
||||
X2tConverter/**/Makefile.*
|
||||
*.7z
|
||||
*.obj
|
||||
*.pdb
|
||||
*.tlb
|
||||
|
||||
@ -780,7 +780,9 @@ public:
|
||||
std::wstring Name;
|
||||
std::wstring Id;
|
||||
BYTE byteType;
|
||||
bool bDefault;
|
||||
bool Default;
|
||||
bool Custom;
|
||||
std::wstring Aliases;
|
||||
std::wstring BasedOn;
|
||||
std::wstring NextId;
|
||||
std::wstring Link;
|
||||
@ -789,6 +791,11 @@ public:
|
||||
bool hidden;
|
||||
bool semiHidden;
|
||||
bool unhideWhenUsed;
|
||||
bool autoRedefine;
|
||||
bool locked;
|
||||
bool personal;
|
||||
bool personalCompose;
|
||||
bool personalReply;
|
||||
std::wstring TextPr;
|
||||
std::wstring ParaPr;
|
||||
std::wstring TablePr;
|
||||
@ -796,22 +803,36 @@ public:
|
||||
std::wstring CellPr;
|
||||
std::vector<std::wstring> TblStylePr;
|
||||
|
||||
bool bDefault;
|
||||
bool bCustom;
|
||||
bool bqFormat;
|
||||
bool buiPriority;
|
||||
bool bhidden;
|
||||
bool bsemiHidden;
|
||||
bool bunhideWhenUsed;
|
||||
bool bautoRedefine;
|
||||
bool blocked;
|
||||
bool bpersonal;
|
||||
bool bpersonalCompose;
|
||||
bool bpersonalReply;
|
||||
|
||||
public:
|
||||
docStyle()
|
||||
{
|
||||
byteType = styletype_Paragraph;
|
||||
bDefault = false;
|
||||
bCustom = false;
|
||||
|
||||
bqFormat = false;
|
||||
buiPriority = false;
|
||||
bhidden = false;
|
||||
bsemiHidden = false;
|
||||
bunhideWhenUsed = false;
|
||||
bautoRedefine = false;
|
||||
blocked = false;
|
||||
bpersonal = false;
|
||||
bpersonalCompose = false;
|
||||
bpersonalReply = false;
|
||||
}
|
||||
void Write(XmlUtils::CStringWriter* pCStringWriter)
|
||||
{
|
||||
@ -827,10 +848,35 @@ public:
|
||||
{
|
||||
std::wstring sStyle = L"<w:style w:type=\"" + sType + L"\" w:styleId=\"" + Id + L"\"";
|
||||
if(bDefault)
|
||||
sStyle += L" w:default=\"1\"";
|
||||
{
|
||||
if(Default)
|
||||
sStyle += L" w:default=\"1\"";
|
||||
else
|
||||
sStyle += L" w:default=\"0\"";
|
||||
}
|
||||
if(bCustom)
|
||||
{
|
||||
if(Custom)
|
||||
sStyle += L" w:customStyle=\"1\"";
|
||||
else
|
||||
sStyle += L" w:customStyle=\"0\"";
|
||||
}
|
||||
|
||||
sStyle += L">";
|
||||
pCStringWriter->WriteString(sStyle);
|
||||
if(!Aliases.empty())
|
||||
{
|
||||
pCStringWriter->WriteString(L"<w:aliases w:val=\"");
|
||||
pCStringWriter->WriteEncodeXmlString(Aliases);
|
||||
pCStringWriter->WriteString(L"\"/>");
|
||||
}
|
||||
if(bautoRedefine)
|
||||
{
|
||||
if(autoRedefine)
|
||||
pCStringWriter->WriteString(L"<w:autoRedefine/>");
|
||||
else
|
||||
pCStringWriter->WriteString(L"<w:autoRedefine val=\"false\"/>");
|
||||
}
|
||||
if(!Name.empty())
|
||||
{
|
||||
pCStringWriter->WriteString(L"<w:name w:val=\"" + Name + L"\"/>");
|
||||
@ -843,12 +889,40 @@ public:
|
||||
{
|
||||
pCStringWriter->WriteString(L"<w:next w:val=\"" + NextId + L"\"/>");
|
||||
}
|
||||
if(bpersonal)
|
||||
{
|
||||
if(personal)
|
||||
pCStringWriter->WriteString(L"<w:personal/>");
|
||||
else
|
||||
pCStringWriter->WriteString(L"<w:personal val=\"false\"/>");
|
||||
}
|
||||
if(bpersonalCompose)
|
||||
{
|
||||
if(personalCompose)
|
||||
pCStringWriter->WriteString(L"<w:personalCompose/>");
|
||||
else
|
||||
pCStringWriter->WriteString(L"<w:personalCompose val=\"false\"/>");
|
||||
}
|
||||
if(bpersonalReply)
|
||||
{
|
||||
if(personalReply)
|
||||
pCStringWriter->WriteString(L"<w:personalReply/>");
|
||||
else
|
||||
pCStringWriter->WriteString(L"<w:personalReply val=\"false\"/>");
|
||||
}
|
||||
if(!Link.empty())
|
||||
{
|
||||
pCStringWriter->WriteString(L"<w:link w:val=\"");
|
||||
pCStringWriter->WriteEncodeXmlString(Link);
|
||||
pCStringWriter->WriteString(L"\"/>");
|
||||
}
|
||||
if(blocked)
|
||||
{
|
||||
if(locked)
|
||||
pCStringWriter->WriteString(L"<w:locked/>");
|
||||
else
|
||||
pCStringWriter->WriteString(L"<w:locked val=\"false\"/>");
|
||||
}
|
||||
if(bqFormat)
|
||||
{
|
||||
if(qFormat)
|
||||
@ -1237,6 +1311,7 @@ public:
|
||||
class docLvl
|
||||
{
|
||||
public:
|
||||
long ILvl;
|
||||
long Format;
|
||||
BYTE Jc;
|
||||
std::vector<docLvlText*> Text;
|
||||
@ -1247,6 +1322,7 @@ public:
|
||||
XmlUtils::CStringWriter TextPr;
|
||||
std::wstring PStyle;
|
||||
|
||||
bool bILvl;
|
||||
bool bFormat;
|
||||
bool bJc;
|
||||
bool bText;
|
||||
@ -1258,6 +1334,7 @@ public:
|
||||
bool bPStyle;
|
||||
docLvl()
|
||||
{
|
||||
bILvl = false;
|
||||
bFormat = false;
|
||||
bJc = false;
|
||||
bText = false;
|
||||
@ -1275,9 +1352,14 @@ public:
|
||||
delete Text[i];
|
||||
}
|
||||
}
|
||||
void Write(XmlUtils::CStringWriter& oWriter, int index)
|
||||
void Write(XmlUtils::CStringWriter& oWriter)
|
||||
{
|
||||
oWriter.WriteString(L"<w:lvl w:ilvl=\"" + std::to_wstring(index) + L"\">");
|
||||
oWriter.WriteString(L"<w:lvl");
|
||||
if(bILvl)
|
||||
{
|
||||
oWriter.WriteString(L" w:ilvl=\"" + std::to_wstring(ILvl) + L"\"");
|
||||
}
|
||||
oWriter.WriteString(L">");
|
||||
if(bStart)
|
||||
{
|
||||
oWriter.WriteString(L"<w:start w:val=\"" + std::to_wstring(Start) + L"\"/>");
|
||||
@ -1374,6 +1456,48 @@ public:
|
||||
oWriter.WriteString(L"</w:lvl>");
|
||||
}
|
||||
};
|
||||
class docLvlOverride
|
||||
{
|
||||
public:
|
||||
long ILvl;
|
||||
long StartOverride;
|
||||
docLvl* Lvl;
|
||||
|
||||
bool bILvl;
|
||||
bool bStartOverride;
|
||||
docLvlOverride()
|
||||
{
|
||||
bILvl = false;
|
||||
bStartOverride = false;
|
||||
Lvl = NULL;
|
||||
}
|
||||
~docLvlOverride()
|
||||
{
|
||||
RELEASEOBJECT(Lvl);
|
||||
}
|
||||
void Write(XmlUtils::CStringWriter& oWriter)
|
||||
{
|
||||
oWriter.WriteString(L"<w:lvlOverride");
|
||||
if (bILvl)
|
||||
{
|
||||
oWriter.WriteString(L" w:ilvl=\"");
|
||||
oWriter.WriteString(std::to_wstring(ILvl));
|
||||
oWriter.WriteString(L"\"");
|
||||
}
|
||||
oWriter.WriteString(L">");
|
||||
if (bStartOverride)
|
||||
{
|
||||
oWriter.WriteString(L"<w:startOverride w:val=\"");
|
||||
oWriter.WriteString(std::to_wstring(StartOverride));
|
||||
oWriter.WriteString(L"\"/>");
|
||||
}
|
||||
if(NULL != Lvl)
|
||||
{
|
||||
Lvl->Write(oWriter);
|
||||
}
|
||||
oWriter.WriteString(L"</w:lvlOverride>");
|
||||
}
|
||||
};
|
||||
class docANum
|
||||
{
|
||||
public:
|
||||
@ -1411,7 +1535,7 @@ public:
|
||||
}
|
||||
for(int i = 0, length = (int)Lvls.size(); i < length; ++i)
|
||||
{
|
||||
Lvls[i]->Write(oWriterANum, i);
|
||||
Lvls[i]->Write(oWriterANum);
|
||||
}
|
||||
oWriterANum.WriteString(L"</w:abstractNum>");
|
||||
}
|
||||
@ -1422,6 +1546,7 @@ class docNum
|
||||
public:
|
||||
long AId;
|
||||
long Id;
|
||||
std::vector<docLvlOverride*> LvlOverrides;
|
||||
|
||||
bool bAId;
|
||||
bool bId;
|
||||
@ -1430,12 +1555,21 @@ public:
|
||||
bAId = false;
|
||||
bId = false;
|
||||
}
|
||||
~docNum()
|
||||
{
|
||||
for(size_t i = 0; i < LvlOverrides.size(); ++i){
|
||||
RELEASEOBJECT(LvlOverrides[i]);
|
||||
}
|
||||
}
|
||||
void Write(XmlUtils::CStringWriter& oWriterNumList)
|
||||
{
|
||||
if(bAId && bId)
|
||||
{
|
||||
oWriterNumList.WriteString(L"<w:num w:numId=\"" + std::to_wstring(Id) + L"\"><w:abstractNumId w:val=\"" +
|
||||
std::to_wstring(AId) + L"\"/></w:num>");
|
||||
oWriterNumList.WriteString(L"<w:num w:numId=\"" + std::to_wstring(Id) + L"\"><w:abstractNumId w:val=\"" + std::to_wstring(AId) + L"\"/>");
|
||||
for(size_t i = 0; i < LvlOverrides.size(); ++i){
|
||||
LvlOverrides[i]->Write(oWriterNumList);
|
||||
}
|
||||
oWriterNumList.WriteString(L"</w:num>");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1593,7 +1727,6 @@ public:
|
||||
};
|
||||
class CComment{
|
||||
private:
|
||||
typedef std::wstring (*funcArg)(CComment* pComment);
|
||||
IdCounter& m_oParaIdCounter;
|
||||
IdCounter& m_oFormatIdCounter;
|
||||
public:
|
||||
@ -1654,13 +1787,13 @@ public:
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
std::wstring writeTemplates(funcArg fReadFunction)
|
||||
std::wstring writeTemplates(bool isExt)
|
||||
{
|
||||
std::wstring sRes;
|
||||
sRes += (fReadFunction(this));
|
||||
sRes += isExt ? writeContentExt(this) : writeContent(this);
|
||||
|
||||
for(size_t i = 0; i < replies.size(); ++i)
|
||||
sRes += (fReadFunction(replies[i]));
|
||||
sRes += isExt ? writeContentExt(replies[i]) : writeContent(replies[i]);
|
||||
return sRes;
|
||||
}
|
||||
static std::wstring writeRef(CComment* pComment, const std::wstring& sBefore, const std::wstring& sRef, const std::wstring& sAfter)
|
||||
@ -1852,7 +1985,7 @@ public:
|
||||
std::wstring sRes;
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += (it->second->writeTemplates(CComment::writeContent));
|
||||
sRes += it->second->writeTemplates(false);
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
@ -1861,7 +1994,7 @@ public:
|
||||
std::wstring sRes;
|
||||
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sRes += (it->second->writeTemplates(CComment::writeContentExt));
|
||||
sRes += it->second->writeTemplates(true);
|
||||
}
|
||||
return sRes;
|
||||
}
|
||||
|
||||
@ -47,7 +47,9 @@ Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReade
|
||||
}
|
||||
int Binary_HdrFtrTableReader::Read()
|
||||
{
|
||||
return ReadTable(&Binary_HdrFtrTableReader::ReadHdrFtrContent, this);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
READ_TABLE_DEF(res, this->ReadHdrFtrContent, NULL);
|
||||
return res;
|
||||
}
|
||||
int Binary_HdrFtrTableReader::ReadHdrFtrContent(BYTE type, long length, void* poResult)
|
||||
{
|
||||
@ -55,7 +57,7 @@ int Binary_HdrFtrTableReader::ReadHdrFtrContent(BYTE type, long length, void* po
|
||||
if ( c_oSerHdrFtrTypes::Header == type || c_oSerHdrFtrTypes::Footer == type )
|
||||
{
|
||||
nCurType = type;
|
||||
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrFEO, this, poResult);
|
||||
READ1_DEF(length, res, this->ReadHdrFtrFEO, poResult);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
@ -67,7 +69,7 @@ int Binary_HdrFtrTableReader::ReadHdrFtrFEO(BYTE type, long length, void* poResu
|
||||
if ( c_oSerHdrFtrTypes::HdrFtr_First == type || c_oSerHdrFtrTypes::HdrFtr_Even == type || c_oSerHdrFtrTypes::HdrFtr_Odd == type )
|
||||
{
|
||||
nCurHeaderType = type;
|
||||
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItem, this, poResult);
|
||||
READ1_DEF(length, res, this->ReadHdrFtrItem, poResult);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
@ -99,7 +101,7 @@ int Binary_HdrFtrTableReader::ReadHdrFtrItem(BYTE type, long length, void* poRes
|
||||
}
|
||||
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
|
||||
Binary_DocumentTableReader oBinary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, poHdrFtrItem->Header, m_pComments);
|
||||
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItemContent, this, &oBinary_DocumentTableReader);
|
||||
READ1_DEF(length, res, this->ReadHdrFtrItemContent, &oBinary_DocumentTableReader);
|
||||
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" +
|
||||
FILE_SEPARATOR_STR + L"_rels"+
|
||||
@ -118,4 +120,4 @@ int Binary_HdrFtrTableReader::ReadHdrFtrItemContent(BYTE type, long length, void
|
||||
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -201,7 +201,10 @@ extern int g_nCurFormatVersion;
|
||||
StyleLink = 23,
|
||||
lvl_NumFmt = 24,
|
||||
NumFmtVal = 25,
|
||||
NumFmtFormat = 26
|
||||
NumFmtFormat = 26,
|
||||
Num_LvlOverride = 27,
|
||||
StartOverride = 28,
|
||||
ILvl = 29
|
||||
};}
|
||||
namespace c_oSerOtherTableTypes{enum c_oSerOtherTableTypes
|
||||
{
|
||||
@ -262,7 +265,14 @@ extern int g_nCurFormatVersion;
|
||||
Style_RowPr = 15,
|
||||
Style_CellPr = 16,
|
||||
Style_TblStylePr = 17,
|
||||
Style_Link = 18
|
||||
Style_Link = 18,
|
||||
Style_CustomStyle = 19,
|
||||
Style_Aliases = 20,
|
||||
Style_AutoRedefine = 21,
|
||||
Style_Locked = 22,
|
||||
Style_Personal = 23,
|
||||
Style_PersonalCompose = 24,
|
||||
Style_PersonalReply = 25
|
||||
};}
|
||||
namespace c_oSerProp_tblStylePrType{enum c_oSerProp_tblStylePrType
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -341,7 +341,7 @@ bool BinDocxRW::CDocxSerializer::getXmlContent(NSBinPptxRW::CBinaryFileReader& o
|
||||
long nLength = oBufferedStream.GetLong();
|
||||
Writers::ContentWriter oTempContentWriter;
|
||||
BinDocxRW::Binary_DocumentTableReader oBinary_DocumentTableReader(oBufferedStream, *m_pCurFileWriter, oTempContentWriter, m_pCurFileWriter->m_pComments);
|
||||
int res = oBinary_DocumentTableReader.Read1(nLength, &BinDocxRW::Binary_DocumentTableReader::ReadDocumentContent, &oBinary_DocumentTableReader, NULL);
|
||||
oBinary_DocumentTableReader.ReadDocumentContentOut(nLength);
|
||||
|
||||
sOutputXml = oTempContentWriter.m_oContent.GetData();
|
||||
return true;
|
||||
@ -433,13 +433,13 @@ bool BinDocxRW::CDocxSerializer::getXmlContentElem(OOX::EElementType eType, NSBi
|
||||
if(OOX::et_m_oMathPara == eType)
|
||||
{
|
||||
oTempContentWriter.m_oContent.WriteString(std::wstring(_T("<m:oMathPara>")));
|
||||
oBinary_DocumentTableReader.Read1(nLength, &BinDocxRW::Binary_DocumentTableReader::ReadMathOMathPara, &oBinary_DocumentTableReader, NULL);
|
||||
oBinary_DocumentTableReader.ReadMathOMathParaOut(nLength);
|
||||
oTempContentWriter.m_oContent.WriteString(std::wstring(_T("</m:oMathPara>")));
|
||||
}
|
||||
else if(OOX::et_m_oMath == eType)
|
||||
{
|
||||
oTempContentWriter.m_oContent.WriteString(std::wstring(_T("<m:oMath>")));
|
||||
oBinary_DocumentTableReader.Read1(nLength, &BinDocxRW::Binary_DocumentTableReader::ReadMathArg, &oBinary_DocumentTableReader, NULL);
|
||||
oBinary_DocumentTableReader.ReadMathArgOut(nLength);
|
||||
oTempContentWriter.m_oContent.WriteString(std::wstring(_T("</m:oMath>")));
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ HRESULT convert_single(std::wstring srcFileName)
|
||||
|
||||
if (nResult == 0)
|
||||
{
|
||||
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), true))
|
||||
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath, dstPath, true))
|
||||
nResult = -2;
|
||||
}
|
||||
|
||||
|
||||
@ -73,6 +73,7 @@ SOURCES += \
|
||||
../src/odf/office_event_listeners.cpp \
|
||||
../src/odf/office_presentation.cpp \
|
||||
../src/odf/office_scripts.cpp \
|
||||
../src/odf/office_forms.cpp \
|
||||
../src/odf/office_settings.cpp \
|
||||
../src/odf/office_spreadsheet.cpp \
|
||||
../src/odf/office_text.cpp \
|
||||
@ -211,6 +212,7 @@ SOURCES += \
|
||||
../src/odf/datatypes/tablefunction.cpp \
|
||||
../src/odf/datatypes/tableorder.cpp \
|
||||
../src/odf/datatypes/dategroup.cpp \
|
||||
../src/odfcommandtype.cpp \
|
||||
../src/docx/xlsx_conditionalFormatting.cpp \
|
||||
../src/docx/xlsx_dxfs.cpp \
|
||||
../src/docx/docx_content_type.cpp \
|
||||
@ -335,6 +337,7 @@ HEADERS += \
|
||||
../src/odf/office_event_listeners.h \
|
||||
../src/odf/office_presentation.h \
|
||||
../src/odf/office_scripts.h \
|
||||
../src/odf/office_forms.h \
|
||||
../src/odf/office_settings.h \
|
||||
../src/odf/office_spreadsheet.h \
|
||||
../src/odf/office_text.h \
|
||||
@ -372,6 +375,7 @@ HEADERS += \
|
||||
../src/odf/datatypes/mathvariant.h \
|
||||
../src/odf/calcext_elements.h \
|
||||
../src/odf/table_database_ranges.h \
|
||||
../src/odfcommandtype.h \
|
||||
../src/odf/datatypes/anchortype.h \
|
||||
../src/odf/datatypes/backgroundcolor.h \
|
||||
../src/odf/datatypes/bool.h \
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
#include "../src/odf/office_event_listeners.cpp"
|
||||
#include "../src/odf/office_presentation.cpp"
|
||||
#include "../src/odf/office_scripts.cpp"
|
||||
#include "../src/odf/office_forms.cpp"
|
||||
#include "../src/odf/office_settings.cpp"
|
||||
#include "../src/odf/office_spreadsheet.cpp"
|
||||
#include "../src/odf/office_text.cpp"
|
||||
|
||||
@ -127,3 +127,4 @@
|
||||
#include "../src/odf/datatypes/tablefunction.cpp"
|
||||
#include "../src/odf/datatypes/tableorder.cpp"
|
||||
#include "../src/odf/datatypes/dategroup.cpp"
|
||||
#include "../src/odf/datatypes/commandtype.cpp"
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
#include "docx_conversion_context.h"
|
||||
|
||||
#include "../odf/odfcontext.h"
|
||||
#include "../odf/text_content.h"
|
||||
#include "../odf/calcs_styles.h"
|
||||
#include "../odf/style_paragraph_properties.h"
|
||||
#include "../odf/style_text_properties.h"
|
||||
#include "../odf/style_table_properties.h"
|
||||
@ -100,7 +102,7 @@ void text_tracked_context::start_change (std::wstring id)
|
||||
}
|
||||
void text_tracked_context::end_change ()
|
||||
{
|
||||
mapChanges_.insert( std::pair<std::wstring, _state>(current_state_.id, current_state_));
|
||||
mapChanges_.insert( std::make_pair(current_state_.id, current_state_));
|
||||
|
||||
current_state_.clear();
|
||||
}
|
||||
@ -130,7 +132,54 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
|
||||
return current_state_; //empty
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
void text_forms_context::start_element (int type)
|
||||
{
|
||||
current_state_.clear();
|
||||
|
||||
current_state_.type = type;
|
||||
}
|
||||
void text_forms_context::set_id (const std::wstring& id)
|
||||
{
|
||||
current_state_.id = id;
|
||||
}
|
||||
void text_forms_context::set_name (const std::wstring& name)
|
||||
{
|
||||
current_state_.name = name;
|
||||
}
|
||||
void text_forms_context::set_label (const std::wstring& label)
|
||||
{
|
||||
current_state_.label = label;
|
||||
}
|
||||
void text_forms_context::set_uuid (const std::wstring& uuid)
|
||||
{
|
||||
current_state_.uuid = uuid;
|
||||
}
|
||||
void text_forms_context::set_value (const std::wstring &value)
|
||||
{
|
||||
current_state_.value = value;
|
||||
}
|
||||
void text_forms_context::set_element(odf_reader::form_element *elm)
|
||||
{
|
||||
current_state_.element = elm;
|
||||
}
|
||||
void text_forms_context::end_element ()
|
||||
{
|
||||
mapElements_.insert( std::make_pair(current_state_.id, current_state_));
|
||||
|
||||
current_state_.clear();
|
||||
}
|
||||
text_forms_context::_state& text_forms_context::get_state_element (std::wstring id)
|
||||
{
|
||||
std::map<std::wstring, _state>::iterator it = mapElements_.find(id);
|
||||
|
||||
if (it != mapElements_.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
return current_state_; //empty
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
|
||||
next_dump_page_properties_ (false),
|
||||
page_break_ (false),
|
||||
@ -333,17 +382,11 @@ hyperlinks::_ref docx_conversion_context::last_hyperlink()
|
||||
return hyperlinks_.last();
|
||||
}
|
||||
|
||||
|
||||
void docx_conversion_context::dump_hyperlinks(rels & Rels, hyperlinks::_type_place type)
|
||||
{
|
||||
hyperlinks_.dump_rels(Rels, type);
|
||||
}
|
||||
|
||||
void docx_conversion_context::dump_mediaitems(rels & Rels)
|
||||
{
|
||||
mediaitems_.dump_rels(Rels);
|
||||
}
|
||||
|
||||
void docx_conversion_context::dump_headers_footers(rels & Rels) const
|
||||
{
|
||||
headers_footers_.dump_rels(Rels);
|
||||
@ -353,12 +396,6 @@ void docx_conversion_context::dump_notes(rels & Rels) const
|
||||
{
|
||||
notes_context_.dump_rels(Rels);
|
||||
}
|
||||
|
||||
std::wstring docx_conversion_context::add_mediaitem(const std::wstring & uri, RelsType type, bool & isInternal, std::wstring & ref)
|
||||
{
|
||||
return mediaitems_.add_or_find(uri, type, isInternal, ref);
|
||||
}
|
||||
|
||||
void docx_conversion_context::start_document()
|
||||
{
|
||||
streams_man_ = streams_man::create(document_xml_);
|
||||
@ -868,13 +905,13 @@ bool docx_conversion_context::process_page_properties(std::wostream & strm)
|
||||
|
||||
void docx_conversion_context::end_process_style_content(bool in_styles)
|
||||
{
|
||||
docx_serialize_paragraph_style(output_stream(), automatic_parent_style_, in_styles);
|
||||
serialize_paragraph_style(output_stream(), automatic_parent_style_, in_styles);
|
||||
|
||||
if (automatic_parent_style_.empty())
|
||||
styles_context_.docx_serialize_text_style( output_stream(), L"", text_tracked_context_.dumpRPr_);
|
||||
}
|
||||
|
||||
void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles)
|
||||
void docx_conversion_context::serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles)
|
||||
//in_styles = true -> styles.xml
|
||||
//почему то конструкция <pPr><rPr/></pPr><rPr/> "не работает" в части в rPr в ms2010 )
|
||||
{
|
||||
@ -919,7 +956,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
|
||||
}
|
||||
}
|
||||
CP_XML_STREAM() << paragraph_style.str();
|
||||
docx_serialize_list_properties(CP_XML_STREAM());
|
||||
serialize_list_properties(CP_XML_STREAM());
|
||||
|
||||
|
||||
if ((run_style.tellp() > 0 && in_styles == false) || !get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
@ -1125,8 +1162,187 @@ std::wstring docx_conversion_context::find_list_rename(const std::wstring & List
|
||||
void docx_conversion_context::end_list_item()
|
||||
{
|
||||
}
|
||||
int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_attrs *Attr)
|
||||
{
|
||||
if (!Attr) return 0;
|
||||
|
||||
void docx_conversion_context::docx_serialize_list_properties(std::wostream & strm)
|
||||
bool in_drawing = false;
|
||||
|
||||
if (get_drawing_context().get_current_shape() || get_drawing_context().get_current_frame())
|
||||
{
|
||||
in_drawing = true;
|
||||
}
|
||||
|
||||
if (false == Attr->text_style_name_.empty())
|
||||
{
|
||||
if (odf_reader::style_instance * styleInst =
|
||||
root()->odf_context().styleContainer().style_by_name(Attr->text_style_name_, odf_types::style_family::Paragraph, process_headers_footers_)
|
||||
)
|
||||
{
|
||||
process_page_break_after(styleInst);
|
||||
if (styleInst->is_automatic())
|
||||
{
|
||||
if (odf_reader::style_content * styleContent = styleInst->content())
|
||||
{
|
||||
std::wstring id;
|
||||
if (const odf_reader::style_instance * parentStyleContent = styleInst->parent())
|
||||
{
|
||||
id = styles_map_.get( parentStyleContent->name(), parentStyleContent->type() );
|
||||
}
|
||||
|
||||
start_automatic_style(id);
|
||||
|
||||
{//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
|
||||
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
|
||||
|
||||
if (properties.style_writing_mode_)
|
||||
{
|
||||
odf_types::writing_mode::type type = properties.style_writing_mode_->get_type();
|
||||
switch(type)
|
||||
{
|
||||
case odf_types::writing_mode::RlTb:
|
||||
case odf_types::writing_mode::TbRl:
|
||||
case odf_types::writing_mode::Rl:
|
||||
set_rtl(true);
|
||||
break;
|
||||
default:
|
||||
set_rtl(false);
|
||||
}
|
||||
}
|
||||
set_margin_left(properties.fo_margin_left_? 20.0 * properties.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt) : 0);
|
||||
//for calculate tabs
|
||||
}
|
||||
|
||||
styleContent->docx_convert(*this);
|
||||
|
||||
end_automatic_style();
|
||||
|
||||
push_text_properties(styleContent->get_style_text_properties());
|
||||
|
||||
if (!get_section_context().dump_.empty()
|
||||
&& !get_table_context().in_table()
|
||||
&& (get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
output_stream() << L"<w:pPr>";
|
||||
if (is_paragraph_header() )
|
||||
{
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
|
||||
output_stream() << L"</w:pPr>";
|
||||
finish_paragraph();
|
||||
start_paragraph();
|
||||
}
|
||||
else
|
||||
{
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
output_stream() << L"</w:pPr>";
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::wstring id = styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
output_stream() << L"<w:pPr>";
|
||||
//todooo причесать
|
||||
if (!get_section_context().dump_.empty()
|
||||
&& !get_table_context().in_table()
|
||||
&& (get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
if (is_paragraph_header() )
|
||||
{
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
|
||||
output_stream() << L"</w:pPr>";
|
||||
finish_paragraph();
|
||||
start_paragraph();
|
||||
output_stream() << L"<w:pPr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
|
||||
|
||||
if (!get_text_tracked_context().dumpPPr_.empty())
|
||||
{
|
||||
output_stream() << get_text_tracked_context().dumpPPr_;
|
||||
get_text_tracked_context().dumpPPr_.clear();
|
||||
}
|
||||
|
||||
serialize_list_properties(output_stream());
|
||||
|
||||
if ((Attr->outline_level_) && (*Attr->outline_level_ > 0))
|
||||
{
|
||||
output_stream() << L"<w:outlineLvl w:val=\"" << *Attr->outline_level_ - 1 << L"\" />";
|
||||
}
|
||||
|
||||
if (!get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
{
|
||||
output_stream() << L"<w:rPr>";
|
||||
output_stream() << get_text_tracked_context().dumpRPrInsDel_;
|
||||
get_text_tracked_context().dumpRPrInsDel_.clear();
|
||||
output_stream() << L"</w:rPr>";
|
||||
}
|
||||
output_stream() << L"</w:pPr>";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!get_section_context().dump_.empty()
|
||||
&& !get_table_context().in_table()
|
||||
&& (get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
output_stream() << L"<w:pPr>";
|
||||
output_stream() << get_section_context().dump_;
|
||||
get_section_context().dump_.clear();
|
||||
//todooo выяснить реальны ли заголовки без стилей и свойств
|
||||
output_stream() << L"</w:pPr>";
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void docx_conversion_context::process_page_break_after(const odf_reader::style_instance * styleInst)
|
||||
{
|
||||
if (styleInst)
|
||||
{
|
||||
const odf_reader::style_instance * inst = styleInst;
|
||||
while (inst)
|
||||
{
|
||||
if (inst->content() && inst->content()->get_style_paragraph_properties())
|
||||
{
|
||||
_CP_OPT(odf_types::fo_break) fo_break_val = inst->content()->get_style_paragraph_properties()->content().fo_break_after_;
|
||||
if (fo_break_val)
|
||||
{
|
||||
if (fo_break_val->get_type() == odf_types::fo_break::Page)
|
||||
{
|
||||
set_page_break_after(true);
|
||||
break;
|
||||
}
|
||||
else if (fo_break_val->get_type() == odf_types::fo_break::Auto)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
inst = inst->parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
void docx_conversion_context::serialize_list_properties(std::wostream & strm)
|
||||
{
|
||||
if (!list_style_stack_.empty())
|
||||
{
|
||||
@ -1203,7 +1419,7 @@ namespace
|
||||
//слить если есть mediaitems, добавить релсы и обнулить их для основного документа.
|
||||
rels internal_rels;
|
||||
|
||||
Context.dump_mediaitems(internal_rels);
|
||||
Context.get_mediaitems().dump_rels(internal_rels);
|
||||
Context.dump_hyperlinks(internal_rels, hyperlinks::document_place);
|
||||
|
||||
Context.get_headers_footers().add(styleName, dbgStr, type, internal_rels);
|
||||
|
||||
@ -33,20 +33,20 @@
|
||||
|
||||
#include "../odf/datatypes/stylefamily.h"
|
||||
#include "../odf/datatypes/length.h"
|
||||
#include "../odf/datatypes/noteclass.h"
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <list>
|
||||
|
||||
#include "hyperlinks.h"
|
||||
#include "mediaitems.h"
|
||||
#include "headers_footers.h"
|
||||
#include "docx_table_context.h"
|
||||
#include "../odf/datatypes/noteclass.h"
|
||||
|
||||
#include "oox_conversion_context.h"
|
||||
#include "oox_chart_context.h"
|
||||
|
||||
#include "headers_footers.h"
|
||||
#include "hyperlinks.h"
|
||||
#include "mediaitems.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -62,12 +62,15 @@ namespace cpdoccore {
|
||||
class style_text_properties;
|
||||
class draw_frame;
|
||||
class draw_shape;
|
||||
class draw_control;
|
||||
class office_element;
|
||||
class style_columns;
|
||||
class form_element;
|
||||
|
||||
namespace text
|
||||
{
|
||||
class note_citation;
|
||||
class paragraph_attrs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,8 +120,6 @@ private:
|
||||
std::wstring name(const std::wstring & Name, odf_types::style_family::type Type);
|
||||
|
||||
size_t count_;
|
||||
//boost::unordered_map<std::wstring, std::wstring> map_;
|
||||
|
||||
std::multimap<std::wstring, std::wstring> map_;
|
||||
};
|
||||
|
||||
@ -164,7 +165,16 @@ public:
|
||||
current_object_name_ = L"";
|
||||
current_shape_ = drawShape;
|
||||
}
|
||||
void start_group()
|
||||
void start_control(odf_reader::draw_control * drawControl)
|
||||
{
|
||||
current_level_++;
|
||||
objects_count_++;
|
||||
|
||||
current_shape_id_ = objects_count_;
|
||||
current_object_name_ = L"";
|
||||
current_control_ = drawControl;
|
||||
}
|
||||
void start_group()
|
||||
{
|
||||
current_level_++;
|
||||
objects_count_++;
|
||||
@ -228,7 +238,6 @@ public:
|
||||
else
|
||||
throw;
|
||||
}
|
||||
|
||||
std::wstring & get_text_stream_shape()
|
||||
{
|
||||
return shape_text_content_;
|
||||
@ -239,15 +248,22 @@ public:
|
||||
}
|
||||
void clear_stream_frame()
|
||||
{
|
||||
if (frames_.size()>0)
|
||||
frames_.back().text_content=L"";
|
||||
if (!frames_.empty())
|
||||
frames_.back().text_content.clear();
|
||||
}
|
||||
void stop_shape()
|
||||
{
|
||||
current_level_--;
|
||||
current_shape_ = NULL;
|
||||
shape_text_content_=L"";
|
||||
current_shape_id_ =0;
|
||||
shape_text_content_.clear();
|
||||
current_shape_id_ = 0;
|
||||
}
|
||||
void stop_control()
|
||||
{
|
||||
current_level_--;
|
||||
current_control_ = NULL;
|
||||
shape_text_content_.clear();
|
||||
current_shape_id_ = 0;
|
||||
}
|
||||
void stop_group()
|
||||
{
|
||||
@ -257,10 +273,10 @@ public:
|
||||
|
||||
int get_current_frame_id() const
|
||||
{
|
||||
if (frames_.size()>0) return frames_.back().id;
|
||||
if (!frames_.empty()) return frames_.back().id;
|
||||
else return 0;
|
||||
}
|
||||
bool in_group() { return groups_.size() > 0; }
|
||||
bool in_group() { return !groups_.empty(); }
|
||||
int get_current_level() const { return current_level_; }
|
||||
int get_current_shape_id() const { return current_shape_id_; }
|
||||
|
||||
@ -268,7 +284,7 @@ public:
|
||||
|
||||
odf_reader::draw_frame * get_current_frame() const
|
||||
{
|
||||
if (frames_.size()>0) return frames_.back().ptr;
|
||||
if (!frames_.empty()) return frames_.back().ptr;
|
||||
else return NULL;
|
||||
}
|
||||
odf_reader::draw_shape * get_current_shape() const { return current_shape_; }
|
||||
@ -284,9 +300,11 @@ private:
|
||||
std::vector<_group> groups_;
|
||||
std::vector<_frame> frames_;
|
||||
|
||||
odf_reader::draw_shape * current_shape_;
|
||||
odf_reader::draw_shape *current_shape_;
|
||||
size_t current_shape_id_;
|
||||
|
||||
odf_reader::draw_control*current_control_;
|
||||
|
||||
std::wstring zero_string_;
|
||||
|
||||
};
|
||||
@ -544,6 +562,48 @@ private:
|
||||
|
||||
std::map<std::wstring, _state> mapChanges_;
|
||||
};
|
||||
|
||||
class text_forms_context
|
||||
{
|
||||
public:
|
||||
struct _state
|
||||
{
|
||||
std::wstring id;
|
||||
std::wstring name;
|
||||
int type = 0; //enum?
|
||||
std::wstring label;
|
||||
std::wstring uuid;
|
||||
std::wstring value;
|
||||
odf_reader::form_element* element = NULL;
|
||||
|
||||
void clear()
|
||||
{
|
||||
type = 0;
|
||||
id.clear();
|
||||
name.clear();
|
||||
label.clear();
|
||||
value.clear();
|
||||
uuid.clear();
|
||||
element = NULL;
|
||||
}
|
||||
};
|
||||
text_forms_context(){}
|
||||
|
||||
void start_element (int type);
|
||||
void set_id (const std::wstring& id);
|
||||
void set_name (const std::wstring& name);
|
||||
void set_label (const std::wstring& label);
|
||||
void set_uuid (const std::wstring& uuid);
|
||||
void set_value (const std::wstring& value);
|
||||
void set_element(odf_reader::form_element *elm);
|
||||
void end_element ();
|
||||
|
||||
_state& get_state_element (std::wstring id);
|
||||
|
||||
private:
|
||||
_state current_state_;
|
||||
std::map<std::wstring, _state> mapElements_;
|
||||
};
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
class docx_conversion_context : boost::noncopyable
|
||||
{
|
||||
@ -581,6 +641,7 @@ public:
|
||||
void set_paragraph_state (bool val) { in_paragraph_ = val; }
|
||||
bool get_paragraph_keep () { return is_paragraph_keep_;}
|
||||
void set_paragraph_keep (bool val) { is_paragraph_keep_ = val; }
|
||||
|
||||
bool get_delete_text_state () { return is_delete_text_; }
|
||||
void set_delete_text_state (bool Val) { is_delete_text_ = Val; }
|
||||
|
||||
@ -591,9 +652,6 @@ public:
|
||||
hyperlinks::_ref last_hyperlink ();
|
||||
void dump_hyperlinks (rels & Rels, hyperlinks::_type_place type);
|
||||
|
||||
std::wstring add_mediaitem(const std::wstring & uri, RelsType type, bool & isInternal, std::wstring & ref);
|
||||
|
||||
void dump_mediaitems (rels & Rels);
|
||||
void dump_headers_footers (rels & Rels) const;
|
||||
void dump_notes (rels & Rels) const;
|
||||
|
||||
@ -624,6 +682,9 @@ public:
|
||||
void process_comments ();
|
||||
bool process_page_properties(std::wostream & strm);
|
||||
void process_section (std::wostream & strm, odf_reader::style_columns * columns = NULL);
|
||||
|
||||
int process_paragraph_attr (odf_reader::text::paragraph_attrs *attr);
|
||||
void process_page_break_after(const odf_reader::style_instance *styleInst);
|
||||
|
||||
std::vector<odf_reader::_property> & get_settings_properties ();
|
||||
void set_settings_property (const odf_reader::_property & prop);
|
||||
@ -670,13 +731,14 @@ public:
|
||||
void start_list_item (bool restart = false);
|
||||
void end_list_item ();
|
||||
|
||||
void docx_serialize_list_properties(std::wostream & strm);
|
||||
void docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles = false);
|
||||
void serialize_list_properties(std::wostream & strm);
|
||||
void serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles = false);
|
||||
|
||||
std::wstring find_list_rename(const std::wstring & ListStyleName) const;
|
||||
|
||||
styles_map * get_style_map() { return &styles_map_; }
|
||||
|
||||
mediaitems & get_mediaitems() {return mediaitems_;}
|
||||
styles_context & get_styles_context() { return styles_context_; }
|
||||
drawing_context & get_drawing_context() { return drawing_context_; }
|
||||
comments_context & get_comments_context() { return comments_context_; }
|
||||
@ -684,6 +746,7 @@ public:
|
||||
section_context & get_section_context() { return section_context_; }
|
||||
notes_context & get_notes_context() { return notes_context_; }
|
||||
text_tracked_context& get_text_tracked_context(){ return text_tracked_context_; }
|
||||
text_forms_context & get_forms_context() { return text_forms_context_; }
|
||||
|
||||
void docx_convert_delayed ();
|
||||
void add_delayed_element (odf_reader::office_element * Elm);
|
||||
@ -753,6 +816,7 @@ private:
|
||||
header_footer_context header_footer_context_;
|
||||
notes_context notes_context_;
|
||||
text_tracked_context text_tracked_context_;
|
||||
text_forms_context text_forms_context_;
|
||||
|
||||
boost::shared_ptr<streams_man> streams_man_;
|
||||
|
||||
|
||||
@ -607,6 +607,42 @@ void docx_serialize_object(std::wostream & strm, _docx_drawing & val)
|
||||
}
|
||||
}
|
||||
|
||||
void docx_serialize_control(std::wostream & strm, _docx_drawing & val)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"w:pict")
|
||||
{
|
||||
CP_XML_NODE(L"v:shape")
|
||||
{
|
||||
CP_XML_ATTR(L"id", L"control_" + val.objectId);
|
||||
|
||||
std::wstring style_str; // = L"width:730.6pt; height:261.8pt";
|
||||
|
||||
style_str += L"width:" + boost::lexical_cast<std::wstring>(val.cx / 12700.) + L"pt;";
|
||||
style_str += L"height:" + boost::lexical_cast<std::wstring>(val.cy / 12700.) + L"pt;";
|
||||
|
||||
CP_XML_ATTR(L"style", style_str);
|
||||
|
||||
if (val.fill.bitmap)
|
||||
{
|
||||
CP_XML_NODE(L"v:imagedata")
|
||||
{
|
||||
CP_XML_ATTR(L"o:title", val.name);
|
||||
CP_XML_ATTR(L"r:id", val.fill.bitmap->rId);
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"w:control")
|
||||
{
|
||||
CP_XML_ATTR(L"w:name", val.name);
|
||||
CP_XML_ATTR(L"w:shapeid", L"control_" + val.objectId);
|
||||
CP_XML_ATTR(L"r:id", val.objectId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
|
||||
{
|
||||
if (type == typeUnknown) return;
|
||||
@ -619,6 +655,10 @@ void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
|
||||
{
|
||||
docx_serialize_object(strm, *this);
|
||||
}
|
||||
else if (type == typeControl)
|
||||
{
|
||||
docx_serialize_control(strm, *this);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (insideOtherDrawing)
|
||||
|
||||
@ -134,8 +134,9 @@ void word_files::write(const std::wstring & RootPath)
|
||||
|
||||
void word_files::update_rels(docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_mediaitems().dump_rels(rels_files_.get_rel_file()->get_rels());
|
||||
|
||||
Context.dump_hyperlinks (rels_files_.get_rel_file()->get_rels(), hyperlinks::document_place);
|
||||
Context.dump_mediaitems (rels_files_.get_rel_file()->get_rels());
|
||||
Context.dump_headers_footers(rels_files_.get_rel_file()->get_rels());
|
||||
Context.dump_notes (rels_files_.get_rel_file()->get_rels());
|
||||
}
|
||||
|
||||
@ -70,7 +70,14 @@ void oox_chart_context::reset_fill(oox::_oox_fill &f)
|
||||
rels_.push_back(_rel(isInternal, f.bitmap->rId, ref, typeImage));
|
||||
}
|
||||
}
|
||||
|
||||
void oox_chart_context::set_externalData(const std::wstring & href)
|
||||
{
|
||||
bool isInternal = true;
|
||||
std::wstring href_out;
|
||||
|
||||
externalDataId_ = mediaitems_.add_or_find(href, typeMsObject, isInternal, href_out);
|
||||
rels_.push_back(_rel(isInternal, externalDataId_, href_out, typeMsObject));
|
||||
}
|
||||
std::wostream & oox_chart_context::chartData()
|
||||
{
|
||||
return impl_->chartData_;
|
||||
@ -78,7 +85,7 @@ std::wostream & oox_chart_context::chartData()
|
||||
|
||||
void oox_chart_context::dump_rels(rels & Rels)
|
||||
{
|
||||
for (int i = 0; i < rels_.size(); i++)
|
||||
for (size_t i = 0; i < rels_.size(); i++)
|
||||
{
|
||||
_rel & r = rels_[i];
|
||||
|
||||
@ -88,8 +95,7 @@ void oox_chart_context::dump_rels(rels & Rels)
|
||||
r.rid,
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
||||
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
|
||||
(r.is_internal ? L"" : L"External")
|
||||
)
|
||||
(r.is_internal ? L"" : L"External"))
|
||||
);
|
||||
}
|
||||
else if (r.type == typeHyperlink)
|
||||
@ -101,6 +107,15 @@ void oox_chart_context::dump_rels(rels & Rels)
|
||||
L"External")
|
||||
);
|
||||
}
|
||||
else if (r.type == typeMsObject)
|
||||
{
|
||||
Rels.add(relationship(
|
||||
r.rid,
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package",
|
||||
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
|
||||
(r.is_internal ? L"" : L"External"))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,10 +214,21 @@ void oox_chart_context::serialize(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (externalDataId_.empty() == false)
|
||||
{
|
||||
CP_XML_NODE(L"c:externalData")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", externalDataId_);
|
||||
CP_XML_NODE(L"c:autoUpdate")
|
||||
{
|
||||
CP_XML_ATTR(L"val", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oox_chart_context::~oox_chart_context()
|
||||
{
|
||||
}
|
||||
|
||||
@ -82,6 +82,7 @@ public:
|
||||
plot_area_.charts_[i]->is3D_ = val;
|
||||
}
|
||||
}
|
||||
void set_externalData(const std::wstring & href);
|
||||
void add_chart(int type)
|
||||
{
|
||||
plot_area_.add_chart(type);
|
||||
@ -135,6 +136,7 @@ private:
|
||||
cpdoccore::oox::oox_chart_legend legend_;
|
||||
|
||||
std::wstring pivot_source_;
|
||||
std::wstring externalDataId_;
|
||||
|
||||
std::vector<odf_reader::_property> graphic_properties_;
|
||||
_oox_fill fill_;
|
||||
|
||||
@ -70,17 +70,12 @@ void oox_chart_series::setFormula(int ind, std::wstring &value, std::wstring & f
|
||||
|
||||
if (ind == 0)
|
||||
{
|
||||
if (std::wstring::npos != value.find(L"local-table")) return;
|
||||
|
||||
values_[ind].strRef_.formula = converter.convert_chart_distance(value);
|
||||
values_[ind].strRef_.present = true;
|
||||
values_[ind].present = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (std::wstring::npos != value.find(L"local-table") && !bLocalTable_ ) return;
|
||||
//в xlsx низя .... нужно сделать тогда отдельную table.xml
|
||||
|
||||
values_[ind].numRef_.formula = converter.convert_chart_distance(value);
|
||||
values_[ind].numRef_.present = true;
|
||||
values_[ind].numRef_.formatCode = formatCode;
|
||||
|
||||
@ -55,7 +55,8 @@ enum RelsType
|
||||
typeOleObject,
|
||||
typeSlide,
|
||||
typeVideo,
|
||||
typeAudio
|
||||
typeAudio,
|
||||
typeControl
|
||||
};
|
||||
|
||||
struct _rel
|
||||
|
||||
@ -184,7 +184,7 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -226,7 +226,7 @@ void oox_line_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -259,7 +259,7 @@ void oox_area_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -289,7 +289,7 @@ void oox_bubble_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
//CP_XML_NODE(L"c:bubbleScale")
|
||||
@ -326,7 +326,7 @@ void oox_doughnut_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -366,7 +366,7 @@ void oox_pie_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
}
|
||||
@ -398,7 +398,7 @@ void oox_radar_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -436,7 +436,7 @@ void oox_scatter_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ public:
|
||||
is3D_ = false;
|
||||
type_ = 0;
|
||||
dispBlanksAs_ = L"zero";
|
||||
varyColors_ = true;
|
||||
}
|
||||
~oox_chart(){}
|
||||
|
||||
@ -99,6 +100,7 @@ public:
|
||||
|
||||
int type_;
|
||||
bool is3D_;
|
||||
bool varyColors_;
|
||||
std::wstring dispBlanksAs_;
|
||||
std::vector<int> axisId_; // axId (Axis ID) §21.2.2.9
|
||||
std::wstring grouping_; // clustered | percentStacked | stacked | standard
|
||||
|
||||
@ -54,7 +54,7 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
|
||||
odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent);
|
||||
|
||||
if (!strTextContent)return;
|
||||
if (strTextContent.get().length()<1)return;
|
||||
if (strTextContent->empty())return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
@ -65,7 +65,7 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
|
||||
CP_XML_NODE(L"a:lstStyle");
|
||||
if (strTextContent)
|
||||
{
|
||||
CP_XML_STREAM() << strTextContent.get();
|
||||
CP_XML_STREAM() << *strTextContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#include "office_spreadsheet.h"
|
||||
#include "office_presentation.h"
|
||||
#include "office_scripts.h"
|
||||
#include "office_forms.h"
|
||||
#include "office_settings.h"
|
||||
#include "paragraph_elements.h"
|
||||
#include "office_binary_data.h"
|
||||
|
||||
@ -212,7 +212,14 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
oox_convert(chart_context);
|
||||
|
||||
chart_context.set_cache_only(true);
|
||||
if (embeddedData.empty())
|
||||
{
|
||||
chart_context.set_cache_only(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
chart_context.set_externalData(embeddedData);
|
||||
}
|
||||
|
||||
Context.end_chart();
|
||||
}
|
||||
@ -259,7 +266,14 @@ void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
oox_convert(chart_context);
|
||||
|
||||
chart_context.set_cache_only(true);
|
||||
if (embeddedData.empty())
|
||||
{
|
||||
chart_context.set_cache_only(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
chart_context.set_externalData(embeddedData);
|
||||
}
|
||||
Context.end_chart();
|
||||
}
|
||||
else if (object_type_ == 2 && office_text_)
|
||||
@ -382,6 +396,11 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
|
||||
if (!current) continue;
|
||||
|
||||
if (1 == series_.size())
|
||||
{
|
||||
current->varyColors_ = false;
|
||||
}
|
||||
|
||||
current->set_properties(plot_area_.properties_);
|
||||
current->set_additional_properties(chart_graphic_properties_);
|
||||
|
||||
@ -420,7 +439,8 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
formatCode = *strVal;
|
||||
}
|
||||
|
||||
if (domain_cell_range_adress_.empty() == false)
|
||||
if (domain_cell_range_adress_.empty() == false ||
|
||||
last_set_type == chart_scatter)
|
||||
{
|
||||
if (last_set_type == chart_bubble)
|
||||
{ //bubble(x)
|
||||
@ -434,13 +454,19 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
}
|
||||
else
|
||||
{ //x
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (2, domain_cash);
|
||||
if (false == domain_cash.empty())
|
||||
{
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (2, domain_cash);
|
||||
}
|
||||
//y
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (3, cell_cash);
|
||||
if (false == cell_cash.empty())
|
||||
{
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (3, cell_cash);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -476,7 +502,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
is3D = true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < axises_.size(); i++)
|
||||
for (size_t i = 0; i < axises_.size(); i++)
|
||||
{
|
||||
axis & a = axises_[i];
|
||||
|
||||
@ -667,7 +693,7 @@ void process_build_object::visit(office_body& val)
|
||||
}
|
||||
void process_build_object::visit(office_chart& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
ACCEPT_ALL_CONTENT(val.content_);
|
||||
}
|
||||
void process_build_object::visit(office_text& val)
|
||||
{
|
||||
@ -684,7 +710,7 @@ void process_build_object::visit(office_spreadsheet& val)
|
||||
object_odf_context_.object_type_ = 4;
|
||||
object_odf_context_.office_spreadsheet_ = &val; //конвертация будет уровнем выше
|
||||
}
|
||||
void process_build_object::visit(const chart_chart& val)
|
||||
void process_build_object::visit(chart_chart& val)
|
||||
{
|
||||
object_odf_context_.object_type_ = 1;
|
||||
|
||||
@ -704,11 +730,11 @@ void process_build_object::visit(const chart_chart& val)
|
||||
if (val.attlist_.loext_data_pilot_source_)
|
||||
object_odf_context_.set_pivot_source(*val.attlist_.loext_data_pilot_source_);
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
ACCEPT_ALL_CONTENT(val.content_);
|
||||
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_title& val)
|
||||
void process_build_object::visit(chart_title& val)
|
||||
{
|
||||
title t;
|
||||
|
||||
@ -735,7 +761,7 @@ void process_build_object::visit(const chart_title& val)
|
||||
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_subtitle & val)
|
||||
void process_build_object::visit(chart_subtitle & val)
|
||||
{
|
||||
title t;
|
||||
std::wstringstream v;
|
||||
@ -751,7 +777,7 @@ void process_build_object::visit(const chart_subtitle & val)
|
||||
object_odf_context_.sub_title_ = t;
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_footer& val)
|
||||
void process_build_object::visit(chart_footer& val)
|
||||
{
|
||||
object_odf_context_.footer_.bEnabled = true;
|
||||
|
||||
@ -760,7 +786,7 @@ void process_build_object::visit(const chart_footer& val)
|
||||
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.footer_.text_properties_);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_legend& val)
|
||||
void process_build_object::visit(chart_legend& val)
|
||||
{
|
||||
object_odf_context_.legend_.bEnabled = true;
|
||||
object_odf_context_.legend_.position = L"r";
|
||||
@ -791,9 +817,9 @@ void process_build_object::visit(const chart_legend& val)
|
||||
ApplyTextProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.text_properties_);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_plot_area& val)
|
||||
void process_build_object::visit(chart_plot_area& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
ACCEPT_ALL_CONTENT(val.content_);
|
||||
|
||||
object_odf_context_.plot_area_.cell_range_address_ = val.attlist_.table_cell_range_address_.get_value_or(L"");
|
||||
|
||||
@ -803,13 +829,13 @@ void process_build_object::visit(const chart_plot_area& val)
|
||||
}
|
||||
|
||||
|
||||
void process_build_object::visit(const chart_axis& val)
|
||||
void process_build_object::visit(chart_axis& val)
|
||||
{
|
||||
object_odf_context_.start_axis(val.attlist_.chart_dimension_.get_value_or(L""),
|
||||
val.attlist_.chart_name_.get_value_or(L""),
|
||||
val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""));
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
ACCEPT_ALL_CONTENT(val.content_);
|
||||
|
||||
std::wstring style_name = val.attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
|
||||
|
||||
@ -820,7 +846,7 @@ void process_build_object::visit(const chart_axis& val)
|
||||
object_odf_context_.end_axis();
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_series& val)
|
||||
void process_build_object::visit(chart_series& val)
|
||||
{
|
||||
const chart_series_attlist & att = val.attlist_;
|
||||
|
||||
@ -834,7 +860,7 @@ void process_build_object::visit(const chart_series& val)
|
||||
att.common_attlist_.chart_style_name_.get_value_or(L"")
|
||||
);
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
ACCEPT_ALL_CONTENT(val.content_);
|
||||
|
||||
ApplyChartProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().properties_);
|
||||
ApplyGraphicProperties (att.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().graphic_properties_,object_odf_context_.series_.back().fill_);
|
||||
@ -842,14 +868,14 @@ void process_build_object::visit(const chart_series& val)
|
||||
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_domain& val)
|
||||
void process_build_object::visit(chart_domain& val)
|
||||
{
|
||||
if (object_odf_context_.domain_cell_range_adress_.empty())
|
||||
object_odf_context_.domain_cell_range_adress_ = val.table_cell_range_address_.get_value_or(L"");
|
||||
else
|
||||
object_odf_context_.domain_cell_range_adress2_ = val.table_cell_range_address_.get_value_or(L"");
|
||||
}
|
||||
void process_build_object::visit(const chart_grid& val)
|
||||
void process_build_object::visit(chart_grid& val)
|
||||
{
|
||||
object_odf_context_.add_grid(val.attlist_.chart_class_.get_value_or(L""),
|
||||
val.attlist_.common_attlist_.chart_style_name_.get_value_or(L"") );
|
||||
@ -859,7 +885,7 @@ void process_build_object::visit(const chart_grid& val)
|
||||
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), (object_odf_context_.axises_.back()).grids_.back().graphic_properties_, fill);
|
||||
|
||||
}
|
||||
void process_build_object::visit(const chart_wall& val)
|
||||
void process_build_object::visit(chart_wall& val)
|
||||
{
|
||||
object_odf_context_.wall_.bEnabled = true;
|
||||
|
||||
@ -868,7 +894,7 @@ void process_build_object::visit(const chart_wall& val)
|
||||
ApplyTextProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.text_properties_);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_floor& val)
|
||||
void process_build_object::visit(chart_floor& val)
|
||||
{
|
||||
object_odf_context_.floor_.bEnabled = true;
|
||||
|
||||
@ -877,7 +903,7 @@ void process_build_object::visit(const chart_floor& val)
|
||||
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.floor_.text_properties_);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_data_point & val)
|
||||
void process_build_object::visit(chart_data_point & val)
|
||||
{
|
||||
object_odf_context_.add_point( val.attlist_.chart_repeated_.get_value_or(1));
|
||||
|
||||
@ -892,16 +918,16 @@ void process_build_object::visit(const chart_data_point & val)
|
||||
}
|
||||
|
||||
}
|
||||
void process_build_object::visit(const chart_mean_value & val)
|
||||
void process_build_object::visit(chart_mean_value & val)
|
||||
{
|
||||
ApplyChartProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().mean_value_.properties_);
|
||||
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().mean_value_.graphic_properties_, object_odf_context_.series_.back().mean_value_.fill_);
|
||||
}
|
||||
void process_build_object::visit(const chart_error_indicator & val)
|
||||
void process_build_object::visit(chart_error_indicator & val)
|
||||
{
|
||||
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().error_indicator_.graphic_properties_,object_odf_context_.series_.back().error_indicator_.fill_ );
|
||||
}
|
||||
void process_build_object::visit(const chart_regression_curve & val)
|
||||
void process_build_object::visit(chart_regression_curve & val)
|
||||
{
|
||||
oox::_oox_fill fill;
|
||||
ApplyGraphicProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().regression_curve_.line_properties_, fill);
|
||||
@ -913,7 +939,7 @@ void process_build_object::visit(const chart_regression_curve & val)
|
||||
val.chart_equation_->accept(*this);
|
||||
}
|
||||
}
|
||||
void process_build_object::visit(const chart_equation & val)
|
||||
void process_build_object::visit(chart_equation & val)
|
||||
{
|
||||
if (object_odf_context_.series_.back().regression_curve_.bEquation == false)return;
|
||||
|
||||
@ -925,7 +951,7 @@ void process_build_object::visit(const chart_equation & val)
|
||||
ApplyTextProperties (val.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.series_.back().regression_curve_.equation_properties_.text_properties_);
|
||||
|
||||
}
|
||||
void process_build_object::visit(const chart_categories& val)
|
||||
void process_build_object::visit(chart_categories& val)
|
||||
{
|
||||
if (object_odf_context_.in_axis_)
|
||||
{
|
||||
@ -936,49 +962,48 @@ void process_build_object::visit(const chart_categories& val)
|
||||
if (val.table_cell_range_address_)
|
||||
object_odf_context_.add_categories(*val.table_cell_range_address_);
|
||||
}
|
||||
void process_build_object::visit(const table_table& val)
|
||||
void process_build_object::visit(table_table& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_);
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_);
|
||||
object_odf_context_.table_table_ = &val;
|
||||
|
||||
ACCEPT_ALL_CONTENT(val.table_columns_and_groups_.content_);
|
||||
ACCEPT_ALL_CONTENT(val.table_rows_and_groups_.content_);
|
||||
}
|
||||
void process_build_object::visit(const table_table_rows& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
|
||||
}
|
||||
void process_build_object::visit(table_table_rows& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
|
||||
ACCEPT_ALL_CONTENT(val.table_table_row_);
|
||||
}
|
||||
void process_build_object::visit(const table_table_row & val)
|
||||
|
||||
void process_build_object::visit(table_table_row & val)
|
||||
{
|
||||
unsigned int repeated = val.attlist_.table_number_rows_repeated_;
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
ACCEPT_ALL_CONTENT(val.content_);
|
||||
visit_rows(repeated);
|
||||
}
|
||||
void process_build_object::visit(const table_table_column& val)
|
||||
void process_build_object::visit(table_table_column& val)
|
||||
{
|
||||
const unsigned int columnsRepeated = val.table_table_column_attlist_.table_number_columns_repeated_;
|
||||
|
||||
visit_column(columnsRepeated);
|
||||
}
|
||||
void process_build_object::visit(const table_table_row_group& val)
|
||||
void process_build_object::visit(table_table_row_group& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_);
|
||||
ACCEPT_ALL_CONTENT(val.table_rows_and_groups_.content_);
|
||||
}
|
||||
void process_build_object::visit(const table_table_column_group& val)
|
||||
void process_build_object::visit(table_table_column_group& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_);
|
||||
ACCEPT_ALL_CONTENT(val.table_columns_and_groups_.content_);
|
||||
}
|
||||
void process_build_object::visit(table_table_columns& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_table_column_);
|
||||
ACCEPT_ALL_CONTENT(val.table_table_column_);
|
||||
}
|
||||
void process_build_object::visit(const table_columns_no_group& val)
|
||||
void process_build_object::visit(table_columns_no_group& val)
|
||||
{
|
||||
if (val.table_columns_1_.table_table_columns_)
|
||||
val.table_columns_1_.table_table_columns_->accept(*this);
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_columns_1_.table_table_column_);
|
||||
ACCEPT_ALL_CONTENT(val.table_columns_1_.table_table_column_);
|
||||
|
||||
if (val.table_table_header_columns_)
|
||||
val.table_table_header_columns_->accept(*this);
|
||||
@ -986,14 +1011,14 @@ void process_build_object::visit(const table_columns_no_group& val)
|
||||
if (val.table_columns_2_.table_table_columns_)
|
||||
val.table_columns_2_.table_table_columns_->accept(*this);
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_columns_2_.table_table_column_);
|
||||
ACCEPT_ALL_CONTENT(val.table_columns_2_.table_table_column_);
|
||||
}
|
||||
void process_build_object::visit(const table_rows_no_group& val)
|
||||
void process_build_object::visit(table_rows_no_group& val)
|
||||
{
|
||||
if (val.table_rows_1_.table_table_rows_)
|
||||
val.table_rows_1_.table_table_rows_->accept(*this);
|
||||
else
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_rows_1_.table_table_row_);
|
||||
ACCEPT_ALL_CONTENT(val.table_rows_1_.table_table_row_);
|
||||
|
||||
if (val.table_table_header_rows_)
|
||||
val.table_table_header_rows_->accept(*this);
|
||||
@ -1001,9 +1026,9 @@ void process_build_object::visit(const table_rows_no_group& val)
|
||||
if (val.table_rows_2_.table_table_rows_)
|
||||
val.table_rows_2_.table_table_rows_->accept(*this);
|
||||
else
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_rows_2_.table_table_row_);
|
||||
ACCEPT_ALL_CONTENT(val.table_rows_2_.table_table_row_);
|
||||
}
|
||||
void process_build_object::visit(const table_table_cell& val)
|
||||
void process_build_object::visit(table_table_cell& val)
|
||||
{
|
||||
const table_table_cell_attlist & attlist = val.attlist_;
|
||||
|
||||
@ -1046,7 +1071,7 @@ void process_build_object::visit(const table_table_cell& val)
|
||||
object_odf_context_.cash_pivot.insert(std::make_pair(cell_desc, cell_));
|
||||
}
|
||||
}
|
||||
void process_build_object::visit(const table_covered_table_cell& val)
|
||||
void process_build_object::visit(table_covered_table_cell& val)
|
||||
{
|
||||
unsigned int repeated = val.attlist_.table_number_columns_repeated_;
|
||||
|
||||
@ -1055,15 +1080,11 @@ void process_build_object::visit(const table_covered_table_cell& val)
|
||||
}
|
||||
void process_build_object::visit(table_table_header_columns& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_table_column_);
|
||||
}
|
||||
void process_build_object::visit(const table_table_header_rows& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
|
||||
ACCEPT_ALL_CONTENT(val.table_table_column_);
|
||||
}
|
||||
void process_build_object::visit(table_table_header_rows& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_table_row_);
|
||||
ACCEPT_ALL_CONTENT(val.table_table_row_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,6 +120,7 @@ public:
|
||||
office_text_ (NULL),
|
||||
office_math_ (NULL),
|
||||
office_spreadsheet_ (NULL),
|
||||
table_table_ (NULL),
|
||||
baseRef_ (ref),
|
||||
baseFontHeight_ (12)
|
||||
{
|
||||
@ -164,6 +165,7 @@ public:
|
||||
office_text *office_text_;
|
||||
office_math *office_math_;
|
||||
office_spreadsheet *office_spreadsheet_;
|
||||
table_table *table_table_;
|
||||
|
||||
int baseFontHeight_;
|
||||
std::wstring baseRef_;
|
||||
@ -203,6 +205,7 @@ public:
|
||||
std::vector<_cell> cash_values;
|
||||
std::map<std::wstring, _cell>cash_pivot;
|
||||
|
||||
std::wstring embeddedData;
|
||||
//---------------------------------------
|
||||
std::wstring target_table_;
|
||||
std::wstring table_name_;
|
||||
@ -234,48 +237,45 @@ class process_build_object
|
||||
public visitor<office_math>,
|
||||
public visitor<office_spreadsheet>,
|
||||
|
||||
public const_visitor<chart_chart>,
|
||||
public visitor<chart_chart>,
|
||||
|
||||
public const_visitor<chart_title>,
|
||||
public const_visitor<chart_subtitle>,
|
||||
public const_visitor<chart_footer>,
|
||||
public const_visitor<chart_legend>,
|
||||
public visitor<chart_title>,
|
||||
public visitor<chart_subtitle>,
|
||||
public visitor<chart_footer>,
|
||||
public visitor<chart_legend>,
|
||||
|
||||
public const_visitor<chart_plot_area>,
|
||||
public visitor<chart_plot_area>,
|
||||
|
||||
public const_visitor<chart_axis>,
|
||||
public const_visitor<chart_categories>,
|
||||
public const_visitor<chart_grid>,
|
||||
public visitor<chart_axis>,
|
||||
public visitor<chart_categories>,
|
||||
public visitor<chart_grid>,
|
||||
|
||||
public const_visitor<chart_series>,
|
||||
public const_visitor<chart_domain>,
|
||||
public const_visitor<chart_data_point>,
|
||||
public const_visitor<chart_mean_value>,
|
||||
public const_visitor<chart_regression_curve>,
|
||||
public const_visitor<chart_equation>,
|
||||
public const_visitor<chart_error_indicator>,
|
||||
public const_visitor<chart_wall>,
|
||||
public const_visitor<chart_floor>,
|
||||
public visitor<chart_series>,
|
||||
public visitor<chart_domain>,
|
||||
public visitor<chart_data_point>,
|
||||
public visitor<chart_mean_value>,
|
||||
public visitor<chart_regression_curve>,
|
||||
public visitor<chart_equation>,
|
||||
public visitor<chart_error_indicator>,
|
||||
public visitor<chart_wall>,
|
||||
public visitor<chart_floor>,
|
||||
|
||||
public const_visitor<table_table>,
|
||||
public visitor<table_table>,
|
||||
|
||||
public const_visitor<table_table_row_group>,
|
||||
public const_visitor<table_rows_no_group>,
|
||||
public const_visitor<table_table_header_rows>,
|
||||
public const_visitor<table_table_rows>,
|
||||
public const_visitor<table_table_row>,
|
||||
|
||||
public visitor<table_table_rows>,
|
||||
public visitor<table_table_row_group>,
|
||||
public visitor<table_rows_no_group>,
|
||||
public visitor<table_table_header_rows>,
|
||||
public visitor<table_table_rows>,
|
||||
public visitor<table_table_row>,
|
||||
|
||||
public const_visitor<table_table_cell>,
|
||||
public const_visitor<table_covered_table_cell>,
|
||||
public visitor<table_table_cell>,
|
||||
public visitor<table_covered_table_cell>,
|
||||
|
||||
public const_visitor<table_table_column_group>,
|
||||
public visitor<table_table_column_group>,
|
||||
public visitor<table_table_header_columns>,
|
||||
public visitor<table_table_columns>,
|
||||
public const_visitor<table_table_column>,
|
||||
public const_visitor<table_columns_no_group>
|
||||
public visitor<table_table_column>,
|
||||
public visitor<table_columns_no_group>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -303,44 +303,39 @@ public:
|
||||
virtual void visit(office_math & val);
|
||||
virtual void visit(office_spreadsheet & val);
|
||||
|
||||
virtual void visit(const chart_chart & val);
|
||||
virtual void visit(const chart_title & val);
|
||||
virtual void visit(const chart_subtitle & val);
|
||||
virtual void visit(const chart_footer & val);
|
||||
virtual void visit(const chart_legend & val);
|
||||
virtual void visit(const chart_plot_area& val);
|
||||
virtual void visit(const chart_axis & val);
|
||||
virtual void visit(const chart_series & val);
|
||||
virtual void visit(const chart_domain & val);
|
||||
virtual void visit(const chart_data_point & val);
|
||||
virtual void visit(const chart_mean_value & val);
|
||||
virtual void visit(const chart_error_indicator & val);
|
||||
virtual void visit(const chart_regression_curve & val);
|
||||
virtual void visit(const chart_equation & val);
|
||||
virtual void visit(const chart_categories & val);
|
||||
virtual void visit(const chart_grid & val);
|
||||
virtual void visit(const chart_wall & val);
|
||||
virtual void visit(const chart_floor & val);
|
||||
virtual void visit(const table_table & val);
|
||||
virtual void visit(chart_chart & val);
|
||||
virtual void visit(chart_title & val);
|
||||
virtual void visit(chart_subtitle & val);
|
||||
virtual void visit(chart_footer & val);
|
||||
virtual void visit(chart_legend & val);
|
||||
virtual void visit(chart_plot_area& val);
|
||||
virtual void visit(chart_axis & val);
|
||||
virtual void visit(chart_series & val);
|
||||
virtual void visit(chart_domain & val);
|
||||
virtual void visit(chart_data_point & val);
|
||||
virtual void visit(chart_mean_value & val);
|
||||
virtual void visit(chart_error_indicator & val);
|
||||
virtual void visit(chart_regression_curve & val);
|
||||
virtual void visit(chart_equation & val);
|
||||
virtual void visit(chart_categories & val);
|
||||
virtual void visit(chart_grid & val);
|
||||
virtual void visit(chart_wall & val);
|
||||
virtual void visit(chart_floor & val);
|
||||
virtual void visit(table_table & val);
|
||||
|
||||
virtual void visit(const table_table_rows & val);
|
||||
virtual void visit(const table_rows_no_group & val);
|
||||
virtual void visit(const table_table_row_group & val);
|
||||
virtual void visit(const table_table_header_rows& val);
|
||||
virtual void visit(table_table_header_rows & val);
|
||||
virtual void visit(table_table_rows & val);
|
||||
virtual void visit(table_table_row & val);
|
||||
virtual void visit(table_rows_no_group & val);
|
||||
virtual void visit(table_table_row_group & val);
|
||||
virtual void visit(table_table_header_rows & val);
|
||||
|
||||
virtual void visit(table_table_rows & val);
|
||||
virtual void visit(const table_table_row & val);
|
||||
|
||||
virtual void visit(const table_columns_no_group & val);
|
||||
virtual void visit(table_columns_no_group & val);
|
||||
virtual void visit(table_table_header_columns & val);
|
||||
virtual void visit(table_table_columns & val);
|
||||
virtual void visit(const table_table_column_group& val);
|
||||
virtual void visit(const table_table_column & val);
|
||||
|
||||
|
||||
virtual void visit(const table_table_cell& val);
|
||||
virtual void visit(const table_covered_table_cell& val);
|
||||
virtual void visit(table_table_columns & val);
|
||||
virtual void visit(table_table_column_group & val);
|
||||
virtual void visit(table_table_column & val);
|
||||
virtual void visit(table_table_cell & val);
|
||||
virtual void visit(table_covered_table_cell & val);
|
||||
|
||||
private:
|
||||
bool stop_;
|
||||
|
||||
76
ASCOfficeOdfFile/src/odf/datatypes/commandtype.cpp
Normal file
76
ASCOfficeOdfFile/src/odf/datatypes/commandtype.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2018
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "commandtype.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace cpdoccore { namespace odf_types {
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const command_type & _Val)
|
||||
{
|
||||
switch(_Val.get_type())
|
||||
{
|
||||
case command_type::command:
|
||||
_Wostream << L"command";
|
||||
break;
|
||||
case command_type::query:
|
||||
_Wostream << L"query";
|
||||
break;
|
||||
case command_type::table:
|
||||
_Wostream << L"table";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
command_type command_type::parse(const std::wstring & Str)
|
||||
{
|
||||
std::wstring tmp = Str;
|
||||
boost::algorithm::to_lower(tmp);
|
||||
|
||||
if (tmp == L"command")
|
||||
return command_type( command );
|
||||
else if (tmp == L"query")
|
||||
return command_type( query );
|
||||
else if (tmp == L"table")
|
||||
return command_type( table );
|
||||
else
|
||||
{
|
||||
return command_type( command );
|
||||
}
|
||||
}
|
||||
|
||||
} }
|
||||
74
ASCOfficeOdfFile/src/odf/datatypes/commandtype.h
Normal file
74
ASCOfficeOdfFile/src/odf/datatypes/commandtype.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2018
|
||||
*
|
||||
* 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 <iosfwd>
|
||||
#include <string>
|
||||
#include "odfattributes.h"
|
||||
|
||||
|
||||
namespace cpdoccore { namespace odf_types {
|
||||
|
||||
class command_type
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
command,
|
||||
query,
|
||||
table
|
||||
};
|
||||
|
||||
command_type() {}
|
||||
|
||||
command_type(type _Type) : type_(_Type)
|
||||
{}
|
||||
|
||||
type get_type() const
|
||||
{
|
||||
return type_;
|
||||
};
|
||||
|
||||
static command_type parse(const std::wstring & Str);
|
||||
|
||||
private:
|
||||
type type_;
|
||||
|
||||
};
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const command_type & _Val);
|
||||
|
||||
}
|
||||
|
||||
APPLY_PARSE_XML_ATTRIBUTES(odf_types::command_type);
|
||||
|
||||
}
|
||||
@ -412,11 +412,11 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
|
||||
{
|
||||
if (style_background_image * image = dynamic_cast<style_background_image *>(style_image.get()))
|
||||
{
|
||||
if ((image) && (image->common_xlink_attlist_))
|
||||
if ((image) && (image->xlink_attlist_))
|
||||
{
|
||||
fill.type = 2;
|
||||
fill.bitmap = oox::oox_bitmap_fill::create();
|
||||
fill.bitmap->xlink_href_ = image->common_xlink_attlist_->href_.get_value_or(L"");
|
||||
fill.bitmap->xlink_href_ = image->xlink_attlist_->href_.get_value_or(L"");
|
||||
if (image->style_repeat_)
|
||||
{
|
||||
switch(image->style_repeat_->get_type())
|
||||
@ -550,7 +550,7 @@ void draw_a::add_child_element( xml::sax * Reader, const std::wstring & Ns, cons
|
||||
}
|
||||
void draw_a::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"office:name" , office_name_ , std::wstring(L""));
|
||||
CP_APPLY_ATTR(L"office:target-frame-name" , office_target_frame_name_);
|
||||
@ -562,7 +562,7 @@ void draw_a::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
void draw_a::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().start_action(L"");
|
||||
Context.get_drawing_context().set_link(common_xlink_attlist_.href_.get_value_or(L""));
|
||||
Context.get_drawing_context().set_link(xlink_attlist_.href_.get_value_or(L""));
|
||||
Context.get_drawing_context().end_action();
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
@ -573,7 +573,7 @@ void draw_a::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
void draw_a::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().start_action(L"");
|
||||
Context.get_slide_context().set_link(common_xlink_attlist_.href_.get_value_or(L""));
|
||||
Context.get_slide_context().set_link(xlink_attlist_.href_.get_value_or(L""));
|
||||
Context.get_slide_context().end_action();
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
@ -583,7 +583,7 @@ void draw_a::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
void draw_a::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wstring rId = Context.add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""), true);//гиперлинк с объекта, а не с текста ..
|
||||
std::wstring rId = Context.add_hyperlink(xlink_attlist_.href_.get_value_or(L""), true);//гиперлинк с объекта, а не с текста ..
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
|
||||
@ -99,7 +99,7 @@ public:
|
||||
friend class odf_document;
|
||||
|
||||
private:
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
std::wstring office_name_;
|
||||
_CP_OPT(odf_types::target_frame_name) office_target_frame_name_;
|
||||
|
||||
@ -90,7 +90,7 @@ const wchar_t * draw_image::name = L"image";
|
||||
void draw_image::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_image_attlist_.add_attributes(Attributes);
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void draw_image::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -122,7 +122,7 @@ std::wostream & draw_chart::text_to_stream(std::wostream & _Wostream) const
|
||||
void draw_chart::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_chart_attlist_.add_attributes(Attributes);
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void draw_chart::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -266,7 +266,7 @@ const wchar_t * draw_object::name = L"object";
|
||||
void draw_object::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_object_attlist_.add_attributes(Attributes);
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void draw_object::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -278,7 +278,7 @@ void draw_object::add_child_element( xml::sax * Reader, const std::wstring & Ns,
|
||||
}
|
||||
}
|
||||
|
||||
// draw:object
|
||||
// draw:object-ole
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_object_ole::ns = L"draw";
|
||||
const wchar_t * draw_object_ole::name = L"object-ole";
|
||||
@ -287,7 +287,7 @@ void draw_object_ole::add_attributes( const xml::attributes_wc_ptr & Attributes
|
||||
{
|
||||
CP_APPLY_ATTR(L"draw:class-id", draw_class_id_);
|
||||
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void draw_object_ole::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -362,7 +362,7 @@ std::wstring draw_object::office_convert(odf_document_ptr odfDocument, int type)
|
||||
{
|
||||
outputDocx.write(objectOutPath);
|
||||
|
||||
href_result = common_xlink_attlist_.href_.get_value_or(L"Object");
|
||||
href_result = xlink_attlist_.href_.get_value_or(L"Object");
|
||||
int pos = href_result.find(L"./");
|
||||
if (pos >= 0) href_result = href_result.substr(2);
|
||||
|
||||
@ -381,7 +381,7 @@ std::wstring draw_object::office_convert(odf_document_ptr odfDocument, int type)
|
||||
{
|
||||
outputXlsx.write(objectOutPath);
|
||||
|
||||
href_result = common_xlink_attlist_.href_.get_value_or(L"Object");
|
||||
href_result = xlink_attlist_.href_.get_value_or(L"Object");
|
||||
int pos = href_result.find(L"./");
|
||||
if (pos >= 0) href_result = href_result.substr(2);
|
||||
|
||||
@ -393,7 +393,7 @@ std::wstring draw_object::office_convert(odf_document_ptr odfDocument, int type)
|
||||
std::wstring temp_file = folderPath + FILE_SEPARATOR_STR + href_result;
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
oCOfficeUtils.CompressFileOrDirectory(objectOutPath.c_str(), temp_file.c_str(), true);
|
||||
oCOfficeUtils.CompressFileOrDirectory(objectOutPath, temp_file, true);
|
||||
}
|
||||
NSDirectory::DeleteDirectory(objectOutPath);
|
||||
|
||||
@ -423,14 +423,36 @@ void draw_plugin::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"draw:mime-type", draw_mime_type_);
|
||||
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void draw_plugin::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
// draw:control
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_control::ns = L"draw";
|
||||
const wchar_t * draw_control::name = L"control";
|
||||
|
||||
void draw_control::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"xml:id", xml_id_);
|
||||
CP_APPLY_ATTR(L"draw:caption-id", caption_id_);
|
||||
CP_APPLY_ATTR(L"draw:control", control_id_);
|
||||
|
||||
draw_attlists_.shape_with_text_and_styles_.add_attributes(Attributes);
|
||||
draw_attlists_.position_.add_attributes(Attributes);
|
||||
draw_attlists_.rel_size_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void draw_control::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"draw", L"glue-point")
|
||||
{
|
||||
CP_CREATE_ELEMENT(draw_glue_point_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
draw_image_attlist draw_image_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
office_element_ptr office_binary_data_;
|
||||
|
||||
@ -121,7 +121,7 @@ private:
|
||||
|
||||
private:
|
||||
draw_chart_attlist draw_chart_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
//office_element_ptr title_;
|
||||
@ -294,7 +294,7 @@ public:
|
||||
virtual void pptx_convert (oox::pptx_conversion_context & Context);
|
||||
|
||||
draw_object_attlist draw_object_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
odf_document_ptr odf_document_;
|
||||
|
||||
@ -320,7 +320,7 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_class_id_;
|
||||
|
||||
private:
|
||||
@ -331,7 +331,7 @@ private:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole);
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_param : public office_element_impl<draw_param>
|
||||
{
|
||||
public:
|
||||
@ -354,7 +354,7 @@ private:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_param);
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_plugin : public office_element_impl<draw_plugin>
|
||||
{
|
||||
public:
|
||||
@ -368,7 +368,7 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_mime_type_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
@ -377,9 +377,34 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_plugin);
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_control : public office_element_impl<draw_control>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeDrawControl;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
odf_types::union_common_draw_attlists draw_attlists_;
|
||||
_CP_OPT(std::wstring) xml_id_;
|
||||
_CP_OPT(std::wstring) caption_id_;
|
||||
_CP_OPT(std::wstring) control_id_;
|
||||
|
||||
office_element_ptr draw_glue_point_;
|
||||
//<svg:desc>
|
||||
//<svg:title>
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_control);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "office_forms.h"
|
||||
#include "draw_frame.h"
|
||||
|
||||
#include <ostream>
|
||||
@ -39,6 +40,7 @@
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <cpdoccore/odf/odf_document.h>
|
||||
#include <cpdoccore/xml/utils.h>
|
||||
|
||||
#include "serialize_elements.h"
|
||||
|
||||
@ -46,7 +48,10 @@
|
||||
#include "odf_document_impl.h"
|
||||
|
||||
#include "draw_common.h"
|
||||
|
||||
#include "../docx/docx_drawing.h"
|
||||
#include "../docx/xlsx_package.h"
|
||||
|
||||
#include "chart_build_oox.h"
|
||||
|
||||
#include "calcs_styles.h"
|
||||
@ -55,6 +60,7 @@
|
||||
#include "datatypes/borderstyle.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
#include "../../../OfficeUtils/src/OfficeUtils.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
@ -880,7 +886,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.empty()))
|
||||
{
|
||||
std::wstring href = drawing->fill.bitmap->xlink_href_;
|
||||
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@ -1093,10 +1099,10 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (!common_xlink_attlist_.href_)
|
||||
if (!xlink_attlist_.href_)
|
||||
return;
|
||||
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
int pos_replaicement = href.find(L"ObjectReplacements");
|
||||
|
||||
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
|
||||
@ -1155,7 +1161,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing->fill.bitmap = oox::oox_bitmap_fill::create();
|
||||
drawing->fill.type = 2;
|
||||
drawing->fill.bitmap->isInternal = false;
|
||||
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
drawing->fill.bitmap->bStretch = true;
|
||||
|
||||
const std::wstring styleName = frame->common_draw_attlists_.shape_with_text_and_styles_.
|
||||
@ -1457,13 +1463,13 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring tempPath = Context.root()->get_temp_folder();
|
||||
std::wstring odfPath = Context.root()->get_folder();
|
||||
|
||||
if (!odf_document_ && !href.empty())
|
||||
{
|
||||
std::wstring tempPath = Context.root()->get_temp_folder();
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
std::wstring objectPath = odfPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
// normalize path ???? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
@ -1481,6 +1487,30 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
process_build_object process_build_object_(objectBuild, odf_document_->odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
|
||||
if (objectBuild.table_table_)
|
||||
{
|
||||
oox::xlsx_conversion_context xlsx_context(odf_document_.get());
|
||||
cpdoccore::oox::package::xlsx_document outputXlsx;
|
||||
|
||||
xlsx_context.set_output_document (&outputXlsx);
|
||||
|
||||
xlsx_context.start_document();
|
||||
objectBuild.table_table_->xlsx_convert(xlsx_context);
|
||||
xlsx_context.end_document();
|
||||
|
||||
std::wstring href_folder = tempPath + FILE_SEPARATOR_STR + L"temp_xlsx";
|
||||
NSDirectory::CreateDirectory(href_folder);
|
||||
outputXlsx.write(href_folder);
|
||||
|
||||
std::wstring href = L"Microsoft_Excel_Worksheet_" + std::to_wstring(Context.get_mediaitems().count_object + 1) + L".xlsx";
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK == oCOfficeUtils.CompressFileOrDirectory(href_folder, odfPath + FILE_SEPARATOR_STR + href, true))
|
||||
{
|
||||
objectBuild.embeddedData = href;
|
||||
}
|
||||
}
|
||||
|
||||
objectBuild.docx_convert(Context);
|
||||
|
||||
frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
@ -1498,7 +1528,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing->type = oox::typeChart;
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
}
|
||||
else if (objectBuild.object_type_ == 2 ) //embedded text
|
||||
{
|
||||
@ -1556,7 +1586,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
bool isMediaInternal = true;
|
||||
|
||||
href += FILE_SEPARATOR_STR + href_new;
|
||||
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectProgId = L"Excel.Sheet.12";
|
||||
}
|
||||
}
|
||||
@ -1579,7 +1609,7 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
|
||||
use_image_replace = true;
|
||||
|
||||
//------------------------------------------------
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
@ -1594,10 +1624,139 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing->type = oox::typeOleObject;
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
|
||||
drawing->objectProgId = detectObject(objectPath);
|
||||
}
|
||||
void draw_control::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (!control_id_) return;
|
||||
|
||||
oox::text_forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
|
||||
if (state.id.empty()) return;
|
||||
|
||||
//if (state.element)
|
||||
//{
|
||||
// return state.element->docx_convert_sdr(Context, this);
|
||||
//}
|
||||
|
||||
Context.get_drawing_context().start_shape(NULL);
|
||||
Context.get_drawing_context().add_name_object(state.name.empty() ? L"Control" : state.name);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
drawing.type = oox::typeShape;
|
||||
drawing.id = Context.get_drawing_context().get_current_shape_id();
|
||||
drawing.name = Context.get_drawing_context().get_current_object_name();
|
||||
drawing.inGroup = Context.get_drawing_context().in_group();
|
||||
drawing.sub_type = 1;
|
||||
|
||||
std::wstring text;
|
||||
if (!state.label.empty()) text = state.label;
|
||||
else if (!state.value.empty()) text = state.value;
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
if (!text.empty())
|
||||
{
|
||||
oox::StreamsManPtr prev = Context.get_stream_man();
|
||||
|
||||
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_shape());
|
||||
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
|
||||
|
||||
bool pState = Context.get_paragraph_state ();
|
||||
bool runState = Context.get_run_state ();
|
||||
bool keepState = Context.get_paragraph_keep ();
|
||||
|
||||
Context.set_run_state (false);
|
||||
Context.set_paragraph_state (false);
|
||||
|
||||
bool drState = Context.get_drawing_state_content();
|
||||
|
||||
Context.set_drawing_state_content(true);
|
||||
|
||||
Context.start_paragraph(false);
|
||||
|
||||
if (draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
|
||||
{
|
||||
text::paragraph_attrs attrs_;
|
||||
attrs_.text_style_name_ = *draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_;
|
||||
|
||||
int textStyle = Context.process_paragraph_attr(&attrs_);
|
||||
}
|
||||
|
||||
Context.add_new_run(L"");
|
||||
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
|
||||
Context.output_stream() << xml::utils::replace_text_to_xml( text );
|
||||
Context.output_stream() << L"</w:t>";
|
||||
Context.finish_run();
|
||||
Context.finish_paragraph();
|
||||
|
||||
Context.get_drawing_context().get_text_stream_shape() = temp_stream.str();
|
||||
Context.set_stream_man(prev);
|
||||
|
||||
Context.set_run_state (runState);
|
||||
Context.set_paragraph_state (pState);
|
||||
Context.set_drawing_state_content (drState);
|
||||
Context.set_paragraph_keep (keepState);
|
||||
|
||||
const std::wstring & content = Context.get_drawing_context().get_text_stream_shape();
|
||||
|
||||
drawing.additional.push_back(_property(L"text-content",content));
|
||||
Context.get_drawing_context().clear_stream_shape();
|
||||
|
||||
drawing.additional.push_back(_property(L"text-padding-left", 0.));
|
||||
drawing.additional.push_back(_property(L"text-padding-top", 0.));
|
||||
drawing.additional.push_back(_property(L"text-padding-right", 0.));
|
||||
drawing.additional.push_back(_property(L"text-padding-bottom", 0.));
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
/////////
|
||||
common_draw_docx_convert(Context, draw_attlists_, &drawing);
|
||||
/////////
|
||||
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
bool runState = Context.get_run_state();
|
||||
bool paraState = Context.get_paragraph_state();
|
||||
bool keepState = Context.get_paragraph_keep();
|
||||
|
||||
//Context.set_run_state (false);
|
||||
Context.set_paragraph_state (false);
|
||||
|
||||
bool new_run = false;
|
||||
|
||||
if ((paraState == false && Context.get_drawing_context().get_current_level() == 1) || (Context.get_drawing_context().in_group()))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Context.get_drawing_context().in_group() && !runState)
|
||||
{
|
||||
if (!paraState)
|
||||
{
|
||||
Context.start_paragraph();
|
||||
}
|
||||
Context.add_new_run(L"");
|
||||
|
||||
new_run = true;
|
||||
}
|
||||
}
|
||||
|
||||
drawing.serialize(strm/*, Context.get_drawing_state_content()*/);
|
||||
|
||||
if (new_run)
|
||||
{
|
||||
Context.finish_run();
|
||||
if (!paraState)
|
||||
{
|
||||
Context.finish_paragraph();
|
||||
}
|
||||
}
|
||||
|
||||
Context.set_paragraph_state(paraState);
|
||||
|
||||
Context.get_drawing_context().stop_shape();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,11 +39,10 @@
|
||||
#include <boost/regex.h>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
#include <cpdoccore/odf/odf_document.h>
|
||||
|
||||
#include "serialize_elements.h"
|
||||
#include <cpdoccore/odf/odf_document.h>
|
||||
|
||||
#include "style_graphic_properties.h"
|
||||
|
||||
@ -53,9 +52,11 @@
|
||||
#include "odf_document_impl.h"
|
||||
|
||||
#include "calcs_styles.h"
|
||||
#include "../docx/pptx_drawing.h"
|
||||
#include "chart_build_oox.h"
|
||||
|
||||
#include "../docx/pptx_drawing.h"
|
||||
#include "../docx/xlsx_package.h"
|
||||
|
||||
#include "datatypes/length.h"
|
||||
#include "datatypes/borderstyle.h"
|
||||
|
||||
@ -208,7 +209,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
const std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
Context.get_slide_context().set_image(href);
|
||||
////////////////////////////////////в принципе достаточно общая часть ...
|
||||
@ -227,7 +228,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
void draw_chart::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
const std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
Context.get_slide_context().set_chart(href);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
@ -257,13 +258,13 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring tempPath = Context.root()->get_temp_folder();
|
||||
std::wstring odfPath = Context.root()->get_folder();
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
if (!odf_document_ && !href.empty())
|
||||
{
|
||||
std::wstring tempPath = Context.root()->get_temp_folder();
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
std::wstring objectPath = odfPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
// normalize path ???? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
@ -282,11 +283,34 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
process_build_object process_build_object_(objectBuild, odf_document_->odf_context() );
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
|
||||
if (objectBuild.table_table_)
|
||||
{
|
||||
oox::xlsx_conversion_context xlsx_context(odf_document_.get());
|
||||
cpdoccore::oox::package::xlsx_document outputXlsx;
|
||||
|
||||
xlsx_context.set_output_document (&outputXlsx);
|
||||
|
||||
xlsx_context.start_document();
|
||||
objectBuild.table_table_->xlsx_convert(xlsx_context);
|
||||
xlsx_context.end_document();
|
||||
|
||||
std::wstring href_folder = tempPath + FILE_SEPARATOR_STR + L"temp_xlsx";
|
||||
NSDirectory::CreateDirectory(href_folder);
|
||||
outputXlsx.write(href_folder);
|
||||
|
||||
std::wstring href = L"Microsoft_Excel_Worksheet_" + std::to_wstring(Context.get_mediaitems().count_object + 1) + L".xlsx";
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK == oCOfficeUtils.CompressFileOrDirectory(href_folder, odfPath + FILE_SEPARATOR_STR + href, true))
|
||||
{
|
||||
objectBuild.embeddedData = href;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1)//диаграмма
|
||||
{
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"Chart");
|
||||
const std::wstring href_draw = xlink_attlist_.href_.get_value_or(L"Chart");
|
||||
objectBuild.pptx_convert(Context);
|
||||
|
||||
Context.get_slide_context().set_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
@ -355,7 +379,7 @@ void draw_object_ole::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
@ -374,7 +398,7 @@ void draw_plugin::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
if (href.empty() && office_binary_data_)
|
||||
{
|
||||
@ -234,7 +234,7 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
void draw_chart::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
const std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
Context.get_drawing_context().set_chart(href);
|
||||
|
||||
for (size_t i = 0 ; i < content_.size(); i++)
|
||||
@ -264,7 +264,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
if (!odf_document_ && !href.empty())
|
||||
{
|
||||
@ -291,7 +291,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1) //диаграмма
|
||||
{
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"chart");
|
||||
const std::wstring href_draw = xlink_attlist_.href_.get_value_or(L"chart");
|
||||
objectBuild.xlsx_convert(Context);
|
||||
|
||||
Context.get_drawing_context().set_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
@ -352,7 +352,7 @@ void draw_object_ole::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
|
||||
@ -65,6 +65,9 @@ public:
|
||||
|
||||
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1) {}
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
friend class odf_document;
|
||||
//----------------------------------------------------------------------------------------------
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
@ -79,14 +82,11 @@ public:
|
||||
odf_types::union_common_draw_attlists common_draw_attlists_;
|
||||
|
||||
draw_shape_attlist draw_shape_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_id_; //используется для анимашек
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
friend class odf_document;
|
||||
//----------------------------------------------------------------------------------------------
|
||||
bool bad_shape_;
|
||||
bool word_art_;
|
||||
int sub_type_;
|
||||
|
||||
@ -134,7 +134,7 @@ void svg_font_face_name::add_text(const std::wstring & Text)
|
||||
|
||||
void common_svg_font_face_xlink_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
// svg:definition-src
|
||||
|
||||
@ -56,7 +56,7 @@ class common_svg_font_face_xlink_attlist
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
};
|
||||
// svg:font-face-uri
|
||||
class svg_font_face_uri : public office_element_impl<svg_font_face_uri>
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
#include "office_annotation.h"
|
||||
#include "office_settings.h"
|
||||
#include "office_scripts.h"
|
||||
#include "office_forms.h"
|
||||
#include "office_event_listeners.h"
|
||||
|
||||
#include "styles.h"
|
||||
|
||||
@ -67,7 +67,6 @@ std::wstring office_binary_data::write_to(const std::wstring & path)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
NSFile::CBase64Converter base64;
|
||||
int nLength = 0;
|
||||
unsigned char *pData = NULL;
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
|
||||
if ((fill.bitmap) && (fill.bitmap->rId.empty()))
|
||||
{
|
||||
std::wstring href = fill.bitmap->xlink_href_;
|
||||
fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
}
|
||||
int id = Context.get_drawing_context().get_current_shape_id();
|
||||
if (layout_properties->docx_background_serialize(Context.output_stream(), Context, fill, id))
|
||||
|
||||
@ -408,6 +408,36 @@ enum ElementType
|
||||
typeDr3dRotate,
|
||||
typeDr3dSphere,
|
||||
|
||||
typeOfficeForms,
|
||||
typeFormForm,
|
||||
typeFormProperties,
|
||||
typeFormProperty,
|
||||
typeFormListProperty,
|
||||
typeFormListValue,
|
||||
typeFormElement,
|
||||
typeFormButton,
|
||||
typeFormCheckbox,
|
||||
typeFormText,
|
||||
typeFormCombobox,
|
||||
typeFormListbox,
|
||||
typeFormConnectionResource,
|
||||
typeFormDate,
|
||||
typeFormFile,
|
||||
typeFormFixedText,
|
||||
typeFormFormattedText,
|
||||
typeFormFrame,
|
||||
typeFormGenericControl,
|
||||
typeFormGrid,
|
||||
typeFormHidden,
|
||||
typeFormImage,
|
||||
typeFormImageFrame,
|
||||
typeFormNumber,
|
||||
typeFormPassword,
|
||||
typeFormRadio,
|
||||
typeFormTextarea,
|
||||
typeFormTime,
|
||||
typeFormValueRange,
|
||||
|
||||
typeDrawPage,
|
||||
typePresentationFooterDecl,
|
||||
typePresentationDateTimeDecl,
|
||||
|
||||
@ -73,7 +73,7 @@ void office_event_listeners::pptx_convert(oox::pptx_conversion_context & Context
|
||||
|
||||
void presentation_event_listener_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"script:event-name", script_event_name_);
|
||||
CP_APPLY_ATTR(L"presentation:action", presentation_action_);
|
||||
@ -101,8 +101,8 @@ void presentation_event_listener::pptx_convert(oox::pptx_conversion_context & Co
|
||||
{
|
||||
Context.get_slide_context().start_action(attlist_.presentation_action_.get_value_or(L""));
|
||||
|
||||
if (attlist_.common_xlink_attlist_.href_)
|
||||
Context.get_slide_context().set_link(*attlist_.common_xlink_attlist_.href_);
|
||||
if (attlist_.xlink_attlist_.href_)
|
||||
Context.get_slide_context().set_link(*attlist_.xlink_attlist_.href_);
|
||||
|
||||
if (presentation_sound_)
|
||||
{
|
||||
|
||||
@ -72,7 +72,7 @@ class presentation_event_listener_attlist
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
_CP_OPT(std::wstring) script_event_name_;
|
||||
_CP_OPT(std::wstring) presentation_action_;
|
||||
|
||||
307
ASCOfficeOdfFile/src/odf/office_forms.cpp
Normal file
307
ASCOfficeOdfFile/src/odf/office_forms.cpp
Normal file
@ -0,0 +1,307 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2018
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include "office_forms.h"
|
||||
#include "draw_frame.h"
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
|
||||
#include "serialize_elements.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
// office:forms
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * office_forms::ns = L"office";
|
||||
const wchar_t * office_forms::name = L"forms";
|
||||
|
||||
void office_forms::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"form:apply-design-mode", apply_design_mode_);
|
||||
CP_APPLY_ATTR(L"form:automatic-focus", automatic_focus_);
|
||||
}
|
||||
|
||||
void office_forms::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void office_forms::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->docx_convert(Context);
|
||||
}
|
||||
}
|
||||
// form:form
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_form::ns = L"form";
|
||||
const wchar_t * form_form::name = L"form";
|
||||
|
||||
void form_form::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"form:allow-deletes", allow_deletes_);
|
||||
CP_APPLY_ATTR(L"form:allow-inserts", allow_inserts_);
|
||||
CP_APPLY_ATTR(L"form:allow-updates", allow_updates_);
|
||||
CP_APPLY_ATTR(L"form:apply-filter", apply_filter_);
|
||||
CP_APPLY_ATTR(L"form:command", command_);
|
||||
CP_APPLY_ATTR(L"form:command_type", command_type_);
|
||||
CP_APPLY_ATTR(L"form:control-implementation", control_implementation_);
|
||||
CP_APPLY_ATTR(L"form:datasource", datasource_);
|
||||
CP_APPLY_ATTR(L"form:detail-fields", detail_fields_);
|
||||
CP_APPLY_ATTR(L"form:enctype", enctype_);
|
||||
CP_APPLY_ATTR(L"form:escape-processing",escape_processing_);
|
||||
CP_APPLY_ATTR(L"form:filter", filter_);
|
||||
CP_APPLY_ATTR(L"form:ignore-result", ignore_result_);
|
||||
CP_APPLY_ATTR(L"form:master-fields", master_fields_);
|
||||
CP_APPLY_ATTR(L"form:method", method_);
|
||||
CP_APPLY_ATTR(L"form:name", name_);
|
||||
CP_APPLY_ATTR(L"form:navigation-mode", navigation_mode_);
|
||||
CP_APPLY_ATTR(L"form:order", order_);
|
||||
CP_APPLY_ATTR(L"form:tabcycle", tabcycle_);
|
||||
|
||||
CP_APPLY_ATTR(L"office:target-frame", office_target_frame_);
|
||||
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void form_form::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"form", L"properties")
|
||||
{
|
||||
CP_CREATE_ELEMENT(properties_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"office", L"event-listeners")
|
||||
{
|
||||
CP_CREATE_ELEMENT(office_event_listeners_);
|
||||
}
|
||||
else
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void form_form::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->docx_convert(Context);
|
||||
}
|
||||
}
|
||||
// form:properties
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_properties::ns = L"form";
|
||||
const wchar_t * form_properties::name = L"properties";
|
||||
|
||||
void form_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void form_properties::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
//for (size_t i = 0; i < content_.size(); i++)
|
||||
// {
|
||||
// content_[i]->docx_convert(Context);
|
||||
// }
|
||||
}
|
||||
// form:property
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_property::ns = L"form";
|
||||
const wchar_t * form_property::name = L"property";
|
||||
|
||||
void form_property::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"form:property-name", property_name_);
|
||||
value_and_type_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
// form:list-property
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_list_property::ns = L"form";
|
||||
const wchar_t * form_list_property::name = L"list-property";
|
||||
|
||||
void form_list_property::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"form:property-name", property_name_);
|
||||
CP_APPLY_ATTR(L"form:value-type", value_type_);
|
||||
}
|
||||
void form_list_property::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void form_list_property::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->docx_convert(Context);
|
||||
}
|
||||
}
|
||||
// form:list-value
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_list_value::ns = L"form";
|
||||
const wchar_t * form_list_value::name = L"list-value";
|
||||
|
||||
void form_list_value::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
value_and_type_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_element::ns = L"form";
|
||||
const wchar_t * form_element::name = L"element";
|
||||
|
||||
void form_element::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"form:control_implementation", control_implementation_);
|
||||
CP_APPLY_ATTR(L"form:data-field", data_field_);
|
||||
CP_APPLY_ATTR(L"form:linked-cell", linked_cell_);
|
||||
CP_APPLY_ATTR(L"form:disabled", disabled_);
|
||||
CP_APPLY_ATTR(L"form:id", id_);
|
||||
CP_APPLY_ATTR(L"form:label", label_);
|
||||
CP_APPLY_ATTR(L"form:name", name_);
|
||||
CP_APPLY_ATTR(L"form:printable", printable_);
|
||||
CP_APPLY_ATTR(L"form:tab-index", tab_index_);
|
||||
CP_APPLY_ATTR(L"form:tab-stop", tab_stop_);
|
||||
CP_APPLY_ATTR(L"form:title", title_);
|
||||
CP_APPLY_ATTR(L"form:value", value_);
|
||||
CP_APPLY_ATTR(L"form:current-value",current_value_);
|
||||
CP_APPLY_ATTR(L"xml:id", xml_id_);
|
||||
CP_APPLY_ATTR(L"xforms:bind", xforms_bind_);
|
||||
}
|
||||
void form_element::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"form", L"properties")
|
||||
{
|
||||
CP_CREATE_ELEMENT(properties_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"office", L"event-listeners")
|
||||
{
|
||||
CP_CREATE_ELEMENT(office_event_listeners_);
|
||||
}
|
||||
}
|
||||
void form_element::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wstring id = id_ ? *id_ : (xml_id_ ? *xml_id_ : L"");
|
||||
Context.get_forms_context().set_id(id);
|
||||
|
||||
if (name_) Context.get_forms_context().set_name(*name_);
|
||||
if (label_) Context.get_forms_context().set_label(*label_);
|
||||
|
||||
if (current_value_) Context.get_forms_context().set_value(*current_value_);
|
||||
else if (value_) Context.get_forms_context().set_value(*value_);
|
||||
|
||||
if (control_implementation_) Context.get_forms_context().set_uuid(*control_implementation_);
|
||||
|
||||
Context.get_forms_context().end_element();
|
||||
|
||||
}
|
||||
// form:button
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_button::ns = L"form";
|
||||
const wchar_t * form_button::name = L"button";
|
||||
|
||||
void form_button::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_button::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(1);
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
|
||||
// form:text
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_text::ns = L"form";
|
||||
const wchar_t * form_text::name = L"text";
|
||||
|
||||
void form_text::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_text::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(2);
|
||||
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
void form_text::docx_convert_sdr(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
|
||||
}
|
||||
// form:checkbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_checkbox::ns = L"form";
|
||||
const wchar_t * form_checkbox::name = L"checkbox";
|
||||
|
||||
void form_checkbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_checkbox::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(3);
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
// form:combobox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_combobox::ns = L"form";
|
||||
const wchar_t * form_combobox::name = L"combobox";
|
||||
|
||||
void form_combobox::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_combobox::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(4);
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
// form:listbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_listbox::ns = L"form";
|
||||
const wchar_t * form_listbox::name = L"listbox";
|
||||
|
||||
void form_listbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_listbox::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(5);
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
}
|
||||
}
|
||||
397
ASCOfficeOdfFile/src/odf/office_forms.h
Normal file
397
ASCOfficeOdfFile/src/odf/office_forms.h
Normal file
@ -0,0 +1,397 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2018
|
||||
*
|
||||
* 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 <iosfwd>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/xmlelement.h>
|
||||
#include <cpdoccore/xml/nodetype.h>
|
||||
|
||||
#include "office_elements.h"
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include "datatypes/common_attlists.h"
|
||||
#include "datatypes/commandtype.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
class draw_control;
|
||||
|
||||
// office:forms
|
||||
class office_forms : public office_element_impl<office_forms>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeForms;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
|
||||
public:
|
||||
office_element_ptr_array content_;
|
||||
_CP_OPT(odf_types::Bool) apply_design_mode_;
|
||||
_CP_OPT(odf_types::Bool) automatic_focus_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_forms);
|
||||
|
||||
// form:form
|
||||
class form_form : public office_element_impl<form_form>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormForm;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
|
||||
public:
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr office_event_listeners_;
|
||||
office_element_ptr properties_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) allow_deletes_;
|
||||
_CP_OPT(odf_types::Bool) allow_inserts_;
|
||||
_CP_OPT(odf_types::Bool) allow_updates_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) apply_filter_;
|
||||
_CP_OPT(std::wstring) command_;
|
||||
_CP_OPT(odf_types::command_type) command_type_;
|
||||
_CP_OPT(std::wstring) control_implementation_;
|
||||
_CP_OPT(std::wstring) datasource_;
|
||||
_CP_OPT(std::wstring) detail_fields_;
|
||||
_CP_OPT(std::wstring) enctype_;
|
||||
_CP_OPT(odf_types::Bool) escape_processing_;
|
||||
_CP_OPT(std::wstring) filter_;
|
||||
_CP_OPT(odf_types::Bool) ignore_result_;
|
||||
_CP_OPT(std::wstring) master_fields_;
|
||||
_CP_OPT(std::wstring) method_;
|
||||
_CP_OPT(std::wstring) name_;
|
||||
_CP_OPT(std::wstring) navigation_mode_;
|
||||
_CP_OPT(std::wstring) order_;
|
||||
_CP_OPT(std::wstring) tabcycle_;
|
||||
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
_CP_OPT(std::wstring) office_target_frame_;
|
||||
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_form);
|
||||
|
||||
// form:properties
|
||||
class form_properties : public office_element_impl<form_properties>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormProperties;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
|
||||
public:
|
||||
office_element_ptr_array content_; //form property && form list-property
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_properties);
|
||||
|
||||
// form:property
|
||||
class form_property : public office_element_impl<form_property>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormProperty;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) property_name_;
|
||||
odf_types::common_value_and_type_attlist value_and_type_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_property);
|
||||
|
||||
// form:list-property
|
||||
class form_list_property : public office_element_impl<form_list_property>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormListProperty;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) property_name_;
|
||||
_CP_OPT(odf_types::office_value_type) value_type_;
|
||||
|
||||
office_element_ptr_array content_; // form:list-value
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_list_property);
|
||||
|
||||
// form:list-value
|
||||
class form_list_value : public office_element_impl<form_list_value>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormListValue;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
odf_types::common_value_and_type_attlist value_and_type_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_list_value);
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
class form_element : public office_element_impl<form_element>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormElement;
|
||||
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context) {}
|
||||
|
||||
virtual void docx_convert_sdr(oox::docx_conversion_context & Context, draw_control* draw) {}
|
||||
form_element() {}
|
||||
|
||||
//CPDOCCORE_DEFINE_VISITABLE();
|
||||
friend class odf_document;
|
||||
//----------------------------------------------------------------------------------------------
|
||||
office_element_ptr office_event_listeners_;
|
||||
office_element_ptr properties_;
|
||||
|
||||
_CP_OPT(std::wstring) control_implementation_;
|
||||
_CP_OPT(std::wstring) data_field_;
|
||||
_CP_OPT(std::wstring) linked_cell_;//cell ref
|
||||
_CP_OPT(odf_types::Bool) disabled_;
|
||||
_CP_OPT(std::wstring) id_;
|
||||
_CP_OPT(std::wstring) label_;
|
||||
_CP_OPT(std::wstring) name_;
|
||||
_CP_OPT(odf_types::Bool) printable_;
|
||||
_CP_OPT(unsigned int) tab_index_;
|
||||
_CP_OPT(odf_types::Bool) tab_stop_;
|
||||
_CP_OPT(std::wstring) title_;
|
||||
_CP_OPT(std::wstring) value_;
|
||||
_CP_OPT(std::wstring) xml_id_;
|
||||
_CP_OPT(std::wstring) xforms_bind_;
|
||||
_CP_OPT(std::wstring) current_value_;
|
||||
};
|
||||
|
||||
// form:button
|
||||
class form_button : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormButton;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
|
||||
//form:image-align
|
||||
//form:image-position
|
||||
//form:button-type 19.255,
|
||||
//form:default-button 19.265,
|
||||
//form:delayfor-repeat
|
||||
//form:focus-on-click
|
||||
//form:image-data
|
||||
//form:repeat
|
||||
//form:toggle
|
||||
//form:xforms-submission
|
||||
//office:target-frame
|
||||
//xlink:href
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_button);
|
||||
|
||||
// form:text
|
||||
class form_text : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormText;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert (oox::docx_conversion_context & Context) ;
|
||||
virtual void docx_convert_sdr (oox::docx_conversion_context & Context, draw_control* draw);
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
//form:convert-empty-to-null
|
||||
//form:current-value
|
||||
//form:readonly
|
||||
//form:max-length
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_text);
|
||||
|
||||
// form:checkbox
|
||||
class form_checkbox : public form_text
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormCheckbox;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert (oox::docx_conversion_context & Context) ;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
//form:image-align
|
||||
//form:image-position
|
||||
//form:current-state
|
||||
//form:is-tristate
|
||||
//form:visual-effect
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_checkbox);
|
||||
|
||||
// form:combobox
|
||||
class form_combobox : public form_text
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormCombobox;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert (oox::docx_conversion_context & Context) ;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
//form:list-source-type
|
||||
//form:size
|
||||
//form:auto-complete
|
||||
//form:list-source
|
||||
//form:sourcecell-range
|
||||
//form:dropdown
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_combobox);
|
||||
|
||||
// form:listbox
|
||||
class form_listbox : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormListbox;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert (oox::docx_conversion_context & Context) ;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
//form:list-source-type
|
||||
//form:size
|
||||
//form:list-source
|
||||
//form:source-cell-range
|
||||
//form:dropdown
|
||||
//form:bound-column
|
||||
//form:xforms-list-source
|
||||
//form:multiple
|
||||
//form:listlinkage-type
|
||||
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_listbox);
|
||||
|
||||
}
|
||||
}
|
||||
//<form:connection-resource>7.6.2,
|
||||
//<form:date> 13.5.8,
|
||||
//<form:file> 13.5.5,
|
||||
//<form:fixed-text> 13.5.10,
|
||||
//<form:form> 13.3,
|
||||
//<form:formatted-text> 13.5.6,
|
||||
//<form:frame> 13.5.19,
|
||||
//<form:generic-control> 13.5.25,
|
||||
//<form:grid> 13.5.22,
|
||||
//<form:hidden> 13.5.21,
|
||||
//<form:image> 13.5.16,
|
||||
//<form:image-frame> 13.5.20,
|
||||
//<form:number> 13.5.7,
|
||||
//<form:password> 13.5.4,
|
||||
//<form:radio> 13.5.18,
|
||||
//<form:textarea> 13.5.3,
|
||||
//<form:time>
|
||||
//<form:value-range> 13.5.24 and
|
||||
@ -52,7 +52,7 @@ void office_scripts::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
void office_scripts::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"office", L"script")
|
||||
CP_CREATE_ELEMENT(office_script_);
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
else
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ private:
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
private:
|
||||
office_element_ptr_array office_script_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
// office-event-listeners ?
|
||||
|
||||
|
||||
@ -100,7 +100,11 @@ bool is_text_content(const std::wstring & ns, const std::wstring & name)
|
||||
|
||||
void office_text::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"text", L"tracked-changes")
|
||||
if CP_CHECK_NAME(L"office", L"forms")
|
||||
{
|
||||
CP_CREATE_ELEMENT(forms_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"text", L"tracked-changes")
|
||||
{
|
||||
CP_CREATE_ELEMENT(tracked_changes_);
|
||||
}
|
||||
@ -142,7 +146,10 @@ void office_text::docx_convert(oox::docx_conversion_context & Context)
|
||||
if (tracked_changes_)
|
||||
tracked_changes_->docx_convert(Context);
|
||||
|
||||
Context.start_office_text();
|
||||
if (forms_)
|
||||
forms_->docx_convert(Context);
|
||||
|
||||
Context.start_office_text();
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->docx_convert(Context);
|
||||
|
||||
@ -67,6 +67,7 @@ private:
|
||||
office_element_ptr user_fields_;
|
||||
office_element_ptr variables_;
|
||||
office_element_ptr sequences_;
|
||||
office_element_ptr forms_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
@ -518,7 +518,7 @@ std::wostream & a::text_to_stream(std::wostream & _Wostream) const
|
||||
|
||||
void a::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"office:name", office_name_, std::wstring(L""));
|
||||
CP_APPLY_ATTR(L"office:target-frame-name", office_target_frame_name_);
|
||||
@ -548,7 +548,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
|
||||
std::wostream & _Wostream = Context.output_stream();
|
||||
|
||||
std::wstring rId;
|
||||
rId = Context.add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""), false);
|
||||
rId = Context.add_hyperlink(xlink_attlist_.href_.get_value_or(L""), false);
|
||||
|
||||
_Wostream << L"<w:hyperlink r:id=\"" << rId << L"\">";
|
||||
|
||||
@ -609,7 +609,7 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
Context.end_hyperlink(common_xlink_attlist_.href_.get_value_or(L""));
|
||||
Context.end_hyperlink(xlink_attlist_.href_.get_value_or(L""));
|
||||
}
|
||||
void a::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
@ -619,7 +619,7 @@ void a::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
|
||||
std::wstring hId = Context.get_slide_context().add_hyperlink(common_xlink_attlist_.href_.get_value_or(L""));
|
||||
std::wstring hId = Context.get_slide_context().add_hyperlink(xlink_attlist_.href_.get_value_or(L""));
|
||||
Context.get_text_context().end_hyperlink(hId);
|
||||
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
std::wstring office_name_;
|
||||
_CP_OPT(odf_types::target_frame_name) office_target_frame_name_;
|
||||
|
||||
@ -150,7 +150,7 @@ void style_background_image::add_attributes( const xml::attributes_wc_ptr & Attr
|
||||
common_xlink_attlist tmp;
|
||||
if (tmp.add_attributes(Attributes))
|
||||
{
|
||||
common_xlink_attlist_ = _CP_OPT(common_xlink_attlist)(tmp);
|
||||
xlink_attlist_ = _CP_OPT(common_xlink_attlist)(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -164,7 +164,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
_CP_OPT(odf_types::common_xlink_attlist) common_xlink_attlist_;
|
||||
_CP_OPT(odf_types::common_xlink_attlist) xlink_attlist_;
|
||||
|
||||
};
|
||||
|
||||
@ -191,7 +191,7 @@ public:
|
||||
_CP_OPT(std::wstring) filter_name_;
|
||||
_CP_OPT(odf_types::percent) draw_opacity_;
|
||||
|
||||
_CP_OPT(odf_types::common_xlink_attlist) common_xlink_attlist_;
|
||||
_CP_OPT(odf_types::common_xlink_attlist) xlink_attlist_;
|
||||
office_element_ptr office_binary_data_;
|
||||
|
||||
};
|
||||
|
||||
@ -90,7 +90,7 @@ const wchar_t * presentation_sound::name = L"sound";
|
||||
|
||||
void presentation_sound::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void presentation_sound::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -100,7 +100,7 @@ void presentation_sound::add_child_element( xml::sax * Reader, const std::wstrin
|
||||
|
||||
void presentation_sound::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().set_link(common_xlink_attlist_.href_.get_value_or(L""), oox::typeAudio);
|
||||
Context.get_slide_context().set_link(xlink_attlist_.href_.get_value_or(L""), oox::typeAudio);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * style_drawing_page_properties::ns = L"style";
|
||||
|
||||
@ -87,7 +87,7 @@ public:
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
@ -117,7 +117,7 @@ void text_list_level_style_bullet_attr::add_attributes( const xml::attributes_wc
|
||||
|
||||
void text_list_level_style_image_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -256,7 +256,7 @@ public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
private:
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
friend class text_list_level_style_image;
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ void table_table_source_attlist::add_attributes( const xml::attributes_wc_ptr &
|
||||
|
||||
void table_linked_source_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"table:filter-name", table_filter_name_);
|
||||
CP_APPLY_ATTR(L"table:filter-options", table_filter_options_);
|
||||
|
||||
@ -130,7 +130,7 @@ class table_linked_source_attlist
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
_CP_OPT(std::wstring) table_filter_name_;
|
||||
_CP_OPT(std::wstring) table_filter_options_;
|
||||
|
||||
@ -328,7 +328,7 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
table_table_source* table_source = dynamic_cast<table_table_source*>( table_table_source_.get() );
|
||||
if ( table_source)
|
||||
{
|
||||
if (table_source->table_linked_source_attlist_.common_xlink_attlist_.href_)return;
|
||||
if (table_source->table_linked_source_attlist_.xlink_attlist_.href_)return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,33 +62,7 @@ const wchar_t * h::name = L"h";
|
||||
|
||||
namespace {
|
||||
|
||||
void process_page_break_after(const style_instance * styleInst, oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (styleInst)
|
||||
{
|
||||
const style_instance * inst = styleInst;
|
||||
while (inst)
|
||||
{
|
||||
if (inst->content() && inst->content()->get_style_paragraph_properties())
|
||||
{
|
||||
_CP_OPT(fo_break) fo_break_val = inst->content()->get_style_paragraph_properties()->content().fo_break_after_;
|
||||
if (fo_break_val)
|
||||
{
|
||||
if (fo_break_val->get_type() == fo_break::Page)
|
||||
{
|
||||
Context.set_page_break_after(true);
|
||||
break;
|
||||
}
|
||||
else if (fo_break_val->get_type() == fo_break::Auto)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
inst = inst->parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
typedef std::map<std::wstring, oox::text_tracked_context::_state>::iterator map_changes_iterator;
|
||||
void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (Attr.text_style_name_.empty())return;
|
||||
@ -131,158 +105,157 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con
|
||||
}
|
||||
return;
|
||||
}
|
||||
typedef std::map<std::wstring, oox::text_tracked_context::_state>::iterator map_changes_iterator;
|
||||
|
||||
int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
|
||||
{
|
||||
bool in_drawing = false;
|
||||
|
||||
if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
|
||||
{
|
||||
in_drawing = true;
|
||||
}
|
||||
|
||||
if (!Attr.text_style_name_.empty())
|
||||
{
|
||||
if (style_instance * styleInst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_, style_family::Paragraph, Context.process_headers_footers_)
|
||||
)
|
||||
{
|
||||
process_page_break_after(styleInst, Context);
|
||||
if (styleInst->is_automatic())
|
||||
{
|
||||
if (style_content * styleContent = styleInst->content())
|
||||
{
|
||||
std::wstring id;
|
||||
if (const style_instance * parentStyleContent = styleInst->parent())
|
||||
{
|
||||
id = Context.styles_map_.get( parentStyleContent->name(), parentStyleContent->type() );
|
||||
}
|
||||
|
||||
Context.start_automatic_style(id);
|
||||
|
||||
{//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
|
||||
paragraph_format_properties properties = calc_paragraph_properties_content(styleInst);
|
||||
|
||||
if (properties.style_writing_mode_)
|
||||
{
|
||||
writing_mode::type type = properties.style_writing_mode_->get_type();
|
||||
switch(type)
|
||||
{
|
||||
case writing_mode::RlTb:
|
||||
case writing_mode::TbRl:
|
||||
case writing_mode::Rl:
|
||||
Context.set_rtl(true);
|
||||
break;
|
||||
default:
|
||||
Context.set_rtl(false);
|
||||
}
|
||||
}
|
||||
Context.set_margin_left(properties.fo_margin_left_? 20.0 * properties.fo_margin_left_->get_length().get_value_unit(length::pt) : 0);
|
||||
//for calculate tabs
|
||||
}
|
||||
|
||||
styleContent->docx_convert(Context);
|
||||
|
||||
Context.end_automatic_style();
|
||||
|
||||
Context.push_text_properties(styleContent->get_style_text_properties());
|
||||
|
||||
if (!Context.get_section_context().dump_.empty()
|
||||
&& !Context.get_table_context().in_table()
|
||||
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
Context.output_stream() << L"<w:pPr>";
|
||||
if (Context.is_paragraph_header() )
|
||||
{
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
Context.get_section_context().dump_.clear();
|
||||
|
||||
Context.output_stream() << L"</w:pPr>";
|
||||
Context.finish_paragraph();
|
||||
Context.start_paragraph();
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
Context.get_section_context().dump_.clear();
|
||||
Context.output_stream() << L"</w:pPr>";
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::wstring id = Context.styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
Context.output_stream() << L"<w:pPr>";
|
||||
//todooo причесать
|
||||
if (!Context.get_section_context().dump_.empty()
|
||||
&& !Context.get_table_context().in_table()
|
||||
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
if (Context.is_paragraph_header() )
|
||||
{
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
Context.get_section_context().dump_.clear();
|
||||
|
||||
Context.output_stream() << L"</w:pPr>";
|
||||
Context.finish_paragraph();
|
||||
Context.start_paragraph();
|
||||
Context.output_stream() << L"<w:pPr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
Context.get_section_context().dump_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Context.output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
|
||||
|
||||
if (!Context.get_text_tracked_context().dumpPPr_.empty())
|
||||
{
|
||||
Context.output_stream() << Context.get_text_tracked_context().dumpPPr_;
|
||||
Context.get_text_tracked_context().dumpPPr_.clear();
|
||||
}
|
||||
|
||||
Context.docx_serialize_list_properties(Context.output_stream());
|
||||
|
||||
if ((Attr.outline_level_) && (*Attr.outline_level_ > 0))
|
||||
{
|
||||
Context.output_stream() << L"<w:outlineLvl w:val=\"" << *Attr.outline_level_ - 1 << L"\" />";
|
||||
}
|
||||
|
||||
if (!Context.get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
{
|
||||
Context.output_stream() << L"<w:rPr>";
|
||||
Context.output_stream() << Context.get_text_tracked_context().dumpRPrInsDel_;
|
||||
Context.get_text_tracked_context().dumpRPrInsDel_.clear();
|
||||
Context.output_stream() << L"</w:rPr>";
|
||||
}
|
||||
Context.output_stream() << L"</w:pPr>";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Context.get_section_context().dump_.empty()
|
||||
&& !Context.get_table_context().in_table()
|
||||
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
&& !in_drawing)
|
||||
{
|
||||
Context.output_stream() << L"<w:pPr>";
|
||||
Context.output_stream() << Context.get_section_context().dump_;
|
||||
Context.get_section_context().dump_.clear();
|
||||
//todooo выяснить реальны ли заголовки без стилей и свойств
|
||||
Context.output_stream() << L"</w:pPr>";
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
|
||||
//{
|
||||
// bool in_drawing = false;
|
||||
//
|
||||
// if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
|
||||
// {
|
||||
// in_drawing = true;
|
||||
// }
|
||||
//
|
||||
// if (!Attr.text_style_name_.empty())
|
||||
// {
|
||||
// if (style_instance * styleInst =
|
||||
// Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_, style_family::Paragraph, Context.process_headers_footers_)
|
||||
// )
|
||||
// {
|
||||
// process_page_break_after(styleInst, Context);
|
||||
// if (styleInst->is_automatic())
|
||||
// {
|
||||
// if (style_content * styleContent = styleInst->content())
|
||||
// {
|
||||
// std::wstring id;
|
||||
// if (const style_instance * parentStyleContent = styleInst->parent())
|
||||
// {
|
||||
// id = Context.styles_map_.get( parentStyleContent->name(), parentStyleContent->type() );
|
||||
// }
|
||||
//
|
||||
// Context.start_automatic_style(id);
|
||||
//
|
||||
// {//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
|
||||
// paragraph_format_properties properties = calc_paragraph_properties_content(styleInst);
|
||||
//
|
||||
// if (properties.style_writing_mode_)
|
||||
// {
|
||||
// writing_mode::type type = properties.style_writing_mode_->get_type();
|
||||
// switch(type)
|
||||
// {
|
||||
// case writing_mode::RlTb:
|
||||
// case writing_mode::TbRl:
|
||||
// case writing_mode::Rl:
|
||||
// Context.set_rtl(true);
|
||||
// break;
|
||||
// default:
|
||||
// Context.set_rtl(false);
|
||||
// }
|
||||
// }
|
||||
// Context.set_margin_left(properties.fo_margin_left_? 20.0 * properties.fo_margin_left_->get_length().get_value_unit(length::pt) : 0);
|
||||
// //for calculate tabs
|
||||
// }
|
||||
//
|
||||
// styleContent->docx_convert(Context);
|
||||
//
|
||||
// Context.end_automatic_style();
|
||||
//
|
||||
// Context.push_text_properties(styleContent->get_style_text_properties());
|
||||
//
|
||||
// if (!Context.get_section_context().dump_.empty()
|
||||
// && !Context.get_table_context().in_table()
|
||||
// && (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
// && !in_drawing)
|
||||
// {
|
||||
// Context.output_stream() << L"<w:pPr>";
|
||||
// if (Context.is_paragraph_header() )
|
||||
// {
|
||||
// Context.output_stream() << Context.get_section_context().dump_;
|
||||
// Context.get_section_context().dump_.clear();
|
||||
//
|
||||
// Context.output_stream() << L"</w:pPr>";
|
||||
// Context.finish_paragraph();
|
||||
// Context.start_paragraph();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Context.output_stream() << Context.get_section_context().dump_;
|
||||
// Context.get_section_context().dump_.clear();
|
||||
// Context.output_stream() << L"</w:pPr>";
|
||||
// }
|
||||
// }
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// const std::wstring id = Context.styles_map_.get( styleInst->name(), styleInst->type() );
|
||||
// Context.output_stream() << L"<w:pPr>";
|
||||
////todooo причесать
|
||||
// if (!Context.get_section_context().dump_.empty()
|
||||
// && !Context.get_table_context().in_table()
|
||||
// && (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
// && !in_drawing)
|
||||
// {
|
||||
// if (Context.is_paragraph_header() )
|
||||
// {
|
||||
// Context.output_stream() << Context.get_section_context().dump_;
|
||||
// Context.get_section_context().dump_.clear();
|
||||
//
|
||||
// Context.output_stream() << L"</w:pPr>";
|
||||
// Context.finish_paragraph();
|
||||
// Context.start_paragraph();
|
||||
// Context.output_stream() << L"<w:pPr>";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Context.output_stream() << Context.get_section_context().dump_;
|
||||
// Context.get_section_context().dump_.clear();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Context.output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
|
||||
//
|
||||
// if (!Context.get_text_tracked_context().dumpPPr_.empty())
|
||||
// {
|
||||
// Context.output_stream() << Context.get_text_tracked_context().dumpPPr_;
|
||||
// Context.get_text_tracked_context().dumpPPr_.clear();
|
||||
// }
|
||||
//
|
||||
// Context.docx_serialize_list_properties(Context.output_stream());
|
||||
//
|
||||
// if ((Attr.outline_level_) && (*Attr.outline_level_ > 0))
|
||||
// {
|
||||
// Context.output_stream() << L"<w:outlineLvl w:val=\"" << *Attr.outline_level_ - 1 << L"\" />";
|
||||
// }
|
||||
//
|
||||
// if (!Context.get_text_tracked_context().dumpRPrInsDel_.empty())
|
||||
// {
|
||||
// Context.output_stream() << L"<w:rPr>";
|
||||
// Context.output_stream() << Context.get_text_tracked_context().dumpRPrInsDel_;
|
||||
// Context.get_text_tracked_context().dumpRPrInsDel_.clear();
|
||||
// Context.output_stream() << L"</w:rPr>";
|
||||
// }
|
||||
// Context.output_stream() << L"</w:pPr>";
|
||||
// return 2;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (!Context.get_section_context().dump_.empty()
|
||||
// && !Context.get_table_context().in_table()
|
||||
// && (Context.get_process_note() == oox::docx_conversion_context::noNote)
|
||||
// && !in_drawing)
|
||||
// {
|
||||
// Context.output_stream() << L"<w:pPr>";
|
||||
// Context.output_stream() << Context.get_section_context().dump_;
|
||||
// Context.get_section_context().dump_.clear();
|
||||
// //todooo выяснить реальны ли заголовки без стилей и свойств
|
||||
// Context.output_stream() << L"</w:pPr>";
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
}
|
||||
|
||||
std::wostream & paragraph::text_to_stream(std::wostream & _Wostream) const
|
||||
@ -355,7 +328,7 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
|
||||
|
||||
str = store_str.substr(0,Context.get_drop_cap_context().Length);
|
||||
|
||||
int textStyle = process_paragraph_attr(attrs_, Context);
|
||||
int textStyle = Context.process_paragraph_attr(&attrs_);
|
||||
first_text_paragraph->docx_convert(Context);
|
||||
|
||||
size_t str_start = Context.get_drop_cap_context().Length;
|
||||
@ -509,7 +482,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
}
|
||||
|
||||
int textStyle = process_paragraph_attr(attrs_, Context);
|
||||
int textStyle = Context.process_paragraph_attr(&attrs_);
|
||||
|
||||
Context.add_note_reference();
|
||||
|
||||
@ -863,7 +836,7 @@ void text_section::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
void text_section_source_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
common_xlink_attlist_.add_attributes(Attributes);
|
||||
xlink_attlist_.add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"text:section-name", text_section_name_);
|
||||
CP_APPLY_ATTR(L"text:filter-name", text_filter_name_);
|
||||
|
||||
@ -271,7 +271,7 @@ public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
private:
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
|
||||
_CP_OPT(std::wstring) text_section_name_;
|
||||
_CP_OPT(std::wstring) text_filter_name_;
|
||||
|
||||
@ -353,6 +353,10 @@
|
||||
RelativePath="..\src\odf\datatypes\calcext_type.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\calcext_type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\chartdatalabelnumber.cpp"
|
||||
>
|
||||
@ -441,6 +445,14 @@
|
||||
RelativePath="..\src\odf\datatypes\color.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\commandtype.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\commandtype.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\common_attlists.cpp"
|
||||
>
|
||||
|
||||
@ -1583,6 +1583,14 @@
|
||||
RelativePath="..\src\odf\office_event_listeners.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\office_forms.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\office_forms.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\office_presentation.cpp"
|
||||
>
|
||||
|
||||
@ -1055,7 +1055,10 @@ bool odf_drawing_context::isLineShape()
|
||||
case 48: //SimpleTypes::shapetypeCurvedConnector3:
|
||||
case 49: //SimpleTypes::shapetypeCurvedConnector4:
|
||||
case 50: //SimpleTypes::shapetypeCurvedConnector5:
|
||||
return true;
|
||||
return true;
|
||||
case 1000:
|
||||
if (impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_.get_value_or(draw_fill(draw_fill::solid)).get_type() == draw_fill::none)
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -901,6 +901,25 @@ void OoxConverter::convert(PPTX::Logic::Path2D *oox_geom_path)
|
||||
|
||||
odf_context()->drawing_context()->set_viewBox(oox_geom_path->w.get_value_or(0), oox_geom_path->h.get_value_or(0));
|
||||
|
||||
if (oox_geom_path->fill.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->start_area_properties();
|
||||
switch(oox_geom_path->fill->GetBYTECode())
|
||||
{
|
||||
case 0://darken
|
||||
case 1://darkenLess
|
||||
case 2://lighten
|
||||
case 3://lightenLess
|
||||
break;
|
||||
case 4:
|
||||
odf_context()->drawing_context()->set_no_fill();
|
||||
break;
|
||||
case 5:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
odf_context()->drawing_context()->end_area_properties();
|
||||
}
|
||||
for (size_t i = 0 ; i < oox_geom_path->Paths.size(); i++)
|
||||
{
|
||||
if (oox_geom_path->Paths[i].Path2D.is<PPTX::Logic::PathBase>())
|
||||
|
||||
@ -25,6 +25,8 @@ include(../OfficeUtils/OfficeUtils.pri)
|
||||
CONFIG += core_static_link_xml_full
|
||||
include(../DesktopEditor/xml/build/qt/libxml2.pri)
|
||||
|
||||
include(../Common/3dParty/curl/curl.pri)
|
||||
|
||||
# DOWNLOADER
|
||||
HEADERS += \
|
||||
./FileDownloader/FileDownloader.h \
|
||||
@ -44,8 +46,6 @@ core_windows {
|
||||
core_linux {
|
||||
SOURCES += \
|
||||
./FileDownloader/FileDownloader_curl.cpp
|
||||
|
||||
LIBS += -lcurl
|
||||
}
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += \
|
||||
|
||||
@ -464,7 +464,7 @@ namespace NSCommon
|
||||
NSFonts::IFontFile* pFile = pManager->GetFile();
|
||||
|
||||
if (pFile)
|
||||
bIsSymbol = pFile->IsSymbolic(true);
|
||||
bIsSymbol = pFile->IsSymbolic(false);
|
||||
|
||||
std::wstring sFontName = pPair->second.m_sName;
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;AGG_BMP_ALPHA_BLEND;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
StructMemberAlignment="0"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
PrecompiledHeaderFile=""
|
||||
|
||||
@ -501,7 +501,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;JAS_WIN_MSVC_BUILD;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
PrecompiledHeaderFile=""
|
||||
AssemblerListingLocation="$(ConfigurationName)\"
|
||||
|
||||
@ -759,7 +759,7 @@ namespace NSDoctRenderer
|
||||
|
||||
if (!bIsEqual || bIsCheckSystemFonts)
|
||||
{
|
||||
NSFonts::IApplicationFonts* pApplicationF;
|
||||
NSFonts::IApplicationFonts* pApplicationF = NSFonts::NSApplication::Create();
|
||||
std::vector<std::wstring> strFontsW_Cur = pApplicationF->GetSetupFontFiles();
|
||||
|
||||
if (strFonts.size() != strFontsW_Cur.size())
|
||||
|
||||
@ -19,7 +19,6 @@ include(../../Common/base.pri)
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter -lkernel -lgraphics
|
||||
|
||||
include(../../Common/3dParty/v8/v8.pri)
|
||||
include(../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
SOURCES += \
|
||||
memorystream.cpp \
|
||||
@ -41,21 +40,3 @@ HEADERS += doctrenderer.h \
|
||||
# downloader
|
||||
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
|
||||
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
|
||||
|
||||
HEADERS += ../../Common/FileDownloader/FileDownloader.h
|
||||
core_windows {
|
||||
SOURCES += \
|
||||
../../Common/FileDownloader/FileDownloader_win.cpp
|
||||
|
||||
LIBS += -lurlmon
|
||||
}
|
||||
core_linux {
|
||||
SOURCES += \
|
||||
../../Common/FileDownloader/FileDownloader_curl.cpp
|
||||
}
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += \
|
||||
../../Common/FileDownloader/FileDownloader_mac.mm
|
||||
|
||||
LIBS += -framework AppKit
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ namespace NSCommon
|
||||
|
||||
if (pManager->GetFile())
|
||||
{
|
||||
bIsSymbol = pManager->GetFile()->IsSymbolic(true);
|
||||
bIsSymbol = pManager->GetFile()->IsSymbolic(false);
|
||||
}
|
||||
|
||||
if (bIsSymbol)
|
||||
|
||||
@ -198,7 +198,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
PrecompiledHeaderFile=""
|
||||
AssemblerListingLocation="$(ConfigurationName)\"
|
||||
|
||||
@ -501,7 +501,7 @@
|
||||
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
DisableLanguageExtensions="true"
|
||||
PrecompiledHeaderFile=""
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;$(NOINHERIT)"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
StructMemberAlignment="0"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
DisableLanguageExtensions="false"
|
||||
|
||||
@ -111,6 +111,7 @@ SOURCES += \
|
||||
./../GraphicsPath.cpp \
|
||||
./../../raster/BgraFrame.cpp \
|
||||
./../../raster/ImageFileFormatChecker.cpp \
|
||||
./../../raster/Metafile/MetaFile.cpp \
|
||||
\
|
||||
./../ArrowHead.cpp \
|
||||
./../Brush.cpp \
|
||||
|
||||
@ -495,7 +495,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;$(NOINHERIT)"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
EnableEnhancedInstructionSet="0"
|
||||
PrecompiledHeaderFile=""
|
||||
AssemblerListingLocation="$(ConfigurationName)\"
|
||||
|
||||
3
Makefile
3
Makefile
@ -75,7 +75,7 @@ LICENSEMANAGER := $(LIBDIR)/$(LIB_PREFIX)LicenceManager$(LIB_EXT)
|
||||
OOXMLSIGNATURE := $(LIBDIR)/$(LIB_PREFIX)ooxmlsignature$(LIB_EXT)
|
||||
HUNSPELL := $(LIBDIR)/$(LIB_PREFIX)hunspell$(SHARED_EXT)
|
||||
KERNEL := $(LIBDIR)/$(LIB_PREFIX)kernel$(SHARED_EXT)
|
||||
CRYPTOPP := $(LIBDIR)/$(LIB_PREFIX)cryptopp$(LIB_EXT)
|
||||
CRYPTOPP := $(LIBDIR)/$(LIB_PREFIX)CryptoPPLib$(LIB_EXT)
|
||||
|
||||
TARGETS += $(ALLFONTSGEN)
|
||||
TARGETS += $(X2T)
|
||||
@ -211,6 +211,7 @@ PDFREADER_DEP += $(CRYPTOPP)
|
||||
PDFWRITER_DEP += $(UNICODECONVERTER)
|
||||
PDFWRITER_DEP += $(KERNEL)
|
||||
PDFWRITER_DEP += $(GRAPHICS)
|
||||
PDFWRITER_DEP += $(CRYPTOPP)
|
||||
|
||||
ARCHIVE := ./$(PACKAGE_NAME)$(ARCH_EXT)
|
||||
|
||||
|
||||
@ -978,15 +978,6 @@ bool ODFDecryptor::Decrypt(const std::wstring & wspassword, unsigned char* data_
|
||||
|
||||
bVerify = (pChecksum == pOutHash);
|
||||
|
||||
// test encrypt chipher - good !!;
|
||||
//ODFEncryptor encryptor;
|
||||
|
||||
//encryptor.SetCryptData(this->cryptData);
|
||||
//data_out = new unsigned char[pOut.size];
|
||||
//
|
||||
//encryptor.Encrypt(wspassword, pOut.ptr, pOut.size, data_out);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (bVerify)
|
||||
@ -1042,26 +1033,9 @@ int ODFEncryptor::Encrypt (const std::wstring & wspassword, unsigned char* data,
|
||||
data_out = new unsigned char[size_out];
|
||||
|
||||
_buf pOut (data_out, size_out, false);
|
||||
//_buf pOut (size_out);
|
||||
|
||||
EncryptCipher(pKey, ivi, data_deflate, pOut, cryptData.cipherAlgorithm, bPadding ? StreamTransformationFilter::W3C_PADDING :
|
||||
StreamTransformationFilter::NO_PADDING);
|
||||
|
||||
//int sz = 16, size_all = 0;
|
||||
//while (true)
|
||||
//{
|
||||
// if (size_all >= size_out)
|
||||
// break;
|
||||
|
||||
// _buf pInp(data_deflate.ptr + size_all, (std::min)(sz, data_deflate.size - size_all), false);
|
||||
// _buf pOut1(data_out + size_all, sz, false);
|
||||
//
|
||||
// EncryptCipher(pKey, ivi, pInp, pOut1, cryptData.cipherAlgorithm, bPadding ? StreamTransformationFilter::W3C_PADDING :
|
||||
// StreamTransformationFilter::NO_PADDING);
|
||||
|
||||
// size_all += sz;
|
||||
|
||||
//}
|
||||
return size_out;
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;CRYPTOPP_DISABLE_ASM"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
||||
@ -53,19 +53,19 @@
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/graphics.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/kernel.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/UnicodeConverter.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/CryptoPPLib.lib")
|
||||
#else
|
||||
#pragma comment(lib, "../../build/lib/win_32/HtmlRenderer.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/graphics.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/kernel.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/UnicodeConverter.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/CryptoPPLib.lib")
|
||||
#endif
|
||||
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
|
||||
#endif
|
||||
|
||||
HRESULT convert_single(PdfReader::CPdfReader& oReader, std::wstring srcFileName)
|
||||
HRESULT convert_single(PdfReader::CPdfReader& oReader, const std::wstring & srcFileName, const std::wstring & sPassword)
|
||||
{
|
||||
std::wstring sPassword = L"58455fdc2013";
|
||||
|
||||
if (oReader.LoadFromFile(srcFileName.c_str(), L"", sPassword, sPassword))
|
||||
{
|
||||
int nPagesCount = oReader.GetPagesCount();
|
||||
@ -99,7 +99,7 @@ HRESULT convert_single(PdfReader::CPdfReader& oReader, std::wstring srcFileName)
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
HRESULT convert_directory(PdfReader::CPdfReader& oReader, std::wstring pathName)
|
||||
HRESULT convert_directory(PdfReader::CPdfReader& oReader, std::wstring pathName, const std::wstring & sPassword)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
@ -107,7 +107,7 @@ HRESULT convert_directory(PdfReader::CPdfReader& oReader, std::wstring pathName)
|
||||
|
||||
for (size_t i = 0; i < arFiles.size(); i++)
|
||||
{
|
||||
hr = convert_single(oReader, arFiles[i]);
|
||||
hr = convert_single(oReader, arFiles[i], sPassword);
|
||||
|
||||
printf("%d of %d %S \tresult = %d\n", i + 1, arFiles.size(), arFiles[i].c_str(), hr);
|
||||
|
||||
@ -124,14 +124,17 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
|
||||
PdfReader::CPdfReader oPdfReader(pApplicationFonts);
|
||||
|
||||
HRESULT hr = -1;
|
||||
HRESULT hr = S_FALSE;
|
||||
|
||||
std::wstring sPassword = argc > 2 ? argv[2] : L"";
|
||||
|
||||
if (NSFile::CFileBinary::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_single(oPdfReader, argv[1]);
|
||||
hr = convert_single(oPdfReader, argv[1], sPassword);
|
||||
}
|
||||
else if (NSDirectory::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_directory(oPdfReader, argv[1]);
|
||||
hr = convert_directory(oPdfReader, argv[1], sPassword);
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -4,13 +4,10 @@ Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PdfReaderTest", "PdfReaderTest.vcproj", "{5F337F52-E630-456E-9081-730A62A89684}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{62C7E428-E07C-4C13-A92B-2536D6442C9D} = {62C7E428-E07C-4C13-A92B-2536D6442C9D}
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PdfReader", "..\PdfReader.vcproj", "{62C7E428-E07C-4C13-A92B-2536D6442C9D}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\..\Common\3dParty\cryptopp\cryptlib.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -47,22 +44,6 @@ Global
|
||||
{62C7E428-E07C-4C13-A92B-2536D6442C9D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{62C7E428-E07C-4C13-A92B-2536D6442C9D}.Release|Win32.Build.0 = Release|Win32
|
||||
{62C7E428-E07C-4C13-A92B-2536D6442C9D}.Release|x64.ActiveCfg = Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Debug|x64.Build.0 = Debug|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Debug|Win32.ActiveCfg = DLL-Import Debug|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Debug|Win32.Build.0 = DLL-Import Debug|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Debug|x64.ActiveCfg = DLL-Import Debug|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Debug|x64.Build.0 = DLL-Import Debug|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Release|Win32.ActiveCfg = DLL-Import Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Release|Win32.Build.0 = DLL-Import Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Release|x64.ActiveCfg = DLL-Import Release|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.DLL-Import Release|x64.Build.0 = DLL-Import Release|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|x64.ActiveCfg = Release|x64
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/freetype-2.5.2/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;CRYPTOPP_DISABLE_ASM"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
#include "../../Common/3dParty/cryptopp/arc4.h"
|
||||
#include "../../Common/3dParty/cryptopp/filters.h"
|
||||
|
||||
#include "../../DesktopEditor/Common/File.h"
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
namespace PdfReader
|
||||
{
|
||||
@ -54,20 +54,49 @@ namespace PdfReader
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(sDigest, buffer.BytePtr(), buffer.SizeInBytes());
|
||||
memcpy(sDigest, buffer.BytePtr(), buffer.size());
|
||||
return;
|
||||
}
|
||||
static void SHA256(unsigned char *sMessage, int nMessageLen, unsigned char *sDigest)
|
||||
static int SHA(int type, unsigned char *sMessage, int nMessageLen, unsigned char *sDigest)
|
||||
{
|
||||
CryptoPP::SHA256 hash;
|
||||
|
||||
hash.Update( sMessage, nMessageLen);
|
||||
int res = 0;
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
case 256:
|
||||
{
|
||||
CryptoPP::SHA256 hash;
|
||||
hash.Update( sMessage, nMessageLen > 0 ? nMessageLen : hash.DigestSize());
|
||||
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
CryptoPP::SecByteBlock buffer(res = hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(sDigest, buffer.BytePtr(), buffer.SizeInBytes());
|
||||
return;
|
||||
memcpy(sDigest, buffer.BytePtr(), buffer.size());
|
||||
}break;
|
||||
case 1:
|
||||
case 384:
|
||||
{
|
||||
CryptoPP::SHA384 hash;
|
||||
hash.Update( sMessage, nMessageLen > 0 ? nMessageLen : hash.DigestSize());
|
||||
|
||||
CryptoPP::SecByteBlock buffer(res = hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(sDigest, buffer.BytePtr(), buffer.size());
|
||||
}break;
|
||||
case 2:
|
||||
case 512:
|
||||
{
|
||||
CryptoPP::SHA512 hash;
|
||||
hash.Update( sMessage, nMessageLen > 0 ? nMessageLen : hash.DigestSize());
|
||||
|
||||
CryptoPP::SecByteBlock buffer(res = hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(sDigest, buffer.BytePtr(), buffer.size());
|
||||
}break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
static unsigned char passwordPad[32] =
|
||||
{
|
||||
@ -150,21 +179,31 @@ namespace PdfReader
|
||||
std::string sUserPassword = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(wsUserPassword);
|
||||
return MakeFileKey2(handler, sUserPassword);
|
||||
}
|
||||
else if ( handler->m_nEncryptRevision == 5 )
|
||||
else
|
||||
{
|
||||
bool bValidate = false;
|
||||
unsigned char empty[16];
|
||||
|
||||
NSUnicodeConverter::CUnicodeConverter conv;
|
||||
std::string sUserPassword = conv.SASLprepToUtf8(wsUserPassword);
|
||||
int len = sUserPassword.length() < 127 ? sUserPassword.length() : 127;
|
||||
|
||||
if (sUserPassword.length() > 127)
|
||||
sUserPassword = sUserPassword.substr(0, 127);
|
||||
|
||||
CryptoPP::SHA256 hash;
|
||||
|
||||
hash.Update( (unsigned char*) sUserPassword.c_str(), len);
|
||||
hash.Update( (unsigned char*) sUserPassword.c_str(), sUserPassword.length());
|
||||
hash.Update( handler->m_seUserKey->GetUBuffer() + 32, 8);
|
||||
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
bool bValidate = (0 == memcmp(buffer.BytePtr(), handler->m_seUserKey->GetUBuffer(), 32));
|
||||
if ( handler->m_nEncryptRevision > 5 )
|
||||
{
|
||||
MakeFileKey3(sUserPassword, buffer.BytePtr(), buffer.size());
|
||||
}
|
||||
|
||||
bValidate = (0 == memcmp(buffer.BytePtr(), handler->m_seUserKey->GetUBuffer(), 32));
|
||||
|
||||
if (bValidate)
|
||||
{
|
||||
@ -174,9 +213,14 @@ namespace PdfReader
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
CryptoPP::AES::Decryption aesDecryption(buffer.BytePtr(), buffer.SizeInBytes());
|
||||
unsigned char* empty[16] = {};
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, (unsigned char*)empty );
|
||||
if ( handler->m_nEncryptRevision > 5 )
|
||||
{
|
||||
MakeFileKey3(sUserPassword, buffer.BytePtr(), buffer.size());
|
||||
}
|
||||
|
||||
memset(empty, 0, 16);
|
||||
CryptoPP::AES::Decryption aesDecryption(buffer.BytePtr(), buffer.size());
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, empty );
|
||||
|
||||
CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::ArraySink( (unsigned char*)handler->m_sFileKey, 32), CryptoPP::StreamTransformationFilter::NO_PADDING );
|
||||
stfDecryptor.Put( handler->m_seUserEncryptionKey->GetUBuffer(), 32);
|
||||
@ -185,6 +229,8 @@ namespace PdfReader
|
||||
else
|
||||
{
|
||||
std::string sOwnerPassword = conv.SASLprepToUtf8(wsOwnerPassword);
|
||||
if (sOwnerPassword.length() > 127)
|
||||
sOwnerPassword = sOwnerPassword.substr(0, 127);
|
||||
|
||||
hash.Update( (unsigned char*) sOwnerPassword.c_str(), sOwnerPassword.length());
|
||||
hash.Update( handler->m_seOwnerKey->GetUBuffer() + 32, 8);
|
||||
@ -193,6 +239,11 @@ namespace PdfReader
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
if ( handler->m_nEncryptRevision > 5 )
|
||||
{
|
||||
MakeFileKey3(sOwnerPassword, buffer.BytePtr(), buffer.size(), handler->m_seUserKey->GetUBuffer(), 48);
|
||||
}
|
||||
|
||||
bValidate = (0 == memcmp(buffer.BytePtr(), handler->m_seOwnerKey->GetUBuffer(), 32));
|
||||
|
||||
if (bValidate)
|
||||
@ -203,10 +254,14 @@ namespace PdfReader
|
||||
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
CryptoPP::AES::Decryption aesDecryption(buffer.BytePtr(), buffer.SizeInBytes());
|
||||
unsigned char* empty[16] = {};
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, (unsigned char*)empty );
|
||||
|
||||
if ( handler->m_nEncryptRevision > 5 )
|
||||
{
|
||||
MakeFileKey3(sOwnerPassword, buffer.BytePtr(), buffer.size(), handler->m_seUserKey->GetUBuffer(), 48);
|
||||
}
|
||||
memset(empty, 0, 16);
|
||||
CryptoPP::AES::Decryption aesDecryption(buffer.BytePtr(), buffer.size());
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, empty );
|
||||
|
||||
CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::ArraySink( (unsigned char*)handler->m_sFileKey, 32), CryptoPP::StreamTransformationFilter::NO_PADDING );
|
||||
stfDecryptor.Put(handler->m_seOwnerEncryptionKey->GetUBuffer(), 32);
|
||||
@ -216,9 +271,62 @@ namespace PdfReader
|
||||
handler->m_bOwnerPasswordValid = bValidate;
|
||||
return bValidate;
|
||||
}
|
||||
else if ( handler->m_nEncryptRevision == 6 )
|
||||
}
|
||||
|
||||
bool Decrypt::MakeFileKey3(const std::string &sPassword, unsigned char *pHash, int nHashSize, unsigned char *pHash2, int nHashSize2)
|
||||
{
|
||||
if (!pHash) return false;
|
||||
|
||||
int size = 64 * (sPassword.length() + 64 + nHashSize2); // max
|
||||
|
||||
unsigned char K[64]; //max size sha
|
||||
unsigned char *K1 = new unsigned char[size];
|
||||
unsigned char *E = new unsigned char[size];
|
||||
|
||||
int hash_size = nHashSize;
|
||||
memcpy(K, pHash, nHashSize);
|
||||
|
||||
int iteration = 0;
|
||||
|
||||
while( (iteration < 64) || (iteration < E[size - 1] + 32))
|
||||
{
|
||||
CryptoPP::SecByteBlock key(K, 16), iv(K + 16, 16);
|
||||
|
||||
size = 0;
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
memcpy(K1 + size, sPassword.c_str(), sPassword.length()); size += sPassword.length();
|
||||
memcpy(K1 + size, K, hash_size); size += hash_size;
|
||||
if (pHash2)
|
||||
{
|
||||
memcpy(K1 + size, pHash2, nHashSize2); size += nHashSize2;
|
||||
}
|
||||
}
|
||||
CryptoPP::AES::Encryption aesEncryption(key, key.size());
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, iv);
|
||||
|
||||
CryptoPP::StreamTransformationFilter stfEncryption(cbcEncryption, new CryptoPP::ArraySink( E, size), CryptoPP::StreamTransformationFilter::NO_PADDING);
|
||||
|
||||
stfEncryption.Put( K1, size);
|
||||
stfEncryption.MessageEnd();
|
||||
//----------------------------------------------------------
|
||||
int E_mod_3 = 0;
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
{
|
||||
E_mod_3 += E[i];
|
||||
}
|
||||
E_mod_3 %= 3;
|
||||
|
||||
hash_size = SHA(E_mod_3, E, size, K);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
|
||||
delete []K1;
|
||||
delete []E;
|
||||
|
||||
memcpy (pHash, K, 32); // pHash - from sha256
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Decrypt::MakeFileKey2(StandardSecurityHandler *handler, const std::string &sUserPassword)
|
||||
|
||||
@ -53,6 +53,7 @@ namespace PdfReader
|
||||
|
||||
private:
|
||||
|
||||
static bool MakeFileKey3(const std::string &sPassword, unsigned char *pHash, int nHashSize, unsigned char *pHash2 = NULL, int nHashSize2 = 0);
|
||||
static bool MakeFileKey2(StandardSecurityHandler *handler, const std::string &userPassword);
|
||||
};
|
||||
|
||||
|
||||
@ -205,7 +205,6 @@ namespace PdfReader
|
||||
}
|
||||
else
|
||||
{
|
||||
// TO DO: Error "Weird encryption info"
|
||||
}
|
||||
|
||||
oFileID.Free();
|
||||
|
||||
@ -52,11 +52,6 @@ namespace PdfReader
|
||||
SecurityHandler(PDFDoc *pDocument);
|
||||
virtual ~SecurityHandler();
|
||||
|
||||
// Проверяем шифрованный ли документ. Если документ шифрованный, тогда сначала продуем использовать <seOwnerPassword> и
|
||||
// <seUserPassword>. Если оба пароля не подходят, тогда запрашиваем пароль у пользователя (не более 3-х раз).
|
||||
// Возвращаемые значения:
|
||||
// True, если документ может быть открыт( либо он вообще не зашифрован, либо пароль верный)
|
||||
// False, в противном случае ( документ зашрифован, а пароль неверный).
|
||||
bool CheckEncryption(const std::wstring &ownerPassword, const std::wstring &userPassword);
|
||||
|
||||
// Пытаемся авторизоваться.
|
||||
|
||||
@ -525,6 +525,13 @@ CPdfRenderer::~CPdfRenderer()
|
||||
if (L"" != m_wsTempFolder)
|
||||
NSDirectory::DeleteDirectory(m_wsTempFolder);
|
||||
}
|
||||
void CPdfRenderer::SetPassword(const std::wstring& wsPassword)
|
||||
{
|
||||
if (!IsValid())
|
||||
return;
|
||||
|
||||
m_pDocument->SetPasswords(wsPassword, wsPassword);
|
||||
}
|
||||
void CPdfRenderer::SaveToFile(const std::wstring& wsPath)
|
||||
{
|
||||
if (!IsValid())
|
||||
|
||||
@ -72,7 +72,8 @@ public:
|
||||
CPdfRenderer(NSFonts::IApplicationFonts* pAppFonts);
|
||||
~CPdfRenderer();
|
||||
void SaveToFile(const std::wstring& wsPath);
|
||||
void SetTempFolder(const std::wstring& wsPath);
|
||||
void SetPassword(const std::wstring& wsPassword);
|
||||
void SetTempFolder(const std::wstring& wsPath);
|
||||
std::wstring GetTempFile();
|
||||
void SetThemesPlace(const std::wstring& wsThemesPlace);
|
||||
std::wstring GetThemesPlace();
|
||||
@ -233,18 +234,18 @@ private:
|
||||
void UpdateBrush();
|
||||
bool IsValid()
|
||||
{
|
||||
return m_bValid;
|
||||
return m_bValid;
|
||||
}
|
||||
bool IsPageValid()
|
||||
{
|
||||
if (!IsValid() || !m_pPage)
|
||||
return false;
|
||||
if (!IsValid() || !m_pPage)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
void SetError()
|
||||
{
|
||||
m_bValid = false;;
|
||||
m_bValid = false;;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -17,6 +17,9 @@ DEFINES += PDFWRITER_USE_DYNAMIC_LIBRARY
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter -lkernel -lgraphics
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
LIBS += -lCryptoPPLib
|
||||
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
core_windows {
|
||||
|
||||
@ -29,12 +29,22 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
// PdfWriterTest.cpp : Defines the entry point for the console application.
|
||||
// PdfReaderTest.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "../OnlineOfficeBinToPdf.h"
|
||||
#include "../PdfRenderer.h"
|
||||
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
|
||||
|
||||
#include "../../DesktopEditor/raster/Metafile/MetaFile.h"
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
|
||||
#include "../Src/Streams.h"
|
||||
#include "../Src/Utils.h"
|
||||
@ -52,194 +62,28 @@
|
||||
#include "../Src/FontCidTT.h"
|
||||
#include "../Src/Pattern.h"
|
||||
|
||||
#include <iostream>
|
||||
#define TEST_PDFWRITER_LIB
|
||||
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
#if defined(_WIN64)
|
||||
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
|
||||
#elif defined (_WIN32)
|
||||
|
||||
#include "../../DesktopEditor/cximage/CxImage/ximage.h"
|
||||
#include "../../DesktopEditor/cximage/CxImage/ximatif.h"
|
||||
#include "../../DesktopEditor/raster/BgraFrame.h"
|
||||
|
||||
#include "../../DesktopEditor/cximage/tiff/tiffio.h"
|
||||
|
||||
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
|
||||
#include "../../DesktopEditor/raster/Metafile/MetaFile.h"
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
|
||||
#include "../Src/FastStringToDouble.h"
|
||||
|
||||
#ifdef DrawText
|
||||
#undef DrawText
|
||||
#if defined(_DEBUG)
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/graphics.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/kernel.lib")
|
||||
//#pragma comment(lib, "../../build/lib/win_32/DEBUG/UnicodeConverter.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/DEBUG/CryptoPPLib.lib")
|
||||
#else
|
||||
#pragma comment(lib, "../../build/lib/win_32/graphics.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/kernel.lib")
|
||||
//#pragma comment(lib, "../../build/lib/win_32/UnicodeConverter.lib")
|
||||
#pragma comment(lib, "../../build/lib/win_32/CryptoPPLib.lib")
|
||||
#endif
|
||||
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
|
||||
#endif
|
||||
|
||||
using namespace PdfWriter;
|
||||
|
||||
void TestStreams()
|
||||
{
|
||||
CFileStream oFS;
|
||||
oFS.OpenFile(L"D:/Test Files/1.txt", false);
|
||||
|
||||
while (!oFS.IsEof())
|
||||
{
|
||||
char nChar = oFS.ReadChar();
|
||||
std::cout << nChar;
|
||||
}
|
||||
|
||||
CMemoryStream oMS;
|
||||
oMS.WriteStream(&oFS, 0, NULL);
|
||||
|
||||
CFileStream oTS;
|
||||
oTS.OpenFile(L"D:/Test Files/TestStreams.tmp", true);
|
||||
oTS.WriteStream(&oMS, 0, NULL);
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteChar('c');
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteBinary((const BYTE*)"123", 3, NULL);
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteEscapeName((const char*)"EscapeName");
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteEscapeText((const BYTE*)"EscapeTest", StrLen("EscapeTest", 12));
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteHex(251, 2);
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteHex(251, 4);
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteInt(63);
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteReal(0.12);
|
||||
oTS.WriteChar(' ');
|
||||
oTS.WriteStr("String");
|
||||
oTS.WriteChar(' ');
|
||||
oTS.Close();
|
||||
|
||||
CFileStream oTS2;
|
||||
oTS2.OpenFile(L"D:/Test Files/TestStreamsFilter.tmp", true);
|
||||
oTS2.WriteStream(&oMS, STREAM_FILTER_FLATE_DECODE, NULL);
|
||||
oTS2.Close();
|
||||
}
|
||||
void TestObjects()
|
||||
{
|
||||
CStream* pStream = new CFileStream();
|
||||
((CFileStream*)pStream)->OpenFile(L"D:/Test Files/TestObjects.tmp", true);
|
||||
|
||||
CNullObject oNull;
|
||||
pStream->Write(&oNull);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CBoolObject oBool = true;
|
||||
pStream->Write(&oBool);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CNumberObject oNumber = 75;
|
||||
pStream->Write(&oNumber);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CRealObject oReal = 13.756;
|
||||
pStream->Write(&oReal);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CNameObject oName = "Name";
|
||||
pStream->Write(&oName);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CStringObject oString("String");
|
||||
pStream->Write(&oString, NULL);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CBinaryObject oBinary((BYTE*)"123", 3);
|
||||
pStream->Write(&oBinary, NULL);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CArrayObject* pArray = new CArrayObject();
|
||||
pArray->Add(12);
|
||||
pArray->Add(0.13);
|
||||
pArray->Add(13.1);
|
||||
pStream->Write(pArray, NULL);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CProxyObject oProxy(pArray);
|
||||
oProxy.SetRef(123, 0);
|
||||
pStream->Write(&oProxy, NULL);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
CDictObject oDict;
|
||||
oDict.Add("Bool", true);
|
||||
oDict.Add("Real", 0.12);
|
||||
oDict.Add("Number", 12);
|
||||
oDict.Add("Name", "SomeName");
|
||||
oDict.Add("Array", pArray);
|
||||
pStream->Write(&oDict, NULL);
|
||||
pStream->WriteChar('\n');
|
||||
|
||||
delete pStream;
|
||||
}
|
||||
void TestEncrypt()
|
||||
{
|
||||
CEncrypt oEncrypt;
|
||||
oEncrypt.Init();
|
||||
oEncrypt.InitKey(1231, 0);
|
||||
|
||||
CFileStream oFS;
|
||||
oFS.OpenFile(L"D:/Test Files/TestStreams.tmp", false);
|
||||
|
||||
CFileStream oTS;
|
||||
oTS.OpenFile(L"D:/Test Files/TestEncrypt.tmp", true);
|
||||
oTS.WriteStream(&oFS, 0, &oEncrypt);
|
||||
oTS.Close();
|
||||
|
||||
oFS.Close();
|
||||
}
|
||||
void TestDict()
|
||||
{
|
||||
CStream* pStream = new CFileStream();
|
||||
((CFileStream*)pStream)->OpenFile(L"D:/Test Files/TestDict.tmp", true);
|
||||
|
||||
CXref oXref(0);
|
||||
|
||||
CDictObject* pDict = new CDictObject(&oXref);
|
||||
pDict->Add("Bool", true);
|
||||
pDict->Add("Real", 0.12);
|
||||
pDict->Add("Number", 12);
|
||||
pDict->Add("Name", "SomeName");
|
||||
pDict->Add("Array", new CArrayObject());
|
||||
|
||||
CStream* pDictStream = pDict->GetStream();
|
||||
pDictStream->WriteEscapeText((BYTE*)"TestTest", 8);
|
||||
pDictStream->WriteBinary((BYTE*)"TestTest", 8, NULL);
|
||||
|
||||
CDictObject* pDict2 = new CDictObject(&oXref);
|
||||
pDict2->Add("Bool", true);
|
||||
pDict2->Add("Real", 0.12);
|
||||
pDict2->Add("Number", 12);
|
||||
pDict2->Add("Name", "SomeName");
|
||||
pDict2->Add("Array", new CArrayObject());
|
||||
|
||||
pDict2->SetFilter(STREAM_FILTER_FLATE_DECODE);
|
||||
|
||||
CStream* pDictStream2 = pDict2->GetStream();
|
||||
pDictStream2->WriteEscapeText((BYTE*)"TestTest", 8);
|
||||
pDictStream2->WriteBinary((BYTE*)"TestTest", 8, NULL);
|
||||
|
||||
TDate oDate;
|
||||
MemSet(&oDate, 0, sizeof(oDate));
|
||||
oDate.nDay = 18;
|
||||
oDate.nMonth = 10;
|
||||
oDate.nYear = 1986;
|
||||
oDate.nHour = 12;
|
||||
oDate.nMinutes = 0;
|
||||
oDate.nSeconds = 0;
|
||||
oDate.nInd = '-';
|
||||
|
||||
CInfoDict* pInfo = new CInfoDict(&oXref);
|
||||
pInfo->SetInfo(EInfoType::InfoCreator, "Ilya");
|
||||
pInfo->SetInfo(EInfoType::InfoCreationDate, oDate);
|
||||
|
||||
oXref.WriteToStream(pStream, NULL);
|
||||
|
||||
delete pStream;
|
||||
}
|
||||
void TestDocument1()
|
||||
{
|
||||
// PageLabels and Encryption
|
||||
@ -251,11 +95,9 @@ void TestDocument1()
|
||||
oPdf.AddPage();
|
||||
oPdf.AddPageLabel(2, pagenumstyle_UpperRoman, 21, "UppRom-");
|
||||
|
||||
oPdf.SetPassword("123", "qwe");
|
||||
oPdf.SetPermission(ENABLE_READ);
|
||||
oPdf.SetEncryptionMode(encryptmode_R3);
|
||||
oPdf.SetPasswords(L"123", L"qwe");
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test1.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test1.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument2()
|
||||
@ -287,7 +129,7 @@ void TestDocument2()
|
||||
pOutline11->SetDestination(pDest);
|
||||
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test2.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test2.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument3()
|
||||
@ -456,7 +298,7 @@ void TestDocument3()
|
||||
|
||||
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test3.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test3.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument4()
|
||||
@ -476,7 +318,7 @@ void TestDocument4()
|
||||
CAnnotation* pAnnot = oPdf.CreateLinkAnnot(0, TRect(0, 100, 100, 0), pDest);
|
||||
pAnnot = oPdf.CreateUriLinkAnnot(0, TRect(0, 200, 100, 100), "www.rbc.ru");
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test4.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test4.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument5()
|
||||
@ -488,9 +330,9 @@ void TestDocument5()
|
||||
pPage->SetWidth(600);
|
||||
|
||||
//CBgraFrame oFrame;
|
||||
//oFrame.OpenFile(L"D:/Test Files/Test.jb2");
|
||||
//oFrame.OpenFile(L"D:/test/_pdf/Test.jb2");
|
||||
|
||||
//TIFF* pTiff = TIFFOpenW(L"D:/Test Files/Test.tiff", "w+");
|
||||
//TIFF* pTiff = TIFFOpenW(L"D:/test/_pdf/Test.tiff", "w+");
|
||||
//TIFFSetField(pTiff, TIFFTAG_IMAGEWIDTH, 800);
|
||||
//TIFFSetField(pTiff, TIFFTAG_IMAGELENGTH, 1000);
|
||||
//TIFFSetField(pTiff, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||
@ -511,7 +353,7 @@ void TestDocument5()
|
||||
//TIFFClose(pTiff);
|
||||
|
||||
//CImageDict* pImage = oPdf.CreateImage();
|
||||
//pImage->LoadCCITT4(L"D:/Test Files/Test.tiff", 800, 1000);
|
||||
//pImage->LoadCCITT4(L"D:/test/_pdf/Test.tiff", 800, 1000);
|
||||
//pPage->DrawImage(pImage, 100, 100, 200, 200);
|
||||
|
||||
BYTE* pBuffer = new BYTE[100 * 800];
|
||||
@ -544,14 +386,14 @@ void TestDocument5()
|
||||
|
||||
|
||||
//CxImage oImage;
|
||||
//oImage.Load(L"D:/Test Files/Test.jb2");
|
||||
//oImage.Load(L"D:/test/_pdf/Test.jb2");
|
||||
|
||||
//CImageDict* pJb2Image = oPdf.CreateImage();
|
||||
//pJb2Image->LoadJb2(L"D:/Test Files/Test.jb2", 1728, 2376);
|
||||
//pJb2Image->LoadJb2(L"D:/test/_pdf/Test.jb2", 1728, 2376);
|
||||
//pPage->DrawImage(pJb2Image, 100, 100, 200, 200);
|
||||
|
||||
//CImageDict* pJpegImage = oPdf.CreateImage();
|
||||
//pJpegImage->LoadJpeg(L"D:/Test Files/Test.jpg", 670, 473);
|
||||
//pJpegImage->LoadJpeg(L"D:/test/_pdf/Test.jpg", 670, 473);
|
||||
//pPage->DrawImage(pJpegImage, 100, 100, 200, 200);
|
||||
|
||||
//BYTE* pAlpha = new BYTE[4 * 400 * 300];
|
||||
@ -579,14 +421,14 @@ void TestDocument5()
|
||||
//}
|
||||
|
||||
//CImageDict* pJpxImage = oPdf.CreateImage();
|
||||
//pJpxImage->LoadJpx(L"D:/Test Files/Test.jp2", 400, 300);
|
||||
//pJpxImage->LoadJpx(L"D:/test/_pdf/Test.jp2", 400, 300);
|
||||
//pJpxImage->LoadSMask(pAlpha, 400, 300);
|
||||
//pPage->DrawImage(pJpxImage, 300, 100, 200, 200);
|
||||
|
||||
//delete[] pAlpha;
|
||||
|
||||
////CImageDict* pJb2Image = oPdf.CreateImage();
|
||||
////pJb2Image->LoadJb2(L"D:/Test Files/Test.jbig2", 400, 300);
|
||||
////pJb2Image->LoadJb2(L"D:/test/_pdf/Test.jbig2", 400, 300);
|
||||
////pPage->DrawImage(pJb2Image, 300, 300, 200, 200);
|
||||
|
||||
//CImageDict* pRawImage = oPdf.CreateImage();
|
||||
@ -620,7 +462,7 @@ void TestDocument5()
|
||||
//pPage->DrawImage(pRawImage, 300, 300, 200, 200);
|
||||
//delete[] pBgra;
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test5.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test5.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument6()
|
||||
@ -693,7 +535,7 @@ void TestDocument6()
|
||||
pPage->ClosePath();
|
||||
pPage->Fill();
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test6.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test6.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument7()
|
||||
@ -726,8 +568,8 @@ void TestDocument7()
|
||||
pPage->SetHeight(600);
|
||||
pPage->SetWidth(1000);
|
||||
|
||||
//CFontCidTrueType* pFont = oPdf.CreateTrueTypeFont(L"D:/Test Files/Test.ttf", 0);
|
||||
CFontCidTrueType* pFont = oPdf.CreateTrueTypeFont(L"D:/Test Files/cambria.ttc", 1);
|
||||
//CFontCidTrueType* pFont = oPdf.CreateTrueTypeFont(L"D:/test/_pdf/Test.ttf", 0);
|
||||
CFontCidTrueType* pFont = oPdf.CreateTrueTypeFont(L"D:/test/_pdf/cambria.ttc", 1);
|
||||
|
||||
pPage->BeginText();
|
||||
|
||||
@ -758,7 +600,7 @@ void TestDocument7()
|
||||
|
||||
pPage->EndText();
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test7.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test7.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument8()
|
||||
@ -837,7 +679,7 @@ void TestDocument8()
|
||||
pPage->GrRestore();
|
||||
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test8.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test8.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
void TestDocument9()
|
||||
@ -853,7 +695,7 @@ void TestDocument9()
|
||||
pPage->SetWidth(600);
|
||||
|
||||
CImageDict* pJpegImage = oPdf.CreateImage();
|
||||
pJpegImage->LoadJpeg(L"D:/Test Files/Test.jpg", 600, 400);
|
||||
pJpegImage->LoadJpeg(L"D:/test/_pdf/Test.jpg", 600, 400);
|
||||
|
||||
CImageTilePattern* pPattern = oPdf.CreateImageTilePattern(70, 70, pJpegImage, NULL, imagetilepatterntype_InverseX);
|
||||
|
||||
@ -865,63 +707,38 @@ void TestDocument9()
|
||||
pPage->GrRestore();
|
||||
|
||||
|
||||
oPdf.SaveToFile(L"D:/Test Files/Test9.pdf");
|
||||
oPdf.SaveToFile(L"D:/test/_pdf/Test9.pdf");
|
||||
oPdf.Close();
|
||||
}
|
||||
|
||||
std::vector<std::wstring> GetAllFilesInFolder(std::wstring wsFolder, std::wstring wsExt)
|
||||
|
||||
void ConvertFolder(std::wstring wsFolderPath)
|
||||
{
|
||||
std::vector<std::wstring> vwsNames;
|
||||
NSFonts::IApplicationFonts *pAppFonts = NSFonts::NSApplication::Create();
|
||||
pAppFonts->Initialize();
|
||||
|
||||
std::wstring wsSearchPath = wsFolder;
|
||||
wsSearchPath.append(L"*.");
|
||||
wsSearchPath.append(wsExt);
|
||||
MetaFile::IMetaFile *pMetaFile = MetaFile::Create(pAppFonts);
|
||||
|
||||
WIN32_FIND_DATA oFindData;
|
||||
HANDLE hFind = ::FindFirstFile(wsSearchPath.c_str(), &oFindData);
|
||||
if (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!(oFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
vwsNames.push_back(oFindData.cFileName);
|
||||
}
|
||||
} while (::FindNextFile(hFind, &oFindData));
|
||||
::FindClose(hFind);
|
||||
}
|
||||
return vwsNames;
|
||||
}
|
||||
void ConvertFolder(std::wstring wsFolderPath, const int nType)
|
||||
{
|
||||
CApplicationFonts oFonts;
|
||||
oFonts.Initialize();
|
||||
|
||||
MetaFile::CMetaFile oMetaFile(&oFonts);
|
||||
CPdfRenderer oRenderer(&oFonts);
|
||||
CPdfRenderer oRenderer(pAppFonts);
|
||||
|
||||
oMetaFile.Close();
|
||||
pMetaFile->Close();
|
||||
|
||||
std::wstring sExt;
|
||||
|
||||
switch (nType)
|
||||
{
|
||||
case MetaFile::c_lMetaEmf: sExt = L"emf"; break;
|
||||
case MetaFile::c_lMetaWmf: sExt = L"wmf"; break;
|
||||
case MetaFile::c_lMetaSvm: sExt = L"svm"; break;
|
||||
}
|
||||
double dPx2Mm = 25.4 / 96;
|
||||
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, sExt);
|
||||
|
||||
std::vector<std::wstring> vFiles = NSDirectory::GetFiles(wsFolderPath);
|
||||
|
||||
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
|
||||
{
|
||||
oRenderer.NewPage();
|
||||
|
||||
std::wstring wsFilePath = wsFolderPath;
|
||||
wsFilePath.append(vFiles.at(nIndex));
|
||||
if (oMetaFile.LoadFromFile(wsFilePath.c_str()))
|
||||
if (pMetaFile->LoadFromFile(wsFilePath.c_str()))
|
||||
{
|
||||
double dW, dH, dX, dY;
|
||||
oMetaFile.GetBounds(&dX, &dY, &dW, &dH);
|
||||
pMetaFile->GetBounds(&dX, &dY, &dW, &dH);
|
||||
|
||||
dW *= dPx2Mm;
|
||||
dH *= dPx2Mm;
|
||||
@ -934,163 +751,56 @@ void ConvertFolder(std::wstring wsFolderPath, const int nType)
|
||||
|
||||
oRenderer.put_Width(dW);
|
||||
oRenderer.put_Height(dH);
|
||||
//oMetaFile.DrawOnRenderer(&oRenderer, -dX, -dY, dW, dH);
|
||||
oMetaFile.DrawOnRenderer(&oRenderer, 0, 0, dW, dH);
|
||||
oMetaFile.Close();
|
||||
//pMetaFile->DrawOnRenderer(&oRenderer, -dX, -dY, dW, dH);
|
||||
pMetaFile->DrawOnRenderer(&oRenderer, 0, 0, dW, dH);
|
||||
pMetaFile->Close();
|
||||
}
|
||||
|
||||
printf("%d of %d %S\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
|
||||
}
|
||||
|
||||
oRenderer.SaveToFile(wsFolderPath + L"Out.pdf");
|
||||
|
||||
delete pMetaFile;
|
||||
delete pAppFonts;
|
||||
}
|
||||
void TestMetafile()
|
||||
|
||||
//void TestOnlineBin()
|
||||
//{
|
||||
// std::wstring wsFolderPath = L"D://Test Files//Txt//Gradient//";
|
||||
// //std::wstring wsFolderPath = L"D://Test Files//Txt//Text//";
|
||||
// std::wstring wsTempFolder = L"D://Test Files//Temp//";
|
||||
//
|
||||
// CApplicationFonts oFonts;
|
||||
// oFonts.Initialize();
|
||||
//
|
||||
// clock_t oBeginTime = clock();
|
||||
// double dPx2Mm = 25.4 / 96;
|
||||
// std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, L"txt");
|
||||
// for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
|
||||
// {
|
||||
// std::wstring wsFilePath = wsFolderPath;
|
||||
// wsFilePath.append(vFiles.at(nIndex));
|
||||
// std::wstring wsOutPath = wsFolderPath + L"Out.pdf";
|
||||
//
|
||||
// CPdfRenderer oRenderer(&oFonts);
|
||||
// oRenderer.SetTempFolder(wsTempFolder);
|
||||
// oRenderer.OnlineWordToPdf(wsFilePath, wsOutPath);
|
||||
//
|
||||
// printf("%d of %d %S\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
|
||||
// }
|
||||
//
|
||||
// clock_t oEndTime = clock();
|
||||
// double dElapsedSecs = double(oEndTime - oBeginTime) / CLOCKS_PER_SEC;
|
||||
// printf("%f\n", dElapsedSecs);
|
||||
//}
|
||||
//
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
ConvertFolder(L"D://Test Files//Emf//", MetaFile::c_lMetaEmf);
|
||||
//ConvertFolder(L"D://Test Files//Wmf//", MetaFile::c_lMetaWmf);
|
||||
}
|
||||
void TestOnlineBin()
|
||||
{
|
||||
std::wstring wsFolderPath = L"D://Test Files//Txt//Gradient//";
|
||||
//std::wstring wsFolderPath = L"D://Test Files//Txt//Text//";
|
||||
std::wstring wsTempFolder = L"D://Test Files//Temp//";
|
||||
|
||||
CApplicationFonts oFonts;
|
||||
oFonts.Initialize();
|
||||
TestDocument1();
|
||||
|
||||
clock_t oBeginTime = clock();
|
||||
double dPx2Mm = 25.4 / 96;
|
||||
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, L"txt");
|
||||
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
|
||||
{
|
||||
std::wstring wsFilePath = wsFolderPath;
|
||||
wsFilePath.append(vFiles.at(nIndex));
|
||||
std::wstring wsOutPath = wsFolderPath + L"Out.pdf";
|
||||
|
||||
CPdfRenderer oRenderer(&oFonts);
|
||||
oRenderer.SetTempFolder(wsTempFolder);
|
||||
oRenderer.OnlineWordToPdf(wsFilePath, wsOutPath);
|
||||
|
||||
printf("%d of %d %S\n", nIndex, vFiles.size(), vFiles.at(nIndex).c_str());
|
||||
}
|
||||
|
||||
clock_t oEndTime = clock();
|
||||
double dElapsedSecs = double(oEndTime - oBeginTime) / CLOCKS_PER_SEC;
|
||||
printf("%f\n", dElapsedSecs);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void TestDouble()
|
||||
{
|
||||
const int nMaxInt = NSFastIntToString::c_nMaxInt;
|
||||
const int nCount = 100000;
|
||||
double pDoubles[nCount];
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++)
|
||||
{
|
||||
pDoubles[nIndex] = (rand() % (nMaxInt - 1) + (rand() % (nMaxInt - 1)) / (double)nMaxInt);
|
||||
}
|
||||
pDoubles[0] = 120.0012;
|
||||
pDoubles[1] = 12.012312;
|
||||
pDoubles[2] = 0.00012312;
|
||||
|
||||
clock_t oBeginTime = clock();
|
||||
|
||||
char pBuffer[32];
|
||||
for (int nI = 0; nI < 10; nI++)
|
||||
{
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++)
|
||||
{
|
||||
double dValue = pDoubles[nIndex];
|
||||
memset(pBuffer, 0x00, 32);
|
||||
FtoA(pBuffer, dValue, pBuffer + 31);
|
||||
}
|
||||
}
|
||||
|
||||
clock_t oEndTime = clock();
|
||||
double dElapsedSecs = double(oEndTime - oBeginTime) / CLOCKS_PER_SEC;
|
||||
printf("FtoA %f\n", dElapsedSecs);
|
||||
|
||||
oBeginTime = clock();
|
||||
|
||||
for (int nI = 0; nI < 10; nI++)
|
||||
{
|
||||
|
||||
for (int nIndex = 0; nIndex < nCount; nIndex++)
|
||||
{
|
||||
int nResLen = 0;
|
||||
double dValue = pDoubles[nIndex];
|
||||
int nIVal = (int)dValue;
|
||||
int nFVal = (int)(fabs(dValue - nIVal) * 10000);
|
||||
|
||||
int nLen = 0;
|
||||
const char* sString = NSFastIntToString::GetString(abs(nIVal), nLen);
|
||||
if (nIVal < 0)
|
||||
pBuffer[nResLen++] = '-';
|
||||
|
||||
memcpy(pBuffer + nResLen, sString, nLen);
|
||||
nResLen += nLen;
|
||||
|
||||
if (nFVal)
|
||||
{
|
||||
sString = NSFastIntToString::GetString(nFVal, nLen);
|
||||
|
||||
pBuffer[nResLen++] = '.';
|
||||
int nZeros = 4 - nLen;
|
||||
if (nZeros > 0)
|
||||
{
|
||||
memcpy(pBuffer + nResLen, NSFastIntToString::GetZeros(nZeros), nLen);
|
||||
nResLen += nZeros;
|
||||
}
|
||||
|
||||
memcpy(pBuffer + nResLen, sString, nLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oEndTime = clock();
|
||||
dElapsedSecs = double(oEndTime - oBeginTime) / CLOCKS_PER_SEC;
|
||||
printf("Fast %f\n", dElapsedSecs);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
//TestStreams();
|
||||
//TestObjects();
|
||||
//TestEncrypt();
|
||||
//TestDict();
|
||||
//TestDocument1();
|
||||
//TestDocument2();
|
||||
//TestDocument3();
|
||||
//TestDocument4();
|
||||
//TestDocument5();
|
||||
//TestDocument6();
|
||||
//TestDocument7();
|
||||
//TestDocument8();
|
||||
//TestDocument9();
|
||||
//TestMetafile();
|
||||
TestOnlineBin();
|
||||
//TestDouble();
|
||||
|
||||
//std::string wsTest = "";
|
||||
|
||||
//wsTest = "static const char c_nPrecisionLen[] = {";
|
||||
|
||||
//int nMax = 100000;
|
||||
//for (int nIndex = 0; nIndex < nMax; nIndex++)
|
||||
//{
|
||||
|
||||
// std::string sInt = std::to_string(nIndex);
|
||||
// while (sInt.length() > 1 && '0' == sInt.at(sInt.length() - 1))
|
||||
// sInt.pop_back();
|
||||
|
||||
// wsTest += std::to_string(sInt.length());
|
||||
|
||||
// if (nIndex != nMax - 1)
|
||||
// wsTest += ",";
|
||||
//}
|
||||
|
||||
//wsTest += "};";
|
||||
|
||||
|
||||
char q;
|
||||
std::cin >> q;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ namespace PdfWriter
|
||||
{
|
||||
Close();
|
||||
}
|
||||
bool CDocument::CreateNew()
|
||||
bool CDocument::CreateNew()
|
||||
{
|
||||
Close();
|
||||
|
||||
@ -109,7 +109,7 @@ namespace PdfWriter
|
||||
return false;
|
||||
|
||||
m_pInfo->SetCreationTime();
|
||||
m_pInfo->SetInfo(InfoProducer, "Ascensio System SIA Copyright (c) 2015");
|
||||
m_pInfo->SetInfo(InfoProducer, "Ascensio System SIA Copyright (c) 2018");
|
||||
|
||||
m_nCurPageNum = -1;
|
||||
|
||||
@ -122,7 +122,7 @@ namespace PdfWriter
|
||||
|
||||
return true;
|
||||
}
|
||||
void CDocument::Close()
|
||||
void CDocument::Close()
|
||||
{
|
||||
// Все объекты удаляются внутри CXref
|
||||
RELEASEOBJECT(m_pXref);
|
||||
@ -151,11 +151,13 @@ namespace PdfWriter
|
||||
m_vFreeTypeFonts.clear();
|
||||
if (m_pFreeTypeLibrary)
|
||||
{
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
FT_Done_FreeType(m_pFreeTypeLibrary);
|
||||
m_pFreeTypeLibrary = NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
bool CDocument::SaveToFile(const std::wstring& wsPath)
|
||||
bool CDocument::SaveToFile(const std::wstring& wsPath)
|
||||
{
|
||||
CFileStream* pStream = new CFileStream();
|
||||
if (!pStream || !pStream->OpenFile(wsPath, true))
|
||||
@ -169,7 +171,7 @@ namespace PdfWriter
|
||||
|
||||
return true;
|
||||
}
|
||||
void CDocument::SaveToStream(CStream* pStream)
|
||||
void CDocument::SaveToStream(CStream* pStream)
|
||||
{
|
||||
unsigned long nRet = OK;
|
||||
|
||||
@ -190,7 +192,7 @@ namespace PdfWriter
|
||||
|
||||
m_pXref->WriteToStream(pStream, pEncrypt);
|
||||
}
|
||||
void CDocument::PrepareEncryption()
|
||||
void CDocument::PrepareEncryption()
|
||||
{
|
||||
CEncrypt* pEncrypt = m_pEncryptDict->GetEncrypt();
|
||||
if (!pEncrypt)
|
||||
@ -207,18 +209,10 @@ namespace PdfWriter
|
||||
else
|
||||
pID->Clear();
|
||||
|
||||
pID->Add(new CBinaryObject(pEncrypt->m_anEncryptID, ID_LEN));
|
||||
pID->Add(new CBinaryObject(pEncrypt->m_anEncryptID, ID_LEN));
|
||||
pID->Add(new CBinaryObject(pEncrypt->m_anEncryptID, 16));
|
||||
pID->Add(new CBinaryObject(pEncrypt->m_anEncryptID, 16));
|
||||
}
|
||||
void CDocument::SetEncryptionMode(EEncryptMode eMode, unsigned int unKeyLen)
|
||||
{
|
||||
if (!m_bEncrypt)
|
||||
return;
|
||||
|
||||
CEncrypt* pEncrypt = m_pEncryptDict->GetEncrypt();
|
||||
pEncrypt->SetMode(eMode, unKeyLen);
|
||||
}
|
||||
void CDocument::SetPassword(const char* sOwnerPassword, const char* sUserPassword)
|
||||
void CDocument::SetPasswords(const std::wstring & wsOwnerPassword, const std::wstring & wsUserPassword)
|
||||
{
|
||||
if (!m_pEncryptDict)
|
||||
m_pEncryptDict = new CEncryptDict(m_pXref);
|
||||
@ -226,11 +220,12 @@ namespace PdfWriter
|
||||
if (!m_pEncryptDict)
|
||||
return;
|
||||
|
||||
m_pEncryptDict->SetPassword(sOwnerPassword, sUserPassword);
|
||||
m_pTrailer->Add("Encrypt", m_pEncryptDict);
|
||||
m_pEncryptDict->SetPasswords(wsOwnerPassword, wsUserPassword);
|
||||
|
||||
m_pTrailer->Add("Encrypt", m_pEncryptDict);
|
||||
m_bEncrypt = true;
|
||||
}
|
||||
CPage* CDocument::AddPage()
|
||||
CPage* CDocument::AddPage()
|
||||
{
|
||||
CPage* pPage = new CPage(m_pXref, m_pPageTree, this);
|
||||
m_pPageTree->AddPage(pPage);
|
||||
@ -246,7 +241,7 @@ namespace PdfWriter
|
||||
m_nCurPageNum++;
|
||||
return pPage;
|
||||
}
|
||||
void CDocument::SetPermission(unsigned int unPermission)
|
||||
void CDocument::SetPermission(unsigned int unPermission)
|
||||
{
|
||||
if (!m_bEncrypt)
|
||||
return;
|
||||
@ -254,11 +249,11 @@ namespace PdfWriter
|
||||
CEncrypt* pEncrypt = m_pEncryptDict->GetEncrypt();
|
||||
pEncrypt->SetPermission(unPermission);
|
||||
}
|
||||
void CDocument::SetCompressionMode(unsigned int unMode)
|
||||
void CDocument::SetCompressionMode(unsigned int unMode)
|
||||
{
|
||||
m_unCompressMode = unMode;
|
||||
}
|
||||
void CDocument::AddPageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
|
||||
void CDocument::AddPageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
|
||||
{
|
||||
CDictObject* pPageLabel = CreatePageLabel(eStyle, unFirstPage, sPrefix);
|
||||
if (!pPageLabel)
|
||||
@ -266,7 +261,7 @@ namespace PdfWriter
|
||||
|
||||
m_pCatalog->AddPageLabel(m_nCurPageNum, pPageLabel);
|
||||
}
|
||||
void CDocument::AddPageLabel(unsigned int unPageNum, EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
|
||||
void CDocument::AddPageLabel(unsigned int unPageNum, EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
|
||||
{
|
||||
CDictObject* pPageLabel = CreatePageLabel(eStyle, unFirstPage, sPrefix);
|
||||
if (!pPageLabel)
|
||||
@ -274,7 +269,7 @@ namespace PdfWriter
|
||||
|
||||
m_pCatalog->AddPageLabel(unPageNum, pPageLabel);
|
||||
}
|
||||
CDictObject* CDocument::CreatePageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
|
||||
CDictObject* CDocument::CreatePageLabel(EPageNumStyle eStyle, unsigned int unFirstPage, const char* sPrefix)
|
||||
{
|
||||
CDictObject* pLabel = new CDictObject();
|
||||
if (!pLabel)
|
||||
@ -298,7 +293,7 @@ namespace PdfWriter
|
||||
|
||||
return pLabel;
|
||||
}
|
||||
COutline* CDocument::CreateOutline(COutline* pParent, const char* sTitle)
|
||||
COutline* CDocument::CreateOutline(COutline* pParent, const char* sTitle)
|
||||
{
|
||||
if (!pParent)
|
||||
{
|
||||
@ -316,7 +311,7 @@ namespace PdfWriter
|
||||
|
||||
return new COutline(pParent, sTitle, m_pXref);
|
||||
}
|
||||
CDestination* CDocument::CreateDestination(unsigned int unPageIndex)
|
||||
CDestination* CDocument::CreateDestination(unsigned int unPageIndex)
|
||||
{
|
||||
if (unPageIndex >= m_vPages.size())
|
||||
return NULL;
|
||||
@ -324,7 +319,7 @@ namespace PdfWriter
|
||||
CPage* pPage = m_vPages.at(unPageIndex);
|
||||
return new CDestination(pPage, m_pXref);
|
||||
}
|
||||
CExtGrState* CDocument::FindExtGrState(double dAlphaStroke, double dAlphaFill, EBlendMode eMode, int nStrokeAdjustment)
|
||||
CExtGrState* CDocument::FindExtGrState(double dAlphaStroke, double dAlphaFill, EBlendMode eMode, int nStrokeAdjustment)
|
||||
{
|
||||
CExtGrState* pExtGrState = NULL;
|
||||
for (unsigned int unIndex = 0, unCount = m_vExtGrStates.size(); unIndex < unCount; unIndex++)
|
||||
@ -348,7 +343,7 @@ namespace PdfWriter
|
||||
|
||||
return NULL;
|
||||
}
|
||||
CExtGrState* CDocument::GetExtGState(double dAlphaStroke, double dAlphaFill, EBlendMode eMode, int nStrokeAdjustment)
|
||||
CExtGrState* CDocument::GetExtGState(double dAlphaStroke, double dAlphaFill, EBlendMode eMode, int nStrokeAdjustment)
|
||||
{
|
||||
CExtGrState* pExtGrState = FindExtGrState(dAlphaStroke, dAlphaFill, eMode, nStrokeAdjustment);
|
||||
|
||||
@ -376,7 +371,7 @@ namespace PdfWriter
|
||||
|
||||
return pExtGrState;
|
||||
}
|
||||
CExtGrState* CDocument::GetStrokeAlpha(double dAlpha)
|
||||
CExtGrState* CDocument::GetStrokeAlpha(double dAlpha)
|
||||
{
|
||||
CExtGrState* pExtGrState = NULL;
|
||||
for (unsigned int unIndex = 0, unCount = m_vStrokeAlpha.size(); unIndex < unCount; unIndex++)
|
||||
@ -395,7 +390,7 @@ namespace PdfWriter
|
||||
m_vStrokeAlpha.push_back(pExtGrState);
|
||||
return pExtGrState;
|
||||
}
|
||||
CExtGrState* CDocument::GetFillAlpha(double dAlpha)
|
||||
CExtGrState* CDocument::GetFillAlpha(double dAlpha)
|
||||
{
|
||||
CExtGrState* pExtGrState = NULL;
|
||||
for (unsigned int unIndex = 0, unCount = m_vFillAlpha.size(); unIndex < unCount; unIndex++)
|
||||
@ -414,7 +409,7 @@ namespace PdfWriter
|
||||
m_vFillAlpha.push_back(pExtGrState);
|
||||
return pExtGrState;
|
||||
}
|
||||
CAnnotation* CDocument::CreateTextAnnot(unsigned int unPageNum, TRect oRect, const char* sText)
|
||||
CAnnotation* CDocument::CreateTextAnnot(unsigned int unPageNum, TRect oRect, const char* sText)
|
||||
{
|
||||
CAnnotation* pAnnot = new CTextAnnotation(m_pXref, oRect, sText);
|
||||
if (pAnnot)
|
||||
@ -425,7 +420,7 @@ namespace PdfWriter
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateLinkAnnot(unsigned int unPageNum, TRect oRect, CDestination* pDest)
|
||||
CAnnotation* CDocument::CreateLinkAnnot(unsigned int unPageNum, TRect oRect, CDestination* pDest)
|
||||
{
|
||||
CAnnotation* pAnnot = new CLinkAnnotation(m_pXref, oRect, pDest);
|
||||
|
||||
@ -437,7 +432,7 @@ namespace PdfWriter
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CAnnotation* CDocument::CreateUriLinkAnnot(unsigned int unPageNum, TRect oRect, const char* sUri)
|
||||
CAnnotation* CDocument::CreateUriLinkAnnot(unsigned int unPageNum, TRect oRect, const char* sUri)
|
||||
{
|
||||
CAnnotation* pAnnot = new CUriLinkAnnotation(m_pXref, oRect, sUri);
|
||||
|
||||
@ -449,11 +444,11 @@ namespace PdfWriter
|
||||
|
||||
return pAnnot;
|
||||
}
|
||||
CImageDict* CDocument::CreateImage()
|
||||
CImageDict* CDocument::CreateImage()
|
||||
{
|
||||
return new CImageDict(m_pXref, this);
|
||||
}
|
||||
CFont14* CDocument::CreateFont14(EStandard14Fonts eType)
|
||||
CFont14* CDocument::CreateFont14(EStandard14Fonts eType)
|
||||
{
|
||||
return new CFont14(m_pXref, this, eType);
|
||||
}
|
||||
@ -473,7 +468,7 @@ namespace PdfWriter
|
||||
m_vTTFonts.push_back(TFontInfo(wsFontPath, unIndex, pFont));
|
||||
return pFont;
|
||||
}
|
||||
char* CDocument::GetTTFontTag()
|
||||
char* CDocument::GetTTFontTag()
|
||||
{
|
||||
if (0 == m_sTTFontTag[0])
|
||||
{
|
||||
@ -493,7 +488,7 @@ namespace PdfWriter
|
||||
|
||||
return m_sTTFontTag;
|
||||
}
|
||||
void CDocument::AddFreeTypeFont(CFontCidTrueType* pFont)
|
||||
void CDocument::AddFreeTypeFont(CFontCidTrueType* pFont)
|
||||
{
|
||||
for (int nIndex = 0, nCount = m_vFreeTypeFonts.size(); nIndex < nCount; nIndex++)
|
||||
{
|
||||
@ -521,14 +516,15 @@ namespace PdfWriter
|
||||
m_vFreeTypeFonts.erase(m_vFreeTypeFonts.begin() + MAX_OPENED_FT_FACES, m_vFreeTypeFonts.end());
|
||||
}
|
||||
}
|
||||
FT_Library CDocument::GetFreeTypeLibrary()
|
||||
FT_Library CDocument::GetFreeTypeLibrary()
|
||||
{
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
if (!m_pFreeTypeLibrary)
|
||||
FT_Init_FreeType(&m_pFreeTypeLibrary);
|
||||
|
||||
#endif
|
||||
return m_pFreeTypeLibrary;
|
||||
}
|
||||
CJbig2Global* CDocument::GetJbig2Global()
|
||||
CJbig2Global* CDocument::GetJbig2Global()
|
||||
{
|
||||
if (m_pJbig2 && m_pJbig2->GetImagesCount() > 4)
|
||||
{
|
||||
@ -542,7 +538,7 @@ namespace PdfWriter
|
||||
|
||||
return m_pJbig2;
|
||||
}
|
||||
CShading* CDocument::CreateShading(CPage* pPage, double *pPattern, bool bAxial, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState)
|
||||
CShading* CDocument::CreateShading(CPage* pPage, double *pPattern, bool bAxial, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState)
|
||||
{
|
||||
pExtGrState = NULL;
|
||||
|
||||
@ -632,7 +628,7 @@ namespace PdfWriter
|
||||
|
||||
return pColorShading;
|
||||
}
|
||||
CShading* CDocument::CreateAxialShading(double dX0, double dY0, double dX1, double dY1, unsigned char* pColors, double* pPoints, int nCount)
|
||||
CShading* CDocument::CreateAxialShading(double dX0, double dY0, double dX1, double dY1, unsigned char* pColors, double* pPoints, int nCount)
|
||||
{
|
||||
for (int nIndex = 0, nShadingsCount = m_vShadings.size(); nIndex < nShadingsCount; nIndex++)
|
||||
{
|
||||
@ -655,7 +651,7 @@ namespace PdfWriter
|
||||
|
||||
return pShading;
|
||||
}
|
||||
CShading* CDocument::CreateRadialShading(double dX0, double dY0, double dR0, double dX1, double dY1, double dR1, unsigned char* pColors, double* pPoints, int nCount)
|
||||
CShading* CDocument::CreateRadialShading(double dX0, double dY0, double dR0, double dX1, double dY1, double dR1, unsigned char* pColors, double* pPoints, int nCount)
|
||||
{
|
||||
for (int nIndex = 0, nShadingsCount = m_vShadings.size(); nIndex < nShadingsCount; nIndex++)
|
||||
{
|
||||
@ -710,12 +706,12 @@ namespace PdfWriter
|
||||
|
||||
return CreateImageTilePattern(dW, dH, pImage, NULL, imagetilepatterntype_Default);
|
||||
}
|
||||
CShading* CDocument::CreateAxialShading(CPage* pPage, double dX0, double dY0, double dX1, double dY1, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState)
|
||||
CShading* CDocument::CreateAxialShading(CPage* pPage, double dX0, double dY0, double dX1, double dY1, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState)
|
||||
{
|
||||
double pPattern[] ={ dX0, dY0, dX1, dY1 };
|
||||
return CreateShading(pPage, pPattern, true, pColors, pAlphas, pPoints, nCount, pExtGrState);
|
||||
}
|
||||
CShading* CDocument::CreateRadialShading(CPage* pPage, double dX0, double dY0, double dR0, double dX1, double dY1, double dR1, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState)
|
||||
CShading* CDocument::CreateRadialShading(CPage* pPage, double dX0, double dY0, double dR0, double dX1, double dY1, double dR1, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState)
|
||||
{
|
||||
double pPattern[] ={ dX0, dY0, dR0, dX1, dY1, dR1 };
|
||||
return CreateShading(pPage, pPattern, false, pColors, pAlphas, pPoints, nCount, pExtGrState);
|
||||
|
||||
@ -90,8 +90,7 @@ namespace PdfWriter
|
||||
void Close();
|
||||
bool SaveToFile(const std::wstring& wsPath);
|
||||
|
||||
void SetEncryptionMode(EEncryptMode eMode, unsigned int unKeyLen = 0);
|
||||
void SetPassword(const char* sOwnerPassword, const char* sUserPassword);
|
||||
void SetPasswords(const std::wstring & wsOwnerPassword, const std::wstring & wsUserPassword);
|
||||
void SetPermission(unsigned int unPermission);
|
||||
void SetCompressionMode(unsigned int unMode);
|
||||
|
||||
|
||||
@ -32,486 +32,296 @@
|
||||
#include "Encrypt.h"
|
||||
#include "Objects.h"
|
||||
|
||||
// Оптимизационные функции.
|
||||
#define OptFunc1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define OptFunc2(x, y, z) OptFunc1(z, x, y)
|
||||
#define OptFunc3(x, y, z) (x ^ y ^ z)
|
||||
#define OptFunc4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
// Основной шаг в алгоритме MD5.
|
||||
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
|
||||
#include "../../Common/3dParty/cryptopp/modes.h"
|
||||
#include "../../Common/3dParty/cryptopp/aes.h"
|
||||
#include "../../Common/3dParty/cryptopp/sha.h"
|
||||
#include "../../Common/3dParty/cryptopp/filters.h"
|
||||
#include "../../Common/3dParty/cryptopp/osrng.h"
|
||||
|
||||
namespace PdfWriter
|
||||
{
|
||||
static const BYTE c_sPaddingString[] =
|
||||
{
|
||||
0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41,
|
||||
0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
|
||||
0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80,
|
||||
0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A
|
||||
};
|
||||
static int SHA(int type, unsigned char *sMessage, int nMessageLen, unsigned char *sDigest)
|
||||
{
|
||||
int res = 0;
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
case 256:
|
||||
{
|
||||
CryptoPP::SHA256 hash;
|
||||
hash.Update( sMessage, nMessageLen > 0 ? nMessageLen : hash.DigestSize());
|
||||
|
||||
void PadOrTrancatePassword(const char* sPassword, BYTE* pNewPassword)
|
||||
{
|
||||
unsigned int unLen = StrLen(sPassword, PASSWD_LEN + 1);
|
||||
MemSet(pNewPassword, 0x00, PASSWD_LEN);
|
||||
CryptoPP::SecByteBlock buffer(res = hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
if (unLen >= PASSWD_LEN)
|
||||
MemCpy(pNewPassword, (BYTE*)sPassword, PASSWD_LEN);
|
||||
else
|
||||
memcpy(sDigest, buffer.data(), buffer.size());
|
||||
}break;
|
||||
case 1:
|
||||
case 384:
|
||||
{
|
||||
CryptoPP::SHA384 hash;
|
||||
hash.Update( sMessage, nMessageLen > 0 ? nMessageLen : hash.DigestSize());
|
||||
|
||||
CryptoPP::SecByteBlock buffer(res = hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(sDigest, buffer.data(), buffer.size());
|
||||
}break;
|
||||
case 2:
|
||||
case 512:
|
||||
{
|
||||
CryptoPP::SHA512 hash;
|
||||
hash.Update( sMessage, nMessageLen > 0 ? nMessageLen : hash.DigestSize());
|
||||
|
||||
CryptoPP::SecByteBlock buffer(res = hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(sDigest, buffer.data(), buffer.size());
|
||||
}break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
class CEncrypt::Impl
|
||||
{
|
||||
public:
|
||||
Impl() : streamEncryption(NULL), aesEncryption(NULL)
|
||||
{
|
||||
if (unLen > 0)
|
||||
MemCpy(pNewPassword, (BYTE*)sPassword, unLen);
|
||||
|
||||
MemCpy(pNewPassword + unLen, c_sPaddingString, PASSWD_LEN - unLen);
|
||||
MemSet(m_anEncryptionKey, 0, 32);
|
||||
}
|
||||
}
|
||||
// The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
// reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
// the data and converts bytes into longwords for this routine.
|
||||
static void MD5ByteReverse(BYTE *pBuf, unsigned int nLongs)
|
||||
{
|
||||
unsigned int nTemp = 0;
|
||||
do
|
||||
{
|
||||
nTemp = (unsigned int)((unsigned int)pBuf[3] << 8 | pBuf[2]) << 16 | ((unsigned int)pBuf[1] << 8 | pBuf[0]);
|
||||
*(unsigned int *)pBuf = nTemp;
|
||||
pBuf += 4;
|
||||
} while (--nLongs);
|
||||
}
|
||||
static void MD5Transform(unsigned int anBuf[4], const unsigned int anIn[16])
|
||||
{
|
||||
register unsigned int a, b, c, d;
|
||||
virtual ~Impl()
|
||||
{
|
||||
if (streamEncryption)
|
||||
delete streamEncryption;
|
||||
if (aesEncryption)
|
||||
delete aesEncryption;
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
unsigned char empty[16] = {};
|
||||
if (streamEncryption)
|
||||
delete streamEncryption;
|
||||
if (aesEncryption)
|
||||
delete aesEncryption;
|
||||
|
||||
a = anBuf[0];
|
||||
b = anBuf[1];
|
||||
c = anBuf[2];
|
||||
d = anBuf[3];
|
||||
aesEncryption = new CryptoPP::AES::Encryption(m_anEncryptionKey, 32);
|
||||
streamEncryption = new CryptoPP::CBC_Mode_ExternalCipher::Encryption( *aesEncryption, empty);
|
||||
}
|
||||
|
||||
MD5STEP(OptFunc1, a, b, c, d, anIn[0] + 0xd76aa478, 7);
|
||||
MD5STEP(OptFunc1, d, a, b, c, anIn[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(OptFunc1, c, d, a, b, anIn[2] + 0x242070db, 17);
|
||||
MD5STEP(OptFunc1, b, c, d, a, anIn[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(OptFunc1, a, b, c, d, anIn[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(OptFunc1, d, a, b, c, anIn[5] + 0x4787c62a, 12);
|
||||
MD5STEP(OptFunc1, c, d, a, b, anIn[6] + 0xa8304613, 17);
|
||||
MD5STEP(OptFunc1, b, c, d, a, anIn[7] + 0xfd469501, 22);
|
||||
MD5STEP(OptFunc1, a, b, c, d, anIn[8] + 0x698098d8, 7);
|
||||
MD5STEP(OptFunc1, d, a, b, c, anIn[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(OptFunc1, c, d, a, b, anIn[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(OptFunc1, b, c, d, a, anIn[11] + 0x895cd7be, 22);
|
||||
MD5STEP(OptFunc1, a, b, c, d, anIn[12] + 0x6b901122, 7);
|
||||
MD5STEP(OptFunc1, d, a, b, c, anIn[13] + 0xfd987193, 12);
|
||||
MD5STEP(OptFunc1, c, d, a, b, anIn[14] + 0xa679438e, 17);
|
||||
MD5STEP(OptFunc1, b, c, d, a, anIn[15] + 0x49b40821, 22);
|
||||
std::string m_sOwnerPassword;
|
||||
std::string m_sUserPassword;
|
||||
BYTE m_anEncryptionKey[32];
|
||||
|
||||
MD5STEP(OptFunc2, a, b, c, d, anIn[1] + 0xf61e2562, 5);
|
||||
MD5STEP(OptFunc2, d, a, b, c, anIn[6] + 0xc040b340, 9);
|
||||
MD5STEP(OptFunc2, c, d, a, b, anIn[11] + 0x265e5a51, 14);
|
||||
MD5STEP(OptFunc2, b, c, d, a, anIn[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(OptFunc2, a, b, c, d, anIn[5] + 0xd62f105d, 5);
|
||||
MD5STEP(OptFunc2, d, a, b, c, anIn[10] + 0x02441453, 9);
|
||||
MD5STEP(OptFunc2, c, d, a, b, anIn[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(OptFunc2, b, c, d, a, anIn[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(OptFunc2, a, b, c, d, anIn[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(OptFunc2, d, a, b, c, anIn[14] + 0xc33707d6, 9);
|
||||
MD5STEP(OptFunc2, c, d, a, b, anIn[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(OptFunc2, b, c, d, a, anIn[8] + 0x455a14ed, 20);
|
||||
MD5STEP(OptFunc2, a, b, c, d, anIn[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(OptFunc2, d, a, b, c, anIn[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(OptFunc2, c, d, a, b, anIn[7] + 0x676f02d9, 14);
|
||||
MD5STEP(OptFunc2, b, c, d, a, anIn[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(OptFunc3, a, b, c, d, anIn[5] + 0xfffa3942, 4);
|
||||
MD5STEP(OptFunc3, d, a, b, c, anIn[8] + 0x8771f681, 11);
|
||||
MD5STEP(OptFunc3, c, d, a, b, anIn[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(OptFunc3, b, c, d, a, anIn[14] + 0xfde5380c, 23);
|
||||
MD5STEP(OptFunc3, a, b, c, d, anIn[1] + 0xa4beea44, 4);
|
||||
MD5STEP(OptFunc3, d, a, b, c, anIn[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(OptFunc3, c, d, a, b, anIn[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(OptFunc3, b, c, d, a, anIn[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(OptFunc3, a, b, c, d, anIn[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(OptFunc3, d, a, b, c, anIn[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(OptFunc3, c, d, a, b, anIn[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(OptFunc3, b, c, d, a, anIn[6] + 0x04881d05, 23);
|
||||
MD5STEP(OptFunc3, a, b, c, d, anIn[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(OptFunc3, d, a, b, c, anIn[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(OptFunc3, c, d, a, b, anIn[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(OptFunc3, b, c, d, a, anIn[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(OptFunc4, a, b, c, d, anIn[0] + 0xf4292244, 6);
|
||||
MD5STEP(OptFunc4, d, a, b, c, anIn[7] + 0x432aff97, 10);
|
||||
MD5STEP(OptFunc4, c, d, a, b, anIn[14] + 0xab9423a7, 15);
|
||||
MD5STEP(OptFunc4, b, c, d, a, anIn[5] + 0xfc93a039, 21);
|
||||
MD5STEP(OptFunc4, a, b, c, d, anIn[12] + 0x655b59c3, 6);
|
||||
MD5STEP(OptFunc4, d, a, b, c, anIn[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(OptFunc4, c, d, a, b, anIn[10] + 0xffeff47d, 15);
|
||||
MD5STEP(OptFunc4, b, c, d, a, anIn[1] + 0x85845dd1, 21);
|
||||
MD5STEP(OptFunc4, a, b, c, d, anIn[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(OptFunc4, d, a, b, c, anIn[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(OptFunc4, c, d, a, b, anIn[6] + 0xa3014314, 15);
|
||||
MD5STEP(OptFunc4, b, c, d, a, anIn[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(OptFunc4, a, b, c, d, anIn[4] + 0xf7537e82, 6);
|
||||
MD5STEP(OptFunc4, d, a, b, c, anIn[11] + 0xbd3af235, 10);
|
||||
MD5STEP(OptFunc4, c, d, a, b, anIn[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(OptFunc4, b, c, d, a, anIn[9] + 0xeb86d391, 21);
|
||||
|
||||
anBuf[0] += a;
|
||||
anBuf[1] += b;
|
||||
anBuf[2] += c;
|
||||
anBuf[3] += d;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CMd5
|
||||
//----------------------------------------------------------------------------------------
|
||||
CMd5::CMd5()
|
||||
{
|
||||
Init();
|
||||
};
|
||||
void CMd5::Init()
|
||||
{
|
||||
m_anBuf[0] = 0x67452301;
|
||||
m_anBuf[1] = 0xefcdab89;
|
||||
m_anBuf[2] = 0x98badcfe;
|
||||
m_anBuf[3] = 0x10325476;
|
||||
|
||||
m_anBits[0] = 0;
|
||||
m_anBits[1] = 0;
|
||||
|
||||
MemSet(m_anIn, 0x00, 64 * sizeof(BYTE));
|
||||
}
|
||||
void CMd5::Update(const BYTE* pBuffer, unsigned int unLen)
|
||||
{
|
||||
// Update bitcount
|
||||
unsigned int nTempBit = m_anBits[0];
|
||||
|
||||
if ((m_anBits[0] = nTempBit + (unLen << 3)) < nTempBit)
|
||||
m_anBits[1]++; // Carry from low to high
|
||||
|
||||
m_anBits[1] += unLen >> 29;
|
||||
nTempBit = (nTempBit >> 3) & 0x3f; // Bytes already in shsInfo->data
|
||||
|
||||
// Handle any leading odd-sized chunks
|
||||
if (nTempBit)
|
||||
{
|
||||
BYTE *pTemp = (BYTE *)m_anIn + nTempBit;
|
||||
|
||||
nTempBit = 64 - nTempBit;
|
||||
if (unLen < nTempBit && pBuffer)
|
||||
{
|
||||
MemCpy(pTemp, pBuffer, unLen);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pBuffer)
|
||||
MemCpy(pTemp, pBuffer, nTempBit);
|
||||
|
||||
MD5ByteReverse(m_anIn, 16);
|
||||
MD5Transform(m_anBuf, (unsigned int *)m_anIn);
|
||||
pBuffer += nTempBit;
|
||||
unLen -= nTempBit;
|
||||
}
|
||||
|
||||
// Process data in 64-byte chunks
|
||||
while (unLen >= 64)
|
||||
{
|
||||
MemCpy(m_anIn, pBuffer, 64);
|
||||
MD5ByteReverse(m_anIn, 16);
|
||||
MD5Transform(m_anBuf, (unsigned int *)m_anIn);
|
||||
pBuffer += 64;
|
||||
unLen -= 64;
|
||||
}
|
||||
|
||||
// Handle any remaining bytes of data.
|
||||
MemCpy(m_anIn, pBuffer, unLen);
|
||||
}
|
||||
// Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
// 1 0* (64-bit count of bits processed, MSB-first)
|
||||
void CMd5::Final(BYTE anDigest[16])
|
||||
{
|
||||
// Вычисляем количество байтов по модулю 64
|
||||
unsigned int nCount = (m_anBits[0] >> 3) & 0x3F;
|
||||
|
||||
// Устанавливаем первый символ в дополнительной строке(padding) значением 0x80.
|
||||
// Это безопасно, поскольку всегда как минимум один байт свободен.
|
||||
BYTE *pTemp = m_anIn + nCount;
|
||||
*pTemp++ = 0x80;
|
||||
|
||||
// Bytes of padding needed to make 64 bytes
|
||||
nCount = 64 - 1 - nCount;
|
||||
|
||||
// Pad out to 56 mod 64
|
||||
if (nCount < 8)
|
||||
{
|
||||
// Two lots of padding: Pad the first block to 64 bytes
|
||||
MemSet(pTemp, 0, nCount);
|
||||
MD5ByteReverse(m_anIn, 16);
|
||||
MD5Transform(m_anBuf, (unsigned int *)m_anIn);
|
||||
|
||||
// Now fill the next block with 56 bytes
|
||||
MemSet(m_anIn, 0, 56);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pad block to 56 bytes
|
||||
MemSet(pTemp, 0, nCount - 8);
|
||||
}
|
||||
MD5ByteReverse(m_anIn, 14);
|
||||
|
||||
// Append length in bits and transform
|
||||
((unsigned int *)m_anIn)[14] = m_anBits[0];
|
||||
((unsigned int *)m_anIn)[15] = m_anBits[1];
|
||||
|
||||
MD5Transform(m_anBuf, (unsigned int *)m_anIn);
|
||||
MD5ByteReverse((BYTE *)m_anBuf, 4);
|
||||
MemCpy((BYTE *)anDigest, (BYTE *)m_anBuf, 16);
|
||||
Clear(); // In case it's sensitive
|
||||
}
|
||||
void CMd5::Clear()
|
||||
{
|
||||
MemSet(m_anBits, 0, 2 * sizeof(unsigned int));
|
||||
MemSet(m_anBuf, 0, 4 * sizeof(unsigned int));
|
||||
MemSet(m_anIn, 0x00, 64 * sizeof(BYTE));
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CArc4
|
||||
//----------------------------------------------------------------------------------------
|
||||
void CArc4::Init(const BYTE* pKey, unsigned int unKeyLen)
|
||||
{
|
||||
BYTE pTempArray[ARC4_BUF_SIZE];
|
||||
unsigned int nJ = 0;
|
||||
|
||||
for (unsigned int nIndex = 0; nIndex < ARC4_BUF_SIZE; nIndex++)
|
||||
m_anState[nIndex] = nIndex;
|
||||
|
||||
for (unsigned int nIndex = 0; nIndex < ARC4_BUF_SIZE; nIndex++)
|
||||
pTempArray[nIndex] = pKey[nIndex % unKeyLen];
|
||||
|
||||
for (unsigned int nIndex = 0; nIndex < ARC4_BUF_SIZE; nIndex++)
|
||||
{
|
||||
nJ = (nJ + m_anState[nIndex] + pTempArray[nIndex]) % ARC4_BUF_SIZE;
|
||||
|
||||
BYTE nTemp = m_anState[nIndex];
|
||||
m_anState[nIndex] = m_anState[nJ];
|
||||
m_anState[nJ] = nTemp;
|
||||
}
|
||||
|
||||
m_nIndex1 = 0;
|
||||
m_nIndex2 = 0;
|
||||
}
|
||||
void CArc4::CryptBuf(const BYTE* pIn, BYTE* pOut, unsigned int unLen)
|
||||
{
|
||||
for (unsigned int nIndex = 0; nIndex < unLen; nIndex++)
|
||||
{
|
||||
m_nIndex1 = (m_nIndex1 + 1) % 256;
|
||||
m_nIndex2 = (m_nIndex2 + m_anState[m_nIndex1]) % 256;
|
||||
|
||||
BYTE nTemp = m_anState[m_nIndex1];
|
||||
m_anState[m_nIndex1] = m_anState[m_nIndex2];
|
||||
m_anState[m_nIndex2] = nTemp;
|
||||
|
||||
unsigned int nTempIndex = (m_anState[m_nIndex1] + m_anState[m_nIndex2]) % 256;
|
||||
BYTE nKoef = m_anState[nTempIndex];
|
||||
|
||||
pOut[nIndex] = pIn[nIndex] ^ nKoef;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CEncrypt
|
||||
//----------------------------------------------------------------------------------------
|
||||
CEncrypt::CEncrypt()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
void CEncrypt::Init()
|
||||
{
|
||||
m_eMode = encryptmode_R2;
|
||||
m_unKeyLen = 5;
|
||||
MemCpy(m_anOwnerPassword, c_sPaddingString, PASSWD_LEN);
|
||||
MemCpy(m_anUserPassword, c_sPaddingString, PASSWD_LEN);
|
||||
CryptoPP::AES::Encryption *aesEncryption;
|
||||
CryptoPP::StreamTransformation *streamEncryption;
|
||||
};
|
||||
CEncrypt::CEncrypt() : m_unKeyLen(32)
|
||||
{
|
||||
impl = new Impl();
|
||||
|
||||
m_unPermission = ENABLE_PRINT | ENABLE_EDIT_ALL | ENABLE_COPY | ENABLE_EDIT | PERMISSION_PAD;
|
||||
|
||||
MemSet(m_anOwnerKey, 0, PASSWD_LEN);
|
||||
MemSet(m_anUserKey, 0, PASSWD_LEN);
|
||||
|
||||
MemSet(m_anEncryptID, 0, ID_LEN);
|
||||
MemSet(m_anEncryptionKey, 0, MD5_KEY_LEN + 5);
|
||||
MemSet(m_anMD5EncryptionKey, 0, MD5_KEY_LEN);
|
||||
}
|
||||
void CEncrypt::CreateUserKey()
|
||||
CEncrypt::~CEncrypt()
|
||||
{
|
||||
delete impl;
|
||||
}
|
||||
void CEncrypt::SetPasswords(const std::string &sUserPassword, const std::string &sOwnerPassword)
|
||||
{
|
||||
impl->m_sUserPassword = sUserPassword;
|
||||
impl->m_sOwnerPassword = sOwnerPassword;
|
||||
}
|
||||
bool CEncrypt::MakeFileKey3(const std::string &sPassword, unsigned char *pHash, int nHashSize, unsigned char *pHash2, int nHashSize2)
|
||||
{
|
||||
if (!pHash) return false;
|
||||
|
||||
int size = 64 * (sPassword.length() + 64 + nHashSize2); // max
|
||||
|
||||
unsigned char K[64]; //max size sha
|
||||
unsigned char *K1 = new unsigned char[size];
|
||||
unsigned char *E = new unsigned char[size];
|
||||
|
||||
int hash_size = nHashSize;
|
||||
memcpy(K, pHash, nHashSize);
|
||||
|
||||
int iteration = 0;
|
||||
|
||||
while( (iteration < 64) || (iteration < E[size - 1] + 32))
|
||||
{
|
||||
size = 0;
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
memcpy(K1 + size, sPassword.c_str(), sPassword.length()); size += sPassword.length();
|
||||
memcpy(K1 + size, K, hash_size); size += hash_size;
|
||||
if (pHash2)
|
||||
{
|
||||
memcpy(K1 + size, pHash2, nHashSize2); size += nHashSize2;
|
||||
}
|
||||
}
|
||||
|
||||
CryptoPP::AES::Encryption aesEncryption(K, 16);
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, K + 16);
|
||||
|
||||
CryptoPP::StreamTransformationFilter stfEncryption(cbcEncryption, new CryptoPP::ArraySink( E, size), CryptoPP::StreamTransformationFilter::NO_PADDING);
|
||||
|
||||
stfEncryption.Put( K1, size);
|
||||
stfEncryption.MessageEnd();
|
||||
//----------------------------------------------------------
|
||||
int E_mod_3 = 0;
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
{
|
||||
E_mod_3 += E[i];
|
||||
}
|
||||
E_mod_3 %= 3;
|
||||
|
||||
hash_size = SHA(E_mod_3, E, size, K);
|
||||
|
||||
iteration++;
|
||||
}
|
||||
|
||||
delete []K1;
|
||||
delete []E;
|
||||
|
||||
memcpy (pHash, K, 32); // pHash - from sha256
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEncrypt::CreateUserKey()
|
||||
{
|
||||
CArc4 oContext;
|
||||
CryptoPP::RandomPool prng;
|
||||
|
||||
// Algorithm 3.4/5 step1
|
||||
// Algorithm 3.4 step2
|
||||
oContext.Init(m_anEncryptionKey, m_unKeyLen);
|
||||
oContext.CryptBuf(c_sPaddingString, m_anUserKey, PASSWD_LEN);
|
||||
CryptoPP::SecByteBlock salt(16);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, salt, salt.size());
|
||||
prng.IncorporateEntropy(salt, salt.size());
|
||||
|
||||
if (encryptmode_R3 == m_eMode)
|
||||
{
|
||||
CMd5 oMmd5;
|
||||
BYTE anDigest[MD5_KEY_LEN];
|
||||
BYTE anDigest2[MD5_KEY_LEN];
|
||||
memcpy(m_anUserKey + 32, salt.data(), salt.size());
|
||||
|
||||
// Algorithm 3.5 step2 (same as Algorithm3.2 step2)
|
||||
oMmd5.Init();
|
||||
oMmd5.Update(c_sPaddingString, PASSWD_LEN);
|
||||
CryptoPP::SHA256 hash;
|
||||
|
||||
// Algorithm 3.5 step3
|
||||
oMmd5.Update(m_anEncryptID, ID_LEN);
|
||||
oMmd5.Final(anDigest);
|
||||
hash.Update( (unsigned char*) impl->m_sUserPassword.c_str(), impl->m_sUserPassword.length());
|
||||
hash.Update( m_anUserKey + 32, 8);
|
||||
|
||||
// Algorithm 3.5 step4
|
||||
oContext.Init(m_anEncryptionKey, m_unKeyLen);
|
||||
oContext.CryptBuf(anDigest, anDigest2, MD5_KEY_LEN);
|
||||
CryptoPP::SecByteBlock pHashData(hash.DigestSize());
|
||||
hash.Final(pHashData);
|
||||
|
||||
// Algorithm 3.5 step5
|
||||
for (unsigned int nI = 1; nI <= 19; nI++)
|
||||
{
|
||||
BYTE pNewKey[MD5_KEY_LEN];
|
||||
for (unsigned int nJ = 0; nJ < m_unKeyLen; nJ++)
|
||||
pNewKey[nJ] = m_anEncryptionKey[nJ] ^ nI;
|
||||
if (MakeFileKey3(impl->m_sUserPassword, pHashData.data(), pHashData.size()))
|
||||
{
|
||||
memcpy(m_anUserKey, pHashData.data(), pHashData.size());
|
||||
|
||||
MemCpy(anDigest, anDigest2, MD5_KEY_LEN);
|
||||
hash.Update( (unsigned char*) impl->m_sUserPassword.c_str(), impl->m_sUserPassword.length());
|
||||
hash.Update( m_anUserKey + 40, 8);
|
||||
|
||||
oContext.Init(pNewKey, m_unKeyLen);
|
||||
oContext.CryptBuf(anDigest, anDigest2, MD5_KEY_LEN);
|
||||
}
|
||||
CryptoPP::SecByteBlock pHashKeyData(hash.DigestSize());
|
||||
hash.Final(pHashKeyData);
|
||||
|
||||
// use the result of Algorithm 3.4 as 'arbitrary padding'
|
||||
MemSet(m_anUserKey, 0, PASSWD_LEN);
|
||||
MemCpy(m_anUserKey, anDigest2, MD5_KEY_LEN);
|
||||
}
|
||||
MakeFileKey3(impl->m_sUserPassword, pHashKeyData.data(), pHashKeyData.size());
|
||||
unsigned char empty[16] = {};
|
||||
|
||||
CryptoPP::AES::Encryption aesEncryption(pHashKeyData.data(), pHashKeyData.size());
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, empty);
|
||||
|
||||
CryptoPP::StreamTransformationFilter stfEncryption(cbcEncryption, new CryptoPP::ArraySink( m_anUserEncryptKey, 32), CryptoPP::StreamTransformationFilter::NO_PADDING );
|
||||
stfEncryption.Put2(impl->m_anEncryptionKey, 32, 1, true);
|
||||
stfEncryption.MessageEnd();
|
||||
}
|
||||
}
|
||||
void CEncrypt::CreateOwnerKey()
|
||||
{
|
||||
CArc4 oArc4;
|
||||
CMd5 oMd5;
|
||||
CryptoPP::RandomPool prng;
|
||||
|
||||
BYTE anDigest[MD5_KEY_LEN];
|
||||
BYTE anTempPassword[PASSWD_LEN];
|
||||
CryptoPP::SecByteBlock salt(16);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, salt, salt.size());
|
||||
prng.IncorporateEntropy(salt, salt.size());
|
||||
|
||||
// create md5-digest using the value of anOwnerPassword
|
||||
// Algorithm 3.3 step 2
|
||||
oMd5.Init();
|
||||
oMd5.Update(m_anOwnerPassword, PASSWD_LEN);
|
||||
oMd5.Final(anDigest);
|
||||
memcpy(m_anOwnerKey + 32, salt.data(), salt.size());
|
||||
|
||||
// Algorithm 3.3 step 3 (Revision 3 only)
|
||||
if (encryptmode_R3 == m_eMode)
|
||||
{
|
||||
for (unsigned int nIndex = 0; nIndex < 50; nIndex++)
|
||||
{
|
||||
oMd5.Init();
|
||||
oMd5.Update(anDigest, m_unKeyLen);
|
||||
oMd5.Final(anDigest);
|
||||
}
|
||||
}
|
||||
CryptoPP::SHA256 hash;
|
||||
|
||||
// Algorithm 3.3 step 4
|
||||
oArc4.Init(anDigest, m_unKeyLen);
|
||||
hash.Update( (unsigned char*) impl->m_sOwnerPassword.c_str(), impl->m_sOwnerPassword.length());
|
||||
hash.Update( m_anOwnerKey + 32, 8);
|
||||
hash.Update( m_anUserKey, 48);
|
||||
|
||||
// Algorithm 3.3 step 6
|
||||
oArc4.CryptBuf(m_anUserPassword, anTempPassword, PASSWD_LEN);
|
||||
CryptoPP::SecByteBlock pHashData(hash.DigestSize());
|
||||
hash.Final(pHashData);
|
||||
|
||||
// Algorithm 3.3 step 7
|
||||
if (encryptmode_R3 == m_eMode)
|
||||
{
|
||||
BYTE anTempPassword2[PASSWD_LEN];
|
||||
if (MakeFileKey3(impl->m_sOwnerPassword, pHashData.data(), pHashData.size(), m_anUserKey, 48))
|
||||
{
|
||||
memcpy(m_anOwnerKey, pHashData.data(), pHashData.size());
|
||||
|
||||
for (unsigned int i = 1; i <= 19; i++)
|
||||
{
|
||||
BYTE anNewKey[MD5_KEY_LEN];
|
||||
hash.Update( (unsigned char*) impl->m_sOwnerPassword.c_str(), impl->m_sOwnerPassword.length());
|
||||
hash.Update( m_anOwnerKey + 40, 8);
|
||||
hash.Update( m_anUserKey, 48);
|
||||
|
||||
for (unsigned int j = 0; j < m_unKeyLen; j++)
|
||||
anNewKey[j] = anDigest[j] ^ i;
|
||||
CryptoPP::SecByteBlock pHashKeyData(hash.DigestSize());
|
||||
hash.Final(pHashKeyData);
|
||||
|
||||
MemCpy(anTempPassword2, anTempPassword, PASSWD_LEN);
|
||||
oArc4.Init(anNewKey, m_unKeyLen);
|
||||
oArc4.CryptBuf(anTempPassword2, anTempPassword, PASSWD_LEN);
|
||||
}
|
||||
}
|
||||
MakeFileKey3(impl->m_sOwnerPassword, pHashKeyData.data(), pHashKeyData.size(), m_anUserKey, 48);
|
||||
unsigned char empty[16] = {};
|
||||
|
||||
// Algorithm 3.3 step 8
|
||||
MemCpy(m_anOwnerKey, anTempPassword, PASSWD_LEN);
|
||||
CryptoPP::AES::Encryption aesEncryption(pHashKeyData.data(), pHashKeyData.size());
|
||||
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, empty);
|
||||
|
||||
CryptoPP::StreamTransformationFilter stfEncryption(cbcEncryption, new CryptoPP::ArraySink( m_anOwnerEncryptKey, 32), CryptoPP::StreamTransformationFilter::NO_PADDING );
|
||||
stfEncryption.Put2(impl->m_anEncryptionKey, 32, 1, true);
|
||||
stfEncryption.MessageEnd();
|
||||
}
|
||||
}
|
||||
void CEncrypt::CreateEncryptionKey()
|
||||
{
|
||||
CMd5 oMd5;
|
||||
BYTE anTempFlag[4];
|
||||
CryptoPP::RandomPool prng;
|
||||
|
||||
// Algorithm3.2 step2
|
||||
oMd5.Init();
|
||||
oMd5.Update(m_anUserPassword, PASSWD_LEN);
|
||||
CryptoPP::SecByteBlock key(32);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, key, key.size());
|
||||
prng.IncorporateEntropy(key, key.size());
|
||||
|
||||
// Algorithm3.2 step3
|
||||
oMd5.Update(m_anOwnerKey, PASSWD_LEN);
|
||||
memcpy(impl->m_anEncryptionKey, key.data(), key.size());
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
unsigned long long extended_perms = 0xffffffff00000000LL | m_unPermission;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
m_anPermEncrypt[i] = static_cast<unsigned char>(extended_perms & 0xff);
|
||||
extended_perms >>= 8;
|
||||
}
|
||||
m_anPermEncrypt[8] = /*m_bEncryptMetadata ? 'T' : */'F';
|
||||
m_anPermEncrypt[9] = 'a';
|
||||
m_anPermEncrypt[10] = 'd';
|
||||
m_anPermEncrypt[11] = 'b';
|
||||
|
||||
CryptoPP::SecByteBlock p(4);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, p, p.size());
|
||||
prng.IncorporateEntropy(p, p.size());
|
||||
|
||||
// Algorithm3.2 step4
|
||||
anTempFlag[0] = m_unPermission;
|
||||
anTempFlag[1] = (m_unPermission >> 8);
|
||||
anTempFlag[2] = (m_unPermission >> 16);
|
||||
anTempFlag[3] = (m_unPermission >> 24);
|
||||
memcpy(m_anPermEncrypt + 12, p.data(), p.size());
|
||||
|
||||
oMd5.Update(anTempFlag, 4);
|
||||
unsigned char empty[16] = {};
|
||||
|
||||
CryptoPP::AES::Encryption aesEncryption(impl->m_anEncryptionKey, 32);
|
||||
|
||||
CryptoPP::CipherModeFinalTemplate_ExternalCipher<CryptoPP::ECB_OneWay> ecbEncryption(aesEncryption, empty );
|
||||
|
||||
// Algorithm3.2 step5
|
||||
oMd5.Update(m_anEncryptID, ID_LEN);
|
||||
oMd5.Final(m_anEncryptionKey);
|
||||
|
||||
// Algorithm 3.2 step6 (Revision 3 only)
|
||||
if (encryptmode_R3 == m_eMode)
|
||||
{
|
||||
for (unsigned int nIndex = 0; nIndex < 50; nIndex++)
|
||||
{
|
||||
oMd5.Init();
|
||||
oMd5.Update(m_anEncryptionKey, m_unKeyLen);
|
||||
oMd5.Final(m_anEncryptionKey);
|
||||
}
|
||||
}
|
||||
CryptoPP::StreamTransformationFilter stfEncryption(ecbEncryption, new CryptoPP::ArraySink( m_anPermEncrypt, 16), CryptoPP::StreamTransformationFilter::NO_PADDING );
|
||||
stfEncryption.Put2(m_anPermEncrypt, 16, 1, true);
|
||||
stfEncryption.MessageEnd();
|
||||
}
|
||||
void CEncrypt::InitKey(unsigned int unObjectId, unsigned short unGenNo)
|
||||
{
|
||||
m_anEncryptionKey[m_unKeyLen + 0] = (BYTE) unObjectId;
|
||||
m_anEncryptionKey[m_unKeyLen + 1] = (BYTE)(unObjectId >> 8);
|
||||
m_anEncryptionKey[m_unKeyLen + 2] = (BYTE)(unObjectId >> 16);
|
||||
m_anEncryptionKey[m_unKeyLen + 3] = (BYTE) unGenNo;
|
||||
m_anEncryptionKey[m_unKeyLen + 4] = (BYTE)(unGenNo >> 8);
|
||||
|
||||
CMd5 oMd5;
|
||||
oMd5.Init();
|
||||
oMd5.Update(m_anEncryptionKey, m_unKeyLen + 5);
|
||||
oMd5.Final(m_anMD5EncryptionKey);
|
||||
|
||||
unsigned int unKeyLen = (m_unKeyLen + 5 > ENCRYPT_KEY_MAX) ? ENCRYPT_KEY_MAX : m_unKeyLen + 5;
|
||||
m_oArc4Context.Init(m_anMD5EncryptionKey, unKeyLen);
|
||||
}
|
||||
void CEncrypt::Reset()
|
||||
{
|
||||
unsigned int unKeyLen = (m_unKeyLen + 5 > ENCRYPT_KEY_MAX) ? ENCRYPT_KEY_MAX : m_unKeyLen + 5;
|
||||
m_oArc4Context.Init(m_anMD5EncryptionKey, unKeyLen);
|
||||
{
|
||||
impl->Reset();
|
||||
}
|
||||
void CEncrypt::CryptBuf(const BYTE* pSrc, BYTE* pDst, unsigned int unLen)
|
||||
void CEncrypt::CryptBuf(const BYTE* pSrc, BYTE* pDst, unsigned int unLen, bool bLast)
|
||||
{
|
||||
m_oArc4Context.CryptBuf(pSrc, pDst, unLen);
|
||||
}
|
||||
CryptoPP::StreamTransformationFilter stfEncryption(*impl->streamEncryption, new CryptoPP::ArraySink( pDst, unLen), CryptoPP::StreamTransformationFilter::ZEROS_PADDING );
|
||||
|
||||
stfEncryption.Put2(pSrc, unLen, bLast ? 1 : 0, true);
|
||||
stfEncryption.MessageEnd();
|
||||
}
|
||||
void CEncrypt::SetPermission(unsigned int unPermission)
|
||||
{
|
||||
m_unPermission = unPermission;
|
||||
}
|
||||
void CEncrypt::SetMode(EEncryptMode eMode, unsigned int unKeyLen)
|
||||
{
|
||||
if (encryptmode_R2 == eMode)
|
||||
m_unKeyLen = 5;
|
||||
else
|
||||
{
|
||||
if (unKeyLen >= 5 && unKeyLen <= 16)
|
||||
m_unKeyLen = unKeyLen;
|
||||
else
|
||||
m_unKeyLen = 16;
|
||||
}
|
||||
|
||||
m_eMode = eMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,85 +35,41 @@
|
||||
#include "Utils.h"
|
||||
|
||||
#define ID_LEN 16
|
||||
#define PASSWD_LEN 32
|
||||
#define ENCRYPT_KEY_MAX 16
|
||||
#define MD5_KEY_LEN 16
|
||||
#define PERMISSION_PAD 0xFFFFFFC0
|
||||
#define ARC4_BUF_SIZE 256
|
||||
|
||||
namespace PdfWriter
|
||||
{
|
||||
void PadOrTrancatePassword(const char *sPassword, BYTE *pNewPassword);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//
|
||||
// The code implements MD5 message-digest algorithm.
|
||||
// To compute the message digest of a chunk of bytes, declare an
|
||||
// MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
// needed on buffers full of bytes, and then call MD5Final, which
|
||||
// will fill a supplied 16-byte array with the digest.
|
||||
//
|
||||
//----------------------------------------------------------------------------------------
|
||||
class CMd5
|
||||
{
|
||||
public:
|
||||
|
||||
CMd5();
|
||||
void Init();
|
||||
void Update(const BYTE* pBuffer, unsigned int unLen);
|
||||
void Final(BYTE anDigest[16]);
|
||||
|
||||
private:
|
||||
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
|
||||
unsigned int m_anBuf[4];
|
||||
unsigned int m_anBits[2];
|
||||
BYTE m_anIn[64];
|
||||
};
|
||||
class CArc4
|
||||
{
|
||||
public:
|
||||
|
||||
void Init(const BYTE* pKey, unsigned int unKeyLen);
|
||||
void CryptBuf(const BYTE* pIn, BYTE* pOut, unsigned int unLen);
|
||||
|
||||
private:
|
||||
BYTE m_nIndex1;
|
||||
BYTE m_nIndex2;
|
||||
BYTE m_anState[ARC4_BUF_SIZE];
|
||||
};
|
||||
class CEncrypt
|
||||
{
|
||||
public:
|
||||
|
||||
CEncrypt();
|
||||
CEncrypt();
|
||||
virtual ~CEncrypt();
|
||||
|
||||
void Init();
|
||||
void CreateUserKey();
|
||||
void CreateOwnerKey();
|
||||
void CreateEncryptionKey();
|
||||
void InitKey(unsigned int unObjectId, unsigned short unGenNo);
|
||||
void Reset();
|
||||
void CryptBuf(const BYTE* pSrc, BYTE* pDst, unsigned int unLen);
|
||||
void CryptBuf(const BYTE* pSrc, BYTE* pDst, unsigned int unLen, bool bLast);
|
||||
void SetPermission(unsigned int unPermission);
|
||||
void SetMode(EEncryptMode eMode, unsigned int unKeyLen);
|
||||
|
||||
void SetPasswords(const std::string &sUserPassword, const std::string &sOwnerPassword);
|
||||
private:
|
||||
class Impl;
|
||||
Impl *impl;
|
||||
|
||||
EEncryptMode m_eMode;
|
||||
unsigned int m_unKeyLen; // unKeyLen должно быть кратно 8, и лежать в отрезке от 40 и до 128
|
||||
BYTE m_anOwnerPassword[PASSWD_LEN]; // Owner-Password (не шифрованный)
|
||||
BYTE m_anUserPassword[PASSWD_LEN]; // User-Password (не шифрованный)
|
||||
BYTE m_anOwnerKey[PASSWD_LEN]; // Owner-Password (шифрованный)
|
||||
BYTE m_anUserKey[PASSWD_LEN]; // User-Password (шифрованный)
|
||||
unsigned int m_unPermission;
|
||||
BYTE m_anEncryptID[ID_LEN];
|
||||
BYTE m_anEncryptionKey[MD5_KEY_LEN + 5];
|
||||
BYTE m_anMD5EncryptionKey[MD5_KEY_LEN];
|
||||
CArc4 m_oArc4Context;
|
||||
bool MakeFileKey3(const std::string &sPassword, unsigned char *pHash, int nHashSize, unsigned char *pHash2 = NULL, int nHashSize2 = 0);
|
||||
|
||||
unsigned int m_unKeyLen;
|
||||
|
||||
BYTE m_anOwnerKey[48]; //O
|
||||
BYTE m_anUserKey[48]; //U
|
||||
BYTE m_anOwnerEncryptKey[32]; //OE
|
||||
BYTE m_anUserEncryptKey[32]; //UE
|
||||
unsigned int m_unPermission; //P
|
||||
BYTE m_anPermEncrypt[16]; //Perm
|
||||
|
||||
BYTE m_anEncryptID[ID_LEN];
|
||||
|
||||
friend class CEncryptDict;
|
||||
friend class CDocument;
|
||||
|
||||
@ -35,16 +35,17 @@
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "../../Common/3dParty/cryptopp/md5.h"
|
||||
#include "../../UnicodeConverter/UnicodeConverter.h"
|
||||
|
||||
namespace PdfWriter
|
||||
{
|
||||
//----------------------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CEncryptDict
|
||||
//----------------------------------------------------------------------------------------
|
||||
CEncryptDict::CEncryptDict(CXref* pXref)
|
||||
{
|
||||
m_pEncrypt = new CEncrypt();
|
||||
if (m_pEncrypt)
|
||||
m_pEncrypt->Init();
|
||||
|
||||
pXref->Add(this);
|
||||
}
|
||||
@ -55,11 +56,10 @@ namespace PdfWriter
|
||||
}
|
||||
void CEncryptDict::CreateId(CInfoDict* pInfo, CXref* pXref)
|
||||
{
|
||||
CMd5 oMd5;
|
||||
oMd5.Init();
|
||||
CryptoPP::MD5 hash;
|
||||
|
||||
std::time_t oTime = time(0);
|
||||
oMd5.Update((BYTE*)&oTime, sizeof(oTime));
|
||||
hash.Update( (BYTE*)&oTime, sizeof(oTime));
|
||||
|
||||
// Создаем идентификатор файла по элементам библиотеки Info.
|
||||
if (pInfo)
|
||||
@ -70,82 +70,107 @@ namespace PdfWriter
|
||||
// Author
|
||||
sTemp = pInfo->GetInfo(InfoAuthor);
|
||||
if ((nLen = StrLen(sTemp, -1)) > 0)
|
||||
oMd5.Update((const BYTE *)sTemp, nLen);
|
||||
hash.Update( (const BYTE *)sTemp, nLen );
|
||||
|
||||
// Creator
|
||||
sTemp = pInfo->GetInfo(InfoCreator);
|
||||
if ((nLen = StrLen(sTemp, -1)) > 0)
|
||||
oMd5.Update((const BYTE *)sTemp, nLen);
|
||||
hash.Update( (const BYTE *)sTemp, nLen);
|
||||
|
||||
// Producer
|
||||
sTemp = pInfo->GetInfo(InfoProducer);
|
||||
if ((nLen = StrLen(sTemp, -1)) > 0)
|
||||
oMd5.Update((const BYTE *)sTemp, nLen);
|
||||
hash.Update( (const BYTE *)sTemp, nLen);
|
||||
|
||||
// Title
|
||||
sTemp = pInfo->GetInfo(InfoTitle);
|
||||
if ((nLen = StrLen(sTemp, -1)) > 0)
|
||||
oMd5.Update((const BYTE *)sTemp, nLen);
|
||||
hash.Update( (const BYTE *)sTemp, nLen);
|
||||
|
||||
// Subject
|
||||
sTemp = pInfo->GetInfo(InfoSubject);
|
||||
if ((nLen = StrLen(sTemp, -1)) > 0)
|
||||
oMd5.Update((const BYTE *)sTemp, nLen);
|
||||
hash.Update( (const BYTE *)sTemp, nLen);
|
||||
|
||||
// Keywords
|
||||
sTemp = pInfo->GetInfo(InfoKeyWords);
|
||||
if ((nLen = StrLen(sTemp, -1)) > 0)
|
||||
oMd5.Update((const BYTE *)sTemp, nLen);
|
||||
hash.Update( (const BYTE *)sTemp, nLen);
|
||||
|
||||
int nXrefEntriesCount = pXref->GetCount();
|
||||
oMd5.Update((const BYTE *)&nXrefEntriesCount, sizeof(unsigned int));
|
||||
hash.Update( (const BYTE *)&nXrefEntriesCount, sizeof(unsigned int));
|
||||
|
||||
}
|
||||
oMd5.Final(m_pEncrypt->m_anEncryptID);
|
||||
CryptoPP::SecByteBlock buffer(hash.DigestSize());
|
||||
hash.Final(buffer);
|
||||
|
||||
memcpy(m_pEncrypt->m_anEncryptID, buffer.BytePtr(), buffer.size());
|
||||
}
|
||||
std::string CEncryptDict::PadOrTrancatePassword(const std::wstring & wsPassword)
|
||||
{
|
||||
NSUnicodeConverter::CUnicodeConverter conv;
|
||||
std::string sNewPassword = conv.SASLprepToUtf8(wsPassword);
|
||||
|
||||
if (sNewPassword.length() > 127)
|
||||
sNewPassword = sNewPassword.substr(0, 127);
|
||||
|
||||
return sNewPassword;
|
||||
}
|
||||
void CEncryptDict::SetPassword(const char* sOwnerPassword, const char* sUserPassword)
|
||||
void CEncryptDict::SetPasswords(const std::wstring & wsOwnerPassword, const std::wstring & wsUserPassword)
|
||||
{
|
||||
if (0 == StrLen(sOwnerPassword, 2))
|
||||
return;
|
||||
std::string sOwnerPassword = PadOrTrancatePassword(wsOwnerPassword);
|
||||
std::string sUserPassword = PadOrTrancatePassword(wsUserPassword);
|
||||
|
||||
if (sOwnerPassword && sUserPassword && 0 == StrCmp(sOwnerPassword, sUserPassword))
|
||||
return;
|
||||
|
||||
PadOrTrancatePassword(sOwnerPassword, m_pEncrypt->m_anOwnerPassword);
|
||||
PadOrTrancatePassword(sUserPassword, m_pEncrypt->m_anUserPassword);
|
||||
m_pEncrypt->SetPasswords(sUserPassword, sOwnerPassword);
|
||||
}
|
||||
void CEncryptDict::Prepare(CInfoDict* pInfo, CXref* pXref)
|
||||
{
|
||||
CreateId(pInfo, pXref);
|
||||
|
||||
m_pEncrypt->CreateOwnerKey();
|
||||
m_pEncrypt->CreateEncryptionKey();
|
||||
m_pEncrypt->CreateUserKey();
|
||||
m_pEncrypt->CreateEncryptionKey();
|
||||
m_pEncrypt->CreateUserKey();
|
||||
m_pEncrypt->CreateOwnerKey();
|
||||
|
||||
CBinaryObject* pOwnerKey = new CBinaryObject(m_pEncrypt->m_anOwnerKey, PASSWD_LEN);
|
||||
if (!pOwnerKey)
|
||||
return;
|
||||
Add("Filter", "Standard");
|
||||
Add("V", 5);
|
||||
Add("Length", m_pEncrypt->m_unKeyLen * 8);
|
||||
Add("R", 6);
|
||||
Add("P", m_pEncrypt->m_unPermission);
|
||||
|
||||
Add("O", pOwnerKey);
|
||||
CDictObject* pCF = new CDictObject();
|
||||
|
||||
CDictObject* pStdCF = new CDictObject();
|
||||
pCF->Add("StdCF", pStdCF);
|
||||
|
||||
CBinaryObject* pUserKey = new CBinaryObject(m_pEncrypt->m_anUserKey, PASSWD_LEN);
|
||||
if (!pUserKey)
|
||||
return;
|
||||
pStdCF->Add("CFM", "AESV3");
|
||||
pStdCF->Add("AuthEvent", "DocOpen");
|
||||
pStdCF->Add("Length", m_pEncrypt->m_unKeyLen);
|
||||
|
||||
Add("U", pUserKey);
|
||||
Add("CF", pCF);
|
||||
|
||||
Add("Filter", "Standard");
|
||||
if (encryptmode_R2 == m_pEncrypt->m_eMode)
|
||||
{
|
||||
Add("V", 1);
|
||||
Add("R", 2);
|
||||
}
|
||||
else if (encryptmode_R3 == m_pEncrypt->m_eMode)
|
||||
{
|
||||
Add("V", 2);
|
||||
Add("R", 3);
|
||||
Add("Length", m_pEncrypt->m_unKeyLen * 8);
|
||||
}
|
||||
Add("P", m_pEncrypt->m_unPermission);
|
||||
}
|
||||
}
|
||||
CBinaryObject* pUserKey = new CBinaryObject(m_pEncrypt->m_anUserKey, 48);
|
||||
if (!pUserKey)
|
||||
return;
|
||||
|
||||
CBinaryObject* pUserEncryptKey = new CBinaryObject(m_pEncrypt->m_anUserEncryptKey, 32);
|
||||
if (!pUserKey)
|
||||
return;
|
||||
|
||||
Add("U", pUserKey);
|
||||
Add("UE", pUserEncryptKey);
|
||||
|
||||
CBinaryObject* pOwnerKey = new CBinaryObject(m_pEncrypt->m_anOwnerKey, 48);
|
||||
if (!pOwnerKey)
|
||||
return;
|
||||
|
||||
CBinaryObject* pOwnerEncryptKey = new CBinaryObject(m_pEncrypt->m_anOwnerEncryptKey, 32);
|
||||
if (!pOwnerKey)
|
||||
return;
|
||||
|
||||
Add("O", pOwnerKey);
|
||||
Add("OE", pOwnerEncryptKey);
|
||||
|
||||
CBinaryObject* pEncryptPerm = new CBinaryObject(m_pEncrypt->m_anPermEncrypt, 16);
|
||||
Add("Perms", pEncryptPerm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ namespace PdfWriter
|
||||
}
|
||||
|
||||
void CreateId(CInfoDict* pInfo, CXref* pXref);
|
||||
void SetPassword(const char* sOwnerPassword, const char* sUserPassword);
|
||||
void SetPasswords(const std::wstring & wsOwnerPassword, const std::wstring & wsUserPassword);
|
||||
void Prepare(CInfoDict* pInfo, CXref* pXref);
|
||||
CEncrypt* GetEncrypt() const
|
||||
{
|
||||
@ -58,6 +58,7 @@ namespace PdfWriter
|
||||
}
|
||||
private:
|
||||
CEncrypt* m_pEncrypt;
|
||||
std::string PadOrTrancatePassword(const std::wstring & wsPassword);
|
||||
};
|
||||
}
|
||||
#endif // _PDF_WRITER_SRC_ENCRYPT_DICTIONARY_H
|
||||
|
||||
@ -55,13 +55,14 @@ namespace PdfWriter
|
||||
if (!pFace)
|
||||
return nCharIndex;
|
||||
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
|
||||
for (int nIndex = 0; nIndex < pFace->num_charmaps; nIndex++)
|
||||
{
|
||||
FT_CharMap pCharMap = pFace->charmaps[nIndex];
|
||||
|
||||
if (FT_Set_Charmap(pFace, pCharMap))
|
||||
continue;
|
||||
|
||||
FT_Encoding pEncoding = pCharMap->encoding;
|
||||
|
||||
if (FT_ENCODING_UNICODE == pEncoding)
|
||||
@ -87,11 +88,13 @@ namespace PdfWriter
|
||||
nCharIndex = FT_Get_Char_Index( pFace, unUnicode );
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
return nCharIndex;
|
||||
}
|
||||
static int GetSymbolicCmapIndex(FT_Face pFace)
|
||||
static int GetSymbolicCmapIndex(FT_Face pFace)
|
||||
{
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
TT_OS2 *pOs2 = (TT_OS2 *)FT_Get_Sfnt_Table(pFace, ft_sfnt_os2);
|
||||
if (NULL == pOs2 || 0xFFFF == pOs2->version)
|
||||
return -1;
|
||||
@ -107,7 +110,7 @@ namespace PdfWriter
|
||||
if (0 == pFace->charmaps[nIndex]->encoding_id && 3 == pFace->charmaps[nIndex]->platform_id)
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
@ -151,13 +154,14 @@ namespace PdfWriter
|
||||
if (m_pFontFile)
|
||||
delete m_pFontFile;
|
||||
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
if (m_pFace)
|
||||
FT_Done_Face(m_pFace);
|
||||
|
||||
#endif
|
||||
if (m_pFaceMemory)
|
||||
delete[] m_pFaceMemory;
|
||||
}
|
||||
void CFontCidTrueType::CreateCIDFont2(CDictObject* pFont)
|
||||
void CFontCidTrueType::CreateCIDFont2(CDictObject* pFont)
|
||||
{
|
||||
m_pFont = pFont;
|
||||
pFont->Add("Subtype", "CIDFontType2");
|
||||
@ -273,6 +277,7 @@ namespace PdfWriter
|
||||
// Данный символ используется
|
||||
m_mGlyphs.insert(std::pair<unsigned int, bool>(unGID, true));
|
||||
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
// Если данный символ составной (CompositeGlyf), тогда мы должны учесть все его дочерные символы (subglyfs)
|
||||
if (0 == FT_Load_Glyph(m_pFace, unGID, FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE))
|
||||
{
|
||||
@ -293,8 +298,8 @@ namespace PdfWriter
|
||||
else
|
||||
m_vWidths.push_back((unsigned int)m_pFace->glyph->metrics.horiAdvance);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
pEncodedString[2 * unIndex + 0] = (ushCode >> 8) & 0xFF;
|
||||
pEncodedString[2 * unIndex + 1] = ushCode & 0xFF;
|
||||
}
|
||||
@ -307,7 +312,7 @@ namespace PdfWriter
|
||||
|
||||
return m_vWidths.at(ushCode);
|
||||
}
|
||||
void CFontCidTrueType::BeforeWrite()
|
||||
void CFontCidTrueType::BeforeWrite()
|
||||
{
|
||||
if (m_pFontFile)
|
||||
{
|
||||
@ -349,7 +354,7 @@ namespace PdfWriter
|
||||
WriteToUnicode();
|
||||
}
|
||||
}
|
||||
bool CFontCidTrueType::GetWidthsAndGids(unsigned short** ppCodeToGid, unsigned int** ppWidths, unsigned char** ppGlyphs, unsigned int& unGlyphsCount)
|
||||
bool CFontCidTrueType::GetWidthsAndGids(unsigned short** ppCodeToGid, unsigned int** ppWidths, unsigned char** ppGlyphs, unsigned int& unGlyphsCount)
|
||||
{
|
||||
*ppCodeToGid = NULL;
|
||||
*ppWidths = NULL;
|
||||
@ -397,7 +402,7 @@ namespace PdfWriter
|
||||
unGlyphsCount = m_nGlyphsCount;
|
||||
return true;
|
||||
}
|
||||
void CFontCidTrueType::WriteToUnicode()
|
||||
void CFontCidTrueType::WriteToUnicode()
|
||||
{
|
||||
CStream* pS = m_pToUnicodeStream;
|
||||
|
||||
@ -433,17 +438,19 @@ namespace PdfWriter
|
||||
pS->WriteStr("endbfchar\n");
|
||||
m_pToUnicodeStream->WriteStr(c_sToUnicodeFooter);
|
||||
}
|
||||
void CFontCidTrueType::CloseFontFace()
|
||||
void CFontCidTrueType::CloseFontFace()
|
||||
{
|
||||
if (m_pFace)
|
||||
{
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
FT_Done_Face(m_pFace);
|
||||
m_pFace = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(m_pFaceMemory);
|
||||
}
|
||||
bool CFontCidTrueType::OpenFontFace()
|
||||
bool CFontCidTrueType::OpenFontFace()
|
||||
{
|
||||
if (m_pFace)
|
||||
{
|
||||
@ -464,7 +471,9 @@ namespace PdfWriter
|
||||
if (!m_pFaceMemory)
|
||||
return false;
|
||||
|
||||
#ifndef TEST_PDFWRITER_LIB
|
||||
FT_New_Memory_Face(pLibrary, m_pFaceMemory, dwFileSize, m_unFontIndex, &m_pFace);
|
||||
#endif
|
||||
if (!m_pFace)
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pFaceMemory);
|
||||
|
||||
@ -81,7 +81,7 @@ namespace PdfWriter
|
||||
|
||||
return (const char*)pString->GetString();
|
||||
}
|
||||
void CInfoDict::SetInfo(EInfoType eType, const TDate& oDate)
|
||||
void CInfoDict::SetInfo(EInfoType eType, const TDate& oDate)
|
||||
{
|
||||
char sTemp[DATE_TIME_STR_LEN + 1];
|
||||
char* pTemp = NULL;
|
||||
@ -151,7 +151,7 @@ namespace PdfWriter
|
||||
|
||||
Add(sName, new CStringObject(sTemp));
|
||||
}
|
||||
void CInfoDict::SetCreationTime()
|
||||
void CInfoDict::SetCreationTime()
|
||||
{
|
||||
time_t oTime = time(0);
|
||||
struct tm* oNow = localtime(&oTime);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user