Compare commits

...

18 Commits

Author SHA1 Message Date
ddb67584b8 . 2017-06-14 12:14:10 +03:00
38ce5586bb ooxml signing developing... 2017-06-13 18:25:58 +03:00
f6d9ce83f0 . 2017-06-13 17:29:31 +03:00
03edd40850 Pptx binary - write notes & master notes 2017-06-13 15:38:13 +03:00
9ff87b3c6b Merge tag 'v4.3.6' into develop
v4.3.6 v4.3.6
2017-06-13 15:28:45 +03:00
645cbef1ef . 2017-06-09 17:46:00 +03:00
02238f7eea Fixed bug with drawing a char with negative size of the font. 2017-06-09 15:11:47 +03:00
907e00a3ac . 2017-06-09 12:19:35 +03:00
2470bfd335 Fixed bug with caching fonts for different pages. Fixed bug with drawing a text. 2017-06-09 11:25:56 +03:00
3ae52bd221 . 2017-06-08 18:15:43 +03:00
227d4f18d6 . 2017-06-08 17:24:17 +03:00
36bdbad685 for bug 27765
external OleLink/DdeLink
2017-06-08 17:08:08 +03:00
525b828540 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  TextParagraphPr swap marR/marL
  .
  .
  .
  Use `uname -m` for determine linux x64\x686
  Add travis example config
  .
2017-06-08 15:48:04 +03:00
f64ee80a1a add event 2017-06-08 15:47:56 +03:00
f6402813c4 TextParagraphPr swap marR/marL 2017-06-08 13:19:53 +03:00
224ac7d6e2 . 2017-06-07 18:53:35 +03:00
2e2bd8989d . 2017-06-07 18:39:24 +03:00
9e867be756 Merge branch 'hotfix/v4.3.5' 2017-06-05 16:48:24 +03:00
53 changed files with 2627 additions and 1387 deletions

1
.gitignore vendored
View File

@ -20,6 +20,7 @@ Common/3dParty/v8/win_32
Common/3dParty/v8/linux_64
Common/3dParty/v8/linux_32
Common/3dParty/v8/mac_64
Common/3dParty/openssl/openssl
**/core_build
**/Release
**/Debug

View File

@ -1115,6 +1115,16 @@ namespace NSBinPptxRW
m_pWriter->WriteString(str);
}
std::wstring s = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"../theme/theme" +
std::to_wstring(nIndexTheme + 1) + L".xml\"/>";
m_pWriter->WriteString(s);
}
void CRelsGenerator::StartNotesMaster(int nIndexTheme)
{
m_pWriter->WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
m_pWriter->WriteString(_T("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"));
std::wstring s = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"../theme/theme" +
std::to_wstring(nIndexTheme + 1) + L".xml\"/>";
@ -1130,7 +1140,7 @@ namespace NSBinPptxRW
std::to_wstring(nIndexTheme + 1) + L".xml\"/>";
m_pWriter->WriteString(str);
}
void CRelsGenerator::StartSlide(int nIndexSlide, int nIndexLayout)
void CRelsGenerator::StartSlide(int nIndexSlide, int nIndexLayout, int nIndexNotes)
{
m_pWriter->WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
m_pWriter->WriteString(_T("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"));
@ -1140,12 +1150,15 @@ namespace NSBinPptxRW
std::to_wstring(nIndexLayout + 1) + L".xml\"/>";
m_pWriter->WriteString(str);
str = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide\" Target=\"../notesSlides/notesSlide" +
std::to_wstring(nIndexSlide + 1) + L".xml\"/>";
if (nIndexNotes >= 0)
{
str = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide\" Target=\"../notesSlides/notesSlide" +
std::to_wstring(nIndexNotes + 1) + L".xml\"/>";
}
m_pWriter->WriteString(str);
}
void CRelsGenerator::StartNote(int nIndexSlide)
void CRelsGenerator::StartNotes(int nIndexSlide)
{
m_pWriter->WriteString(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>");
m_pWriter->WriteString(L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");

View File

@ -407,8 +407,9 @@ namespace NSBinPptxRW
void StartMaster (int nIndexTheme, const _slideMasterInfo& oInfo);
void StartLayout (int nIndexTheme);
void StartSlide (int nIndexSlide, int nIndexLayout);
void StartNote (int nIndexSlide);
void StartSlide (int nIndexSlide, int nIndexLayout, int nIndexNotes);
void StartNotes (int nIndexSlide);
void StartNotesMaster(int nIndexTheme);
void WriteMasters (int nCount);
void WriteThemes (int nCount);

View File

@ -162,8 +162,7 @@ namespace PPTX2EditorAdvanced
}
// записываем все слайды
size_t nCount = presentation->sldIdLst.size();
for (size_t i = 0; i < nCount; ++i)
for (size_t i = 0; i < presentation->sldIdLst.size(); ++i)
{
std::wstring rId = presentation->sldIdLst[i].rid.get();
smart_ptr<PPTX::Slide> slide = ((*presentation)[rId]).smart_dynamic_cast<PPTX::Slide>();

View File

@ -58,10 +58,12 @@ namespace NSBinPptxRW
std::vector<PPTX::Slide> m_arSlides;
std::vector<LONG> m_arSlides_Layout;
std::vector<LONG> m_arSlides_Notes;
std::vector<PPTX::NotesMaster> m_arNotesMasters;
std::vector<PPTX::NotesSlide> m_arNotesSlides;
std::vector<LONG> m_arNotesSlides_Master;
std::vector<LONG> m_arNotesMasters_Theme;
PPTX::Presentation m_oPresentation;
PPTX::TableStyles m_oTableStyles;
@ -175,10 +177,9 @@ namespace NSBinPptxRW
std::map<BYTE, LONG>::iterator pPair;
// writer
CXmlWriter oXmlWriter;
// первым делом определим количество необходимого. если хоть одно из этих чисел - ноль, то ппту не корректный
// первым делом определим количество необходимого. если хоть одно из этих чисел - ноль, то ппту не корректный
LONG nCountThemes = 0;
LONG nCountMasters = 0;
LONG nCountLayouts = 0;
@ -214,7 +215,7 @@ namespace NSBinPptxRW
return;
}
// теперь создадим массивы для рельсов
// теперь создадим массивы для рельсов
for (LONG i = 0; i < nCountMasters; ++i)
{
_slideMasterInfo elm;
@ -226,8 +227,11 @@ namespace NSBinPptxRW
}
for (LONG i = 0; i < nCountSlides; ++i)
m_arSlides_Layout.push_back(0);
for (LONG i = 0; i < nCountSlides; ++i)
m_arSlides_Notes.push_back(-1);
// ThemeRels
// ThemeRels
pPair = m_mainTables.find(NSMainTables::ThemeRels);
if (m_mainTables.end() != pPair)
{
@ -242,7 +246,7 @@ namespace NSBinPptxRW
}
}
// нужно проставить всем шаблонам мастер.
// нужно проставить всем шаблонам мастер.
for (LONG i = 0; i < nCountMasters; ++i)
{
size_t _countL = m_arSlideMasters_Theme[i].m_arLayouts.size();
@ -252,7 +256,7 @@ namespace NSBinPptxRW
}
}
// готово, теперь нужно слайдам проставить шаблоны
// готово, теперь нужно слайдам проставить шаблоны
pPair = m_mainTables.find(NSMainTables::SlideRels);
if (m_mainTables.end() != pPair)
{
@ -271,11 +275,46 @@ namespace NSBinPptxRW
m_arSlides_Layout[index++] = m_oReader.GetULong();
}
}
pPair = m_mainTables.find(NSMainTables::SlideNotesRels);
if (m_mainTables.end() != pPair)
{
m_oReader.Seek(pPair->second);
m_oReader.Skip(6); // type + len + start attr
// теперь нужно удалить все themes, которые не ведут на мастерслайд
size_t index =0;
while (true)
{
BYTE _at = m_oReader.GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
//m_arSlides_Layout[_at] = m_oReader.GetULong(); тут прописан не индекс, а тип - смотри - oBinaryWriter.WriteInt1(0, oBinaryWriter.m_pCommon->m_oSlide_Layout_Rels[i]);
if (index < m_arSlides_Notes.size())
m_arSlides_Notes[index++] = m_oReader.GetULong();
}
}
pPair = m_mainTables.find(NSMainTables::NotesMastersRels);
if (m_mainTables.end() != pPair)
{
m_oReader.Seek(pPair->second);
m_oReader.Skip(6); // type + len + start attr
size_t index =0;
while (true)
{
BYTE _at = m_oReader.GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
m_arNotesMasters_Theme.push_back( m_oReader.GetULong());
}
}
// теперь нужно удалить все themes, которые не ведут на мастерслайды
std::vector<LONG> arThemes;
std::vector<LONG> arThemesDst;
std::vector<bool> arThemesSave;
for (LONG i = 0; i < nCountThemes; ++i)
{
arThemes.push_back(i);
@ -286,6 +325,11 @@ namespace NSBinPptxRW
{
arThemesSave[m_arSlideMasters_Theme[i].m_lThemeIndex] = true;
}
for (size_t i = 0; i < m_arNotesMasters_Theme.size(); i++)
{
arThemesSave[m_arNotesMasters_Theme[i]] = true;
}
LONG lCurrectTheme = 0;
for (LONG i = 0; i < nCountMasters; ++i)
{
@ -298,9 +342,8 @@ namespace NSBinPptxRW
for (LONG i = 0; i < nCountMasters; ++i)
{
m_arSlideMasters_Theme[i].m_lThemeIndex = arThemesDst[i];
}
// themes
}
// themes
pPair = m_mainTables.find(NSMainTables::Themes);
if (m_mainTables.end() != pPair)
{
@ -343,7 +386,7 @@ namespace NSBinPptxRW
}
}
// slideMasters
// slideMasters
pPair = m_mainTables.find(NSMainTables::SlideMasters);
if (m_mainTables.end() != pPair)
{
@ -396,7 +439,7 @@ namespace NSBinPptxRW
}
}
// slideLayouts
// slideLayouts
pPair = m_mainTables.find(NSMainTables::SlideLayouts);
if (m_mainTables.end() != pPair)
{
@ -431,8 +474,99 @@ namespace NSBinPptxRW
m_oReader.m_pRels->SaveRels(pathFileRels.GetPath());
}
}
// notes
pPair = m_mainTables.find(NSMainTables::NotesSlides);
if (m_mainTables.end() != pPair)
{
m_oReader.Seek(pPair->second);
LONG lCount = m_oReader.GetLong();
// slides
if ( lCount > 0 )
{
OOX::CPath pathFolder = m_strDstFolder + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("notesSlides");
OOX::CPath pathFolderRels = pathFolder + FILE_SEPARATOR_STR + _T("_rels");
NSDirectory::CreateDirectory (pathFolder.GetPath());
NSDirectory::CreateDirectory (pathFolderRels.GetPath());
for (LONG i = 0; i < lCount; ++i)
{
PPTX::NotesSlide elm;
m_arNotesSlides.push_back(elm);
m_oReader.m_pRels->Clear();
size_t indexSlide = 0;
for (indexSlide = 0; indexSlide < m_arSlides_Notes.size(); indexSlide++)
{//todooo -> make map
if (m_arSlides_Notes[indexSlide] == i)
{
break;
}
}
m_oReader.m_pRels->StartNotes(indexSlide);
m_arNotesSlides[i].fromPPTY(&m_oReader);
m_oReader.m_pRels->CloseRels();
std::wstring strNotesXml = L"notesSlide" + std::to_wstring(i + 1) + L".xml";
oXmlWriter.ClearNoAttack();
m_arNotesSlides[i].toXmlWriter(&oXmlWriter);
OOX::CPath pathFile = pathFolder + FILE_SEPARATOR_STR + strNotesXml;
oXmlWriter.SaveToFile(pathFile.GetPath());
OOX::CPath pathFileRels = pathFolderRels + FILE_SEPARATOR_STR + strNotesXml + _T(".rels");
m_oReader.m_pRels->SaveRels(pathFileRels.GetPath());
}
}
}
// noteMasters
pPair = m_mainTables.find(NSMainTables::NotesMasters);
if (m_mainTables.end() != pPair)
{
m_oReader.Seek(pPair->second);
LONG lCount = m_oReader.GetLong();
if (lCount > 0 || m_arNotesSlides.size() > 0)//один элемент
{
OOX::CPath pathFolder = m_strDstFolder + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("notesMasters");
OOX::CPath pathFolderRels = pathFolder + FILE_SEPARATOR_STR + _T("_rels");
NSDirectory::CreateDirectory(pathFolder.GetPath());
NSDirectory::CreateDirectory(pathFolderRels.GetPath());
PPTX::NotesMaster elm;
m_arNotesMasters.push_back(elm);
m_oReader.m_pRels->Clear();
m_oReader.m_pRels->StartNotesMaster(m_arSlideMasters_Theme.size());
if (lCount > 0)
{
m_arNotesMasters.back().fromPPTY(&m_oReader);
m_oReader.m_pRels->CloseRels();
std::wstring strMasterNotesXml = L"notesMaster1.xml";
oXmlWriter.ClearNoAttack();
m_arNotesMasters.back().toXmlWriter(&oXmlWriter);
OOX::CPath pathFile = pathFolder + FILE_SEPARATOR_STR + strMasterNotesXml;
oXmlWriter.SaveToFile(pathFile.GetPath());
OOX::CPath pathFileRels = pathFolderRels + FILE_SEPARATOR_STR + strMasterNotesXml + _T(".rels");
m_oReader.m_pRels->SaveRels(pathFileRels.GetPath());
}
else
{
CreateDefaultNotesMasters(m_arSlideMasters_Theme.size());
}
}
}
// slides
int nComment = 1;
pPair = m_mainTables.find(NSMainTables::Slides);
if (m_mainTables.end() != pPair)
@ -452,7 +586,7 @@ namespace NSBinPptxRW
m_arSlides.push_back(elm);
m_oReader.m_pRels->Clear();
m_oReader.m_pRels->StartSlide(i, m_arSlides_Layout[i]);
m_oReader.m_pRels->StartSlide(i, m_arSlides_Layout[i], m_arSlides_Notes[i]);
m_arSlides[i].fromPPTY(&m_oReader);
if (m_arSlides[i].comments.is_init())
@ -488,71 +622,6 @@ namespace NSBinPptxRW
m_oReader.m_pRels->SaveRels(pathFileRels.GetPath());
}
}
if (false)
{
// noteMasters
pPair = m_mainTables.find(NSMainTables::NotesMasters);
if (m_mainTables.end() != pPair)
{
m_oReader.Seek(pPair->second);
LONG lCount = m_oReader.GetLong();
for (LONG i = 0; i < lCount; ++i)
{
PPTX::NotesMaster elm;
m_arNotesMasters.push_back(elm);
m_arNotesMasters[i].fromPPTY(&m_oReader);
}
}
// notes
pPair = m_mainTables.find(NSMainTables::NotesSlides);
if (m_mainTables.end() != pPair)
{
m_oReader.Seek(pPair->second);
LONG lCount = m_oReader.GetLong();
for (LONG i = 0; i < lCount; ++i)
{
PPTX::NotesSlide elm;
m_arNotesSlides.push_back(elm);
m_arNotesSlides[i].fromPPTY(&m_oReader);
}
}
}
else
{
// create default
CreateDefaultNotesMasters((int)m_arThemes.size() + 1);
CreateDefaultNote();
OOX::CPath pathFolder = m_strDstFolder + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("notesSlides");
OOX::CPath pathFolderRels = pathFolder + FILE_SEPARATOR_STR + _T("_rels");
NSDirectory::CreateDirectory (pathFolder.GetPath());
NSDirectory::CreateDirectory (pathFolderRels.GetPath());
LONG lCount = (LONG)m_arSlides.size();
for (LONG i = 0; i < lCount; ++i)
{
m_oReader.m_pRels->Clear();
m_oReader.m_pRels->StartNote(i);
m_oReader.m_pRels->CloseRels();
std::wstring strMasterXml = L"notesSlide" + std::to_wstring(i + 1) + L".xml";
oXmlWriter.ClearNoAttack();
m_oDefaultNote.toXmlWriter(&oXmlWriter);
OOX::CPath pathFile = pathFolder + FILE_SEPARATOR_STR + strMasterXml;
oXmlWriter.SaveToFile(pathFile.GetPath());
OOX::CPath pathFileRels = pathFolderRels + FILE_SEPARATOR_STR + strMasterXml + _T(".rels");
m_oReader.m_pRels->SaveRels(pathFileRels.GetPath());
}
}
if (false)
{
// app
@ -595,15 +664,13 @@ namespace NSBinPptxRW
m_oViewProps.fromPPTY(&m_oReader);
}
//CreateDefaultPresProps();
}
else
{
// create default
CreateDefaultApp();
CreateDefaultCore();
//CreateDefaultPresProps();
//CreateDefaultTableStyles();
CreateDefaultViewProps();
// presProps
@ -760,15 +827,13 @@ namespace NSBinPptxRW
pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.extended-properties+xml", L"/docProps", L"app.xml");
// themes
for (LONG i = 0; i < (LONG)m_arThemes.size(); ++i)
for (size_t i = 0; i < m_arThemes.size(); ++i)
{
pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.theme+xml", L"/ppt/theme", L"theme" + std::to_wstring(i + 1) + L".xml");
}
if (true)
{
// notes theme
pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.theme+xml", L"/ppt/theme", L"theme" + std::to_wstring((int)m_arThemes.size() + 1) + L".xml");
// notes master
if (!m_arNotesMasters.empty())
{
pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml", L"/ppt/notesMasters", L"notesMaster1.xml");
}
@ -785,13 +850,13 @@ namespace NSBinPptxRW
}
// slides
for (LONG i = 0; i < nCountSlides; ++i)
for (size_t i = 0; i < m_arSlides.size(); ++i)
{
pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml", L"/ppt/slides", L"slide" + std::to_wstring(i + 1) + L".xml");
}
// notes
for (LONG i = 0; i < nCountSlides; ++i)
for (size_t i = 0; i < m_arNotesSlides.size(); ++i)
{
pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml", L"/ppt/notesSlides", L"notesSlide" + std::to_wstring(i + 1) + L".xml");
}

View File

@ -44,7 +44,11 @@ namespace PPTX
{
public:
WritingElement_AdditionConstructors(ClrMap)
PPTX_LOGIC_BASE2(ClrMap)
ClrMap(std::wstring name = L"p:clrMap")
{
m_name = name;
}
virtual OOX::EElementType getType() const
{

View File

@ -137,7 +137,7 @@ namespace PPTX
pWriter->WriteLimit2(4, m_oDrawAspect);
pWriter->WriteLimit2(5, m_oType);
pWriter->WriteLimit2(6, m_oUpdateMode);
if (ole_file.IsInit() == false || ole_file->isMsPackage() == false)
if (ole_file.IsInit() && ole_file->isMsPackage() == false)
{
std::wstring sExt = ole_file->filename().GetExtention(false);
if (!sExt.empty())

View File

@ -46,9 +46,9 @@ namespace PPTX
public:
WritingElement_AdditionConstructors(TextListStyle)
TextListStyle()
TextListStyle(std::wstring name = L"a:lstStyle")
{
m_name = L"a:lstStyle";
m_name = name;
}
virtual void fromXML(XmlUtils::CXmlNode& node)

View File

@ -189,8 +189,8 @@ namespace PPTX
WritingElement_ReadAttributes_Read_else_if( oReader, _T("lvl"), lvl)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("algn"), algn)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("fontAlgn"),fontAlgn)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marL"), marR)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marR"), marL)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marL"), marL)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("marR"), marR)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("indent"), indent)
WritingElement_ReadAttributes_Read_else_if( oReader, _T("defTabSz"),defTabSz)
WritingElement_ReadAttributes_End ( oReader )
@ -541,4 +541,4 @@ namespace PPTX
} // namespace Logic
} // namespace PPTX
#endif // PPTX_LOGIC_TEXTPARAGRAPHPR_INCLUDE_H_
#endif // PPTX_LOGIC_TEXTPARAGRAPHPR_INCLUDE_H_

View File

@ -131,11 +131,11 @@ namespace PPTX
pWriter->StartAttributes();
pWriter->WriteAttribute(_T("xmlns:a"), PPTX::g_Namespaces.a.m_strLink);
pWriter->WriteAttribute(_T("xmlns:r"), PPTX::g_Namespaces.r.m_strLink);
pWriter->WriteAttribute(_T("xmlns:m"), PPTX::g_Namespaces.m.m_strLink);
pWriter->WriteAttribute(_T("xmlns:w"), PPTX::g_Namespaces.w.m_strLink);
pWriter->WriteAttribute(_T("xmlns:p"), PPTX::g_Namespaces.p.m_strLink);
pWriter->EndAttributes();
cSld.toXmlWriter(pWriter);
clrMap.toXmlWriter(pWriter);
pWriter->Write(hf);
pWriter->Write(notesStyle);
@ -172,7 +172,7 @@ namespace PPTX
}
case 3:
{
notesStyle = new Logic::TextListStyle();
notesStyle = new Logic::TextListStyle(L"p:notesStyle");
notesStyle->fromPPTY(pReader);
break;
}

View File

@ -0,0 +1,12 @@
#!/bin/bash
export PATH=`pwd`/depot_tools:"$PATH"
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd "$SCRIPTPATH"/openssl
perl ./Configure linux-64
./config
make

View File

@ -0,0 +1,8 @@
#!/bin/bash
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd "$SCRIPTPATH"
git clone https://github.com/openssl/openssl.git

View File

@ -1099,6 +1099,14 @@ namespace OOX
et_x_ExternalSheetData,
et_x_ExternalRow,
et_x_ExternalCell,
et_x_OleLink,
et_x_OleItems,
et_x_OleItem,
et_x_DdeLink,
et_x_DdeItems,
et_x_DdeItem,
et_x_DdeValues,
et_x_DdeValue,
et_x_Selection,
et_x_LegacyDrawingWorksheet,
et_x_LegacyDrawingHFWorksheet,

View File

@ -68,7 +68,35 @@ namespace OOX
return type().DefaultFileName();
}
};
class ExternalOleObject : public External
{
public:
ExternalOleObject()
{
}
ExternalOleObject(const CPath& uri)
{
read(uri);
}
~ExternalOleObject()
{
}
public:
virtual const FileType type() const
{
return OOX::FileTypes::OleObject;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
};
}// namespace Spreadsheet
} // namespace OOX
#endif // OOX_EXTERNALLINKPATH_INCLUDE_H_
#endif // OOX_EXTERNALLINKPATH_INCLUDE_H_

View File

@ -76,8 +76,8 @@ namespace OOX
writer.WriteString(L"<sheetNames>");
for (size_t i = 0; i < m_arrItems.size(); ++i)
{
writer.WriteString(L"<sheetName ");
writer.WriteEncodeXmlString(m_arrItems[i]->ToString());
writer.WriteString(L"<sheetName");
WritingStringAttrEncodeXmlString(L"val", m_arrItems[i]->ToString2());
writer.WriteString(L"/>");
}
writer.WriteString(L"</sheetNames>");
@ -552,6 +552,529 @@ namespace OOX
nullable<CExternalSheetDataSet > m_oSheetDataSet;
};
class CDdeValue : public WritingElementWithChilds<CText>
{
public:
WritingElement_AdditionConstructors(CDdeValue)
CDdeValue()
{
}
virtual ~CDdeValue()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"val" == sName)
{
m_arrItems.push_back(new CText(oReader));
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<value");
WritingStringNullableAttrString(L"t", m_oType, m_oType->ToString());
writer.WriteString(L">");
for (size_t i = 0; i < m_arrItems.size(); ++i)
{
m_arrItems[i]->toXML2(writer, L"val");
}
writer.WriteString(L"</value>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_DdeValue;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("t"), m_oType )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::Spreadsheet::CDdeValueType<> > m_oType;
};
class CDdeValues : public WritingElementWithChilds<CDdeValue>
{
public:
WritingElement_AdditionConstructors(CDdeValues)
CDdeValues()
{
}
virtual ~CDdeValues()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"value" == sName)
{
m_arrItems.push_back(new CDdeValue(oReader));
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<values");
WritingStringNullableAttrInt(L"rows", m_oRows, m_oRows->GetValue());
WritingStringNullableAttrInt(L"cols", m_oCols, m_oCols->GetValue());
writer.WriteString(L">");
for (size_t i = 0; i < m_arrItems.size(); ++i)
{
m_arrItems[i]->toXML(writer);
}
writer.WriteString(L"</values>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_DdeValues;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("rows"), m_oRows )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cols"), m_oCols )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRows;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCols;
};
class CDdeItem : public WritingElement
{
public:
WritingElement_AdditionConstructors(CDdeItem)
CDdeItem()
{
}
virtual ~CDdeItem()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"values" == sName)
{
m_oDdeValues = oReader;
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<ddeItem");
WritingStringNullableAttrEncodeXmlString(L"name", m_oName, m_oName.get());
WritingStringNullableAttrBool(L"ole", m_oOle);
WritingStringNullableAttrBool(L"advise", m_oAdvise);
WritingStringNullableAttrBool(L"preferPic", m_oPreferPic);
writer.WriteString(L">");
if (m_oDdeValues.IsInit())
{
m_oDdeValues->toXML(writer);
}
writer.WriteString(L"</ddeItem>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_OleItem;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("ole"), m_oOle )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("advise"), m_oAdvise )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("preferPic"), m_oPreferPic )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<std::wstring > m_oName;
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oOle;
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oAdvise;
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oPreferPic;
nullable<CDdeValues> m_oDdeValues;
};
class CDdeItems : public WritingElementWithChilds<CDdeItem>
{
public:
WritingElement_AdditionConstructors(CDdeItems)
CDdeItems()
{
}
virtual ~CDdeItems()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"ddeItem" == sName)
{
m_arrItems.push_back(new CDdeItem(oReader));
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<ddeItems>");
for (size_t i = 0; i < m_arrItems.size(); ++i)
{
m_arrItems[i]->toXML(writer);
}
writer.WriteString(L"</ddeItems>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_DdeItems;
}
};
class CDdeLink : public WritingElement
{
public:
WritingElement_AdditionConstructors(CDdeLink)
CDdeLink()
{
}
virtual ~CDdeLink()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"ddeItems" == sName)
{
m_oDdeItems = oReader;
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<ddeLink xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
WritingStringNullableAttrEncodeXmlString(L"ddeService", m_oDdeService, m_oDdeService.get());
WritingStringNullableAttrEncodeXmlString(L"ddeTopic", m_oDdeTopic, m_oDdeTopic.get());
writer.WriteString(L">");
if (m_oDdeItems.IsInit())
{
m_oDdeItems->toXML(writer);
}
writer.WriteString(L"</ddeLink>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_DdeLink;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("ddeService"), m_oDdeService )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("ddeTopic"), m_oDdeTopic )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<std::wstring > m_oDdeService;
nullable<std::wstring > m_oDdeTopic;
nullable<CDdeItems > m_oDdeItems;
};
class COleItem : public WritingElement
{
public:
WritingElement_AdditionConstructors(COleItem)
COleItem()
{
}
virtual ~COleItem()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<oleItem");
WritingStringNullableAttrEncodeXmlString(L"name", m_oName, m_oName.get());
WritingStringNullableAttrBool(L"icon", m_oIcon);
WritingStringNullableAttrBool(L"advise", m_oAdvise);
WritingStringNullableAttrBool(L"preferPic", m_oPreferPic);
writer.WriteString(L"/>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_OleItem;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("name"), m_oName )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("icon"), m_oIcon )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("advise"), m_oAdvise )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("preferPic"), m_oPreferPic )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<std::wstring > m_oName;
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oIcon;
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oAdvise;
nullable<SimpleTypes::COnOff<SimpleTypes::onoffTrue>> m_oPreferPic;
};
class COleItems : public WritingElementWithChilds<COleItem>
{
public:
WritingElement_AdditionConstructors(COleItems)
COleItems()
{
}
virtual ~COleItems()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"oleItem" == sName)
{
m_arrItems.push_back(new COleItem(oReader));
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<oleItems>");
for (size_t i = 0; i < m_arrItems.size(); ++i)
{
m_arrItems[i]->toXML(writer);
}
writer.WriteString(L"</oleItems>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_OleItems;
}
};
class COleLink : public WritingElement
{
public:
WritingElement_AdditionConstructors(COleLink)
COleLink()
{
}
virtual ~COleLink()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
// TO DO: Реализовать
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
if (L"oleItems" == sName)
{
m_oOleItems = oReader;
}
}
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<oleLink xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
WritingStringNullableAttrString(L"r:id", m_oRid, m_oRid->ToString());
WritingStringNullableAttrEncodeXmlString(L"progId", m_oProgId, m_oProgId.get());
writer.WriteString(L">");
if (m_oOleItems.IsInit())
{
m_oOleItems->toXML(writer);
}
writer.WriteString(L"</oleLink>");
}
virtual std::wstring toXML() const
{
NSStringUtils::CStringBuilder writer;
toXML(writer);
return writer.GetData().c_str();
}
virtual EElementType getType() const
{
return et_x_OleLink;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if( oReader, _T("r:id"), m_oRid )
WritingElement_ReadAttributes_Read_else_if( oReader, _T("progId"), m_oProgId )
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CRelationshipId > m_oRid;
nullable<std::wstring > m_oProgId;
nullable<COleItems > m_oOleItems;
};
class CExternalLink : public OOX::FileGlobalEnumerated, public OOX::IFileContainer
{
public:
@ -604,6 +1127,14 @@ namespace OOX
{
m_oExternalBook = oReader;
}
else if ( _T("oleLink") == sName )
{
m_oOleLink = oReader;
}
else if ( _T("ddeLink") == sName )
{
m_oDdeLink = oReader;
}
}
}
}
@ -615,10 +1146,18 @@ namespace OOX
sXml.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
sXml.WriteString(_T("<externalLink xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"));
if(m_oExternalBook.IsInit())
if (m_oExternalBook.IsInit())
{
m_oExternalBook->toXML(sXml);
}
if (m_oOleLink.IsInit())
{
m_oOleLink->toXML(sXml);
}
if (m_oDdeLink.IsInit())
{
m_oDdeLink->toXML(sXml);
}
sXml.WriteString(_T("</externalLink>"));
@ -651,6 +1190,8 @@ namespace OOX
}
nullable<CExternalBook> m_oExternalBook;
nullable<COleLink> m_oOleLink;
nullable<CDdeLink> m_oDdeLink;
private:
CPath m_oReadPath;
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)

View File

@ -161,7 +161,16 @@ namespace OOX
else if ( pRelation->Type() == OOX::FileTypes::ExternalLinkPath)
return smart_ptr<OOX::File>(new ExternalLinkPath( oRelationFilename ));
else if ( pRelation->Type() == OOX::FileTypes::OleObject)
return smart_ptr<OOX::File>(new OOX::OleObject( oFileName ));
{
if (pRelation->IsExternal())
{
return smart_ptr<OOX::File>(new OOX::OleObject( oRelationFilename ));
}
else
{
return smart_ptr<OOX::File>(new OOX::OleObject( oFileName ));
}
}
else if ( pRelation->Type() == OOX::FileTypes::Data)
return smart_ptr<OOX::File>(new OOX::CDiagramData( oRootPath, oFileName ));
else if ( pRelation->Type() == OOX::FileTypes::DiagDrawing)

View File

@ -2608,5 +2608,48 @@ namespace SimpleTypes
SimpleType_FromString (EPaneState)
SimpleType_Operator_Equal (CPaneState)
};
enum EDdeValueType
{
ddevaluetypeNil = 0,
ddevaluetypeB = 1,
ddevaluetypeN = 2,
ddevaluetypeE = 3,
ddevaluetypeStr = 4
};
template<EDdeValueType eDefValue = ddevaluetypeNil>
class CDdeValueType : public CSimpleType<EDdeValueType, eDefValue>
{
public:
CDdeValueType() {}
virtual EDdeValueType FromString(std::wstring &sValue)
{
if ( _T("nil") == sValue ) this->m_eValue = ddevaluetypeNil;
else if ( _T("b") == sValue ) this->m_eValue = ddevaluetypeB;
else if ( _T("n") == sValue ) this->m_eValue = ddevaluetypeN;
else if ( _T("e") == sValue ) this->m_eValue = ddevaluetypeE;
else if ( _T("str") == sValue ) this->m_eValue = ddevaluetypeStr;
else this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual std::wstring ToString () const
{
switch(this->m_eValue)
{
case ddevaluetypeNil : return _T("nil");
case ddevaluetypeB : return _T("b");
case ddevaluetypeN : return _T("n");
case ddevaluetypeE : return _T("e");
case ddevaluetypeStr : return _T("str");
default : return _T("nil");
}
}
SimpleType_FromString (EDdeValueType)
SimpleType_Operator_Equal (CDdeValueType)
};
};// Spreadsheet
} // SimpleTypes

View File

@ -745,6 +745,7 @@
#define ASC_MENU_EVENT_TYPE_USER_ZOOM 301
#define ASC_MENU_EVENT_TYPE_INSERT_CHART 400
#define ASC_MENU_EVENT_TYPE_GET_CHART_DATA 450
#define ASC_MENU_EVENT_TYPE_ERROR 500

View File

@ -1,91 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-01-19T14:14:33
#
#-------------------------------------------------
QT -= core
QT -= gui
TARGET = docbuilder
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
CONFIG -= debug_and_release debug_and_release_target
CONFIG += c++11
linux-g++ | linux-g++-64 | linux-g++-32 {
QMAKE_LFLAGS += -Wl,--rpath=./
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
}
############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../../../build/lib
DESTINATION_PATH = $$PWD/../../../build/bin/docbuilder
win32 {
DEFINES += WIN32
}
linux-g++ | linux-g++-64 | linux-g++-32 {
DEFINES += \
LINUX \
_LINUX \
_LINUX_QT
}
mac {
DEFINES += \
LINUX \
_LINUX \
_LINUX_QT \
_MAC \
MAC
}
# WINDOWS
win32:contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_64/DEBUG
} else {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_64
}
TARGET_PLATFORM = _win64
}
win32:!contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_32/DEBUG
} else {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/win_32
}
TARGET_PLATFORM = _win32
}
linux-g++:contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/linux_64
TARGET_PLATFORM = _linux64
}
linux-g++:!contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/linux_32
TARGET_PLATFORM = _linux32
}
mac {
DESTINATION_SDK_PATH_DOCTRENDERER = $$DESTINATION_SDK_PATH/mac_64
TARGET_PLATFORM = _mac64
}
DESTDIR = $$DESTINATION_PATH
TARGET = docbuilder$$TARGET_PLATFORM
################################################
LIBS += -L$$DESTINATION_SDK_PATH_DOCTRENDERER/docbuilder -ldoctrenderer
linux-g++ {
LIBS += -ldl
}
SOURCES += main.cpp

View File

@ -1,111 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../docbuilder.h"
#ifdef LINUX
#include "../../common/File.h"
#endif
#define OFFICESTUDIO_FILE_DOCUMENT 0x0040
#define OFFICESTUDIO_FILE_DOCUMENT_DOCX OFFICESTUDIO_FILE_DOCUMENT + 0x0001
#define OFFICESTUDIO_FILE_DOCUMENT_DOC OFFICESTUDIO_FILE_DOCUMENT + 0x0002
#define OFFICESTUDIO_FILE_DOCUMENT_ODT OFFICESTUDIO_FILE_DOCUMENT + 0x0003
#define OFFICESTUDIO_FILE_DOCUMENT_RTF OFFICESTUDIO_FILE_DOCUMENT + 0x0004
#define OFFICESTUDIO_FILE_DOCUMENT_TXT OFFICESTUDIO_FILE_DOCUMENT + 0x0005
#define OFFICESTUDIO_FILE_DOCUMENT_HTML OFFICESTUDIO_FILE_DOCUMENT + 0x0006
#define OFFICESTUDIO_FILE_DOCUMENT_MHT OFFICESTUDIO_FILE_DOCUMENT + 0x0007
#define OFFICESTUDIO_FILE_DOCUMENT_EPUB OFFICESTUDIO_FILE_DOCUMENT + 0x0008
#define OFFICESTUDIO_FILE_DOCUMENT_FB2 OFFICESTUDIO_FILE_DOCUMENT + 0x0009
#define OFFICESTUDIO_FILE_DOCUMENT_MOBI OFFICESTUDIO_FILE_DOCUMENT + 0x000a
#define OFFICESTUDIO_FILE_PRESENTATION 0x0080
#define OFFICESTUDIO_FILE_PRESENTATION_PPTX OFFICESTUDIO_FILE_PRESENTATION + 0x0001
#define OFFICESTUDIO_FILE_PRESENTATION_PPT OFFICESTUDIO_FILE_PRESENTATION + 0x0002
#define OFFICESTUDIO_FILE_PRESENTATION_ODP OFFICESTUDIO_FILE_PRESENTATION + 0x0003
#define OFFICESTUDIO_FILE_PRESENTATION_PPSX OFFICESTUDIO_FILE_PRESENTATION + 0x0004
#define OFFICESTUDIO_FILE_SPREADSHEET 0x0100
#define OFFICESTUDIO_FILE_SPREADSHEET_XLSX OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
#define OFFICESTUDIO_FILE_SPREADSHEET_XLS OFFICESTUDIO_FILE_SPREADSHEET + 0x0002
#define OFFICESTUDIO_FILE_SPREADSHEET_ODS OFFICESTUDIO_FILE_SPREADSHEET + 0x0003
#define OFFICESTUDIO_FILE_SPREADSHEET_CSV OFFICESTUDIO_FILE_SPREADSHEET + 0x0004
#define OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
#define OFFICESTUDIO_FILE_CROSSPLATFORM_PDF OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
#define OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0003
#define OFFICESTUDIO_FILE_CROSSPLATFORM_XPS OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0004
#include <string>
#ifdef WIN32
int wmain(int argc, wchar_t *argv[])
#else
int main(int argc, char *argv[])
#endif
{
if (argc <= 0)
return 0;
#ifdef WIN32
std::wstring sBuildFile(argv[argc - 1]);
#else
std::string sBuildFileA(argv[argc - 1]);
std::wstring sBuildFile = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sBuildFileA.c_str(), (LONG)sBuildFileA.length());
#endif
NSDoctRenderer::CDocBuilder::Initialize();
if (true)
{
NSDoctRenderer::CDocBuilder oBuilder;
oBuilder.SetProperty("--check-fonts", L"");
//oBuilder.SetProperty("--use-doctrenderer-scheme", L"");
//oBuilder.SetProperty("--work-directory", L"builder");
for (int i = 0; i < (argc - 1); ++i)
{
#ifdef WIN32
std::wstring sW(argv[i]);
std::string sParam(sW.begin(), sW.end());
#else
std::string sParam(argv[i]);
#endif
oBuilder.SetProperty(sParam.c_str(), L"");
}
oBuilder.Run(sBuildFile.c_str());
}
NSDoctRenderer::CDocBuilder::Dispose();
return 0;
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@ -1,78 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
namespace test
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1806, 1090);
this.Name = "MainForm";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,145 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
//#define NET_DLL
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace test
{
public partial class MainForm : Form
{
public TabControl m_oTabControl = new TabControl();
public MainForm()
{
InitializeComponent();
this.Text = "Document Builder";
m_oTabControl.SetBounds(0, 0, this.ClientSize.Width, this.ClientSize.Height - 50);
m_oTabControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
this.Controls.Add(m_oTabControl);
AddTab("builder.SetTmpFolder(\"D:/BuilderTest\");\r\n" +
"#builder.CreateFile(\"docx\");\r\n" +
"builder.OpenFile(\"D:/TESTFILES/images.docx\", \"\");\r\n" +
"builder.SaveFile(\"pdf\", \"D:/TESTFILES/images.pdf\");\r\n" +
"builder.CloseFile();");
int nButtonsHeight = 30;
int nButtonsTop = this.ClientSize.Height - ((50 + nButtonsHeight) / 2);
int nButtonsWidth = 100;
int nButtonsBetween = 10;
int nButtonsRight = 10;
Button _buttonNew = new Button();
_buttonNew.SetBounds(this.ClientSize.Width - nButtonsRight - 2 * nButtonsWidth - nButtonsBetween, nButtonsTop, nButtonsWidth, nButtonsHeight);
_buttonNew.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
_buttonNew.Text = "New Test";
_buttonNew.Click += _buttonNew_Click;
this.Controls.Add(_buttonNew);
Button _buttonRun = new Button();
_buttonRun.SetBounds(this.ClientSize.Width - nButtonsRight - nButtonsWidth, nButtonsTop, nButtonsWidth, nButtonsHeight);
_buttonRun.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
_buttonRun.Text = "Run";
_buttonRun.Click += _buttonRun_Click;
_buttonRun.BackColor = Color.Green;
_buttonRun.ForeColor = Color.White;
this.Controls.Add(_buttonRun);
#if (NET_DLL)
docbuilder_net.CDocBuilder.Initialize();
#else
ascdocbuilder.IASCDocBuilder oBuilder = new ascdocbuilder.CASCDocBuilder();
oBuilder.Initialize();
#endif
this.Disposed += MainForm_Disposed;
}
void MainForm_Disposed(object sender, EventArgs e)
{
#if (NET_DLL)
docbuilder_net.CDocBuilder.Destroy();
#else
ascdocbuilder.IASCDocBuilder oBuilder = new ascdocbuilder.CASCDocBuilder();
oBuilder.Dispose();
#endif
}
void _buttonRun_Click(object sender, EventArgs e)
{
#if (NET_DLL)
docbuilder_net.CDocBuilder oBuilder = new docbuilder_net.CDocBuilder(true);
oBuilder.RunText(this.m_oTabControl.SelectedTab.Controls[0].Text);
oBuilder.Dispose();
#else
ascdocbuilder.IASCDocBuilder oBuilder = new ascdocbuilder.CASCDocBuilder();
oBuilder.CreateInstance(true);
oBuilder.RunText(this.m_oTabControl.SelectedTab.Controls[0].Text);
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBuilder);
#endif
}
void _buttonNew_Click(object sender, EventArgs e)
{
AddTab("");
}
private void AddTab(string _code)
{
TabPage _page = new TabPage("Test №" + Convert.ToString(m_oTabControl.TabCount + 1));
TextBox _text = new TextBox();
_text.Multiline = true;
_text.Dock = DockStyle.Fill;
_text.Text = _code;
_text.Font = new System.Drawing.Font(_text.Font.Name, 12);
_page.Controls.Add(_text);
m_oTabControl.Controls.Add(_page);
m_oTabControl.Controls[m_oTabControl.TabCount - 1].Name = "Test №" + Convert.ToString(m_oTabControl.TabCount);
this.OnResize(EventArgs.Empty);
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,53 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace test
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

View File

@ -1,67 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("test")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("492b3cfa-599e-4bd7-be7f-66de3e48c1cb")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,102 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace test.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,61 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace test.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{85EE7B43-D2BF-4E8B-A103-7D1845A21587}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>test</RootNamespace>
<AssemblyName>test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="docbuilder.net, Version=1.0.5996.29843, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\docbuilder.net\bin\x64\Debug\docbuilder.net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<COMReference Include="ascdocbuilder">
<Guid>{B43F4AFD-2278-4175-992C-D7AE390507D8}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -1,28 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test.csproj", "{85EE7B43-D2BF-4E8B-A103-7D1845A21587}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Debug|x64.ActiveCfg = Debug|x64
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Debug|x64.Build.0 = Debug|x64
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Release|Any CPU.Build.0 = Release|Any CPU
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Release|x64.ActiveCfg = Release|x64
{85EE7B43-D2BF-4E8B-A103-7D1845A21587}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -8,9 +8,40 @@
#define OOXML_HASH_ALG_SHA1 0
#define OOXML_HASH_ALG_INVALID 1
class Q_DECL_EXPORT CCertificateInfo
#define OPEN_SSL_WARNING_OK 0
#define OPEN_SSL_WARNING_ERR 1
#define OPEN_SSL_WARNING_ALL_OK 2
#define OPEN_SSL_WARNING_PASS 4
class ICertificate;
class Q_DECL_EXPORT ICertificateSelectDialogOpenSsl
{
public:
ICertificateSelectDialogOpenSsl()
{
}
virtual ~ICertificateSelectDialogOpenSsl()
{
}
public:
virtual std::wstring GetCertificatePath() = 0;
virtual std::wstring GetCertificatePassword() = 0;
virtual std::wstring GetKeyPath() = 0;
virtual std::wstring GetKeyPassword() = 0;
virtual bool ShowSelectDialog() = 0;
virtual int ShowCertificate(ICertificate* pCert) = 0;
static int LoadKey(std::wstring file, std::string password);
static int LoadCert(std::wstring file, std::string password);
static void SetOpenSslDialogApplication(ICertificateSelectDialogOpenSsl* pDialog);
};
class Q_DECL_EXPORT CCertificateInfo
{
private:
std::wstring m_name;
std::string m_date;
std::string m_id;
@ -22,6 +53,33 @@ public:
~CCertificateInfo()
{
}
std::wstring GetName()
{
return m_name;
}
void SetName(const std::wstring& name)
{
m_name = name;
}
std::string GetDate()
{
return m_date;
}
void SetDate(const std::string& date)
{
m_date = date;
}
std::string GetId()
{
return m_id;
}
void SetId(const std::string& id)
{
m_id = id;
}
};
class Q_DECL_EXPORT ICertificate
@ -58,21 +116,23 @@ public:
virtual bool ShowSelectDialog() = 0;
virtual int ShowCertificate() = 0;
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog) {}
static CCertificateInfo GetDefault();
static ICertificate* GetById(const std::string& id);
virtual CCertificateInfo GetInfo()
{
CCertificateInfo info;
info.m_name = GetSignerName();
info.m_date = GetDate();
info.m_id = GetId();
info.SetName(GetSignerName());
info.SetDate(GetDate());
info.SetId(GetId());
return info;
}
public:
static int GetOOXMLHashAlg(const std::string& sAlg);
static ICertificate* CreateInstance();
static ICertificate* CreateInstance();
};
#endif // _XML_SERTIFICATE_BASE_H_

View File

@ -21,6 +21,13 @@ include($$CORE_ROOT_DIR/DesktopEditor/xml/build/qt/libxml2.pri)
DEFINES -= UNICODE
core_linux {
CONFIG += signature_openssl
}
core_mac {
CONFIG += signature_openssl
}
HEADERS += \
include/XmlCertificate.h \
include/OOXMLSigner.h \
@ -29,9 +36,7 @@ HEADERS += \
HEADERS += \
src/XmlCanonicalizator.h \
src/XmlRels.h \
src/XmlTransform.h \
src/XmlSigner_mscrypto.h \
src/XmlSigner_openssl.h
src/XmlTransform.h
SOURCES += \
src/XmlTransform.cpp \
@ -41,8 +46,31 @@ SOURCES += \
core_windows {
HEADERS += \
src/XmlSigner_mscrypto.h
LIBS += -lcrypt32
LIBS += -lcryptui
LIBS += -lAdvapi32
}
signature_openssl {
HEADERS += \
src/XmlSigner_openssl.h
SOURCES += \
src/XmlSigner_openssl.cpp
}
signature_openssl {
DEFINES += XMLSEC_OPENSSL_110
INCLUDEPATH += $$CORE_ROOT_DIR/Common/3dParty/openssl/openssl/include
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lssl
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lcrypto
}

View File

@ -1,6 +1,17 @@
#ifdef WIN32
#include "./XmlSigner_mscrypto.h"
#define CCertificate CCertificate_mscrypto
int ICertificateSelectDialogOpenSsl::LoadKey(std::wstring file, std::string password)
{
return 0;
}
int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string password)
{
return 0;
}
#endif
#if defined(_LINUX) && !defined(_MAC)
@ -13,6 +24,16 @@
#define CCertificate CCertificate_openssl
#endif
namespace
{
ICertificateSelectDialogOpenSsl* g_application_openssl_gialog = NULL;
}
void ICertificateSelectDialogOpenSsl::SetOpenSslDialogApplication(ICertificateSelectDialogOpenSsl* pDialog)
{
g_application_openssl_gialog = pDialog;
}
int ICertificate::GetOOXMLHashAlg(const std::string& sAlg)
{
if ("http://www.w3.org/2000/09/xmldsig#rsa-sha1" == sAlg ||
@ -24,25 +45,25 @@ int ICertificate::GetOOXMLHashAlg(const std::string& sAlg)
ICertificate* ICertificate::CreateInstance()
{
return new CCertificate();
ICertificate* pCert = new CCertificate();
pCert->SetOpenSslDialog(g_application_openssl_gialog);
return pCert;
}
CCertificateInfo ICertificate::GetDefault()
{
CCertificateInfo info;
#ifdef WIN32
// detect user name
std::wstring sUserName;
#ifdef WIN32
DWORD dwUserNameLen = 1024;
wchar_t* _name = new wchar_t[dwUserNameLen + 1];
GetUserNameW(_name, &dwUserNameLen);
sUserName = std::wstring(_name);
delete []_name;
#endif
////////////////////
#ifdef WIN32
HANDLE hStoreHandle = CertOpenSystemStoreA(NULL, "MY");
if (!hStoreHandle)
return info;

View File

@ -0,0 +1,672 @@
#include "./XmlSigner_openssl.h"
#include "../../../common/File.h"
#include "../../../common/String.h"
#include "../../../common/BigInteger.h"
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/pkcs12.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#include <openssl/crypto.h>
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <openssl/conf.h>
void BIO_FREE(BIO*& bio)
{
if (bio)
{
BIO_free(bio);
bio = NULL;
}
}
class CCertificate_openssl_private
{
protected:
ICertificateSelectDialogOpenSsl* m_pDialog;
X509* m_cert;
EVP_PKEY* m_key;
public:
ICertificate* m_pBase;
public:
CCertificate_openssl_private()
{
m_pDialog = NULL;
m_cert = NULL;
m_key = NULL;
m_pBase = NULL;
}
virtual ~CCertificate_openssl_private()
{
if (NULL != m_cert)
X509_free(m_cert);
if (NULL != m_key)
EVP_PKEY_free(m_key);
}
public:
std::string GetNumber()
{
if (NULL == m_cert)
return "";
ASN1_INTEGER* asn1_serial = X509_get_serialNumber(m_cert);
if (asn1_serial == NULL)
return "";
BIGNUM* bn = ASN1_INTEGER_to_BN(asn1_serial, NULL);
if (!bn)
{
ASN1_INTEGER_free(asn1_serial);
return "";
}
char *tmp = BN_bn2dec(bn);
std::string sReturn(tmp);
BN_free(bn);
ASN1_INTEGER_free(asn1_serial);
return sReturn;
}
std::wstring GetSignerName()
{
if (NULL == m_cert)
return L"";
X509_NAME* name = X509_get_issuer_name(m_cert);
char* utf_8_name = X509_NAME_oneline(name, NULL, 0);
std::string sName(utf_8_name);
std::wstring sNameW = UTF8_TO_U(sName);
OPENSSL_free(utf_8_name);
return sNameW;
}
std::string GetCertificateBase64()
{
if (NULL == m_cert)
return "";
BIO* bio = BIO_new(BIO_s_mem());
PEM_write_bio_X509_AUX(bio, m_cert);
unsigned char *data;
unsigned int len = 0;
len = BIO_get_mem_data(bio, &data);
std::string sReturn((char*)data, (size_t)len);
BIO_free(bio);
return sReturn;
}
std::string GetCertificateHash()
{
std::string sBase64 = GetCertificateBase64();
BYTE* pData = NULL;
int nLen = 0;
if (NSFile::CBase64Converter::Decode(sBase64.c_str(), (int)sBase64.length(), pData, nLen))
{
std::string sHash = GetHash(pData, (unsigned int)nLen, OOXML_HASH_ALG_SHA1);
RELEASEARRAYOBJECTS(pData);
return sHash;
}
return "";
}
std::string GetDate()
{
if (NULL == m_cert)
return "";
ASN1_TIME* _time1 = X509_get_notBefore(m_cert);
struct tm t1 = this->ASN1_GetTimeT(_time1);
ASN1_TIME_free(_time1);
ASN1_TIME* _time2 = X509_get_notAfter(m_cert);
struct tm t2 = this->ASN1_GetTimeT(_time2);
ASN1_TIME_free(_time2);
std::string sRet = std::to_string(t1.tm_mday) +
"/" +
std::to_string(t1.tm_mon + 1) +
"/" +
std::to_string(t1.tm_year + 1900) +
" - " +
std::to_string(t1.tm_mday) +
"/" +
std::to_string(t2.tm_mon + 1) +
"/" +
std::to_string(t2.tm_year + 1900);
return sRet;
}
std::string GetId()
{
// TODO: + public key?
return GetNumber();
}
public:
std::string Sign(const std::string& sXml)
{
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
const EVP_MD* pDigest = EVP_sha1();
int n1 = EVP_SignInit(pCtx, pDigest);
n1 = n1;
int n2 = EVP_SignUpdate(pCtx, sXml.c_str(), sXml.length());
n2 = n2;
BYTE pSignature[4096];
unsigned int nSignatureLen = 0;
int n3 = EVP_SignFinal(pCtx, pSignature, &nSignatureLen, m_key);
n3 = n3;
EVP_MD_CTX_destroy(pCtx);
return std::string((char*)pSignature, (size_t)nSignatureLen);
}
std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
{
if (nAlg == OOXML_HASH_ALG_SHA1)
{
unsigned char obuf[20];
SHA1(pData, (size_t)nSize, obuf);
char* pBase64_hash = NULL;
int nBase64Len_hash = 0;
NSFile::CBase64Converter::Encode(obuf, 20, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sReturn(pBase64_hash, nBase64Len_hash);
delete [] pBase64_hash;
return sReturn;
}
return "";
}
std::string GetHash(const std::string& sXml, int nAlg)
{
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length(), nAlg);
}
std::string GetHash(const std::wstring& sXmlFile, int nAlg)
{
BYTE* pFileData = NULL;
DWORD dwFileDataLen = 0;
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
if (0 == dwFileDataLen)
return "";
std::string sReturn = GetHash(pFileData, dwFileDataLen, nAlg);
RELEASEARRAYOBJECTS(pFileData);
return sReturn;
}
bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
{
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
const EVP_MD* pDigest = EVP_sha1();
int n1 = EVP_VerifyInit(pCtx, pDigest);
n1 = n1;
BYTE* pDigestValue = NULL;
int nDigestLen = 0;
NSFile::CBase64Converter::Decode(sXmlSignature.c_str(), (int)sXmlSignature.length(), pDigestValue, nDigestLen);
int n2 = EVP_VerifyUpdate(pCtx, pDigestValue, (size_t)nDigestLen);
n2 = n2;
EVP_PKEY* pubkey = X509_get_pubkey(m_cert);
int n3 = EVP_VerifyFinal(pCtx, (BYTE*)sXml.c_str(), (unsigned int)sXml.length(), pubkey);
n3 = n3;
EVP_MD_CTX_destroy(pCtx);
EVP_PKEY_free(pubkey);
RELEASEARRAYOBJECTS(pDigestValue);
return (1 == n3) ? true : false;
}
bool LoadFromBase64Data(const std::string& data)
{
BYTE* pData = NULL;
int nLen = 0;
if (NSFile::CBase64Converter::Decode(data.c_str(), (int)data.length(), pData, nLen))
{
X509* pCert = NULL;
int nErr = LoadCert(pData, (DWORD)nLen, "", &pCert);
if (nErr == OPEN_SSL_WARNING_OK || nErr == OPEN_SSL_WARNING_ALL_OK)
{
m_cert = pCert;
}
else
{
X509_free(pCert);
m_cert = NULL;
}
RELEASEARRAYOBJECTS(pData);
return (NULL == m_cert) ? false : true;
}
return false;
}
public:
bool ShowSelectDialog()
{
if (!m_pDialog)
return false;
bool bResult = m_pDialog->ShowSelectDialog();
std::wstring sKeyPath = m_pDialog->GetKeyPath();
std::wstring sKeyPasswordW = m_pDialog->GetKeyPassword();
std::string sKeyPassword = U_TO_UTF8(sKeyPasswordW);
std::wstring sCertPath = m_pDialog->GetCertificatePath();
std::wstring sCertPasswordW = m_pDialog->GetCertificatePassword();
std::string sCertPassword = U_TO_UTF8(sCertPasswordW);
if (sCertPath.empty())
{
sCertPath = sKeyPath;
sCertPassword = sKeyPassword;
}
int nErr = LoadKey(sKeyPath, sKeyPassword, &m_key);
if (nErr != OPEN_SSL_WARNING_OK && nErr != OPEN_SSL_WARNING_ALL_OK)
return false;
nErr = LoadCert(sCertPath, sCertPassword, &m_cert);
if (nErr != OPEN_SSL_WARNING_OK && nErr != OPEN_SSL_WARNING_ALL_OK)
return false;
return true;
}
int ShowCertificate()
{
if (m_pDialog)
return m_pDialog->ShowCertificate(m_pBase);
return 1;
}
void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
{
m_pDialog = pDialog;
}
protected:
tm ASN1_GetTimeT(ASN1_TIME* time)
{
struct tm t;
const char* str = (const char*) time->data;
size_t i = 0;
memset(&t, 0, sizeof(t));
if (time->type == V_ASN1_UTCTIME)
{
/* two digit year */
t.tm_year = (str[i++] - '0') * 10;
t.tm_year += (str[i++] - '0');
if (t.tm_year < 70)
t.tm_year += 100;
}
else if (time->type == V_ASN1_GENERALIZEDTIME)
{
/* four digit year */
t.tm_year = (str[i++] - '0') * 1000;
t.tm_year+= (str[i++] - '0') * 100;
t.tm_year+= (str[i++] - '0') * 10;
t.tm_year+= (str[i++] - '0');
t.tm_year -= 1900;
}
t.tm_mon = (str[i++] - '0') * 10;
t.tm_mon += (str[i++] - '0') - 1; // -1 since January is 0 not 1.
t.tm_mday = (str[i++] - '0') * 10;
t.tm_mday+= (str[i++] - '0');
t.tm_hour = (str[i++] - '0') * 10;
t.tm_hour+= (str[i++] - '0');
t.tm_min = (str[i++] - '0') * 10;
t.tm_min += (str[i++] - '0');
t.tm_sec = (str[i++] - '0') * 10;
t.tm_sec += (str[i++] - '0');
/* Note: we did not adjust the time based on time zone information */
return t;
}
public:
static std::string GetOpenSslErrors()
{
BIO* bio = BIO_new(BIO_s_mem());
ERR_print_errors(bio);
char *buf = NULL;
size_t len = BIO_get_mem_data(bio, &buf);
std::string sRet((char*)buf, len);
NSStringExt::ToLower(sRet);
BIO_free (bio);
return sRet;
}
static bool IsOpenSslPasswordError(const std::string& str)
{
if (std::string::npos != str.find("mac verify error"))
return true;
if (std::string::npos != str.find("mac verify failure"))
return true;
if (std::string::npos != str.find("password"))
return true;
return false;
}
static int LoadKey(BYTE* pData, DWORD dwDataLen, std::string password, EVP_PKEY** ppKey)
{
int nErr = OPEN_SSL_WARNING_ERR;
std::string sError = "";
PKCS12* p12 = NULL;
EVP_PKEY* pKey = NULL;
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (PEM_read_bio_PrivateKey(bio, &pKey, NULL, (void*)pPassword))
{
nErr = OPEN_SSL_WARNING_OK;
goto end;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
BIO_FREE(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (d2i_PrivateKey_bio(bio, &pKey))
{
nErr = OPEN_SSL_WARNING_OK;
goto end;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
BIO_FREE(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (d2i_PKCS8PrivateKey_bio(bio, &pKey, NULL, (void*)pPassword))
{
nErr = OPEN_SSL_WARNING_OK;
goto end;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
BIO_FREE(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
p12 = d2i_PKCS12_bio(bio, NULL);
if (p12)
{
X509* pCert = NULL;
STACK_OF(X509)* pCa = NULL;
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
{
sk_X509_pop_free(pCa, X509_free);
X509_free(pCert);
PKCS12_free(p12);
nErr = OPEN_SSL_WARNING_ALL_OK;
goto end;
}
PKCS12_free(p12);
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
}
end:
if (NULL == ppKey)
EVP_PKEY_free(pKey);
else
*ppKey = pKey;
BIO_FREE(bio);
return nErr;
}
static int LoadKey(std::wstring file, std::string password, EVP_PKEY** ppKey)
{
BYTE* pData = NULL;
DWORD dwDataLen;
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
return OPEN_SSL_WARNING_ERR;
int nErr = LoadKey(pData, dwDataLen, password, ppKey);
RELEASEARRAYOBJECTS(pData);
return nErr;
}
static int LoadCert(BYTE* pData, DWORD dwDataLen, std::string password, X509** ppCert)
{
int nErr = OPEN_SSL_WARNING_ERR;
std::string sError = "";
PKCS12* p12 = NULL;
X509* pCert = NULL;
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (PEM_read_bio_X509(bio, &pCert, NULL, (void*)pPassword))
{
nErr = OPEN_SSL_WARNING_OK;
goto end;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
BIO_FREE(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (d2i_X509_bio(bio, &pCert))
{
nErr = OPEN_SSL_WARNING_OK;
goto end;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
BIO_FREE(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
p12 = d2i_PKCS12_bio(bio, NULL);
if (p12)
{
EVP_PKEY* pKey = NULL;
STACK_OF(X509)* pCa = NULL;
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
{
sk_X509_pop_free(pCa, X509_free);
EVP_PKEY_free(pKey);
PKCS12_free(p12);
BIO_FREE(bio);
nErr = OPEN_SSL_WARNING_ALL_OK;
goto end;
}
PKCS12_free(p12);
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
nErr = OPEN_SSL_WARNING_PASS;
goto end;
}
}
end:
if (NULL == ppCert)
X509_free(pCert);
else
*ppCert = pCert;
BIO_FREE(bio);
return nErr;
}
static int LoadCert(std::wstring file, std::string password, X509** ppCert)
{
BYTE* pData = NULL;
DWORD dwDataLen;
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
return OPEN_SSL_WARNING_ERR;
int nErr = LoadCert(pData, dwDataLen, password, ppCert);
RELEASEARRAYOBJECTS(pData);
return nErr;
}
};
// REALIZE
CCertificate_openssl::CCertificate_openssl() : ICertificate()
{
m_internal = new CCertificate_openssl_private();
m_internal->m_pBase = this;
}
CCertificate_openssl::~CCertificate_openssl()
{
RELEASEOBJECT(m_internal);
}
std::string CCertificate_openssl::GetNumber()
{
return m_internal->GetNumber();
}
std::wstring CCertificate_openssl::GetSignerName()
{
return m_internal->GetSignerName();
}
std::string CCertificate_openssl::GetCertificateBase64()
{
return m_internal->GetCertificateBase64();
}
std::string CCertificate_openssl::GetCertificateHash()
{
return m_internal->GetCertificateHash();
}
std::string CCertificate_openssl::GetDate()
{
return m_internal->GetDate();
}
std::string CCertificate_openssl::GetId()
{
return m_internal->GetId();
}
std::string CCertificate_openssl::Sign(const std::string& sXml)
{
return m_internal->Sign(sXml);
}
std::string CCertificate_openssl::GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
{
return m_internal->GetHash(pData, nSize, nAlg);
}
std::string CCertificate_openssl::GetHash(const std::string& sXml, int nAlg)
{
return m_internal->GetHash(sXml, nAlg);
}
std::string CCertificate_openssl::GetHash(const std::wstring& sXmlFile, int nAlg)
{
return m_internal->GetHash(sXmlFile, nAlg);
}
bool CCertificate_openssl::Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
{
return m_internal->Verify(sXml, sXmlSignature, nAlg);
}
bool CCertificate_openssl::LoadFromBase64Data(const std::string& data)
{
return m_internal->LoadFromBase64Data(data);
}
bool CCertificate_openssl::ShowSelectDialog()
{
return m_internal->ShowSelectDialog();
}
int CCertificate_openssl::ShowCertificate()
{
return m_internal->ShowCertificate();
}
void CCertificate_openssl::SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
{
return m_internal->SetOpenSslDialog(pDialog);
}
int ICertificateSelectDialogOpenSsl::LoadKey(std::wstring file, std::string password)
{
return CCertificate_openssl_private::LoadKey(file, password, NULL);
}
int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string password)
{
return CCertificate_openssl_private::LoadCert(file, password, NULL);
}

View File

@ -1,111 +1,49 @@
#ifndef _XMLSIGNER_OPENSSL_H_
#define _XMLSIGNER_OPENSSL_H_
#include "./include/XmlCertificate.h"
#include "../../../common/File.h"
#include "../../../common/BigInteger.h"
#include "./../include/XmlCertificate.h"
class CCertificate_openssl_private;
class CCertificate_openssl : public ICertificate
{
public:
protected:
BYTE* m_rawData;
int m_rawDataLen;
CCertificate_openssl_private* m_internal;
public:
CCertificate_openssl() : ICertificate()
{
m_rawData = NULL;
m_rawDataLen = 0;
}
virtual ~CCertificate_openssl()
{
}
CCertificate_openssl();
virtual ~CCertificate_openssl();
public:
virtual std::string GetNumber()
{
return "";
}
virtual std::string GetNumber();
virtual std::wstring GetSignerName()
{
return L"";
}
virtual std::wstring GetSignerName();
virtual std::string GetCertificateBase64()
{
return "";
}
virtual std::string GetCertificateBase64();
virtual std::string GetCertificateHash()
{
return "";
}
virtual std::string GetCertificateHash();
virtual std::string GetDate()
{
return "";
}
virtual std::string GetDate();
virtual std::string GetId()
{
return "";
}
virtual std::string GetId();
public:
virtual std::string Sign(const std::string& sXml)
{
return "";
}
virtual std::string Sign(const std::string& sXml);
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
{
return "";
}
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg);
virtual std::string GetHash(const std::string& sXml, int nAlg)
{
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length(), nAlg);
}
virtual std::string GetHash(const std::string& sXml, int nAlg);
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg)
{
BYTE* pFileData = NULL;
DWORD dwFileDataLen = 0;
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg);
if (0 == dwFileDataLen)
return "";
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg);
std::string sReturn = GetHash(pFileData, dwFileDataLen, nAlg);
RELEASEARRAYOBJECTS(pFileData);
return sReturn;
}
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
{
return false;
}
virtual bool LoadFromBase64Data(const std::string& data)
{
return false;
}
virtual int ShowCertificate()
{
return 1;
}
virtual bool LoadFromBase64Data(const std::string& data);
public:
virtual bool ShowSelectDialog()
{
return false;
}
virtual bool ShowSelectDialog();
virtual int ShowCertificate();
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog);
};
#endif // _XMLSIGNER_OPENSSL_H_

View File

@ -0,0 +1,43 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-06-05T12:59:43
#
#-------------------------------------------------
QT += core gui
QT += widgets
TARGET = OpenSSL_gui_test
TEMPLATE = app
DEFINES -= \
UNICODE \
_UNICODE
CORE_ROOT_DIR = $$PWD/../../../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
core_linux {
QMAKE_LFLAGS += -Wl,--rpath=./
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
}
DEFINES += XMLSEC_OPENSSL_110
#DEFINES += "OPENSSL_API_COMPAT=\"0x10100000\""
INCLUDEPATH += $$CORE_ROOT_DIR/Common/3dParty/openssl/openssl/include
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lssl
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lcrypto
LIBS += -ldl
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
HEADERS += opensslwrapper.h
SOURCES += opensslwrapper.cpp

View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,110 @@
#include "mainwindow.h"
#include <QGridLayout>
#include <QFileDialog>
#include <QtNetwork/QSslSocket>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QRect rect = this->geometry();
this->setGeometry(rect.x(), rect.y(), 600, 170);
QGridLayout *mainGridLayout = new QGridLayout();
mainGridLayout->setSpacing( 0 );
mainGridLayout->setMargin( 0 );
setLayout( mainGridLayout );
QWidget *centralWidget = new QWidget( this );
centralWidget->setObjectName( "centralWidget" );
centralWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
this->setCentralWidget(centralWidget);
m_pKeyFile = new QPlainTextEdit(centralWidget);
m_pKeyPassword = new QPlainTextEdit(centralWidget);
m_pCertFile = new QPlainTextEdit(centralWidget);
m_pCertPassword = new QPlainTextEdit(centralWidget);
m_pKeyDialog = new QPushButton(centralWidget);
m_pCertDialog = new QPushButton(centralWidget);
m_pOK = new QPushButton(centralWidget);
m_pKeyDialog->setText("...");
m_pCertDialog->setText("...");
m_pOK->setText("OK");
m_pKeyFile->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_pKeyPassword->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_pCertFile->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_pCertPassword->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QObject::connect( m_pKeyDialog, SIGNAL( clicked() ), this, SLOT( pushButtonKeyClicked()) );
QObject::connect( m_pCertDialog, SIGNAL( clicked() ), this, SLOT( pushButtonCertClicked()) );
QObject::connect( m_pOK, SIGNAL( clicked() ), this, SLOT( pushButtonOKClicked()) );
CalculatePlaces();
}
MainWindow::~MainWindow()
{
}
void MainWindow::resizeEvent(QResizeEvent* e)
{
CalculatePlaces();
}
void MainWindow::CalculatePlaces()
{
int nWidth = this->width();
int nHeight = this->height();
int nWidthBetween = 30;
int nWidthButton = 40;
int nWidthPassword = 40;
int nHeightLine = 30;
int nWidthPath = nWidth - 40 - 2 * nWidthBetween - nWidthButton - nWidthPassword;
if (nWidthPath < 20)
nWidthPath = 20;
int nTop1 = 20;
m_pKeyFile->setGeometry(20, nTop1, nWidthPath, nHeightLine);
m_pKeyPassword->setGeometry(20 + nWidthPath + nWidthBetween, nTop1, nWidthPassword, nHeightLine);
m_pKeyDialog->setGeometry(nWidth - 20 - nWidthButton, nTop1, nWidthButton, nHeightLine);
nTop1 = 20 + nHeightLine + 20;
m_pCertFile->setGeometry(20, nTop1, nWidthPath, nHeightLine);
m_pCertPassword->setGeometry(20 + nWidthPath + nWidthBetween, nTop1, nWidthPassword, nHeightLine);
m_pCertDialog->setGeometry(nWidth - 20 - nWidthButton, nTop1, nWidthButton, nHeightLine);
m_pOK->setGeometry((nWidth - 40) >> 1, nTop1 + nHeightLine + 20, 40, nHeightLine);
}
void MainWindow::pushButtonKeyClicked()
{
std::wstring sFile = QFileDialog::getOpenFileName(NULL, QString(), QString()).toStdWString();
if (sFile.empty())
return;
m_pKeyFile->setPlainText(QString::fromStdWString(sFile));
}
void MainWindow::pushButtonCertClicked()
{
std::wstring sFile = QFileDialog::getOpenFileName(NULL, QString(), QString()).toStdWString();
if (sFile.empty())
return;
m_pCertFile->setPlainText(QString::fromStdWString(sFile));
}
void MainWindow::pushButtonOKClicked()
{
COpenssl_library library;
int nKeyValue = library.LoadKey(m_pKeyFile->toPlainText().toStdWString(), m_pKeyPassword->toPlainText().toStdString());
int nCertValue = library.LoadCert(m_pCertFile->toPlainText().toStdWString(), m_pCertPassword->toPlainText().toStdString());
int y = 0;
y++;
}

View File

@ -0,0 +1,44 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTextEdit>
#include <QPushButton>
#include <QResizeEvent>
#include <QPlainTextEdit>
#include "opensslwrapper.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
virtual void resizeEvent(QResizeEvent*);
void CalculatePlaces();
public:
QPlainTextEdit* m_pKeyFile;
QPlainTextEdit* m_pKeyPassword;
QPushButton* m_pKeyDialog;
QPlainTextEdit* m_pCertFile;
QPlainTextEdit* m_pCertPassword;
QPushButton* m_pCertDialog;
QPushButton* m_pOK;
public slots:
void pushButtonKeyClicked();
void pushButtonCertClicked();
void pushButtonOKClicked();
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,247 @@
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/pkcs12.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#include <openssl/crypto.h>
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <openssl/conf.h>
#include "../../../common/File.h"
#include "../../../common/String.h"
#include "opensslwrapper.h"
class COpenssl_library_private
{
private:
static bool m_bInit;
public:
EVP_PKEY* m_key;
public:
COpenssl_library_private()
{
if (!m_bInit)
{
SSL_library_init();
OpenSSL_add_all_algorithms();
ERR_load_BIO_strings();
ERR_load_crypto_strings();
m_bInit = true;
}
}
~COpenssl_library_private()
{
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
}
};
bool COpenssl_library_private::m_bInit = false;
std::string GetOpenSslErrors()
{
BIO* bio = BIO_new(BIO_s_mem());
ERR_print_errors(bio);
char *buf = NULL;
size_t len = BIO_get_mem_data(bio, &buf);
std::string sRet((char*)buf, len);
NSStringExt::ToLower(sRet);
BIO_free (bio);
return sRet;
}
bool IsOpenSslPasswordError(const std::string& str)
{
if (std::string::npos != str.find("mac verify error"))
return true;
if (std::string::npos != str.find("mac verify failure"))
return true;
if (std::string::npos != str.find("password"))
return true;
return false;
}
COpenssl_library::COpenssl_library()
{
m_internal = new COpenssl_library_private();
}
COpenssl_library::~COpenssl_library()
{
RELEASEOBJECT(m_internal);
}
int COpenssl_library::LoadKey(std::wstring file, std::string password)
{
BYTE* pData = NULL;
DWORD dwDataLen;
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
return OPEN_SSL_WARNING_ERR;
EVP_PKEY* pKey = NULL;
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (PEM_read_bio_PrivateKey(bio, &pKey, NULL, (void*)pPassword))
{
EVP_PKEY_free(pKey);
BIO_free(bio);
return OPEN_SSL_WARNING_OK;
}
std::string sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
EVP_PKEY_free(pKey);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
BIO_free(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (d2i_PrivateKey_bio(bio, &pKey))
{
EVP_PKEY_free(pKey);
BIO_free(bio);
return OPEN_SSL_WARNING_OK;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
EVP_PKEY_free(pKey);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
BIO_free(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (d2i_PKCS8PrivateKey_bio(bio, &pKey, NULL, (void*)pPassword))
{
EVP_PKEY_free(pKey);
BIO_free(bio);
return OPEN_SSL_WARNING_OK;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
EVP_PKEY_free(pKey);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
BIO_free(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
PKCS12* p12 = d2i_PKCS12_bio(bio, NULL);
if (p12)
{
X509* pCert = NULL;
STACK_OF(X509)* pCa = NULL;
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
{
sk_X509_pop_free(pCa, X509_free);
X509_free(pCert);
EVP_PKEY_free(pKey);
PKCS12_free(p12);
BIO_free(bio);
return OPEN_SSL_WARNING_ALL_OK;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
PKCS12_free(p12);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
PKCS12_free(p12);
}
BIO_free(bio);
return OPEN_SSL_WARNING_ERR;
}
int COpenssl_library::LoadCert(std::wstring file, std::string password)
{
BYTE* pData = NULL;
DWORD dwDataLen;
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwDataLen))
return OPEN_SSL_WARNING_ERR;
X509* pCert = NULL;
char* pPassword = (password.empty()) ? NULL : (char*)password.c_str();
BIO* bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (PEM_read_bio_X509(bio, &pCert, NULL, (void*)pPassword))
{
X509_free(pCert);
BIO_free(bio);
return OPEN_SSL_WARNING_OK;
}
std::string sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
X509_free(pCert);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
BIO_free(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
if (d2i_X509_bio(bio, &pCert))
{
X509_free(pCert);
BIO_free(bio);
return OPEN_SSL_WARNING_OK;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
X509_free(pCert);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
BIO_free(bio);
bio = BIO_new_mem_buf((void*)pData, (int)dwDataLen);
PKCS12* p12 = d2i_PKCS12_bio(bio, NULL);
if (p12)
{
EVP_PKEY* pKey = NULL;
STACK_OF(X509)* pCa = NULL;
if (PKCS12_parse(p12, pPassword, &pKey, &pCert, &pCa))
{
sk_X509_pop_free(pCa, X509_free);
X509_free(pCert);
EVP_PKEY_free(pKey);
PKCS12_free(p12);
BIO_free(bio);
return OPEN_SSL_WARNING_ALL_OK;
}
sError = GetOpenSslErrors();
if (IsOpenSslPasswordError(sError))
{
PKCS12_free(p12);
BIO_free(bio);
return OPEN_SSL_WARNING_PASS;
}
PKCS12_free(p12);
}
BIO_free(bio);
return OPEN_SSL_WARNING_ERR;
}

View File

@ -0,0 +1,23 @@
#ifndef OPENSSL_WRAPPER
#define OPENSSL_WRAPPER
#define OPEN_SSL_WARNING_OK 0
#define OPEN_SSL_WARNING_ERR 1
#define OPEN_SSL_WARNING_ALL_OK 2
#define OPEN_SSL_WARNING_PASS 4
class COpenssl_library_private;
class COpenssl_library
{
private:
COpenssl_library_private* m_internal;
public:
COpenssl_library();
~COpenssl_library();
int LoadKey(std::wstring file, std::string password);
int LoadCert(std::wstring file, std::string password);
};
#endif // OPENSSL_WRAPPER

View File

@ -44,7 +44,7 @@ static time_t ASN1_GetTimeT(ASN1_TIME* time)
return mktime(&t);
}
#if 0
#if 1
int main()
{
std::wstring sFolderW = NSFile::GetProcessDirectory();
@ -141,7 +141,7 @@ int main()
}
#endif
#if 1
#if 0
int main(int argc, char **argv)
{
std::wstring sFolderW = NSFile::GetProcessDirectory();

View File

@ -262,9 +262,9 @@ namespace PdfReader
}
void CPdfReader::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
{
CFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
CFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
CFontsCache* pFontCache = new CFontsCache();
pFontCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
pFontCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
pFontManager->SetOwnerCache(pFontCache);
CGraphicsRenderer oRenderer;

View File

@ -47,6 +47,7 @@
#include "GFont.h"
#include "File.h"
#include "Stream.h"
#include "XRef.h"
namespace PdfReader
{
@ -1945,12 +1946,10 @@ namespace PdfReader
}
else
{
// Нет ссылки на данный шрифт, но ссылка нам нужна как идентефикатор, поэтому выбираем некотый уникальный номер
// (поскольку корректное версионное число состоит из 5 цифр, поэтому любое 6-циферное число будет безопасным решением)
oRef.nNum = nIndex;
if (pFontDictRef)
if (pXref)
{
oRef.nGen = 100000 + pFontDictRef->nNum;
oRef.nGen = pXref->GenerateUniqueRefGen();
}
else
{
@ -1998,4 +1997,4 @@ namespace PdfReader
}
return NULL;
}
}
}

View File

@ -69,25 +69,35 @@ namespace PdfReader
}
bool operator <(const Ref& oRight)const
{
return nNum < oRight.nNum;
if (nNum < oRight.nNum)
return true;
else if (nNum == oRight.nNum)
return nGen < oRight.nGen;
else
return false;
}
bool operator >(const Ref& oRight)const
{
return nNum > oRight.nNum;
if (nNum > oRight.nNum)
return true;
else if (nNum == oRight.nNum)
return nGen > oRight.nGen;
else
return false;
}
bool operator <=(const Ref& oRight)const
{
if (*this == oRight)
return true;
return nNum < oRight.nNum;
return (*this < oRight);
}
bool operator >=(const Ref& oRight)const
{
if (*this == oRight)
return true;
return nNum > oRight.nNum;
return (*this > oRight);
}
};

View File

@ -345,7 +345,7 @@ namespace PdfReader
m_bTransparentGroupSoftMask = false;
m_pTransparentGroupSoftMask = NULL;
m_bDrawOnlyText = false;
m_bDrawOnlyText = false;
//m_oFontList.LoadFromFile( m_pGlobalParams->GetTempFolder() );
//// Тестовый пример
@ -461,7 +461,7 @@ namespace PdfReader
if (c_nHtmlRendrerer2 == m_lRendererType)
m_bDrawOnlyText = ((NSHtmlRenderer::CASCHTMLRenderer3*)m_pRenderer)->GetOnlyTextMode();
else
m_bDrawOnlyText = false;
m_bDrawOnlyText = false;
}
void RendererOutputDev::EndPage()
{
@ -2982,39 +2982,36 @@ namespace PdfReader
double *pCTM = pGState->GetCTM();
double *pTm = pGState->GetTextMatrix();
GrFont *pFont = pGState->GetFont();
//double dTfs = pGState->GetFontSize();
//double dTh = pGState->GetHorizScaling();
//double dTrise = pGState->GetRise();
//double *pFontBBox = pGState->GetFont()->GetFontBBox();
//double dAcsentFactor = ( ( fabs(pFontBBox[1]) + fabs(pFontBBox[3]) ) - ( pFont->GetAscent() + fabs( pFont->GetDescent() ) ) ) / 2 + pFont->GetAscent();
double pNewTm[6], arrMatrix[6];
//double dKoef = 0;//( pFont->GetAscent() - fabs( pFont->GetDescent() ) ) * dTfs;
double dTextScale = min(sqrt(pTm[2] * pTm[2] + pTm[3] * pTm[3]), sqrt(pTm[0] * pTm[0] + pTm[1] * pTm[1]));
double dITextScale = 1 / dTextScale;
//pTm[0] *= dITextScale;
//pTm[1] *= dITextScale;
//pTm[2] *= dITextScale;
//pTm[3] *= dITextScale;
//double dOldSize = m_oFont.Size;
//m_oFont.Size *= dTextScale;
double dOldSize = 10.0;
m_pRenderer->get_FontSize(&dOldSize);
m_pRenderer->put_FontSize(dOldSize * dTextScale);
if (dOldSize * dTextScale > 0)
{
m_pRenderer->put_FontSize(dOldSize * dTextScale);
pNewTm[0] = pTm[0] * dITextScale;
pNewTm[1] = pTm[1] * dITextScale;
pNewTm[2] = -pTm[2] * dITextScale;
pNewTm[3] = -pTm[3] * dITextScale;
pNewTm[4] = dX;
pNewTm[5] = dY;
}
else
{
m_pRenderer->put_FontSize(-dOldSize * dTextScale);
pNewTm[0] = pTm[0] * dITextScale;
pNewTm[1] = pTm[1] * dITextScale;
pNewTm[2] = pTm[2] * dITextScale;
pNewTm[3] = pTm[3] * dITextScale;
pNewTm[4] = dX;
pNewTm[5] = dY;
}
pNewTm[0] = pTm[0] * dITextScale;
pNewTm[1] = pTm[1] * dITextScale;
pNewTm[2] = -pTm[2] * dITextScale;
pNewTm[3] = -pTm[3] * dITextScale;
//pNewTm[0] = pTm[0];
//pNewTm[1] = pTm[1];
//pNewTm[2] = -pTm[2];
//pNewTm[3] = -pTm[3];
pNewTm[4] = dX;//+ pTm[2] * dKoef;
pNewTm[5] = dY;//+ pTm[3] * dKoef;
arrMatrix[0] = pNewTm[0] * pCTM[0] + pNewTm[1] * pCTM[2];
arrMatrix[1] = -(pNewTm[0] * pCTM[1] + pNewTm[1] * pCTM[3]);
@ -3023,31 +3020,26 @@ namespace PdfReader
arrMatrix[4] = pNewTm[4] * pCTM[0] + pNewTm[5] * pCTM[2] + pCTM[4];
arrMatrix[5] = -(pNewTm[4] * pCTM[1] + pNewTm[5] * pCTM[3] + pCTM[5]) + pGState->GetPageHeight();
//double dAscentShiftX = arrMatrix[2] * pFont->GetDescent();
//double dAscentShiftY = arrMatrix[3] * pFont->GetDescent();
//arrMatrix[4] += dAscentShiftX;
//arrMatrix[5] += dAscentShiftY;
if (true)
{
double dDet = sqrt(arrMatrix[0] * arrMatrix[3] - arrMatrix[1] * arrMatrix[2]);
arrMatrix[0] /= dDet;
arrMatrix[1] /= dDet;
arrMatrix[2] /= dDet;
arrMatrix[3] /= dDet;
double dNorma = min(sqrt(arrMatrix[0] * arrMatrix[0] + arrMatrix[1] * arrMatrix[1]), sqrt(arrMatrix[2] * arrMatrix[2] + arrMatrix[3] * arrMatrix[3]));
if (dNorma > 0.001)
{
arrMatrix[0] /= dNorma;
arrMatrix[1] /= dNorma;
arrMatrix[2] /= dNorma;
arrMatrix[3] /= dNorma;
double dSize = 1;
m_pRenderer->get_FontSize(&dSize);
m_pRenderer->put_FontSize(dSize * dDet);
double dSize = 1;
m_pRenderer->get_FontSize(&dSize);
m_pRenderer->put_FontSize(dSize * dNorma);
}
}
double dShiftX = 0, dShiftY = 0;
DoTransform(arrMatrix, &dShiftX, &dShiftY, true);
// Здесь мы посылаем координаты текста в пунктах
double dPageHeight = pGState->GetPageHeight();
std::wstring wsUnicodeText;

View File

@ -241,6 +241,10 @@ namespace PdfReader
m_nPermissionFlags = DefaultPermissionFlags;
m_bOwnerPassword = false;
// Если нет ссылки на данный объект, а ссылка нам нужна как идентефикатор, то выбираем некотый уникальный номер
// (поскольку корректное версионное число состоит из 5 цифр, поэтому любое 6-циферное число будет безопасным решением)
m_unRefGenCounter = 100000;
// Читаем Trailer
m_pStream = pStream;
m_nStart = m_pStream->GetStartPos();
@ -1066,4 +1070,4 @@ namespace PdfReader
}
return unRes;
}
}
}

View File

@ -142,6 +142,10 @@ namespace PdfReader
{
return &m_oTrailerDict;
}
unsigned int GenerateUniqueRefGen()
{
return m_unRefGenCounter++;
}
private:
@ -181,6 +185,8 @@ namespace PdfReader
int m_nEncryptVersion; // Версия шифровки
CryptAlgorithm m_eEncryptAlgorithm; // Алгоритм шифрования
unsigned int m_unRefGenCounter; // Специальный счетчик для генерации уникальных ссылок для встроенных объектов
NSCriticalSection::CRITICAL_SECTION m_oCS;
};
}

View File

@ -188,7 +188,9 @@ namespace BinXlsxRW
ExternalReference = 6,
PivotCaches = 7,
PivotCache = 8,
ExternalBook = 9
ExternalBook = 9,
OleLink = 10,
DdeLink = 11
};}
namespace c_oSerWorkbookPrTypes{enum c_oSerWorkbookPrTypes
{
@ -841,6 +843,32 @@ namespace BinXlsxRW
SheetDataRowCellType = 16,
SheetDataRowCellValue = 17
};}
namespace c_oSer_OleLinkTypes{enum c_oSer_OleLinkTypes
{
Id = 0,
ProgId = 1,
OleItem = 2,
Name = 3,
Icon = 4,
Advise = 5,
PreferPic = 6
};}
namespace c_oSer_DdeLinkTypes{enum c_oSer_DdeLinkTypes
{
DdeService = 0,
DdeTopic = 1,
DdeItem = 2,
Name = 3,
Ole = 4,
Advise = 5,
PreferPic = 6,
DdeValues = 7,
DdeValuesRows = 8,
DdeValuesCols = 9,
DdeValue = 10,
DdeValueType = 11,
DdeValueVal = 12
};}
}
#endif //

View File

@ -1587,22 +1587,50 @@ namespace BinXlsxRW
if (pFile.IsInit() && OOX::Spreadsheet::FileTypes::ExternalLinks == pFile->type())
{
OOX::Spreadsheet::CExternalLink* pExternalLink = static_cast<OOX::Spreadsheet::CExternalLink*>(pFile.operator ->());
if ((pExternalLink) && (pExternalLink->m_oExternalBook.IsInit()))
if (pExternalLink)
{
std::wstring sLink;
if (pExternalLink->m_oExternalBook->m_oRid.IsInit())
if(pExternalLink->m_oExternalBook.IsInit())
{
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oExternalBook->m_oRid.get().GetValue()));
if (pFile.IsInit() && OOX::FileTypes::ExternalLinkPath == pFile->type())
std::wstring sLink;
if (pExternalLink->m_oExternalBook->m_oRid.IsInit())
{
OOX::Spreadsheet::ExternalLinkPath* pLinkFile = static_cast<OOX::Spreadsheet::ExternalLinkPath*>(pFile.operator ->());
sLink = pLinkFile->Uri().GetPath();
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oExternalBook->m_oRid.get().GetValue()));
if (pFile.IsInit() && OOX::FileTypes::ExternalLinkPath == pFile->type())
{
OOX::Spreadsheet::ExternalLinkPath* pLinkFile = static_cast<OOX::Spreadsheet::ExternalLinkPath*>(pFile.operator ->());
sLink = pLinkFile->Uri().GetPath();
}
}
if(!sLink.empty())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::ExternalBook);
WriteExternalBook(pExternalLink->m_oExternalBook.get(), sLink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
if(!sLink.empty())
else if(pExternalLink->m_oOleLink.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::ExternalBook);
WriteExternalBook(pExternalLink->m_oExternalBook.get(), sLink);
std::wstring sLink;
if (pExternalLink->m_oOleLink->m_oRid.IsInit())
{
smart_ptr<OOX::File> pFile = pExternalLink->Find( OOX::RId(pExternalLink->m_oOleLink->m_oRid.get().GetValue()));
if (pFile.IsInit() && OOX::FileTypes::OleObject == pFile->type())
{
OOX::OleObject* pLinkFile = static_cast<OOX::OleObject*>(pFile.operator ->());
sLink = pLinkFile->filename().GetPath();
}
}
if(!sLink.empty())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::OleLink);
WriteOleLink(pExternalLink->m_oOleLink.get(), sLink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
else if(pExternalLink->m_oDdeLink.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::DdeLink);
WriteDdeLink(pExternalLink->m_oDdeLink.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
@ -1748,6 +1776,155 @@ namespace BinXlsxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteOleLink(const OOX::Spreadsheet::COleLink& oleLink, const std::wstring& sLink)
{
int nCurPos = 0;
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Id);
m_oBcw.m_oStream.WriteStringW3(sLink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
if (oleLink.m_oProgId.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::ProgId);
m_oBcw.m_oStream.WriteStringW3(oleLink.m_oProgId.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oleLink.m_oOleItems.IsInit())
{
for(size_t i = 0; i < oleLink.m_oOleItems->m_arrItems.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::OleItem);
WriteOleItem(*oleLink.m_oOleItems->m_arrItems[i]);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
void WriteOleItem(const OOX::Spreadsheet::COleItem& oleItem)
{
int nCurPos = 0;
if (oleItem.m_oName.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Name);
m_oBcw.m_oStream.WriteStringW3(oleItem.m_oName.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oleItem.m_oIcon.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Icon);
m_oBcw.m_oStream.WriteBOOL(oleItem.m_oIcon->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oleItem.m_oAdvise.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::Advise);
m_oBcw.m_oStream.WriteBOOL(oleItem.m_oAdvise->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oleItem.m_oPreferPic.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_OleLinkTypes::PreferPic);
m_oBcw.m_oStream.WriteBOOL(oleItem.m_oPreferPic->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteDdeLink(const OOX::Spreadsheet::CDdeLink& ddeLink)
{
int nCurPos = 0;
if (ddeLink.m_oDdeService.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeService);
m_oBcw.m_oStream.WriteStringW3(ddeLink.m_oDdeService.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeLink.m_oDdeTopic.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeTopic);
m_oBcw.m_oStream.WriteStringW3(ddeLink.m_oDdeTopic.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeLink.m_oDdeItems.IsInit())
{
for(size_t i = 0; i < ddeLink.m_oDdeItems->m_arrItems.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeItem);
WriteDdeItem(*ddeLink.m_oDdeItems->m_arrItems[i]);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
}
void WriteDdeItem(const OOX::Spreadsheet::CDdeItem& ddeItem)
{
int nCurPos = 0;
if (ddeItem.m_oName.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::Name);
m_oBcw.m_oStream.WriteStringW3(ddeItem.m_oName.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeItem.m_oOle.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::Ole);
m_oBcw.m_oStream.WriteBOOL(ddeItem.m_oOle->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeItem.m_oAdvise.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::Advise);
m_oBcw.m_oStream.WriteBOOL(ddeItem.m_oAdvise->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeItem.m_oPreferPic.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::PreferPic);
m_oBcw.m_oStream.WriteBOOL(ddeItem.m_oPreferPic->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeItem.m_oDdeValues.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValues);
WriteDdeValues(ddeItem.m_oDdeValues.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteDdeValues(const OOX::Spreadsheet::CDdeValues& ddeValues)
{
int nCurPos = 0;
if (ddeValues.m_oRows.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValuesRows);
m_oBcw.m_oStream.WriteULONG(ddeValues.m_oRows->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (ddeValues.m_oCols.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValuesCols);
m_oBcw.m_oStream.WriteULONG(ddeValues.m_oCols->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
for(size_t i = 0; i < ddeValues.m_arrItems.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValue);
WriteDdeValue(*ddeValues.m_arrItems[i]);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteDdeValue(const OOX::Spreadsheet::CDdeValue& ddeValue)
{
int nCurPos = 0;
if (ddeValue.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValueType);
m_oBcw.m_oStream.WriteBYTE(ddeValue.m_oType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
for (size_t i = 0; i < ddeValue.m_arrItems.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_DdeLinkTypes::DdeValueVal);
m_oBcw.m_oStream.WriteStringW3(ddeValue.m_arrItems[i]->ToString());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteDefinedName(const OOX::Spreadsheet::CDefinedName& definedName)
{
int nCurPos = 0;
@ -2874,7 +3051,10 @@ namespace BinXlsxRW
{
OOX::CPath pathImage = pImageFileCache->filename();
olePic->oleObject->m_OleObjectFile->set_filename_cache(pathImage);
if (olePic->oleObject->m_OleObjectFile.IsInit())
{
olePic->oleObject->m_OleObjectFile->set_filename_cache(pathImage);
}
olePic->blipFill.blip->embed = new OOX::RId(sIdImageFileCache); //ваще то тут не важно что - приоритет у того что ниже..
olePic->blipFill.blip->oleFilepathImage = pathImage.GetPath();

View File

@ -1615,6 +1615,40 @@ namespace BinXlsxRW {
RELEASEOBJECT(extLink)
}
}
else if(c_oSerWorkbookTypes::OleLink == type)
{
OOX::Spreadsheet::CExternalLink *extLink = new OOX::Spreadsheet::CExternalLink();
extLink->m_oOleLink.Init();
res = Read1(length, &BinaryWorkbookTableReader::ReadOleLink, this, extLink);
if (extLink->m_oOleLink->m_oRid.IsInit())
{
smart_ptr<OOX::File> oCurFile(extLink);
const OOX::RId oRId = m_oWorkbook.Add(oCurFile);
OOX::Spreadsheet::CExternalReference* pExternalReference = new OOX::Spreadsheet::CExternalReference();
pExternalReference->m_oRid.Init();
pExternalReference->m_oRid->SetValue(oRId.get());
m_oWorkbook.m_oExternalReferences->m_arrItems.push_back(pExternalReference);
}
else
{
RELEASEOBJECT(extLink)
}
}
else if(c_oSerWorkbookTypes::DdeLink == type)
{
OOX::Spreadsheet::CExternalLink *extLink = new OOX::Spreadsheet::CExternalLink();
extLink->m_oDdeLink.Init();
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeLink, this, extLink->m_oDdeLink.GetPointer());
smart_ptr<OOX::File> oCurFile(extLink);
const OOX::RId oRId = m_oWorkbook.Add(oCurFile);
OOX::Spreadsheet::CExternalReference* pExternalReference = new OOX::Spreadsheet::CExternalReference();
pExternalReference->m_oRid.Init();
pExternalReference->m_oRid->SetValue(oRId.get());
m_oWorkbook.m_oExternalReferences->m_arrItems.push_back(pExternalReference);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -1832,7 +1866,173 @@ namespace BinXlsxRW {
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadOleLink(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CExternalLink* extLink = static_cast<OOX::Spreadsheet::CExternalLink*>(poResult);
OOX::Spreadsheet::COleLink* oleLink = extLink->m_oOleLink.GetPointer();
int res = c_oSerConstants::ReadOk;
if(c_oSer_OleLinkTypes::Id == type)
{
std::wstring sName(m_oBufferedStream.GetString3(length));
OOX::Spreadsheet::ExternalOleObject *link = new OOX::Spreadsheet::ExternalOleObject(sName);
smart_ptr<OOX::File> oLinkFile(link);
const OOX::RId oRIdLink = extLink->Add(oLinkFile);
oleLink->m_oRid.Init();
oleLink->m_oRid->SetValue(oRIdLink.get());
}
else if(c_oSer_OleLinkTypes::ProgId == type)
{
oleLink->m_oProgId.Init();
oleLink->m_oProgId->append(m_oBufferedStream.GetString3(length));
}
else if(c_oSer_OleLinkTypes::OleItem == type)
{
if (!oleLink->m_oOleItems.IsInit())
{
oleLink->m_oOleItems.Init();
}
OOX::Spreadsheet::COleItem* pOleItem = new OOX::Spreadsheet::COleItem();
res = Read1(length, &BinaryWorkbookTableReader::ReadOleItem, this, pOleItem);
oleLink->m_oOleItems->m_arrItems.push_back(pOleItem);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadOleItem(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::COleItem* pOleItem = static_cast<OOX::Spreadsheet::COleItem*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_OleLinkTypes::Name == type)
{
pOleItem->m_oName.Init();
pOleItem->m_oName->append(m_oBufferedStream.GetString3(length));
}
else if(c_oSer_OleLinkTypes::Icon == type)
{
pOleItem->m_oIcon.Init();
pOleItem->m_oIcon->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_OleLinkTypes::Advise == type)
{
pOleItem->m_oAdvise.Init();
pOleItem->m_oAdvise->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_OleLinkTypes::PreferPic == type)
{
pOleItem->m_oPreferPic.Init();
pOleItem->m_oPreferPic->FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadDdeLink(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeLink* ddeLink = static_cast<OOX::Spreadsheet::CDdeLink*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_DdeLinkTypes::DdeService == type)
{
ddeLink->m_oDdeService.Init();
ddeLink->m_oDdeService->append(m_oBufferedStream.GetString3(length));
}
else if(c_oSer_DdeLinkTypes::DdeTopic == type)
{
ddeLink->m_oDdeTopic.Init();
ddeLink->m_oDdeTopic->append(m_oBufferedStream.GetString3(length));
}
else if(c_oSer_DdeLinkTypes::DdeItem == type)
{
if (!ddeLink->m_oDdeItems.IsInit())
{
ddeLink->m_oDdeItems.Init();
}
OOX::Spreadsheet::CDdeItem* pDdeItem = new OOX::Spreadsheet::CDdeItem();
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeItem, this, pDdeItem);
ddeLink->m_oDdeItems->m_arrItems.push_back(pDdeItem);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadDdeItem(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeItem* pDdeItem = static_cast<OOX::Spreadsheet::CDdeItem*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_DdeLinkTypes::Name == type)
{
pDdeItem->m_oName.Init();
pDdeItem->m_oName->append(m_oBufferedStream.GetString3(length));
}
else if(c_oSer_DdeLinkTypes::Ole == type)
{
pDdeItem->m_oOle.Init();
pDdeItem->m_oOle->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_DdeLinkTypes::Advise == type)
{
pDdeItem->m_oAdvise.Init();
pDdeItem->m_oAdvise->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_DdeLinkTypes::PreferPic == type)
{
pDdeItem->m_oPreferPic.Init();
pDdeItem->m_oPreferPic->FromBool(m_oBufferedStream.GetBool());
}
else if(c_oSer_DdeLinkTypes::DdeValues == type)
{
pDdeItem->m_oDdeValues.Init();
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeValues, this, pDdeItem->m_oDdeValues.GetPointer());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadDdeValues(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeValues* pDdeValues = static_cast<OOX::Spreadsheet::CDdeValues*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_DdeLinkTypes::DdeValuesRows == type)
{
pDdeValues->m_oRows.Init();
pDdeValues->m_oRows->SetValue(m_oBufferedStream.GetULong());
}
else if(c_oSer_DdeLinkTypes::DdeValuesCols == type)
{
pDdeValues->m_oCols.Init();
pDdeValues->m_oCols->SetValue(m_oBufferedStream.GetULong());
}
else if(c_oSer_DdeLinkTypes::DdeValue == type)
{
OOX::Spreadsheet::CDdeValue* pDdeValue = new OOX::Spreadsheet::CDdeValue();
res = Read1(length, &BinaryWorkbookTableReader::ReadDdeValue, this, pDdeValue);
pDdeValues->m_arrItems.push_back(pDdeValue);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadDdeValue(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CDdeValue* pDdeValue = static_cast<OOX::Spreadsheet::CDdeValue*>(poResult);
int res = c_oSerConstants::ReadOk;
if(c_oSer_DdeLinkTypes::DdeValueType == type)
{
pDdeValue->m_oType.Init();
pDdeValue->m_oType->SetValue((SimpleTypes::Spreadsheet::EDdeValueType)m_oBufferedStream.GetUChar());
}
else if(c_oSer_DdeLinkTypes::DdeValueVal == type)
{
OOX::Spreadsheet::CText* pText = new OOX::Spreadsheet::CText();
pText->m_sText.append(m_oBufferedStream.GetString3(length));
pDdeValue->m_arrItems.push_back(pText);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
};
int ReadPivotCaches(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;