mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0295ef2d54 | |||
| 797b745b35 | |||
| 37c276b736 | |||
| 41ea42459a | |||
| bc68323506 | |||
| 5a8c9069be | |||
| ae90e4ae96 | |||
| 6fae9115ea | |||
| b952692225 | |||
| 867b0634f3 | |||
| dde6b8bdc7 | |||
| b66bb0d63f | |||
| d666da2697 | |||
| 97ff1efba8 | |||
| 50ff5fc0b2 | |||
| 1c2b86519e | |||
| 323d1b44cd | |||
| 83fa44edcd | |||
| 2ead42a513 | |||
| 427046cb8f | |||
| e60cc05b6e | |||
| 8cd55fb9c4 | |||
| 01b9309f09 | |||
| d3a4f00f76 | |||
| a7d2191649 | |||
| 14fa14de3f | |||
| cced8f4912 | |||
| a52a8e982e | |||
| 6afa54ebef | |||
| 27a0e77ef1 | |||
| 76b682063e | |||
| effdab1ff4 | |||
| 48aa99af83 | |||
| 00e9ce56df | |||
| 261e48227d | |||
| 29e3f90ebf | |||
| b9b843f25d | |||
| d7e2bedc6b | |||
| 58cd45f4ee | |||
| 33f7ee49df | |||
| 95a49140cb | |||
| aad12cf471 | |||
| f0ffb7f14c | |||
| 4c8bc2227a |
7
.gitignore
vendored
7
.gitignore
vendored
@ -13,6 +13,11 @@ Common/3dParty/cef/win_32
|
||||
Common/3dParty/cef/linux_64
|
||||
Common/3dParty/cef/linux_32
|
||||
Common/3dParty/cef/mac_64
|
||||
Common/3dParty/curl/win_64
|
||||
Common/3dParty/curl/win_32
|
||||
Common/3dParty/curl/linux_64
|
||||
Common/3dParty/curl/linux_32
|
||||
Common/3dParty/curl/mac_64
|
||||
Common/3dParty/v8/v8
|
||||
Common/3dParty/v8/depot_tools
|
||||
Common/3dParty/v8/win_64
|
||||
@ -40,6 +45,8 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_i.c
|
||||
ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c
|
||||
ASCOfficeXlsFile2/win32/dlldata.c
|
||||
OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
|
||||
X2tConverter/**/Makefile.*
|
||||
*.7z
|
||||
*.obj
|
||||
*.pdb
|
||||
*.tlb
|
||||
|
||||
@ -58,6 +58,9 @@
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
|
||||
#define GETBIT(from, num) ((from & (1 << num)) != 0)
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
typedef unsigned char Bool8;
|
||||
|
||||
@ -72,10 +72,14 @@ namespace DocFileFormat
|
||||
{
|
||||
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
|
||||
|
||||
unsigned short index_author = atrdPre10->GetAuthorIndex();
|
||||
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
|
||||
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
|
||||
m_pXmlWriter->WriteAttribute( L"w:author",
|
||||
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->GetAuthorIndex() ) ));
|
||||
if (index_author < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
|
||||
{
|
||||
m_pXmlWriter->WriteAttribute( L"w:author",
|
||||
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( index_author ) ));
|
||||
}
|
||||
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());
|
||||
|
||||
//!!!TODO!!!
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
namespace Writers
|
||||
{
|
||||
static std::wstring g_string_set_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><w:settings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">");
|
||||
static std::wstring g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"14\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
|
||||
static std::wstring g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"15\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
|
||||
static std::wstring g_string_set_End = _T("</w:settings>");
|
||||
|
||||
class SettingWriter
|
||||
|
||||
@ -39,10 +39,9 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
/**/
|
||||
|
||||
docx_table_state::docx_table_state(docx_conversion_context & Context,
|
||||
const std::wstring & StyleName) : context_(Context),
|
||||
docx_table_state::docx_table_state(docx_conversion_context & Context, const std::wstring & StyleName) :
|
||||
context_(Context),
|
||||
table_style_(StyleName),
|
||||
current_table_column_(-1),
|
||||
columns_spanned_num_(0),
|
||||
@ -93,6 +92,19 @@ std::wstring docx_table_state::current_row_style() const
|
||||
return L"";
|
||||
}
|
||||
|
||||
double docx_table_state::get_current_cell_width()
|
||||
{
|
||||
if (current_table_column_ < columns_width_.size())
|
||||
return columns_width_[current_table_column_];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void docx_table_state::add_column_width(double width)
|
||||
{
|
||||
columns_width_.push_back(width);
|
||||
}
|
||||
|
||||
void docx_table_state::start_cell()
|
||||
{
|
||||
current_table_column_++;
|
||||
@ -102,7 +114,6 @@ void docx_table_state::start_cell()
|
||||
|
||||
void docx_table_state::end_cell()
|
||||
{}
|
||||
|
||||
bool docx_table_state::start_covered_cell(docx_conversion_context & Context)
|
||||
{
|
||||
std::wostream & _Wostream = context_.output_stream();
|
||||
|
||||
@ -70,6 +70,8 @@ public:
|
||||
void set_rows_spanned(unsigned int Column, unsigned int Val, unsigned int ColumnsSpanned, const std::wstring & Style);
|
||||
unsigned int current_rows_spanned(unsigned int Column) const;
|
||||
|
||||
double get_current_cell_width();
|
||||
void add_column_width(double width);
|
||||
private:
|
||||
docx_conversion_context & context_;
|
||||
std::wstring table_style_;
|
||||
@ -81,7 +83,8 @@ private:
|
||||
std::vector<table_row_spanned> rows_spanned_;
|
||||
bool close_table_covered_cell_;
|
||||
std::vector<unsigned int> columns_;
|
||||
std::vector<std::wstring> columnsDefaultCellStyleName_;
|
||||
std::vector<double> columns_width_;
|
||||
std::vector<std::wstring> columnsDefaultCellStyleName_;
|
||||
|
||||
};
|
||||
|
||||
@ -135,6 +138,14 @@ public:
|
||||
{
|
||||
return table_states_.back().start_cell();
|
||||
}
|
||||
double get_current_cell_width()
|
||||
{
|
||||
return table_states_.back().get_current_cell_width();
|
||||
}
|
||||
void add_column_width(double width)
|
||||
{
|
||||
table_states_.back().add_column_width(width);
|
||||
}
|
||||
|
||||
void end_cell()
|
||||
{
|
||||
|
||||
@ -184,7 +184,7 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -226,7 +226,7 @@ void oox_line_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -259,7 +259,7 @@ void oox_area_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -289,7 +289,7 @@ void oox_bubble_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
//CP_XML_NODE(L"c:bubbleScale")
|
||||
@ -326,7 +326,7 @@ void oox_doughnut_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -366,7 +366,7 @@ void oox_pie_chart::oox_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
}
|
||||
@ -398,7 +398,7 @@ void oox_radar_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
@ -436,7 +436,7 @@ void oox_scatter_chart::oox_serialize(std::wostream & _Wostream)
|
||||
}
|
||||
CP_XML_NODE(L"c:varyColors")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
CP_XML_ATTR(L"val", varyColors_ ? L"1" : L"0");
|
||||
}
|
||||
oox_serialize_common(CP_XML_STREAM());
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ public:
|
||||
is3D_ = false;
|
||||
type_ = 0;
|
||||
dispBlanksAs_ = L"zero";
|
||||
varyColors_ = true;
|
||||
}
|
||||
~oox_chart(){}
|
||||
|
||||
@ -99,6 +100,7 @@ public:
|
||||
|
||||
int type_;
|
||||
bool is3D_;
|
||||
bool varyColors_;
|
||||
std::wstring dispBlanksAs_;
|
||||
std::vector<int> axisId_; // axId (Axis ID) §21.2.2.9
|
||||
std::wstring grouping_; // clustered | percentStacked | stacked | standard
|
||||
|
||||
@ -382,6 +382,11 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
|
||||
if (!current) continue;
|
||||
|
||||
if (1 == series_.size())
|
||||
{
|
||||
current->varyColors_ = false;
|
||||
}
|
||||
|
||||
current->set_properties(plot_area_.properties_);
|
||||
current->set_additional_properties(chart_graphic_properties_);
|
||||
|
||||
@ -420,7 +425,8 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
formatCode = *strVal;
|
||||
}
|
||||
|
||||
if (domain_cell_range_adress_.empty() == false)
|
||||
if (domain_cell_range_adress_.empty() == false ||
|
||||
last_set_type == chart_scatter)
|
||||
{
|
||||
if (last_set_type == chart_bubble)
|
||||
{ //bubble(x)
|
||||
@ -434,13 +440,19 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
}
|
||||
else
|
||||
{ //x
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (2, domain_cash);
|
||||
if (false == domain_cash.empty())
|
||||
{
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (2, domain_cash);
|
||||
}
|
||||
//y
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (3, cell_cash);
|
||||
if (false == cell_cash.empty())
|
||||
{
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (3, cell_cash);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -207,10 +207,9 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
|
||||
{
|
||||
std::wostream & strm = Context.output_stream();
|
||||
|
||||
|
||||
if (attlist_.style_column_width_)
|
||||
{
|
||||
double kf_max_width_ms =1.;
|
||||
double kf_max_width_ms = 1.;
|
||||
|
||||
const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();//
|
||||
if ((pp) && (pp->properties()))
|
||||
@ -226,17 +225,15 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
|
||||
|
||||
int val = attlist_.style_column_width_->get_value_unit(length::pt);
|
||||
|
||||
double width = 0.5 + 20.0 * val * kf_max_width_ms;
|
||||
|
||||
//_CP_OPT(int) iUnormalWidth;
|
||||
//if (odf_reader::GetProperty(Context.get_settings_properties(),L"UnormalWidthPage",iUnormalWidth))
|
||||
{
|
||||
//kf_max_width_ms = 31680./iUnormalWidth.get();//эквивалент 22"
|
||||
}
|
||||
|
||||
|
||||
strm << L"<w:gridCol w:w=\"" <<
|
||||
(int)(0.5 + 20.0 * val * kf_max_width_ms) << "\"/>";
|
||||
Context.get_table_context().add_column_width(width);
|
||||
strm << L"<w:gridCol w:w=\"" << (int)(width) << "\"/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.get_table_context().add_column_width(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -244,7 +241,6 @@ void style_table_column_properties::pptx_convert(oox::pptx_conversion_context &
|
||||
{
|
||||
std::wostream & strm = Context.get_table_context().tableData();
|
||||
|
||||
|
||||
if (attlist_.style_column_width_)
|
||||
{
|
||||
int val = attlist_.style_column_width_->get_value_unit(length::emu);
|
||||
|
||||
@ -109,14 +109,20 @@ namespace svg_path
|
||||
aChar = rStr[++io_rPos];
|
||||
}
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
if(!sNumberString.empty())
|
||||
{
|
||||
o_fRetval = boost::lexical_cast<double>(sNumberString);
|
||||
return true;
|
||||
try
|
||||
{
|
||||
o_fRetval = boost::lexical_cast<double>(sNumberString);
|
||||
result = true;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool importDoubleAndSpaces( double& o_fRetval, int& io_rPos, const std::wstring& rStr, const int nLen )
|
||||
|
||||
@ -238,16 +238,24 @@ void table_table_column::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
for (unsigned int i = 0; i < columnsRepeated; ++i)
|
||||
{
|
||||
bool bAddWidth = false;
|
||||
if (table_table_column_attlist_.table_style_name_)
|
||||
{
|
||||
const std::wstring colStyleName = table_table_column_attlist_.table_style_name_.get();
|
||||
if (style_instance * inst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn,Context.process_headers_footers_ ))
|
||||
Context.root()->odf_context().styleContainer().style_by_name( colStyleName , style_family::TableColumn, Context.process_headers_footers_ ))
|
||||
{
|
||||
if (inst->content())
|
||||
{
|
||||
inst->content()->docx_convert(Context);
|
||||
bAddWidth = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == bAddWidth)
|
||||
{
|
||||
Context.get_table_context().add_column_width(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,22 +274,27 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
|
||||
_Wostream << L"<w:tcPr>";
|
||||
|
||||
const std::wstring styleName = attlist_.table_style_name_.get_value_or(L"");
|
||||
|
||||
//_Wostream << L"<w:tcW w:w=\"0\" w:type=\"auto\" />";
|
||||
|
||||
if (attlist_extra_.table_number_rows_spanned_ > 1)
|
||||
{
|
||||
_Wostream << L"<w:vMerge w:val=\"restart\" />";
|
||||
_Wostream << L"<w:vMerge w:val=\"restart\"/>";
|
||||
Context.get_table_context().set_rows_spanned(Context.get_table_context().current_column(),
|
||||
attlist_extra_.table_number_rows_spanned_ - 1,
|
||||
attlist_extra_.table_number_columns_spanned_ - 1,
|
||||
styleName
|
||||
);
|
||||
}
|
||||
|
||||
double width = Context.get_table_context().get_current_cell_width();
|
||||
|
||||
if (width > 0.01)
|
||||
{
|
||||
_Wostream << L"<w:tcW w:w=\"" << (int)width << L"\" w:type=\"dxa\"/>";
|
||||
}
|
||||
|
||||
if (attlist_extra_.table_number_columns_spanned_ > 1)
|
||||
{
|
||||
_Wostream << L"<w:gridSpan w:val=\"" << attlist_extra_.table_number_columns_spanned_ << "\" />";
|
||||
_Wostream << L"<w:gridSpan w:val=\"" << attlist_extra_.table_number_columns_spanned_ << "\"/>";
|
||||
Context.get_table_context().set_columns_spanned(attlist_extra_.table_number_columns_spanned_ - 1);
|
||||
}
|
||||
|
||||
@ -324,8 +337,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
/// Стиль по умолчанию для данной строки
|
||||
{
|
||||
const std::wstring & defaultCellStyle =
|
||||
Context.get_table_context().get_default_cell_style_row();
|
||||
const std::wstring & defaultCellStyle = Context.get_table_context().get_default_cell_style_row();
|
||||
|
||||
if (const style_instance * inst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyle, style_family::TableCell,Context.process_headers_footers_))
|
||||
|
||||
@ -100,6 +100,7 @@ namespace
|
||||
case XmlUtils::XmlNodeType_DocumentType:
|
||||
return typeDocumentType;
|
||||
case XmlUtils::XmlNodeType_Whitespace:
|
||||
case XmlUtils::XmlNodeType_SIGNIFICANT_WHITESPACE:
|
||||
return typeWhitespace;
|
||||
case XmlUtils::XmlNodeType_EndElement:
|
||||
return typeEndElement;
|
||||
@ -236,4 +237,4 @@ sax_ptr create_sax_xmllite(const wchar_t * FileName)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1055,7 +1055,10 @@ bool odf_drawing_context::isLineShape()
|
||||
case 48: //SimpleTypes::shapetypeCurvedConnector3:
|
||||
case 49: //SimpleTypes::shapetypeCurvedConnector4:
|
||||
case 50: //SimpleTypes::shapetypeCurvedConnector5:
|
||||
return true;
|
||||
return true;
|
||||
case 1000:
|
||||
if (impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_.get_value_or(draw_fill(draw_fill::solid)).get_type() == draw_fill::none)
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -342,6 +342,16 @@ void odf_table_context::change_current_column_width(double width)
|
||||
int index = impl_->current_table().current_column ;
|
||||
if (index < 0) return;
|
||||
|
||||
while(index >= impl_->current_table().columns.size())
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"table-column", elm, impl_->odf_context_);
|
||||
|
||||
impl_->styles_context()->create_style(L"", style_family::TableColumn, true, false, -1);
|
||||
|
||||
add_column(elm, true);
|
||||
|
||||
}
|
||||
style *style_ = dynamic_cast<style*>(impl_->current_table().columns[index].style_elm.get());
|
||||
|
||||
if (style_ == NULL) return;
|
||||
@ -527,7 +537,11 @@ void odf_table_context::set_cell_row_span_restart()
|
||||
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = sz;
|
||||
}
|
||||
state.spanned_row_cell.clear();
|
||||
state.spanned_row_cell.push_back(impl_->current_table().cells.back().elm);
|
||||
|
||||
if (false == impl_->current_table().cells.empty())
|
||||
{
|
||||
state.spanned_row_cell.push_back(impl_->current_table().cells.back().elm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
|
||||
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
|
||||
#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SpTreeElem.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h"
|
||||
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
|
||||
@ -267,6 +268,10 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
}
|
||||
if (oox_picture->oleObject.IsInit())
|
||||
{
|
||||
if (pathImage.empty() && oox_picture->blipFill.blip.IsInit())
|
||||
{
|
||||
pathImage = oox_picture->blipFill.blip->oleFilepathImage;
|
||||
}
|
||||
std::wstring pathOle;
|
||||
|
||||
if (oox_picture->oleObject->m_oId.IsInit())
|
||||
@ -283,6 +288,58 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
{
|
||||
odf_context()->drawing_context()->set_program(*oox_picture->oleObject->m_sProgId);
|
||||
}
|
||||
|
||||
if (pathImage.empty() && oox_picture->oleObject->m_sShapeId.IsInit())
|
||||
{
|
||||
PPTX::Slide *pSlide = dynamic_cast<PPTX::Slide*>(current_document());
|
||||
PPTX::SlideMaster *pSlideMaster = dynamic_cast<PPTX::SlideMaster*>(current_document());
|
||||
|
||||
OOX::CVmlDrawing *pVml = pSlide ? pSlide->Vml.operator->() : (pSlideMaster ? pSlideMaster->Vml.operator->() : NULL);
|
||||
|
||||
if (pVml)
|
||||
{
|
||||
std::wstring sShapeId = oox_picture->oleObject->m_sShapeId.get();
|
||||
boost::unordered_map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pFind = pVml->m_mapShapes.find(sShapeId);
|
||||
|
||||
if (pVml->m_mapShapes.end() != pFind)
|
||||
{
|
||||
OOX::Vml::CVmlCommonElements* pShape = dynamic_cast<OOX::Vml::CVmlCommonElements*>(pFind->second.pElement);
|
||||
|
||||
if (pShape)
|
||||
{
|
||||
for(size_t i = 0; i < pShape->m_arrItems.size(); ++i)
|
||||
{
|
||||
OOX::WritingElement* pChildElemShape = pShape->m_arrItems[i];
|
||||
|
||||
if(OOX::et_v_imagedata == pChildElemShape->getType())
|
||||
{
|
||||
OOX::Vml::CImageData* pImageData = static_cast<OOX::Vml::CImageData*>(pChildElemShape);
|
||||
|
||||
std::wstring sIdImageFileCache;
|
||||
|
||||
if (pImageData->m_oRelId.IsInit()) sIdImageFileCache = pImageData->m_oRelId->GetValue();
|
||||
else if (pImageData->m_rId.IsInit()) sIdImageFileCache = pImageData->m_rId->GetValue();
|
||||
|
||||
if (!sIdImageFileCache.empty())
|
||||
{
|
||||
//ищем физический файл ( rId относительно vml_drawing)
|
||||
smart_ptr<OOX::File> pFile = pVml->Find(sIdImageFileCache);
|
||||
|
||||
if (pFile.IsInit() && ( OOX::FileTypes::Image == pFile->type()))
|
||||
{
|
||||
OOX::Image* pImageFileCache = static_cast<OOX::Image*>(pFile.operator->());
|
||||
|
||||
pathImage = pImageFileCache->filename().GetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
odf_ref_image = bEmbedded ? odf_context()->add_imageobject(pathImage) : pathImage;
|
||||
odf_context()->drawing_context()->set_image_replacement(odf_ref_image);
|
||||
|
||||
@ -844,6 +901,25 @@ void OoxConverter::convert(PPTX::Logic::Path2D *oox_geom_path)
|
||||
|
||||
odf_context()->drawing_context()->set_viewBox(oox_geom_path->w.get_value_or(0), oox_geom_path->h.get_value_or(0));
|
||||
|
||||
if (oox_geom_path->fill.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->start_area_properties();
|
||||
switch(oox_geom_path->fill->GetBYTECode())
|
||||
{
|
||||
case 0://darken
|
||||
case 1://darkenLess
|
||||
case 2://lighten
|
||||
case 3://lightenLess
|
||||
break;
|
||||
case 4:
|
||||
odf_context()->drawing_context()->set_no_fill();
|
||||
break;
|
||||
case 5:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
odf_context()->drawing_context()->end_area_properties();
|
||||
}
|
||||
for (size_t i = 0 ; i < oox_geom_path->Paths.size(); i++)
|
||||
{
|
||||
if (oox_geom_path->Paths[i].Path2D.is<PPTX::Logic::PathBase>())
|
||||
@ -1973,24 +2049,26 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
|
||||
if (!oox_run) return;
|
||||
bool styled = false;
|
||||
|
||||
odf_writer::odf_text_context* text_context = odf_context()->text_context();
|
||||
|
||||
if (oox_run->rPr.IsInit())
|
||||
{
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
|
||||
odf_writer::style_text_properties * text_properties = text_context->get_text_properties();
|
||||
|
||||
if (!text_properties)
|
||||
{
|
||||
odf_context()->styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
|
||||
text_properties = odf_context()->styles_context()->last_state()->get_text_properties();
|
||||
text_context->get_styles_context()->create_style(L"", odf_types::style_family::Text, true, false, -1);
|
||||
text_properties = text_context->get_styles_context()->last_state()->get_text_properties();
|
||||
styled = true;
|
||||
}
|
||||
convert(oox_run->rPr.GetPointer(), text_properties);
|
||||
}
|
||||
|
||||
odf_context()->text_context()->start_span(styled);
|
||||
text_context->start_span(styled);
|
||||
|
||||
if ((oox_run->rPr.IsInit()) && (oox_run->rPr->hlinkClick.IsInit()) && (oox_run->rPr->hlinkClick->id.IsInit()))
|
||||
{
|
||||
odf_writer::style_text_properties * text_properties = odf_context()->text_context()->get_text_properties();
|
||||
odf_writer::style_text_properties * text_properties = text_context->get_text_properties();
|
||||
|
||||
if (!text_properties->content_.fo_color_)
|
||||
{
|
||||
@ -2010,13 +2088,13 @@ void OoxConverter::convert(PPTX::Logic::Run *oox_run)
|
||||
text_properties->content_.style_text_underline_style_ = odf_types::line_style::Solid;
|
||||
|
||||
std::wstring hlink = find_link_by_id(oox_run->rPr->hlinkClick->id.get(), 2);
|
||||
odf_context()->text_context()->add_hyperlink(hlink, oox_run->GetText());
|
||||
text_context->add_hyperlink(hlink, oox_run->GetText());
|
||||
}
|
||||
else
|
||||
{
|
||||
odf_context()->text_context()->add_text_content( oox_run->GetText());
|
||||
text_context->add_text_content( oox_run->GetText());
|
||||
}
|
||||
odf_context()->text_context()->end_span();
|
||||
text_context->end_span();
|
||||
}
|
||||
void OoxConverter::convert(PPTX::Logic::Fld *oox_fld)
|
||||
{
|
||||
|
||||
@ -437,7 +437,10 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
odt_context->text_context()->set_KeepNextParagraph(false);
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
|
||||
if (false == current_font_size.empty())
|
||||
{
|
||||
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
|
||||
}
|
||||
|
||||
bool bStyled = false;
|
||||
bool bStartNewParagraph = !odt_context->text_context()->get_KeepNextParagraph();
|
||||
@ -2112,7 +2115,7 @@ void DocxConverter::convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf
|
||||
//tblwidthNil = 2,
|
||||
//tblwidthPct = 3
|
||||
}
|
||||
void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::style_text_properties * text_properties)
|
||||
void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::style_text_properties * text_properties, bool is_list_styles)
|
||||
{
|
||||
if (oox_run_pr == NULL) return;
|
||||
if (text_properties == NULL) return;
|
||||
@ -2120,7 +2123,20 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
|
||||
if (oox_run_pr->m_oRStyle.IsInit() && oox_run_pr->m_oRStyle->m_sVal.IsInit())
|
||||
{
|
||||
std::wstring style_name = *oox_run_pr->m_oRStyle->m_sVal;
|
||||
odt_context->styles_context()->last_state()->set_parent_style_name(style_name);
|
||||
|
||||
odf_writer::odf_style_state_ptr style_state;
|
||||
//if (is_list_styles)
|
||||
//{
|
||||
// style_state = odt_context->styles_context()->lists_styles()->last_state();
|
||||
//}
|
||||
//else
|
||||
{
|
||||
style_state = odt_context->styles_context()->last_state();
|
||||
}
|
||||
if (style_state)
|
||||
{
|
||||
style_state->set_parent_style_name(style_name);
|
||||
}
|
||||
|
||||
odf_writer::style_text_properties parent_text_properties;
|
||||
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Text, &parent_text_properties.content_);
|
||||
@ -3233,7 +3249,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
|
||||
odf_writer::odf_style_context* styles_context = odf_context()->page_layout_context()->get_local_styles_context();
|
||||
|
||||
odf_writer::style_text_properties *text_props = odt_context->styles_context()->lists_styles().get_text_properties();
|
||||
convert(oox_num_lvl->m_oRPr.GetPointer(), text_props);
|
||||
convert(oox_num_lvl->m_oRPr.GetPointer(), text_props, true);
|
||||
|
||||
//create text style for symbols list НА ЛОКАЛЬНОМ контексте - иначе пересечение имен стилей (todoo вытащить генерацию имен в общую часть)
|
||||
styles_context->create_style(L"", odf_types::style_family::Text, false, true, -1);
|
||||
|
||||
@ -189,7 +189,7 @@ namespace Oox2Odf
|
||||
void convert(OOX::Logic::CRun *oox_run);
|
||||
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);
|
||||
void convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf_writer::style_paragraph_properties *paragraph_properties);
|
||||
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties);
|
||||
void convert(OOX::Logic::CRunProperty *oox_run_prop, odf_writer::style_text_properties *text_properties, bool is_list_styles = false);
|
||||
void convert(ComplexTypes::Word::CShading *oox_shading, odf_writer::style_text_properties *text_properties );
|
||||
void convert(OOX::Logic::CFldSimple *oox_fld);
|
||||
void convert(OOX::Logic::CFldChar *oox_fld);
|
||||
|
||||
@ -954,7 +954,9 @@ void PptxConverter::convert(PPTX::Logic::TableCell *oox_table_cell, int numCol)
|
||||
covered = true;
|
||||
|
||||
if (oox_table_cell->CellProperties.IsInit())
|
||||
{
|
||||
styled = (oox_table_cell->CellProperties->is_empty == false);
|
||||
}
|
||||
|
||||
odp_context->slide_context()->start_table_cell(numCol, covered, styled);
|
||||
|
||||
@ -1193,8 +1195,8 @@ bool PptxConverter::convert(PPTX::Logic::TableCellProperties *oox_table_cell_pr)
|
||||
{
|
||||
if (!oox_table_cell_pr) return false;
|
||||
|
||||
odf_writer::style_table_cell_properties *odf_cell_props = odp_context->styles_context()->last_state()->get_table_cell_properties();
|
||||
odf_writer::style_paragraph_properties *odf_para_props = odp_context->styles_context()->last_state(odf_types::style_family::TableCell)->get_paragraph_properties();
|
||||
odf_writer::style_table_cell_properties *odf_cell_props = odp_context->slide_context()->get_styles_context()->last_state()->get_table_cell_properties();
|
||||
odf_writer::style_paragraph_properties *odf_para_props = odp_context->slide_context()->get_styles_context()->last_state(odf_types::style_family::TableCell)->get_paragraph_properties();
|
||||
|
||||
if (!odf_para_props) return false;
|
||||
|
||||
|
||||
@ -916,11 +916,10 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views)
|
||||
{
|
||||
int table_id = oox_book_views->m_oActiveTab->GetValue();
|
||||
|
||||
std::map<int, OOX::Spreadsheet::CSheet*>::iterator pFind = Workbook->m_oSheets->mapSheets.find(table_id);
|
||||
|
||||
if (pFind != Workbook->m_oSheets->mapSheets.end())
|
||||
if (table_id >= 0 && table_id < Workbook->m_oSheets->m_arrItems.size())
|
||||
{
|
||||
ods_context->settings_context()->add_property(L"ActiveTable", L"string", pFind->second->m_oName.get2());
|
||||
ods_context->settings_context()->add_property(L"ActiveTable", L"string",
|
||||
Workbook->m_oSheets->m_arrItems[table_id]->m_oName.get2());
|
||||
}
|
||||
}
|
||||
if (oox_book_views->m_oShowSheetTabs.IsInit())
|
||||
|
||||
@ -15,6 +15,7 @@ PWD_ROOT_DIR = $$PWD
|
||||
|
||||
CONFIG += core_x2t
|
||||
include(../../../Common/base.pri)
|
||||
include(../../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
#BOOST
|
||||
include($$PWD/../../../Common/3dParty/boost/boost.pri)
|
||||
|
||||
@ -1191,7 +1191,7 @@ namespace NSBinPptxRW
|
||||
std::to_wstring(nIndexTheme + 1) + L".xml\"/>";
|
||||
m_pWriter->WriteString(s);
|
||||
}
|
||||
void CRelsGenerator::StartNotesMaster(int nIndexTheme)
|
||||
void CRelsGenerator::StartThemeNotesMaster(int nIndexTheme)
|
||||
{
|
||||
m_pWriter->WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
|
||||
m_pWriter->WriteString(_T("<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"));
|
||||
@ -1280,22 +1280,22 @@ namespace NSBinPptxRW
|
||||
|
||||
m_pWriter->WriteString(strRels);
|
||||
}
|
||||
void CRelsGenerator::WriteNotesMaster()
|
||||
{
|
||||
std::wstring strRels0 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster\" Target=\"notesMasters/notesMaster1.xml\"/>";
|
||||
m_pWriter->WriteString(strRels0);
|
||||
}
|
||||
void CRelsGenerator::WritePresentationComments(int nComment)
|
||||
{
|
||||
std::wstring strRels = L"<Relationship Id=\"rId" + std::to_wstring( m_lNextRelsID++ ) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\" Target=\"comments/comment" +
|
||||
L"\" Type=\"http://schemas.onlyoffice.com/comments\" Target=\"comments/comment" +
|
||||
std::to_wstring(nComment) + L".xml\"/>";
|
||||
|
||||
m_pWriter->WriteString(strRels);
|
||||
}
|
||||
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsNotesMaster, bool bIsVbaProject, bool bIsJsaProject)
|
||||
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsVbaProject, bool bIsJsaProject)
|
||||
{
|
||||
if (bIsNotesMaster)
|
||||
{
|
||||
std::wstring strRels0 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster\" Target=\"notesMasters/notesMaster1.xml\"/>";
|
||||
m_pWriter->WriteString(strRels0);
|
||||
}
|
||||
std::wstring strRels1 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps\" Target=\"presProps.xml\" />";
|
||||
std::wstring strRels2 = L"<Relationship Id=\"rId" + std::to_wstring(m_lNextRelsID++) +
|
||||
@ -1326,10 +1326,6 @@ namespace NSBinPptxRW
|
||||
m_pWriter->WriteString(strRels5);
|
||||
}
|
||||
}
|
||||
int CRelsGenerator::GetNextId()
|
||||
{
|
||||
return m_lNextRelsID;
|
||||
}
|
||||
void CRelsGenerator::CloseRels()
|
||||
{
|
||||
m_pWriter->WriteString(_T("</Relationships>"));
|
||||
|
||||
@ -401,10 +401,10 @@ namespace NSBinPptxRW
|
||||
{
|
||||
private:
|
||||
CStringWriter* m_pWriter;
|
||||
int m_lNextRelsID;
|
||||
std::map<std::wstring, _relsGeneratorInfo> m_mapImages;
|
||||
std::map<std::wstring, int> m_mapLinks;
|
||||
public:
|
||||
size_t m_lNextRelsID;
|
||||
CImageManager2* m_pManager;
|
||||
|
||||
CRelsGenerator(CImageManager2* pManager = NULL);
|
||||
@ -418,19 +418,20 @@ namespace NSBinPptxRW
|
||||
void StartLayout (int nIndexTheme);
|
||||
void StartSlide (int nIndexSlide, int nIndexLayout, int nIndexNotes);
|
||||
void StartNotes (int nIndexSlide);
|
||||
void StartNotesMaster(int nIndexTheme);
|
||||
void StartThemeNotesMaster(int nIndexTheme);
|
||||
|
||||
void WriteMasters (int nCount);
|
||||
void WriteThemes (int nCount);
|
||||
void WriteSlides (int nCount);
|
||||
void WriteNotesMaster();
|
||||
|
||||
void WriteSlideComments (int nComment);
|
||||
void WritePresentationComments (int nComment);
|
||||
int WriteChart (int nChartNumber, _INT32 lDocType);
|
||||
int WriteRels (const std::wstring& bsType, const std::wstring& bsTarget, const std::wstring& bsTargetMode);
|
||||
int WriteHyperlink (const std::wstring& strLink, const bool& bIsActionInit);
|
||||
|
||||
void EndPresentationRels (bool bIsCommentsAuthors = false, bool bIsNotesMaster = false, bool bIsVbaProject = false, bool bIsJsaProject = false );
|
||||
int GetNextId ();
|
||||
void EndPresentationRels (bool bIsCommentsAuthors = false, bool bIsVbaProject = false, bool bIsJsaProject = false );
|
||||
void CloseRels ();
|
||||
|
||||
void AddRels (const std::wstring& strRels);
|
||||
|
||||
@ -131,6 +131,11 @@ namespace PPTX2EditorAdvanced
|
||||
for (size_t nNote = 0; nNote < nCountNoteMasters; ++nNote)
|
||||
{
|
||||
smart_ptr<PPTX::NotesMaster> noteMaster = ((*presentation)[presentation->notesMasterIdLst[nNote].rid.get()]).smart_dynamic_cast<PPTX::NotesMaster>();
|
||||
if (false == noteMaster.IsInit())
|
||||
{
|
||||
// такого быть не должно
|
||||
continue;
|
||||
}
|
||||
size_t pPointerNM = (size_t)(noteMaster.operator ->());
|
||||
|
||||
std::map<size_t, LONG>::const_iterator pSearchNM = pCommon->notesMasters.find(pPointerNM);
|
||||
|
||||
@ -209,25 +209,25 @@ namespace NSBinPptxRW
|
||||
LONG nCountSlides = 0;
|
||||
bool bNotesMasterPresent = false;
|
||||
|
||||
pPair = m_mainTables.find(NSMainTables::Themes);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::Themes);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
nCountThemes = m_oReader.GetLong();
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::SlideMasters);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideMasters);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
nCountMasters = m_oReader.GetLong();
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::SlideLayouts);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideLayouts);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
nCountLayouts = m_oReader.GetLong();
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::Slides);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::Slides);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -256,7 +256,7 @@ namespace NSBinPptxRW
|
||||
m_arSlides_Notes.push_back(-1);
|
||||
|
||||
// ThemeRels
|
||||
pPair = m_mainTables.find(NSMainTables::ThemeRels);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::ThemeRels);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -286,7 +286,7 @@ namespace NSBinPptxRW
|
||||
}
|
||||
|
||||
// готово, теперь нужно слайдам проставить шаблоны
|
||||
pPair = m_mainTables.find(NSMainTables::SlideRels);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideRels);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -304,7 +304,7 @@ namespace NSBinPptxRW
|
||||
m_arSlides_Layout[index++] = m_oReader.GetULong();
|
||||
}
|
||||
}
|
||||
pPair = m_mainTables.find(NSMainTables::SlideNotesRels);
|
||||
pPair = m_mainTables.find(NSBinPptxRW::NSMainTables::SlideNotesRels);
|
||||
if (m_mainTables.end() != pPair)
|
||||
{
|
||||
m_oReader.Seek(pPair->second);
|
||||
@ -574,7 +574,7 @@ namespace NSBinPptxRW
|
||||
m_arNotesMasters.push_back(elm);
|
||||
|
||||
m_oReader.m_pRels->Clear();
|
||||
m_oReader.m_pRels->StartNotesMaster(m_arSlideMasters_Theme.size());
|
||||
m_oReader.m_pRels->StartThemeNotesMaster(m_arSlideMasters_Theme.size());
|
||||
|
||||
bNotesMasterPresent = true;
|
||||
if (lCount > 0)
|
||||
@ -798,7 +798,7 @@ namespace NSBinPptxRW
|
||||
m_oReader.m_pRels->WriteMasters(nCountMasters);
|
||||
m_oReader.m_pRels->WriteThemes(nCountThemes);
|
||||
|
||||
int nCurrentRels = m_oReader.m_pRels->GetNextId();
|
||||
size_t nCurrentRels = m_oReader.m_pRels->m_lNextRelsID;
|
||||
|
||||
m_oPresentation.sldIdLst.clear();
|
||||
for (LONG i = 0; i < nCountSlides; ++i)
|
||||
@ -808,10 +808,8 @@ namespace NSBinPptxRW
|
||||
std::wstring sId = std::to_wstring(256 + i);
|
||||
|
||||
m_oPresentation.sldIdLst[i].id = sId;
|
||||
m_oPresentation.sldIdLst[i].rid = (size_t)nCurrentRels;
|
||||
++nCurrentRels;
|
||||
m_oPresentation.sldIdLst[i].rid = nCurrentRels++;
|
||||
}
|
||||
|
||||
m_oReader.m_pRels->WriteSlides(nCountSlides);
|
||||
|
||||
m_oPresentation.notesMasterIdLst.clear();
|
||||
@ -819,8 +817,8 @@ namespace NSBinPptxRW
|
||||
{
|
||||
m_oPresentation.notesMasterIdLst.push_back(PPTX::Logic::XmlId(L"p:notesMasterId"));
|
||||
|
||||
m_oPresentation.notesMasterIdLst[0].rid = (size_t)nCurrentRels;
|
||||
++nCurrentRels;
|
||||
m_oPresentation.notesMasterIdLst[0].rid = m_oReader.m_pRels->m_lNextRelsID;
|
||||
m_oReader.m_pRels->WriteNotesMaster();
|
||||
}
|
||||
if (m_oPresentation.comments.is_init())
|
||||
{
|
||||
@ -841,7 +839,7 @@ namespace NSBinPptxRW
|
||||
++nComment;
|
||||
}
|
||||
|
||||
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), bNotesMasterPresent, m_oPresentation.m_pVbaProject.is_init(), m_oPresentation.m_pJsaProject.is_init());
|
||||
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), m_oPresentation.m_pVbaProject.is_init(), m_oPresentation.m_pJsaProject.is_init());
|
||||
m_oReader.m_pRels->CloseRels();
|
||||
|
||||
oXmlWriter.ClearNoAttack();
|
||||
|
||||
@ -74,7 +74,8 @@ namespace NSShapeImageGen
|
||||
itWMF = 3,
|
||||
itEMF = 4,
|
||||
itSVG = 5,
|
||||
itMedia = 6
|
||||
itMedia = 6,
|
||||
itUnknown = 7
|
||||
};
|
||||
|
||||
class CMediaInfo
|
||||
@ -380,6 +381,10 @@ namespace NSShapeImageGen
|
||||
//конвертация неудачная - берем оригинальный файл
|
||||
OOX::CPath pathOriginal = strFileSrc;
|
||||
|
||||
//default is itJPG. set itUnknown to use original extension
|
||||
oInfo.m_eType = itUnknown;
|
||||
oInfo.m_sExt = pathOriginal.GetExtention();
|
||||
|
||||
std::wstring strSaveItem = oInfo.GetPathWithoutExtension();
|
||||
|
||||
strSaveItem = m_strDstMedia + FILE_SEPARATOR_STR + strSaveItem + pathOriginal.GetExtention();
|
||||
|
||||
@ -15,6 +15,7 @@ PWD_ROOT_DIR = $$PWD
|
||||
|
||||
CONFIG += core_x2t
|
||||
include(../../../../Common/base.pri)
|
||||
include(../../../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
core_windows {
|
||||
QMAKE_CXXFLAGS_RELEASE += -Ob0
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
@ -567,6 +567,10 @@
|
||||
<Filter
|
||||
Name="___"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\source\Writer\OOXCommentsWriter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\Writer\OOXContentTypesWriter.h"
|
||||
>
|
||||
|
||||
@ -987,32 +987,32 @@ bool RtfCharPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRea
|
||||
//COMMAND_RTF_BOOL( "ul", charProps->m_bUnderline, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "ulc", charProps->m_nUnderlineColor, sCommand, hasParameter, parameter)
|
||||
|
||||
COMMAND_RTF_INT ( "uld", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dotted)
|
||||
COMMAND_RTF_INT ( "uld", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dotted)
|
||||
COMMAND_RTF_INT ( "uldash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dashed)
|
||||
COMMAND_RTF_INT ( "uldashd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dash_dotted)
|
||||
COMMAND_RTF_INT ( "uldashdd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dash_dot_dotted)
|
||||
COMMAND_RTF_INT ( "uldb", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Double)
|
||||
COMMAND_RTF_INT ( "ulhwave", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Heavy_wave)
|
||||
COMMAND_RTF_INT ( "ulldash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Long_dashe)
|
||||
COMMAND_RTF_INT ( "uldashd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dash_dotted)
|
||||
COMMAND_RTF_INT ( "uldashdd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Dash_dot_dotted)
|
||||
COMMAND_RTF_INT ( "uldb", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Double)
|
||||
COMMAND_RTF_INT ( "ulhwave", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Heavy_wave)
|
||||
COMMAND_RTF_INT ( "ulldash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Long_dashe)
|
||||
COMMAND_RTF_INT ( "ulnone", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_none)
|
||||
COMMAND_RTF_INT ( "ulth", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick)
|
||||
COMMAND_RTF_INT ( "ulthd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dotted)
|
||||
COMMAND_RTF_INT ( "ulthdash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dashed)
|
||||
COMMAND_RTF_INT ( "ulthdashd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dash_dotted)
|
||||
COMMAND_RTF_INT ( "ulth", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick)
|
||||
COMMAND_RTF_INT ( "ulthd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dotted)
|
||||
COMMAND_RTF_INT ( "ulthdash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dashed)
|
||||
COMMAND_RTF_INT ( "ulthdashd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dash_dotted)
|
||||
COMMAND_RTF_INT ( "ulthdashdd", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_dash_dot_dotted)
|
||||
COMMAND_RTF_INT ( "ulthldash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_long_dashed)
|
||||
COMMAND_RTF_INT ( "ulthldash", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Thick_long_dashed)
|
||||
COMMAND_RTF_INT ( "ululdbwave", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Double_wave)
|
||||
COMMAND_RTF_INT ( "ulw", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Word)
|
||||
COMMAND_RTF_INT ( "ulw", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Word)
|
||||
COMMAND_RTF_INT ( "ulwave", charProps->m_eUnderStyle, sCommand, true, RtfCharProperty::uls_Wave)
|
||||
|
||||
COMMAND_RTF_INT ( "up", charProps->m_nUp, sCommand, hasParameter, parameter)
|
||||
|
||||
COMMAND_RTF_INT ( "crauth", charProps->m_nCrAuth, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "crdate", charProps->m_nCrDate, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "insrsid", charProps->m_nInsrsid, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "insrsid", charProps->m_nInsrsid, sCommand, hasParameter, parameter)
|
||||
|
||||
COMMAND_RTF_INT ( "revauth", charProps->m_nRevauth, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "revdttm", charProps->m_nRevdttm, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "revauth", charProps->m_nRevauth, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "revdttm", charProps->m_nRevdttm, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "revauthdel", charProps->m_nRevauthDel, sCommand, hasParameter, parameter)
|
||||
COMMAND_RTF_INT ( "revdttmdel", charProps->m_nRevdttmDel, sCommand, hasParameter, parameter)
|
||||
|
||||
@ -2794,7 +2794,69 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
|
||||
if ( pNewBookmarkEnd->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewBookmarkEnd );
|
||||
}
|
||||
else if ( "footnote" == sCommand )
|
||||
else if ( "atrfstart" == sCommand )
|
||||
{
|
||||
RtfAnnotElemPtr pNewAnnotElem ( new RtfAnnotElem(1) );
|
||||
RtfAnnotElemReader oAnnotElemReader ( *pNewAnnotElem );
|
||||
|
||||
oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader );
|
||||
|
||||
if ( pNewAnnotElem->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewAnnotElem );
|
||||
}
|
||||
else if ( "atrfend" == sCommand )
|
||||
{
|
||||
RtfAnnotElemPtr pNewAnnotElem ( new RtfAnnotElem(2) );
|
||||
RtfAnnotElemReader oAnnotElemReader ( *pNewAnnotElem );
|
||||
|
||||
oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader );
|
||||
|
||||
if ( pNewAnnotElem->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewAnnotElem );
|
||||
|
||||
}
|
||||
else if ( "annotation" == sCommand )
|
||||
{
|
||||
RtfAnnotationPtr pNewAnnot ( new RtfAnnotation() );
|
||||
RtfAnnotationReader oAnnotReader ( *pNewAnnot );
|
||||
|
||||
oAbstrReader.StartSubReader( oAnnotReader, oDocument, oReader );
|
||||
|
||||
if ( pNewAnnot->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewAnnot );
|
||||
}
|
||||
else if ( "atnid" == sCommand )
|
||||
{
|
||||
RtfAnnotElemPtr pNewAnnotElem ( new RtfAnnotElem(5) );
|
||||
RtfAnnotElemReader oAnnotElemReader( *pNewAnnotElem );
|
||||
|
||||
oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader );
|
||||
|
||||
if ( pNewAnnotElem->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewAnnotElem );
|
||||
}
|
||||
else if ( "atnauthor" == sCommand )
|
||||
{
|
||||
RtfAnnotElemPtr pNewAnnotElem ( new RtfAnnotElem(4) );
|
||||
RtfAnnotElemReader oAnnotElemReader( *pNewAnnotElem );
|
||||
|
||||
oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader );
|
||||
|
||||
if ( pNewAnnotElem->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewAnnotElem );
|
||||
}
|
||||
else if ( "atnref" == sCommand )
|
||||
{
|
||||
RtfAnnotElemPtr pNewAnnotElem ( new RtfAnnotElem(3) );
|
||||
RtfAnnotElemReader oAnnotElemReader ( *pNewAnnotElem );
|
||||
|
||||
oAbstrReader.StartSubReader( oAnnotElemReader, oDocument, oReader );
|
||||
|
||||
if ( pNewAnnotElem->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewAnnotElem );
|
||||
|
||||
}
|
||||
else if ( "footnote" == sCommand )
|
||||
{
|
||||
RtfFootnotePtr pNewFootnote ( new RtfFootnote() );
|
||||
pNewFootnote->m_oCharProp = oReader.m_oState->m_oCharProp;
|
||||
@ -2805,6 +2867,14 @@ bool RtfParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfRead
|
||||
if ( pNewFootnote->IsValid() )
|
||||
m_oCurParagraph->AddItem( pNewFootnote );
|
||||
}
|
||||
//else if ( "chatn" == sCommand )
|
||||
//{
|
||||
// RtfCharSpecialPtr pNewChar ( new RtfCharSpecial() );
|
||||
//
|
||||
// pNewChar->m_oProperty = oReader.m_oState->m_oCharProp;
|
||||
// pNewChar->m_eType = RtfCharSpecial::rsc_chatn;
|
||||
// m_oCurParagraph->AddItem( pNewChar );
|
||||
//}
|
||||
else if ( "chftn" == sCommand )
|
||||
{
|
||||
if ( 1 == oReader.m_nFootnote )
|
||||
|
||||
@ -1513,6 +1513,40 @@ private:
|
||||
m_oField.m_bTextOnly = true;
|
||||
}
|
||||
};
|
||||
class RtfAnnotElemReader: public RtfAbstractReader
|
||||
{
|
||||
public:
|
||||
RtfAnnotElem& m_oAnnot;
|
||||
|
||||
RtfAnnotElemReader( RtfAnnotElem& oAnnot ) : m_oAnnot(oAnnot)
|
||||
{
|
||||
}
|
||||
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
|
||||
{
|
||||
if( "atrfstart" == sCommand )
|
||||
;
|
||||
else if( "atrfend" == sCommand )
|
||||
;
|
||||
else if( "atnref" == sCommand )
|
||||
;
|
||||
else if( "atndate" == sCommand )
|
||||
;
|
||||
else if( "atnid" == sCommand )
|
||||
;
|
||||
else if( "atnauthor" == sCommand )
|
||||
;
|
||||
else if ( "atnparent" == sCommand )
|
||||
;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, std::wstring sText)
|
||||
{
|
||||
m_oAnnot.m_sValue += sText ;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class RtfBookmarkStartReader: public RtfAbstractReader
|
||||
{
|
||||
@ -1679,6 +1713,60 @@ public:
|
||||
oReader.m_nFootnote = PROP_DEF;
|
||||
}
|
||||
};
|
||||
|
||||
class RtfAnnotationReader: public RtfAbstractReader
|
||||
{
|
||||
private:
|
||||
RtfParagraphPropDestination m_oParPropDest;
|
||||
public:
|
||||
RtfAnnotation& m_oRtfAnnotation;
|
||||
|
||||
RtfAnnotationReader( RtfAnnotation& oRtfAnnotation ) : m_oRtfAnnotation(oRtfAnnotation)
|
||||
{
|
||||
}
|
||||
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
|
||||
{
|
||||
if( "annotation" == sCommand )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if( "atnref" == sCommand )
|
||||
{
|
||||
m_oRtfAnnotation.m_oRef = RtfAnnotElemPtr ( new RtfAnnotElem(3) );
|
||||
RtfAnnotElemReader oAnnotReader ( *m_oRtfAnnotation.m_oRef );
|
||||
|
||||
StartSubReader( oAnnotReader, oDocument, oReader );
|
||||
|
||||
}
|
||||
else if( "atndate" == sCommand )
|
||||
{
|
||||
m_oRtfAnnotation.m_oDate = RtfAnnotElemPtr ( new RtfAnnotElem(6) );
|
||||
RtfAnnotElemReader oAnnotReader ( *m_oRtfAnnotation.m_oDate );
|
||||
|
||||
StartSubReader( oAnnotReader, oDocument, oReader );
|
||||
}
|
||||
else if( "atnparent" == sCommand )
|
||||
{
|
||||
m_oRtfAnnotation.m_oParent = RtfAnnotElemPtr ( new RtfAnnotElem(7) );
|
||||
RtfAnnotElemReader oAnnotReader ( *m_oRtfAnnotation.m_oParent );
|
||||
|
||||
StartSubReader( oAnnotReader, oDocument, oReader );
|
||||
}
|
||||
else
|
||||
return m_oParPropDest.ExecuteCommand( oDocument, oReader, (*this), sCommand, hasParameter, parameter );
|
||||
return true;
|
||||
}
|
||||
void ExecuteText( RtfDocument& oDocument, RtfReader& oReader, std::wstring sText )
|
||||
{
|
||||
m_oParPropDest.ExecuteText( oDocument, oReader, sText );
|
||||
}
|
||||
void ExitReader( RtfDocument& oDocument, RtfReader& oReader )
|
||||
{
|
||||
m_oParPropDest.Finalize( oReader );
|
||||
|
||||
m_oRtfAnnotation.m_oContent = m_oParPropDest.m_oTextItems;
|
||||
}
|
||||
};
|
||||
class RtfDefParPropReader: public RtfAbstractReader
|
||||
{
|
||||
private:
|
||||
|
||||
@ -405,7 +405,8 @@ public:
|
||||
|
||||
if (Header.FormatID == 2)
|
||||
{
|
||||
if (Header.OLEVersion & 0x00000500)
|
||||
if (Header.OLEVersion & 0x00000500 ||
|
||||
Header.OLEVersion & 0x00010001)
|
||||
{
|
||||
stream >> Header.ClassName;
|
||||
}
|
||||
|
||||
@ -407,60 +407,63 @@ bool OOXShapeReader::ParseVmlChild( ReaderParameter oParam , RtfShapePtr& pOutpu
|
||||
WriteDataToPicture( sImagePath, *pOutput->m_oPicture, oParam.oReader->m_sTempFolder );
|
||||
}
|
||||
}
|
||||
int nCropedWidthGoal = pOutput->m_oPicture->m_nWidthGoal;
|
||||
if( PROP_DEF != nCropedWidthGoal )
|
||||
if (pOutput->m_oPicture)
|
||||
{
|
||||
//делаем crop
|
||||
if( image_data->m_oCropLeft.IsInit() )
|
||||
int nCropedWidthGoal = pOutput->m_oPicture->m_nWidthGoal;
|
||||
if( PROP_DEF != nCropedWidthGoal )
|
||||
{
|
||||
float nCropLeft = image_data->m_oCropLeft->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropL = nCropLeft * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropL = (int)(nCropLeft * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromLeft = (int)(nCropLeft * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropL;
|
||||
//делаем crop
|
||||
if( image_data->m_oCropLeft.IsInit() )
|
||||
{
|
||||
float nCropLeft = image_data->m_oCropLeft->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropL = nCropLeft * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropL = (int)(nCropLeft * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromLeft = (int)(nCropLeft * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropL;
|
||||
}
|
||||
if( image_data->m_oCropRight.IsInit())
|
||||
{
|
||||
float nCropRight =image_data->m_oCropRight->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropR = nCropRight * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropR = (int)(nCropRight * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromRight = (int)(nCropRight * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropR;
|
||||
}
|
||||
}
|
||||
if( image_data->m_oCropRight.IsInit())
|
||||
int nCropedHeightGoal = pOutput->m_oPicture->m_nHeightGoal;
|
||||
if( PROP_DEF != nCropedHeightGoal )
|
||||
{
|
||||
float nCropRight =image_data->m_oCropRight->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropR = nCropRight * pOutput->m_oPicture->m_nWidthGoal * pOutput->m_oPicture->m_nScaleX / 100;
|
||||
pOutput->m_oPicture->m_nCropR = (int)(nCropRight * pOutput->m_oPicture->m_nWidthGoal);
|
||||
pOutput->m_nCropFromRight = (int)(nCropRight * 65536);
|
||||
nCropedWidthGoal -= pOutput->m_oPicture->m_nCropR;
|
||||
if( image_data->m_oCropTop.IsInit() )
|
||||
{
|
||||
float nCropTop = image_data->m_oCropTop->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropT = (int)(nCropTop * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromTop = (int)(nCropTop * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropT;
|
||||
}
|
||||
if( image_data->m_oCropBottom.IsInit())
|
||||
{
|
||||
float nCropBottom = image_data->m_oCropBottom->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropB = (int)(nCropBottom * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromBottom = (int)(nCropBottom * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropB;
|
||||
}
|
||||
}
|
||||
}
|
||||
int nCropedHeightGoal = pOutput->m_oPicture->m_nHeightGoal;
|
||||
if( PROP_DEF != nCropedHeightGoal )
|
||||
{
|
||||
if( image_data->m_oCropTop.IsInit() )
|
||||
//устанавливаем scale
|
||||
if( PROP_DEF != pOutput->m_nLeft && PROP_DEF != pOutput->m_nRight && PROP_DEF != nCropedWidthGoal && 0 != nCropedWidthGoal )
|
||||
{
|
||||
float nCropTop = image_data->m_oCropTop->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropT = (int)(nCropTop * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromTop = (int)(nCropTop * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropT;
|
||||
int nWidth = pOutput->m_nRight - pOutput->m_nLeft;
|
||||
double dNewScale = 100 * ( 1.0 * nWidth / nCropedWidthGoal );
|
||||
pOutput->m_oPicture->m_dScaleX = dNewScale;
|
||||
}
|
||||
if( image_data->m_oCropBottom.IsInit())
|
||||
if( PROP_DEF != pOutput->m_nTop && PROP_DEF != pOutput->m_nBottom && PROP_DEF != nCropedHeightGoal && 0 != nCropedHeightGoal )
|
||||
{
|
||||
float nCropBottom = image_data->m_oCropBottom->GetValue();
|
||||
//pOutput->m_oPicture->m_nCropT = nCropTop * pOutput->m_oPicture->m_nHeightGoal * pOutput->m_oPicture->m_dScaleY / 100;
|
||||
pOutput->m_oPicture->m_nCropB = (int)(nCropBottom * pOutput->m_oPicture->m_nHeightGoal);
|
||||
pOutput->m_nCropFromBottom = (int)(nCropBottom * 65536);
|
||||
nCropedHeightGoal -= pOutput->m_oPicture->m_nCropB;
|
||||
int nHeight = pOutput->m_nBottom - pOutput->m_nTop;
|
||||
double dNewScale = 100 * ( 1.0 * nHeight / nCropedHeightGoal );
|
||||
pOutput->m_oPicture->m_dScaleY = dNewScale;
|
||||
}
|
||||
}
|
||||
//устанавливаем scale
|
||||
if( PROP_DEF != pOutput->m_nLeft && PROP_DEF != pOutput->m_nRight && PROP_DEF != nCropedWidthGoal && 0 != nCropedWidthGoal )
|
||||
{
|
||||
int nWidth = pOutput->m_nRight - pOutput->m_nLeft;
|
||||
double dNewScale = 100 * ( 1.0 * nWidth / nCropedWidthGoal );
|
||||
pOutput->m_oPicture->m_dScaleX = dNewScale;
|
||||
}
|
||||
if( PROP_DEF != pOutput->m_nTop && PROP_DEF != pOutput->m_nBottom && PROP_DEF != nCropedHeightGoal && 0 != nCropedHeightGoal )
|
||||
{
|
||||
int nHeight = pOutput->m_nBottom - pOutput->m_nTop;
|
||||
double dNewScale = 100 * ( 1.0 * nHeight / nCropedHeightGoal );
|
||||
pOutput->m_oPicture->m_dScaleY = dNewScale;
|
||||
}
|
||||
}break;
|
||||
case OOX::et_wd_wrap:
|
||||
{
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include "Writer/OOXWriter.h"
|
||||
#include "Writer/OOXFootnoteWriter.h"
|
||||
#include "Writer/OOXCommentsWriter.h"
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
@ -56,11 +57,10 @@ std::wstring RtfBookmarkStart::RenderToRtf(RenderParameter oRenderParameter)
|
||||
std::wstring RtfBookmarkStart::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
std::wstring sResult;
|
||||
//ATLASSERT( false == m_sName.empty() );
|
||||
sResult += L"<w:bookmarkStart";
|
||||
|
||||
OOXWriter * poOOXWriter = static_cast<OOXWriter*> ( oRenderParameter.poWriter );
|
||||
RtfDocument * poDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
|
||||
RtfDocument * poDocument = static_cast<RtfDocument*> ( oRenderParameter.poDocument );
|
||||
|
||||
std::map<std::wstring, int>::iterator pPair = poOOXWriter->m_aBookmarksId.find( m_sName );
|
||||
|
||||
@ -118,6 +118,115 @@ std::wstring RtfBookmarkEnd::RenderToOOX(RenderParameter oRenderParameter)
|
||||
sResult += L"/>";
|
||||
return sResult;
|
||||
}
|
||||
|
||||
std::wstring RtfAnnotElem::RenderToRtf(RenderParameter oRenderParameter)
|
||||
{
|
||||
std::wstring sResult;
|
||||
|
||||
if (m_nType == 1) sResult += L"{\\*\\atrfstart " + m_sValue + L"}";
|
||||
else if (m_nType = 2) sResult += L"{\\*\\atrfend " + m_sValue + L"}";
|
||||
else if (m_nType = 3) sResult += L"{\\*\\atnref " + m_sValue + L"}";
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
std::wstring RtfAnnotElem::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
if (m_nType > 8 || m_nType < 1) return L"";
|
||||
|
||||
std::wstring sResult;
|
||||
|
||||
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
|
||||
OOXCommentsWriter* poCommentsWriter = static_cast<OOXCommentsWriter*>( poOOXWriter->m_poCommentsWriter );
|
||||
|
||||
if (m_nType == 4)
|
||||
{
|
||||
poCommentsWriter->AddCommentAuthor(m_sValue);
|
||||
}
|
||||
else if (m_nType == 5)
|
||||
{
|
||||
poCommentsWriter->AddCommentID(m_sValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<std::wstring,OOXCommentsWriter::_comment>::iterator pFind = poCommentsWriter->m_mapComments.find(m_sValue);
|
||||
|
||||
int id = -1;
|
||||
if (pFind == poCommentsWriter->m_mapComments.end())
|
||||
{
|
||||
id = poCommentsWriter->m_mapComments.size() ;//+ 1;
|
||||
poCommentsWriter->AddComment(m_sValue, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = pFind->second.nID;
|
||||
}
|
||||
if (m_nType == 1)
|
||||
{
|
||||
sResult += L"<w:commentRangeStart w:id=\"" + std::to_wstring(id) + L"\"/>";
|
||||
}
|
||||
else if (m_nType == 3)
|
||||
{
|
||||
sResult += L"<w:commentReference w:id=\"" + std::to_wstring(id) + L"\"/>";
|
||||
}
|
||||
else if (m_nType == 2)
|
||||
{
|
||||
poCommentsWriter->SetCommentEnd(m_sValue);
|
||||
|
||||
sResult += L"<w:commentRangeEnd w:id=\"" + std::to_wstring(id) + L"\"/>";
|
||||
sResult += L"<w:r><w:commentReference w:id=\"" + std::to_wstring(id) + L"\"/></w:r>";
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
}
|
||||
|
||||
std::wstring RtfAnnotation::RenderToRtf(RenderParameter oRenderParameter)
|
||||
{
|
||||
std::wstring sResult;
|
||||
|
||||
if (m_oRef)
|
||||
{
|
||||
if (m_oRef->m_nType == 1) sResult += L"{\\*\\atrfstart " + m_oRef->m_sValue + L"}";
|
||||
else if (m_oRef->m_nType = 2) sResult += L"{\\*\\atrfend " + m_oRef->m_sValue + L"}";
|
||||
else if (m_oRef->m_nType = 3) sResult += L"{\\*\\atnref " + m_oRef->m_sValue + L"}";
|
||||
}
|
||||
return sResult;
|
||||
}
|
||||
|
||||
std::wstring RtfAnnotation::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
|
||||
OOXCommentsWriter* poCommentsWriter = static_cast<OOXCommentsWriter*>( poOOXWriter->m_poCommentsWriter );
|
||||
|
||||
if (!m_oRef) return L"";
|
||||
|
||||
if (m_oDate)
|
||||
{
|
||||
int nValue = boost::lexical_cast<int>(m_oDate->m_sValue);
|
||||
|
||||
poCommentsWriter->AddCommentDate(m_oRef->m_sValue, RtfUtility::convertDateTime(nValue));
|
||||
}
|
||||
if (m_oContent)
|
||||
{
|
||||
RenderParameter oNewParameter = oRenderParameter;
|
||||
|
||||
oNewParameter.nType = RENDER_TO_OOX_PARAM_COMMENT;
|
||||
oNewParameter.poRels = poCommentsWriter->m_oRelsWriter.get();
|
||||
|
||||
std::wstring content = m_oContent->RenderToOOX(oNewParameter);
|
||||
|
||||
std::wstring sParaId = XmlUtils::IntToString(poOOXWriter->m_nextParaId, L"%08X");//last para id in comment
|
||||
|
||||
poCommentsWriter->AddCommentContent(m_oRef->m_sValue, sParaId, content);
|
||||
}
|
||||
if (m_oParent)
|
||||
{
|
||||
poCommentsWriter->AddCommentParent(m_oRef->m_sValue, m_oParent->m_sValue);
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring RtfFootnote::RenderToRtf(RenderParameter oRenderParameter)
|
||||
{
|
||||
std::wstring sResult;
|
||||
@ -147,9 +256,11 @@ std::wstring RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
int nID = poDocument->m_oIdGenerator.Generate_EndnoteNumber();
|
||||
OOXEndnoteWriter* poEndnoteWriter = static_cast<OOXEndnoteWriter*>( poOOXWriter->m_poEndnoteWriter );
|
||||
|
||||
RenderParameter oNewParameter = oRenderParameter;
|
||||
oNewParameter.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
|
||||
oNewParameter.poRels = poEndnoteWriter->m_oRelsWriter.get();
|
||||
|
||||
poEndnoteWriter->AddEndnote( L"", nID, m_oContent->RenderToOOX(oNewParameter) );
|
||||
|
||||
sResult += L"<w:r>";
|
||||
|
||||
@ -64,6 +64,48 @@ public:
|
||||
std::wstring RenderToRtf(RenderParameter oRenderParameter);
|
||||
std::wstring RenderToOOX(RenderParameter oRenderParameter);
|
||||
};
|
||||
|
||||
class RtfAnnotElem : public IDocumentElement
|
||||
{
|
||||
public:
|
||||
std::wstring m_sValue;
|
||||
int m_nType;
|
||||
|
||||
RtfAnnotElem(int type = 0) : m_nType (type)
|
||||
{
|
||||
}
|
||||
int GetType()
|
||||
{
|
||||
return TYPE_RTF_ANNOTVALUE;
|
||||
}
|
||||
std::wstring RenderToRtf(RenderParameter oRenderParameter);
|
||||
std::wstring RenderToOOX(RenderParameter oRenderParameter);
|
||||
};
|
||||
typedef boost::shared_ptr<RtfAnnotElem> RtfAnnotElemPtr;
|
||||
|
||||
class RtfAnnotation : public IDocumentElement
|
||||
{
|
||||
public:
|
||||
RtfAnnotElemPtr m_oRef;
|
||||
RtfAnnotElemPtr m_oDate;
|
||||
RtfAnnotElemPtr m_oParent;
|
||||
|
||||
TextItemContainerPtr m_oContent;
|
||||
RtfCharProperty m_oCharProp;
|
||||
|
||||
RtfAnnotation()
|
||||
{
|
||||
m_oContent = TextItemContainerPtr( new TextItemContainer() );
|
||||
}
|
||||
int GetType()
|
||||
{
|
||||
return TYPE_RTF_ANNOTATION;
|
||||
}
|
||||
std::wstring RenderToRtf(RenderParameter oRenderParameter);
|
||||
std::wstring RenderToOOX(RenderParameter oRenderParameter);
|
||||
};
|
||||
typedef boost::shared_ptr<RtfAnnotation> RtfAnnotationPtr;
|
||||
|
||||
class RtfFootnote : public IDocumentElement
|
||||
{
|
||||
public:
|
||||
|
||||
@ -40,7 +40,7 @@ std::wstring RtfChar::RenderToOOX(RenderParameter oRenderParameter)
|
||||
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
|
||||
|
||||
std::wstring sResult;
|
||||
if (RENDER_TO_OOX_PARAM_RUN == oRenderParameter.nType)
|
||||
if (RENDER_TO_OOX_PARAM_RUN == oRenderParameter.nType)
|
||||
{
|
||||
bool bInsert = false;
|
||||
bool bDelete = false;
|
||||
@ -69,6 +69,7 @@ std::wstring RtfChar::RenderToOOX(RenderParameter oRenderParameter)
|
||||
sResult += L"<w:rPr>";
|
||||
sResult += m_oProperty.RenderToOOX(oRenderParameter);
|
||||
sResult += L"</w:rPr>";
|
||||
|
||||
sResult += renderTextToXML(L"Text", bDelete );
|
||||
sResult += L"</w:r>";
|
||||
|
||||
|
||||
@ -82,6 +82,11 @@ const long g_cdMaxPercent = 1000000;
|
||||
|
||||
#define TYPE_RTF_FOOTNOTE 30
|
||||
|
||||
#define TYPE_RTF_ANNOTSTART 31
|
||||
#define TYPE_RTF_ANNOTEND 32
|
||||
#define TYPE_RTF_ANNOTVALUE 33
|
||||
#define TYPE_RTF_ANNOTATION 34
|
||||
|
||||
#define RENDER_TO_OOX_PARAM_UNKNOWN 0
|
||||
#define RENDER_TO_OOX_PARAM_LAST 1
|
||||
#define RENDER_TO_OOX_PARAM_RUN 2
|
||||
@ -107,6 +112,7 @@ const long g_cdMaxPercent = 1000000;
|
||||
#define RENDER_TO_OOX_PARAM_OLE_ONLY 25
|
||||
#define RENDER_TO_OOX_PARAM_OLDLIST_ABS 26
|
||||
#define RENDER_TO_OOX_PARAM_OLDLIST_OVR 27
|
||||
#define RENDER_TO_OOX_PARAM_COMMENT 28
|
||||
|
||||
#define RENDER_TO_RTF_PARAM_UNKNOWN 0
|
||||
#define RENDER_TO_RTF_PARAM_CHAR 1
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
#include "RtfParagraph.h"
|
||||
#include "RtfWriter.h"
|
||||
|
||||
#include "Writer/OOXWriter.h"
|
||||
|
||||
int RtfParagraph::AddItem( IDocumentElementPtr piRend )
|
||||
{
|
||||
if( TYPE_RTF_CHAR == piRend->GetType() )
|
||||
@ -85,7 +87,11 @@ std::wstring RtfParagraph::RenderToRtf(RenderParameter oRenderParameter)
|
||||
|
||||
std::wstring RtfParagraph::RenderToOOX(RenderParameter oRenderParameter)
|
||||
{
|
||||
std::wstring sResult ;
|
||||
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
|
||||
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
|
||||
|
||||
std::wstring sResult ;
|
||||
|
||||
if( RENDER_TO_OOX_PARAM_PLAIN == oRenderParameter.nType )
|
||||
{
|
||||
for (size_t i = 0; i < m_aArray.size(); i++ )
|
||||
@ -125,11 +131,33 @@ std::wstring RtfParagraph::RenderToOOX(RenderParameter oRenderParameter)
|
||||
if( NULL != m_oOldList )
|
||||
bCanConvertToNumbering = m_oOldList->CanConvertToNumbering();
|
||||
|
||||
sResult += L"<w:p>";
|
||||
std::wstring sParaId = XmlUtils::IntToString(++poOOXWriter->m_nextParaId, L"%08X");
|
||||
sResult += L"<w:p w14:paraId=\"" + sParaId + L"\" w14:textId=\"" + sParaId + L"\">";
|
||||
sResult += L"<w:pPr>";
|
||||
|
||||
m_oProperty.m_bOldList = (NULL != m_oOldList);
|
||||
sResult += m_oProperty.RenderToOOX(oRenderParameter);
|
||||
|
||||
bool bRenderProps = false;
|
||||
if ( PROP_DEF != m_oProperty.m_nTableStyle && m_oProperty.m_bInTable > 0)
|
||||
{
|
||||
RtfStylePtr oCurStyle;
|
||||
if( true == poRtfDocument->m_oStyleTable.GetStyle( m_oProperty.m_nTableStyle, oCurStyle ) )
|
||||
{
|
||||
RtfParagraphStyle* oCurParaStyle = dynamic_cast<RtfParagraphStyle*>(oCurStyle.get());
|
||||
|
||||
if (oCurParaStyle)
|
||||
{
|
||||
RtfParagraphProperty newProps;
|
||||
newProps.Merge(oCurParaStyle->m_oParProp);
|
||||
newProps.Merge(m_oProperty);
|
||||
|
||||
sResult += newProps.RenderToOOX(oRenderParameter);
|
||||
bRenderProps = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == bRenderProps)
|
||||
sResult += m_oProperty.RenderToOOX(oRenderParameter);
|
||||
|
||||
if( NULL != m_oOldList )
|
||||
{
|
||||
@ -162,7 +190,15 @@ std::wstring RtfParagraph::RenderToOOX(RenderParameter oRenderParameter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oRenderParameter.nType == RENDER_TO_OOX_PARAM_COMMENT)
|
||||
{
|
||||
sResult += L"<w:r>";
|
||||
sResult += L"<w:rPr>";
|
||||
sResult += m_oProperty.m_oCharProperty.RenderToOOX(oRenderParameter);
|
||||
sResult += L"</w:rPr>";
|
||||
sResult += L"<w:annotationRef/>";
|
||||
sResult += L"</w:r>";
|
||||
}
|
||||
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
|
||||
|
||||
std::wstring ParagraphContent;
|
||||
|
||||
@ -877,8 +877,29 @@ std::wstring RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderP
|
||||
sContent += L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n";
|
||||
sContent += L"<";
|
||||
sContent += sRootName;
|
||||
sContent += L" xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\">";
|
||||
|
||||
sContent += L" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se wp14\">";
|
||||
|
||||
RenderParameter oNewParameter = oRenderParameter;
|
||||
|
||||
OOXRelsWriterPtr oNewRelsWr ( new OOXRelsWriter( sFilename, *poRtfDocument ) );
|
||||
|
||||
@ -271,7 +271,7 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
|
||||
|
||||
sResult += m_oCharProperty.RenderToRtf( oRenderParameter );
|
||||
|
||||
if (m_bIsOle)
|
||||
if (m_bIsOle && m_oPicture)
|
||||
{
|
||||
m_oPicture->dump_shape_properties = RenderToRtfShapeProperty( oRenderParameter );
|
||||
sResult += m_oPicture->RenderToRtf( oRenderParameter );
|
||||
@ -1143,9 +1143,8 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
|
||||
|
||||
if( PROP_DEF != m_nZOrderRelative && PROP_DEF != nZIndex)
|
||||
{
|
||||
//берем большое значение чтобы сделать строго выше или ниже текста
|
||||
if( 0 == m_nZOrderRelative ) nZIndex += 10000;
|
||||
else nZIndex -= 10000;
|
||||
if( 0 == m_nZOrderRelative ) nZIndex = abs(nZIndex);
|
||||
else nZIndex = -abs(nZIndex);
|
||||
}
|
||||
if (PROP_DEF != nZIndex)
|
||||
sStyle += L"z-index:" + std::to_wstring(nZIndex) + L";";
|
||||
|
||||
@ -455,30 +455,37 @@ public:
|
||||
}
|
||||
static int convertDateTime (std::wstring & dt_)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if ( dt_.empty() ) return PROP_DEF;
|
||||
|
||||
std::string dt(dt_.begin(), dt_.end());
|
||||
|
||||
boost::posix_time::ptime date_time_;
|
||||
try
|
||||
{
|
||||
boost::posix_time::ptime date_time_;
|
||||
|
||||
boost::posix_time::time_input_facet *tif = new boost::posix_time::time_input_facet;
|
||||
tif->set_iso_extended_format();
|
||||
std::istringstream strm(dt);
|
||||
strm.imbue(std::locale(std::locale::classic(), tif));
|
||||
strm >> date_time_;
|
||||
boost::posix_time::time_input_facet *tif = new boost::posix_time::time_input_facet;
|
||||
tif->set_iso_extended_format();
|
||||
std::istringstream strm(dt);
|
||||
strm.imbue(std::locale(std::locale::classic(), tif));
|
||||
strm >> date_time_;
|
||||
|
||||
short Min = date_time_.time_of_day().minutes();
|
||||
short Hour = date_time_.time_of_day().hours();
|
||||
short Day = date_time_.date().day();
|
||||
short Month = date_time_.date().month().as_number();
|
||||
int Year = date_time_.date().year() - 1900;
|
||||
short Min = date_time_.time_of_day().minutes();
|
||||
short Hour = date_time_.time_of_day().hours();
|
||||
short Day = date_time_.date().day();
|
||||
short Month = date_time_.date().month().as_number();
|
||||
int Year = date_time_.date().year() - 1900;
|
||||
|
||||
int result = 0;
|
||||
SETBITS(result, 0 , 5, Min);
|
||||
SETBITS(result, 6 , 10, Hour);
|
||||
SETBITS(result, 11, 15, Day);
|
||||
SETBITS(result, 16, 19, Month);
|
||||
SETBITS(result, 20, 28, Year);
|
||||
SETBITS(result, 0 , 5, Min);
|
||||
SETBITS(result, 6 , 10, Hour);
|
||||
SETBITS(result, 11, 15, Day);
|
||||
SETBITS(result, 16, 19, Month);
|
||||
SETBITS(result, 20, 28, Year);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
236
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXCommentsWriter.h
Normal file
236
ASCOfficeRtfFile/RtfFormatLib/source/Writer/OOXCommentsWriter.h
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2018
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "OOXWriter.h"
|
||||
|
||||
class OOXCommentsWriter
|
||||
{
|
||||
public:
|
||||
OOXRelsWriterPtr m_oRelsWriter;
|
||||
|
||||
OOXCommentsWriter( OOXWriter& oWriter, RtfDocument& oDocument ) : m_oWriter(oWriter), m_oDocument(oDocument)
|
||||
{
|
||||
m_oRelsWriter = OOXRelsWriterPtr( new OOXRelsWriter( _T("comments.xml"), oDocument ) );
|
||||
oWriter.m_oCustomRelsWriter.push_back( m_oRelsWriter );
|
||||
}
|
||||
void SetCommentEnd(const std::wstring & ref) //for author
|
||||
{
|
||||
m_sCurrent_ref = ref;
|
||||
}
|
||||
void AddComment( const std::wstring & ref, int nID)
|
||||
{
|
||||
_comment comment(nID);
|
||||
m_mapComments.insert(std::make_pair(ref, comment));
|
||||
}
|
||||
void AddCommentID( const std::wstring & id)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(m_sCurrent_ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.authorId = id;
|
||||
}
|
||||
}
|
||||
void AddCommentAuthor( const std::wstring & author)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(m_sCurrent_ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.author = author;
|
||||
}
|
||||
}
|
||||
void AddCommentContent( const std::wstring & ref, const std::wstring & paraId, const std::wstring & content)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.content = content;
|
||||
pFind->second.paraId = paraId;
|
||||
|
||||
m_mapCommentsParent.insert(std::make_pair(pFind->second.nID, paraId));
|
||||
}
|
||||
}
|
||||
void AddCommentParent( const std::wstring & ref, const std::wstring & parent)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.nParentID = boost::lexical_cast<int>(parent);
|
||||
}
|
||||
}
|
||||
void AddCommentDate( const std::wstring & ref, const std::wstring & date)
|
||||
{
|
||||
std::map<std::wstring, _comment>::iterator pFind = m_mapComments.find(ref);
|
||||
|
||||
if (pFind != m_mapComments.end())
|
||||
{
|
||||
pFind->second.date = date;
|
||||
}
|
||||
}
|
||||
bool Save( std::wstring sFolder )
|
||||
{
|
||||
if( m_mapComments.empty() ) return false;
|
||||
|
||||
CFile file;
|
||||
if (file.CreateFile(sFolder + FILE_SEPARATOR_STR + _T("comments.xml"))) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"), _T("comments.xml") );
|
||||
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"), _T("/word/comments.xml") );
|
||||
|
||||
std::wstring sXml = CreateXml();
|
||||
|
||||
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
if (file.CreateFile(sFolder + FILE_SEPARATOR_STR + L"commentsExtended.xml")) return false;
|
||||
|
||||
m_oWriter.m_oDocRels.AddRelationship( L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml" );
|
||||
m_oWriter.m_oContentTypes.AddContent( L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word/commentsExtended.xml" );
|
||||
|
||||
sXml = CreateXmlExtended();
|
||||
|
||||
sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
|
||||
|
||||
file.WriteFile((void*)sXmlUTF.c_str(), (DWORD)sXmlUTF.length());
|
||||
|
||||
file.CloseFile();
|
||||
return true;
|
||||
}
|
||||
struct _comment
|
||||
{
|
||||
_comment(int id) : nID(id) {}
|
||||
int nID = 0;
|
||||
int nParentID = 0;
|
||||
std::wstring author;
|
||||
std::wstring date;
|
||||
std::wstring content;
|
||||
std::wstring authorId;
|
||||
std::wstring paraId;
|
||||
|
||||
};
|
||||
std::map<std::wstring, _comment> m_mapComments;
|
||||
private:
|
||||
RtfDocument& m_oDocument;
|
||||
OOXWriter& m_oWriter;
|
||||
|
||||
std::wstring m_sCurrent_ref;
|
||||
std::wstring m_sCommentsExtended;
|
||||
std::map<int, std::wstring> m_mapCommentsParent;
|
||||
|
||||
std::wstring CreateXml()
|
||||
{
|
||||
std::wstring sResult = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
sResult += L"<w:comments \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 wp14\">";
|
||||
|
||||
for (std::map<std::wstring, _comment>::iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
|
||||
{
|
||||
sResult += L"<w:comment w:id=\"" + std::to_wstring(it->second.nID) + L"\" w:author=\"" +
|
||||
it->second.author + L"\" w:date=\"" + it->second.date + L"\" w:initials=\"" + it->second.authorId + L"\">";
|
||||
sResult += it->second.content;
|
||||
|
||||
sResult += L"</w:comment>";
|
||||
//--------------------------------------------------------
|
||||
m_sCommentsExtended += L"<w15:commentEx w15:paraId=\"" + it->second.paraId + L"\"";
|
||||
if (it->second.nParentID != 0)
|
||||
{
|
||||
it->second.nParentID = it->second.nID + it->second.nParentID;
|
||||
|
||||
std::map<int, std::wstring>::iterator pFind = m_mapCommentsParent.find(it->second.nParentID);
|
||||
|
||||
if (pFind != m_mapCommentsParent.end())
|
||||
{
|
||||
m_sCommentsExtended += L" w15:paraIdParent=\"" + pFind->second + L"\"";
|
||||
}
|
||||
}
|
||||
m_sCommentsExtended += L" w15:done=\"0\"/>";
|
||||
|
||||
}
|
||||
sResult += L"</w:comments>";
|
||||
return sResult;
|
||||
}
|
||||
std::wstring CreateXmlExtended()
|
||||
{
|
||||
std::wstring sResult;
|
||||
sResult += L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
|
||||
sResult += L"<w15:commentsEx \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se wp14\">";
|
||||
sResult += m_sCommentsExtended;
|
||||
sResult += L"</w15:commentsEx>";
|
||||
return sResult;
|
||||
}
|
||||
|
||||
};
|
||||
@ -51,16 +51,28 @@ std::wstring OOXDocumentWriter::CreateXmlStart()
|
||||
|
||||
//пишем document.xml
|
||||
std::wstring sResult = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n";
|
||||
sResult += L"<w:document";
|
||||
sResult += L" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"";
|
||||
sResult += L" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"";
|
||||
sResult += L" xmlns:v=\"urn:schemas-microsoft-com:vml\"";
|
||||
sResult += L" xmlns:o=\"urn:schemas-microsoft-com:office:office\"";
|
||||
sResult += L" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\"";
|
||||
sResult += L" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"";
|
||||
sResult += L" xmlns:w10=\"urn:schemas-microsoft-com:office:word\"";
|
||||
sResult += L" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"";
|
||||
sResult += L">";
|
||||
sResult += L"<w:document \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
|
||||
xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" \
|
||||
xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" \
|
||||
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" \
|
||||
xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 w15 w16se wp14\">";
|
||||
|
||||
if (m_oDocument.m_pBackground)
|
||||
{
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include "OOXSettingsWriter.h"
|
||||
#include "OOXThemeWriter.h"
|
||||
#include "OOXFootnoteWriter.h"
|
||||
#include "OOXCommentsWriter.h"
|
||||
|
||||
#include "../../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
|
||||
#include "../../../../Common/DocxFormat/Source/DocxFormat/App.h"
|
||||
@ -53,11 +54,13 @@ OOXWriter::OOXWriter( RtfDocument& oDocument, std::wstring sPath ) :
|
||||
m_sTargetFolder ( sPath.c_str() ),
|
||||
m_oRels ( L"", oDocument ),
|
||||
m_nCurTrackChangesId( 0),
|
||||
m_nextParaId ( 0x77000000),
|
||||
m_oDocRels ( L"document.xml", oDocument )
|
||||
{
|
||||
m_nCurFitWidth = PROP_DEF;
|
||||
m_poFootnoteWriter = NULL;
|
||||
m_poEndnoteWriter = NULL;
|
||||
m_poCommentsWriter = NULL;
|
||||
|
||||
m_poDocumentWriter = new OOXDocumentWriter ( *this, m_oDocument );
|
||||
m_poFootnoteWriter = new OOXFootnoteWriter ( *this, m_oDocument );
|
||||
@ -66,6 +69,7 @@ OOXWriter::OOXWriter( RtfDocument& oDocument, std::wstring sPath ) :
|
||||
m_poNumberingWriter = new OOXNumberingWriter( *this, m_oDocument );
|
||||
m_poSettingsWriter = new OOXSettingsWriter ( *this, m_oDocument );
|
||||
m_poStylesWriter = new OOXStylesWriter ( *this, m_oDocument );
|
||||
m_poCommentsWriter = new OOXCommentsWriter ( *this, m_oDocument );
|
||||
|
||||
m_poDocPropsApp = new OOX::CApp(NULL);
|
||||
m_poDocPropsCore = new OOX::CCore(NULL);
|
||||
@ -88,6 +92,7 @@ OOXWriter::OOXWriter( RtfDocument& oDocument, std::wstring sPath ) :
|
||||
}
|
||||
OOXWriter::~OOXWriter()
|
||||
{
|
||||
delete ((OOXCommentsWriter*) m_poCommentsWriter);
|
||||
delete ((OOXDocumentWriter*) m_poDocumentWriter);
|
||||
delete ((OOXFootnoteWriter*) m_poFootnoteWriter);
|
||||
delete ((OOXEndnoteWriter*) m_poEndnoteWriter);
|
||||
@ -142,10 +147,11 @@ bool OOXWriter::SaveByItemEnd()
|
||||
|
||||
((OOXFootnoteWriter*) m_poFootnoteWriter)->Save (pathWord.GetPath());
|
||||
((OOXEndnoteWriter*) m_poEndnoteWriter)->Save (pathWord.GetPath());
|
||||
((OOXCommentsWriter*) m_poCommentsWriter)->Save (pathWord.GetPath());
|
||||
((OOXNumberingWriter*) m_poNumberingWriter)->Save (m_sTargetFolder);
|
||||
((OOXStylesWriter*) m_poStylesWriter)->Save (m_sTargetFolder);
|
||||
((OOXFontTableWriter*) m_poFontTableWriter)->Save (m_sTargetFolder);
|
||||
|
||||
|
||||
((OOXSettingsWriter*) m_poSettingsWriter)->Save (m_sTargetFolder); //setting в последнюю очередь
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
@ -44,6 +44,8 @@ public:
|
||||
int m_nCurFitWidth;
|
||||
int m_nCurTrackChangesId;
|
||||
|
||||
long int m_nextParaId;
|
||||
|
||||
OOXRelsWriter m_oDocRels;
|
||||
OOXRelsWriter m_oRels;
|
||||
|
||||
@ -57,6 +59,7 @@ public:
|
||||
void* m_poNumberingWriter;
|
||||
void* m_poSettingsWriter;
|
||||
void* m_poStylesWriter;
|
||||
void* m_poCommentsWriter;
|
||||
|
||||
void* m_poDocPropsApp;
|
||||
void* m_poDocPropsCore;
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
|
||||
@ -39,6 +39,8 @@
|
||||
#include "../Biff_records/XCT.h"
|
||||
#include "../Biff_records/CRN.h"
|
||||
|
||||
#include "../../../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
@ -310,7 +312,7 @@ int SUPBOOK::serialize_book(std::wostream & strm)
|
||||
}
|
||||
CP_XML_NODE(L"v")
|
||||
{
|
||||
CP_XML_STREAM() << strVal;
|
||||
CP_XML_STREAM() << XmlUtils::EncodeXmlString(strVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -331,9 +331,9 @@ namespace oox
|
||||
//case msosptWedgeEllipseCallout : return L"wedgeEllipseCallout";
|
||||
//case msosptWave : return L"wave";
|
||||
//case msosptFoldedCorner : return L"foldedCorner";
|
||||
//case msosptLeftArrow : return L"leftArrow";
|
||||
case msosptLeftArrow : return L"leftArrow";
|
||||
//case msosptDownArrow : return L"downArrow";
|
||||
//case msosptUpArrow : return L"upArrow";
|
||||
case msosptUpArrow : return L"upArrow";
|
||||
//case msosptLeftRightArrow : return L"leftRightArrow";
|
||||
//case msosptUpDownArrow : return L"upDownArrow";
|
||||
//case msosptIrregularSeal1 : return L"irregularSeal1";
|
||||
|
||||
73
Common/3dParty/curl/build.sh
Executable file
73
Common/3dParty/curl/build.sh
Executable file
@ -0,0 +1,73 @@
|
||||
SCRIPT=$(readlink -f "$0" || grealpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
os=$(uname -s)
|
||||
platform=""
|
||||
|
||||
case "$os" in
|
||||
Linux*)
|
||||
platform="linux"
|
||||
BUILD_PLATFORM=Linux
|
||||
;;
|
||||
Darwin*)
|
||||
platform="mac"
|
||||
BUILD_PLATFORM=MacOSX
|
||||
;;
|
||||
*) exit ;;
|
||||
esac
|
||||
|
||||
|
||||
architecture=$(uname -m)
|
||||
arch=""
|
||||
|
||||
case "$architecture" in
|
||||
x86_64*) arch="_64" ;;
|
||||
*) arch="_32" ;;
|
||||
esac
|
||||
|
||||
if [[ -d "$SCRIPTPATH/$platform$arch" ]]
|
||||
then
|
||||
echo
|
||||
else
|
||||
mkdir "$SCRIPTPATH/$platform$arch"
|
||||
fi
|
||||
|
||||
CURL_FOLDER=curl
|
||||
cd ${CURL_FOLDER}
|
||||
|
||||
if [[ ! -f configure ]]
|
||||
then
|
||||
./buildconf
|
||||
fi
|
||||
|
||||
if [[ ! -f Makefile ]]
|
||||
then
|
||||
./configure \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
--disable-ldap \
|
||||
--disable-sspi \
|
||||
--without-librtmp \
|
||||
--disable-ftp \
|
||||
--disable-file \
|
||||
--disable-dict \
|
||||
--disable-telnet \
|
||||
--disable-tftp \
|
||||
--disable-rtsp \
|
||||
--disable-pop3 \
|
||||
--disable-imap \
|
||||
--disable-smtp \
|
||||
--disable-gopher \
|
||||
--disable-smb \
|
||||
--without-libidn
|
||||
fi
|
||||
|
||||
make
|
||||
|
||||
if [ ! -d "$SCRIPTPATH/$platform$arch/build" ]
|
||||
then
|
||||
DESTDIR="$SCRIPTPATH/$platform$arch" make install
|
||||
mkdir -p "$SCRIPTPATH/$platform$arch/build"
|
||||
cp "$SCRIPTPATH/$platform$arch/usr/local/lib/libcurl.a" "$SCRIPTPATH/$platform$arch/build/"
|
||||
fi
|
||||
|
||||
5
Common/3dParty/curl/curl.pri
Normal file
5
Common/3dParty/curl/curl.pri
Normal file
@ -0,0 +1,5 @@
|
||||
core_linux {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
|
||||
|
||||
LIBS += -lcurl
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
SET SCRIPTPATH=%~dp0
|
||||
CD /D %~dp0
|
||||
|
||||
SET ICU_MAJOR_VER=60
|
||||
SET ICU_MAJOR_VER=58
|
||||
SET ICU_MINOR_VER=2
|
||||
|
||||
SET build_platform=win_32
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
SCRIPT=$(readlink -f "$0" || grealpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
ICU_MAJOR_VER=60
|
||||
ICU_MAJOR_VER=58
|
||||
ICU_MINOR_VER=2
|
||||
|
||||
SHARED_LIB_VER=$ICU_MAJOR_VER.$ICU_MINOR_VER
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
ICU_MAJOR_VER = 58
|
||||
|
||||
core_windows {
|
||||
message($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu/include)
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu/include
|
||||
@ -14,13 +16,13 @@ core_win_32 {
|
||||
core_linux {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.60
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.60
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.so.$$ICU_MAJOR_VER
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.so.$$ICU_MAJOR_VER
|
||||
}
|
||||
|
||||
core_mac {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/usr/local/include
|
||||
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.60.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.60.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
|
||||
@ -30,8 +30,8 @@ fi
|
||||
echo "$platform$arch"
|
||||
|
||||
if [ ! -f Makefile ]; then
|
||||
perl ./Configure $platform$arch
|
||||
./config
|
||||
#perl ./Configure $platform$arch
|
||||
./config no-shared no-asm
|
||||
fi
|
||||
|
||||
make
|
||||
|
||||
8
Common/3dParty/openssl/openssl.pri
Normal file
8
Common/3dParty/openssl/openssl.pri
Normal file
@ -0,0 +1,8 @@
|
||||
core_linux {
|
||||
|
||||
INCLUDEPATH += $$PWD/openssl/include
|
||||
|
||||
LIBS += -L$$PWD/openssl/libssl.a
|
||||
LIBS += -L$$PWD/openssl/libcrypto.a
|
||||
|
||||
}
|
||||
@ -1056,7 +1056,7 @@ namespace OOX
|
||||
std::vector<std::wstring> sAnchors;
|
||||
boost::algorithm::split(sAnchors, m_oAnchor.get(), boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
|
||||
|
||||
if (sAnchors.size() != 8) return; //???? todoooo
|
||||
if (sAnchors.size() < 8) return;
|
||||
|
||||
if (pCellAnchor == NULL)
|
||||
{
|
||||
|
||||
@ -368,7 +368,7 @@ namespace OOX
|
||||
sClientData += boost::lexical_cast<std::wstring>(comment->m_nRight.get()) + L",";
|
||||
sClientData += boost::lexical_cast<std::wstring>(comment->m_nRightOffset.get()) + L",";
|
||||
sClientData += boost::lexical_cast<std::wstring>(comment->m_nBottom.get()) + L",";
|
||||
sClientData += boost::lexical_cast<std::wstring>(comment->m_nBottomOffset.get()) + L",";
|
||||
sClientData += boost::lexical_cast<std::wstring>(comment->m_nBottomOffset.get());
|
||||
sClientData += L"</x:Anchor>";
|
||||
}
|
||||
sClientData += L"<x:AutoFill>False</x:AutoFill>";
|
||||
|
||||
@ -145,17 +145,15 @@ namespace OOX
|
||||
|
||||
int nCurDepth = oReader.GetDepth();
|
||||
|
||||
int index = 0;
|
||||
while( oReader.ReadNextSiblingNode( nCurDepth ) )
|
||||
{
|
||||
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
|
||||
|
||||
if ( _T("sheet") == sName )
|
||||
if ( _T("sheet") == sName )
|
||||
{
|
||||
CSheet* pSheet = new CSheet( oReader );
|
||||
|
||||
m_arrItems.push_back( pSheet );
|
||||
mapSheets.insert(std::make_pair(index++, pSheet));
|
||||
}
|
||||
|
||||
}
|
||||
@ -170,8 +168,6 @@ namespace OOX
|
||||
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
|
||||
{
|
||||
}
|
||||
public:
|
||||
std::map<int, OOX::Spreadsheet::CSheet*> mapSheets;
|
||||
};
|
||||
} //Spreadsheet
|
||||
} // namespace OOX
|
||||
|
||||
@ -251,7 +251,7 @@ namespace OOX
|
||||
pCommentItem->m_sGfxdata = pShape->m_sGfxData.get2();
|
||||
std::vector<int> m_aAnchor;
|
||||
pClientData->getAnchorArray(m_aAnchor);
|
||||
if(8 == m_aAnchor.size())
|
||||
if(8 <= m_aAnchor.size())
|
||||
{
|
||||
pCommentItem->m_nLeft = m_aAnchor[0];
|
||||
pCommentItem->m_nLeftOffset = m_aAnchor[1];
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "FileDownloader.h"
|
||||
#include "FileDownloader.h"
|
||||
|
||||
#if _IOS
|
||||
#import <Foundation/Foundation.h>
|
||||
@ -27,10 +27,13 @@ public :
|
||||
}
|
||||
|
||||
virtual int DownloadFile()
|
||||
{
|
||||
m_sFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
|
||||
if (NSFile::CFileBinary::Exists(m_sFilePath))
|
||||
NSFile::CFileBinary::Remove(m_sFilePath);
|
||||
{
|
||||
if (m_sFilePath.empty())
|
||||
{
|
||||
m_sFilePath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"DWD");
|
||||
if (NSFile::CFileBinary::Exists(m_sFilePath))
|
||||
NSFile::CFileBinary::Remove(m_sFilePath);
|
||||
}
|
||||
|
||||
NSString* stringURL = StringWToNSString(m_sFileUrl);
|
||||
NSURL *url = [NSURL URLWithString:stringURL];
|
||||
|
||||
@ -245,8 +245,14 @@ bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & fileName)
|
||||
bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring fileName = CorrectPathW(_fileName);
|
||||
#else
|
||||
std::wstring fileName = _fileName;
|
||||
#endif
|
||||
|
||||
//приоритет как оказывается важен
|
||||
//Metamorphic Manual for windows 28415.doc
|
||||
POLE::Storage storage(fileName.c_str());
|
||||
|
||||
@ -314,7 +314,8 @@ namespace NSDirectory
|
||||
static bool Exists(const std::wstring& strDirectory)
|
||||
{
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
DWORD dwAttrib = ::GetFileAttributesW(strDirectory.c_str());
|
||||
std::wstring strDirectoryW = CorrectPathW(strDirectory);
|
||||
DWORD dwAttrib = ::GetFileAttributesW(strDirectoryW.c_str());
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES && 0 != (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||
#elif __linux__
|
||||
BYTE* pUtf8 = NULL;
|
||||
|
||||
@ -43,6 +43,32 @@
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
|
||||
static std::wstring CorrectPathW(const std::wstring& path)
|
||||
{
|
||||
int len = (int)path.length();
|
||||
if (2 > len)
|
||||
return path;
|
||||
|
||||
const wchar_t* path_str = path.c_str();
|
||||
if (path_str[0] == '\\' || path_str[1] == '/')
|
||||
return path;
|
||||
|
||||
// local files: '\\?\' prefix
|
||||
// server files: '\\?\UNC\' prefix <== TODO!
|
||||
int nLen = GetFullPathNameW(path_str, 0, 0, 0);
|
||||
if (2 > nLen)
|
||||
return path;
|
||||
|
||||
wchar_t* pBuf = new wchar_t[nLen * sizeof(wchar_t)];
|
||||
GetFullPathNameW(path_str, nLen, pBuf, NULL);
|
||||
if (pBuf[0] == '\\' || pBuf[1] == '/')
|
||||
return path;
|
||||
|
||||
std::wstring retPath(pBuf);
|
||||
delete [] pBuf;
|
||||
return L"\\\\?\\" + retPath;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val.c_str(), (LONG)val.length())
|
||||
@ -629,7 +655,8 @@ namespace NSFile
|
||||
bool OpenFile(const std::wstring& sFileName, bool bRewrite = false)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileName.c_str(), bRewrite ? L"rb+" : L"rb"))
|
||||
std::wstring sFileNameW = CorrectPathW(sFileName);
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileNameW.c_str(), bRewrite ? L"rb+" : L"rb"))
|
||||
return false;
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
@ -668,8 +695,9 @@ namespace NSFile
|
||||
bool CreateFileW(const std::wstring& sFileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileName.c_str(), L"wb"))
|
||||
return false;
|
||||
std::wstring sFileNameW = CorrectPathW(sFileName);
|
||||
if ( 0 != _wfopen_s(&m_pFile, sFileNameW.c_str(), L"wb"))
|
||||
return false;
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -829,8 +857,9 @@ namespace NSFile
|
||||
static bool Exists(const std::wstring& strFileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring sFileNameW = CorrectPathW(strFileName);
|
||||
FILE* pFile = NULL;
|
||||
if ( 0 != _wfopen_s( &pFile, strFileName.c_str(), L"rb"))
|
||||
if ( 0 != _wfopen_s( &pFile, sFileNameW.c_str(), L"rb"))
|
||||
return false;
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
@ -879,8 +908,10 @@ namespace NSFile
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
src.open(strSrc.c_str(), std::ios::binary);
|
||||
dst.open(strDst.c_str(), std::ios::binary);
|
||||
std::wstring sS = CorrectPathW(strSrc);
|
||||
std::wstring sD = CorrectPathW(strDst);
|
||||
src.open(sS.c_str(), std::ios::binary);
|
||||
dst.open(sD.c_str(), std::ios::binary);
|
||||
#else
|
||||
BYTE* pUtf8Src = NULL;
|
||||
LONG lLenSrc = 0;
|
||||
@ -913,7 +944,8 @@ namespace NSFile
|
||||
static bool Remove(const std::wstring& strFileName)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
int nRes = _wremove(strFileName.c_str());
|
||||
std::wstring strFileNameW = CorrectPathW(strFileName);
|
||||
int nRes = _wremove(strFileNameW.c_str());
|
||||
#else
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -938,7 +970,8 @@ namespace NSFile
|
||||
bool bIsSuccess = false;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
HANDLE hFile = ::CreateFileW( sPath.c_str(), GENERIC_WRITE, FILE_SHARE_READ,
|
||||
std::wstring sPathW = CorrectPathW(sPath);
|
||||
HANDLE hFile = ::CreateFileW( sPathW.c_str(), GENERIC_WRITE, FILE_SHARE_READ,
|
||||
NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
if ( hFile == INVALID_HANDLE_VALUE )
|
||||
@ -1091,7 +1124,8 @@ namespace NSFile
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
FILE* pFile = NULL;
|
||||
_wfopen_s(&pFile, sFileName.c_str(), sMode.c_str());
|
||||
std::wstring sFileNameW = CorrectPathW(sFileName);
|
||||
_wfopen_s(&pFile, sFileNameW.c_str(), sMode.c_str());
|
||||
|
||||
return pFile;
|
||||
#else
|
||||
|
||||
@ -23,6 +23,7 @@ CONFIG += build_all_zlib build_zlib_as_sources
|
||||
include(../../OfficeUtils/OfficeUtils.pri)
|
||||
|
||||
include(../../Common/3dParty/v8/v8.pri)
|
||||
include(../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
SOURCES += \
|
||||
memorystream.cpp \
|
||||
@ -55,8 +56,6 @@ core_windows {
|
||||
core_linux {
|
||||
SOURCES += \
|
||||
../../Common/FileDownloader/FileDownloader_curl.cpp
|
||||
|
||||
LIBS += -lcurl
|
||||
}
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += \
|
||||
|
||||
@ -515,6 +515,9 @@ namespace MetaFile
|
||||
else //if (WINDING == unFillMode)
|
||||
unClipMode |= c_nClipRegionTypeWinding;
|
||||
|
||||
if (RGN_COPY == unMode)
|
||||
ResetClip();
|
||||
|
||||
m_pRenderer->put_ClipMode(unClipMode);
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
m_pRenderer->BeginCommand(c_nPathType);
|
||||
|
||||
@ -228,7 +228,7 @@ static const struct ActionNamesEmf
|
||||
//-----------------------------------------------------------
|
||||
// 2.3.2 Clipping
|
||||
//-----------------------------------------------------------
|
||||
case EMR_EXCLUDECLIPRECT: Read_EMR_EXCLUDECLIPRECT(); break;
|
||||
case EMR_EXCLUDECLIPRECT: Read_EMR_EXCLUDECLIPRECT(); break;
|
||||
case EMR_EXTSELECTCLIPRGN: Read_EMR_EXTSELECTCLIPRGN(); break;
|
||||
case EMR_INTERSECTCLIPRECT: Read_EMR_INTERSECTCLIPRECT(); break;
|
||||
case EMR_SELECTCLIPPATH: Read_EMR_SELECTCLIPPATH(); break;
|
||||
|
||||
@ -596,8 +596,8 @@ namespace MetaFile
|
||||
float fL = 0, fT = 0, fW = 0, fH = 0;
|
||||
pFontManager->LoadFontByName(wsFaceName, dFontHeight, lStyle, 72, 72);
|
||||
pFontManager->SetCharSpacing(GetCharSpace());
|
||||
double dFHeight = dFontHeight * pFontManager->m_pFont->GetHeight() / pFontManager->m_pFont->m_lUnits_Per_Em;
|
||||
double dFDescent = dFontHeight * pFontManager->m_pFont->GetDescender() / pFontManager->m_pFont->m_lUnits_Per_Em;
|
||||
double dFHeight = pFontManager->m_pFont ? (dFontHeight * pFontManager->m_pFont->GetHeight() / pFontManager->m_pFont->m_lUnits_Per_Em) : 0;
|
||||
double dFDescent = pFontManager->m_pFont ? (dFontHeight * pFontManager->m_pFont->GetDescender() / pFontManager->m_pFont->m_lUnits_Per_Em) : 0;
|
||||
double dFAscent = dFHeight - std::abs(dFDescent);
|
||||
|
||||
if (NULL != pDx && unCharsCount > 1)
|
||||
|
||||
@ -208,7 +208,8 @@ namespace XmlUtils
|
||||
|
||||
if ((XmlNodeType_Element == eNodeType && nCurDepth == nDepth + 1)
|
||||
|| ((XmlNodeType_Text == eNodeType ||
|
||||
XmlNodeType_Whitespace == eNodeType) && nCurDepth == nDepth + 1))
|
||||
XmlNodeType_Whitespace == eNodeType ||
|
||||
XmlNodeType_SIGNIFICANT_WHITESPACE == eNodeType ) && nCurDepth == nDepth + 1))
|
||||
return true;
|
||||
else if (XmlNodeType_EndElement == eNodeType && nCurDepth == nDepth)
|
||||
return false;
|
||||
@ -509,4 +510,4 @@ namespace XmlUtils
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_XMLLIGHT_PRIVATE_CROSSPLATFORM_H_
|
||||
#endif // _BUILD_XMLLIGHT_PRIVATE_CROSSPLATFORM_H_
|
||||
@ -8,6 +8,9 @@
|
||||
#define OOXML_HASH_ALG_SHA1 0
|
||||
#define OOXML_HASH_ALG_INVALID 1
|
||||
#define OOXML_HASH_ALG_SHA256 2
|
||||
#define OOXML_HASH_ALG_SHA224 3
|
||||
#define OOXML_HASH_ALG_SHA384 4
|
||||
#define OOXML_HASH_ALG_SHA512 5
|
||||
|
||||
#define OPEN_SSL_WARNING_OK 0
|
||||
#define OPEN_SSL_WARNING_ERR 1
|
||||
@ -15,31 +18,11 @@
|
||||
#define OPEN_SSL_WARNING_PASS 4
|
||||
#define OPEN_SSL_WARNING_NOVERIFY 8
|
||||
|
||||
class ICertificate;
|
||||
class Q_DECL_EXPORT ICertificateSelectDialogOpenSsl
|
||||
namespace NSOpenSSL
|
||||
{
|
||||
public:
|
||||
ICertificateSelectDialogOpenSsl()
|
||||
{
|
||||
}
|
||||
virtual ~ICertificateSelectDialogOpenSsl()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::wstring GetCertificatePath() = 0;
|
||||
virtual std::wstring GetCertificatePassword() = 0;
|
||||
|
||||
virtual std::wstring GetKeyPath() = 0;
|
||||
virtual std::wstring GetKeyPassword() = 0;
|
||||
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate(ICertificate* pCert) = 0;
|
||||
|
||||
static int LoadKey(std::wstring file, std::string password);
|
||||
static int LoadCert(std::wstring file, std::string password);
|
||||
static void SetOpenSslDialogApplication(ICertificateSelectDialogOpenSsl* pDialog);
|
||||
};
|
||||
Q_DECL_EXPORT int LoadKey(std::wstring file, std::string password);
|
||||
Q_DECL_EXPORT int LoadCert(std::wstring file, std::string password);
|
||||
}
|
||||
|
||||
class Q_DECL_EXPORT CCertificateInfo
|
||||
{
|
||||
@ -123,22 +106,30 @@ public:
|
||||
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg) = 0;
|
||||
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg) = 0;
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data) = 0;
|
||||
virtual bool LoadFromBase64Data(const std::string& data) = 0;
|
||||
|
||||
virtual std::vector<int> GetHashAlgs() = 0;
|
||||
virtual int GetHashAlg() = 0;
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
|
||||
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog) {}
|
||||
virtual int ShowSelectDialog(void* parent = NULL) = 0;
|
||||
virtual int ShowCertificate(void* parent = NULL) = 0;
|
||||
|
||||
static CCertificateInfo GetDefault();
|
||||
static ICertificate* GetById(const std::string& id);
|
||||
|
||||
virtual CCertificateInfo GetInfo();
|
||||
|
||||
virtual bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword);
|
||||
|
||||
public:
|
||||
static int GetOOXMLHashAlg(const std::string& sAlg);
|
||||
static ICertificate* CreateInstance();
|
||||
static std::string GetDigestMethodA(const int& nAlg);
|
||||
static std::wstring GetDigestMethod(const int& nAlg);
|
||||
static std::string GetSignatureMethodA(const int& nAlg);
|
||||
static std::wstring GetSignatureMethod(const int& nAlg);
|
||||
|
||||
static ICertificate* CreateInstance();
|
||||
};
|
||||
|
||||
#endif // _XML_SERTIFICATE_BASE_H_
|
||||
|
||||
@ -67,10 +67,6 @@ SOURCES += \
|
||||
|
||||
signature_openssl {
|
||||
|
||||
DEFINES += XMLSEC_OPENSSL_110
|
||||
INCLUDEPATH += $$CORE_ROOT_DIR/Common/3dParty/openssl/openssl/include
|
||||
|
||||
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lssl
|
||||
LIBS += -L$$CORE_ROOT_DIR/Common/3dParty/openssl/openssl -lcrypto
|
||||
include(../../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
}
|
||||
|
||||
@ -46,7 +46,9 @@ public:
|
||||
m_date = NSFile::CUtf8Converter::GetUnicodeFromCharPtr(date);
|
||||
|
||||
m_signed_info.WriteString("<CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/>");
|
||||
m_signed_info.WriteString("<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"/>");
|
||||
m_signed_info.WriteString("<SignatureMethod Algorithm=\"");
|
||||
m_signed_info.WriteString(ICertificate::GetSignatureMethodA(m_certificate->GetHashAlg()));
|
||||
m_signed_info.WriteString("\"/>");
|
||||
}
|
||||
~COOXMLSigner_private()
|
||||
{
|
||||
@ -55,9 +57,9 @@ public:
|
||||
std::wstring GetReference(const std::wstring& file, const std::wstring& content_type)
|
||||
{
|
||||
std::wstring sXml = L"<Reference URI=\"" + file + L"?ContentType=" + content_type + L"\">";
|
||||
sXml += L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>";
|
||||
sXml += (L"<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethod(m_certificate->GetHashAlg()) + L"\"/>");
|
||||
sXml += L"<DigestValue>";
|
||||
std::string sTmp = m_certificate->GetHash(m_sFolder + file, OOXML_HASH_ALG_SHA1);
|
||||
std::string sTmp = m_certificate->GetHash(m_sFolder + file, m_certificate->GetHashAlg());
|
||||
sXml += UTF8_TO_U(sTmp);
|
||||
sXml += L"</DigestValue>";
|
||||
sXml += L"</Reference>";
|
||||
@ -68,7 +70,7 @@ public:
|
||||
{
|
||||
std::string sXmlSigned = U_TO_UTF8(xml);
|
||||
sXmlSigned = CXmlCanonicalizator::Execute(sXmlSigned, XML_C14N_1_0);
|
||||
return m_certificate->GetHash(sXmlSigned, OOXML_HASH_ALG_SHA1);
|
||||
return m_certificate->GetHash(sXmlSigned, m_certificate->GetHashAlg());
|
||||
}
|
||||
|
||||
std::string GetReferenceMain(const std::wstring& xml, const std::wstring& id, const bool& isCannon = true)
|
||||
@ -87,7 +89,7 @@ public:
|
||||
if (isCannon)
|
||||
sRet = "<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>";
|
||||
|
||||
sRet += ("<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>" + sHash + "</DigestValue>");
|
||||
sRet += ("<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethodA(m_certificate->GetHashAlg()) + "\"/><DigestValue>" + sHash + "</DigestValue>");
|
||||
|
||||
return sRet;
|
||||
}
|
||||
@ -144,7 +146,7 @@ public:
|
||||
builder.WriteString(file);
|
||||
builder.WriteString(L"?ContentType=application/vnd.openxmlformats-package.relationships+xml\">");
|
||||
builder.WriteString(oRels.GetTransforms());
|
||||
builder.WriteString(L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>");
|
||||
builder.WriteString(L"<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethod(m_certificate->GetHashAlg()) + L"\"/><DigestValue>");
|
||||
|
||||
std::wstring sXml = oRels.GetXml();
|
||||
std::string sHash = GetHashXml(sXml);
|
||||
@ -489,13 +491,16 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
|
||||
std::string sKeyA = m_certificate->GetNumber();
|
||||
std::wstring sKey = UTF8_TO_U(sKeyA);
|
||||
|
||||
std::string sCertHA = m_certificate->GetCertificateHash();
|
||||
std::wstring sCertHW = UTF8_TO_U(sCertHA);
|
||||
|
||||
std::wstring sXml = (L"<xd:SignedSignatureProperties>\
|
||||
<xd:SigningTime>" + m_date + L"</xd:SigningTime>\
|
||||
<xd:SigningCertificate>\
|
||||
<xd:Cert>\
|
||||
<xd:CertDigest>\
|
||||
<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>\
|
||||
<DigestValue>MJJT2Y0iMxaPGVXBmOLb9bY60pA=</DigestValue>\
|
||||
<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethod(m_certificate->GetHashAlg()) + L"\"/>\
|
||||
<DigestValue>" + sCertHW + L"</DigestValue>\
|
||||
</xd:CertDigest>\
|
||||
<xd:IssuerSerial>\
|
||||
<X509IssuerName>CN=" + sName + L"</X509IssuerName>\
|
||||
@ -516,8 +521,8 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
|
||||
|
||||
m_signed_info.WriteString("<Reference Type=\"http://uri.etsi.org/01903#SignedProperties\" URI=\"#idSignedProperties\">");
|
||||
m_signed_info.WriteString("<Transforms><Transform Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\"/></Transforms>");
|
||||
m_signed_info.WriteString("<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/><DigestValue>");
|
||||
m_signed_info.WriteString(m_certificate->GetHash(sXmlTmp, OOXML_HASH_ALG_SHA1));
|
||||
m_signed_info.WriteString("<DigestMethod Algorithm=\"" + ICertificate::GetDigestMethodA(m_certificate->GetHashAlg()) + "\"/><DigestValue>");
|
||||
m_signed_info.WriteString(m_certificate->GetHash(sXmlTmp, m_certificate->GetHashAlg()));
|
||||
m_signed_info.WriteString("</DigestValue></Reference>");
|
||||
|
||||
return (L"<Object><xd:QualifyingProperties xmlns:xd=\"http://uri.etsi.org/01903/v1.3.2#\" Target=\"#idPackageSignature\">\
|
||||
|
||||
@ -252,7 +252,9 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
// 5) Check signature
|
||||
// 5) Check sert digest! (TODO:)
|
||||
|
||||
// 6) Check signature
|
||||
CXmlStackNamespaces stack(m_node);
|
||||
CXmlStackNamespaces stackRes = stack.GetById("SignedInfo", true);
|
||||
std::string sXml = stackRes.GetXml();
|
||||
@ -609,6 +611,8 @@ public:
|
||||
sFile = m_arSignaturesFiles.at(i);
|
||||
m_arSignatures.erase(m_arSignatures.begin() + i);
|
||||
delete pSignature;
|
||||
--i;
|
||||
--nCountSignatures;
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,6 +693,41 @@ public:
|
||||
sXml += L"</Relationships>";
|
||||
NSFile::CFileBinary::SaveToFile(m_sFolder + L"/_rels/.rels", sXml);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sFileFound = sFile.substr(m_sFolder.length());
|
||||
std::wstring::size_type posRemove = sFileFound.find(L"/_xmlsignatures/");
|
||||
if (std::wstring::npos != posRemove)
|
||||
sFileFound = sFileFound.substr(posRemove + 16);
|
||||
|
||||
std::wstring sOriginRels = m_sFolder + L"/_xmlsignatures/_rels/origin.sigs.rels";
|
||||
|
||||
XmlUtils::CXmlNode oRels;
|
||||
if (!oRels.FromXmlFile(sOriginRels))
|
||||
return;
|
||||
|
||||
sXml = L"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">";
|
||||
XmlUtils::CXmlNodes oNodes;
|
||||
if (oRels.GetNodes(L"*", oNodes))
|
||||
{
|
||||
int nCount = oNodes.GetCount();
|
||||
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode oNode;
|
||||
oNodes.GetAt(i, oNode);
|
||||
|
||||
if (L"Relationship" == oNode.GetName() &&
|
||||
L"http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature" == oNode.GetAttribute(L"Type") &&
|
||||
sFileFound == oNode.GetAttribute(L"Target"))
|
||||
continue;
|
||||
|
||||
sXml += oNode.GetXml();
|
||||
}
|
||||
}
|
||||
sXml += L"</Relationships>";
|
||||
NSFile::CFileBinary::SaveToFile(sOriginRels, sXml);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -2,18 +2,23 @@
|
||||
#include "./XmlSigner_mscrypto.h"
|
||||
#define CCertificate CCertificate_mscrypto
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadKey(std::wstring file, std::string password)
|
||||
namespace NSOpenSSL
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int LoadKey(std::wstring file, std::string password)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return 0;
|
||||
int LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#include "../../../common/File.h"
|
||||
|
||||
#if defined(_LINUX) && !defined(_MAC)
|
||||
#include "./XmlSigner_openssl.h"
|
||||
#define XML_CERTIFICATE_USE_OPENSSL
|
||||
@ -26,29 +31,87 @@ int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string pas
|
||||
#define CCertificate CCertificate_openssl
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
ICertificateSelectDialogOpenSsl* g_application_openssl_gialog = NULL;
|
||||
}
|
||||
|
||||
void ICertificateSelectDialogOpenSsl::SetOpenSslDialogApplication(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
{
|
||||
g_application_openssl_gialog = pDialog;
|
||||
}
|
||||
|
||||
int ICertificate::GetOOXMLHashAlg(const std::string& sAlg)
|
||||
{
|
||||
if ("http://www.w3.org/2000/09/xmldsig#rsa-sha1" == sAlg ||
|
||||
"http://www.w3.org/2000/09/xmldsig#sha1" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA1;
|
||||
|
||||
/*
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha224" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha224" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA224;
|
||||
*/
|
||||
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha256" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmlenc#sha256" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA256;
|
||||
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha384" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA384;
|
||||
|
||||
if ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmldsig-more#sha512" == sAlg ||
|
||||
"http://www.w3.org/2001/04/xmlenc#sha512" == sAlg)
|
||||
return OOXML_HASH_ALG_SHA512;
|
||||
|
||||
return OOXML_HASH_ALG_INVALID;
|
||||
}
|
||||
|
||||
std::string ICertificate::GetDigestMethodA(const int& nAlg)
|
||||
{
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
return "http://www.w3.org/2000/09/xmldsig#sha1";
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#sha224";
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
return "http://www.w3.org/2001/04/xmlenc#sha256";
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#sha384";
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
return "http://www.w3.org/2001/04/xmlenc#sha512";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "http://www.w3.org/2000/09/xmldsig#sha1";
|
||||
}
|
||||
std::wstring ICertificate::GetDigestMethod(const int& nAlg)
|
||||
{
|
||||
std::string sTmp = GetDigestMethodA(nAlg);
|
||||
return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sTmp);
|
||||
}
|
||||
std::string ICertificate::GetSignatureMethodA(const int& nAlg)
|
||||
{
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha224";
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256";
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
return "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||
}
|
||||
std::wstring ICertificate::GetSignatureMethod(const int& nAlg)
|
||||
{
|
||||
std::string sTmp = GetSignatureMethodA(nAlg);
|
||||
return NSFile::CUtf8Converter::GetUnicodeFromCharPtr(sTmp);
|
||||
}
|
||||
|
||||
ICertificate* ICertificate::CreateInstance()
|
||||
{
|
||||
ICertificate* pCert = new CCertificate();
|
||||
pCert->SetOpenSslDialog(g_application_openssl_gialog);
|
||||
return pCert;
|
||||
}
|
||||
|
||||
@ -62,6 +125,11 @@ CCertificateInfo ICertificate::GetInfo()
|
||||
return info;
|
||||
}
|
||||
|
||||
bool ICertificate::FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CCertificateInfo ICertificate::GetDefault()
|
||||
{
|
||||
CCertificateInfo info;
|
||||
|
||||
@ -11,6 +11,80 @@
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
#ifdef MS_CRYPTO_PRIVATE
|
||||
namespace NSMSCryptoPrivate
|
||||
{
|
||||
typedef BOOL (WINAPI * PFNCCERTDISPLAYPROC) (
|
||||
_In_ PCCERT_CONTEXT pCertContext,
|
||||
_In_ HWND hWndSelCertDlg,
|
||||
_In_ void *pvCallbackData
|
||||
);
|
||||
|
||||
typedef struct _CRYPTUI_SELECTCERTIFICATE_STRUCT {
|
||||
DWORD dwSize;
|
||||
HWND hwndParent;
|
||||
DWORD dwFlags;
|
||||
LPCTSTR szTitle;
|
||||
DWORD dwDontUseColumn;
|
||||
LPCTSTR szDisplayString;
|
||||
PFNCFILTERPROC pFilterCallback;
|
||||
PFNCCERTDISPLAYPROC pDisplayCallback;
|
||||
void *pvCallbackData;
|
||||
DWORD cDisplayStores;
|
||||
HCERTSTORE *rghDisplayStores;
|
||||
DWORD cStores;
|
||||
HCERTSTORE *rghStores;
|
||||
DWORD cPropSheetPages;
|
||||
LPCPROPSHEETPAGE rgPropSheetPages;
|
||||
HCERTSTORE hSelectedCertStore;
|
||||
} CRYPTUI_SELECTCERTIFICATE_STRUCT, *PCRYPTUI_SELECTCERTIFICATE_STRUCT;
|
||||
|
||||
typedef PCCERT_CONTEXT (WINAPI * _CryptUIDlgSelectCertificate) (
|
||||
_In_ PCRYPTUI_SELECTCERTIFICATE_STRUCT pcsc
|
||||
);
|
||||
|
||||
class CCertificate_mscrypto_methods
|
||||
{
|
||||
public:
|
||||
HINSTANCE m_instance;
|
||||
_CryptUIDlgSelectCertificate CryptUIDlgSelectCertificate_internal;
|
||||
|
||||
CCertificate_mscrypto_methods()
|
||||
{
|
||||
CryptUIDlgSelectCertificate_internal = NULL;
|
||||
m_instance = LoadLibraryA("Cryptui.dll");
|
||||
|
||||
if (m_instance)
|
||||
{
|
||||
CryptUIDlgSelectCertificate_internal = (_CryptUIDlgSelectCertificate)GetProcAddress(m_instance, "CryptUIDlgSelectCertificate");
|
||||
}
|
||||
}
|
||||
~CCertificate_mscrypto_methods()
|
||||
{
|
||||
if (m_instance)
|
||||
FreeLibrary(m_instance);
|
||||
}
|
||||
|
||||
PCCERT_CONTEXT ShowSelectCertificate(HWND* parent)
|
||||
{
|
||||
if (!CryptUIDlgSelectCertificate_internal)
|
||||
return NULL;
|
||||
|
||||
CRYPTUI_SELECTCERTIFICATE_STRUCT info;
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.hSelectedCertStore = CertOpenSystemStoreA(NULL, "MY");
|
||||
|
||||
PCCERT_CONTEXT ctx = CryptUIDlgSelectCertificate_internal(&info);
|
||||
|
||||
if (info.hSelectedCertStore != NULL)
|
||||
CertCloseStore(info.hSelectedCertStore, 0);
|
||||
|
||||
return ctx;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
class CCertificate_mscrypto : public ICertificate
|
||||
{
|
||||
public:
|
||||
@ -22,6 +96,8 @@ protected:
|
||||
BYTE* m_rawData;
|
||||
int m_rawDataLen;
|
||||
|
||||
int m_alg;
|
||||
|
||||
public:
|
||||
CCertificate_mscrypto() : ICertificate()
|
||||
{
|
||||
@ -32,6 +108,7 @@ public:
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_release = false;
|
||||
m_alg = OOXML_HASH_ALG_INVALID;
|
||||
}
|
||||
CCertificate_mscrypto(PCCERT_CONTEXT ctx) : ICertificate()
|
||||
{
|
||||
@ -42,6 +119,8 @@ public:
|
||||
m_rawDataLen = 0;
|
||||
|
||||
m_release = false;
|
||||
|
||||
GetHashAlgs();
|
||||
}
|
||||
|
||||
virtual ~CCertificate_mscrypto()
|
||||
@ -101,7 +180,7 @@ public:
|
||||
|
||||
virtual std::string GetCertificateHash()
|
||||
{
|
||||
return GetHash(m_context->pbCertEncoded, (unsigned int)m_context->cbCertEncoded, OOXML_HASH_ALG_SHA1);
|
||||
return GetHash(m_context->pbCertEncoded, (unsigned int)m_context->cbCertEncoded, GetHashAlg());
|
||||
}
|
||||
|
||||
virtual std::string GetDate()
|
||||
@ -136,7 +215,63 @@ public:
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
}
|
||||
|
||||
std::vector<int> GetHashAlgs()
|
||||
{
|
||||
std::vector<int> algs;
|
||||
if (!m_context || !m_context->pCertInfo)
|
||||
return algs;
|
||||
|
||||
std::string sAlg(m_context->pCertInfo->SignatureAlgorithm.pszObjId);
|
||||
|
||||
if ("1.2.840.113549.1.1.5" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA1);
|
||||
else if ("1.2.840.113549.1.1.11" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA256);
|
||||
else if ("1.2.840.113549.1.1.12" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA384);
|
||||
else if ("1.2.840.113549.1.1.13" == sAlg)
|
||||
algs.push_back(OOXML_HASH_ALG_SHA512);
|
||||
else
|
||||
algs.push_back(OOXML_HASH_ALG_SHA1);
|
||||
|
||||
if (algs.empty())
|
||||
m_alg = OOXML_HASH_ALG_SHA1;
|
||||
else
|
||||
m_alg = algs[0];
|
||||
|
||||
m_alg = OOXML_HASH_ALG_SHA1;
|
||||
return algs;
|
||||
}
|
||||
int GetHashAlg()
|
||||
{
|
||||
if (m_alg == OOXML_HASH_ALG_INVALID)
|
||||
GetHashAlgs();
|
||||
return m_alg;
|
||||
}
|
||||
|
||||
public:
|
||||
PCRYPT_KEY_PROV_INFO GetProviderInfo()
|
||||
{
|
||||
LPBYTE pInfoData = NULL;
|
||||
DWORD dwInfoDataLength = 0;
|
||||
|
||||
if (!CertGetCertificateContextProperty(m_context, CERT_KEY_PROV_INFO_PROP_ID, NULL, &dwInfoDataLength))
|
||||
return NULL;
|
||||
|
||||
if (dwInfoDataLength > 0)
|
||||
{
|
||||
pInfoData = (LPBYTE)malloc(dwInfoDataLength * sizeof(BYTE));
|
||||
|
||||
if (!CertGetCertificateContextProperty(m_context, CERT_KEY_PROV_INFO_PROP_ID, pInfoData, &dwInfoDataLength))
|
||||
{
|
||||
free(pInfoData);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return (PCRYPT_KEY_PROV_INFO)pInfoData;
|
||||
}
|
||||
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
@ -144,16 +279,46 @@ public:
|
||||
HCRYPTHASH hHash = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
bResult = CryptAcquireCertificatePrivateKey(m_context, CRYPT_ACQUIRE_COMPARE_KEY_FLAG, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
if (!bResult)
|
||||
return "";
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash);
|
||||
int nAlg = GetHashAlg();
|
||||
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
|
||||
if (!bResult)
|
||||
{
|
||||
PCRYPT_KEY_PROV_INFO info = GetProviderInfo();
|
||||
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
if (!CryptAcquireContextW(&hCryptProv, info->pwszContainerName, info->pwszProvName, info->dwProvType, 0))
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
free(info);
|
||||
return "";
|
||||
}
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
if (!CryptAcquireContextW(&hCryptProv, info->pwszContainerName, NULL, PROV_RSA_AES, 0))
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
free(info);
|
||||
return "";
|
||||
}
|
||||
|
||||
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
|
||||
}
|
||||
|
||||
free(info);
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
CryptReleaseContext(hCryptProv, 0);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bResult = CryptHashData(hHash, (BYTE*)sXml.c_str(), (DWORD)sXml.length(), 0);
|
||||
@ -223,10 +388,23 @@ public:
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
|
||||
bResult = (NULL != m_context) ? CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL) : FALSE;
|
||||
bResult = FALSE;//(NULL != m_context) ? CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL) : FALSE;
|
||||
|
||||
DWORD dwProvType = PROV_RSA_FULL;
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
dwProvType = PROV_RSA_AES;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bResult)
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, (nAlg == OOXML_HASH_ALG_SHA256) ? PROV_RSA_AES : PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, dwProvType, CRYPT_VERIFYCONTEXT);
|
||||
|
||||
if (!bResult)
|
||||
return "";
|
||||
@ -308,10 +486,23 @@ public:
|
||||
HCRYPTKEY hPubKey = NULL;
|
||||
|
||||
HCRYPTPROV hCryptProv = NULL;
|
||||
BOOL bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
BOOL bResult = FALSE;//CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
|
||||
|
||||
DWORD dwProvType = PROV_RSA_FULL;
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
dwProvType = PROV_RSA_AES;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bResult)
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, dwProvType, CRYPT_VERIFYCONTEXT);
|
||||
|
||||
if (!bResult)
|
||||
return false;
|
||||
@ -365,30 +556,43 @@ public:
|
||||
m_rawDataLen = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
GetHashAlgs();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int ShowCertificate()
|
||||
virtual int ShowCertificate(void* parent = NULL)
|
||||
{
|
||||
return (int)CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, m_context, NULL, NULL, 0, NULL);
|
||||
return (int)CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, m_context, (NULL == parent) ? NULL : (*((HWND*)parent)), NULL, 0, NULL);
|
||||
}
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog()
|
||||
virtual int ShowSelectDialog(void* parent = NULL)
|
||||
{
|
||||
#ifdef MS_CRYPTO_PRIVATE
|
||||
NSMSCryptoPrivate::CCertificate_mscrypto_methods methods;
|
||||
m_context = methods.ShowSelectCertificate((HWND*)parent);
|
||||
|
||||
if (m_context)
|
||||
{
|
||||
GetHashAlgs();
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_store = CertOpenSystemStoreA(NULL, "MY");
|
||||
if (!m_store)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
m_context = CryptUIDlgSelectCertificateFromStore(m_store, NULL, NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL);
|
||||
m_context = CryptUIDlgSelectCertificateFromStore(m_store, (NULL == parent) ? NULL : (*((HWND*)parent)), NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL);
|
||||
if (!m_context)
|
||||
{
|
||||
CertCloseStore(m_store, 0);
|
||||
m_store = NULL;
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
GetHashAlgs();
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -406,6 +610,12 @@ private:
|
||||
return CALG_SHA1;
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
return CALG_SHA_256;
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
return CALG_SHA_384;
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
return CALG_SHA_512;
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
return CALG_SHA1;
|
||||
default:
|
||||
return CALG_SHA1;
|
||||
}
|
||||
|
||||
@ -17,6 +17,36 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/conf.h>
|
||||
|
||||
const EVP_MD* Get_EVP_MD(int nAlg)
|
||||
{
|
||||
switch (nAlg)
|
||||
{
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
{
|
||||
return EVP_sha1();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
{
|
||||
return EVP_sha224();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
{
|
||||
return EVP_sha256();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
{
|
||||
return EVP_sha384();
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
return EVP_sha512();
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return EVP_sha1();
|
||||
}
|
||||
|
||||
void BIO_FREE(BIO*& bio)
|
||||
{
|
||||
if (bio)
|
||||
@ -44,23 +74,20 @@ void X509_FREE(X509*& cert)
|
||||
|
||||
class CCertificate_openssl_private
|
||||
{
|
||||
protected:
|
||||
ICertificateSelectDialogOpenSsl* m_pDialog;
|
||||
|
||||
X509* m_cert;
|
||||
EVP_PKEY* m_key;
|
||||
|
||||
std::string m_separator;
|
||||
std::string m_id;
|
||||
|
||||
int m_alg;
|
||||
|
||||
public:
|
||||
ICertificate* m_pBase;
|
||||
|
||||
public:
|
||||
CCertificate_openssl_private()
|
||||
{
|
||||
m_pDialog = NULL;
|
||||
|
||||
m_cert = NULL;
|
||||
m_key = NULL;
|
||||
|
||||
@ -117,18 +144,25 @@ public:
|
||||
return L"";
|
||||
|
||||
X509_NAME* name = X509_get_issuer_name(m_cert);
|
||||
char buffer[1024];
|
||||
memset(buffer, 0, 1025);
|
||||
char buffer[10000];
|
||||
memset(buffer, 0, 10000);
|
||||
|
||||
X509_NAME_oneline(name, buffer, 1024);
|
||||
X509_NAME_oneline(name, buffer, 10000);
|
||||
|
||||
std::string sName(buffer);
|
||||
std::wstring sNameW = UTF8_TO_U(sName);
|
||||
|
||||
std::wstring::size_type pos = sNameW.find(L"CN=");
|
||||
if (std::wstring::npos != pos)
|
||||
{
|
||||
sNameW = sNameW.substr(pos + 3);
|
||||
pos = sNameW.find(L"/");
|
||||
|
||||
if (std::wstring::npos != pos)
|
||||
{
|
||||
sNameW = sNameW.substr(0, pos);
|
||||
}
|
||||
}
|
||||
return sNameW;
|
||||
}
|
||||
|
||||
@ -137,6 +171,7 @@ public:
|
||||
if (NULL == m_cert)
|
||||
return "";
|
||||
|
||||
#if 0
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
PEM_write_bio_X509_AUX(bio, m_cert);
|
||||
|
||||
@ -157,6 +192,27 @@ public:
|
||||
string_replace(sReturn, "\n", "");
|
||||
|
||||
BIO_free(bio);
|
||||
return sReturn;
|
||||
#endif
|
||||
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
|
||||
i2d_X509_bio(bio, m_cert);
|
||||
BIO_flush(bio);
|
||||
|
||||
BYTE* data = NULL;
|
||||
int size = (int)BIO_get_mem_data(bio, &data);
|
||||
|
||||
char* dataDst = NULL;
|
||||
int lenDst = 0;
|
||||
NSFile::CBase64Converter::Encode(data, size, dataDst, lenDst);
|
||||
|
||||
std::string sReturn(dataDst);
|
||||
|
||||
RELEASEARRAYOBJECTS(dataDst);
|
||||
|
||||
BIO_free(bio);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
@ -167,7 +223,7 @@ public:
|
||||
int nLen = 0;
|
||||
if (NSFile::CBase64Converter::Decode(sBase64.c_str(), (int)sBase64.length(), pData, nLen))
|
||||
{
|
||||
std::string sHash = GetHash(pData, (unsigned int)nLen, OOXML_HASH_ALG_SHA1);
|
||||
std::string sHash = GetHash(pData, (unsigned int)nLen, GetHashAlg());
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sHash;
|
||||
}
|
||||
@ -209,11 +265,11 @@ public:
|
||||
return GetNumber();
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
std::string Sign(const std::string& sXml)
|
||||
{
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
const EVP_MD* pDigest = Get_EVP_MD(this->GetHashAlg());
|
||||
|
||||
int n1 = EVP_SignInit(pCtx, pDigest);
|
||||
n1 = n1;
|
||||
@ -241,35 +297,63 @@ public:
|
||||
|
||||
std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
|
||||
{
|
||||
if (nAlg == OOXML_HASH_ALG_SHA1)
|
||||
int nBufLen = 0;
|
||||
unsigned char* pBufData = NULL;
|
||||
|
||||
switch (nAlg)
|
||||
{
|
||||
unsigned char obuf[20];
|
||||
SHA1(pData, (size_t)nSize, obuf);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(obuf, 20, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
|
||||
return sReturn;
|
||||
case OOXML_HASH_ALG_SHA1:
|
||||
{
|
||||
nBufLen = 20;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA1(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA224:
|
||||
{
|
||||
nBufLen = 28;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA224(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA256:
|
||||
{
|
||||
nBufLen = 32;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA256(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA384:
|
||||
{
|
||||
nBufLen = 48;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA384(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
case OOXML_HASH_ALG_SHA512:
|
||||
{
|
||||
nBufLen = 64;
|
||||
pBufData = new unsigned char[nBufLen];
|
||||
SHA512(pData, (size_t)nSize, pBufData);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (nAlg == OOXML_HASH_ALG_SHA256)
|
||||
{
|
||||
unsigned char obuf[32];
|
||||
SHA256(pData, (size_t)nSize, obuf);
|
||||
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(obuf, 32, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
if (0 == nBufLen)
|
||||
return "";
|
||||
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
char* pBase64_hash = NULL;
|
||||
int nBase64Len_hash = 0;
|
||||
NSFile::CBase64Converter::Encode(pBufData, nBufLen, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
return "";
|
||||
std::string sReturn(pBase64_hash, nBase64Len_hash);
|
||||
delete [] pBase64_hash;
|
||||
|
||||
delete [] pBufData;
|
||||
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
std::string GetHash(const std::string& sXml, int nAlg)
|
||||
@ -295,7 +379,7 @@ public:
|
||||
bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
|
||||
{
|
||||
EVP_MD_CTX* pCtx = EVP_MD_CTX_create();
|
||||
const EVP_MD* pDigest = EVP_sha1();
|
||||
const EVP_MD* pDigest = Get_EVP_MD(this->GetHashAlg());
|
||||
|
||||
int n1 = EVP_VerifyInit(pCtx, pDigest);
|
||||
n1 = n1;
|
||||
@ -346,27 +430,39 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
bool ShowSelectDialog()
|
||||
std::vector<int> GetHashAlgs()
|
||||
{
|
||||
if (!m_pDialog)
|
||||
return false;
|
||||
std::vector<int> algs;
|
||||
if (!m_cert)
|
||||
return algs;
|
||||
|
||||
bool bResult = m_pDialog->ShowSelectDialog();
|
||||
// TODO:
|
||||
// Check algs in cert
|
||||
|
||||
std::wstring sKeyPath = m_pDialog->GetKeyPath();
|
||||
std::wstring sKeyPasswordW = m_pDialog->GetKeyPassword();
|
||||
std::string sKeyPassword = U_TO_UTF8(sKeyPasswordW);
|
||||
if (algs.empty())
|
||||
m_alg = OOXML_HASH_ALG_SHA1;
|
||||
else
|
||||
m_alg = algs[0];
|
||||
|
||||
std::wstring sCertPath = m_pDialog->GetCertificatePath();
|
||||
std::wstring sCertPasswordW = m_pDialog->GetCertificatePassword();
|
||||
std::string sCertPassword = U_TO_UTF8(sCertPasswordW);
|
||||
|
||||
return FromFiles(sKeyPath, sKeyPassword, sCertPath, sCertPassword);
|
||||
return algs;
|
||||
}
|
||||
int GetHashAlg()
|
||||
{
|
||||
if (m_alg == OOXML_HASH_ALG_INVALID)
|
||||
GetHashAlgs();
|
||||
return m_alg;
|
||||
}
|
||||
|
||||
bool FromFiles(const std::wstring& sKeyPath, const std::string& sKeyPassword, const std::wstring& certPath, const std::string& certPassword)
|
||||
public:
|
||||
int ShowSelectDialog()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword)
|
||||
{
|
||||
std::wstring sKeyPath = keyPath;
|
||||
std::string sKeyPassword = keyPassword;
|
||||
std::wstring sCertPath = certPath;
|
||||
std::string sCertPassword = certPassword;
|
||||
|
||||
@ -375,6 +471,11 @@ public:
|
||||
sCertPath = sKeyPath;
|
||||
sCertPassword = sKeyPassword;
|
||||
}
|
||||
else if (sKeyPath.empty())
|
||||
{
|
||||
sKeyPath = sCertPath;
|
||||
sKeyPassword = sCertPassword;
|
||||
}
|
||||
|
||||
int nErr = LoadKey(sKeyPath, sKeyPassword, &m_key);
|
||||
|
||||
@ -394,6 +495,7 @@ public:
|
||||
m_id += m_separator;
|
||||
m_id += sCertPassword;
|
||||
|
||||
GetHashAlgs();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -429,18 +531,13 @@ public:
|
||||
|
||||
int ShowCertificate()
|
||||
{
|
||||
if (m_pDialog)
|
||||
return m_pDialog->ShowCertificate(m_pBase);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
{
|
||||
m_pDialog = pDialog;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int VerifySelf()
|
||||
{
|
||||
return OPEN_SSL_WARNING_OK;
|
||||
|
||||
if (NULL == m_cert)
|
||||
return OPEN_SSL_WARNING_NOVERIFY;
|
||||
|
||||
@ -787,12 +884,12 @@ bool CCertificate_openssl::LoadFromBase64Data(const std::string& data)
|
||||
return m_internal->LoadFromBase64Data(data);
|
||||
}
|
||||
|
||||
bool CCertificate_openssl::ShowSelectDialog()
|
||||
int CCertificate_openssl::ShowSelectDialog(void* parent)
|
||||
{
|
||||
return m_internal->ShowSelectDialog();
|
||||
}
|
||||
|
||||
int CCertificate_openssl::ShowCertificate()
|
||||
int CCertificate_openssl::ShowCertificate(void* parent)
|
||||
{
|
||||
return m_internal->ShowCertificate();
|
||||
}
|
||||
@ -807,17 +904,24 @@ bool CCertificate_openssl::FromId(const std::string& id)
|
||||
return m_internal->FromKey(id);
|
||||
}
|
||||
|
||||
void CCertificate_openssl::SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog)
|
||||
std::vector<int> CCertificate_openssl::GetHashAlgs()
|
||||
{
|
||||
return m_internal->SetOpenSslDialog(pDialog);
|
||||
return m_internal->GetHashAlgs();
|
||||
}
|
||||
int CCertificate_openssl::GetHashAlg()
|
||||
{
|
||||
return m_internal->GetHashAlg();
|
||||
}
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadKey(std::wstring file, std::string password)
|
||||
namespace NSOpenSSL
|
||||
{
|
||||
return CCertificate_openssl_private::LoadKey(file, password, NULL);
|
||||
}
|
||||
int LoadKey(std::wstring file, std::string password)
|
||||
{
|
||||
return CCertificate_openssl_private::LoadKey(file, password, NULL);
|
||||
}
|
||||
|
||||
int ICertificateSelectDialogOpenSsl::LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return CCertificate_openssl_private::LoadCert(file, password, NULL);
|
||||
int LoadCert(std::wstring file, std::string password)
|
||||
{
|
||||
return CCertificate_openssl_private::LoadCert(file, password, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,14 +41,15 @@ public:
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data);
|
||||
|
||||
virtual std::vector<int> GetHashAlgs();
|
||||
virtual int GetHashAlg();
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog();
|
||||
virtual int ShowCertificate();
|
||||
virtual int ShowSelectDialog(void* parent = NULL);
|
||||
virtual int ShowCertificate(void* parent = NULL);
|
||||
|
||||
bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword);
|
||||
virtual bool FromFiles(const std::wstring& keyPath, const std::string& keyPassword, const std::wstring& certPath, const std::string& certPassword);
|
||||
bool FromId(const std::string& id);
|
||||
|
||||
virtual void SetOpenSslDialog(ICertificateSelectDialogOpenSsl* pDialog);
|
||||
};
|
||||
|
||||
#endif // _XMLSIGNER_OPENSSL_H_
|
||||
|
||||
@ -39,8 +39,16 @@ COfficeUtils::COfficeUtils(OnProgressCallback* fCallback)
|
||||
m_fCallback = fCallback;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& zipFile, const std::wstring& unzipDir, wchar_t* password, SHORT extract_without_path)
|
||||
HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& _zipFile, const std::wstring& _unzipDir, wchar_t* password, SHORT extract_without_path)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
std::wstring unzipDir = CorrectPathW(_unzipDir);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
std::wstring unzipDir = _unzipDir;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::UnzipToDir( zipFile.c_str(), unzipDir.c_str(), m_fCallback, password, ( extract_without_path > 0 ) ? (true) : (false) ) == 0 )
|
||||
{
|
||||
return S_OK;
|
||||
@ -52,8 +60,16 @@ HRESULT COfficeUtils::ExtractToDirectory(const std::wstring& zipFile, const std:
|
||||
}
|
||||
|
||||
|
||||
HRESULT COfficeUtils::CompressFileOrDirectory(const std::wstring& name, const std::wstring& outputFile, bool bSorted, short level)
|
||||
HRESULT COfficeUtils::CompressFileOrDirectory(const std::wstring& _name, const std::wstring& _outputFile, bool bSorted, short level)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring name = _name;//CorrectPathW(_name);
|
||||
std::wstring outputFile = CorrectPathW(_outputFile);
|
||||
#else
|
||||
std::wstring name = _name;
|
||||
std::wstring outputFile = _outputFile;
|
||||
#endif
|
||||
|
||||
HRESULT result = S_FALSE;
|
||||
if(NSDirectory::Exists(name))
|
||||
{
|
||||
@ -104,8 +120,14 @@ HRESULT COfficeUtils::Compress(BYTE* destBuf, ULONG* destSize, BYTE* sourceBuf,
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::IsArchive(const std::wstring& filename)
|
||||
HRESULT COfficeUtils::IsArchive(const std::wstring& _filename)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring filename = CorrectPathW(_filename);
|
||||
#else
|
||||
std::wstring filename = _filename;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::IsArchive(filename.c_str()) )
|
||||
{
|
||||
return S_OK;
|
||||
@ -116,8 +138,14 @@ HRESULT COfficeUtils::IsArchive(const std::wstring& filename)
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::IsFileExistInArchive(const std::wstring& zipFile, const std::wstring& filePath)
|
||||
HRESULT COfficeUtils::IsFileExistInArchive(const std::wstring& _zipFile, const std::wstring& filePath)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::IsFileExistInArchive( zipFile.c_str(), filePath.c_str()) )
|
||||
{
|
||||
return S_OK;
|
||||
@ -128,8 +156,14 @@ HRESULT COfficeUtils::IsFileExistInArchive(const std::wstring& zipFile, const st
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::LoadFileFromArchive(const std::wstring& zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize)
|
||||
HRESULT COfficeUtils::LoadFileFromArchive(const std::wstring& _zipFile, const std::wstring& filePath, BYTE** fileInBytes, ULONG& nFileSize)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
if( ZLibZipUtils::LoadFileFromArchive( zipFile.c_str(), filePath.c_str(), fileInBytes, nFileSize))
|
||||
{
|
||||
return S_OK;
|
||||
@ -140,20 +174,38 @@ HRESULT COfficeUtils::LoadFileFromArchive(const std::wstring& zipFile, const std
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::ExtractFilesToMemory(const std::wstring& zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result)
|
||||
HRESULT COfficeUtils::ExtractFilesToMemory(const std::wstring& _zipFile, const ExtractedFileCallback& data_receiver, void* pParam, bool* result)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
*result = ZLibZipUtils::ExtractFiles(zipFile.c_str(), data_receiver, pParam) ? true : false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::CompressFilesFromMemory(const std::wstring& zipFile, const RequestFileCallback& data_source, void* pParam, SHORT compression_level, bool* result)
|
||||
HRESULT COfficeUtils::CompressFilesFromMemory(const std::wstring& _zipFile, const RequestFileCallback& data_source, void* pParam, SHORT compression_level, bool* result)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
*result = ZLibZipUtils::CompressFiles(zipFile.c_str(), data_source, pParam, compression_level) ? true : false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT COfficeUtils::GetFilesSize(const std::wstring& zipFile, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed)
|
||||
HRESULT COfficeUtils::GetFilesSize(const std::wstring& _zipFile, const std::wstring& searchPattern, ULONG& nCommpressed, ULONG& nUncommpressed)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring zipFile = CorrectPathW(_zipFile);
|
||||
#else
|
||||
std::wstring zipFile = _zipFile;
|
||||
#endif
|
||||
|
||||
if (ZLibZipUtils::GetFilesSize(zipFile.c_str(), searchPattern, nCommpressed, nUncommpressed))
|
||||
{
|
||||
return S_OK;
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/ures.h"
|
||||
#include "unicode/ucnv.h" /* C Converter API */
|
||||
|
||||
#include "../DesktopEditor/common/File.h"
|
||||
|
||||
@ -145,6 +145,7 @@ LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
#BOOST
|
||||
CONFIG += core_boost_regex
|
||||
include($$PWD/../../../Common/3dParty/boost/boost.pri)
|
||||
include($$PWD/../../../Common/3dParty/curl/curl.pri)
|
||||
|
||||
core_windows {
|
||||
LIBS += -lAdvapi32
|
||||
@ -155,7 +156,6 @@ core_windows {
|
||||
core_linux {
|
||||
LIBS += -lz
|
||||
LIBS += -lxml2
|
||||
LIBS += -lcurl
|
||||
}
|
||||
|
||||
mac {
|
||||
|
||||
@ -1078,7 +1078,7 @@ namespace NExtractTools
|
||||
std::wstring sMediaPath;
|
||||
std::wstring sEmbedPath;
|
||||
|
||||
nRes = m_oCXlsxSerializer.loadFromFile (sResultXlstDir, sCSV, sXMLOptions, sMediaPath, sEmbedPath);
|
||||
nRes = m_oCXlsxSerializer.loadFromFile (sResultXlstFileEditor, sCSV, sXMLOptions, sMediaPath, sEmbedPath);
|
||||
}
|
||||
|
||||
return nRes;
|
||||
|
||||
@ -142,7 +142,7 @@ namespace CSVWriter
|
||||
if ( oXlsx.m_pWorkbook )
|
||||
{
|
||||
// Get active sheet
|
||||
if ( oXlsx.m_pWorkbook->m_oBookViews.IsInit() && ! oXlsx.m_pWorkbook->m_oBookViews->m_arrItems.empty())
|
||||
if ( oXlsx.m_pWorkbook->m_oBookViews.IsInit() && !oXlsx.m_pWorkbook->m_oBookViews->m_arrItems.empty())
|
||||
{
|
||||
if ( oXlsx.m_pWorkbook->m_oBookViews->m_arrItems.front()->m_oActiveTab.IsInit())
|
||||
{
|
||||
@ -154,16 +154,17 @@ namespace CSVWriter
|
||||
|
||||
// Get active sheet rId (для конвертации в CSV нужно использовать name, т.к. это наш бинарник из js-скриптов и еще нет rId
|
||||
// А для json-а нужно пользовать rId, т.к. при открытии они используются
|
||||
if ( oXlsx.m_pWorkbook->m_oSheets.IsInit() && ! oXlsx.m_pWorkbook->m_oSheets->m_arrItems.empty())
|
||||
if ( oXlsx.m_pWorkbook->m_oSheets.IsInit() && !oXlsx.m_pWorkbook->m_oSheets->m_arrItems.empty())
|
||||
{
|
||||
std::map<int, OOX::Spreadsheet::CSheet*>::iterator pFind = oXlsx.m_pWorkbook->m_oSheets->mapSheets.find(lActiveSheet);
|
||||
|
||||
OOX::Spreadsheet::CSheet *pSheet = NULL;
|
||||
|
||||
if (pFind != oXlsx.m_pWorkbook->m_oSheets->mapSheets.end())
|
||||
pSheet = pFind->second;
|
||||
if (lActiveSheet >= 0 && lActiveSheet < oXlsx.m_pWorkbook->m_oSheets->m_arrItems.size())
|
||||
{
|
||||
pSheet = oXlsx.m_pWorkbook->m_oSheets->m_arrItems[lActiveSheet];
|
||||
}
|
||||
else
|
||||
{
|
||||
pSheet = oXlsx.m_pWorkbook->m_oSheets->m_arrItems.front();
|
||||
}
|
||||
|
||||
sSheetRId = bJSON ? pSheet->m_oRid->GetValue() : pSheet->m_oName.get2();
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ namespace XPS
|
||||
ReadAttribute(oReader, L"Source", wsSource);
|
||||
if (!wsSource.empty())
|
||||
{
|
||||
std::wstring wsPath = m_wsRootPath + wsSource.c_str();
|
||||
std::wstring wsPath = m_wsRootPath + wsSource.c_stdstr();
|
||||
pState->PushResource(m_pDocument->GetStaticResource(wsPath.c_str()), false);
|
||||
}
|
||||
else
|
||||
@ -687,7 +687,14 @@ namespace XPS
|
||||
if (oEntry.bGid)
|
||||
pRenderer->CommandDrawTextExCHAR(oEntry.nUnicode, oEntry.nGid, xpsUnitToMM(dXorigin), xpsUnitToMM(dYorigin), 0, 0);
|
||||
else
|
||||
pRenderer->CommandDrawTextCHAR(oEntry.nUnicode, xpsUnitToMM(dXorigin), xpsUnitToMM(dYorigin), 0, 0);
|
||||
{
|
||||
LONG nRenType = 0;
|
||||
pRenderer->get_Type(&nRenType);
|
||||
if (c_nGrRenderer == nRenType)
|
||||
pRenderer->put_FontStringGID(FALSE);
|
||||
|
||||
pRenderer->CommandDrawTextCHAR(oEntry.nUnicode, xpsUnitToMM(dXorigin), xpsUnitToMM(dYorigin), 0, 0);
|
||||
}
|
||||
|
||||
if (bNeedBold)
|
||||
{
|
||||
|
||||
@ -152,13 +152,13 @@ namespace XPS
|
||||
}
|
||||
bool CImageBrush::SetToRenderer(IRenderer* pRenderer)
|
||||
{
|
||||
std::wstring wsPath = m_wsRoot.c_str();
|
||||
wsPath += m_wsPath.c_str();
|
||||
std::wstring wsPath = m_wsRoot.c_stdstr();
|
||||
wsPath += m_wsPath.c_stdstr();
|
||||
|
||||
if (!NSFile::CFileBinary::Exists(wsPath))
|
||||
{
|
||||
wsPath = m_wsPage.c_str();
|
||||
wsPath += m_wsPath.c_str();
|
||||
wsPath = m_wsPage.c_stdstr();
|
||||
wsPath += m_wsPath.c_stdstr();
|
||||
if (!NSFile::CFileBinary::Exists(wsPath))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -186,6 +186,13 @@ namespace XPS
|
||||
|
||||
return (const wchar_t*)m_pBuffer;
|
||||
}
|
||||
const std::wstring CWString::c_stdstr() const
|
||||
{
|
||||
const wchar_t* pData = c_str();
|
||||
if (NULL == pData)
|
||||
return L"";
|
||||
return std::wstring(pData);
|
||||
}
|
||||
bool CWString::operator<(const CWString& wsString) const
|
||||
{
|
||||
const wchar_t* wsLeft = this->c_str();
|
||||
|
||||
@ -59,6 +59,7 @@ namespace XPS
|
||||
bool empty() const;
|
||||
wchar_t operator[](const unsigned int& unIndex) const;
|
||||
const wchar_t* c_str() const;
|
||||
const std::wstring c_stdstr() const;
|
||||
void clear();
|
||||
|
||||
int tointeger() const;
|
||||
|
||||
Reference in New Issue
Block a user