mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-13 03:15:54 +08:00
Compare commits
34 Commits
core/devel
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| e9805cef30 | |||
| e3e05eb2db | |||
| c09f17cffb | |||
| ce73dd5987 | |||
| 77df8aacb9 | |||
| ce45b2802f | |||
| 7886018d6f | |||
| 5b5cb4188e | |||
| f797af5f17 | |||
| 055977535e | |||
| 6ab24f10f0 | |||
| 12a03da231 | |||
| cb7088979a | |||
| 1fb1fc6c97 | |||
| e633c3c5d1 | |||
| 0f04de34b1 | |||
| 3f8c2c293a | |||
| 2c97e743da | |||
| 2c83860c04 | |||
| c64b624de2 | |||
| 5e3990937d | |||
| 21744c1607 | |||
| 0892e2549f | |||
| cff6f305d4 | |||
| 5060071227 | |||
| d64109eaa4 | |||
| ec064bbd50 | |||
| baf952a151 | |||
| 0dd36c5e6a | |||
| 474404a8f9 | |||
| f2f6483b6f | |||
| c30161dbd0 | |||
| 1244048c50 | |||
| a62b69fb31 |
@ -811,10 +811,10 @@ namespace DocFileFormat
|
||||
{
|
||||
Symbol s = getSymbol( chpx );
|
||||
|
||||
m_pXmlWriter->WriteNodeBegin(L"w:sym", true);
|
||||
m_pXmlWriter->WriteAttribute(L"w:font", FormatUtils::XmlEncode(s.FontName));
|
||||
m_pXmlWriter->WriteAttribute(L"w:char", FormatUtils::XmlEncode(s.HexValue));
|
||||
m_pXmlWriter->WriteNodeEnd(L"", true);
|
||||
//m_pXmlWriter->WriteNodeBegin(L"w:sym", true);
|
||||
//m_pXmlWriter->WriteAttribute(L"w:font", FormatUtils::XmlEncode(s.FontName));
|
||||
//m_pXmlWriter->WriteAttribute(L"w:char", FormatUtils::XmlEncode(s.HexValue));
|
||||
//m_pXmlWriter->WriteNodeEnd(L"", true);
|
||||
}
|
||||
else if ((TextMark::DrawnObject == code) && fSpec)
|
||||
{
|
||||
@ -1663,12 +1663,17 @@ namespace DocFileFormat
|
||||
FontFamilyName* ffn = static_cast<FontFamilyName*>( m_document->FontTable->operator [] ( fontIndex ) );
|
||||
|
||||
ret.FontName = ffn->xszFtn;
|
||||
ret.HexValue = L"f0" + FormatUtils::IntToFormattedWideString( code, L"%02x" );
|
||||
ret.HexValue = L"f0" + FormatUtils::IntToFormattedWideString( code, L"%02x" );//-123 - ShortToFormattedWideString
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.HexValue.length() > 4)
|
||||
{
|
||||
ret.HexValue = ret.HexValue.substr(ret.HexValue.length() - 4, 4);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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\" \
|
||||
|
||||
@ -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){}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -186,6 +186,8 @@ namespace NSBinPptxRW
|
||||
#define SPTREE_TYPE_SPTREE 4
|
||||
#define SPTREE_TYPE_GRFRAME 5
|
||||
#define SPTREE_TYPE_OLE 6
|
||||
#define SPTREE_TYPE_VIDEO 7
|
||||
#define SPTREE_TYPE_AUDIO 8
|
||||
|
||||
static BYTE SchemeClr_GetBYTECode(const std::wstring& sValue)
|
||||
{
|
||||
|
||||
@ -36,6 +36,8 @@
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/WritingElement.h"
|
||||
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
|
||||
|
||||
#include "../../Common/Base64.h"
|
||||
|
||||
@ -106,7 +108,7 @@ namespace NSBinPptxRW
|
||||
CreateFontPicker(NULL);
|
||||
}
|
||||
|
||||
CImageManager2::CImageManager2() : m_mapImages(), m_lIndexNextImage(0), m_lIndexNextOle(0)
|
||||
CImageManager2::CImageManager2() : m_mapImages(), m_lIndexNextImage(0), m_lIndexCounter(0)
|
||||
{
|
||||
m_nDocumentType = XMLWRITER_DOC_TYPE_PPTX;
|
||||
m_pContentTypes = new OOX::CContentTypes();
|
||||
@ -118,8 +120,8 @@ namespace NSBinPptxRW
|
||||
void CImageManager2::Clear()
|
||||
{
|
||||
m_mapImages.clear();
|
||||
m_lIndexNextImage = 1;
|
||||
m_lIndexNextOle = 1;
|
||||
m_lIndexNextImage = 0;
|
||||
m_lIndexCounter = 0;
|
||||
}
|
||||
void CImageManager2::SetDstMedia(const std::wstring& strDst)
|
||||
{
|
||||
@ -147,34 +149,50 @@ namespace NSBinPptxRW
|
||||
{
|
||||
if(nIndex1 + sFind1.length() < strInput.length())
|
||||
{
|
||||
wchar_t cRes = strInput[nIndex1 + sFind1.length()];
|
||||
if('1' <= cRes && cRes <= '6')
|
||||
wchar_t cRes1 = strInput[nIndex1 + sFind1.length()];
|
||||
if('1' <= cRes1 && cRes1 <= '9')
|
||||
{
|
||||
wchar_t cRes2 = strInput[nIndex1 + sFind1.length() + 1];
|
||||
|
||||
int nImageIndex = nIndex1 + (int)sFind1.length() + 1;
|
||||
if(nImageIndex == (int)strInput.find(_T("image"), nImageIndex))
|
||||
nRes = cRes - '0';
|
||||
if (std::wstring::npos != strInput.find(_T("image"), nImageIndex))
|
||||
{
|
||||
nRes = cRes1 - '0';
|
||||
if('0' <= cRes2 && cRes2 <= '9')
|
||||
{
|
||||
nRes = nRes * 10 + (cRes2 - '0');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
_imageManager2Info CImageManager2::GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::OleObject> & oleFile, const std::wstring& oleData, std::wstring strBase64Image)
|
||||
_imageManager2Info CImageManager2::GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image)
|
||||
{
|
||||
if (IsNeedDownload(strInput))
|
||||
return DownloadImage(strInput);
|
||||
|
||||
std::map<std::wstring, _imageManager2Info>::const_iterator pPair = m_mapImages.find ((_T("") == strBase64Image) ? strInput : strBase64Image);
|
||||
std::map<std::wstring, _imageManager2Info>::const_iterator pPair = m_mapImages.find ((strBase64Image.empty()) ? strInput : strBase64Image);
|
||||
|
||||
if (pPair != m_mapImages.end())
|
||||
{
|
||||
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
if (mediaFile.IsInit())
|
||||
mediaFile->set_filename(pPair->second.sFilepathAdditional);
|
||||
|
||||
return pPair->second;
|
||||
}
|
||||
|
||||
std::wstring strExts = _T(".jpg");
|
||||
int nIndexExt = (int)strInput.rfind(wchar_t('.'));
|
||||
if (-1 != nIndexExt)
|
||||
strExts = strInput.substr(nIndexExt);
|
||||
|
||||
std::wstring strOleBin;
|
||||
int typeAdditional = 0;
|
||||
std::wstring strAdditional;
|
||||
std::wstring strImage = strInput;
|
||||
|
||||
int nDisplayType = IsDisplayedImage(strInput);
|
||||
@ -208,21 +226,52 @@ namespace NSBinPptxRW
|
||||
}
|
||||
if(0 != (nDisplayType & 4))
|
||||
{
|
||||
smart_ptr<OOX::OleObject> oleFile = additionalFile.smart_dynamic_cast<OOX::OleObject>();
|
||||
if (oleFile.IsInit())
|
||||
{
|
||||
if (OOX::CSystemUtility::IsFileExist(oleFile->filename()) == false)
|
||||
{
|
||||
typeAdditional = 1;
|
||||
|
||||
std::wstring strOle = strFolder + strFileName + oleFile->filename().GetExtention();
|
||||
if (OOX::CSystemUtility::IsFileExist(strOle))
|
||||
{
|
||||
m_pContentTypes->AddDefault(oleFile->filename().GetExtention(false));
|
||||
strOleBin = strOle;
|
||||
strAdditional = strOle;
|
||||
}
|
||||
else
|
||||
{
|
||||
strOle = strFolder + strFileName + L".bin";
|
||||
if (OOX::CSystemUtility::IsFileExist(strOle))
|
||||
strOleBin = strOle;
|
||||
strAdditional = strOle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(0 != (nDisplayType & 8))
|
||||
{
|
||||
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
if (mediaFile.IsInit())
|
||||
{
|
||||
if (OOX::CSystemUtility::IsFileExist(mediaFile->filename()) == false)
|
||||
{
|
||||
typeAdditional = 2;
|
||||
|
||||
std::wstring strMedia = strFolder + strFileName + mediaFile->filename().GetExtention();
|
||||
if (OOX::CSystemUtility::IsFileExist(strMedia))
|
||||
{
|
||||
m_pContentTypes->AddDefault(mediaFile->filename().GetExtention(false));
|
||||
strAdditional = strMedia;
|
||||
}
|
||||
else
|
||||
{
|
||||
strMedia = strFolder + strFileName;
|
||||
|
||||
if (mediaFile.is<OOX::Audio>()) strMedia += L".wav";
|
||||
if (mediaFile.is<OOX::Video>()) strMedia += L".avi";
|
||||
|
||||
if (OOX::CSystemUtility::IsFileExist(strMedia))
|
||||
strAdditional = strMedia;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,10 +282,14 @@ namespace NSBinPptxRW
|
||||
m_pContentTypes->AddDefault(strExts.substr(1));
|
||||
}
|
||||
|
||||
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strOleBin, oleData);
|
||||
_imageManager2Info oImageManagerInfo = GenerateImageExec(strImage, strExts, strAdditional, typeAdditional, oleData);
|
||||
|
||||
if (!oImageManagerInfo.sFilepathOle.empty())
|
||||
oleFile->set_filename(oImageManagerInfo.sFilepathOle);
|
||||
if (!oImageManagerInfo.sFilepathAdditional.empty())
|
||||
{
|
||||
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
if (mediaFile.IsInit())
|
||||
mediaFile->set_filename(oImageManagerInfo.sFilepathAdditional);
|
||||
}
|
||||
|
||||
if (strBase64Image.empty())
|
||||
m_mapImages[strInput] = oImageManagerInfo;
|
||||
@ -281,7 +334,7 @@ namespace NSBinPptxRW
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
_imageManager2Info CImageManager2::GenerateImageExec(const std::wstring& strInput, const std::wstring& sExts, const std::wstring& strOleImage, const std::wstring& oleData)
|
||||
_imageManager2Info CImageManager2::GenerateImageExec(const std::wstring& strInput, const std::wstring& sExts, const std::wstring& strAdditionalImage, int nAdditionalType, const std::wstring& oleData)
|
||||
{
|
||||
OOX::CPath oPathOutput;
|
||||
_imageManager2Info oImageManagerInfo;
|
||||
@ -305,29 +358,45 @@ namespace NSBinPptxRW
|
||||
}
|
||||
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
|
||||
|
||||
if (!strOleImage.empty() || !oleData.empty() )
|
||||
if ((!strAdditionalImage.empty() || !oleData.empty() ) && (nAdditionalType == 1))
|
||||
{
|
||||
std::wstring strExtsOle = L".bin";
|
||||
std::wstring strAdditionalExt = L".bin";
|
||||
|
||||
int pos = (int)strOleImage.rfind(L".");
|
||||
if (pos >= 0) strExtsOle = strOleImage.substr(pos);
|
||||
int pos = (int)strAdditionalImage.rfind(L".");
|
||||
if (pos >= 0) strAdditionalExt = strAdditionalImage.substr(pos);
|
||||
|
||||
std::wstring strImageOle = L"oleObject" + std::to_wstring(++m_lIndexNextOle) + strExtsOle;
|
||||
std::wstring strImageAdditional = L"oleObject" + std::to_wstring(++m_lIndexCounter) + strAdditionalExt;
|
||||
|
||||
OOX::CPath pathOutputOle = m_strDstEmbed + FILE_SEPARATOR_STR + strImageOle;
|
||||
OOX::CPath pathOutput = m_strDstEmbed + FILE_SEPARATOR_STR + strImageAdditional;
|
||||
|
||||
std::wstring strOleImageOut = pathOutputOle.GetPath();
|
||||
std::wstring strAdditionalImageOut = pathOutput.GetPath();
|
||||
|
||||
if(!oleData.empty())
|
||||
{
|
||||
WriteOleData(strOleImageOut, oleData);
|
||||
WriteOleData(strAdditionalImageOut, oleData);
|
||||
}
|
||||
else
|
||||
{
|
||||
CDirectory::CopyFile(strOleImage, strOleImageOut);
|
||||
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
|
||||
}
|
||||
|
||||
oImageManagerInfo.sFilepathOle = strOleImageOut;
|
||||
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
|
||||
}
|
||||
else if (!strAdditionalImage.empty() && nAdditionalType == 2)
|
||||
{
|
||||
std::wstring strAdditionalExt;
|
||||
|
||||
int pos = (int)strAdditionalImage.rfind(L".");
|
||||
if (pos >= 0) strAdditionalExt = strAdditionalImage.substr(pos);
|
||||
|
||||
std::wstring strImageAdditional = L"media" + std::to_wstring(++m_lIndexCounter) + strAdditionalExt;
|
||||
|
||||
OOX::CPath pathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strImageAdditional;
|
||||
|
||||
std::wstring strAdditionalImageOut = pathOutput.GetPath();
|
||||
|
||||
CDirectory::CopyFile(strAdditionalImage, strAdditionalImageOut);
|
||||
oImageManagerInfo.sFilepathAdditional = strAdditionalImageOut;
|
||||
}
|
||||
|
||||
return oImageManagerInfo;
|
||||
@ -372,7 +441,6 @@ namespace NSBinPptxRW
|
||||
strExts = strUrl.substr(nIndexExt);
|
||||
|
||||
std::wstring strImage;
|
||||
std::wstring strOleImage;
|
||||
|
||||
int nDisplayType = IsDisplayedImage(strUrl);
|
||||
|
||||
@ -380,11 +448,6 @@ namespace NSBinPptxRW
|
||||
{
|
||||
std::wstring strInputMetafile = strUrl.substr(0, strUrl.length() - strExts.length());
|
||||
std::wstring sDownloadRes;
|
||||
//todo
|
||||
if(0 != (nDisplayType & 4))
|
||||
{
|
||||
strOleImage = DownloadImageExec(strInputMetafile + _T(".bin"));
|
||||
}
|
||||
|
||||
if(0 != (nDisplayType & 1))
|
||||
{
|
||||
@ -414,11 +477,9 @@ namespace NSBinPptxRW
|
||||
_imageManager2Info oImageManagerInfo;
|
||||
if (!strImage.empty())
|
||||
{
|
||||
oImageManagerInfo = GenerateImageExec(strImage, strExts, strOleImage, L"");
|
||||
oImageManagerInfo = GenerateImageExec(strImage, strExts, L"", 0, L"");
|
||||
CDirectory::DeleteFile(strImage);
|
||||
}
|
||||
if (!strOleImage.empty())
|
||||
CDirectory::DeleteFile(strOleImage);
|
||||
|
||||
m_mapImages[strUrl] = oImageManagerInfo;
|
||||
return oImageManagerInfo;
|
||||
@ -1166,9 +1227,9 @@ namespace NSBinPptxRW
|
||||
oFile.CloseFile();
|
||||
}
|
||||
|
||||
_relsGeneratorInfo CRelsGenerator::WriteImage(const std::wstring& strImage, smart_ptr<OOX::OleObject> & oleFile, const std::wstring& oleData, std::wstring strBase64Image = _T(""))
|
||||
_relsGeneratorInfo CRelsGenerator::WriteImage(const std::wstring& strImage, smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image = _T(""))
|
||||
{
|
||||
_imageManager2Info oImageManagerInfo = m_pManager->GenerateImage(strImage, oleFile, oleData, strBase64Image);
|
||||
_imageManager2Info oImageManagerInfo = m_pManager->GenerateImage(strImage, additionalFile, oleData, strBase64Image);
|
||||
|
||||
std::wstring strImageRelsPath;
|
||||
|
||||
@ -1194,8 +1255,10 @@ namespace NSBinPptxRW
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"" + strImageRelsPath +
|
||||
L"\"/>");
|
||||
|
||||
if( oleFile.IsInit() )
|
||||
if(additionalFile.is<OOX::OleObject>())
|
||||
{
|
||||
smart_ptr<OOX::OleObject> oleFile = additionalFile.smart_dynamic_cast<OOX::OleObject>();
|
||||
|
||||
std::wstring strOleRelsPath;
|
||||
|
||||
oRelsGeneratorInfo.nOleRId = m_lNextRelsID++;
|
||||
@ -1222,7 +1285,29 @@ namespace NSBinPptxRW
|
||||
}
|
||||
}
|
||||
}
|
||||
if(additionalFile.is<OOX::Media>())
|
||||
{
|
||||
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
|
||||
std::wstring strMediaRelsPath;
|
||||
|
||||
oRelsGeneratorInfo.nMediaRId = m_lNextRelsID++;
|
||||
oRelsGeneratorInfo.sFilepathOle = mediaFile->filename().GetPath();
|
||||
|
||||
if (m_pManager->m_nDocumentType != XMLWRITER_DOC_TYPE_XLSX)
|
||||
{
|
||||
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nMediaRId);
|
||||
|
||||
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strMediaRelsPath = L"media/";
|
||||
else strMediaRelsPath = L"../media/";
|
||||
|
||||
strMediaRelsPath += mediaFile->filename().GetFilename();
|
||||
|
||||
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid
|
||||
+ L"\" Type=\"http://schemas.microsoft.com/office/2007/relationships/media\" Target=\"" +
|
||||
strMediaRelsPath + L"\"/>");
|
||||
}
|
||||
}
|
||||
m_mapImages.insert(std::pair<std::wstring, _relsGeneratorInfo>(strImageRelsPath, oRelsGeneratorInfo));
|
||||
return oRelsGeneratorInfo;
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ class COfficeFontPicker;
|
||||
|
||||
namespace OOX
|
||||
{
|
||||
class OleObject;
|
||||
class File;
|
||||
class CContentTypes;
|
||||
class WritingElement;
|
||||
class IFileContainer;
|
||||
@ -91,7 +91,7 @@ namespace NSBinPptxRW
|
||||
|
||||
struct _imageManager2Info
|
||||
{
|
||||
std::wstring sFilepathOle;
|
||||
std::wstring sFilepathAdditional;
|
||||
std::wstring sFilepathImage;
|
||||
};
|
||||
|
||||
@ -99,7 +99,9 @@ namespace NSBinPptxRW
|
||||
{
|
||||
int nImageRId;
|
||||
int nOleRId;
|
||||
int nMediaRId;
|
||||
|
||||
std::wstring sFilepathMedia;
|
||||
std::wstring sFilepathOle;
|
||||
std::wstring sFilepathImage;
|
||||
|
||||
@ -107,6 +109,7 @@ namespace NSBinPptxRW
|
||||
{
|
||||
nImageRId = -1;
|
||||
nOleRId = -1;
|
||||
nMediaRId = -1;
|
||||
}
|
||||
};
|
||||
|
||||
@ -158,17 +161,13 @@ namespace NSBinPptxRW
|
||||
|
||||
NSShapeImageGen::CImageManager* m_pImageManager;
|
||||
|
||||
//NSFontCutter::CFontDstManager m_oFontPicker;
|
||||
|
||||
NSFontCutter::CFontDstManager* m_pNativePicker;
|
||||
COfficeFontPicker* m_pFontPicker;
|
||||
bool m_bDeleteFontPicker;
|
||||
|
||||
public:
|
||||
CCommonWriter();
|
||||
~CCommonWriter();
|
||||
|
||||
public:
|
||||
void CreateFontPicker(COfficeFontPicker* pPicker);
|
||||
void CheckFontPicker();
|
||||
};
|
||||
@ -178,7 +177,7 @@ namespace NSBinPptxRW
|
||||
private:
|
||||
std::map<std::wstring, _imageManager2Info> m_mapImages;
|
||||
_INT32 m_lIndexNextImage;
|
||||
_INT32 m_lIndexNextOle;
|
||||
_INT32 m_lIndexCounter;
|
||||
std::wstring m_strDstMedia;
|
||||
std::wstring m_strDstEmbed;
|
||||
public:
|
||||
@ -197,8 +196,8 @@ namespace NSBinPptxRW
|
||||
|
||||
int IsDisplayedImage(const std::wstring& strInput);
|
||||
|
||||
_imageManager2Info GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::OleObject> & oleFile, const std::wstring& oleData, std::wstring strBase64Image);
|
||||
_imageManager2Info GenerateImageExec(const std::wstring& strInput, const std::wstring& strExts, const std::wstring& strOleImage, const std::wstring& oleData);
|
||||
_imageManager2Info GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image);
|
||||
_imageManager2Info GenerateImageExec(const std::wstring& strInput, const std::wstring& strExts, const std::wstring& strAdditionalImage, int nAdditionalType, const std::wstring& oleData);
|
||||
|
||||
void SaveImageAsPng(const std::wstring& strFileSrc, const std::wstring& strFileDst);
|
||||
void SaveImageAsJPG(const std::wstring& strFileSrc, const std::wstring& strFileDst);
|
||||
@ -426,7 +425,7 @@ namespace NSBinPptxRW
|
||||
void AddRels (const std::wstring& strRels);
|
||||
void SaveRels (const std::wstring& strFile);
|
||||
|
||||
_relsGeneratorInfo WriteImage (const std::wstring& strImage, NSCommon::smart_ptr<OOX::OleObject>& strOle, const std::wstring& oleData, std::wstring strBase64Image);
|
||||
_relsGeneratorInfo WriteImage (const std::wstring& strImage, NSCommon::smart_ptr<OOX::File>& additionalFile, const std::wstring& oleData, std::wstring strBase64Image);
|
||||
};
|
||||
|
||||
class CBinaryFileReader
|
||||
|
||||
@ -104,16 +104,14 @@ namespace NSShapeImageGen
|
||||
|
||||
return *this;
|
||||
}
|
||||
void SetNameModificator(NSShapeImageGen::ImageType eType, bool bOle)
|
||||
void SetNameModificator(NSShapeImageGen::ImageType eType, int typeAdditionalFile )
|
||||
{
|
||||
std::wstring sPrefix;
|
||||
int nRes = 0;
|
||||
if(itWMF == eType)
|
||||
nRes += 1;
|
||||
if(itEMF == eType)
|
||||
nRes += 2;
|
||||
if(bOle)
|
||||
nRes += 4;
|
||||
if(itWMF == eType) nRes += 1;
|
||||
if(itEMF == eType) nRes += 2;
|
||||
if(typeAdditionalFile == 1) nRes += 4;
|
||||
if(typeAdditionalFile == 2) nRes += 8;
|
||||
|
||||
if(0 != nRes)
|
||||
m_sName = L"display" + std::to_wstring(nRes) + L"image";
|
||||
}
|
||||
@ -199,7 +197,7 @@ namespace NSShapeImageGen
|
||||
|
||||
return GenerateImageID(punkImage, (std::max)(1.0, width), (std::max)(1.0, height));
|
||||
}
|
||||
CImageInfo WriteImage(const std::wstring& strFile, const std::wstring& strOleFile, double& x, double& y, double& width, double& height)
|
||||
CImageInfo WriteImage(const std::wstring& strFile, double& x, double& y, double& width, double& height, const std::wstring& strAdditionalFile, int typeAdditionalFile)
|
||||
{
|
||||
bool bIsDownload = false;
|
||||
int n1 = (int)strFile.find (L"www");
|
||||
@ -215,16 +213,16 @@ namespace NSShapeImageGen
|
||||
if (bIsDownload)
|
||||
{
|
||||
|
||||
std::wstring strFile1 = strFile;
|
||||
std::wstring strFileUrl = strFile;
|
||||
|
||||
XmlUtils::replace_all(strFile1, L"\\", L"/");
|
||||
XmlUtils::replace_all(strFile1, L"http:/", L"http://");
|
||||
XmlUtils::replace_all(strFile1, L"https:/", L"https://");
|
||||
XmlUtils::replace_all(strFile1, L"ftp:/", L"ftp://");
|
||||
XmlUtils::replace_all(strFileUrl, L"\\", L"/");
|
||||
XmlUtils::replace_all(strFileUrl, L"http:/", L"http://");
|
||||
XmlUtils::replace_all(strFileUrl, L"https:/", L"https://");
|
||||
XmlUtils::replace_all(strFileUrl, L"ftp:/", L"ftp://");
|
||||
|
||||
|
||||
CImageInfo oInfo;
|
||||
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(strFile1);
|
||||
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(strFileUrl);
|
||||
|
||||
if (pPair != m_mapImagesFile.end())
|
||||
return pPair->second;
|
||||
@ -233,7 +231,7 @@ namespace NSShapeImageGen
|
||||
|
||||
#ifndef DISABLE_FILE_DOWNLOADER
|
||||
|
||||
CFileDownloader oDownloader(strFile1, true);
|
||||
CFileDownloader oDownloader(strFileUrl, true);
|
||||
if (oDownloader.DownloadSync())
|
||||
{
|
||||
strDownload = oDownloader.GetFilePath();
|
||||
@ -241,21 +239,23 @@ namespace NSShapeImageGen
|
||||
|
||||
#endif
|
||||
|
||||
return GenerateImageID(strDownload, strFile1, strOleFile, (std::max)(1.0, width), (std::max)(1.0, height));
|
||||
return GenerateImageID(strDownload, strFileUrl, (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
|
||||
|
||||
|
||||
}
|
||||
|
||||
CImageInfo info;
|
||||
CFile oFile;
|
||||
if (S_OK != oFile.OpenFile(strFile))
|
||||
return info;
|
||||
if (strAdditionalFile.empty())
|
||||
{
|
||||
CImageInfo info;
|
||||
CFile oFile;
|
||||
if (S_OK != oFile.OpenFile(strFile))
|
||||
return info;
|
||||
oFile.CloseFile();
|
||||
}
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
if (-1 == width && -1 == height)
|
||||
return GenerateImageID(strFile, L"", strOleFile, width, height);
|
||||
return GenerateImageID(strFile, L"", strOleFile, (std::max)(1.0, width), (std::max)(1.0, height));
|
||||
if (width < 0 && height < 0) return GenerateImageID(strFile, L"", -1, -1, strAdditionalFile, typeAdditionalFile);
|
||||
return GenerateImageID(strFile, L"", (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
|
||||
}
|
||||
void SetFontManager(CFontManager* pFontManager)
|
||||
{
|
||||
@ -413,12 +413,12 @@ namespace NSShapeImageGen
|
||||
return oInfo;
|
||||
}
|
||||
|
||||
CImageInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, const std::wstring& strOleFile, double dWidth, double dHeight)
|
||||
CImageInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, double dWidth, double dHeight, const std::wstring& strAdditionalFile, int typeAdditionalFile)
|
||||
{
|
||||
std::wstring sMapKey = strFileName;
|
||||
|
||||
if(!strUrl.empty()) sMapKey = strUrl;
|
||||
if(!strOleFile.empty()) sMapKey += strOleFile;
|
||||
if(!strAdditionalFile.empty()) sMapKey += strAdditionalFile;
|
||||
|
||||
CImageInfo oInfo;
|
||||
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(sMapKey);
|
||||
@ -434,26 +434,30 @@ namespace NSShapeImageGen
|
||||
LONG lImageType = m_oImageExt.GetImageType(strFileName);
|
||||
|
||||
bool bVector = (1 == lImageType || 2 == lImageType);
|
||||
bool bOle = !strOleFile.empty();
|
||||
|
||||
bool bOle = !strAdditionalFile.empty() && (typeAdditionalFile == 1);
|
||||
bool bMedia = !strAdditionalFile.empty() && (typeAdditionalFile == 2);
|
||||
|
||||
if(bVector)
|
||||
oInfo.m_eType = (1 == lImageType) ? itWMF : itEMF;
|
||||
|
||||
oInfo.SetNameModificator(oInfo.m_eType, bOle);
|
||||
oInfo.SetNameModificator(oInfo.m_eType, typeAdditionalFile);
|
||||
|
||||
std::wstring strSaveDir = m_strDstMedia + FILE_SEPARATOR_STR;
|
||||
std::wstring strSaveItemWE = strSaveDir + std::wstring(oInfo.GetPathWithoutExtension());
|
||||
|
||||
//copy ole bin
|
||||
if(bOle)
|
||||
//copy ole bin or media
|
||||
if(bOle || bMedia)
|
||||
{
|
||||
std::wstring strExts = _T(".bin");
|
||||
int nIndexExt = (int)strOleFile.rfind(wchar_t('.'));
|
||||
std::wstring strExts;
|
||||
int nIndexExt = (int)strAdditionalFile.rfind(wchar_t('.'));
|
||||
if (-1 != nIndexExt)
|
||||
strExts = strOleFile.substr(nIndexExt);
|
||||
strExts = strAdditionalFile.substr(nIndexExt);
|
||||
|
||||
std::wstring sCopyOlePath = strSaveItemWE + strExts;//L".bin";
|
||||
CDirectory::CopyFile(strOleFile, sCopyOlePath);
|
||||
if(bOle && strExts.empty()) strExts = L".bin";
|
||||
|
||||
std::wstring sCopyOlePath = strSaveItemWE + strExts;
|
||||
CDirectory::CopyFile(strAdditionalFile, sCopyOlePath);
|
||||
}
|
||||
|
||||
if (bVector)
|
||||
|
||||
@ -86,12 +86,12 @@ namespace PPTX
|
||||
|
||||
void FileContainer::read(const OOX::CPath& filename)
|
||||
{
|
||||
//not implement FileContainer.read
|
||||
//OOX::IFileContainer::read(filename);
|
||||
}
|
||||
|
||||
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path)
|
||||
{
|
||||
//not implement FileContainer.read
|
||||
//OOX::IFileContainer::read(rels, path);
|
||||
}
|
||||
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path, FileMap& map, IPPTXEvent* Event)
|
||||
{
|
||||
@ -157,8 +157,6 @@ namespace PPTX
|
||||
pContainer->read(normPath, map, Event);
|
||||
m_bCancelled = pContainer->m_bCancelled;
|
||||
}
|
||||
//todo детально разобраться и вернуть проверку res.(до перехода на cross platform все было хорошо)
|
||||
//на презентация с hyperlink выходим при достижении 100%. Проценты считаются от количества обработанных файлов, а hyperlink не файл(Ligninger_og_uligheder.pptx)
|
||||
if (m_bCancelled)
|
||||
{
|
||||
break;
|
||||
|
||||
@ -165,12 +165,26 @@ namespace PPTX
|
||||
XmlUtils::CAttribute oAttr;
|
||||
XmlUtils::CNodeValue oValue;
|
||||
|
||||
return XmlUtils::CreateNode(_T("p:ext"), oValue);
|
||||
return XmlUtils::CreateNode(L"p:ext", oValue);
|
||||
}
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
// TODO:
|
||||
if (link.IsInit() && uri.IsInit())
|
||||
{
|
||||
pWriter->StartNode(L"p:ext");
|
||||
pWriter->StartAttributes();
|
||||
pWriter->WriteAttribute(L"uri", *uri);
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->StartNode(L"p14:media");
|
||||
pWriter->StartAttributes();
|
||||
pWriter->WriteAttribute(L"xmlns:p14", std::wstring(L"http://schemas.microsoft.com/office/powerpoint/2010/main"));
|
||||
pWriter->WriteAttribute(L"r:embed", link->get());
|
||||
pWriter->EndAttributes();
|
||||
pWriter->EndNode(L"p14:media");
|
||||
pWriter->EndNode(L"p:ext");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
|
||||
@ -156,5 +156,106 @@ namespace PPTX
|
||||
|
||||
return L"";
|
||||
}
|
||||
void Blip::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
std::wstring strName = (_T("") == m_namespace) ? _T("blip") : (m_namespace + _T(":blip"));
|
||||
pWriter->StartNode(strName);
|
||||
|
||||
pWriter->StartAttributes();
|
||||
if (embed.IsInit())
|
||||
pWriter->WriteAttribute(_T("r:embed"), embed->ToString());
|
||||
if (link.IsInit())
|
||||
pWriter->WriteAttribute(_T("r:link"), link->ToString());
|
||||
pWriter->WriteAttribute(_T("cstate"), cstate);
|
||||
pWriter->EndAttributes();
|
||||
|
||||
// TODO:
|
||||
size_t nCount = Effects.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
Effects[i].toXmlWriter(pWriter);
|
||||
}
|
||||
|
||||
pWriter->EndNode(strName);
|
||||
}
|
||||
|
||||
void Blip::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
pWriter->WriteLimit2(0, cstate);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
if (embed.is_init())
|
||||
pWriter->WriteString1(10, embed->get());
|
||||
if (link.is_init())
|
||||
pWriter->WriteString1(11, link->get());
|
||||
|
||||
pWriter->StartRecord(2);
|
||||
ULONG len = (ULONG)Effects.size();
|
||||
pWriter->WriteULONG(len);
|
||||
|
||||
for (ULONG i = 0; i < len; ++i)
|
||||
{
|
||||
pWriter->WriteRecord1(3, Effects[i]);
|
||||
}
|
||||
|
||||
pWriter->EndRecord();
|
||||
|
||||
double dX = pWriter->GetShapeX(); //mm
|
||||
double dY = pWriter->GetShapeY();
|
||||
|
||||
double dW = pWriter->GetShapeWidth(); //mm
|
||||
double dH = pWriter->GetShapeHeight();
|
||||
|
||||
OOX::IFileContainer* pRels = NULL;
|
||||
|
||||
if (pWriter->m_pCurrentContainer->is_init())
|
||||
pRels = pWriter->m_pCurrentContainer->operator ->();
|
||||
|
||||
std::wstring additionalPath;
|
||||
int additionalType = 0;
|
||||
if(!oleFilepathBin.empty())
|
||||
{
|
||||
additionalPath = oleFilepathBin;
|
||||
additionalType = 1;
|
||||
}
|
||||
else if(!oleRid.empty())
|
||||
{
|
||||
additionalPath = this->GetFullOleName(OOX::RId(oleRid), pRels);
|
||||
additionalType = 1;
|
||||
}
|
||||
else if(!mediaRid.empty())
|
||||
{
|
||||
additionalPath = this->GetFullOleName(OOX::RId(mediaRid), pRels);
|
||||
additionalType = 2;
|
||||
}
|
||||
else if(!mediaFilepath.empty())
|
||||
{
|
||||
additionalPath = mediaFilepath;
|
||||
additionalType = 2;
|
||||
}
|
||||
|
||||
std::wstring imagePath;
|
||||
if(!oleFilepathImage.empty())
|
||||
{
|
||||
imagePath = oleFilepathImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
imagePath = this->GetFullPicName(pRels);
|
||||
}
|
||||
|
||||
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(imagePath, dX, dY, dW, dH, additionalPath, additionalType);
|
||||
std::wstring s = oId.GetPath2();
|
||||
|
||||
pWriter->StartRecord(3);
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
pWriter->WriteString1(0, s);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
} // namespace Logic
|
||||
} // namespace PPTX
|
||||
@ -63,16 +63,22 @@ namespace PPTX
|
||||
link = oSrc.link;
|
||||
|
||||
m_namespace = oSrc.m_namespace;
|
||||
|
||||
oleRid = oSrc.oleRid;
|
||||
oleFilepathBin = oSrc.oleFilepathBin;
|
||||
|
||||
mediaRid = oSrc.mediaRid;
|
||||
mediaFilepath = oSrc.mediaFilepath;
|
||||
|
||||
return *this;
|
||||
}
|
||||
virtual OOX::EElementType getType() const
|
||||
{
|
||||
return OOX::et_a_blip;
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
@ -81,96 +87,11 @@ namespace PPTX
|
||||
WritingElement_ReadAttributes_Read_else_if( oReader, _T("cstate"), cstate )
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual std::wstring toXML() const;
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
std::wstring strName = (_T("") == m_namespace) ? _T("blip") : (m_namespace + _T(":blip"));
|
||||
pWriter->StartNode(strName);
|
||||
|
||||
pWriter->StartAttributes();
|
||||
if (embed.IsInit())
|
||||
pWriter->WriteAttribute(_T("r:embed"), embed->ToString());
|
||||
if (link.IsInit())
|
||||
pWriter->WriteAttribute(_T("r:link"), link->ToString());
|
||||
pWriter->WriteAttribute(_T("cstate"), cstate);
|
||||
pWriter->EndAttributes();
|
||||
|
||||
// TODO:
|
||||
size_t nCount = Effects.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
Effects[i].toXmlWriter(pWriter);
|
||||
}
|
||||
|
||||
pWriter->EndNode(strName);
|
||||
}
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
pWriter->WriteLimit2(0, cstate);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
if (embed.is_init())
|
||||
pWriter->WriteString1(10, embed->get());
|
||||
if (link.is_init())
|
||||
pWriter->WriteString1(11, link->get());
|
||||
|
||||
pWriter->StartRecord(2);
|
||||
ULONG len = (ULONG)Effects.size();
|
||||
pWriter->WriteULONG(len);
|
||||
|
||||
for (ULONG i = 0; i < len; ++i)
|
||||
{
|
||||
pWriter->WriteRecord1(3, Effects[i]);
|
||||
}
|
||||
|
||||
pWriter->EndRecord();
|
||||
|
||||
double dX = pWriter->GetShapeX(); //mm
|
||||
double dY = pWriter->GetShapeY();
|
||||
|
||||
double dW = pWriter->GetShapeWidth(); //mm
|
||||
double dH = pWriter->GetShapeHeight();
|
||||
|
||||
OOX::IFileContainer* pRels = NULL;
|
||||
|
||||
if (pWriter->m_pCurrentContainer->is_init())
|
||||
pRels = pWriter->m_pCurrentContainer->operator ->();
|
||||
|
||||
std::wstring olePath;
|
||||
if(!oleFilepathBin.empty())
|
||||
{
|
||||
olePath = oleFilepathBin;
|
||||
}
|
||||
else if(!oleRid.empty())
|
||||
{
|
||||
olePath= this->GetFullOleName(OOX::RId(oleRid), pRels);
|
||||
}
|
||||
|
||||
std::wstring imagePath;
|
||||
if(!oleFilepathImage.empty())
|
||||
{
|
||||
imagePath = oleFilepathImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
imagePath = this->GetFullPicName(pRels);
|
||||
}
|
||||
|
||||
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(imagePath, olePath, dX, dY, dW, dH);
|
||||
std::wstring s = oId.GetPath2();
|
||||
|
||||
pWriter->StartRecord(3);
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
pWriter->WriteString1(0, s);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
|
||||
virtual std::wstring GetFullPicName(OOX::IFileContainer* pRels = NULL)const;
|
||||
virtual std::wstring GetFullOleName(const OOX::RId& pRId, OOX::IFileContainer* pRels = NULL)const;
|
||||
|
||||
@ -180,9 +101,11 @@ namespace PPTX
|
||||
nullable<OOX::RId> embed;
|
||||
nullable<OOX::RId> link;
|
||||
std::wstring m_namespace;
|
||||
//internal
|
||||
std::wstring mediaRid;
|
||||
std::wstring mediaFilepath;
|
||||
|
||||
std::wstring oleRid;
|
||||
//internal
|
||||
std::wstring oleFilepathBin;
|
||||
std::wstring oleFilepathImage;
|
||||
protected:
|
||||
|
||||
@ -69,6 +69,9 @@ namespace PPTX
|
||||
dpi = oSrc.dpi;
|
||||
rotWithShape = oSrc.rotWithShape;
|
||||
|
||||
additionalFile = oSrc.additionalFile;
|
||||
oleData = oSrc.oleData;
|
||||
|
||||
m_namespace = oSrc.m_namespace;
|
||||
return *this;
|
||||
}
|
||||
@ -432,10 +435,10 @@ namespace PPTX
|
||||
strImagePath = pathUrl.GetPath();
|
||||
}
|
||||
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, oleFile, oleData, strOrigBase64);
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strImagePath, additionalFile, oleData, strOrigBase64);
|
||||
|
||||
// -------------------
|
||||
if (strTempFile != _T(""))
|
||||
if (!strTempFile.empty())
|
||||
{
|
||||
CDirectory::DeleteFile(strTempFile);
|
||||
}
|
||||
@ -445,14 +448,18 @@ namespace PPTX
|
||||
blip = new PPTX::Logic::Blip();
|
||||
|
||||
blip->embed = new OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
|
||||
blip->oleFilepathImage = oRelsGeneratorInfo.sFilepathImage;
|
||||
|
||||
if(oRelsGeneratorInfo.nOleRId > 0)
|
||||
{
|
||||
blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
|
||||
blip->oleFilepathBin = oRelsGeneratorInfo.sFilepathOle;
|
||||
blip->oleFilepathImage = oRelsGeneratorInfo.sFilepathImage;
|
||||
}
|
||||
if(oRelsGeneratorInfo.nMediaRId > 0)
|
||||
{
|
||||
blip->mediaRid = OOX::RId((size_t)oRelsGeneratorInfo.nMediaRId).get();
|
||||
blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia;
|
||||
}
|
||||
|
||||
pReader->Skip(1); // end attribute
|
||||
break;
|
||||
}
|
||||
@ -507,8 +514,8 @@ namespace PPTX
|
||||
nullable_bool rotWithShape;
|
||||
|
||||
//internal
|
||||
smart_ptr<OOX::OleObject> oleFile;
|
||||
std::wstring oleData;
|
||||
mutable smart_ptr<OOX::File> additionalFile;
|
||||
std::wstring oleData;
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds()
|
||||
{
|
||||
|
||||
@ -45,8 +45,9 @@ namespace PPTX
|
||||
public:
|
||||
WritingElement_AdditionConstructors(MediaFile)
|
||||
|
||||
MediaFile()
|
||||
MediaFile(std::wstring name_)
|
||||
{
|
||||
name = name_;
|
||||
}
|
||||
|
||||
MediaFile& operator=(const MediaFile& oSrc)
|
||||
@ -75,19 +76,28 @@ namespace PPTX
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
WritingElement_ReadAttributes_Start( oReader )
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:link"), link)
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("contentType"), contentType)
|
||||
WritingElement_ReadAttributes_Read_if ( oReader, L"r:link", link)
|
||||
WritingElement_ReadAttributes_Read_else_if ( oReader, L"contentType", contentType)
|
||||
WritingElement_ReadAttributes_End( oReader )
|
||||
}
|
||||
virtual std::wstring toXML() const
|
||||
{
|
||||
XmlUtils::CAttribute oAttr;
|
||||
oAttr.Write(_T("r:link"), link.ToString());
|
||||
oAttr.Write(_T("contentType"), contentType);
|
||||
oAttr.Write(L"r:link", link.ToString());
|
||||
oAttr.Write(L"contentType", contentType);
|
||||
|
||||
return XmlUtils::CreateNode(_T("a:") + name, oAttr);
|
||||
return XmlUtils::CreateNode(L"a:" + name, oAttr);
|
||||
}
|
||||
public:
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
pWriter->StartNode(L"a:" + name);
|
||||
pWriter->StartAttributes();
|
||||
pWriter->WriteAttribute (L"r:link", link.ToString());
|
||||
pWriter->WriteAttribute (L"contentType", contentType);
|
||||
pWriter->EndAttributes();
|
||||
pWriter->EndNode(L"a:" + name);
|
||||
}
|
||||
|
||||
std::wstring name;
|
||||
OOX::RId link;
|
||||
nullable_string contentType;
|
||||
|
||||
@ -41,7 +41,10 @@
|
||||
#include "Media/MediaFile.h"
|
||||
#include "Media/WavAudioFile.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/MathEquation/MathEquation.h"
|
||||
|
||||
#include "../../../ASCOfficeDocxFile2/BinWriter/BinEquationWriter.h"
|
||||
@ -136,7 +139,9 @@ namespace PPTX
|
||||
pWriter->WriteLimit2(6, m_oUpdateMode);
|
||||
if (ole_file.IsInit() == false || ole_file->isMsPackage() == false)
|
||||
{
|
||||
pWriter->WriteString1(7, ole_file->filename().GetFilename()); //OleObject Binary FileName (bin, xls, doc, ... other stream file)
|
||||
std::wstring sExt = ole_file->filename().GetExtention(false);
|
||||
if (!sExt.empty())
|
||||
pWriter->WriteString1(7, L"maskFile." + sExt); //OleObject Binary FileName Extension (bin, xls, doc, ... other stream file)
|
||||
}
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
|
||||
@ -608,6 +613,137 @@ namespace PPTX
|
||||
|
||||
return XmlUtils::CreateNode(m_namespace + L":pic", oValue);
|
||||
}
|
||||
|
||||
void Pic::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
if(oleObject.IsInit())
|
||||
{
|
||||
pWriter->StartRecord(SPTREE_TYPE_OLE);
|
||||
}
|
||||
else if (nvPicPr.nvPr.media.is_init())
|
||||
{
|
||||
blipFill.additionalFile = GetMediaLink();
|
||||
|
||||
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
if (mediaFile.IsInit() && blipFill.blip.IsInit())
|
||||
{
|
||||
blipFill.blip->mediaFilepath = mediaFile->filename().GetPath();
|
||||
}
|
||||
|
||||
if (nvPicPr.nvPr.media.as<MediaFile>().name == L"audioFile")
|
||||
pWriter->StartRecord(SPTREE_TYPE_AUDIO);
|
||||
else if (nvPicPr.nvPr.media.as<MediaFile>().name == L"videoFile")
|
||||
pWriter->StartRecord(SPTREE_TYPE_VIDEO);
|
||||
else
|
||||
pWriter->StartRecord(SPTREE_TYPE_PIC);
|
||||
}
|
||||
else
|
||||
{
|
||||
pWriter->StartRecord(SPTREE_TYPE_PIC);
|
||||
}
|
||||
|
||||
if (blipFill.additionalFile.is<OOX::Media>())
|
||||
{
|
||||
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
|
||||
pWriter->StartRecord(5);
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
|
||||
std::wstring sExt = mediaFile->filename().GetExtention(false);
|
||||
if (!sExt.empty())
|
||||
pWriter->WriteString1(0, L"maskFile." + sExt);
|
||||
//todoo start, end positions ..
|
||||
|
||||
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
pWriter->WriteRecord2(4, oleObject);
|
||||
pWriter->WriteRecord1(0, nvPicPr);
|
||||
pWriter->WriteRecord1(1, blipFill);
|
||||
pWriter->WriteRecord1(2, spPr);
|
||||
pWriter->WriteRecord2(3, style);
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
void Pic::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
std::wstring namespace_ = m_namespace;
|
||||
bool bOle = false;
|
||||
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
|
||||
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
|
||||
|
||||
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
|
||||
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
if(oleObject.IsInit() && oleObject->isValid())
|
||||
{
|
||||
bOle = true;
|
||||
pWriter->WriteString(L"<p:graphicFrame><p:nvGraphicFramePr><p:cNvPr id=\"0\" name=\"\"/><p:cNvGraphicFramePr><a:graphicFrameLocks noChangeAspect=\"1\"/></p:cNvGraphicFramePr><p:nvPr><p:extLst><p:ext uri=\"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}\"><p14:modId xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\" val=\"2157879785\"/></p:ext></p:extLst></p:nvPr></p:nvGraphicFramePr>");
|
||||
if(spPr.xfrm.IsInit())
|
||||
{
|
||||
std::wstring oldNamespace = spPr.xfrm->m_ns;
|
||||
spPr.xfrm->m_ns = _T("p");
|
||||
spPr.xfrm->toXmlWriter(pWriter);
|
||||
spPr.xfrm->m_ns = oldNamespace;
|
||||
}
|
||||
pWriter->WriteString(L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/presentationml/2006/ole\">");
|
||||
|
||||
pWriter->StartNode(_T("p:oleObj"));
|
||||
pWriter->WriteAttribute(L"name", (std::wstring)L"oleObj");
|
||||
if(oleObject->m_oId.IsInit())
|
||||
{
|
||||
pWriter->WriteAttribute2(L"r:id", oleObject->m_oId->get());
|
||||
}
|
||||
if(oleObject->m_oDxaOrig.IsInit())
|
||||
{
|
||||
int nDxaOrig = oleObject->m_oDxaOrig.get();
|
||||
pWriter->WriteAttribute(L"imgW", 635 * nDxaOrig); //twips to emu
|
||||
}
|
||||
if(oleObject->m_oDyaOrig.IsInit())
|
||||
{
|
||||
int nDyaOrig = oleObject->m_oDyaOrig.get();
|
||||
pWriter->WriteAttribute(L"imgH", 635 * nDyaOrig); //twips to emu
|
||||
}
|
||||
pWriter->WriteAttribute2(L"progId", oleObject->m_sProgId);
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->WriteString(L"<p:embed/>");
|
||||
}
|
||||
}
|
||||
pWriter->StartNode(namespace_ + L":pic");
|
||||
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
pWriter->StartAttributes();
|
||||
pWriter->WriteAttribute(_T("xmlns:pic"), (std::wstring)_T("http://schemas.openxmlformats.org/drawingml/2006/picture"));
|
||||
}
|
||||
pWriter->EndAttributes();
|
||||
|
||||
nvPicPr.toXmlWriter(pWriter);
|
||||
|
||||
blipFill.m_namespace = namespace_;
|
||||
blipFill.toXmlWriter(pWriter);
|
||||
|
||||
pWriter->m_lFlag = 1;
|
||||
spPr.toXmlWriter(pWriter);
|
||||
pWriter->m_lFlag = 0;
|
||||
|
||||
pWriter->Write(style);
|
||||
|
||||
pWriter->EndNode(namespace_ + L":pic");
|
||||
|
||||
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
|
||||
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
if(bOle)
|
||||
{
|
||||
pWriter->WriteString(L"</p:oleObj></a:graphicData></a:graphic></p:graphicFrame>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Pic::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
|
||||
{
|
||||
@ -621,9 +757,8 @@ namespace PPTX
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
nvPicPr.fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
nvPicPr.fromPPTY(pReader);
|
||||
}break;
|
||||
case 1:
|
||||
{
|
||||
blipFill.fromPPTY(pReader);
|
||||
@ -637,19 +772,23 @@ namespace PPTX
|
||||
if (NSFile::CFileBinary::Exists(oleObject->m_OleObjectFile->filename().GetPath()) == false)
|
||||
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
if (mediaFile.IsInit() && blipFill.blip.IsInit())
|
||||
{
|
||||
if (NSFile::CFileBinary::Exists(mediaFile->filename().GetPath()) == false)
|
||||
mediaFile->set_filename (blipFill.blip->mediaFilepath);
|
||||
}
|
||||
}break;
|
||||
case 2:
|
||||
{
|
||||
spPr.fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
spPr.fromPPTY(pReader);
|
||||
}break;
|
||||
case 3:
|
||||
{
|
||||
style = new ShapeStyle(L"p");
|
||||
style->fromPPTY(pReader);
|
||||
break;
|
||||
}
|
||||
style->fromPPTY(pReader);
|
||||
}break;
|
||||
case 4:
|
||||
{
|
||||
oleObject = new COLEObject();
|
||||
@ -658,15 +797,34 @@ namespace PPTX
|
||||
if(oleObject->m_sData.IsInit())
|
||||
blipFill.oleData = oleObject->m_sData.get();
|
||||
|
||||
blipFill.oleFile = oleObject->m_OleObjectFile;
|
||||
blipFill.additionalFile = oleObject->m_OleObjectFile.smart_dynamic_cast<OOX::File>();
|
||||
}break;
|
||||
case 5:
|
||||
{
|
||||
LONG _end_rec1 = pReader->GetPos() + pReader->GetLong() + 4;
|
||||
|
||||
//if (oleObject->m_OleObjectFile.IsInit())
|
||||
//{
|
||||
// blipFill.olePath = oleObject->m_OleObjectFile->filename().GetPath();
|
||||
// if (NSFile::CFileBinary::Exists(blipFill.olePath))
|
||||
// blipFill.olePath.clear();
|
||||
//}
|
||||
break;
|
||||
pReader->Skip(1); // start attributes
|
||||
|
||||
while (true)
|
||||
{
|
||||
BYTE _at = pReader->GetUChar_TypeNode();
|
||||
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
|
||||
break;
|
||||
|
||||
if (0 == _at)
|
||||
{
|
||||
std::wstring strMediaFileMask = pReader->GetString2();
|
||||
|
||||
smart_ptr<OOX::Media> mediaFile = blipFill.additionalFile.smart_dynamic_cast<OOX::Media>();
|
||||
if (mediaFile.IsInit())
|
||||
{
|
||||
mediaFile->set_filename(strMediaFileMask);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
pReader->Seek(_end_rec1);
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -674,16 +832,53 @@ namespace PPTX
|
||||
}
|
||||
}
|
||||
}
|
||||
if(blipFill.blip.IsInit() && !blipFill.blip->oleRid.empty() && oleObject.IsInit())
|
||||
if(blipFill.blip.IsInit() && blipFill.additionalFile.IsInit())
|
||||
{
|
||||
oleObject->m_oId = OOX::RId(blipFill.blip->oleRid);
|
||||
|
||||
if (oleObject->m_OleObjectFile.IsInit() == false)
|
||||
if (!blipFill.blip->oleRid.empty() && oleObject.IsInit())
|
||||
{
|
||||
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
|
||||
|
||||
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin);
|
||||
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);
|
||||
oleObject->m_oId = OOX::RId(blipFill.blip->oleRid);
|
||||
|
||||
if (oleObject->m_OleObjectFile.IsInit() == false)
|
||||
{
|
||||
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
|
||||
|
||||
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin);
|
||||
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);
|
||||
}
|
||||
}
|
||||
if (!blipFill.blip->mediaRid.empty())
|
||||
{
|
||||
PPTX::Logic::Ext ext;
|
||||
ext.link = OOX::RId(blipFill.blip->mediaRid);
|
||||
ext.uri = L"{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}";
|
||||
nvPicPr.nvPr.extLst.push_back(ext);
|
||||
|
||||
int nRId = -1;
|
||||
if (blipFill.additionalFile.is<OOX::Audio>())
|
||||
{
|
||||
nvPicPr.nvPr.media.Media = new PPTX::Logic::MediaFile(L"audioFile");
|
||||
nRId = pReader->m_pRels->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio",
|
||||
L"NULL", L"External");
|
||||
|
||||
}
|
||||
if (blipFill.additionalFile.is<OOX::Video>())
|
||||
{
|
||||
nvPicPr.nvPr.media.Media = new PPTX::Logic::MediaFile(L"videoFile");
|
||||
nRId = pReader->m_pRels->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video",
|
||||
L"NULL", L"External");
|
||||
}
|
||||
|
||||
if (nvPicPr.nvPr.media.Media.IsInit() && nRId > 0)
|
||||
{
|
||||
PPTX::Logic::MediaFile& mediaFile = nvPicPr.nvPr.media.Media.as<PPTX::Logic::MediaFile>();
|
||||
mediaFile.link = OOX::RId((size_t)nRId);
|
||||
|
||||
}
|
||||
if (nvPicPr.cNvPr.hlinkClick.IsInit() == false)
|
||||
nvPicPr.cNvPr.hlinkClick.Init();
|
||||
|
||||
nvPicPr.cNvPr.hlinkClick->id = L"";
|
||||
nvPicPr.cNvPr.hlinkClick->action = L"ppaction://media";
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,57 +921,28 @@ namespace PPTX
|
||||
return blipFill.blip->GetFullPicName();
|
||||
return _T("");
|
||||
}
|
||||
|
||||
std::wstring Pic::GetVideoLink()const
|
||||
smart_ptr<OOX::File> Pic::GetMediaLink()const
|
||||
{
|
||||
std::wstring file = _T("");
|
||||
if (parentFileIs<Slide>())
|
||||
smart_ptr<OOX::File> file;
|
||||
|
||||
if (!parentFileIs<Slide>()) return file;
|
||||
|
||||
if (nvPicPr.nvPr.media.is<WavAudioFile>())
|
||||
{
|
||||
if (nvPicPr.nvPr.media.is<MediaFile>())
|
||||
{
|
||||
if ((nvPicPr.nvPr.media.as<MediaFile>().name == _T("videoFile")) || (nvPicPr.nvPr.media.as<MediaFile>().name == _T("quickTimeFile")))
|
||||
{
|
||||
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.media.as<MediaFile>().link.get());
|
||||
if (std::wstring (_T("NULL")) == file) // HAVE TRIM
|
||||
{
|
||||
if(nvPicPr.nvPr.extLst.size())
|
||||
{
|
||||
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.extLst[0].link.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return parentFileAs<Slide>().Find(nvPicPr.nvPr.media.as<WavAudioFile>().embed.get());
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
std::wstring Pic::GetAudioLink()const
|
||||
{
|
||||
std::wstring file = _T("");
|
||||
if (parentFileIs<Slide>())
|
||||
if (nvPicPr.nvPr.media.is<MediaFile>())
|
||||
{
|
||||
if (nvPicPr.nvPr.media.is<WavAudioFile>())
|
||||
file = parentFileAs<Slide>().Find(nvPicPr.nvPr.media.as<MediaFile>().link.get());
|
||||
smart_ptr<OOX::Media> mediaFile = file.smart_dynamic_cast<OOX::Media>();
|
||||
|
||||
if ( mediaFile.IsInit() == false && !nvPicPr.nvPr.extLst.empty())
|
||||
{
|
||||
return parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.media.as<WavAudioFile>().embed.get());
|
||||
}
|
||||
|
||||
if (nvPicPr.nvPr.media.is<MediaFile>())
|
||||
{
|
||||
if (nvPicPr.nvPr.media.as<MediaFile>().name == _T("audioFile"))
|
||||
{
|
||||
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.media.as<MediaFile>().link.get());
|
||||
|
||||
if (std::wstring (_T("NULL")) == file) // HAVE TRIM
|
||||
{
|
||||
if(nvPicPr.nvPr.extLst.size())
|
||||
{
|
||||
file = parentFileAs<Slide>().GetLinkFromRId(nvPicPr.nvPr.extLst[0].link.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//todooo - почему везде нулевой то? - сделать по всем поиск по uri
|
||||
file = parentFileAs<Slide>().Find(nvPicPr.nvPr.extLst[0].link.get());
|
||||
}
|
||||
}//удалять ли c UnknownType ???? (если не найден щас генерится)
|
||||
return file;
|
||||
}
|
||||
|
||||
@ -1158,7 +1324,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
|
||||
|
||||
@ -237,127 +237,35 @@ namespace PPTX
|
||||
|
||||
virtual void fromXML(XmlUtils::CXmlNode& node);
|
||||
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader);
|
||||
|
||||
virtual std::wstring toXML() const;
|
||||
void fromXMLOle(XmlUtils::CXmlNode& node);
|
||||
|
||||
virtual void GetRect(Aggplus::RECT& pRect)const;
|
||||
|
||||
virtual std::wstring GetFullPicName()const;
|
||||
virtual std::wstring GetVideoLink()const;
|
||||
virtual std::wstring GetAudioLink()const;
|
||||
smart_ptr<OOX::File> GetMediaLink()const;
|
||||
|
||||
DWORD GetFill(UniFill& fill)const;
|
||||
DWORD GetLine(Ln& line)const;
|
||||
|
||||
double GetStTrim () const;
|
||||
double GetEndTrim () const;
|
||||
long GetRefId() const;
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
if(oleObject.IsInit())
|
||||
{
|
||||
pWriter->StartRecord(SPTREE_TYPE_OLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
pWriter->StartRecord(SPTREE_TYPE_PIC);
|
||||
}
|
||||
|
||||
pWriter->WriteRecord2(4, oleObject);
|
||||
pWriter->WriteRecord1(0, nvPicPr);
|
||||
pWriter->WriteRecord1(1, blipFill);
|
||||
pWriter->WriteRecord1(2, spPr);
|
||||
pWriter->WriteRecord2(3, style);
|
||||
|
||||
pWriter->EndRecord();
|
||||
}
|
||||
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
std::wstring namespace_ = m_namespace;
|
||||
bool bOle = false;
|
||||
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_XLSX) namespace_ = L"xdr";
|
||||
else if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX) namespace_ = L"pic";
|
||||
|
||||
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
|
||||
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
if(oleObject.IsInit() && oleObject->isValid())
|
||||
{
|
||||
bOle = true;
|
||||
pWriter->WriteString(L"<p:graphicFrame><p:nvGraphicFramePr><p:cNvPr id=\"0\" name=\"\"/><p:cNvGraphicFramePr><a:graphicFrameLocks noChangeAspect=\"1\"/></p:cNvGraphicFramePr><p:nvPr><p:extLst><p:ext uri=\"{D42A27DB-BD31-4B8C-83A1-F6EECF244321}\"><p14:modId xmlns:p14=\"http://schemas.microsoft.com/office/powerpoint/2010/main\" val=\"2157879785\"/></p:ext></p:extLst></p:nvPr></p:nvGraphicFramePr>");
|
||||
if(spPr.xfrm.IsInit())
|
||||
{
|
||||
std::wstring oldNamespace = spPr.xfrm->m_ns;
|
||||
spPr.xfrm->m_ns = _T("p");
|
||||
spPr.xfrm->toXmlWriter(pWriter);
|
||||
spPr.xfrm->m_ns = oldNamespace;
|
||||
}
|
||||
pWriter->WriteString(L"<a:graphic><a:graphicData uri=\"http://schemas.openxmlformats.org/presentationml/2006/ole\">");
|
||||
|
||||
pWriter->StartNode(_T("p:oleObj"));
|
||||
pWriter->WriteAttribute(L"name", (std::wstring)L"oleObj");
|
||||
if(oleObject->m_oId.IsInit())
|
||||
{
|
||||
pWriter->WriteAttribute2(L"r:id", oleObject->m_oId->get());
|
||||
}
|
||||
if(oleObject->m_oDxaOrig.IsInit())
|
||||
{
|
||||
int nDxaOrig = oleObject->m_oDxaOrig.get();
|
||||
pWriter->WriteAttribute(L"imgW", 635 * nDxaOrig); //twips to emu
|
||||
}
|
||||
if(oleObject->m_oDyaOrig.IsInit())
|
||||
{
|
||||
int nDyaOrig = oleObject->m_oDyaOrig.get();
|
||||
pWriter->WriteAttribute(L"imgH", 635 * nDyaOrig); //twips to emu
|
||||
}
|
||||
pWriter->WriteAttribute2(L"progId", oleObject->m_sProgId);
|
||||
pWriter->EndAttributes();
|
||||
|
||||
pWriter->WriteString(L"<p:embed/>");
|
||||
}
|
||||
}
|
||||
pWriter->StartNode(namespace_ + L":pic");
|
||||
|
||||
if (pWriter->m_lDocType == XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
pWriter->StartAttributes();
|
||||
pWriter->WriteAttribute(_T("xmlns:pic"), (std::wstring)_T("http://schemas.openxmlformats.org/drawingml/2006/picture"));
|
||||
}
|
||||
pWriter->EndAttributes();
|
||||
|
||||
nvPicPr.toXmlWriter(pWriter);
|
||||
|
||||
blipFill.m_namespace = namespace_;
|
||||
blipFill.toXmlWriter(pWriter);
|
||||
|
||||
pWriter->m_lFlag = 1;
|
||||
spPr.toXmlWriter(pWriter);
|
||||
pWriter->m_lFlag = 0;
|
||||
|
||||
pWriter->Write(style);
|
||||
|
||||
pWriter->EndNode(namespace_ + L":pic");
|
||||
|
||||
if (pWriter->m_lDocType != XMLWRITER_DOC_TYPE_XLSX &&
|
||||
pWriter->m_lDocType != XMLWRITER_DOC_TYPE_DOCX)
|
||||
{
|
||||
if(bOle)
|
||||
{
|
||||
pWriter->WriteString(L"</p:oleObj></a:graphicData></a:graphic></p:graphicFrame>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
|
||||
virtual std::wstring toXML() const;
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const;
|
||||
void toXmlWriterVML(NSBinPptxRW::CXmlWriter* pWriter, smart_ptr<PPTX::Theme>& oTheme, smart_ptr<PPTX::Logic::ClrMap>& oClrMap, bool in_group = false);
|
||||
void fromXMLOle(XmlUtils::CXmlNode& node);
|
||||
//----------------------------------------------------------------------
|
||||
NvPicPr nvPicPr;
|
||||
BlipFill blipFill;
|
||||
SpPr spPr;
|
||||
nullable<ShapeStyle> style;
|
||||
//internal
|
||||
nullable<COLEObject> oleObject;
|
||||
|
||||
std::wstring m_namespace;
|
||||
nullable<COLEObject> oleObject;
|
||||
nullable_string m_sClientDataXml;
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds();
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -37,8 +37,11 @@
|
||||
#include "CxnSp.h"
|
||||
#include "SpTree.h"
|
||||
#include "GraphicFrame.h"
|
||||
#include "./../SlideMaster.h"
|
||||
|
||||
#include "../SlideMaster.h"
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Audio.h"
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Media/Video.h"
|
||||
namespace PPTX
|
||||
{
|
||||
namespace Logic
|
||||
@ -56,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;
|
||||
@ -110,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=\"\" />");
|
||||
@ -346,8 +349,22 @@ namespace PPTX
|
||||
}
|
||||
case SPTREE_TYPE_OLE:
|
||||
case SPTREE_TYPE_PIC:
|
||||
case SPTREE_TYPE_AUDIO:
|
||||
case SPTREE_TYPE_VIDEO:
|
||||
{
|
||||
Logic::Pic* p = new Logic::Pic();
|
||||
|
||||
if (_type == SPTREE_TYPE_AUDIO)
|
||||
{
|
||||
OOX::Audio *pAudio = new OOX::Audio(pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
|
||||
p->blipFill.additionalFile = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(pAudio));
|
||||
}
|
||||
else if (_type == SPTREE_TYPE_VIDEO)
|
||||
{
|
||||
OOX::Video* pVideo = new OOX::Video(pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
|
||||
p->blipFill.additionalFile = smart_ptr<OOX::File>(dynamic_cast<OOX::File*>(pVideo));
|
||||
}
|
||||
|
||||
p->fromPPTY(pReader);
|
||||
m_elem.reset(p);
|
||||
break;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -434,10 +434,10 @@ namespace PPTX
|
||||
}
|
||||
// -------------------
|
||||
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, pFill->oleFile, pFill->oleData, strOrigBase64);
|
||||
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteImage(strUrl, pFill->additionalFile, pFill->oleData, strOrigBase64);
|
||||
|
||||
// -------------------
|
||||
if (strTempFile != _T(""))
|
||||
if (!strTempFile.empty())
|
||||
{
|
||||
CDirectory::DeleteFile(strTempFile);
|
||||
}
|
||||
@ -455,7 +455,11 @@ namespace PPTX
|
||||
pFill->blip->oleRid = OOX::RId((size_t)oRelsGeneratorInfo.nOleRId).get();
|
||||
pFill->blip->oleFilepathBin = oRelsGeneratorInfo.sFilepathOle;
|
||||
}
|
||||
|
||||
if(oRelsGeneratorInfo.nMediaRId > 0)
|
||||
{
|
||||
pFill->blip->mediaRid = OOX::RId((size_t)oRelsGeneratorInfo.nMediaRId).get();
|
||||
pFill->blip->mediaFilepath = oRelsGeneratorInfo.sFilepathMedia;
|
||||
}
|
||||
pReader->Skip(1); // end attribute
|
||||
break;
|
||||
}
|
||||
|
||||
@ -107,16 +107,13 @@ namespace PPTX
|
||||
return Media->toXML();
|
||||
return _T("");
|
||||
}
|
||||
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
virtual void toPPTY(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
|
||||
{
|
||||
// TODO:
|
||||
if (Media.is_init())
|
||||
Media->toXmlWriter(pWriter);
|
||||
}
|
||||
@ -126,8 +123,7 @@ namespace PPTX
|
||||
template<class T> AVSINLINE const bool is() const { return Media.is<T>(); }
|
||||
template<class T> AVSINLINE T& as() { return Media.as<T>(); }
|
||||
template<class T> AVSINLINE const T& as() const { return Media.as<T>(); }
|
||||
//public:
|
||||
private:
|
||||
|
||||
smart_ptr<WrapperWritingElement> Media;
|
||||
protected:
|
||||
virtual void FillParentPointersForChilds(){};
|
||||
|
||||
@ -74,7 +74,7 @@ namespace PPTX
|
||||
}
|
||||
virtual void read(const OOX::CPath& filename, FileMap& map)
|
||||
{
|
||||
//FileContainer::read(filename, map);
|
||||
//FileContainer::read(filename);
|
||||
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNode.FromXmlFile(filename.m_strFilename);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="8,00"
|
||||
Name="PPTXFormat"
|
||||
ProjectGUID="{36636678-AE25-4BE6-9A34-2561D1BCF302}"
|
||||
RootNamespace="PPTXFormat"
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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")
|
||||
{
|
||||
|
||||
@ -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]);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -66,7 +66,14 @@ namespace OOX
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wmf"), _T("image/x-wmf")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("svm"), _T("image/svm")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wav"), _T("audio/wav")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xls"), _T("application/vnd.ms-excel")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wma"), _T("audio/x-wma")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("m4a"), _T("audio/unknown")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("mp3"), _T("audio/mpeg")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("mp4"), _T("video/unknown")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("mov"), _T("video/unknown")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("avi"), _T("video/avi")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("wmv"), _T("video/x-wmv")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xls"), _T("application/vnd.ms-excel")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xlsm"), _T("application/vnd.ms-excel.sheet.macroEnabled.12")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xlsb"), _T("application/vnd.ms-excel.sheet.binary.macroEnabled.12")));
|
||||
m_mTable.insert( std::pair<std::wstring,std::wstring>( _T("xlsx"), _T("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")));
|
||||
|
||||
@ -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"&"); break;
|
||||
case '\"': buffer.append(L"""); break;
|
||||
case '\'': buffer.append(L"'"); break;
|
||||
case '<': buffer.append(L"<"); break;
|
||||
case '>': buffer.append(L">"); break;
|
||||
case '\n': buffer.append(L"
"); break;
|
||||
case '\r': buffer.append(L"
"); break;
|
||||
case '\t': buffer.append(L"	"); break;
|
||||
case 160: buffer.append(L" "); 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"&"); break;
|
||||
case '\"': buffer.append(L"""); break;
|
||||
case '\'': buffer.append(L"'"); break;
|
||||
case '<': buffer.append(L"<"); break;
|
||||
case '>': buffer.append(L">"); break;
|
||||
case '\n': buffer.append(L"
"); break;
|
||||
case '\r': buffer.append(L"
"); break;
|
||||
case '\t': buffer.append(L"	"); break;
|
||||
case 160: buffer.append(L" "); break;
|
||||
case '\0':
|
||||
return buffer;
|
||||
default: buffer.append(&data[pos], 1); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
//#ifndef _USE_LIBXML2_READER_
|
||||
class CStringWriter
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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";
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,22 @@
|
||||
#define OOXML_HASH_ALG_SHA1 0
|
||||
#define OOXML_HASH_ALG_INVALID 1
|
||||
|
||||
class Q_DECL_EXPORT CCertificateInfo
|
||||
{
|
||||
public:
|
||||
std::wstring m_name;
|
||||
std::string m_date;
|
||||
std::string m_id;
|
||||
|
||||
public:
|
||||
CCertificateInfo()
|
||||
{
|
||||
}
|
||||
~CCertificateInfo()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class Q_DECL_EXPORT ICertificate
|
||||
{
|
||||
public:
|
||||
@ -26,6 +42,9 @@ public:
|
||||
virtual std::string GetCertificateBase64() = 0;
|
||||
virtual std::string GetCertificateHash() = 0;
|
||||
|
||||
virtual std::string GetDate() = 0;
|
||||
virtual std::string GetId() = 0;
|
||||
|
||||
public:
|
||||
virtual std::string Sign(const std::string& sXml) = 0;
|
||||
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg) = 0;
|
||||
@ -39,6 +58,18 @@ public:
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
|
||||
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();
|
||||
return info;
|
||||
}
|
||||
|
||||
public:
|
||||
static int GetOOXMLHashAlg(const std::string& sAlg);
|
||||
static ICertificate* CreateInstance();
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -174,10 +174,19 @@ 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) Check files (Manifect)
|
||||
// 2) Images
|
||||
XmlUtils::CXmlNode nodeImageValid = GetObjectById("idValidSigLnImg");
|
||||
if (nodeImageValid.IsValid())
|
||||
m_sImageValidBase64 = GetBase64Image(nodeImageValid);
|
||||
XmlUtils::CXmlNode nodeImageInvalid = GetObjectById("idInvalidSigLnImg");
|
||||
if (nodeImageInvalid.IsValid())
|
||||
m_sImageInvalidBase64 = GetBase64Image(nodeImageInvalid);
|
||||
|
||||
// 3) Check files (Manifect)
|
||||
XmlUtils::CXmlNode nodeManifect = GetObjectById("idPackageObject");
|
||||
if (!nodeManifect.IsValid())
|
||||
{
|
||||
@ -197,14 +206,6 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// 3) Images
|
||||
XmlUtils::CXmlNode nodeImageValid = GetObjectById("idValidSigLnImg");
|
||||
if (nodeImageValid.IsValid())
|
||||
m_sImageValidBase64 = GetBase64Image(nodeImageValid);
|
||||
XmlUtils::CXmlNode nodeImageInvalid = GetObjectById("idInvalidSigLnImg");
|
||||
if (nodeImageInvalid.IsValid())
|
||||
m_sImageInvalidBase64 = GetBase64Image(nodeImageInvalid);
|
||||
|
||||
// 4) Objects
|
||||
XmlUtils::CXmlNodes nodesReferences;
|
||||
m_node.ReadNode(L"SignedInfo").GetNodes(L"Reference", nodesReferences);
|
||||
@ -543,5 +544,7 @@ int COOXMLVerifier::GetSignatureCount()
|
||||
|
||||
COOXMLSignature* COOXMLVerifier::GetSignature(const int& index)
|
||||
{
|
||||
if (index >= (int)m_internal->m_arSignatures.size())
|
||||
return NULL;
|
||||
return m_internal->m_arSignatures[index];
|
||||
}
|
||||
|
||||
@ -26,3 +26,67 @@ ICertificate* ICertificate::CreateInstance()
|
||||
{
|
||||
return new CCertificate();
|
||||
}
|
||||
|
||||
CCertificateInfo ICertificate::GetDefault()
|
||||
{
|
||||
CCertificateInfo info;
|
||||
|
||||
// detect user name
|
||||
std::wstring sUserName;
|
||||
#ifdef WIN32
|
||||
DWORD dwUserNameLen = 1024;
|
||||
wchar_t* _name = new wchar_t[dwUserNameLen + 1];
|
||||
GetUserNameW(_name, &dwUserNameLen);
|
||||
sUserName = std::wstring(_name);
|
||||
delete []_name;
|
||||
#endif
|
||||
////////////////////
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE hStoreHandle = CertOpenSystemStoreA(NULL, "MY");
|
||||
if (!hStoreHandle)
|
||||
return info;
|
||||
|
||||
PCCERT_CONTEXT pCertContext = NULL;
|
||||
|
||||
while (pCertContext = CertEnumCertificatesInStore(hStoreHandle, pCertContext))
|
||||
{
|
||||
CCertificate_mscrypto _cert(pCertContext);
|
||||
if (sUserName == _cert.GetSignerName())
|
||||
{
|
||||
info = _cert.GetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
CertCloseStore(hStoreHandle, 0);
|
||||
#endif
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
ICertificate* ICertificate::GetById(const std::string& id)
|
||||
{
|
||||
#ifdef WIN32
|
||||
HANDLE hStoreHandle = CertOpenSystemStoreA(NULL, "MY");
|
||||
if (!hStoreHandle)
|
||||
return NULL;
|
||||
|
||||
PCCERT_CONTEXT pCertContext = NULL;
|
||||
|
||||
while (pCertContext = CertEnumCertificatesInStore(hStoreHandle, pCertContext))
|
||||
{
|
||||
CCertificate_mscrypto* _cert = new CCertificate_mscrypto(pCertContext);
|
||||
if (id == _cert->GetId())
|
||||
{
|
||||
_cert->m_release = true;
|
||||
return _cert;
|
||||
}
|
||||
|
||||
RELEASEOBJECT(_cert);
|
||||
}
|
||||
|
||||
CertCloseStore(hStoreHandle, 0);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ class CCertificate_mscrypto : public ICertificate
|
||||
public:
|
||||
HCERTSTORE m_store;
|
||||
PCCERT_CONTEXT m_context;
|
||||
bool m_release;
|
||||
|
||||
protected:
|
||||
BYTE* m_rawData;
|
||||
@ -29,6 +30,8 @@ public:
|
||||
|
||||
m_rawData = NULL;
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_release = false;
|
||||
}
|
||||
CCertificate_mscrypto(PCCERT_CONTEXT ctx) : ICertificate()
|
||||
{
|
||||
@ -37,11 +40,13 @@ public:
|
||||
|
||||
m_rawData = NULL;
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_release = false;
|
||||
}
|
||||
|
||||
virtual ~CCertificate_mscrypto()
|
||||
{
|
||||
if (m_store != NULL || m_rawData != NULL)
|
||||
if (m_store != NULL || m_rawData != NULL || m_release)
|
||||
{
|
||||
if (NULL != m_context)
|
||||
CertFreeCertificateContext(m_context);
|
||||
@ -99,6 +104,33 @@ public:
|
||||
return GetHash(m_context->pbCertEncoded, (unsigned int)m_context->cbCertEncoded, OOXML_HASH_ALG_SHA1);
|
||||
}
|
||||
|
||||
virtual std::string GetDate()
|
||||
{
|
||||
SYSTEMTIME t1;
|
||||
FileTimeToSystemTime(&m_context->pCertInfo->NotBefore, &t1);
|
||||
SYSTEMTIME t2;
|
||||
FileTimeToSystemTime(&m_context->pCertInfo->NotAfter, &t2);
|
||||
|
||||
std::string sRet = std::to_string(t1.wDay) +
|
||||
"/" +
|
||||
std::to_string(t1.wMonth) +
|
||||
"/" +
|
||||
std::to_string(t1.wYear) +
|
||||
" - " +
|
||||
std::to_string(t1.wDay) +
|
||||
"/" +
|
||||
std::to_string(t2.wMonth) +
|
||||
"/" +
|
||||
std::to_string(t2.wYear);
|
||||
return sRet;
|
||||
}
|
||||
|
||||
virtual std::string GetId()
|
||||
{
|
||||
// TODO: + public key?
|
||||
return GetNumber();
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
|
||||
@ -45,6 +45,16 @@ public:
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::string GetDate()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::string GetId()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
56
Makefile
56
Makefile
@ -18,6 +18,7 @@ else
|
||||
SHARED_EXT := .so*
|
||||
SHELL_EXT := .sh
|
||||
LIB_EXT := .a
|
||||
LIB_PREFIX := lib
|
||||
MAKE := make -j $(shell grep -c ^processor /proc/cpuinfo)
|
||||
endif
|
||||
UNAME_P := $(shell uname -p)
|
||||
@ -36,29 +37,30 @@ LIBDIR := build/lib/$(TARGET)
|
||||
ALLFONTSGEN := build/bin/AllFontsGen/$(TARGET)$(EXEC_EXT)
|
||||
X2T := build/bin/$(TARGET)/x2t$(EXEC_EXT)
|
||||
HTMLFILEINTERNAL := $(LIBDIR)/HtmlFileInternal$(EXEC_EXT)
|
||||
XLSFORMATLIB := $(LIBDIR)/libXlsFormatLib$(LIB_EXT)
|
||||
ODFFILEWRITERLIB := $(LIBDIR)/libOdfFileWriterLib$(LIB_EXT)
|
||||
ODFFILEREADERLIB := $(LIBDIR)/libOdfFileReaderLib$(LIB_EXT)
|
||||
DOCFORMATLIB := $(LIBDIR)/libDocFormatLib$(LIB_EXT)
|
||||
PPTFORMATLIB := $(LIBDIR)/libPptFormatLib$(LIB_EXT)
|
||||
RTFFORMATLIB := $(LIBDIR)/libRtfFormatLib$(LIB_EXT)
|
||||
TXTXMLFORMATLIB := $(LIBDIR)/libTxtXmlFormatLib$(LIB_EXT)
|
||||
PDFWRITER := $(LIBDIR)/libPdfWriter$(SHARED_EXT)
|
||||
ASCOFFICEDOCXFILE2LIB := $(LIBDIR)/libASCOfficeDocxFile2Lib$(LIB_EXT)
|
||||
PPTXFORMATLIB := $(LIBDIR)/libPPTXFormatLib$(LIB_EXT)
|
||||
DOCXFORMATLIB := $(LIBDIR)/libDocxFormatLib$(LIB_EXT)
|
||||
OFFICEUTILS := $(LIBDIR)/libOfficeUtils$(LIB_EXT)
|
||||
GRAPHICS := $(LIBDIR)/libgraphics$(LIB_EXT)
|
||||
DOCTRENDERER := $(LIBDIR)/libdoctrenderer$(SHARED_EXT)
|
||||
HTMLRENDERER := $(LIBDIR)/libHtmlRenderer$(SHARED_EXT)
|
||||
PDFREADER := $(LIBDIR)/libPdfReader$(SHARED_EXT)
|
||||
DJVUFILE := $(LIBDIR)/libDjVuFile$(SHARED_EXT)
|
||||
XPSFILE := $(LIBDIR)/libXpsFile$(SHARED_EXT)
|
||||
HTMLFILE := $(LIBDIR)/libHtmlFile$(SHARED_EXT)
|
||||
UNICODECONVERTER := $(LIBDIR)/libUnicodeConverter$(SHARED_EXT)
|
||||
ASCDOCUMENTSCORE := $(LIBDIR)/libascdocumentscore$(SHARED_EXT)
|
||||
LIBXML := $(LIBDIR)/liblibxml$(LIB_EXT)
|
||||
LICENSEMANAGER := $(LIBDIR)/libLicenceManager$(LIB_EXT)
|
||||
XLSFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)XlsFormatLib$(LIB_EXT)
|
||||
ODFFILEWRITERLIB := $(LIBDIR)/$(LIB_PREFIX)OdfFileWriterLib$(LIB_EXT)
|
||||
ODFFILEREADERLIB := $(LIBDIR)/$(LIB_PREFIX)OdfFileReaderLib$(LIB_EXT)
|
||||
DOCFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)DocFormatLib$(LIB_EXT)
|
||||
PPTFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)PptFormatLib$(LIB_EXT)
|
||||
RTFFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)RtfFormatLib$(LIB_EXT)
|
||||
TXTXMLFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)TxtXmlFormatLib$(LIB_EXT)
|
||||
PDFWRITER := $(LIBDIR)/$(LIB_PREFIX)PdfWriter$(SHARED_EXT)
|
||||
ASCOFFICEDOCXFILE2LIB := $(LIBDIR)/$(LIB_PREFIX)ASCOfficeDocxFile2Lib$(LIB_EXT)
|
||||
PPTXFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)PPTXFormatLib$(LIB_EXT)
|
||||
DOCXFORMATLIB := $(LIBDIR)/$(LIB_PREFIX)DocxFormatLib$(LIB_EXT)
|
||||
OFFICEUTILS := $(LIBDIR)/$(LIB_PREFIX)OfficeUtils$(LIB_EXT)
|
||||
GRAPHICS := $(LIBDIR)/$(LIB_PREFIX)graphics$(LIB_EXT)
|
||||
DOCTRENDERER := $(LIBDIR)/$(LIB_PREFIX)doctrenderer$(SHARED_EXT)
|
||||
HTMLRENDERER := $(LIBDIR)/$(LIB_PREFIX)HtmlRenderer$(SHARED_EXT)
|
||||
PDFREADER := $(LIBDIR)/$(LIB_PREFIX)PdfReader$(SHARED_EXT)
|
||||
DJVUFILE := $(LIBDIR)/$(LIB_PREFIX)DjVuFile$(SHARED_EXT)
|
||||
XPSFILE := $(LIBDIR)/$(LIB_PREFIX)XpsFile$(SHARED_EXT)
|
||||
HTMLFILE := $(LIBDIR)/$(LIB_PREFIX)HtmlFile$(SHARED_EXT)
|
||||
UNICODECONVERTER := $(LIBDIR)/$(LIB_PREFIX)UnicodeConverter$(SHARED_EXT)
|
||||
ASCDOCUMENTSCORE := $(LIBDIR)/$(LIB_PREFIX)ascdocumentscore$(SHARED_EXT)
|
||||
LIBXML := $(LIBDIR)/$(LIB_PREFIX)libxml$(LIB_EXT)
|
||||
LICENSEMANAGER := $(LIBDIR)/$(LIB_PREFIX)LicenceManager$(LIB_EXT)
|
||||
OOXMLSIGNATURE := $(LIBDIR)/$(LIB_PREFIX)ooxmlsignature$(LIB_EXT)
|
||||
|
||||
TARGETS += $(ALLFONTSGEN)
|
||||
TARGETS += $(X2T)
|
||||
@ -86,6 +88,7 @@ TARGETS += $(UNICODECONVERTER)
|
||||
TARGETS += $(ASCDOCUMENTSCORE)
|
||||
TARGETS += $(LIBXML)
|
||||
TARGETS += $(LICENSEMANAGER)
|
||||
TARGETS += $(OOXMLSIGNATURE)
|
||||
|
||||
X2T_PRO := $(abspath X2tConverter/build/Qt/X2tSLN.pro)
|
||||
HTMLFILEINTERNAL_PRO := $(abspath ../desktop-sdk/HtmlFile/Internal/Internal.pro)
|
||||
@ -113,6 +116,7 @@ UNICODECONVERTER_PRO := $(abspath UnicodeConverter/UnicodeConverter.pro)
|
||||
ASCDOCUMENTSCORE_PRO := $(abspath ../desktop-sdk/ChromiumBasedEditors/lib/AscDocumentsCore_$(PLATFORM).pro)
|
||||
LIBXML_PRO := $(abspath DesktopEditor/xml/build/qt/libxml2.pro)
|
||||
LICENSEMANAGER_PRO := $(abspath LicenceManager/linux/LicenseManager.pro)
|
||||
OOXMLSIGNATURE_PRO := $(abspath DesktopEditor/xmlsec/src/ooxmlsignature.pro)
|
||||
|
||||
# PROS += $(basename $(X2T_PRO)).build
|
||||
# PROS += ALLFONTSGEN_PRO
|
||||
@ -163,6 +167,7 @@ QT_PROJ += UNICODECONVERTER
|
||||
QT_PROJ += ASCDOCUMENTSCORE
|
||||
QT_PROJ += LIBXML
|
||||
QT_PROJ += LICENSEMANAGER
|
||||
QT_PROJ += OOXMLSIGNATURE
|
||||
|
||||
# X2T_DEP += $(XLSFORMATLIB)
|
||||
# X2T_DEP += $(ODFFILEWRITERLIB)
|
||||
@ -211,6 +216,9 @@ ASCDOCUMENTSCORE_DEP += $(DJVUFILE)
|
||||
ASCDOCUMENTSCORE_DEP += $(XPSFILE)
|
||||
#ASCDOCUMENTSCORE_DEP += $(LICENSEMANAGER)
|
||||
ASCDOCUMENTSCORE_DEP += $(LIBXML)
|
||||
ASCDOCUMENTSCORE_DEP += $(OOXMLSIGNATURE)
|
||||
|
||||
OOXMLSIGNATURE_DEP += $(LIBXML)
|
||||
|
||||
PDFREADER_DEP += $(HTMLRENDERER)
|
||||
|
||||
@ -262,6 +270,8 @@ $(PDFREADER): $(PDFREADER_DEP)
|
||||
|
||||
$(PDFWRITER): $(PDFWRITER_DEP)
|
||||
|
||||
$(OOXMLSIGNATURE): $(OOXMLSIGNATURE_DEP)
|
||||
|
||||
%.build/Makefile: %.pro
|
||||
mkdir -p $(dir $@) && cd $(dir $@) && qmake -r $<
|
||||
|
||||
|
||||
@ -12,9 +12,11 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
std::wstring password = L"password";
|
||||
|
||||
ECMACryptFile crypt_file;
|
||||
crypt_file.DecryptOfficeFile(srcFileName, dstFileName, password);
|
||||
bool result, bDataIntegrity;
|
||||
|
||||
result = crypt_file.DecryptOfficeFile(srcFileName, dstFileName, password, bDataIntegrity);
|
||||
|
||||
crypt_file.EncryptOfficeFile(dstFileName, dstFileName2, password);
|
||||
result = crypt_file.EncryptOfficeFile(dstFileName, dstFileName2, password);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -177,34 +177,40 @@ void CorrectHashSize(_buf & hashBuf, int size, unsigned char padding)
|
||||
}
|
||||
_buf Hmac(_buf & buf, CRYPT_METHOD::_hashAlgorithm algorithm, std::string & plain)
|
||||
{
|
||||
std::string mac;
|
||||
if (algorithm == CRYPT_METHOD::SHA1)
|
||||
{
|
||||
CryptoPP::HMAC<CryptoPP::SHA1> hmac(buf.ptr, buf.size);
|
||||
|
||||
//return _buf(mac.BytePtr(), mac.SizeInBytes());
|
||||
}
|
||||
else if (algorithm == CRYPT_METHOD::SHA256)
|
||||
{
|
||||
CryptoPP::HMAC<CryptoPP::SHA256> hmac(buf.ptr, buf.size);
|
||||
|
||||
//return _buf(mac.BytePtr(), mac.SizeInBytes());
|
||||
}
|
||||
else if (algorithm == CRYPT_METHOD::SHA512)
|
||||
{
|
||||
CryptoPP::HMAC<CryptoPP::SHA512> hmac(buf.ptr, buf.size);
|
||||
|
||||
std::string mac;
|
||||
CryptoPP::StringSource(plain, true,
|
||||
new CryptoPP::HashFilter(hmac,
|
||||
new CryptoPP::StringSink(mac)
|
||||
) // HashFilter
|
||||
); // StringSource
|
||||
|
||||
return _buf(mac);
|
||||
}
|
||||
else if (algorithm == CRYPT_METHOD::SHA256)
|
||||
{
|
||||
CryptoPP::HMAC<CryptoPP::SHA256> hmac(buf.ptr, buf.size);
|
||||
CryptoPP::StringSource(plain, true,
|
||||
new CryptoPP::HashFilter(hmac,
|
||||
new CryptoPP::StringSink(mac)
|
||||
) // HashFilter
|
||||
); // StringSource
|
||||
|
||||
}
|
||||
//else
|
||||
return _buf();
|
||||
else if (algorithm == CRYPT_METHOD::SHA512)
|
||||
{
|
||||
CryptoPP::HMAC<CryptoPP::SHA512> hmac(buf.ptr, buf.size);
|
||||
|
||||
CryptoPP::StringSource(plain, true,
|
||||
new CryptoPP::HashFilter(hmac,
|
||||
new CryptoPP::StringSink(mac)
|
||||
) // HashFilter
|
||||
); // StringSource
|
||||
|
||||
}
|
||||
|
||||
return _buf(mac);
|
||||
}
|
||||
|
||||
|
||||
@ -488,8 +494,10 @@ void ECMADecryptor::Decrypt(char* data , const size_t size, const unsigned long
|
||||
}
|
||||
}
|
||||
}
|
||||
bool ECMADecryptor::IsDataIntegrity(unsigned char* data, int size)
|
||||
bool ECMADecryptor::CheckDataIntegrity(unsigned char* data, int size)
|
||||
{
|
||||
if (cryptData.bAgile == false) return true;
|
||||
|
||||
_buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8);
|
||||
_buf pBlockHmacKey ((unsigned char*)encrDataIntegritySaltBlockKey, 8);
|
||||
_buf pBlockHmacValue((unsigned char*)encrDataIntegrityHmacValueBlockKey, 8);
|
||||
@ -514,15 +522,15 @@ bool ECMADecryptor::IsDataIntegrity(unsigned char* data, int size)
|
||||
_buf iv2 = HashAppend(pDataSalt, pBlockHmacValue, cryptData.hashAlgorithm);
|
||||
CorrectHashSize(iv2, cryptData.blockSize, 0x36);
|
||||
|
||||
_buf salt;
|
||||
DecryptCipher(secretKey, iv1, pEncHmacKey, salt, cryptData.cipherAlgorithm);
|
||||
_buf pSaltHmac;
|
||||
DecryptCipher(secretKey, iv1, pEncHmacKey, pSaltHmac, cryptData.cipherAlgorithm);
|
||||
|
||||
_buf expected;
|
||||
DecryptCipher(secretKey, iv2, pEncHmacValue, expected, cryptData.cipherAlgorithm);
|
||||
|
||||
std::string sData((char*)data, size);
|
||||
_buf hmac = Hmac(salt, cryptData.hashAlgorithm, sData);
|
||||
|
||||
_buf hmac = Hmac(pSaltHmac, cryptData.hashAlgorithm, sData);
|
||||
|
||||
return (hmac == expected);
|
||||
}
|
||||
void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned char*& data_out)
|
||||
@ -540,8 +548,6 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch
|
||||
|
||||
if (cryptData.bAgile)
|
||||
{
|
||||
bool isDataIntegrity = IsDataIntegrity(data_ptr, data_size);
|
||||
|
||||
_buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8);
|
||||
_buf pDataSalt (cryptData.dataSaltValue);
|
||||
_buf pKeyValue (cryptData.encryptedKeyValue);
|
||||
@ -603,6 +609,7 @@ void ECMADecryptor::Decrypt(unsigned char* data_ptr, int data_size, unsigned ch
|
||||
DecryptCipher(hashKey, empty, pInp, pOut, cryptData.cipherAlgorithm);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
ECMAEncryptor::ECMAEncryptor()
|
||||
{
|
||||
@ -611,6 +618,65 @@ ECMAEncryptor::ECMAEncryptor()
|
||||
void ECMAEncryptor::SetPassword(std::wstring _password)
|
||||
{
|
||||
password = _password;
|
||||
|
||||
//---------
|
||||
CryptoPP::RandomPool prng;
|
||||
|
||||
//сгенерить соль
|
||||
CryptoPP::SecByteBlock seed_salt(cryptData.saltSize);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, seed_salt, seed_salt.size());
|
||||
prng.IncorporateEntropy(seed_salt, seed_salt.size());
|
||||
|
||||
CryptoPP::SecByteBlock seed_datasalt(cryptData.saltSize);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, seed_datasalt, seed_datasalt.size());
|
||||
prng.IncorporateEntropy(seed_datasalt, seed_datasalt.size());
|
||||
|
||||
//сгенерить ключ
|
||||
CryptoPP::SecByteBlock seed_key(cryptData.keySize);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, seed_key, seed_key.size());
|
||||
prng.IncorporateEntropy(seed_key, seed_key.size());
|
||||
|
||||
//сгенерить проверочный
|
||||
CryptoPP::SecByteBlock seed_verify(cryptData.saltSize);
|
||||
CryptoPP::OS_GenerateRandomBlock(false, seed_verify, seed_verify.size());
|
||||
prng.IncorporateEntropy(seed_verify, seed_verify.size());
|
||||
//---------
|
||||
_buf pPassword (password);
|
||||
_buf empty (NULL, 0, false);
|
||||
|
||||
_buf pBlockKey ((unsigned char*)encrKeyValueBlockKey, 8);
|
||||
_buf pInputBlockKey ((unsigned char*)encrVerifierHashInputBlockKey, 8);
|
||||
_buf pValueBlockKey ((unsigned char*)encrVerifierHashValueBlockKey, 8);
|
||||
|
||||
_buf pSalt (seed_salt.m_ptr, seed_salt.m_size);
|
||||
_buf pDataSalt (seed_datasalt.m_ptr, seed_datasalt.m_size);
|
||||
_buf pDecryptedKey (seed_key.m_ptr, seed_key.m_size);
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
_buf agileKey = GenerateAgileKey( pSalt, pPassword, pBlockKey, cryptData.keySize, cryptData.spinCount, cryptData.hashAlgorithm);
|
||||
|
||||
_buf pKeyValue;
|
||||
EncryptCipher( agileKey, pSalt, pDecryptedKey, pKeyValue, cryptData.cipherAlgorithm);
|
||||
|
||||
//--------------------------------------------
|
||||
_buf decryptedVerifierHashInputBytes(seed_verify.m_ptr, seed_verify.m_size);
|
||||
_buf verifierInputKey = GenerateAgileKey( pSalt, pPassword, pInputBlockKey, cryptData.keySize, cryptData.spinCount, cryptData.hashAlgorithm );
|
||||
|
||||
_buf pEncVerInput;
|
||||
EncryptCipher( verifierInputKey, pSalt, decryptedVerifierHashInputBytes, pEncVerInput, cryptData.cipherAlgorithm);
|
||||
//--------------------------------------------
|
||||
|
||||
_buf decryptedVerifierHashBytes = HashAppend(decryptedVerifierHashInputBytes, empty, cryptData.hashAlgorithm);
|
||||
_buf verifierHashKey = GenerateAgileKey(pSalt, pPassword, pValueBlockKey, cryptData.keySize, cryptData.spinCount, cryptData.hashAlgorithm);
|
||||
|
||||
_buf pEncVerValue;
|
||||
EncryptCipher( verifierHashKey, pSalt, decryptedVerifierHashBytes, pEncVerValue, cryptData.cipherAlgorithm);
|
||||
|
||||
cryptData.saltValue = std::string((char*)pSalt.ptr, pSalt.size);
|
||||
cryptData.dataSaltValue = std::string((char*)pDataSalt.ptr, pDataSalt.size);
|
||||
cryptData.encryptedKeyValue = std::string((char*)pKeyValue.ptr, pKeyValue.size);
|
||||
cryptData.encryptedVerifierInput = std::string((char*)pEncVerInput.ptr, pEncVerInput.size);
|
||||
cryptData.encryptedVerifierValue = std::string((char*)pEncVerValue.ptr, pEncVerValue.size);
|
||||
}
|
||||
|
||||
void ECMAEncryptor::SetCryptData(_ecmaCryptData & data)
|
||||
@ -622,6 +688,7 @@ void ECMAEncryptor::GetCryptData(_ecmaCryptData &data)
|
||||
{
|
||||
data = cryptData;
|
||||
}
|
||||
|
||||
void ECMAEncryptor::UpdateDataIntegrity(unsigned char* data, int size)
|
||||
{
|
||||
if (cryptData.bAgile == false) return;
|
||||
@ -636,31 +703,41 @@ void ECMAEncryptor::UpdateDataIntegrity(unsigned char* data, int size)
|
||||
|
||||
_buf pDataSalt (cryptData.dataSaltValue);
|
||||
_buf pKeyValue (cryptData.encryptedKeyValue);
|
||||
_buf pEncHmacKey (cryptData.encryptedHmacKey);
|
||||
_buf pEncHmacValue (cryptData.encryptedHmacValue);
|
||||
|
||||
|
||||
//----
|
||||
_buf agileKey = GenerateAgileKey( pSalt, pPassword, pBlockKey, cryptData.keySize, cryptData.spinCount, cryptData.hashAlgorithm);
|
||||
|
||||
_buf secretKey;
|
||||
DecryptCipher( agileKey, pSalt, pKeyValue, secretKey, cryptData.cipherAlgorithm);
|
||||
//----
|
||||
|
||||
_buf iv1 = HashAppend(pDataSalt, pBlockHmacKey, cryptData.hashAlgorithm);
|
||||
CorrectHashSize(iv1, cryptData.blockSize, 0x36);
|
||||
|
||||
_buf iv2 = HashAppend(pDataSalt, pBlockHmacValue, cryptData.hashAlgorithm);
|
||||
CorrectHashSize(iv2, cryptData.blockSize, 0x36);
|
||||
|
||||
_buf salt;
|
||||
DecryptCipher(secretKey, iv1, pEncHmacKey, salt, cryptData.cipherAlgorithm);
|
||||
//----
|
||||
CryptoPP::RandomPool prng;
|
||||
CryptoPP::SecByteBlock seed(cryptData.hashSize);
|
||||
|
||||
CryptoPP::OS_GenerateRandomBlock(false, seed, seed.size());
|
||||
prng.IncorporateEntropy(seed, seed.size());
|
||||
|
||||
_buf expected;
|
||||
DecryptCipher(secretKey, iv2, pEncHmacValue, expected, cryptData.cipherAlgorithm);
|
||||
_buf pSaltHmac(seed.m_ptr, seed.m_size);
|
||||
|
||||
std::string sData((char*)data, size);
|
||||
_buf hmac = Hmac(salt, cryptData.hashAlgorithm, sData);
|
||||
|
||||
//return (hmac == expected);
|
||||
_buf hmac = Hmac(pSaltHmac, cryptData.hashAlgorithm, sData);
|
||||
|
||||
_buf pEncHmacKey;
|
||||
EncryptCipher(secretKey, iv1, pSaltHmac, pEncHmacKey, cryptData.cipherAlgorithm);
|
||||
|
||||
_buf pEncHmacValue;
|
||||
EncryptCipher(secretKey, iv2, hmac, pEncHmacValue, cryptData.cipherAlgorithm);
|
||||
|
||||
cryptData.encryptedHmacKey = std::string((char*)pEncHmacKey.ptr, pEncHmacKey.size);
|
||||
cryptData.encryptedHmacValue = std::string((char*)pEncHmacValue.ptr, pEncHmacValue.size);
|
||||
}
|
||||
|
||||
int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*& data_out_ptr)
|
||||
{
|
||||
data_out_ptr = NULL;
|
||||
@ -686,19 +763,17 @@ int ECMAEncryptor::Encrypt(unsigned char* data_inp_ptr, int size, unsigned char*
|
||||
_buf pKeyValue (cryptData.encryptedKeyValue);
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//соль нужно сгенерить
|
||||
|
||||
_buf agileKey = GenerateAgileKey( pSalt, pPassword, pBlockKey, cryptData.keySize, cryptData.spinCount, cryptData.hashAlgorithm);
|
||||
|
||||
//тут нужно именно дешифрованый генерить - пока их файла берем
|
||||
_buf pDecryptedKey;
|
||||
DecryptCipher( agileKey, pSalt, pKeyValue, pDecryptedKey, cryptData.cipherAlgorithm);
|
||||
|
||||
//зашифровать ключь
|
||||
_buf pEncryptedKey;
|
||||
EncryptCipher( agileKey, pSalt, pDecryptedKey, pEncryptedKey, cryptData.cipherAlgorithm);
|
||||
////зашифровать ключь
|
||||
//_buf pEncryptedKey;
|
||||
//EncryptCipher( agileKey, pSalt, pDecryptedKey, pEncryptedKey, cryptData.cipherAlgorithm);
|
||||
|
||||
//??? pEncryptedKey == pKeyValue;
|
||||
////??? pEncryptedKey == pKeyValue;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
_buf iv(cryptData.blockSize);
|
||||
|
||||
@ -133,11 +133,12 @@ public:
|
||||
virtual bool SetPassword (std::wstring password);
|
||||
virtual bool IsVerify();
|
||||
|
||||
bool CheckDataIntegrity(unsigned char* data, int size);
|
||||
|
||||
void SetCryptData(_ecmaCryptData &data);
|
||||
|
||||
private:
|
||||
bool IsDataIntegrity(unsigned char* data, int size);
|
||||
|
||||
|
||||
std::wstring password;
|
||||
_ecmaCryptData cryptData;
|
||||
bool bVerify;
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
#include "../../ASCOfficeDocFile/DocDocxConverter/MemoryStream.h"
|
||||
#include "simple_xml_writer.h"
|
||||
|
||||
CRYPT::_ecmaCryptData cryptDataGlobal;
|
||||
//CRYPT::_ecmaCryptData cryptDataGlobal; for Test
|
||||
|
||||
using namespace CRYPT;
|
||||
|
||||
@ -489,19 +489,19 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
|
||||
_ecmaCryptData cryptData;
|
||||
|
||||
cryptData.bAgile = true;
|
||||
cryptData.hashAlgorithm = CRYPT_METHOD::SHA256;
|
||||
cryptData.hashAlgorithm = CRYPT_METHOD::SHA512;
|
||||
cryptData.keySize = 0x20;
|
||||
cryptData.hashSize = 0x40;
|
||||
cryptData.blockSize = 0x10;
|
||||
cryptData.saltSize = 0x10;
|
||||
|
||||
ECMAEncryptor cryptor;
|
||||
|
||||
//cryptor.SetCryptData(cryptDataGlobal); //for test !!!
|
||||
cryptor.SetCryptData(cryptData); //basic settings
|
||||
|
||||
cryptor.SetPassword(password);
|
||||
|
||||
cryptor.SetCryptData(cryptDataGlobal); //for test !!!
|
||||
//cryptor.SetCryptData(cryptData); //basic settings
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.OpenFile(file_name_inp)) return false;
|
||||
|
||||
@ -575,6 +575,9 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
|
||||
{
|
||||
unsigned char* data_out2 = NULL;
|
||||
decryptor.Decrypt(data_out, lengthData, data_out2);
|
||||
|
||||
bool bDataIntegrity = decryptor.CheckDataIntegrity(data_out, lengthData);
|
||||
|
||||
NSFile::CFileBinary test;
|
||||
|
||||
test.CreateFileW(file_name_out + L"-back.oox");
|
||||
@ -586,8 +589,10 @@ bool ECMACryptFile::EncryptOfficeFile(std::wstring file_name_inp, std::wstring f
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password)
|
||||
bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password, bool & bDataIntegrity)
|
||||
{
|
||||
bDataIntegrity = false;
|
||||
|
||||
POLE::Storage *pStorage = new POLE::Storage(file_name_inp.c_str());
|
||||
|
||||
if (!pStorage)return false;
|
||||
@ -597,45 +602,10 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
|
||||
delete pStorage;
|
||||
return false;
|
||||
}
|
||||
_ecmaCryptData cryptData;
|
||||
//-------------------------------------------------------------------------------------------
|
||||
_ecmaCryptData cryptData;
|
||||
bool result = false;
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//{
|
||||
// std::wstring f = file_name_out + L"-1.docx";
|
||||
// POLE::Storage *pStorage1 = new POLE::Storage(f.c_str());
|
||||
// pStorage1->open(true, true);
|
||||
|
||||
// POLE::Stream *pStrIn = new POLE::Stream(pStorage, "EncryptionInfo");
|
||||
// POLE::uint64 sz = pStrIn->size();
|
||||
// POLE::Stream *pStrOut = new POLE::Stream(pStorage1, "EncryptionInfo", true, sz);
|
||||
|
||||
// BYTE *d = new BYTE [sz];
|
||||
// pStrIn->read(d, sz);
|
||||
// pStrOut->write(d, sz);
|
||||
// delete d;
|
||||
|
||||
// pStrOut->flush();
|
||||
// delete pStrOut;
|
||||
// delete pStrIn;
|
||||
|
||||
// pStrIn = new POLE::Stream(pStorage, "EncryptedPackage");
|
||||
// sz = pStrIn->size();
|
||||
// pStrOut = new POLE::Stream(pStorage1, "EncryptedPackage", true, sz);
|
||||
|
||||
// d = new BYTE [sz];
|
||||
// pStrIn->read(d, sz);
|
||||
// pStrOut->write(d, sz);
|
||||
// delete d;
|
||||
|
||||
// pStrOut->flush();
|
||||
// delete pStrOut;
|
||||
// delete pStrIn;
|
||||
|
||||
// pStorage1->close();
|
||||
// delete pStorage1;
|
||||
//}
|
||||
//----------------------------------------------------------------------------
|
||||
POLE::Stream *pStream = new POLE::Stream(pStorage, "EncryptionInfo");
|
||||
|
||||
if (pStream)
|
||||
@ -747,8 +717,6 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
|
||||
lengthData = *((_UINT64*)data);
|
||||
|
||||
decryptor.Decrypt(data, readTrue, data_out);//todoo сделать покусочное чтение декриптование
|
||||
delete pStream;
|
||||
delete []data;
|
||||
|
||||
if (data_out)
|
||||
{
|
||||
@ -760,11 +728,16 @@ bool ECMACryptFile::DecryptOfficeFile(std::wstring file_name_inp, std::wstring f
|
||||
delete []data_out;
|
||||
result = true;
|
||||
}
|
||||
|
||||
bDataIntegrity = decryptor.CheckDataIntegrity(data, readTrue);
|
||||
|
||||
delete pStream;
|
||||
delete []data;
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
delete pStorage;
|
||||
|
||||
cryptDataGlobal = cryptData;
|
||||
//cryptDataGlobal = cryptData; // for encrypt like sample & test
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
class ECMACryptFile
|
||||
{
|
||||
public:
|
||||
bool DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password);
|
||||
bool DecryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password, bool & bDataIntegrity);
|
||||
bool EncryptOfficeFile(std::wstring file_name_inp, std::wstring file_name_out, std::wstring password);
|
||||
|
||||
struct _refComponent
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 2.4.460.0
|
||||
VERSION = 2.4.463.0
|
||||
DEFINES += INTVER=$$VERSION
|
||||
|
||||
TARGET = x2t
|
||||
|
||||
@ -1457,14 +1457,21 @@ namespace NExtractTools
|
||||
int mscrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring password = params.getPassword();
|
||||
//decrypt to sTo
|
||||
|
||||
ECMACryptFile cryptReader;
|
||||
if (cryptReader.DecryptOfficeFile(sFrom, sTo, password) == false)
|
||||
bool bDataIntegrity = false;
|
||||
|
||||
if (cryptReader.DecryptOfficeFile(sFrom, sTo, password, bDataIntegrity) == false)
|
||||
{
|
||||
if (password.empty()) return AVS_FILEUTILS_ERROR_CONVERT_DRM;
|
||||
else return AVS_FILEUTILS_ERROR_CONVERT_PASSWORD;
|
||||
}
|
||||
|
||||
if (bDataIntegrity == false)
|
||||
{
|
||||
//было несанкционированое вешательство в файл
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
int mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
@ -1473,9 +1480,16 @@ namespace NExtractTools
|
||||
std::wstring sResultDecryptFile = sTemp + FILE_SEPARATOR_STR + L"uncrypt_file.oox";
|
||||
|
||||
ECMACryptFile cryptReader;
|
||||
if (cryptReader.DecryptOfficeFile(sFrom, sResultDecryptFile, params.getPassword()) == false)
|
||||
bool bDataIntegrity = false;
|
||||
|
||||
if (cryptReader.DecryptOfficeFile(sFrom, sResultDecryptFile, params.getPassword(), bDataIntegrity) == false)
|
||||
return AVS_FILEUTILS_ERROR_CONVERT_PASSWORD;
|
||||
|
||||
if (bDataIntegrity == false)
|
||||
{
|
||||
//было несанкционированое вешательство в файл
|
||||
}
|
||||
|
||||
COfficeFileFormatChecker OfficeFileFormatChecker;
|
||||
|
||||
if (OfficeFileFormatChecker.isOfficeFile(sResultDecryptFile))
|
||||
@ -1500,6 +1514,19 @@ namespace NExtractTools
|
||||
}
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
int oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring password = params.getPassword();
|
||||
|
||||
ECMACryptFile cryptReader;
|
||||
|
||||
if (cryptReader.EncryptOfficeFile(sFrom, sTo, password) == false)
|
||||
{
|
||||
return AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
int fromMscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params)
|
||||
{
|
||||
std::wstring password = params.getPassword();
|
||||
@ -1556,7 +1583,7 @@ namespace NExtractTools
|
||||
}
|
||||
return nRes;
|
||||
}
|
||||
//html
|
||||
//html
|
||||
int html2doct_dir (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
|
||||
{
|
||||
std::vector<std::wstring> arFiles;
|
||||
|
||||
@ -128,6 +128,8 @@ namespace NExtractTools
|
||||
int mscrypt2oox (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
int mscrypt2oot (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
int mscrypt2oot_bin (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
|
||||
int oox2mscrypt (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring & sTemp, InputParams& params);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
int dir2zip (const std::wstring &sFrom, const std::wstring &sTo);
|
||||
|
||||
@ -487,7 +487,11 @@ namespace NExtractTools
|
||||
}
|
||||
else if(_T("m_nCsvDelimiterChar") == sName)
|
||||
{
|
||||
m_sCsvDelimiterChar = new std::wstring(L"");
|
||||
std::wstring sNil;
|
||||
if (!oXmlNode.GetAttributeIfExist(L"xsi:nil", sNil))
|
||||
{
|
||||
m_sCsvDelimiterChar = new std::wstring(L"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -540,7 +544,7 @@ namespace NExtractTools
|
||||
}
|
||||
sRes = L"<xmlOptions><fileOptions fileType='" + std::to_wstring(nFileType);
|
||||
sRes += L"' codePage='" + std::to_wstring(nCsvEncoding);
|
||||
sRes += L"' delimiter='" + XmlUtils::EncodeXmlString(cDelimiter) + L"' " + sSaveType;
|
||||
sRes += L"' delimiter='" + XmlUtils::EncodeXmlStringExtend(cDelimiter) + L"' " + sSaveType;
|
||||
sRes += L"/><TXTOptions><Encoding>" + std::to_wstring(nCsvEncoding) + L"</Encoding></TXTOptions></xmlOptions>";
|
||||
|
||||
return sRes;
|
||||
|
||||
Reference in New Issue
Block a user