Compare commits

...

66 Commits

Author SHA1 Message Date
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
8f434efb95 . 2017-06-07 18:36:40 +03:00
244dafb02b Merge pull request #31 from ONLYOFFICE/ShockwaveNN-patch-1
Use `uname -m` for determine linux x64\x686
2017-06-07 18:35:57 +03:00
149a1bdbd5 Use uname -m for determine linux x64\x686
`uname -p` return `unknown` on several system (including debian, but not including ubuntu)
2017-06-07 18:34:18 +03:00
a79d9041bc Merge pull request #30 from ONLYOFFICE/fix/travis-status-green
Add travis example config
2017-06-07 17:26:08 +03:00
3954c42602 Add travis example config 2017-06-07 17:16:51 +03:00
29dc0aee32 . 2017-06-06 16:50:39 +03:00
d805972d6d Merge pull request #28 from ONLYOFFICE/hotfix/v4.3.5
Hotfix/v4.3.5
2017-06-05 17:19:24 +03:00
549d5a46a6 Merge branch 'develop' into hotfix/v4.3.5 2017-06-05 17:12:36 +03:00
9e867be756 Merge branch 'hotfix/v4.3.5' 2017-06-05 16:48:24 +03:00
771bf2d55c for bug 27765
EncodeXml
2017-06-05 15:03:29 +03:00
3c58cd96fc for bug 27765 2017-06-05 14:36:34 +03:00
e50864fa98 . 2017-06-05 10:39:58 +03:00
c8c0924c74 for oox2mscrypt 2017-06-02 18:43:38 +03:00
af732e4e85 . 2017-06-02 18:38:44 +03:00
47ffdae8cc PptxFormat - partly fix 35054 2017-06-02 14:35:41 +03:00
fd5870083b . 2017-06-02 11:16:59 +03:00
5ba62cb25d . 2017-06-01 16:54:16 +03:00
79e0588544 fix partly 35047 2017-06-01 16:16:39 +03:00
a3d08cfc35 XlsxFormat - fix object without replacement image 2017-06-01 14:39:41 +03:00
5caccb284a Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-06-01 12:27:46 +03:00
ce19969b52 PptxFormat - fix objects without replacement image 2017-06-01 12:24:27 +03:00
0f91dc392e test ParseAllCultureInfo 2017-06-01 11:52:36 +03:00
e9805cef30 PptxFormat - fix Ole object without image cash 2017-05-31 19:22:26 +03:00
e3e05eb2db test 2017-05-31 19:01:24 +03:00
c09f17cffb . 2017-05-31 17:56:45 +03:00
ce73dd5987 linux build error 2017-05-31 15:48:59 +03:00
77df8aacb9 . 2017-05-31 14:13:54 +03:00
ce45b2802f fix bug #34953 2017-05-31 13:46:49 +03:00
7886018d6f Oox file crypter 2017-05-31 12:35:27 +03:00
5b5cb4188e OfficeCryptReader - check data integrity 2017-05-30 19:49:54 +03:00
f797af5f17 . 2017-05-30 16:05:49 +03:00
055977535e fixed build error 2017-05-30 16:04:33 +03:00
6ab24f10f0 Added prefix for lib targets 2017-05-30 15:55:31 +03:00
12a03da231 Changed extension for ooxmlsignature 2017-05-30 15:29:43 +03:00
cb7088979a . 2017-05-30 15:26:56 +03:00
1fb1fc6c97 Added OOXMLSIGNATURE project 2017-05-30 13:15:14 +03:00
e633c3c5d1 fix bug 35012 2017-05-29 17:11:10 +03:00
0f04de34b1 OdfFormatWriter - dont write backgroud master notes, notes (errors in libre & open office) 2017-05-29 16:19:26 +03:00
3f8c2c293a XlsFormatReader - fix users file 2017-05-28 17:18:27 +03:00
2c97e743da . 2017-05-28 15:44:49 +03:00
2c83860c04 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
Conflicts:
	DesktopEditor/raster/Metafile/Emf/EmfFile.cpp
2017-05-27 15:27:51 +03:00
c64b624de2 . 2017-05-27 15:24:50 +03:00
5e3990937d OdfFormatReader - fix after testing 2017-05-27 15:17:46 +03:00
21744c1607 . 2017-05-26 17:50:23 +03:00
0892e2549f . 2017-05-26 17:48:13 +03:00
cff6f305d4 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-05-26 17:09:34 +03:00
5060071227 fix bug #35006 2017-05-26 17:07:38 +03:00
d64109eaa4 imagedata for document signature 2017-05-26 17:06:40 +03:00
ec064bbd50 signing documents 2017-05-26 16:53:02 +03:00
ec4f4fe476 Fix for cross compiling 2017-05-23 15:04:53 +03:00
634509ae28 Fix for cross compilation 2017-05-23 14:50:07 +03:00
8197fb8900 do not read theme.xml if there is rels file but there is no xml file 2017-05-16 18:18:55 +03:00
122 changed files with 5247 additions and 1829 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

@ -1 +1,14 @@
language: cpp
language: cpp
compiler: gcc
dist: trusty
addons:
apt:
packages:
- p7zip-full
script:
- exit 0
# Build fails anyway. See explanation in
# https://github.com/ONLYOFFICE/core/pull/29#issuecomment-306773327
- cd Common/3dParty && ./make.sh
- cd ../../
- make

View File

@ -178,7 +178,9 @@ namespace BinXlsxRW{
{
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;

View File

@ -307,6 +307,7 @@ namespace
content << L"<w:" << Node << L"s \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \

View File

@ -191,6 +191,12 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
}
CP_XML_STREAM() << impl_->drawing_.str();
if (!impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();
}//props выше legacyDrawing !!
if (impl_->commentsId_.length()>0)
{
CP_XML_NODE(L"legacyDrawing")
@ -205,10 +211,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
if (!impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();
}
//CP_XML_NODE(L"headerFooter){}
//CP_XML_NODE(L"rowBreaks){}

View File

@ -34,8 +34,6 @@
#include "office_presentation.h"
#include "draw_page.h"
#include <boost/foreach.hpp>
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
@ -76,9 +74,10 @@ void office_presentation::docx_convert(oox::docx_conversion_context & Context)
{
Context.start_office_text();
_CP_LOG << L"[info][docx] process pages (" << pages_.size() << L" elmements)" << std::endl;
BOOST_FOREACH(const office_element_ptr & elm, pages_)
{
elm->docx_convert(Context);
for (size_t i = 0; i < pages_.size(); i++)
{
pages_[i]->docx_convert(Context);
}
Context.end_office_text();
}
@ -87,9 +86,10 @@ void office_presentation::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.start_office_spreadsheet(this);
_CP_LOG << L"[info][xlsx] process pages (" << pages_.size() << L" elmements)" << std::endl;
BOOST_FOREACH(const office_element_ptr & elm, pages_)
{
elm->xlsx_convert(Context);
for (size_t i = 0; i < pages_.size(); i++)
{
pages_[i]->xlsx_convert(Context);
}
Context.end_office_spreadsheet();
}
@ -100,29 +100,29 @@ void office_presentation::pptx_convert(oox::pptx_conversion_context & Context)
_CP_LOG << L"[info][pptx] process pages(" << pages_.size() << L" elmements)" << std::endl;
BOOST_FOREACH(const office_element_ptr & elm, footer_decls_)
for (size_t i = 0; i < footer_decls_.size(); i++)
{
presentation_footer_decl * style = dynamic_cast<presentation_footer_decl *>(elm.get());
presentation_footer_decl * style = dynamic_cast<presentation_footer_decl *>(footer_decls_[i].get());
if (!style)
continue;
std::wstring style_name_ = L"footer:" + style->presentation_name_.get_value_or(L"");
Context.root()->odf_context().drawStyles().add(style_name_, elm);
Context.root()->odf_context().drawStyles().add(style_name_, footer_decls_[i]);
}
BOOST_FOREACH(const office_element_ptr & elm, date_time_decls_)
{
presentation_date_time_decl * style = dynamic_cast<presentation_date_time_decl *>(elm.get());
for (size_t i = 0; i < date_time_decls_.size(); i++)
{
presentation_date_time_decl * style = dynamic_cast<presentation_date_time_decl *>(date_time_decls_[i].get());
if (!style)
continue;
std::wstring style_name_ = L"datetime:" + style->presentation_name_.get_value_or(L"");
Context.root()->odf_context().drawStyles().add(style_name_, elm);
Context.root()->odf_context().drawStyles().add(style_name_, date_time_decls_[i]);
}
BOOST_FOREACH(const office_element_ptr & elm, pages_)
for (size_t i = 0; i < pages_.size(); i++)
{
elm->pptx_convert(Context);
pages_[i]->pptx_convert(Context);
}
Context.end_office_presentation();
}

View File

@ -602,17 +602,24 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
bool bLine = odf_context()->drawing_context()->isLineShape();
if (!bLine)
if (custGeom && !custGeom->cxnLst.empty())
bLine = true;
odf_context()->drawing_context()->start_area_properties();
{
odf_context()->drawing_context()->start_area_properties();
if (bLine)
{
odf_context()->drawing_context()->set_no_fill();
}
else
{
if (oox_spPr->Fill.is_init())
convert(&oox_spPr->Fill);
else if (oox_sp_style)
convert(&oox_sp_style->fillRef, 1);
}
odf_context()->drawing_context()->end_area_properties();
}
odf_context()->drawing_context()->end_area_properties();
odf_context()->drawing_context()->start_line_properties();
{

View File

@ -72,6 +72,7 @@ using namespace cpdoccore;
namespace Oox2Odf
{
PptxConverter::PptxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{
current_clrMap = NULL;
@ -342,7 +343,7 @@ void PptxConverter::convert_slides()
current_slide = slide->Master.operator->();
if (bShowLayoutMasterSp && bShowMasterSp)
convert_slide(&slide->Master->cSld, current_txStyles, false, true, 2);
convert_slide(&slide->Master->cSld, current_txStyles, false, true, Master);
else
convert(slide->Master->cSld.bg.GetPointer());
@ -350,7 +351,7 @@ void PptxConverter::convert_slides()
current_clrMap = slide->Layout->clrMapOvr->overrideClrMapping.GetPointer();
current_slide = slide->Layout.operator->();
convert_slide(&slide->Layout->cSld, current_txStyles, true, bShowLayoutMasterSp, 3);
convert_slide(&slide->Layout->cSld, current_txStyles, true, bShowLayoutMasterSp, Layout);
if (slide->Layout->transition.IsInit()) convert (slide->Layout->transition.GetPointer());
else convert (slide->Master->transition.GetPointer());
@ -402,7 +403,7 @@ void PptxConverter::convert_slides()
odp_context->current_slide().set_master_page (master_style_name);
odp_context->current_slide().set_layout_page (layout_style_name);
convert_slide (slide->cSld.GetPointer(), current_txStyles, true, bShowMasterSp, 1);
convert_slide (slide->cSld.GetPointer(), current_txStyles, true, bShowMasterSp, Slide);
convert (slide->comments.operator->());
convert (slide->Note.operator->());
@ -435,7 +436,7 @@ void PptxConverter::convert(PPTX::NotesMaster *oox_notes)
odf_context()->page_layout_context()->set_page_size(width, height);
}
convert_slide(&oox_notes->cSld, NULL, true, true, 2);
convert_slide(&oox_notes->cSld, NULL, true, true, NotesMaster);
odp_context->end_note();
@ -468,7 +469,7 @@ void PptxConverter::convert(PPTX::NotesSlide *oox_notes)
if (oox_notes->clrMapOvr.IsInit() && oox_notes->clrMapOvr->overrideClrMapping.IsInit())
current_clrMap = oox_notes->clrMapOvr->overrideClrMapping.GetPointer();
convert_slide(&oox_notes->cSld, NULL, true, true, 1);
convert_slide(&oox_notes->cSld, NULL, true, true, Notes);
odp_context->end_note();
@ -1312,13 +1313,19 @@ void PptxConverter::convert(PPTX::Logic::Bg *oox_background)
}
odf_writer::style* page_style_ = dynamic_cast<odf_writer::style*>(odp_context->current_slide().page_style_elm_.get());
odf_writer::style_drawing_page_properties* page_props = page_style_->content_.get_style_drawing_page_properties();
//необязательно
//if (page_props->content_.common_draw_fill_attlist_.draw_fill_image_name_)
//{
// page_props->content_.draw_background_size_ = L"border";
//}
odp_context->drawing_context()->end_drawing_background(page_props->content_.common_draw_fill_attlist_);
odp_context->end_drawings();
}
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp, int type)
void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp, _typePages type)
{
if (oox_slide == NULL) return;
@ -1328,7 +1335,10 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
if (oox_slide->attrName.IsInit())
odp_context->current_slide().set_page_name(oox_slide->attrName.get());
convert(oox_slide->bg.GetPointer());
if (type != Notes && type != NotesMaster)
{
convert(oox_slide->bg.GetPointer());
}
for (size_t i = 0 ; i < oox_slide->spTree.SpTreeElems.size(); i++)
{
@ -1348,7 +1358,7 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
{
int ph_type = pShape->nvSpPr.nvPr.ph->type->GetBYTECode();
if (type == 3 && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
if (type == Layout && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
continue;
odf_context()->drawing_context()->set_placeholder_type(ph_type);

View File

@ -100,6 +100,14 @@ using namespace cpdoccore;
namespace Oox2Odf
{
enum _typePages
{
Slide,
Master,
Layout,
NotesMaster,
Notes
};
class PptxConverter : public OoxConverter
{
public:
@ -119,7 +127,7 @@ namespace Oox2Odf
void convert(OOX::WritingElement *oox_unknown);
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp, int type);
void convert_slide (PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxStyles* txStyles, bool bPlaceholders, bool bFillUp, _typePages type);
void convert_layout (PPTX::Logic::CSld *oox_slide);
void convert (PPTX::Comments *oox_comments);
void convert (PPTX::NotesSlide *oox_notes);

View File

@ -282,6 +282,12 @@ namespace NSBinPptxRW
m_pContentTypes->AddDefault(strExts.substr(1));
}
if (oleData.empty() == false)
{
//plugins data - generate ole
typeAdditional = 1;
}
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strAdditional, typeAdditional, oleData);
if (!oImageManagerInfo.sFilepathAdditional.empty())
@ -346,8 +352,11 @@ namespace NSBinPptxRW
{
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
if (oPathOutput.GetPath() != strInput)
CDirectory::CopyFile(strInput, oPathOutput.GetPath());
if (oPathOutput.GetPath() != strInput && NSFile::CFileBinary::Exists(strInput))
{
NSFile::CFileBinary::Copy(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
}
else
{
@ -355,8 +364,8 @@ namespace NSBinPptxRW
strExts = _T(".png");
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImage + strExts;
SaveImageAsPng(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1))
{
@ -374,13 +383,14 @@ namespace NSBinPptxRW
if(!oleData.empty())
{
WriteOleData(strAdditionalImageOut, oleData);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else
else if (NSFile::CFileBinary::Exists(strAdditionalImage))
{
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
else if (!strAdditionalImage.empty() && nAdditionalType == 2)
{
@ -395,8 +405,11 @@ namespace NSBinPptxRW
std::wstring strAdditionalImageOut = pathOutput.GetPath();
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
if (NSFile::CFileBinary::Exists(strAdditionalImage))
{
NSFile::CFileBinary::Copy(strAdditionalImage, strAdditionalImageOut);
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
}
}
return oImageManagerInfo;
@ -1102,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\"/>";
@ -1117,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\">"));
@ -1127,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\">");
@ -1236,24 +1262,28 @@ namespace NSBinPptxRW
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strImageRelsPath = L"media/";
else strImageRelsPath = L"../media/";
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
_relsGeneratorInfo oRelsGeneratorInfo;
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
if (!oImageManagerInfo.sFilepathImage.empty())
{
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
L"\"/>");
}
if(additionalFile.is<OOX::OleObject>())
{
@ -1285,7 +1315,7 @@ namespace NSBinPptxRW
}
}
}
if(additionalFile.is<OOX::Media>())
else if(additionalFile.is<OOX::Media>())
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();

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

@ -187,8 +187,25 @@ namespace PPTX
break;
}
case BULLET_TYPE_BULLET_BLIP:
// TODO:
break;
{
pReader->Skip(5); // len + type + start attr
Logic::BuBlip *pBuBlip = new Logic::BuBlip();
pBuBlip->blip.fromPPTY(pReader);
if (pBuBlip->blip.embed.IsInit())
{
m_Bullet.reset(pBuBlip);
}
else
{//??? сбой ???
delete pBuBlip;
Logic::BuChar *pBuChar = new Logic::BuChar();
pBuChar->Char = wchar_t(L'\x2022');
m_Bullet.reset(pBuChar);
}
}break;
default:
m_Bullet.reset(new Logic::BuNone());
break;

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

@ -257,5 +257,129 @@ namespace PPTX
pWriter->EndRecord();
}
void Blip::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _s2 = pReader->GetPos();
LONG _e2 = _s2 + pReader->GetLong() + 4;
pReader->Skip(1);
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (NSBinPptxRW::g_nodeAttributeEnd == _at)
break;
if (_at == 0)
pReader->Skip(1);
}
while (pReader->GetPos() < _e2)
{
BYTE _t = pReader->GetUChar();
switch (_t)
{
case 0:
case 1:
{
// id. embed / link
pReader->Skip(4);
break;
}
case 10:
case 11:
{
// id. embed / link
pReader->GetString2();
break;
}
case 2:
{
pReader->Skip(4);
ULONG count_effects = pReader->GetULong();
for (ULONG _eff = 0; _eff < count_effects; ++_eff)
{
pReader->Skip(1); // type
ULONG rec_len = pReader->GetULong();
if (0 == rec_len)
continue;
BYTE rec = pReader->GetUChar();
if (rec == EFFECT_TYPE_ALPHAMODFIX)
{
// alpha!!!
LONG _e22 = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // startattr
PPTX::Logic::AlphaModFix* pEffect = new PPTX::Logic::AlphaModFix();
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (NSBinPptxRW::g_nodeAttributeEnd == _at)
break;
if (_at == 0)
pEffect->amt = pReader->GetLong();
}
Effects.push_back(UniEffect());
Effects[0].InitPointer(pEffect);
pReader->Seek(_e22);
}
else
{
pReader->SkipRecord();
}
}
break;
}
case 3:
{
pReader->Skip(6); // len + start attributes + type
std::wstring strImagePath = pReader->GetString2();
if (0 != strImagePath.find(_T("http:")) &&
0 != strImagePath.find(_T("https:")) &&
0 != strImagePath.find(_T("ftp:")) &&
0 != strImagePath.find(_T("file:")))
{
if (0 == strImagePath.find(_T("theme")))
{
strImagePath = pReader->m_strFolderExternalThemes + FILE_SEPARATOR_STR + strImagePath;
}
else
{
strImagePath = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + strImagePath;
}
OOX::CPath pathUrl = strImagePath;
strImagePath = pathUrl.GetPath();
}
smart_ptr<OOX::File> additionalFile;
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, additionalFile, L"", L"");
if (oRelsGeneratorInfo.nImageRId > 0)
{
embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
}
pReader->Skip(1); // end attribute
break;
}
default:
{
pReader->SkipRecord();
break;
}
}
}
pReader->Seek(_e2);
}
} // namespace Logic
} // namespace PPTX

View File

@ -91,6 +91,7 @@ namespace PPTX
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const;
virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const;

View File

@ -447,7 +447,10 @@ namespace PPTX
if (!blip.is_init())
blip = new PPTX::Logic::Blip();
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
if (oRelsGeneratorInfo.nImageRId > 0)
{
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
}
if(oRelsGeneratorInfo.nOleRId > 0)
{

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())
@ -1136,8 +1136,18 @@ namespace PPTX
}
}
if (spPr.Geometry.is_init())
bool bRect = bOle; //ole ВСЕГДА rect
if (spPr.Geometry.is<PPTX::Logic::PrstGeom>())
{
const PPTX::Logic::PrstGeom & lpGeom = spPr.Geometry.as<PPTX::Logic::PrstGeom>();
if( lpGeom.prst.get() == L"rect" )
bRect = true;
}
if (bRect == false)
{//custom vml shape
std::wstring strPath;
std::wstring strTextRect;
@ -1324,7 +1334,9 @@ namespace PPTX
}
if(oleObject->m_oId.IsInit())
{
blipFill.blip->oleRid = oleObject->m_oId.get().ToString();
if (blipFill.blip.IsInit() == false)
blipFill.blip.Init();
blipFill.blip->oleRid = oleObject->m_oId->get();
}
}
} // namespace Logic

View File

@ -409,7 +409,6 @@ namespace PPTX
pWriter->StartRecord(4);
pWriter->m_pMainDocument->getBinaryContentElem(OOX::et_w_sdtContent, oTextBoxShape.GetPointer(), *pWriter, lDataSize);
//pWriter->m_pMainDocument->getBinaryContent(TextBoxShape.get(), *pWriter, lDataSize);
pWriter->EndRecord();
if (oTextBoxBodyPr.is_init())
@ -419,6 +418,24 @@ namespace PPTX
pWriter->EndRecord();
}
}
else if (strTextBoxShape.is_init())//после конвертации старого шейпа (vml)
{
long lDataSize = 0;
ULONG lPos = pWriter->GetPosition();
pWriter->SetPosition(lPos);
pWriter->StartRecord(4);
pWriter->m_pMainDocument->getBinaryContent(strTextBoxShape.get(), *pWriter, lDataSize);
pWriter->EndRecord();
if (oTextBoxBodyPr.is_init())
{
pWriter->StartRecord(5);
oTextBoxBodyPr->toPPTY(pWriter);
pWriter->EndRecord();
}
}
else if (txBody.is_init())
{
std::wstring strContent = txBody->GetDocxTxBoxContent(pWriter, style);
@ -553,7 +570,7 @@ namespace PPTX
std::wstring strFillNode;
std::wstring strStrokeNode;;
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, bOle);
CalculateFill(spPr, style, oTheme, oClrMap, strFillAttr, strFillNode, bOle, bSignature);
CalculateLine(spPr, style, oTheme, oClrMap, strStrokeAttr, strStrokeNode, bOle, bSignature);
pWriter->StartNode(L"v:shape");

View File

@ -59,7 +59,7 @@ namespace PPTX
}
void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, NSCommon::smart_ptr<PPTX::Theme>& oTheme,
NSCommon::smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle)
NSCommon::smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle, bool bSignature)
{
PPTX::Logic::UniFill fill;
DWORD ARGB = 0;
@ -113,7 +113,7 @@ namespace PPTX
std::wstring strId = oBlip.blip->embed->ToString();
if(bOle)
if (bOle || bSignature)
{
strAttr = _T(" filled=\"f\"");
strNode = _T("<v:imagedata r:id=\"") + strId + _T("\" o:title=\"\" />");

View File

@ -44,7 +44,7 @@ namespace PPTX
namespace Logic
{
void CalculateFill(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle, smart_ptr<PPTX::Theme>& oTheme,
smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false);
smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false, bool bSignature = false);
void CalculateLine(PPTX::Logic::SpPr& oSpPr, nullable<ShapeStyle>& pShapeStyle,
smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, std::wstring& strAttr, std::wstring& strNode, bool bOle = false, bool bSignature = false);

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

@ -32,7 +32,6 @@
#include "FixedPoint.h"
#include <Binary/CFRecord.h>
//#include <Exception/AttributeDataWrong.h>
namespace OSHARED
{
@ -40,8 +39,14 @@ namespace OSHARED
FixedPoint::FixedPoint()
{
Integral = 0;
Fractional = 0;
}
FixedPoint::FixedPoint(unsigned short cbElement_)
{
Integral = 0;
Fractional = 0;
}
FixedPoint::FixedPoint(const int raw_data)
{
@ -49,7 +54,6 @@ FixedPoint::FixedPoint(const int raw_data)
Integral = static_cast<unsigned char>(raw_data >> 16);
}
XLS::BiffStructurePtr FixedPoint::clone()
{
return XLS::BiffStructurePtr(new FixedPoint(*this));

View File

@ -41,6 +41,7 @@ class CFRecord;
class FixedPoint : public XLS::BiffAttribute
{
public:
FixedPoint(unsigned short cbElement_); //fixed always!!
FixedPoint();
FixedPoint(const int raw_data);
XLS::BiffStructurePtr clone();

View File

@ -56,8 +56,11 @@ public:
unsigned short nElems, nElemsAlloc;
unsigned short cbElem;
int pos1 = record.getRdPtr();
record >> nElems >> nElemsAlloc >> cbElem;
while(nElems--)
for (unsigned short i = 0; i < nElems; i++)
{
Type element(cbElem);
record >> element;

View File

@ -223,18 +223,26 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
fopte = OfficeArtFOPTEPtr(new AdjustValue);
break;
case 0x0151:
fopte = OfficeArtFOPTEPtr(new pConnectionSites);
break;
case 0x0152:
fopte = OfficeArtFOPTEPtr(new pConnectionSitesDir);
break;
case 0x0153:
case 0x0154:
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
case 0x0155:
fopte = OfficeArtFOPTEPtr(new pAdjustHandles);
break;
case 0x0156:
fopte = OfficeArtFOPTEPtr(new pGuides);
break;
case 0x0152:
case 0x0153:
case 0x0154:
case 0x0155:
case 0x0157:
fopte = OfficeArtFOPTEPtr(new pInscribe);
break;
case 0x0158:
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);//cxk
break;
case 0x017f:
fopte = OfficeArtFOPTEPtr(new GeometryBooleanProperties);
@ -427,6 +435,14 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
return fopte;
}
FixedPoint::FixedPoint()
{
dVal = 0;
}
FixedPoint::FixedPoint(unsigned short cbElement_)
{
dVal = 0;
}
void FixedPoint::load(XLS::CFRecord& record)
{
OfficeArtFOPTE::load(record);
@ -642,17 +658,6 @@ void pihlShape::ReadComplexData(XLS::CFRecord& record)
int pos = record.getRdPtr();
record >> complex;
int pos2 = record.getRdPtr() - pos;
if (pos2 > 0 && pos2 < op)
{
record.skipNunBytes(op - pos2);
}
if (pos2 > 0 && pos2 > op)
{
record.RollRdPtrBack( pos2 - op);
}
}
//---------------------------------------------------------------------------------------------
MSOPOINT::MSOPOINT()
@ -691,6 +696,44 @@ void MSOPOINT::load(XLS::CFRecord& record)
}
}
//---------------------------------------------------------------------------------------------
MSORECT::MSORECT()
{
cbElement = 8;
}
MSORECT::MSORECT(unsigned short cbElement_)
{
cbElement = 8;
if (cbElement_ == 0xfff0)
{
cbElement = 4;
}
}
XLS::BiffStructurePtr MSORECT::clone()
{
return XLS::BiffStructurePtr(new MSORECT(*this));
}
void MSORECT::load(XLS::CFRecord& record)
{
if (cbElement == 8)
{
record >> l >> t >> r >> b;
}
else
{
unsigned short l_, t_, r_, b_;
record >> l_ >> t_ >> r_ >> b_;
l = l_;
t = t_;
r = r_;
b = b_;
}
}
//---------------------------------------------------------------------------------------------
MSOPATHINFO::MSOPATHINFO()
{
cbElement = 4;
@ -926,17 +969,6 @@ void PVertices::ReadComplexData(XLS::CFRecord& record)
int pos = record.getRdPtr();
record >> complex;
int pos2 = record.getRdPtr() - pos;
if (pos2 > 0 && pos2 < op)
{
record.skipNunBytes(op - pos2);
}
if (pos2 > 0 && pos2 > op)
{
record.RollRdPtrBack( pos2 - op);
}
}
void PSegmentInfo::ReadComplexData(XLS::CFRecord& record)
@ -945,17 +977,6 @@ void PSegmentInfo::ReadComplexData(XLS::CFRecord& record)
int pos = record.getRdPtr();
record >> complex;
int pos2 = record.getRdPtr() - pos;
if (pos2 > 0 && pos2 < op)
{
record.skipNunBytes(op - pos2);
}
if (pos2 > 0 && pos2 > op)
{
record.RollRdPtrBack( pos2 - op);
}
}
void pGuides::ReadComplexData(XLS::CFRecord& record)
@ -964,17 +985,6 @@ void pGuides::ReadComplexData(XLS::CFRecord& record)
int pos = record.getRdPtr();
record >> complex;
int pos2 = record.getRdPtr() - pos;
if (pos2 > 0 && pos2 < op)
{
record.skipNunBytes(op - pos2);
}
if (pos2 > 0 && pos2 > op)
{
record.RollRdPtrBack( pos2 - op);
}
}
void pAdjustHandles::ReadComplexData(XLS::CFRecord& record)
{
@ -983,16 +993,26 @@ void pAdjustHandles::ReadComplexData(XLS::CFRecord& record)
int pos = record.getRdPtr();
record >> complex;
}
void pConnectionSites::ReadComplexData(XLS::CFRecord& record)
{
complex.op = op;
int pos = record.getRdPtr();
int pos2 = record.getRdPtr() - pos;
record >> complex;
}
void pConnectionSitesDir::ReadComplexData(XLS::CFRecord& record)
{
complex.op = op;
int pos = record.getRdPtr();
if (pos2 > 0 && pos2 < op)
{
record.skipNunBytes(op - pos2);
}
if (pos2 > 0 && pos2 > op)
{
record.RollRdPtrBack( pos2 - op);
}
record >> complex;
}
void pInscribe::ReadComplexData(XLS::CFRecord& record)
{
complex.op = op;
int pos = record.getRdPtr();
record >> complex;
}
}

View File

@ -88,7 +88,10 @@ class fillColor : public OfficeArtFOPTE
class FixedPoint : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(fillColor)
BASE_STRUCTURE_DEFINE_CLASS_NAME(FixedPoint)
FixedPoint();
FixedPoint(unsigned short cbElement_); //fixed always!!
virtual void load(XLS::CFRecord& record);
double dVal;
@ -574,6 +577,28 @@ class MSOPOINT : public XLS::BiffStructure
int cbElement;
};
class MSORECT : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(MSORECT)
MSORECT(unsigned short cbElement_);
MSORECT();
XLS::BiffStructurePtr clone();
virtual void load(XLS::CFRecord& record);
static const XLS::ElementType type = XLS::typeOfficeArtRecord;
_INT32 l;
_INT32 t;
_INT32 r;
_INT32 b;
int cbElement;
};
class MSOPATHINFO : public XLS::BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(MSOPATHINFO)
@ -710,6 +735,40 @@ class pAdjustHandles : public OfficeArtFOPTE
IMsoArray<ADJH> complex;
};
class pConnectionSites : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(pConnectionSites)
virtual void ReadComplexData(XLS::CFRecord& record);
IMsoArray<MSOPOINT> complex;
};
class pConnectionSitesDir : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(pConnectionSitesDir)
virtual void ReadComplexData(XLS::CFRecord& record);
IMsoArray<ODRAW::FixedPoint> complex;
};
class pInscribe : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(pInscribe)
virtual void ReadComplexData(XLS::CFRecord& record);
IMsoArray<MSORECT> complex;
};
//class cxk : public OfficeArtFOPTE
//{
// BASE_STRUCTURE_DEFINE_CLASS_NAME(cxk)
//
// virtual void ReadComplexData(XLS::CFRecord& record);
//
// IMsoArray<MSOCXK> complex;
//};
class lineOpacity : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineOpacity)

View File

@ -221,7 +221,7 @@ int CELL_GROUP::serialize(std::wostream & stream)
CP_XML_ATTR(L"customFormat", true);
}
}
if (row->miyRw > 0/* && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
if (row->miyRw > 0 && row->miyRw < 0x8000) //v8_14A_1b13.xls
{
CP_XML_ATTR(L"ht", row->miyRw / 20.);
CP_XML_ATTR(L"customHeight", true);

View File

@ -115,30 +115,30 @@ public:
m_strRect = Shape->m_strRect;
m_arAdjustments.clear();
for(int i = 0; i < Shape->m_arAdjustments.size(); i++)
for(size_t i = 0; i < Shape->m_arAdjustments.size(); i++)
m_arAdjustments.push_back(Shape->m_arAdjustments[i]);
m_arGuides.clear();
for(int i = 0; i < Shape->m_arGuides.size(); i++)
for(size_t i = 0; i < Shape->m_arGuides.size(); i++)
m_arGuides.push_back(Shape->m_arGuides[i]);
m_eJoin = Shape->m_eJoin;
m_bConcentricFill = Shape->m_bConcentricFill;
m_arConnectors.clear();
for(int i = 0; i < Shape->m_arConnectors.size(); i++)
for(size_t i = 0; i < Shape->m_arConnectors.size(); i++)
m_arConnectors.push_back(Shape->m_arConnectors[i]);
m_arConnectorAngles.clear();
for(int i = 0; i < Shape->m_arConnectorAngles.size(); i++)
for(size_t i = 0; i < Shape->m_arConnectorAngles.size(); i++)
m_arConnectorAngles.push_back(Shape->m_arConnectorAngles[i]);
m_arTextRects.clear();
for(int i = 0; i < Shape->m_arTextRects.size(); i++)
for(size_t i = 0; i < Shape->m_arTextRects.size(); i++)
m_arTextRects.push_back(Shape->m_arTextRects[i]);
m_arHandles.clear();
for(int i = 0; i < Shape->m_arHandles.size(); i++)
for(size_t i = 0; i < Shape->m_arHandles.size(); i++)
m_arHandles.push_back(Shape->m_arHandles[i]);
@ -157,26 +157,26 @@ public:
// Shape->m_strRect = m_strRect;
//
// Shape->m_arAdjustments.clear();
// for(int i = 0; i < m_arAdjustments.size(); i++)
// for(size_t i = 0; i < m_arAdjustments.size(); i++)
// Shape->m_arAdjustments.push_back(m_arAdjustments[i]);
// Shape->Guides.clear();
// for(int i = 0; i < Guides.size(); i++)
// for(size_t i = 0; i < Guides.size(); i++)
// Shape->Guides.push_back(Guides[i]);
// Shape->m_eJoin = m_eJoin;
// Shape->m_bConcentricFill = m_bConcentricFill;
// Shape->m_arConnectors.clear();
// for(int i = 0; i < m_arConnectors.size(); i++)
// for(size_t i = 0; i < m_arConnectors.size(); i++)
// Shape->m_arConnectors.push_back(m_arConnectors[i]);
// Shape->m_arConnectorAngles.clear();
// for(int i = 0; i < m_arConnectorAngles.size(); i++)
// for(size_t i = 0; i < m_arConnectorAngles.size(); i++)
// Shape->m_arConnectorAngles.push_back(m_arConnectorAngles[i]);
// Shape->m_arTextRects.clear();
// for(int i = 0; i < m_arTextRects.size(); i++)
// for(size_t i = 0; i < m_arTextRects.size(); i++)
// Shape->m_arTextRects.push_back(m_arTextRects[i]);
// Shape->m_strRect = m_strRect;

View File

@ -351,12 +351,12 @@ private:
m_lShapeHeight = oSrc.m_lShapeHeight;
m_arResults.clear();
for (int nIndex = 0; nIndex < oSrc.m_arResults.size(); ++nIndex)
for (size_t nIndex = 0; nIndex < oSrc.m_arResults.size(); ++nIndex)
{
m_arResults.push_back(oSrc.m_arResults[nIndex]);
}
m_arFormulas.clear();
for (int nIndex = 0; nIndex < oSrc.m_arFormulas.size(); ++nIndex)
for (size_t nIndex = 0; nIndex < oSrc.m_arFormulas.size(); ++nIndex)
{
m_arFormulas.push_back(oSrc.m_arFormulas[nIndex]);
}
@ -379,7 +379,7 @@ private:
//m_arFormulas.clear();
//m_arResults.clear();
for (int nIndex = 0; nIndex < m_arResults.size(); ++nIndex)
for (size_t nIndex = 0; nIndex < m_arResults.size(); ++nIndex)
{
m_arResults[nIndex] = 0xFFFFFFFF;
}
@ -399,7 +399,7 @@ private:
}
void CalculateResults()
{
for (int index = 0; index < m_arFormulas.size(); ++index)
for (size_t index = 0; index < m_arFormulas.size(); ++index)
{
LONG lResult = m_arFormulas[index].CalculateFormula(this);
}

View File

@ -426,7 +426,7 @@ namespace NSCustomShapesConvert
{
m_eType = oSrc.m_eType;
this->m_arPoints.clear();
for (int nIndex = 0; nIndex < oSrc.m_arPoints.size(); ++nIndex)
for (size_t nIndex = 0; nIndex < oSrc.m_arPoints.size(); ++nIndex)
{
this->m_arPoints.push_back(oSrc.m_arPoints[nIndex]);
}
@ -771,7 +771,7 @@ namespace NSCustomShapesConvert
case rtAngleEllipseTo:
{
int nFigure = 0;
while ((nFigure + 3) <= this->m_arPoints.size())
while ((nFigure + 3) <= (int)this->m_arPoints.size())
{
double nLeft = this->m_arPoints[nFigure].dX - this->m_arPoints[nFigure + 1].dX / 2;
double nTop = this->m_arPoints[nFigure].dY - this->m_arPoints[nFigure + 1].dY / 2;
@ -790,7 +790,7 @@ namespace NSCustomShapesConvert
{
pRenderer->PathCommandStart();
int nFigure = 0;
while ((nFigure + 3) <= this->m_arPoints.size())
while ((nFigure + 3) <= (int)this->m_arPoints.size())
{
double nLeft = this->m_arPoints[nFigure].dX - this->m_arPoints[nFigure + 1].dX / 2;
double nTop = this->m_arPoints[nFigure].dY - this->m_arPoints[nFigure + 1].dY / 2;
@ -809,7 +809,7 @@ namespace NSCustomShapesConvert
{
pRenderer->PathCommandStart();
int nFigure = 0;
while ((nFigure + 4) <= this->m_arPoints.size())
while ((nFigure + 4) <= (int)this->m_arPoints.size())
{
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
@ -834,7 +834,7 @@ namespace NSCustomShapesConvert
case rtArcTo:
{
int nFigure = 0;
while ((nFigure + 4) <= this->m_arPoints.size())
while ((nFigure + 4) <= (int)this->m_arPoints.size())
{
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
@ -859,7 +859,7 @@ namespace NSCustomShapesConvert
case rtClockwiseArcTo:
{
int nFigure = 0;
while ((nFigure + 4) <= this->m_arPoints.size())
while ((nFigure + 4) <= (int)this->m_arPoints.size())
{
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
@ -885,7 +885,7 @@ namespace NSCustomShapesConvert
{
pRenderer->PathCommandStart();
int nFigure = 0;
while ((nFigure + 4) <= this->m_arPoints.size())
while ((nFigure + 4) <= (int)this->m_arPoints.size())
{
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;

View File

@ -332,7 +332,7 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook)
convert((XLS::GlobalsSubstream*)woorkbook->m_GlobalsSubstream.get());
int count_sheets = 0, count_chart_sheets = 0;
for (int i=0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++)
for (size_t i = 0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++)
{
if (woorkbook->m_arWorksheetSubstream[i]->get_type() == XLS::typeWorksheetSubstream)
{
@ -406,14 +406,14 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
{
CP_XML_NODE(L"mergeCells")
{
for (int i = 0 ; i < sheet->m_arMergeCells.size(); i++)
for (size_t i = 0 ; i < sheet->m_arMergeCells.size(); i++)
{
sheet->m_arMergeCells[i]->serialize(CP_XML_STREAM());
}
}
}
}
for (int i = 0 ; i < sheet->m_arHLINK.size(); i++)
for (size_t i = 0 ; i < sheet->m_arHLINK.size(); i++)
{
convert((XLS::HLINK*)sheet->m_arHLINK[i].get());
}
@ -438,7 +438,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
if (!sheet->m_arNote.empty() && xls_global_info->Version < 0x0600)
{
xlsx_context->get_drawing_context().start_drawing(0);
for (int i = 0 ; i < sheet->m_arNote.size(); i++)
for (size_t i = 0 ; i < sheet->m_arNote.size(); i++)
{
xlsx_context->get_drawing_context().start_drawing(0x0019);
convert(dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get()));
@ -452,7 +452,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
sheet->m_PAGESETUP->serialize(xlsx_context->current_sheet().pageProperties());
}
for (int i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
for (size_t i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
{
//convert(dynamic_cast<XLS::Note*>(sheet->sheet->m_arHFPictureDrawing[i].get(),
}
@ -463,7 +463,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
{
CP_XML_NODE(L"customSheetViews")
{
for (int i = 0 ; i < sheet->m_arCUSTOMVIEW.size(); i++)
for (size_t i = 0 ; i < sheet->m_arCUSTOMVIEW.size(); i++)
{
sheet->m_arCUSTOMVIEW[i]->serialize(CP_XML_STREAM());
}
@ -476,7 +476,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
convert(dynamic_cast<XLS::BACKGROUND*>(sheet->m_BACKGROUND.get()));
}
for (int i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
for (size_t i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
{
convert((ODRAW::OfficeArtDgContainer*)sheet->m_arHFPictureDrawing[i].get());
}
@ -492,26 +492,26 @@ void XlsConverter::convert(XLS::GlobalsSubstream* global)
convert((XLS::SHAREDSTRINGS*)global->m_SHAREDSTRINGS.get());
for (int i = 0 ; i < global->m_arLBL.size(); i++)
for (size_t i = 0 ; i < global->m_arLBL.size(); i++)
{
convert((XLS::LBL*)global->m_arLBL[i].get());
}
for (int i = 0 ; i < global->m_arMSODRAWINGGROUP.size(); i++)
for (size_t i = 0 ; i < global->m_arMSODRAWINGGROUP.size(); i++)
{
convert((XLS::MSODRAWINGGROUP*)global->m_arMSODRAWINGGROUP[i].get());
}
for (int i = 0 ; i < global->m_arHFPictureDrawing.size(); i++)
for (size_t i = 0 ; i < global->m_arHFPictureDrawing.size(); i++)
{
convert((ODRAW::OfficeArtDgContainer*)global->m_arHFPictureDrawing[i].get());
}
for (int i = 0 ; i < global->m_arWindow1.size(); i++)
for (size_t i = 0 ; i < global->m_arWindow1.size(); i++)
{
global->m_arWindow1[i]->serialize(xlsx_context->workbook_views());
}
for (int i = 0 ; i < global->m_arUserBView.size(); i++)
for (size_t i = 0 ; i < global->m_arUserBView.size(); i++)
{
global->m_arUserBView[i]->serialize(xlsx_context->custom_views());
}
@ -544,7 +544,7 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
}
CP_XML_ATTR(L"count", fills_out.size());
for (int i = 0 ;i < fills_out.size(); i++)
for (size_t i = 0 ;i < fills_out.size(); i++)
{
fills_out[i].serialize(CP_XML_STREAM());
}
@ -560,7 +560,7 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
}
CP_XML_ATTR(L"count", borders_out.size());
for (int i = 0 ;i < borders_out.size(); i++)
for (size_t i = 0 ;i < borders_out.size(); i++)
{
borders_out[i].serialize(CP_XML_STREAM());
}
@ -740,7 +740,7 @@ void XlsConverter::convert(ODRAW::OfficeArtBStoreContainer* art_bstore, int star
if (art_bstore == NULL) return;
if (art_bstore->rgfb.size() < 1) return;
for (int i = 0 ; i < art_bstore->rgfb.size(); i++)
for (size_t i = 0 ; i < art_bstore->rgfb.size(); i++)
{
int bin_id = i + start_id + 1;
@ -896,7 +896,7 @@ void XlsConverter::convert_old(XLS::OBJECTS* objects, XLS::WorksheetSubstream *
xlsx_context->get_drawing_context().set_line_old_version(obj->old_version.line);
xlsx_context->get_drawing_context().set_flag_old_version(obj->old_version.flag, obj->old_version.flag2);
for (int i = 0 ; i < obj->old_version.additional.size(); i++)
for (size_t i = 0 ; i < obj->old_version.additional.size(); i++)
{
convert(obj->old_version.additional[i].get());
}
@ -1020,7 +1020,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
{
text_obj->preserve_enabled = true;
for (int i = 0 ; i < sheet->m_arNote.size(); i++)
for (size_t i = 0 ; i < sheet->m_arNote.size(); i++)
{
XLS::Note* note = dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get());
if ((note) && (note->note_sh.idObj == obj->cmo.id))
@ -1055,7 +1055,7 @@ void XlsConverter::convert(ODRAW::OfficeArtSpgrContainer * spgr)
if (spgr == NULL) return;
if (spgr->anchor_type_ != ODRAW::OfficeArtRecord::CA_HF) return; //todooo проверить что тока для header/footer это нужно
for (int i = 0; i < spgr->child_records.size(); i++)
for (size_t i = 0; i < spgr->child_records.size(); i++)
{
int type_object = 2;//rect
@ -1076,7 +1076,7 @@ void XlsConverter::convert(ODRAW::OfficeArtSpContainer *sp, bool anchor_only)
{
convert(sp->m_OfficeArtFSP.get());
for (int i = 0; i < sp->child_records.size(); i++)
for (size_t i = 0; i < sp->child_records.size(); i++)
{
convert(sp->child_records[i].get());
}
@ -1140,12 +1140,12 @@ void XlsConverter::convert(ODRAW::OfficeArtRecord * art)
{
ODRAW::OfficeArtDgContainer * dg = dynamic_cast<ODRAW::OfficeArtDgContainer *>(art);
for (int i = 0 ; i < dg->child_records.size(); i++) //a-la msodrawing for headers/footers
for (size_t i = 0 ; i < dg->child_records.size(); i++) //a-la msodrawing for headers/footers
{
convert(dg->child_records[i].get());
}
for (int i = 0; i < dg->m_OfficeArtSpContainer.size(); i++)
for (size_t i = 0; i < dg->m_OfficeArtSpContainer.size(); i++)
{
convert(dg->m_OfficeArtSpContainer[i].get());
}
@ -1167,7 +1167,7 @@ void XlsConverter::convert(ODRAW::OfficeArtFSP * fsp)
}
void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1286,7 +1286,7 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
ODRAW::fillShadeColors *shadeColors = (ODRAW::fillShadeColors *)(props[i].get());
for (int i = 0 ; (shadeColors) && (i < shadeColors->fillShadeColors_complex.data.size()); i++)
for (size_t i = 0 ; (shadeColors) && (i < shadeColors->fillShadeColors_complex.data.size()); i++)
{
ODRAW::OfficeArtCOLORREF & color = shadeColors->fillShadeColors_complex.data[i].color;
@ -1325,7 +1325,7 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
if (props.size() < 1) return;
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1403,6 +1403,18 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
}
}
}break;
case NSOfficeDrawing::lineMiterLimit:
{
xlsx_context->get_drawing_context().set_line_miter(props[i]->op);
}break;
case NSOfficeDrawing::lineJoinStyle:
{
xlsx_context->get_drawing_context().set_line_join(props[i]->op);
}break;
case NSOfficeDrawing::lineEndCapStyle:
{
xlsx_context->get_drawing_context().set_line_endcap(props[i]->op);
}break;
}
}
}
@ -1410,7 +1422,7 @@ void XlsConverter::convert_blip(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
if (props.size() < 1) return;
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
ODRAW::FixedPoint * fixed_point = static_cast<ODRAW::FixedPoint *>(props[i].get());
switch(props[i]->opid)
@ -1457,7 +1469,7 @@ void XlsConverter::convert_geometry(std::vector<ODRAW::OfficeArtFOPTEPtr> & prop
oox::_rect rect;
std::vector<_CP_OPT(int)> adjustValues(8);
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1489,6 +1501,24 @@ void XlsConverter::convert_geometry(std::vector<ODRAW::OfficeArtFOPTEPtr> & prop
adjustValues[props[i]->opid - 0x0147] = props[i]->op ;
}break;
case 0x0151:
{
ODRAW::pConnectionSites * a = (ODRAW::pConnectionSites *)(props[i].get());
xlsx_context->get_drawing_context().set_custom_connection(a->complex.data);
}break;
case 0x0152:
{
ODRAW::pConnectionSitesDir * a = (ODRAW::pConnectionSitesDir *)(props[i].get());
xlsx_context->get_drawing_context().set_custom_connectionDir(a->complex.data);
}break;
case 0x0153:
{
xlsx_context->get_drawing_context().set_custom_x_limo(props[i]->op);
}break;
case 0x0154:
{
xlsx_context->get_drawing_context().set_custom_y_limo(props[i]->op);
}break;
case 0x0155:
{
ODRAW::pAdjustHandles * a = (ODRAW::pAdjustHandles *)(props[i].get());
xlsx_context->get_drawing_context().set_custom_adjustHandles(a->complex.data);
@ -1498,6 +1528,16 @@ void XlsConverter::convert_geometry(std::vector<ODRAW::OfficeArtFOPTEPtr> & prop
ODRAW::pGuides* s = (ODRAW::pGuides *)(props[i].get());
xlsx_context->get_drawing_context().set_custom_guides(s->complex.data);
}break;
case 0x0157:
{
ODRAW::pInscribe * a = (ODRAW::pInscribe *)(props[i].get());
xlsx_context->get_drawing_context().set_custom_inscribe(a->complex.data);
}break;
//case 0x0158:
// {
// ODRAW::cxk * a = (ODRAW::cxk *)(props[i].get());
// xlsx_context->get_drawing_context().set_custom_cxk(a->complex.data);
// }break;
}
}
rect.cy -= rect.y;
@ -1510,7 +1550,7 @@ void XlsConverter::convert_geometry_text(std::vector<ODRAW::OfficeArtFOPTEPtr> &
{
if (props.size() < 1) return;
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1571,7 +1611,7 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
if (props.size() < 1) return;
RECT text_margin = {0x00016530, 0x0000b298, 0x00016530, 0x0000b298};
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1647,20 +1687,20 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
}
void XlsConverter::convert_shadow(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_shape(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
}
}
void XlsConverter::convert_group_shape(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1726,7 +1766,7 @@ void XlsConverter::convert(XLS::Note* note)
void XlsConverter::convert_transform(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
{
for (int i = 0 ; i < props.size() ; i++)
for (size_t i = 0 ; i < props.size() ; i++)
{
switch(props[i]->opid)
{
@ -1774,7 +1814,7 @@ void XlsConverter::convert(XLS::SHAREDSTRINGS* sharedstrings)
}
}
for (int i = 0 ; i < xls_global_info->arAddedSharedStrings.size(); i++)
for (size_t i = 0 ; i < xls_global_info->arAddedSharedStrings.size(); i++)
{
CP_XML_NODE(L"si")
{

View File

@ -622,7 +622,7 @@ void xlsx_drawing_context::serialize_group()
//serialize_line(CP_XML_STREAM(), drawing_state);
}
for (int i = 1; i < current_drawing_states->size(); i++)
for (size_t i = 1; i < current_drawing_states->size(); i++)
{
CP_XML_STREAM() << current_drawing_states->at(i)->shape;
//todooo current_drawing_states->at(i).shape.erase(); // память поэкономить
@ -1033,7 +1033,7 @@ std::wstring xlsx_drawing_context::convert_custom_shape(_drawing_state_ptr & dra
shape->m_oCustomVML.m_bIsVerticesPresent = drawing_state->custom_verticles.empty() ? false : true;
for (int i = 0 ; i < drawing_state->custom_verticles.size(); i++)
for (size_t i = 0 ; i < drawing_state->custom_verticles.size(); i++)
{
Aggplus::POINT p;
@ -1043,7 +1043,7 @@ std::wstring xlsx_drawing_context::convert_custom_shape(_drawing_state_ptr & dra
shape->m_oCustomVML.m_arVertices.push_back(p);
}
for (int i = 0 ; i < drawing_state->custom_guides.size(); i++)
for (size_t i = 0 ; i < drawing_state->custom_guides.size(); i++)
{//todooo объеденить/срастить !!
NSCustomShapesConvert::CGuide guid;
@ -1058,7 +1058,7 @@ std::wstring xlsx_drawing_context::convert_custom_shape(_drawing_state_ptr & dra
shape->m_oCustomVML.addGuide(guid);
}
for (int i = 0 ; i < drawing_state->custom_segments.size(); i++)
for (size_t i = 0 ; i < drawing_state->custom_segments.size(); i++)
{
if (0 == drawing_state->custom_segments[i].m_nCount)
{
@ -1076,7 +1076,7 @@ std::wstring xlsx_drawing_context::convert_custom_shape(_drawing_state_ptr & dra
//{//todooo - ранее этого не было ?????
// shape->m_oCustomVML.addHandle(i, *drawing_state->custom_adjustHandles[i]);
//}
for (int i = 0; i < drawing_state->custom_adjustValues.size(); i++)
for (size_t i = 0; i < drawing_state->custom_adjustValues.size(); i++)
{
if (drawing_state->custom_adjustValues[i])
{
@ -1301,7 +1301,7 @@ void xlsx_drawing_context::serialize_gradient_fill(std::wostream & stream, _draw
if ( !fill.colorsPosition.empty() )
{
for (int i = 0; i < fill.colorsPosition.size(); i++)
for (size_t i = 0; i < fill.colorsPosition.size(); i++)
{
CP_XML_NODE(L"a:gs")
{
@ -1600,6 +1600,13 @@ void xlsx_drawing_context::serialize_line(std::wostream & stream, _drawing_state
else
CP_XML_ATTR(L"w", 9525); //default
switch(line.endcap)
{
case 0: CP_XML_ATTR(L"cap", L"rnd"); break;
case 1: CP_XML_ATTR(L"cap", L"sq"); break;
case 2: CP_XML_ATTR(L"cap", L"flat"); break;
}
serialize_fill(CP_XML_STREAM(), line.fill);
CP_XML_NODE(L"a:prstDash")
@ -1613,6 +1620,18 @@ void xlsx_drawing_context::serialize_line(std::wostream & stream, _drawing_state
case lineDashDotDot:CP_XML_ATTR(L"val", L"lgDashDotDot"); break;
}
}
switch(line.join)
{
case 0: CP_XML_NODE(L"a:bevel"); break;
case 1:
CP_XML_NODE(L"a:miter")
{
if (line.miter > 0)
CP_XML_ATTR(L"lim", line.miter * 1000);
}break;
case 2: CP_XML_NODE(L"a:round"); break;
}
if (line.arrow.enabled)
{
serialize_arrow(CP_XML_STREAM(), L"a:headEnd", line.arrow.start, line.arrow.start_width, line.arrow.start_length);
@ -2019,7 +2038,27 @@ void xlsx_drawing_context::set_line_width (int val)
current_drawing_states->back()->line.width = val;
}
void xlsx_drawing_context::set_line_miter(int val)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->line.miter = val;
}
void xlsx_drawing_context::set_line_join(int val)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->line.join = val;
}
void xlsx_drawing_context::set_line_endcap(int val)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->line.endcap = val;
}
void xlsx_drawing_context::set_line_arrow(bool val)
{
if (current_drawing_states == NULL) return;
@ -2032,7 +2071,8 @@ void xlsx_drawing_context::set_arrow_start (int val)
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->line.arrow.start = val;
current_drawing_states->back()->line.arrow.start = val;
current_drawing_states->back()->line.arrow.enabled = true;
}
void xlsx_drawing_context::set_arrow_end (int val)
{
@ -2040,6 +2080,7 @@ void xlsx_drawing_context::set_arrow_end (int val)
if (current_drawing_states->empty()) return;
current_drawing_states->back()->line.arrow.end = val;
current_drawing_states->back()->line.arrow.enabled = true;
}
void xlsx_drawing_context::set_arrow_start_width (int val)
{
@ -2375,6 +2416,41 @@ void xlsx_drawing_context::set_custom_path (int type_path)
current_drawing_states->back()->custom_path = type_path;
}
void xlsx_drawing_context::set_custom_connection(std::vector<ODRAW::MSOPOINT>& points)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->custom_connection = points;
}
void xlsx_drawing_context::set_custom_connectionDir(std::vector<ODRAW::FixedPoint>& points)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->custom_connectionDir = points;
}
void xlsx_drawing_context::set_custom_inscribe(std::vector<ODRAW::MSORECT>& rects)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->custom_inscribe = rects;
}
void xlsx_drawing_context::set_custom_x_limo(int val)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->custom_x_limo = val;
}
void xlsx_drawing_context::set_custom_y_limo(int val)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
current_drawing_states->back()->custom_y_limo = val;
}
//----------------------------------------------------------------------------------------------------------
bool xlsx_drawing_context::get_mode_vmlwrite ()
{//comment, shapes in header/footer, ....
@ -2435,7 +2511,7 @@ void xlsx_drawing_context::serialize_vml_HF(std::wostream & strm)
CP_XML_ATTR(L"xmlns:o" , L"urn:schemas-microsoft-com:office:office");
CP_XML_ATTR(L"xmlns:x" , L"urn:schemas-microsoft-com:office:excel");
for (int i = 0 ; i < drawing_states_vml_HF.size(); i++)
for (size_t i = 0 ; i < drawing_states_vml_HF.size(); i++)
{
serialize_vml(CP_XML_STREAM(), drawing_states_vml_HF[i]);
}
@ -2471,7 +2547,7 @@ void xlsx_drawing_context::serialize_vml_comments(std::wostream & strm)
}
}
for (int i = 0 ; i < drawing_states_vml_comments.size(); i++)
for (size_t i = 0 ; i < drawing_states_vml_comments.size(); i++)
{
serialize_vml(CP_XML_STREAM(), drawing_states_vml_comments[i]);
}
@ -2490,7 +2566,7 @@ void xlsx_drawing_context::serialize(std::wostream & strm)
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:mc" , L"http://schemas.openxmlformats.org/markup-compatibility/2006");
for (int i = 0 ; i < drawing_states.size(); i++)
for (size_t i = 0 ; i < drawing_states.size(); i++)
{
serialize(CP_XML_STREAM(), drawing_states[i]);
}

View File

@ -137,10 +137,12 @@ public:
type_anchor(0),
vmlwrite_mode_(false)
{
id = -1;
rotation = 0;
parent_drawing_states = NULL;
custom_path = -1;
id = -1;
rotation = 0;
parent_drawing_states = NULL;
custom_path = -1;
custom_x_limo = 0x80000000;
custom_y_limo = 0x80000000;
}
external_items::Type type;
@ -179,10 +181,15 @@ public:
std::vector<ODRAW::MSOSG> custom_guides;
std::vector<ODRAW::MSOPOINT> custom_verticles;
std::vector<ODRAW::ADJH> custom_adjustHandles;
std::vector<ODRAW::MSOPOINT> custom_connection;
std::vector<ODRAW::FixedPoint> custom_connectionDir;
std::vector<ODRAW::MSORECT> custom_inscribe;
_rect custom_rect;
std::vector<_CP_OPT(int)> custom_adjustValues;
int custom_path;
int custom_x_limo;
int custom_y_limo;
//-----------------------------------------------
std::wstring hyperlink;
struct _text
@ -265,12 +272,15 @@ public:
};
struct _line
{
_line() { fill.color.SetRGB(0, 0, 0); width = 0; }
_line() : join(-1), endcap(-1), miter(0), width(0) { fill.color.SetRGB(0, 0, 0); }
std::wstring style;
int width;
_line_typeDash typeDash;
_fill fill;
_arrow arrow;
int miter;
int join;
int endcap;
}line;
struct _object
{
@ -357,6 +367,9 @@ public:
void set_arrow_end_width (int val);
void set_arrow_start_length (int val);
void set_arrow_end_length (int val);
void set_line_miter (int val);
void set_line_join (int val);
void set_line_endcap (int val);
void set_fill_old_version (_UINT32 val);
void set_line_old_version (_UINT32 val);
@ -399,6 +412,11 @@ public:
void set_custom_adjustHandles(std::vector<ODRAW::ADJH> & handles);
void set_custom_adjustValues(std::vector<_CP_OPT(int)> & values);
void set_custom_path (int type_path);
void set_custom_connection (std::vector<ODRAW::MSOPOINT> & points);
void set_custom_connectionDir(std::vector<ODRAW::FixedPoint>& points);
void set_custom_inscribe (std::vector<ODRAW::MSORECT> & rects);
void set_custom_x_limo (int val);
void set_custom_y_limo (int val);
//------------------------------------------------------------------------------
void serialize_group ();
void serialize_shape (_drawing_state_ptr & drawing_state);

View File

@ -1,19 +1,21 @@
SET SCRIPTPATH=%~dp0
CD /D %~dp0
SET PLATFORM=win
SET ARCH=_32
SET PLATFORM=win_32
if defined ProgramFiles(x86) (
SET ARCH=_64
SET PLATFORM=win_64
)
mkdir "%SCRIPTPATH%%PLATFORM%%ARCH%"
cd "%SCRIPTPATH%%PLATFORM%%ARCH%"
if defined TARGET (
SET PLATFORM=%TARGET%
)
mkdir "%SCRIPTPATH%%PLATFORM%"
cd "%SCRIPTPATH%%PLATFORM%"
if exist "cef_binary.7z" (
echo "cef_binary.7z already downloaded"
) else (
Powershell.exe Invoke-WebRequest -OutFile cef_binary.7z http://d2ettrnqo7v976.cloudfront.net/cef/2454/%PLATFORM%%ARCH%/cef_binary.7z
Powershell.exe Invoke-WebRequest -OutFile cef_binary.7z http://d2ettrnqo7v976.cloudfront.net/cef/2454/%PLATFORM%/cef_binary.7z
)
SET UNSIP_PROGRAMM="%ProgramFiles%\7-Zip\7z.exe"

View File

@ -6,6 +6,10 @@ if defined ProgramFiles(x86) (
SET platform=win_64
)
if defined TARGET (
SET platform=%TARGET%
)
if not exist "%platform%" (
md "%platform%"
)

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

@ -158,7 +158,16 @@ namespace OOX
else if ( pRelation->Type() == FileTypes::Document)
return smart_ptr<OOX::File>(new CDocument( oRootPath, oFileName ));
else if ( pRelation->Type() == FileTypes::Theme)
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
{
if(NSFile::CFileBinary::Exists(oFileName.GetPath()))
{
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
}
else
{
return smart_ptr<OOX::File>( new UnknowTypeFile() );
}
}
else if ( pRelation->Type() == FileTypes::ThemeOverride)
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
else if ( pRelation->Type() == FileTypes::Setting)

View File

@ -1092,6 +1092,21 @@ namespace OOX
et_x_SheetPr,
et_x_Pane,
et_x_ExternalBook,
et_x_ExternalSheetNames,
et_x_ExternalDefinedNames,
et_x_ExternalDefinedName,
et_x_ExternalSheetDataSet,
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

@ -369,6 +369,71 @@ namespace XmlUtils
return buffer;
}
AVSINLINE static std::wstring EncodeXmlStringExtend(const std::wstring& data, bool bDeleteNoUnicode = false)
{
std::wstring buffer;
buffer.reserve(data.size());
if(bDeleteNoUnicode)
{
for(size_t pos = 0; pos < data.size(); ++pos)
{
switch(data[pos])
{
case '&': buffer.append(L"&amp;"); break;
case '\"': buffer.append(L"&quot;"); break;
case '\'': buffer.append(L"&apos;"); break;
case '<': buffer.append(L"&lt;"); break;
case '>': buffer.append(L"&gt;"); break;
case '\n': buffer.append(L"&#xA;"); break;
case '\r': buffer.append(L"&#xD;"); break;
case '\t': buffer.append(L"&#x9;"); break;
case 160: buffer.append(L"&#160;"); break;
default:
{
if ( false == IsUnicodeSymbol( data[pos] ) )
{
wchar_t symbol1 = data[pos];
if(0xD800 <= symbol1 && symbol1 <= 0xDFFF && pos + 1 < data.size())
{
pos++;
wchar_t symbol2 = data[pos];
if (symbol1 < 0xDC00 && symbol2 >= 0xDC00 && symbol2 <= 0xDFFF)
{
buffer.append(&data[pos-1], 2);
}
}
}
else
buffer.append(&data[pos], 1);
}break;
}
}
}
else
{
for(size_t pos = 0; pos < data.size(); ++pos)
{
switch(data[pos])
{
case '&': buffer.append(L"&amp;"); break;
case '\"': buffer.append(L"&quot;"); break;
case '\'': buffer.append(L"&apos;"); break;
case '<': buffer.append(L"&lt;"); break;
case '>': buffer.append(L"&gt;"); break;
case '\n': buffer.append(L"&#xA;"); break;
case '\r': buffer.append(L"&#xD;"); break;
case '\t': buffer.append(L"&#x9;"); break;
case 160: buffer.append(L"&#160;"); break;
case '\0':
return buffer;
default: buffer.append(&data[pos], 1); break;
}
}
}
return buffer;
}
//#ifndef _USE_LIBXML2_READER_
class CStringWriter
{

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

@ -128,7 +128,16 @@ namespace OOX
else if ( pRelation->Type() == FileTypes::Worksheet )
return smart_ptr<OOX::File>(new CWorksheet( oRootPath, oFileName ));
else if ( pRelation->Type() == OOX::FileTypes::Theme )
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
{
if(NSFile::CFileBinary::Exists(oFileName.GetPath()))
{
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
}
else
{
return smart_ptr<OOX::File>( new UnknowTypeFile() );
}
}
else if ( pRelation->Type() == OOX::FileTypes::ThemeOverride )
return smart_ptr<OOX::File>(new PPTX::Theme( oFileName ));
else if ( pRelation->Type() == FileTypes::Drawings )
@ -152,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

@ -452,6 +452,14 @@ namespace NSStringExt
return arrElements;
}
static inline void ToLower(std::string& wsString)
{
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);
}
static inline void ToUpper(std::string& wsString)
{
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towupper);
}
static inline void ToLower(std::wstring& wsString)
{
std::transform(wsString.begin(), wsString.end(), wsString.begin(), ::towlower);

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

@ -644,7 +644,12 @@ namespace MetaFile
dKoefG = 255.0 / (ulMaskG >> ulShiftG);
dKoefB = 255.0 / (ulMaskB >> ulShiftB);
bMask = true;
if ((ulMaskR >> ulShiftR) == 255 && (ulMaskG >> ulShiftG) == 255 && (ulMaskB >> ulShiftB) == 255)
{
bMask = false; // Proper_Attire_CALT2.odt
}
else
bMask = true;
}
else
return false;

View File

@ -35,8 +35,142 @@
#include "../../../common/String.h"
#include "../../../fontengine/FontManager.h"
#ifdef _DEBUG
#include <iostream>
#endif
namespace MetaFile
{
static const struct ActionNamesEmf
{
int actionNumber;
std::wstring actionName;
} actionNamesEmf[] =
{
{ 0, L"Unknown"},
{ EMR_HEADER, L"EMR_HEADER"},
{ EMR_POLYBEZIER, L"EMR_POLYBEZIER"},
{ EMR_POLYGON, L"EMR_POLYGON"},
{ EMR_POLYLINE, L"EMR_POLYLINE"},
{ EMR_POLYBEZIERTO, L"EMR_POLYBEZIERTO"},
{ EMR_POLYLINETO, L"EMR_POLYLINETO"},
{ EMR_POLYPOLYLINE, L"EMR_POLYPOLYLINE"},
{ EMR_POLYPOLYGON, L"EMR_POLYPOLYGON"},
{ EMR_SETWINDOWEXTEX, L"EMR_SETWINDOWEXTEX"},
{ EMR_SETWINDOWORGEX, L"EMR_SETWINDOWORGEX"},
{ EMR_SETVIEWPORTEXTEX, L"EMR_SETVIEWPORTEXTEX"},
{ EMR_SETVIEWPORTORGEX, L"EMR_SETVIEWPORTORGEX"},
{ EMR_SETBRUSHORGEX, L"EMR_SETBRUSHORGEX"},
{ EMR_EOF, L"EMR_EOF"},
{ EMR_SETPIXELV, L"EMR_SETPIXELV"},
{ EMR_SETMAPPERFLAGS, L"EMR_SETMAPPERFLAGS"},
{ EMR_SETMAPMODE, L"EMR_SETMAPMODE"},
{ EMR_SETBKMODE, L"EMR_SETBKMODE"},
{ EMR_SETPOLYFILLMODE, L"EMR_SETPOLYFILLMODE"},
{ EMR_SETROP2, L"EMR_SETROP2"},
{ EMR_SETSTRETCHBLTMODE, L"EMR_SETSTRETCHBLTMODE"},
{ EMR_SETTEXTALIGN, L"EMR_SETTEXTALIGN"},
{ EMR_SETCOLORADJUSTMENT, L"EMR_SETCOLORADJUSTMENT"},
{ EMR_SETTEXTCOLOR, L"EMR_SETTEXTCOLOR"},
{ EMR_SETBKCOLOR, L"EMR_SETBKCOLOR"},
{ EMR_OFFSETCLIPRGN, L"EMR_OFFSETCLIPRGN"},
{ EMR_MOVETOEX, L"EMR_MOVETOEX"},
{ EMR_SETMETARGN, L"EMR_SETMETARGN"},
{ EMR_EXCLUDECLIPRECT, L"EMR_EXCLUDECLIPRECT"},
{ EMR_INTERSECTCLIPRECT, L"EMR_INTERSECTCLIPRECT"},
{ EMR_SCALEVIEWPORTEXTEX, L"EMR_SCALEVIEWPORTEXTEX"},
{ EMR_SCALEWINDOWEXTEX, L"EMR_SCALEWINDOWEXTEX"},
{ EMR_SAVEDC, L"EMR_SAVEDC"},
{ EMR_RESTOREDC, L"EMR_RESTOREDC"},
{ EMR_SETWORLDTRANSFORM, L"EMR_SETWORLDTRANSFORM"},
{ EMR_MODIFYWORLDTRANSFORM, L"EMR_MODIFYWORLDTRANSFORM"},
{ EMR_SELECTOBJECT, L"EMR_SELECTOBJECT"},
{ EMR_CREATEPEN, L"EMR_CREATEPEN"},
{ EMR_CREATEBRUSHINDIRECT, L"EMR_CREATEBRUSHINDIRECT"},
{ EMR_DELETEOBJECT, L"EMR_DELETEOBJECT"},
{ EMR_ANGLEARC, L"EMR_ANGLEARC"},
{ EMR_ELLIPSE, L"EMR_ELLIPSE"},
{ EMR_RECTANGLE, L"EMR_RECTANGLE"},
{ EMR_ROUNDRECT, L"EMR_ROUNDRECT"},
{ EMR_ARC, L"EMR_ARC"},
{ EMR_CHORD, L"EMR_CHORD"},
{ EMR_PIE, L"EMR_PIE"},
{ EMR_SELECTPALETTE, L"EMR_SELECTPALETTE"},
{ EMR_CREATEPALETTE, L"EMR_CREATEPALETTE"},
{ EMR_SETPALETTEENTRIES, L"EMR_SETPALETTEENTRIES"},
{ EMR_RESIZEPALETTE, L"EMR_RESIZEPALETTE"},
{ EMR_REALIZEPALETTE, L"EMR_REALIZEPALETTE"},
{ EMR_EXTFLOODFILL, L"EMR_EXTFLOODFILL"},
{ EMR_LINETO, L"EMR_LINETO"},
{ EMR_ARCTO, L"EMR_ARCTO"},
{ EMR_POLYDRAW, L"EMR_POLYDRAW"},
{ EMR_SETARCDIRECTION, L"EMR_SETARCDIRECTION"},
{ EMR_SETMITERLIMIT, L"EMR_SETMITERLIMIT"},
{ EMR_BEGINPATH, L"EMR_BEGINPATH"},
{ EMR_ENDPATH, L"EMR_ENDPATH"},
{ EMR_CLOSEFIGURE, L"EMR_CLOSEFIGURE"},
{ EMR_FILLPATH, L"EMR_FILLPATH"},
{ EMR_STROKEANDFILLPATH, L"EMR_STROKEANDFILLPATH"},
{ EMR_STROKEPATH, L"EMR_STROKEPATH"},
{ EMR_FLATTENPATH, L"EMR_FLATTENPATH"},
{ EMR_WIDENPATH, L"EMR_WIDENPATH"},
{ EMR_SELECTCLIPPATH, L"EMR_SELECTCLIPPATH"},
{ EMR_ABORTPATH, L"EMR_ABORTPATH"},
{ 69, L"Unknown"},
{ EMR_GDICOMMENT, L"EMR_GDICOMMENT"},
{ EMR_FILLRGN, L"EMR_FILLRGN"},
{ EMR_FRAMERGN, L"EMR_FRAMERGN"},
{ EMR_INVERTRGN, L"EMR_INVERTRGN"},
{ EMR_PAINTRGN, L"EMR_PAINTRGN"},
{ EMR_EXTSELECTCLIPRGN, L"EMR_EXTSELECTCLIPRGN"},
{ EMR_BITBLT, L"EMR_BITBLT"},
{ EMR_STRETCHBLT, L"EMR_STRETCHBLT"},
{ EMR_MASKBLT, L"EMR_MASKBLT"},
{ EMR_PLGBLT, L"EMR_PLGBLT"},
{ EMR_SETDIBITSTODEVICE, L"EMR_SETDIBITSTODEVICE"},
{ EMR_STRETCHDIBITS, L"EMR_STRETCHDIBITS"},
{ EMR_EXTCREATEFONTINDIRECTW, L"EMR_EXTCREATEFONTINDIRECTW"},
{ EMR_EXTTEXTOUTA, L"EMR_EXTTEXTOUTA"},
{ EMR_EXTTEXTOUTW, L"EMR_EXTTEXTOUTW"},
{ EMR_POLYBEZIER16, L"EMR_POLYBEZIER16"},
{ EMR_POLYGON16, L"EMR_POLYGON16"},
{ EMR_POLYLINE16, L"EMR_POLYLINE16"},
{ EMR_POLYBEZIERTO16, L"EMR_POLYBEZIERTO16"},
{ EMR_POLYLINETO16, L"EMR_POLYLINETO16"},
{ EMR_POLYPOLYLINE16, L"EMR_POLYPOLYLINE16"},
{ EMR_POLYPOLYGON16, L"EMR_POLYPOLYGON16"},
{ EMR_POLYDRAW16, L"EMR_POLYDRAW16"},
{ EMR_CREATEMONOBRUSH, L"EMR_CREATEMONOBRUSH"},
{ EMR_CREATEDIBPATTERNBRUSHPT,L"EMR_CREATEDIBPATTERNBRUSHPT"},
{ EMR_EXTCREATEPEN, L"EMR_EXTCREATEPEN"},
{ EMR_POLYTEXTOUTA, L"EMR_POLYTEXTOUTA"},
{ EMR_POLYTEXTOUTW, L"EMR_POLYTEXTOUTW"},
{ EMR_SETICMMODE, L"EMR_SETICMMODE"},
{ EMR_CREATECOLORSPACE, L"EMR_CREATECOLORSPACE"},
{ EMR_SETCOLORSPACE, L"EMR_SETCOLORSPACE"},
{ EMR_DELETECOLORSPACE, L"EMR_DELETECOLORSPACE"},
{ EMR_GLSRECORD, L"EMR_GLSRECORD"},
{ EMR_GLSBOUNDEDRECORD, L"EMR_GLSBOUNDEDRECORD"},
{ EMR_PIXELFORMAT, L"EMR_PIXELFORMAT"},
{ EMR_RESERVED_105, L"EMR_RESERVED_105"},
{ EMR_RESERVED_106, L"EMR_RESERVED_106"},
{ EMR_RESERVED_107, L"EMR_RESERVED_107"},
{ EMR_RESERVED_108, L"EMR_RESERVED_108"},
{ EMR_RESERVED_109, L"EMR_RESERVED_109"},
{ EMR_RESERVED_110, L"EMR_RESERVED_110"},
{ EMR_COLORCORRECTPALETTE, L"EMR_COLORCORRECTPALETTE"},
{ EMR_SETICMPROFILEA, L"EMR_SETICMPROFILEA"},
{ EMR_SETICMPROFILEW, L"EMR_SETICMPROFILEW"},
{ EMR_ALPHABLEND, L"EMR_ALPHABLEND"},
{ EMR_SETLAYOUT, L"EMR_SETLAYOUT"},
{ EMR_TRANSPARENTBLT, L"EMR_TRANSPARENTBLT"},
{ EMR_RESERVED_117, L"EMR_RESERVED_117"},
{ EMR_GRADIENTFILL, L"EMR_GRADIENTFILL"},
{ EMR_RESERVED_119, L"EMR_RESERVED_119"},
{ EMR_RESERVED_120, L"EMR_RESERVED_120"},
{ EMR_COLORMATCHTOTARGETW, L"EMR_COLORMATCHTOTARGETW"},
{ EMR_CREATECOLORSPACEW, L"EMR_CREATECOLORSPACEW "}
};
void CEmfFile::PlayMetaFile()
{
if (!m_oStream.IsValid())
@ -47,7 +181,8 @@ namespace MetaFile
bool bEof = false;
unsigned int ulRecordIndex = 0;
unsigned int ulRecordIndex = 0;
unsigned int m_ulRecordPos = 0;
if (m_pOutput)
m_pOutput->Begin();
@ -60,10 +195,17 @@ namespace MetaFile
m_oStream >> ulType;
m_oStream >> ulSize;
m_ulRecordSize = ulSize - 8;
m_ulRecordPos = m_oStream.Tell();
m_ulRecordSize = ulSize - 8;
if (ulType < EMR_MIN || ulType > EMR_MAX)
return SetError();
{
if (ENHMETA_SIGNATURE != m_oHeader.ulSignature || 0x00010000 != m_oHeader.ulVersion)
return SetError();
else
break;
}
if (0 == ulRecordIndex && EMR_HEADER != ulType)
return SetError();
@ -95,7 +237,7 @@ namespace MetaFile
// 2.3.5 Drawing
//-----------------------------------------------------------
case EMR_ANGLEARC: Read_EMR_ANGLEARC(); break;
case EMR_ARC: Read_EMR_ARC(); break;
case EMR_ARC: Read_EMR_ARC(); break;
case EMR_ARCTO: Read_EMR_ARCTO(); break;
case EMR_CHORD: Read_EMR_CHORD(); break;
case EMR_ELLIPSE: Read_EMR_ELLIPSE(); break;
@ -103,7 +245,7 @@ namespace MetaFile
case EMR_EXTTEXTOUTW: Read_EMR_EXTTEXTOUTW(); break;
case EMR_FILLPATH: Read_EMR_FILLPATH(); break;
case EMR_LINETO: Read_EMR_LINETO(); break;
case EMR_PIE: Read_EMR_PIE(); break;
case EMR_PIE: Read_EMR_PIE(); break;
case EMR_POLYBEZIER: Read_EMR_POLYBEZIER(); break;
case EMR_POLYBEZIER16: Read_EMR_POLYBEZIER16(); break;
case EMR_POLYBEZIERTO: Read_EMR_POLYBEZIERTO(); break;
@ -134,7 +276,7 @@ namespace MetaFile
case EMR_CREATEBRUSHINDIRECT: Read_EMR_CREATEBRUSHINDIRECT(); break;
case EMR_CREATEDIBPATTERNBRUSHPT: Read_EMR_CREATEDIBPATTERNBRUSHPT(); break;
case EMR_CREATEPALETTE: Read_EMR_CREATEPALETTE(); break;
case EMR_CREATEPEN: Read_EMR_CREATEPEN(); break;
case EMR_CREATEPEN: Read_EMR_CREATEPEN(); break;
case EMR_EXTCREATEFONTINDIRECTW: Read_EMR_EXTCREATEFONTINDIRECTW(); break;
case EMR_EXTCREATEPEN: Read_EMR_EXTCREATEPEN(); break;
//-----------------------------------------------------------
@ -198,6 +340,17 @@ namespace MetaFile
if (bEof)
break;
int need_skip = m_ulRecordSize - (m_oStream.Tell() - m_ulRecordPos);
m_oStream.Skip(need_skip);
#ifdef _DEBUG
if ( need_skip != 0 && !m_pOutput)
{
std::wstring name = actionNamesEmf[ulType].actionName;
std::wcout << name << L"\t\t(" << ulType << L")\t; skiped = " << need_skip << L"\n";
}
#endif
ulRecordIndex++;
} while (!CheckError());
@ -732,9 +885,9 @@ namespace MetaFile
{
// Делаем цветом кисти
pBgraBuffer = new BYTE[4];
pBgraBuffer[0] = pBrush->Color.b;
pBgraBuffer[0] = pBrush->Color.b;
pBgraBuffer[1] = pBrush->Color.g;
pBgraBuffer[2] = pBrush->Color.r;
pBgraBuffer[2] = pBrush->Color.r;
pBgraBuffer[3] = 30;
ulWidth = 1;
@ -1419,6 +1572,8 @@ namespace MetaFile
template<typename T>void CEmfFile::Read_EMR_POLYDRAW_BASE()
{
// TODO: Как найдутся файлы проверить данную запись.
//bug #35006 - не прочитывается весь рекорд ... выравнивание?
TEmfRectL oBounds;
m_oStream >> oBounds;

View File

@ -360,6 +360,8 @@ namespace MetaFile
struct TEmfHeader
{
TEmfHeader() : ulSignature(0), ulVersion(0), ulRecords(0), ushObjects(0), ulSize(0), ulPalEntries(0), ulOffsetDescription(0),ulSizeDescription(0) {}
TEmfRectL oBounds;
TEmfRectL oFrame;
unsigned int ulSignature;

View File

@ -50,11 +50,11 @@
namespace MetaFile
{
static const struct ActionNames
static const struct ActionNamesSmv
{
int actionNumber;
std::wstring actionName;
} actionNames[] =
} actionNamesSmv[] =
{
{ META_NULL_ACTION, L"META_NULL_ACTION" },
{ META_PIXEL_ACTION, L"META_PIXEL_ACTION" },
@ -224,7 +224,7 @@ void CSvmFile::PlayMetaFile()
#ifdef _DEBUG
if (100 <= actionType && actionType <= META_LAST_ACTION && need_skip > 0 && !m_pOutput)
{
std::wstring name = actionNames[actionType - 99].actionName;
std::wstring name = actionNamesSmv[actionType - 99].actionName;
std::wcout << name << L"\t\t" << actionType << L"\t(version = " << m_currentActionVersion << L")\t; skiped = " << need_skip << L"\n";
}

View File

@ -11,18 +11,7 @@ TEMPLATE = lib
CONFIG += staticlib
QMAKE_CXXFLAGS += -Wall -g
DEFINES += \
LIBXML_READER_ENABLED \
LIBXML_PUSH_ENABLED \
LIBXML_HTML_ENABLED \
LIBXML_XPATH_ENABLED \
LIBXML_OUTPUT_ENABLED \
LIBXML_C14N_ENABLED \
LIBXML_SAX1_ENABLED \
LIBXML_TREE_ENABLED \
LIBXML_XPTR_ENABLED \
IN_LIBXML \
LIBXML_STATIC
CONFIG += core_static_link_xml_full
CORE_ROOT_DIR = $$PWD/../../../..
PWD_ROOT_DIR = $$PWD

View File

@ -19,7 +19,8 @@ PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
INCLUDEPATH += \
$$PWD_ROOT_DIR/xmlsec/include
$$PWD_ROOT_DIR/xmlsec/include \
$$CORE_ROOT_DIR/DesktopEditor/xml/build/qt
DEFINES += \
LIBXML_READER_ENABLED \
@ -38,15 +39,15 @@ include($$CORE_ROOT_DIR/DesktopEditor/xml/build/qt/libxml2_src.pri)
DEFINES += PACKAGE=\\\"xmlsec1\\\"
DEFINES += VERSION=\\\"1.2.23\\\"
DEFINES += XMLSEC_DEFAULT_CRYPTO=\\\"mscrypto\\\"
DEFINES += XMLSEC_DEFAULT_CRYPTO=\\\"openssl\\\"
DEFINES += \
IN_XMLSEC \
XMLSEC_STATIC
core_linux {
CONFIG += use_gcrypt
CONFIG += use_gnutls
#CONFIG += use_gcrypt
#CONFIG += use_gnutls
#CONFIG += use_mscrypto
#CONFIG += use_nss
CONFIG += use_openssl
@ -246,6 +247,10 @@ SOURCES += \
use_openssl {
DEFINES += XMLSEC_OPENSSL_110
INCLUDEPATH += $$PWD/openssl/include
HEADERS += \
xmlsec/include/xmlsec/openssl/app.h \
xmlsec/include/xmlsec/openssl/bn.h \
@ -258,21 +263,21 @@ HEADERS += \
xmlsec/src/openssl/openssl11_wrapper.h
SOURCES += \
xmlsec/src/openssl/app.c \
xmlsec/src/openssl/bn.c \
xmlsec/src/openssl/ciphers.c \
xmlsec/src/openssl/crypto.c \
xmlsec/src/openssl/digests.c \
xmlsec/src/openssl/evp.c \
xmlsec/src/openssl/evp_signatures.c \
xmlsec/src/openssl/hmac.c \
xmlsec/src/openssl/kt_rsa.c \
xmlsec/src/openssl/kw_aes.c \
xmlsec/src/openssl/kw_des.c \
xmlsec/src/openssl/signatures.c \
xmlsec/src/openssl/symkeys.c \
xmlsec/src/openssl/x509.c \
xmlsec/src/openssl/x509vfy.c
xmlsec/src/openssl/_app.c \
xmlsec/src/openssl/_bn.c \
xmlsec/src/openssl/_ciphers.c \
xmlsec/src/openssl/_crypto.c \
xmlsec/src/openssl/_digests.c \
xmlsec/src/openssl/_evp.c \
xmlsec/src/openssl/_evp_signatures.c \
xmlsec/src/openssl/_hmac.c \
xmlsec/src/openssl/_kt_rsa.c \
xmlsec/src/openssl/_kw_aes.c \
xmlsec/src/openssl/_kw_des.c \
xmlsec/src/openssl/_signatures.c \
xmlsec/src/openssl/_symkeys.c \
xmlsec/src/openssl/_x509.c \
xmlsec/src/openssl/_x509vfy.c
}

View File

@ -8,9 +8,36 @@
#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;
};
class Q_DECL_EXPORT CCertificateInfo
{
private:
std::wstring m_name;
std::string m_date;
std::string m_id;
@ -22,6 +49,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,15 +112,17 @@ 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;
}

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

@ -77,6 +77,11 @@ public:
std::wstring GetImageBase64(const std::wstring& file)
{
if (0 == file.find(L"data:image/"))
{
return file.substr(file.find(L",") + 1);
}
BYTE* pData = NULL;
DWORD dwLen = 0;
if (!NSFile::CFileBinary::ReadAllBytes(file, &pData, dwLen))
@ -97,6 +102,8 @@ public:
std::wstring GetRelsReference(const std::wstring& file)
{
COOXMLRelationships oRels(m_sFolder + file, true);
if (oRels.rels.size() == 0)
return L"";
if (L"/_rels/.rels" == file)
{

View File

@ -174,7 +174,8 @@ public:
return;
}
std::wstring sSetupID = FindFirstChild(GetObjectById("idOfficeObject"), L"SetupID").GetText();
XmlUtils::CXmlNode firstChild = GetObjectById("idOfficeObject");
std::wstring sSetupID = FindFirstChild(firstChild, L"SetupID").GetText();
m_guid = U_TO_UTF8(sSetupID);
// 2) Images

View File

@ -0,0 +1,663 @@
#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>
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 LoadKey(std::wstring file, std::string password)
{
return CCertificate_openssl_private::LoadKey(file, password, NULL);
}
int LoadCert(std::wstring file, std::string password)
{
return CCertificate_openssl_private::LoadCert(file, password, NULL);
}

View File

@ -1,111 +1,53 @@
#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);
public:
static int LoadKey(std::wstring file, std::string password);
static int LoadCert(std::wstring file, std::string password);
};
#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

@ -0,0 +1,294 @@
#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 "../../../common/File.h"
static time_t 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 mktime(&t);
}
#if 1
int main()
{
std::wstring sFolderW = NSFile::GetProcessDirectory();
std::string sFolder = U_TO_UTF8(sFolderW);
std::string __file = sFolder + "/settings.xml";
std::string __key = sFolder + "/rsakey.pem";
std::string __cert = sFolder + "/rsacert.pem";
ASN1_INTEGER *asn1_serial = NULL;
BIO *certbio = NULL;
BIO *outbio = NULL;
X509 *cert = NULL;
const char *neg;
int ret, i;
long l;
/* ---------------------------------------------------------- *
* These function calls initialize openssl for correct work. *
* ---------------------------------------------------------- */
OpenSSL_add_all_algorithms();
ERR_load_BIO_strings();
ERR_load_crypto_strings();
/* ---------------------------------------------------------- *
* Create the Input/Output BIO's. *
* ---------------------------------------------------------- */
certbio = BIO_new(BIO_s_file());
outbio = BIO_new_fp(stdout, BIO_NOCLOSE);
/* ---------------------------------------------------------- *
* Load the certificate from file (PEM). *
* ---------------------------------------------------------- */
ret = BIO_read_filename(certbio, __cert.c_str());
if (! (cert = PEM_read_bio_X509(certbio, NULL, 0, NULL)))
{
BIO_printf(outbio, "Error loading cert into memory\n");
exit(-1);
}
/* ---------------------------------------------------------- *
* Extract the certificate's serial number. *
* ---------------------------------------------------------- */
asn1_serial = X509_get_serialNumber(cert);
if (asn1_serial == NULL)
BIO_printf(outbio, "Error getting serial number from certificate");
ASN1_TIME* _time = X509_get_notBefore(cert);
const char* s = (const char*)_time->data;
time_t time1 = ASN1_GetTimeT(_time);
/* ---------------------------------------------------------- *
* Print the serial number value, openssl x509 -serial style *
* ---------------------------------------------------------- */
BIO_puts(outbio,"serial (openssl x509 -serial style): ");
i2a_ASN1_INTEGER(outbio, asn1_serial);
BIO_puts(outbio,"\n");
/* ---------------------------------------------------------- *
* Print the serial number value, openssl x509 -text style *
* ---------------------------------------------------------- */
if (asn1_serial->length <= (int)sizeof(long))
{
l=ASN1_INTEGER_get(asn1_serial);
if (asn1_serial->type == V_ASN1_NEG_INTEGER)
{
l= -l;
neg="-";
}
else neg="";
if (BIO_printf(outbio," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0)
BIO_printf(outbio, "Error during printing the serial.\n");
}
else
{
neg=(asn1_serial->type == V_ASN1_NEG_INTEGER)?" (Negative)":"";
//if (BIO_printf(outbio,"\n%12s%s","",neg) <= 0)
if (BIO_printf(outbio,"serial (openssl x509 -text style): %s","",neg) <= 0)
BIO_printf(outbio, "Error during printing the serial.\n");
for (i=0; i<asn1_serial->length; i++)
{
char c[2];
c[0] = asn1_serial->data[i];
c[1] = '0';
BIO_printf(outbio, c);
}
}
X509_free(cert);
BIO_free_all(certbio);
BIO_free_all(outbio);
exit(0);
}
#endif
#if 0
int main(int argc, char **argv)
{
std::wstring sFolderW = NSFile::GetProcessDirectory();
std::string sFolder = U_TO_UTF8(sFolderW);
std::string __file = sFolder + "/settings.xml";
std::string __key = sFolder + "/rsakey.pem";
std::string __cert = sFolder + "/www.pfx";
std::string __export = sFolder + "/www.pem";
FILE *fp;
EVP_PKEY *pkey;
X509 *cert;
STACK_OF(X509) *ca = NULL;
PKCS12 *p12;
SSL_library_init();
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
if (!(fp = fopen(__cert.c_str(), "rb")))
{
fprintf(stderr, "Error opening file %s\n", __cert.c_str());
exit(1);
}
p12 = d2i_PKCS12_fp(fp, NULL);
fclose (fp);
if (!p12)
{
fprintf(stderr, "Error reading PKCS#12 file\n");
ERR_print_errors_fp(stderr);
exit (1);
}
if (!PKCS12_parse(p12, "111", &pkey, &cert, &ca))
{
fprintf(stderr, "Error parsing PKCS#12 file\n");
ERR_print_errors_fp(stderr);
exit (1);
}
PKCS12_free(p12);
if (!(fp = fopen(__export.c_str(), "w")))
{
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
if (pkey)
{
fprintf(fp, "***Private Key***\n");
PEM_write_PrivateKey(fp, pkey, NULL, NULL, 0, NULL, NULL);
}
if (cert)
{
fprintf(fp, "***User Certificate***\n");
PEM_write_X509_AUX(fp, cert);
}
if (ca && sk_X509_num(ca))
{
fprintf(fp, "***Other Certificates***\n");
int count = sk_X509_num(ca);
for (int i = 0; i < count; i++)
PEM_write_X509_AUX(fp, sk_X509_value(ca, i));
}
sk_X509_pop_free(ca, X509_free);
X509_free(cert);
EVP_PKEY_free(pkey);
fclose(fp);
return 0;
}
#endif
#if 0
int main()
{
unsigned char ibuf[] = "compute sha1";
unsigned char obuf[20];
SHA1(ibuf, strlen((char*)ibuf), obuf);
int i;
for (i = 0; i < 20; i++) {
printf("%02x ", obuf[i]);
}
printf("\n");
return 0;
}
#endif
#if 0
int main()
{
std::wstring sFolderW = NSFile::GetProcessDirectory();
std::string sFolder = U_TO_UTF8(sFolderW);
std::string __file = sFolder + "/settings.xml";
#if 1
std::string __key = sFolder + "/www.pem";
std::string __cert = sFolder + "/www.pem";
#else
std::string __key = sFolder + "/rsakey.pem";
std::string __cert = sFolder + "/rsacert.pem";
#endif
OpenSSL_add_all_algorithms();
ERR_load_BIO_strings();
ERR_load_crypto_strings();
FILE* file_key = NSFile::CFileBinary::OpenFileNative(UTF8_TO_U(__key), L"r+");
FILE* file_cert = NSFile::CFileBinary::OpenFileNative(UTF8_TO_U(__key), L"r+");
EVP_PKEY* pKey = NULL;
PEM_read_PrivateKey(file_key, &pKey, NULL, NULL);
X509* pCert = NULL;
PEM_read_X509(file_cert, &pCert, NULL, NULL);
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
const EVP_MD* pDigest = EVP_sha1();
int n1 = EVP_SignInit(pCtx, pDigest);
BYTE* pDataSrc = NULL;
DWORD nDataSrcLen = 0;
NSFile::CFileBinary::ReadAllBytes(UTF8_TO_U(__file), &pDataSrc, nDataSrcLen);
int n2 = EVP_SignUpdate(pCtx, pDataSrc, (size_t)nDataSrcLen);
BYTE pSignature[4096];
unsigned int nSignatureLen = 0;
int n3 = EVP_SignFinal(pCtx, pSignature, &nSignatureLen, pKey);
RELEASEARRAYOBJECTS(pDataSrc);
EVP_PKEY_free(pKey);
X509_free(pCert);
EVP_MD_CTX_destroy(pCtx);
fclose(file_key);
fclose(file_cert);
return 0;
}
#endif

View File

@ -0,0 +1,24 @@
QT -= core gui
TARGET = test
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
DEFINES -= \
UNICODE \
_UNICODE
CORE_ROOT_DIR = $$PWD/../../../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
DEFINES += XMLSEC_OPENSSL_110
INCLUDEPATH += $$PWD/../../openssl/include
LIBS += -L$$PWD/../../openssl -lssl -lcrypto
LIBS += -ldl
SOURCES += main.cpp

View File

@ -42,6 +42,8 @@
#include <xmlsec/templates.h>
#include <xmlsec/crypto.h>
#include "../../../common/File.h"
int sign_file(const char* xml_file, const char* key_file, const char* cert_file);
int
@ -50,13 +52,11 @@ main(int argc, char **argv) {
xsltSecurityPrefsPtr xsltSecPrefs = NULL;
#endif /* XMLSEC_NO_XSLT */
assert(argv);
if(argc != 4) {
fprintf(stderr, "Error: wrong number of arguments.\n");
fprintf(stderr, "Usage: %s <xml-file> <key-file> <cert-file>\n", argv[0]);
return(1);
}
std::wstring sFolderW = NSFile::GetProcessDirectory();
std::string sFolder = U_TO_UTF8(sFolderW);
std::string __file = sFolder + "/settings.xml";
std::string __key = sFolder + "/rsakey.pem";
std::string __cert = sFolder + "/rsacert.pem";
/* Init libxml and libxslt libraries */
xmlInitParser();
@ -117,7 +117,7 @@ main(int argc, char **argv) {
return(-1);
}
if(sign_file(argv[1], argv[2], argv[3]) < 0) {
if(sign_file(__file.c_str(), __key.c_str(), __cert.c_str()) < 0) {
return(-1);
}

View File

@ -15,7 +15,7 @@ PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
#DEFINES += XMLSEC_CRYPTO_DYNAMIC_LOADING
DEFINES += XMLSEC_CRYPTO_MSCRYPTO
DEFINES += XMLSEC_CRYPTO_OPENSSL
INCLUDEPATH += \
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include \
@ -40,8 +40,8 @@ DEFINES += XMLSEC_STATIC
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxmlsec
LIBS += -lcrypt32
LIBS += -lcryptui
LIBS += -lAdvapi32
LIBS += -L$$PWD/../../openssl -lcrypto -lssl
LIBS += -ldl
SOURCES += main.cpp

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