mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-12 10:55:49 +08:00
Compare commits
10 Commits
core/devel
...
core/devel
| Author | SHA1 | Date | |
|---|---|---|---|
| fecefb672d | |||
| f91e030836 | |||
| d0591483bc | |||
| 729f9f246f | |||
| 17a6ba735b | |||
| de22fb4737 | |||
| 751774419e | |||
| 8278609f10 | |||
| 445eedc7a3 | |||
| ed7661b93c |
1
.gitignore
vendored
1
.gitignore
vendored
@ -43,3 +43,4 @@ OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
|
||||
*.pdb
|
||||
*.tlb
|
||||
*.idb
|
||||
**/.hg
|
||||
|
||||
@ -41,8 +41,13 @@ namespace cpdoccore { namespace odf_types {
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const clockvalue & _Val)
|
||||
{
|
||||
// 5ms = 5 milliseconds
|
||||
_Wostream << _Val.get_value() << "ms"; // todoooo усложнить ..
|
||||
// 5ms = 5 milliseconds
|
||||
if (_Val.get_value() < 0)
|
||||
_Wostream << L"indefinite";
|
||||
else
|
||||
{
|
||||
_Wostream << _Val.get_value() << "ms"; // todoooo усложнить ..
|
||||
}
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
@ -120,15 +125,20 @@ static bool parseTime(const std::wstring & Time, double & Hours, double & Minute
|
||||
}
|
||||
clockvalue clockvalue::parse(const std::wstring & Str)
|
||||
{
|
||||
int v=0;
|
||||
if (Str == L"indefinite")
|
||||
return clockvalue(-1);
|
||||
else
|
||||
{
|
||||
int v=0;
|
||||
|
||||
int ms=0;
|
||||
double h=0,m=0,s =0;
|
||||
bool res = parseTime(Str,h,m,s,ms);
|
||||
int ms=0;
|
||||
double h=0,m=0,s =0;
|
||||
bool res = parseTime(Str,h,m,s,ms);
|
||||
|
||||
v = (((h*60)+m)*60+s)*1000+ms;
|
||||
v = (((h*60)+m)*60+s)*1000+ms;
|
||||
|
||||
return clockvalue(v);
|
||||
return clockvalue(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -804,28 +804,32 @@ void common_presentation_attlist::serialize(CP_ATTR_NODE)
|
||||
|
||||
void common_anim_smil_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"smil:direction", smil_direction_);
|
||||
CP_APPLY_ATTR(L"smil:subtype", smil_subtype_);
|
||||
CP_APPLY_ATTR(L"smil:type", smil_type_);
|
||||
CP_APPLY_ATTR(L"smil:dur", smil_dur_);
|
||||
CP_APPLY_ATTR(L"presentation:node-type", presentation_node_type_);
|
||||
CP_APPLY_ATTR(L"smil:direction", smil_direction_);
|
||||
CP_APPLY_ATTR(L"smil:begin", smil_begin_);
|
||||
CP_APPLY_ATTR(L"smil:end", smil_end_);
|
||||
CP_APPLY_ATTR(L"smil:restart", smil_restart_);
|
||||
CP_APPLY_ATTR(L"smil:dur", smil_dur_);
|
||||
|
||||
}
|
||||
void common_anim_smil_attlist::apply_from(const common_anim_smil_attlist & Other)
|
||||
{
|
||||
_CP_APPLY_PROP(presentation_node_type_, Other.presentation_node_type_);
|
||||
|
||||
_CP_APPLY_PROP(smil_direction_, Other.smil_direction_);
|
||||
_CP_APPLY_PROP(smil_subtype_, Other.smil_subtype_);
|
||||
_CP_APPLY_PROP(smil_type_, Other.smil_type_);
|
||||
_CP_APPLY_PROP(smil_begin_, Other.smil_begin_);
|
||||
_CP_APPLY_PROP(smil_end_, Other.smil_end_);
|
||||
_CP_APPLY_PROP(smil_restart_, Other.smil_restart_);
|
||||
_CP_APPLY_PROP(smil_dur_, Other.smil_dur_);
|
||||
}
|
||||
void common_anim_smil_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"smil:direction", smil_direction_);
|
||||
CP_XML_ATTR_OPT(L"smil:subtype", smil_subtype_);
|
||||
CP_XML_ATTR_OPT(L"smil:type", smil_type_);
|
||||
CP_XML_ATTR_OPT(L"smil:restart", smil_restart_);
|
||||
CP_XML_ATTR_OPT(L"smil:dur", smil_dur_);
|
||||
CP_XML_ATTR_OPT(L"presentation:node-type", presentation_node_type_);
|
||||
CP_XML_ATTR_OPT(L"smil:begin", smil_begin_);
|
||||
CP_XML_ATTR_OPT(L"smil:end", smil_end_);
|
||||
}
|
||||
void union_common_draw_attlists::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
|
||||
@ -577,17 +577,14 @@ public:
|
||||
void apply_from (const common_anim_smil_attlist & Other);
|
||||
void serialize (CP_ATTR_NODE);
|
||||
|
||||
_CP_OPT(std::wstring) presentation_node_type_;
|
||||
_CP_OPT(std::wstring) smil_direction_;
|
||||
_CP_OPT(std::wstring) smil_restart_;
|
||||
_CP_OPT(std::wstring) smil_subtype_;
|
||||
_CP_OPT(std::wstring) smil_type_;
|
||||
_CP_OPT(std::wstring) smil_dur_;
|
||||
_CP_OPT(std::wstring) presentation_node_type_;
|
||||
|
||||
_CP_OPT(std::wstring) smil_begin_;
|
||||
|
||||
_CP_OPT(color) smil_fadeColor;
|
||||
_CP_OPT(std::wstring) smil_direction_;
|
||||
_CP_OPT(std::wstring) smil_restart_;
|
||||
_CP_OPT(odf_types::clockvalue) smil_dur_;
|
||||
|
||||
_CP_OPT(std::wstring) smil_begin_;
|
||||
_CP_OPT(std::wstring) smil_end_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -99,6 +99,8 @@ SOURCES += \
|
||||
../source/OdfFormat/odf_settings_context.cpp \
|
||||
../source/OdfFormat/office_settings.cpp \
|
||||
../source/OdfFormat/mediaitems_utils.cpp \
|
||||
../source/OdfFormat/office_scripts.cpp \
|
||||
../source/OdfFormat/office_event_listeners.cpp \
|
||||
../source/OdfFormat/anim_elements.cpp \
|
||||
../source/OdfFormat/draw_page.cpp \
|
||||
../source/OdfFormat/odp_conversion_context.cpp \
|
||||
@ -208,4 +210,6 @@ HEADERS += \
|
||||
../source/OdfFormat/style_presentation.h \
|
||||
../source/Oox2OdfConverter/PptxConverter.h \
|
||||
../source/OdfFormat/anim_elements.h \
|
||||
../source/OdfFormat/office_event_listeners.h \
|
||||
../source/OdfFormat/office_scripts.h \
|
||||
../source/OdfFormat/style_presentation.h
|
||||
|
||||
@ -91,3 +91,5 @@
|
||||
#include "../source/OdfFormat/odp_slide_context.cpp"
|
||||
#include "../source/OdfFormat/office_presentation.cpp"
|
||||
#include "../source/OdfFormat/style_presentation.cpp"
|
||||
#include "../source/OdfFormat/office_scripts.cpp"
|
||||
#include "../source/OdfFormat/office_event_listeners.cpp"
|
||||
|
||||
@ -59,6 +59,8 @@ void anim_par::create_child_element(const std::wstring & Ns, const std::wstring
|
||||
}
|
||||
void anim_par::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeAnimPar)
|
||||
@ -122,16 +124,18 @@ void anim_seq::add_child_element( const office_element_ptr & child)
|
||||
////////////////////////////////////////////////////////////////
|
||||
void anim_transition_filter_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"smil:direction", smil_direction_);
|
||||
CP_XML_ATTR_OPT(L"smil:subtype", smil_subtype_);
|
||||
CP_XML_ATTR_OPT(L"smil:type", smil_type_);
|
||||
CP_XML_ATTR_OPT(L"smil:fadeColor", smil_fadeColor_);
|
||||
CP_XML_ATTR_OPT(L"smil:mode", smil_mode_);
|
||||
CP_XML_ATTR_OPT(L"smil:dur", smil_dur_);
|
||||
|
||||
}
|
||||
|
||||
const wchar_t * anim_transitionFilter::ns = L"anim";
|
||||
void anim_audio_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"xlink:href", xlink_href_);
|
||||
CP_XML_ATTR_OPT(L"anim:audio-level",anim_audio_level_);
|
||||
}
|
||||
const wchar_t * anim_transitionFilter::ns = L"anim";
|
||||
const wchar_t * anim_transitionFilter::name = L"transitionFilter";
|
||||
|
||||
void anim_transitionFilter::serialize(std::wostream & _Wostream)
|
||||
@ -140,11 +144,26 @@ void anim_transitionFilter::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_attlist_.serialize(CP_GET_XML_NODE());
|
||||
filter_attlist_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
const wchar_t * anim_audio::ns = L"anim";
|
||||
const wchar_t * anim_audio::name = L"audio";
|
||||
|
||||
void anim_audio::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
common_attlist_.serialize(CP_GET_XML_NODE());
|
||||
audio_attlist_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,19 +86,24 @@ CP_REGISTER_OFFICE_ELEMENT2(anim_seq);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//anim:iterate
|
||||
//class anim_iterate : public office_element_impl<anim_iterate>//Итеративные анимации
|
||||
class anim_audio_attlist
|
||||
{
|
||||
public:
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
_CP_OPT(std::wstring) xlink_href_;
|
||||
_CP_OPT(std::wstring) anim_audio_level_;
|
||||
};
|
||||
|
||||
class anim_transition_filter_attlist
|
||||
{
|
||||
public:
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
_CP_OPT(std::wstring) smil_direction_;
|
||||
_CP_OPT(std::wstring) smil_subtype_;
|
||||
_CP_OPT(odf_types::smil_transition_type) smil_type_;
|
||||
_CP_OPT(std::wstring) smil_mode_;
|
||||
_CP_OPT(odf_types::color) smil_fadeColor_;
|
||||
_CP_OPT(odf_types::clockvalue) smil_dur_;
|
||||
};
|
||||
|
||||
|
||||
@ -116,11 +121,29 @@ public:
|
||||
|
||||
virtual void serialize(std::wostream & strm);
|
||||
///////////////////////////////////////////////////////////
|
||||
anim_transition_filter_attlist attlist_;
|
||||
odf_types::common_anim_smil_attlist common_attlist_;
|
||||
anim_transition_filter_attlist filter_attlist_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(anim_transitionFilter);
|
||||
|
||||
//anim:audio
|
||||
class anim_audio : public office_element_impl<anim_audio>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeAnimAudio;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element( const office_element_ptr & child){}
|
||||
|
||||
virtual void serialize(std::wostream & strm);
|
||||
///////////////////////////////////////////////////////////
|
||||
odf_types::common_anim_smil_attlist common_attlist_;
|
||||
anim_audio_attlist audio_attlist_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(anim_audio);
|
||||
//anim:command
|
||||
|
||||
}
|
||||
|
||||
@ -73,10 +73,9 @@ void draw_chart_attlist::serialize(CP_ATTR_NODE)
|
||||
//CP_XML_ATTR_OPT(L"draw:filter-name", draw_filter_name_);
|
||||
}
|
||||
|
||||
// draw:image
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_image::ns = L"draw";
|
||||
const wchar_t * draw_image::name = L"image";
|
||||
//-----------------------------------------------------------------------
|
||||
const wchar_t * draw_image::ns = L"draw";
|
||||
const wchar_t * draw_image::name = L"image";
|
||||
|
||||
void draw_image::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
@ -111,6 +110,8 @@ void draw_image::create_child_element(const std::wstring & Ns, const std::wstrin
|
||||
}
|
||||
void draw_image::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeOfficeBinaryData)
|
||||
@ -154,8 +155,7 @@ void draw_chart::add_child_element( const office_element_ptr & child_element)
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
|
||||
// draw:g
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///-----------------------------------------------------------------------
|
||||
const wchar_t * draw_g::ns = L"draw";
|
||||
const wchar_t * draw_g::name = L"g";
|
||||
|
||||
@ -207,12 +207,12 @@ void draw_frame::serialize(std::wostream & _Wostream)
|
||||
void draw_frame::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (CP_CHECK_NAME(L"draw", L"text-box") ||
|
||||
CP_CHECK_NAME(L"draw", L"image") ||//копия чарта в виде картинки ну.. или просто картинка
|
||||
CP_CHECK_NAME(L"draw", L"object") ||//месторасположение чарта
|
||||
CP_CHECK_NAME(L"draw", L"image") ||//копия чарта в виде картинки ну.. или просто картинка
|
||||
CP_CHECK_NAME(L"draw", L"object") ||//месторасположение чарта
|
||||
CP_CHECK_NAME(L"draw", L"object-ole") ||
|
||||
CP_CHECK_NAME(L"draw", L"applet") ||
|
||||
CP_CHECK_NAME(L"draw", L"applet") ||
|
||||
CP_CHECK_NAME(L"draw", L"floating-frame") ||
|
||||
CP_CHECK_NAME(L"draw", L"plugin") ||
|
||||
CP_CHECK_NAME(L"draw", L"plugin") ||
|
||||
CP_CHECK_NAME(L"table", L"table")
|
||||
)
|
||||
{
|
||||
@ -242,9 +242,16 @@ void draw_frame::create_child_element( const std::wstring & Ns, const std::wstr
|
||||
}
|
||||
void draw_frame::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeDrawImage || type == typeDrawTextBox || type == typeDrawObject || type == typeDrawObjectOle || type == typeTableTable)
|
||||
if (type == typeDrawImage ||
|
||||
type == typeDrawTextBox ||
|
||||
type == typeDrawObject ||
|
||||
type == typeDrawObjectOle ||
|
||||
type == typeDrawPlugin ||
|
||||
type == typeTableTable)
|
||||
{
|
||||
draw_base::add_child_element(child_element);
|
||||
}
|
||||
@ -259,8 +266,6 @@ void draw_frame::add_child_element( const office_element_ptr & child_element)
|
||||
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
|
||||
void draw_text_box_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"draw:chain-next-name", draw_chain_next_name_);
|
||||
@ -271,9 +276,8 @@ void draw_text_box_attlist::serialize(CP_ATTR_NODE)
|
||||
CP_XML_ATTR_OPT(L"fo:max-height", fo_max_height_);
|
||||
}
|
||||
|
||||
// draw:text-box
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_text_box::ns = L"draw";
|
||||
//-----------------------------------------------------------------------
|
||||
const wchar_t * draw_text_box::ns = L"draw";
|
||||
const wchar_t * draw_text_box::name = L"text-box";
|
||||
|
||||
|
||||
@ -285,9 +289,9 @@ void draw_text_box::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
draw_text_box_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -302,8 +306,7 @@ void draw_text_box::add_child_element( const office_element_ptr & child_element)
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
|
||||
// draw:object
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------
|
||||
const wchar_t * draw_object::ns = L"draw";
|
||||
const wchar_t * draw_object::name = L"object";
|
||||
|
||||
@ -326,10 +329,9 @@ void draw_object::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
//CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
// draw:object
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_object_ole::ns = L"draw";
|
||||
const wchar_t * draw_object_ole::name = L"object-ole";
|
||||
//-----------------------------------------------------------------------
|
||||
const wchar_t * draw_object_ole::ns = L"draw";
|
||||
const wchar_t * draw_object_ole::name = L"object-ole";
|
||||
|
||||
void draw_object_ole::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
@ -351,5 +353,37 @@ void draw_object_ole::add_child_element( const office_element_ptr & child_elemen
|
||||
{
|
||||
//CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
const wchar_t * draw_plugin::ns = L"draw";
|
||||
const wchar_t * draw_plugin::name = L"plugin";
|
||||
|
||||
void draw_plugin::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
common_xlink_attlist_.serialize(CP_GET_XML_NODE());
|
||||
CP_XML_ATTR_OPT(L"draw:mime-type", draw_mime_type_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw_plugin::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"draw", L"param")
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
}
|
||||
void draw_plugin::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,10 +235,33 @@ public:
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_class_id_;
|
||||
_CP_OPT(std::wstring) draw_class_id_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole)
|
||||
|
||||
// draw:plugin
|
||||
class draw_plugin : public office_element_impl<draw_plugin>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeDrawPlugin;
|
||||
CPDOCCORE_DEFINE_VISITABLE()
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
_CP_OPT(std::wstring) draw_mime_type_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_plugin)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,6 +72,8 @@ void draw_page::create_child_element( const std::wstring & Ns, const std::wstrin
|
||||
}
|
||||
void draw_page::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
if(type == typeAnimPar)
|
||||
animation_ = child_element;
|
||||
|
||||
@ -464,7 +464,9 @@ void draw_enhanced_geometry::create_child_element( const std::wstring & Ns, cons
|
||||
}
|
||||
void draw_enhanced_geometry::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
ElementType type = child_element->get_type();
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeDrawHandle)
|
||||
{
|
||||
|
||||
@ -102,6 +102,8 @@ void text_list_item::create_child_element(const std::wstring & Ns, const std::ws
|
||||
}
|
||||
void text_list_item::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextNumber)
|
||||
@ -148,6 +150,8 @@ void text_list_header::create_child_element(const std::wstring & Ns, const std::
|
||||
}
|
||||
void text_list_header::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextNumber)
|
||||
|
||||
@ -42,7 +42,7 @@ class rels;
|
||||
class _mediaitems
|
||||
{
|
||||
public:
|
||||
enum Type { typeUnknown = 0, typeImage, typeAudio, typeVideo};
|
||||
enum Type { typeUnknown = 0, typeImage, typeMedia};
|
||||
//oleObject ???
|
||||
|
||||
_mediaitems()
|
||||
|
||||
@ -123,6 +123,8 @@ void number_style_base::create_child_element( const std::wstring & Ns, const std
|
||||
}
|
||||
void number_style_base::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeStyleTextProperties)
|
||||
|
||||
@ -185,12 +185,12 @@ namespace odf_writer
|
||||
{
|
||||
if (mediaitems_.count_media < 1)return;
|
||||
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"Media";
|
||||
NSDirectory::CreateDirectory(path);
|
||||
|
||||
BOOST_FOREACH( _mediaitems::item & item, mediaitems_.items() )
|
||||
{
|
||||
if (item.type == _mediaitems::typeAudio || item.type == _mediaitems::typeVideo)
|
||||
if (item.type == _mediaitems::typeMedia)
|
||||
{
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.odf_ref;
|
||||
|
||||
@ -346,13 +346,13 @@ namespace odf_writer
|
||||
CP_XML_ATTR(L"xmlns:anim", L"urn:oasis:names:tc:opendocument:xmlns:animation:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:calcext", L"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:field", L"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:formx", L"urn:openoffice:names:experimental:ooxml-odf_writer-interop:xmlns:form:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:formx", L"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:loext", L"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:css3t", L"http://www.w3.org/TR/css3-text/" );
|
||||
|
||||
CP_XML_ATTR(L"office:version", L"1.2");
|
||||
|
||||
//CP_XML_NODE(L"office:scripts");
|
||||
CP_XML_NODE(L"office:font-face-decls");
|
||||
if (content_)
|
||||
{
|
||||
CP_XML_STREAM() << content_->styles_str();
|
||||
@ -414,7 +414,7 @@ namespace odf_writer
|
||||
CP_XML_ATTR(L"xmlns:chartooo", L"http://openoffice.org/2010/chart" );
|
||||
CP_XML_ATTR(L"xmlns:calcext", L"urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:field", L"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:formx", L"urn:openoffice:names:experimental:ooxml-odf_writer-interop:xmlns:form:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:formx", L"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:loext", L"urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" );
|
||||
CP_XML_ATTR(L"xmlns:css3t", L"http://www.w3.org/TR/css3-text/" );
|
||||
CP_XML_ATTR(L"office:version", L"1.2");
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "office_spreadsheet.h"
|
||||
#include "office_scripts.h"
|
||||
#include "office_chart.h"
|
||||
|
||||
#include "office_elements_create.h"
|
||||
@ -128,6 +129,10 @@ void odf_conversion_context::end_document()
|
||||
process_settings(object, isRoot);
|
||||
|
||||
package::content_content_ptr content_root_ = package::content_content::create();
|
||||
|
||||
if (objects_.back().scripts)
|
||||
objects_.back().scripts->serialize(content_root_->styles());
|
||||
|
||||
object.content->serialize(content_root_->content());
|
||||
BOOST_FOREACH(const office_element_ptr & elm, object.content_styles)
|
||||
{
|
||||
@ -193,6 +198,8 @@ void odf_conversion_context::start_presentation()
|
||||
{
|
||||
create_object();
|
||||
create_element(L"office", L"presentation", objects_.back().content, this, true);
|
||||
|
||||
create_element(L"office", L"scripts", objects_.back().scripts, this);
|
||||
}
|
||||
void odf_conversion_context::create_object()
|
||||
{
|
||||
@ -298,6 +305,15 @@ std::wstring odf_conversion_context::add_image(const std::wstring & image_file_n
|
||||
|
||||
return odf_ref_name;
|
||||
}
|
||||
std::wstring odf_conversion_context::add_media(const std::wstring & file_name)
|
||||
{
|
||||
if (file_name.empty()) return L"";
|
||||
|
||||
std::wstring odf_ref_name ;
|
||||
mediaitems()->add_or_find(file_name,_mediaitems::typeMedia, odf_ref_name);
|
||||
|
||||
return odf_ref_name;
|
||||
}
|
||||
void odf_conversion_context::add_tab(_CP_OPT(int) type, _CP_OPT(length) _length, _CP_OPT(int) leader)
|
||||
{
|
||||
if (!temporary_.elm) return;
|
||||
|
||||
@ -65,6 +65,7 @@ class odf_conversion_context : boost::noncopyable
|
||||
std::wstring name;
|
||||
|
||||
office_element_ptr content;
|
||||
office_element_ptr scripts;
|
||||
std::vector<office_element_ptr> content_styles;
|
||||
std::vector<office_element_ptr> styles;
|
||||
office_element_ptr settings;
|
||||
@ -96,6 +97,7 @@ public:
|
||||
virtual void end_text_context() = 0;
|
||||
|
||||
std::wstring add_image(const std::wstring & image_file_name);
|
||||
std::wstring add_media(const std::wstring & file_name);
|
||||
|
||||
virtual odf_style_context * styles_context();
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "odf_text_context.h"
|
||||
#include "odf_style_context.h"
|
||||
#include "odf_conversion_context.h"
|
||||
#include "office_event_listeners.h"
|
||||
|
||||
#include "draw_frame.h"
|
||||
#include "draw_shapes.h"
|
||||
@ -2332,14 +2333,37 @@ void odf_drawing_context::start_object(std::wstring name)
|
||||
draw_object* object = dynamic_cast<draw_object*>(object_elm.get());
|
||||
if (object == NULL)return;
|
||||
|
||||
object->common_xlink_attlist_.href_= std::wstring(L"./") + name;
|
||||
object->common_xlink_attlist_.type_= xlink_type::Simple;
|
||||
object->common_xlink_attlist_.show_ = xlink_show::Embed;
|
||||
object->common_xlink_attlist_.actuate_= xlink_actuate::OnLoad;
|
||||
object->common_xlink_attlist_.href_ = std::wstring(L"./") + name;
|
||||
object->common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
object->common_xlink_attlist_.show_ = xlink_show::Embed;
|
||||
object->common_xlink_attlist_.actuate_ = xlink_actuate::OnLoad;
|
||||
|
||||
start_element(object_elm);
|
||||
}
|
||||
void odf_drawing_context::start_media(std::wstring name)
|
||||
{
|
||||
start_frame();
|
||||
|
||||
office_element_ptr plugin_elm;
|
||||
create_element(L"draw", L"plugin", plugin_elm, impl_->odf_context_);
|
||||
|
||||
draw_plugin* plugin = dynamic_cast<draw_plugin*>(plugin_elm.get());
|
||||
if (plugin == NULL)return;
|
||||
|
||||
plugin->common_xlink_attlist_.href_ = name;
|
||||
plugin->common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
plugin->common_xlink_attlist_.show_ = xlink_show::Embed;
|
||||
plugin->common_xlink_attlist_.actuate_ = xlink_actuate::OnLoad;
|
||||
|
||||
plugin->draw_mime_type_ = L"application/vnd.sun.star.media";
|
||||
|
||||
start_element(plugin_elm);
|
||||
}
|
||||
void odf_drawing_context::end_media()
|
||||
{
|
||||
end_element();
|
||||
end_frame();
|
||||
}
|
||||
void odf_drawing_context::start_text_box()
|
||||
{
|
||||
impl_->current_drawing_state_.oox_shape_preset_ = 2000;
|
||||
@ -2369,6 +2393,95 @@ void odf_drawing_context::set_text_box_min_size(bool val)
|
||||
}
|
||||
}
|
||||
|
||||
void odf_drawing_context::start_action(std::wstring value)
|
||||
{
|
||||
office_element_ptr elm_listeners;
|
||||
create_element(L"office", L"event-listeners", elm_listeners, impl_->odf_context_);
|
||||
|
||||
start_element(elm_listeners);
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"presentation", L"event-listener", elm, impl_->odf_context_);
|
||||
|
||||
start_element(elm);
|
||||
|
||||
presentation_event_listener * event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get());
|
||||
|
||||
if (event_)
|
||||
{
|
||||
event_->attlist_.script_event_name_ = L"dom:click";
|
||||
|
||||
if (std::wstring::npos != value.find(L"noaction") ||
|
||||
std::wstring::npos != value.find(L"media"))
|
||||
{
|
||||
event_->attlist_.script_event_name_ = boost::none;
|
||||
}
|
||||
else if (std::wstring::npos != value.find(L"program"))
|
||||
{
|
||||
event_->attlist_.presentation_action_ = L"execute";
|
||||
}
|
||||
else if (std::wstring::npos != value.find(L"hlinkshowjump"))
|
||||
{
|
||||
if (std::wstring::npos != value.find(L"previousslide"))
|
||||
event_->attlist_.presentation_action_ = L"previous-page";
|
||||
if (std::wstring::npos != value.find(L"nextslide"))
|
||||
event_->attlist_.presentation_action_ = L"next-page";
|
||||
}
|
||||
else if (std::wstring::npos != value.find(L"hlinksldjump"))
|
||||
{
|
||||
event_->attlist_.presentation_action_ = L"previous-page";
|
||||
}
|
||||
else
|
||||
{//hyperlink
|
||||
event_->attlist_.presentation_action_ = L"show";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void odf_drawing_context::add_link(std::wstring href)
|
||||
{
|
||||
if (href.empty()) return;
|
||||
|
||||
presentation_event_listener * event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get());
|
||||
|
||||
if (event_)
|
||||
{
|
||||
event_->attlist_.common_xlink_attlist_.href_ = href;
|
||||
event_->attlist_.common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
event_->attlist_.common_xlink_attlist_.show_ = xlink_show::Embed;
|
||||
event_->attlist_.common_xlink_attlist_.actuate_ = xlink_actuate::OnRequest;
|
||||
}
|
||||
}
|
||||
|
||||
void odf_drawing_context::add_sound(std::wstring href)
|
||||
{
|
||||
presentation_event_listener * event_ = dynamic_cast<presentation_event_listener*>(impl_->current_level_.back().get());
|
||||
if (event_)
|
||||
{
|
||||
event_->attlist_.script_event_name_ = L"dom:click";
|
||||
event_->attlist_.presentation_action_ = L"sound";
|
||||
}
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"presentation", L"sound", elm, impl_->odf_context_);
|
||||
|
||||
start_element(elm);
|
||||
|
||||
presentation_sound *sound = dynamic_cast<presentation_sound*>(elm.get());
|
||||
if (sound)
|
||||
{
|
||||
sound->common_xlink_attlist_.href_ = href;
|
||||
sound->common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
sound->common_xlink_attlist_.show_ = xlink_show::New;
|
||||
sound->common_xlink_attlist_.actuate_ = xlink_actuate::OnRequest;
|
||||
}
|
||||
end_element();
|
||||
}
|
||||
void odf_drawing_context::end_action()
|
||||
{
|
||||
end_element();
|
||||
end_element();
|
||||
}
|
||||
void odf_drawing_context::set_text_box_min_size(double w_pt, double h_pt)
|
||||
{
|
||||
if (impl_->current_drawing_state_.elements_.empty()) return;
|
||||
|
||||
@ -144,6 +144,9 @@ public:
|
||||
void start_object(std::wstring name);
|
||||
void end_object();
|
||||
|
||||
void start_media(std::wstring name);
|
||||
void end_media();
|
||||
|
||||
bool isLineShape();
|
||||
void corrected_line_fill();
|
||||
|
||||
@ -260,6 +263,11 @@ public:
|
||||
void set_bitmap_tile_translate_y(double y);
|
||||
void set_bitmap_tile_translate_x(double x);
|
||||
|
||||
void start_action(std::wstring value);
|
||||
void add_sound (std::wstring href);
|
||||
void add_link (std::wstring href);
|
||||
void end_action();
|
||||
|
||||
std::map<std::wstring, OOX::Vml::CShapeType*> m_mapVmlShapeTypes;
|
||||
|
||||
private:
|
||||
|
||||
@ -214,17 +214,7 @@ void odp_conversion_context::end_note()
|
||||
current_slide().drawing_context()->end_element();
|
||||
current_slide().drawing_context()->end_drawing();
|
||||
}
|
||||
void odp_conversion_context::start_timing()
|
||||
{
|
||||
anim_state anim;
|
||||
anim.elm = current_slide().page_elm_;
|
||||
current_slide().anim_levels.push_back(anim);
|
||||
}
|
||||
void odp_conversion_context::end_timing()
|
||||
{
|
||||
current_slide().anim_levels.pop_back();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,9 +80,6 @@ public:
|
||||
void start_note(bool bMaster = false);
|
||||
void end_note();
|
||||
|
||||
void start_timing();
|
||||
void end_timing();
|
||||
|
||||
private:
|
||||
odp_slide_context slide_context_;
|
||||
|
||||
|
||||
@ -61,8 +61,8 @@ namespace odf_writer {
|
||||
odp_page_state::odp_page_state(odf_conversion_context * Context, office_element_ptr & elm)
|
||||
: context_(Context), drawing_context_(Context), comment_context_(Context)
|
||||
{
|
||||
page_elm_ = elm;
|
||||
|
||||
page_elm_ = elm;
|
||||
page_properties_ = NULL;
|
||||
}
|
||||
void odp_page_state::set_page_id(int id)
|
||||
{
|
||||
@ -113,6 +113,8 @@ void odp_page_state::set_page_style(office_element_ptr & elm)
|
||||
|
||||
if (!office_page_style_)return;
|
||||
|
||||
page_properties_ = office_page_style_->content_.get_style_drawing_page_properties();
|
||||
|
||||
draw_page* page = dynamic_cast<draw_page*>(page_elm_.get());
|
||||
if (page)
|
||||
page->attlist_.draw_style_name_ = office_page_style_->style_name_;
|
||||
@ -142,6 +144,19 @@ void odp_page_state::set_anim_id (int val)
|
||||
|
||||
//anim_levels.back().attlist->smil_begin_ = L"id" + std::to_wstring(val) + L".begin";
|
||||
}
|
||||
void odp_page_state::finalize_page()
|
||||
{
|
||||
if (transactions.empty() == false)
|
||||
{
|
||||
start_timing();
|
||||
start_timing_par();
|
||||
set_anim_duration(-1);
|
||||
set_anim_restart(L"never");
|
||||
set_anim_type(L"tmRoot");
|
||||
end_timing_par();
|
||||
end_timing();
|
||||
}
|
||||
}
|
||||
void odp_page_state::set_anim_type(std::wstring val)
|
||||
{
|
||||
if (anim_levels.empty()) return;
|
||||
@ -150,7 +165,7 @@ void odp_page_state::set_anim_type(std::wstring val)
|
||||
if (val == L"tmRoot")
|
||||
{
|
||||
anim_levels.back().attlist->presentation_node_type_ = L"timing-root";
|
||||
if (page_transaction)
|
||||
if (transactions.empty() == false)
|
||||
{
|
||||
std::wstring slide_id = L"slide_id" + std::to_wstring(page_id_);
|
||||
|
||||
@ -161,19 +176,22 @@ void odp_page_state::set_anim_type(std::wstring val)
|
||||
|
||||
start_timing_par();
|
||||
anim_levels.back().attlist->smil_begin_ = slide_id + L".begin";
|
||||
anim_levels.back().elm->add_child_element( page_transaction );
|
||||
while(!transactions.empty())
|
||||
{
|
||||
anim_levels.back().elm->add_child_element( transactions[0] );
|
||||
transactions.erase(transactions.begin());
|
||||
}
|
||||
end_timing_par();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void odp_page_state::set_anim_duration(std::wstring val)
|
||||
void odp_page_state::set_anim_duration(int val)
|
||||
{
|
||||
if (anim_levels.empty()) return;
|
||||
if (!anim_levels.back().attlist)return;
|
||||
|
||||
//if (val == L"indefinite")
|
||||
anim_levels.back().attlist->smil_dur_ = val;
|
||||
anim_levels.back().attlist->smil_dur_ = odf_types::clockvalue(val);
|
||||
|
||||
}
|
||||
void odp_page_state::set_anim_restart(std::wstring val)
|
||||
@ -185,36 +203,93 @@ void odp_page_state::set_anim_restart(std::wstring val)
|
||||
}
|
||||
void odp_page_state::start_transition()
|
||||
{
|
||||
create_element(L"anim", L"transitionFilter", page_transaction, context_);
|
||||
office_element_ptr elm;
|
||||
create_element(L"anim", L"transitionFilter", elm, context_);
|
||||
|
||||
transactions.push_back(elm);
|
||||
}
|
||||
void odp_page_state::set_transition_type(int val)
|
||||
{
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
|
||||
if (transactions.empty()) return;
|
||||
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(transactions.back().get());
|
||||
if (trans)
|
||||
trans->attlist_.smil_type_ = odf_types::smil_transition_type((odf_types::smil_transition_type::type)val);
|
||||
trans->filter_attlist_.smil_type_ = odf_types::smil_transition_type((odf_types::smil_transition_type::type)val);
|
||||
}
|
||||
void odp_page_state::set_transition_subtype(std::wstring val)
|
||||
{
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
|
||||
if (transactions.empty()) return;
|
||||
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(transactions.back().get());
|
||||
if (trans)
|
||||
trans->attlist_.smil_subtype_ = val;
|
||||
trans->filter_attlist_.smil_subtype_ = val;
|
||||
}
|
||||
void odp_page_state::set_transition_speed(int val)
|
||||
{
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
|
||||
if (transactions.empty()) return;
|
||||
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(transactions.back().get());
|
||||
if (trans)
|
||||
{
|
||||
if (val == 0) trans->attlist_.smil_dur_ = odf_types::clockvalue(3000);
|
||||
if (val == 1) trans->attlist_.smil_dur_ = odf_types::clockvalue(4000);
|
||||
if (val == 2) trans->attlist_.smil_dur_ = odf_types::clockvalue(5000);
|
||||
if (val == 0)
|
||||
{
|
||||
if (page_properties_)
|
||||
page_properties_->content_.presentation_transition_speed_ = L"fast";
|
||||
trans->common_attlist_.smil_dur_ = odf_types::clockvalue(2000);
|
||||
}
|
||||
if (val == 1)
|
||||
{
|
||||
if (page_properties_)
|
||||
page_properties_->content_.presentation_transition_speed_ = L"medium";
|
||||
trans->common_attlist_.smil_dur_ = odf_types::clockvalue(3000);
|
||||
}
|
||||
if (val == 2)
|
||||
{
|
||||
if (page_properties_)
|
||||
page_properties_->content_.presentation_transition_speed_ = L"slow";
|
||||
trans->common_attlist_.smil_dur_ = odf_types::clockvalue(4000);
|
||||
}
|
||||
}
|
||||
}
|
||||
void odp_page_state::set_transition_duration(int val)
|
||||
{
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(page_transaction.get());
|
||||
if (transactions.empty()) return;
|
||||
|
||||
anim_transitionFilter *trans = dynamic_cast<anim_transitionFilter*>(transactions.back().get());
|
||||
if (trans)
|
||||
trans->attlist_.smil_dur_ = odf_types::clockvalue(val * 1000);
|
||||
trans->common_attlist_.smil_dur_ = odf_types::clockvalue(val);
|
||||
}
|
||||
|
||||
void odp_page_state::set_transition_sound(std::wstring ref, bool loop)
|
||||
{
|
||||
if (transactions.empty()) return;
|
||||
if (ref.empty()) return;
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"anim", L"audio", elm, context_);
|
||||
|
||||
anim_audio *audio = dynamic_cast<anim_audio*>(elm.get());
|
||||
if (audio)
|
||||
{
|
||||
audio->audio_attlist_.xlink_href_ = ref;
|
||||
}
|
||||
|
||||
transactions.push_back(elm);
|
||||
|
||||
if (page_properties_)
|
||||
{
|
||||
create_element(L"presentation", L"sound", page_properties_->content_.presentation_sound_, context_);
|
||||
presentation_sound *sound = dynamic_cast<presentation_sound*>(page_properties_->content_.presentation_sound_.get());
|
||||
if (sound)
|
||||
{
|
||||
sound->common_xlink_attlist_.href_ = ref;
|
||||
sound->common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
sound->common_xlink_attlist_.show_ = xlink_show::New;
|
||||
sound->common_xlink_attlist_.actuate_ = xlink_actuate::OnRequest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void odp_page_state::start_timing_seq()
|
||||
{
|
||||
if (anim_levels.empty()) return;
|
||||
@ -231,10 +306,24 @@ void odp_page_state::start_timing_seq()
|
||||
|
||||
anim_levels.push_back(anim);
|
||||
}
|
||||
void odp_page_state::start_timing()
|
||||
{
|
||||
if (!anim_levels.empty()) return;
|
||||
|
||||
anim_state anim;
|
||||
anim.elm = page_elm_;
|
||||
|
||||
anim_levels.push_back(anim);
|
||||
}
|
||||
void odp_page_state::end_timing()
|
||||
{
|
||||
if (anim_levels.empty()) return;
|
||||
anim_levels.pop_back();
|
||||
}
|
||||
void odp_page_state::end_timing_seq()
|
||||
{
|
||||
anim_levels.pop_back();
|
||||
|
||||
if (anim_levels.empty()) return;
|
||||
anim_levels.pop_back();
|
||||
}
|
||||
void odp_page_state::start_timing_par()
|
||||
{
|
||||
@ -254,8 +343,8 @@ void odp_page_state::start_timing_par()
|
||||
}
|
||||
void odp_page_state::end_timing_par()
|
||||
{
|
||||
anim_levels.pop_back();
|
||||
|
||||
if (anim_levels.empty()) return;
|
||||
anim_levels.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,19 +31,13 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include"../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
#include "odf_drawing_context.h"
|
||||
#include "odf_comment_context.h"
|
||||
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include "style_presentation.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
@ -84,7 +78,7 @@ public:
|
||||
void set_layout_page(std::wstring name);
|
||||
|
||||
void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
void finalize_page();
|
||||
///////////////////////////////
|
||||
odf_drawing_context * drawing_context(){return &drawing_context_;}
|
||||
odf_comment_context * comment_context(){return &comment_context_;}
|
||||
@ -94,32 +88,37 @@ public:
|
||||
office_element_ptr page_elm_;
|
||||
office_element_ptr page_style_elm_;
|
||||
|
||||
std::vector<anim_state> anim_levels;
|
||||
office_element_ptr page_transaction;
|
||||
std::vector<anim_state> anim_levels;
|
||||
std::vector<office_element_ptr> transactions;
|
||||
|
||||
void set_anim_id (int val);
|
||||
void set_anim_type (std::wstring val);
|
||||
void set_anim_duration (std::wstring val);
|
||||
void set_anim_restart (std::wstring val);
|
||||
void start_timing();
|
||||
void start_timing_par();
|
||||
void end_timing_par();
|
||||
|
||||
void start_timing_par();
|
||||
void end_timing_par();
|
||||
void start_timing_seq();
|
||||
void end_timing_seq();
|
||||
|
||||
void start_timing_seq();
|
||||
void end_timing_seq();
|
||||
void set_anim_id (int val);
|
||||
void set_anim_type (std::wstring val);
|
||||
void set_anim_duration (int val);
|
||||
void set_anim_restart (std::wstring val);
|
||||
void end_timing();
|
||||
|
||||
void start_transition();
|
||||
void set_transition_type (int val);
|
||||
void set_transition_subtype (std::wstring val);
|
||||
void set_transition_speed (int val);
|
||||
void set_transition_duration(int val);
|
||||
void set_transition_sound (std::wstring ref, bool loop);
|
||||
void end_transition(){}
|
||||
private:
|
||||
|
||||
odf_conversion_context * context_;
|
||||
odf_conversion_context * context_;
|
||||
|
||||
odf_drawing_context drawing_context_;
|
||||
odf_comment_context comment_context_;
|
||||
odf_drawing_context drawing_context_;
|
||||
odf_comment_context comment_context_;
|
||||
|
||||
style_drawing_page_properties* page_properties_;
|
||||
|
||||
friend class odp_slide_context;
|
||||
|
||||
|
||||
@ -81,6 +81,7 @@ void odp_slide_context::start_page(office_element_ptr & elm)
|
||||
void odp_slide_context::end_page()
|
||||
{
|
||||
state().drawing_context()->finalize(state().page_elm_);
|
||||
state().finalize_page();
|
||||
}
|
||||
|
||||
void odp_slide_context::remove_page()
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include "odp_page_state.h"
|
||||
|
||||
#include "odf_table_context.h"
|
||||
|
||||
@ -124,6 +124,8 @@ void office_annotation::create_child_element(const std::wstring & Ns, const std:
|
||||
}
|
||||
void office_annotation::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeDcCreator)
|
||||
@ -186,6 +188,8 @@ void officeooo_annotation::create_child_element( const std::wstring & Ns, const
|
||||
}
|
||||
void officeooo_annotation::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeDcCreator)
|
||||
|
||||
@ -153,6 +153,7 @@ enum ElementType
|
||||
typeStyleFooterStyle,
|
||||
typeStyleHeaderFooterProperties,
|
||||
|
||||
typeStylePresentationSound,
|
||||
typeStylePresentationPageLayout,
|
||||
typeStylePresentationPlaceholder,
|
||||
typeStyleDrawingPageProperties,
|
||||
@ -235,6 +236,7 @@ enum ElementType
|
||||
typeDrawObject,
|
||||
typeDrawObjectOle,
|
||||
typeDrawChart,
|
||||
typeDrawPlugin,
|
||||
|
||||
typeDrawBase,
|
||||
typeDrawShape,
|
||||
@ -267,6 +269,9 @@ enum ElementType
|
||||
typeAnimPar,
|
||||
typeAnimSeq,
|
||||
typeAnimTransitionFilter,
|
||||
typeAnimAudio,
|
||||
typeAnimCommand,
|
||||
typeAnimIterator,
|
||||
|
||||
typeStyleGraphicPropertis,
|
||||
typeStyleDrawGradient,
|
||||
|
||||
158
ASCOfficeOdfFileW/source/OdfFormat/office_event_listeners.cpp
Normal file
158
ASCOfficeOdfFileW/source/OdfFormat/office_event_listeners.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "office_event_listeners.h"
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace odf_writer {
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * office_event_listeners::ns = L"office";
|
||||
const wchar_t * office_event_listeners::name = L"event-listeners";
|
||||
|
||||
void office_event_listeners::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME (L"presentation", L"event-listener")
|
||||
CP_CREATE_ELEMENT (presentation_event_listeners_);
|
||||
else if CP_CHECK_NAME (L"script", L"event-listener")
|
||||
CP_CREATE_ELEMENT (script_event_listeners_);
|
||||
}
|
||||
void office_event_listeners::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typePresentationEventListener)
|
||||
{
|
||||
presentation_event_listeners_.push_back(child_element);
|
||||
}
|
||||
else if (type == typeScriptEventListener)
|
||||
{
|
||||
script_event_listeners_.push_back(child_element);
|
||||
}
|
||||
}
|
||||
|
||||
void office_event_listeners::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < presentation_event_listeners_.size(); i++)
|
||||
{
|
||||
presentation_event_listeners_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
for (size_t i = 0; i < script_event_listeners_.size(); i++)
|
||||
{
|
||||
script_event_listeners_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------
|
||||
void presentation_event_listener_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"script:event-name", script_event_name_);
|
||||
CP_XML_ATTR_OPT(L"presentation:action", presentation_action_);
|
||||
|
||||
common_xlink_attlist_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * presentation_event_listener::ns = L"presentation";
|
||||
const wchar_t * presentation_event_listener::name = L"event-listener";
|
||||
|
||||
void presentation_event_listener::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"presentation", L"sound")
|
||||
CP_CREATE_ELEMENT(presentation_sound_);
|
||||
else
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
void presentation_event_listener::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeStylePresentationSound)
|
||||
{
|
||||
presentation_sound_ = child_element;
|
||||
}
|
||||
}
|
||||
void presentation_event_listener::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
attlist_.serialize(CP_GET_XML_NODE());
|
||||
if (presentation_sound_)
|
||||
presentation_sound_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// script:event-listener
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * script_event_listener::ns = L"script";
|
||||
const wchar_t * script_event_listener::name = L"event-listener";
|
||||
|
||||
void script_event_listener::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void script_event_listener::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void script_event_listener::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
125
ASCOfficeOdfFileW/source/OdfFormat/office_event_listeners.h
Normal file
125
ASCOfficeOdfFileW/source/OdfFormat/office_event_listeners.h
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/xmlelement.h>
|
||||
#include <cpdoccore/xml/nodetype.h>
|
||||
#include "office_elements.h"
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include "common_attlists.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
class office_event_listeners : public office_element_impl<office_event_listeners>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeEventListeners;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array presentation_event_listeners_;
|
||||
office_element_ptr_array script_event_listeners_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_event_listeners);
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
class presentation_event_listener_attlist
|
||||
{
|
||||
public:
|
||||
void serialize(CP_ATTR_NODE);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
_CP_OPT(std::wstring) script_event_name_;
|
||||
_CP_OPT(std::wstring) presentation_action_;
|
||||
//presentation:verb
|
||||
//presentation:start-scale
|
||||
//presentation:speed
|
||||
//presentation:direction
|
||||
//presentation:effect
|
||||
};
|
||||
|
||||
class presentation_event_listener : public office_element_impl<presentation_event_listener>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typePresentationEventListener;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
//office_element_ptr_array content_;
|
||||
office_element_ptr presentation_sound_;
|
||||
presentation_event_listener_attlist attlist_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(presentation_event_listener);
|
||||
|
||||
|
||||
// script:event-listeners_
|
||||
class script_event_listener : public office_element_impl<presentation_event_listener>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeScriptEventListener;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(script_event_listener);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -61,6 +61,8 @@ void office_presentation::create_child_element(const std::wstring & Ns, const st
|
||||
|
||||
void office_presentation::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typePresentationDateTimeDecl)
|
||||
@ -83,7 +85,7 @@ void office_presentation::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (int i = 0; i < pages_.size(); i++)
|
||||
for (size_t i = 0; i < pages_.size(); i++)
|
||||
{
|
||||
pages_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
|
||||
@ -56,8 +56,6 @@ public:
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
public:
|
||||
|
||||
office_element_ptr_array date_time_decls_;
|
||||
office_element_ptr_array footer_decls_;
|
||||
|
||||
|
||||
105
ASCOfficeOdfFileW/source/OdfFormat/office_scripts.cpp
Normal file
105
ASCOfficeOdfFileW/source/OdfFormat/office_scripts.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "office_scripts.h"
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
const wchar_t * office_scripts::ns = L"office";
|
||||
const wchar_t * office_scripts::name = L"scripts";
|
||||
|
||||
|
||||
void office_scripts::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void office_scripts::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void office_scripts::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * office_script::ns = L"office";
|
||||
const wchar_t * office_script::name = L"script";
|
||||
|
||||
|
||||
void office_script::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void office_script::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void office_script::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"script:language", script_language_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
91
ASCOfficeOdfFileW/source/OdfFormat/office_scripts.h
Normal file
91
ASCOfficeOdfFileW/source/OdfFormat/office_scripts.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2017
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cpdoccore/CPOptional.h>
|
||||
#include <cpdoccore/xml/xmlelement.h>
|
||||
#include <cpdoccore/xml/nodetype.h>
|
||||
#include "office_elements.h"
|
||||
#include "office_elements_create.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
class office_scripts : public office_element_impl<office_scripts>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeScripts;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
// office-event-listeners ?
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_scripts);
|
||||
|
||||
class office_script : public office_element_impl<office_script>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeScript;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) script_language_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_script);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -161,6 +161,8 @@ void office_change_info::create_child_element( const std::wstring & Ns, const st
|
||||
}
|
||||
void office_change_info::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeDcCreator)
|
||||
|
||||
@ -435,6 +435,8 @@ void text_note::create_child_element( const std::wstring & Ns, const std::wstri
|
||||
}
|
||||
void text_note::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextNoteCitation)
|
||||
@ -487,6 +489,8 @@ void text_ruby::create_child_element( const std::wstring & Ns, const std::wstrin
|
||||
}
|
||||
void text_ruby::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextRubyBase)
|
||||
|
||||
@ -162,6 +162,8 @@ void paragraph_format_properties::create_child_element(const std::wstring & Ns,
|
||||
}
|
||||
void paragraph_format_properties::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeStyleTabStops)
|
||||
|
||||
@ -42,7 +42,7 @@ namespace cpdoccore {
|
||||
|
||||
namespace odf_writer {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * presentation_placeholder::ns = L"presentation";
|
||||
const wchar_t * presentation_placeholder::name = L"placeholder";
|
||||
|
||||
@ -62,6 +62,20 @@ void presentation_placeholder::serialize(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * presentation_sound::ns = L"presentation";
|
||||
const wchar_t * presentation_sound::name = L"sound";
|
||||
|
||||
void presentation_sound::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
common_xlink_attlist_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void drawing_page_properties::serialize(std::wostream & strm, const wchar_t * ns, const wchar_t * name )
|
||||
@ -85,17 +99,20 @@ void drawing_page_properties::serialize(std::wostream & strm, const wchar_t * ns
|
||||
CP_XML_ATTR_OPT(L"presentation:display-page-number",presentation_display_page_number_);
|
||||
CP_XML_ATTR_OPT(L"presentation:display-date-time", presentation_display_date_time_);
|
||||
CP_XML_ATTR_OPT(L"presentation:display-header", presentation_display_header_);
|
||||
|
||||
if (presentation_sound_)
|
||||
presentation_sound_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * style_drawing_page_properties::ns = L"style";
|
||||
const wchar_t * style_drawing_page_properties::ns = L"style";
|
||||
const wchar_t * style_drawing_page_properties::name = L"drawing-page-properties";
|
||||
|
||||
void style_drawing_page_properties::serialize(std::wostream & strm)
|
||||
{
|
||||
content_.serialize(strm,ns,name);
|
||||
content_.serialize(strm, ns, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -74,11 +74,33 @@ public:
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(presentation_placeholder);
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------
|
||||
class presentation_sound : public office_element_impl<presentation_sound>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeStylePresentationSound;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element( const office_element_ptr & child){}
|
||||
|
||||
virtual void serialize(std::wostream & strm);
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(presentation_sound);
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
class drawing_page_properties
|
||||
{
|
||||
public:
|
||||
void apply_from(const drawing_page_properties & Other);
|
||||
|
||||
void serialize(std::wostream & strm, const wchar_t * ns, const wchar_t * name );
|
||||
|
||||
odf_types::common_draw_fill_attlist common_draw_fill_attlist_;
|
||||
@ -87,23 +109,24 @@ public:
|
||||
_CP_OPT(odf_types::length_or_percent) draw_fill_image_height_;
|
||||
_CP_OPT(odf_types::length_or_percent) draw_fill_image_width_;
|
||||
|
||||
_CP_OPT(std::wstring) draw_background_size_;//"border" or "full"
|
||||
_CP_OPT(std::wstring) draw_background_size_; //"border" or "full"
|
||||
|
||||
_CP_OPT(std::wstring) presentation_transition_type_;//manual, automatic, semi-automatic (переход отделен от эффектов кликом)
|
||||
_CP_OPT(std::wstring) presentation_transition_style_;//none, fade, move, uncover,clockwise, .... игнор если smil
|
||||
_CP_OPT(std::wstring) presentation_transition_speed_;//slow, medium, fast
|
||||
_CP_OPT(std::wstring) presentation_transition_type_; //manual, automatic, semi-automatic (переход отделен от эффектов кликом)
|
||||
_CP_OPT(std::wstring) presentation_transition_style_; //none, fade, move, uncover,clockwise, .... игнор если smil
|
||||
_CP_OPT(std::wstring) presentation_transition_speed_; //slow, medium, fast
|
||||
|
||||
_CP_OPT(bool) presentation_display_footer_;
|
||||
_CP_OPT(bool) presentation_display_page_number_;
|
||||
_CP_OPT(bool) presentation_display_date_time_;
|
||||
_CP_OPT(bool) presentation_display_header_;
|
||||
_CP_OPT(std::wstring) presentation_page_duration_;
|
||||
|
||||
office_element_ptr presentation_sound_;
|
||||
|
||||
//presentation:background-objects-visible
|
||||
//presentation:background-visible
|
||||
//style:repeat
|
||||
//presentation:page-duration
|
||||
//presentation:visibility.
|
||||
//presentation:sound.
|
||||
//presentation:visibility
|
||||
//draw:background-size
|
||||
|
||||
};
|
||||
|
||||
@ -184,6 +184,8 @@ void table_table::create_child_element(const std::wstring & Ns, const std::wstri
|
||||
|
||||
void table_table::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableSource)
|
||||
@ -277,6 +279,8 @@ void table_table_columns::create_child_element(const std::wstring & Ns, const st
|
||||
}
|
||||
void table_table_columns::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableColumn)
|
||||
@ -312,6 +316,8 @@ void table_table_header_columns::create_child_element( const std::wstring & Ns,
|
||||
}
|
||||
void table_table_header_columns::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableColumn)
|
||||
@ -348,6 +354,8 @@ void table_columns::create_child_element( const std::wstring & Ns, const std::ws
|
||||
}
|
||||
void table_columns::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableColumns)
|
||||
@ -400,6 +408,8 @@ void table_columns_no_group::create_child_element( const std::wstring & Ns, con
|
||||
}
|
||||
void table_columns_no_group::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableColumns || type == typeTableTableColumn)
|
||||
@ -489,6 +499,8 @@ void table_columns_and_groups::create_child_element(const std::wstring & Ns, con
|
||||
}
|
||||
void table_columns_and_groups::add_child_element( const office_element_ptr & child_element, odf_conversion_context * Context)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableColumnGroup)
|
||||
@ -608,6 +620,8 @@ void table_table_row::create_child_element( const std::wstring & Ns, const std::
|
||||
}
|
||||
void table_table_row::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableCell || type == typeTableCoveredTableCell )
|
||||
@ -672,6 +686,8 @@ void table_table_header_rows::create_child_element( const std::wstring & Ns, con
|
||||
}
|
||||
void table_table_header_rows::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableRow)
|
||||
@ -709,6 +725,8 @@ void table_rows::create_child_element(const std::wstring & Ns, const std::wstrin
|
||||
}
|
||||
void table_rows::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableRows)
|
||||
@ -761,6 +779,8 @@ void table_rows_no_group::create_child_element( const std::wstring & Ns, const s
|
||||
}
|
||||
void table_rows_no_group::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableRows || type == typeTableTableRow)
|
||||
@ -816,6 +836,8 @@ void table_rows_and_groups::create_child_element( const std::wstring & Ns, const
|
||||
}
|
||||
void table_rows_and_groups::add_child_element( const office_element_ptr & child_element, odf_conversion_context * Context)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableTableRowGroup)
|
||||
|
||||
@ -64,7 +64,9 @@ void table_database_ranges::create_child_element(const std::wstring & Ns, const
|
||||
|
||||
void table_database_ranges::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
ElementType type = child_element->get_type();
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableDatabaseRange)
|
||||
{
|
||||
|
||||
@ -66,7 +66,9 @@ void table_named_expressions::create_child_element(const std::wstring & Ns, cons
|
||||
|
||||
void table_named_expressions::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
ElementType type = child_element->get_type();
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTableNamedRange)
|
||||
{
|
||||
|
||||
@ -255,6 +255,8 @@ void text_section::create_child_element( const std::wstring & Ns, const std::wst
|
||||
|
||||
void text_section::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextSectionSource)
|
||||
@ -510,6 +512,8 @@ void text_unknown_change::create_child_element(const std::wstring & Ns, const st
|
||||
|
||||
void text_unknown_change::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeOfficeChangeInfo)
|
||||
|
||||
@ -171,7 +171,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
{
|
||||
if (!oox_picture)return;
|
||||
|
||||
bool bImage = true;
|
||||
if (oox_picture->spPr.Geometry.is_init())
|
||||
{
|
||||
int type = SimpleTypes::shapetypeRect;
|
||||
@ -203,7 +202,33 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
return;
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
if (oox_picture->nvPicPr.nvPr.media.is_init())
|
||||
{
|
||||
if (oox_picture->nvPicPr.nvPr.media.is<PPTX::Logic::MediaFile>())
|
||||
{
|
||||
PPTX::Logic::MediaFile & media = oox_picture->nvPicPr.nvPr.media.as<PPTX::Logic::MediaFile>();
|
||||
|
||||
std::wstring sID = media.link.get();
|
||||
std::wstring pathMedia = find_link_by_id(sID, 3);
|
||||
|
||||
std::wstring odf_ref = odf_context()->add_media(pathMedia);
|
||||
|
||||
if (!odf_ref.empty())
|
||||
{
|
||||
odf_context()->drawing_context()->start_media(odf_ref);
|
||||
//... params
|
||||
|
||||
OoxConverter::convert(&oox_picture->nvPicPr.cNvPr);
|
||||
OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer());
|
||||
|
||||
odf_context()->drawing_context()->end_media();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
std::wstring odf_ref;
|
||||
std::wstring pathImage;
|
||||
if (oox_picture->blipFill.blip.IsInit())
|
||||
@ -222,7 +247,6 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
|
||||
bEmbedded = false;
|
||||
}
|
||||
}
|
||||
|
||||
odf_context()->drawing_context()->start_image(odf_ref);
|
||||
{
|
||||
double Width = 0, Height = 0;
|
||||
@ -1120,6 +1144,22 @@ void OoxConverter::convert(PPTX::Logic::CNvPr *oox_cnvPr)
|
||||
}
|
||||
if (oox_cnvPr->hlinkClick.IsInit())
|
||||
{
|
||||
odf_context()->drawing_context()->start_action(oox_cnvPr->hlinkClick->action.get_value_or(L""));
|
||||
|
||||
if (oox_cnvPr->hlinkClick->snd.IsInit())
|
||||
{
|
||||
std::wstring sound = find_link_by_id(oox_cnvPr->hlinkClick->snd->embed.get(), 3);
|
||||
|
||||
std::wstring href = odf_context()->add_media(sound);
|
||||
odf_context()->drawing_context()->add_sound(href);
|
||||
}
|
||||
if (oox_cnvPr->hlinkClick->id.IsInit())
|
||||
{
|
||||
std::wstring hlink = find_link_by_id(oox_cnvPr->hlinkClick->id.get(), 2);
|
||||
|
||||
odf_context()->drawing_context()->add_link(hlink);
|
||||
}
|
||||
odf_context()->drawing_context()->end_action();
|
||||
}
|
||||
//nullable_string title;
|
||||
//nullable<Hyperlink> hlinkHover;
|
||||
@ -1146,8 +1186,11 @@ void OoxConverter::convert(PPTX::Logic::NvCxnSpPr *oox_nvSpPr)
|
||||
void OoxConverter::convert(PPTX::Logic::NvPr *oox_nvPr)
|
||||
{
|
||||
if (!oox_nvPr) return;
|
||||
|
||||
|
||||
|
||||
//ph уровнем выше
|
||||
|
||||
}
|
||||
|
||||
void OoxConverter::convert_list_level(PPTX::Logic::TextParagraphPr *oox_para_props, int level)
|
||||
|
||||
@ -304,28 +304,31 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
|
||||
_CP_LOG << L"[error] : no convert element(" << (oox_unknown ? oox_unknown->getType() : -1 ) << L")\n";
|
||||
}
|
||||
}
|
||||
std::wstring OoxConverter::find_link_by (smart_ptr<OOX::File> & oFile, int type)
|
||||
{
|
||||
if (!oFile.IsInit()) return L"";
|
||||
|
||||
std::wstring ref;
|
||||
if (type == 1 && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
|
||||
//void OoxConverter::convert(OOX::Drawing::CLockedCanvas *oox_canvas)
|
||||
//{
|
||||
// if (oox_canvas == NULL)return;
|
||||
//
|
||||
// odf_context()->drawing_context()->start_group();
|
||||
// if (oox_canvas->m_oNvGroupSpPr.IsInit() && oox_canvas->m_oNvGroupSpPr->m_oCNvPr.IsInit())
|
||||
// {
|
||||
// if (oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_sName.IsInit())
|
||||
// odf_context()->drawing_context()->set_group_name(*oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_sName);
|
||||
// if (oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_oId.IsInit())
|
||||
// odf_context()->drawing_context()->set_group_z_order(oox_canvas->m_oNvGroupSpPr->m_oCNvPr->m_oId->GetValue());
|
||||
// }
|
||||
// convert(oox_canvas->m_oGroupSpPr.GetPointer());
|
||||
// convert(oox_canvas->m_oSpPr.GetPointer());
|
||||
//
|
||||
// for (size_t i = 0; i < oox_canvas->m_arrItems.size(); i++)
|
||||
// {
|
||||
// convert(oox_canvas->m_arrItems[i]);
|
||||
// }
|
||||
// odf_context()->drawing_context()->end_group();
|
||||
//}
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
if (type == 2 && OOX::FileTypes::HyperLink == oFile->type())
|
||||
{
|
||||
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
|
||||
if (pHyperlink->bHyperlink)
|
||||
ref = pHyperlink->Uri().GetPath();
|
||||
}
|
||||
if (type == 3)
|
||||
{
|
||||
OOX::Media* pMedia = (OOX::Media*)oFile.operator->();
|
||||
|
||||
ref = pMedia->filename().GetPath();
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
bool OoxConverter::convert(std::wstring sSchemeColor, DWORD & argb)
|
||||
{
|
||||
|
||||
@ -360,6 +360,7 @@ public:
|
||||
virtual PPTX::Theme *oox_theme() = 0;
|
||||
virtual PPTX::Logic::ClrMap *oox_clrMap() {return NULL;}
|
||||
|
||||
std::wstring find_link_by (NSCommon::smart_ptr<OOX::File> & oFile, int type);
|
||||
virtual std::wstring find_link_by_id(std::wstring sId, int t) = 0;
|
||||
virtual NSCommon::smart_ptr<OOX::File> find_file_by_id(std::wstring sId) = 0;
|
||||
|
||||
|
||||
@ -131,48 +131,23 @@ NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
|
||||
|
||||
std::wstring DocxConverter::find_link_by_id (std::wstring sId, int type)
|
||||
{
|
||||
if (!docx_document) return L"";
|
||||
|
||||
std::wstring ref;
|
||||
smart_ptr<OOX::File> oFile;
|
||||
|
||||
if (oox_current_child_document)
|
||||
{
|
||||
oFile = oox_current_child_document->Find(sId);
|
||||
ref = OoxConverter::find_link_by(oFile, type);
|
||||
}
|
||||
if (!ref.empty()) return ref;
|
||||
|
||||
OOX::CDocument *oox_doc = docx_document->GetDocument();
|
||||
|
||||
if (oox_doc == NULL)return L"";
|
||||
|
||||
std::wstring ref;
|
||||
|
||||
if (ref.empty() && oox_current_child_document)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile = oox_current_child_document->Find(sId);
|
||||
if (oFile.IsInit())
|
||||
{
|
||||
if (type==1 && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
if (type==2 && oFile.IsInit() && OOX::FileTypes::HyperLink == oFile->type())
|
||||
{
|
||||
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
|
||||
|
||||
ref = pHyperlink->Uri().GetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
smart_ptr<OOX::File> oFile = docx_document->GetDocument()->Find(sId);
|
||||
if (ref.empty() && oFile.IsInit())
|
||||
{
|
||||
if (type==1 && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
if (type == 2 && OOX::FileTypes::HyperLink == oFile->type())
|
||||
{
|
||||
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
|
||||
|
||||
ref = pHyperlink->Uri().GetPath();
|
||||
}
|
||||
}
|
||||
if (oox_doc == NULL) return L"";
|
||||
|
||||
oFile = oox_doc->Find(sId);
|
||||
ref = OoxConverter::find_link_by(oFile, type);
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
@ -168,43 +168,20 @@ NSCommon::smart_ptr<OOX::File> PptxConverter::find_file_by_id(std::wstring sId)
|
||||
|
||||
std::wstring PptxConverter::find_link_by_id (std::wstring sId, int type)
|
||||
{
|
||||
std::wstring ref;
|
||||
if(!pptx_document) return L"";
|
||||
|
||||
if (ref.empty() && oox_current_child_document)
|
||||
std::wstring ref;
|
||||
smart_ptr<OOX::File> oFile;
|
||||
|
||||
if (oox_current_child_document)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile = oox_current_child_document->Find(sId);
|
||||
if (oFile.IsInit())
|
||||
{
|
||||
if (type==1 && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
if (type==2 && oFile.IsInit() && OOX::FileTypes::HyperLink == oFile->type())
|
||||
{
|
||||
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
|
||||
|
||||
ref = pHyperlink->Uri().GetPath();
|
||||
}
|
||||
}
|
||||
oFile = oox_current_child_document->Find(sId);
|
||||
ref = OoxConverter::find_link_by(oFile, type);
|
||||
}
|
||||
smart_ptr<OOX::File> oFile = current_slide ? current_slide->Find(sId) : pptx_document->Find(sId);
|
||||
if (ref.empty() && oFile.IsInit())
|
||||
{
|
||||
if (type==1 && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
if (!ref.empty()) return ref;
|
||||
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
if (type == 2 && OOX::FileTypes::HyperLink == oFile->type())
|
||||
{
|
||||
OOX::HyperLink* pHyperlink = (OOX::HyperLink*)oFile.operator->();
|
||||
|
||||
ref = pHyperlink->Uri().GetPath();
|
||||
}
|
||||
}
|
||||
oFile = current_slide ? current_slide->Find(sId) : pptx_document->Find(sId);
|
||||
ref = OoxConverter::find_link_by(oFile, type);
|
||||
|
||||
return ref;
|
||||
}
|
||||
@ -378,8 +355,8 @@ void PptxConverter::convert_slides()
|
||||
if (slide->Layout->transition.IsInit()) convert (slide->Layout->transition.GetPointer());
|
||||
else convert (slide->Master->transition.GetPointer());
|
||||
|
||||
if (slide->Layout->timing.IsInit()) convert (slide->Layout->timing.GetPointer());
|
||||
else convert (slide->Master->timing.GetPointer());
|
||||
//if (slide->Layout->timing.IsInit()) convert (slide->Layout->timing.GetPointer());
|
||||
//else convert (slide->Master->timing.GetPointer());
|
||||
|
||||
if (!presentation->notesMasterIdLst.empty())
|
||||
{
|
||||
@ -430,7 +407,7 @@ void PptxConverter::convert_slides()
|
||||
convert (slide->Note.operator->());
|
||||
|
||||
convert (slide->transition.GetPointer());
|
||||
convert (slide->timing.GetPointer());
|
||||
//convert (slide->timing.GetPointer());
|
||||
|
||||
|
||||
odp_context->end_slide();
|
||||
@ -577,15 +554,15 @@ void PptxConverter::convert( PPTX::Logic::Transition *oox_transition )
|
||||
|
||||
convert(oox_transition->base.base.operator->());
|
||||
|
||||
//if (oox_transition->sndAc.is_init() && oox_transition->sndAc->stSnd.is_init())
|
||||
//{
|
||||
// std::wstring sID = oox_transition->sndAc->stSnd->embed->get();
|
||||
// pathAudio = find_link_by_id(sID, 1);
|
||||
//
|
||||
// std::wstring odf_ref = odf_context()->add_media(pathAudio);
|
||||
if (oox_transition->sndAc.is_init() && oox_transition->sndAc->stSnd.is_init())
|
||||
{
|
||||
std::wstring sID = oox_transition->sndAc->stSnd->embed.get();
|
||||
std::wstring pathAudio = find_link_by_id(sID, 3);
|
||||
|
||||
std::wstring odf_ref = odf_context()->add_media(pathAudio);
|
||||
|
||||
// odp_context->current_slide().set_transition_sound(odf_ref, oox_transition->sndAc->stSnd->loop.get_value_or(false));
|
||||
//}
|
||||
odp_context->current_slide().set_transition_sound(odf_ref, oox_transition->sndAc->stSnd->loop.get_value_or(false));
|
||||
}
|
||||
|
||||
odp_context->current_slide().end_transition();
|
||||
}
|
||||
@ -594,14 +571,14 @@ void PptxConverter::convert(PPTX::Logic::Timing *oox_timing)
|
||||
if (!oox_timing) return;
|
||||
if (!oox_timing->tnLst.IsInit()) return;
|
||||
|
||||
odp_context->start_timing();
|
||||
odp_context->current_slide().start_timing();
|
||||
for (size_t i = 0; i < oox_timing->tnLst->list.size(); i++)
|
||||
{
|
||||
if (oox_timing->tnLst->list[i].is_init() == false) continue;
|
||||
|
||||
convert(&oox_timing->tnLst->list[i]);
|
||||
}
|
||||
odp_context->end_timing();
|
||||
odp_context->current_slide().end_timing();
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::TimeNodeBase *oox_time_base)
|
||||
{
|
||||
@ -630,7 +607,10 @@ void PptxConverter::convert(PPTX::Logic::EmptyTransition *oox_transition)
|
||||
if (oox_transition->name == L"random")
|
||||
odp_context->current_slide().set_transition_type(40);
|
||||
if (oox_transition->name == L"circle")
|
||||
{
|
||||
odp_context->current_slide().set_transition_type(16);
|
||||
odp_context->current_slide().set_transition_subtype(L"circle");
|
||||
}
|
||||
if (oox_transition->name == L"dissolve")
|
||||
odp_context->current_slide().set_transition_type(39);
|
||||
if (oox_transition->name == L"diamond")
|
||||
@ -639,9 +619,12 @@ void PptxConverter::convert(PPTX::Logic::EmptyTransition *oox_transition)
|
||||
odp_context->current_slide().set_transition_subtype(L"diamond");
|
||||
}
|
||||
if (oox_transition->name == L"newsflash")
|
||||
odp_context->current_slide().set_transition_type(5);
|
||||
odp_context->current_slide().set_transition_type(24);
|
||||
if (oox_transition->name == L"plus")
|
||||
odp_context->current_slide().set_transition_type(2);//??
|
||||
{
|
||||
odp_context->current_slide().set_transition_type(19);
|
||||
odp_context->current_slide().set_transition_subtype(L"fourPoint");
|
||||
}
|
||||
if (oox_transition->name == L"wedge")
|
||||
odp_context->current_slide().set_transition_type(24);
|
||||
}
|
||||
@ -649,10 +632,6 @@ void PptxConverter::convert(PPTX::Logic::OrientationTransition *oox_transition)
|
||||
{
|
||||
if (!oox_transition) return;
|
||||
|
||||
if (oox_transition->name == L"blinds")
|
||||
odp_context->current_slide().set_transition_type(38);
|
||||
if (oox_transition->name == L"checker")
|
||||
odp_context->current_slide().set_transition_type(37);
|
||||
if (oox_transition->name == L"comb")
|
||||
{
|
||||
odp_context->current_slide().set_transition_type(34);
|
||||
@ -665,8 +644,23 @@ void PptxConverter::convert(PPTX::Logic::OrientationTransition *oox_transition)
|
||||
odp_context->current_slide().set_transition_subtype(L"combVertical");
|
||||
}
|
||||
}
|
||||
if (oox_transition->name == L"randomBar")
|
||||
odp_context->current_slide().set_transition_type(40);
|
||||
else
|
||||
{
|
||||
if (oox_transition->name == L"blinds")
|
||||
odp_context->current_slide().set_transition_type(38);
|
||||
else if (oox_transition->name == L"checker")
|
||||
odp_context->current_slide().set_transition_type(37);
|
||||
else if (oox_transition->name == L"randomBar")
|
||||
odp_context->current_slide().set_transition_type(40);
|
||||
|
||||
//if (oox_transition->dir.IsInit())
|
||||
//{
|
||||
// if (oox_transition->dir->get() == L"horz")
|
||||
// odp_context->current_slide().set_transition_subtype(L"combHorizontal");
|
||||
// if (oox_transition->dir->get() == L"vert")
|
||||
// odp_context->current_slide().set_transition_subtype(L"combVertical");
|
||||
//}
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::EightDirectionTransition *oox_transition)
|
||||
{
|
||||
@ -676,6 +670,19 @@ void PptxConverter::convert(PPTX::Logic::EightDirectionTransition *oox_transitio
|
||||
odp_context->current_slide().set_transition_type(1);
|
||||
if (oox_transition->name == L"pull")
|
||||
odp_context->current_slide().set_transition_type(35);
|
||||
|
||||
if (oox_transition->dir.IsInit())
|
||||
{
|
||||
if (oox_transition->dir->get() == L"d") odp_context->current_slide().set_transition_subtype(L"fromTop");
|
||||
else if (oox_transition->dir->get() == L"l") odp_context->current_slide().set_transition_subtype(L"fromRight");
|
||||
else if (oox_transition->dir->get() == L"r") odp_context->current_slide().set_transition_subtype(L"fromLeft");
|
||||
else if (oox_transition->dir->get() == L"u") odp_context->current_slide().set_transition_subtype(L"fromBottom");
|
||||
|
||||
else if (oox_transition->dir->get() == L"rd") odp_context->current_slide().set_transition_subtype(L"horizontalLeft");
|
||||
else if (oox_transition->dir->get() == L"lu") odp_context->current_slide().set_transition_subtype(L"horizontalRight");
|
||||
else if (oox_transition->dir->get() == L"ld") odp_context->current_slide().set_transition_subtype(L"verticalRight");
|
||||
else if (oox_transition->dir->get() == L"ru") odp_context->current_slide().set_transition_subtype(L"verticalLeft");
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::OptionalBlackTransition *oox_transition)
|
||||
{
|
||||
@ -690,19 +697,18 @@ void PptxConverter::convert(PPTX::Logic::SideDirectionTransition *oox_transition
|
||||
{
|
||||
if (!oox_transition) return;
|
||||
|
||||
std::wstring dir;
|
||||
if (oox_transition->dir.IsInit()) dir = oox_transition->dir->get();
|
||||
|
||||
if (oox_transition->name == L"push")
|
||||
{
|
||||
odp_context->current_slide().set_transition_type(34);
|
||||
if (dir == L"d") odp_context->current_slide().set_transition_subtype(L"fromTop");
|
||||
if (dir == L"l") odp_context->current_slide().set_transition_subtype(L"fromRight");
|
||||
if (dir == L"r") odp_context->current_slide().set_transition_subtype(L"fromLeft");
|
||||
if (dir == L"u") odp_context->current_slide().set_transition_subtype(L"fromBottom");
|
||||
}
|
||||
if (oox_transition->name == L"wipe")
|
||||
odp_context->current_slide().set_transition_type(0);
|
||||
|
||||
if (oox_transition->dir.IsInit())
|
||||
{
|
||||
if (oox_transition->dir->get() == L"d") odp_context->current_slide().set_transition_subtype(L"fromTop");
|
||||
else if (oox_transition->dir->get() == L"l") odp_context->current_slide().set_transition_subtype(L"fromRight");
|
||||
else if (oox_transition->dir->get() == L"r") odp_context->current_slide().set_transition_subtype(L"fromLeft");
|
||||
else if (oox_transition->dir->get() == L"u") odp_context->current_slide().set_transition_subtype(L"fromBottom");
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::CornerDirectionTransition *oox_transition)
|
||||
{
|
||||
@ -712,16 +718,17 @@ void PptxConverter::convert(PPTX::Logic::CornerDirectionTransition *oox_transiti
|
||||
|
||||
if (oox_transition->dir.IsInit())
|
||||
{
|
||||
if (oox_transition->dir->get() == L"rd") odp_context->current_slide().set_transition_subtype(L"horizontalLeft");
|
||||
if (oox_transition->dir->get() == L"lu") odp_context->current_slide().set_transition_subtype(L"horizontalRight");
|
||||
if (oox_transition->dir->get() == L"ld") odp_context->current_slide().set_transition_subtype(L"verticalRight");
|
||||
if (oox_transition->dir->get() == L"rd") odp_context->current_slide().set_transition_subtype(L"horizontalLeft");
|
||||
else if (oox_transition->dir->get() == L"lu") odp_context->current_slide().set_transition_subtype(L"horizontalRight");
|
||||
else if (oox_transition->dir->get() == L"ld") odp_context->current_slide().set_transition_subtype(L"verticalRight");
|
||||
else if (oox_transition->dir->get() == L"ru") odp_context->current_slide().set_transition_subtype(L"verticalLeft");
|
||||
}
|
||||
}
|
||||
void PptxConverter::convert(PPTX::Logic::WheelTransition *oox_transition)
|
||||
{
|
||||
if (!oox_transition) return;
|
||||
//name == wheel
|
||||
odp_context->current_slide().set_transition_type(21);
|
||||
odp_context->current_slide().set_transition_type(22);
|
||||
|
||||
switch (oox_transition->spokes.get_value_or(0))
|
||||
{
|
||||
@ -758,7 +765,10 @@ void PptxConverter::convert(PPTX::Logic::CTn *oox_time_common)
|
||||
}
|
||||
if (oox_time_common->dur.IsInit())
|
||||
{
|
||||
odp_context->current_slide().set_anim_duration(*oox_time_common->dur);
|
||||
if (*oox_time_common->dur == L"indefinite")
|
||||
odp_context->current_slide().set_anim_duration(-1);
|
||||
else
|
||||
odp_context->current_slide().set_anim_duration(XmlUtils::GetInteger(*oox_time_common->dur));
|
||||
}
|
||||
if (oox_time_common->restart.IsInit())
|
||||
{
|
||||
|
||||
@ -115,30 +115,20 @@ smart_ptr<OOX::File> XlsxConverter::find_file_by_id(std::wstring sId)
|
||||
}
|
||||
std::wstring XlsxConverter::find_link_by_id (std::wstring sId, int type)
|
||||
{
|
||||
std::wstring ref;
|
||||
smart_ptr<OOX::File> oFile;
|
||||
std::wstring ref;
|
||||
|
||||
if (type == 1)
|
||||
if (xlsx_current_container)
|
||||
{
|
||||
if (ref.empty() && xlsx_current_container)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile = xlsx_current_container->Find(sId);
|
||||
if (oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
oFile = xlsx_current_container->Find(sId);
|
||||
ref = OoxConverter::find_link_by(oFile, type);
|
||||
}
|
||||
if (!ref.empty()) return ref;
|
||||
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
}
|
||||
if (ref.empty() && oox_current_child_document)
|
||||
{
|
||||
smart_ptr<OOX::File> oFile = oox_current_child_document->Find(sId);
|
||||
if (oFile.IsInit() && OOX::FileTypes::Image == oFile->type())
|
||||
{
|
||||
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
|
||||
|
||||
ref = pImage->filename().GetPath();
|
||||
}
|
||||
}
|
||||
if (oox_current_child_document)
|
||||
{
|
||||
oFile = oox_current_child_document->Find(sId);
|
||||
ref = OoxConverter::find_link_by(oFile, type);
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
|
||||
@ -401,6 +401,14 @@
|
||||
RelativePath="..\OdfFormat\office_chart.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\OdfFormat\office_event_listeners.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\OdfFormat\office_event_listeners.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\OdfFormat\office_presentation.cpp"
|
||||
>
|
||||
@ -409,6 +417,14 @@
|
||||
RelativePath="..\OdfFormat\office_presentation.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\OdfFormat\office_scripts.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\OdfFormat\office_scripts.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\OdfFormat\office_settings.cpp"
|
||||
>
|
||||
|
||||
@ -114,9 +114,14 @@ namespace PPTX
|
||||
pRelation->Type() == OOX::Presentation::FileTypes::Slide))
|
||||
{// + external audio, video ...
|
||||
|
||||
smart_ptr<OOX::File> file;
|
||||
smart_ptr<OOX::File> file = smart_ptr<OOX::File>(new OOX::HyperLink(pRelation->Target()));
|
||||
|
||||
file = smart_ptr<OOX::File>(new OOX::HyperLink(pRelation->Target()));
|
||||
if (pRelation->Type() == OOX::Presentation::FileTypes::Slide)
|
||||
{
|
||||
OOX::HyperLink *link = dynamic_cast<OOX::HyperLink*>(file.operator->());
|
||||
if (link)
|
||||
link->bHyperlink = false;
|
||||
}
|
||||
|
||||
normPath = pRelation->Target();
|
||||
Add(pRelation->rId(), file);
|
||||
|
||||
@ -52,8 +52,6 @@ namespace OOX
|
||||
~External()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void read(const CPath& uri)
|
||||
{
|
||||
m_uri = uri;
|
||||
@ -61,9 +59,7 @@ namespace OOX
|
||||
virtual void write(const CPath& filename, const CPath& directory, CContentTypes& content) const
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
CPath Uri() const
|
||||
CPath Uri() const
|
||||
{
|
||||
return m_uri;
|
||||
}
|
||||
|
||||
@ -43,16 +43,16 @@ namespace OOX
|
||||
public:
|
||||
HyperLink()
|
||||
{
|
||||
bHyperlink = true;
|
||||
}
|
||||
HyperLink(const CPath& uri)
|
||||
{
|
||||
bHyperlink = true;
|
||||
read(uri);
|
||||
}
|
||||
~HyperLink()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual const FileType type() const
|
||||
{
|
||||
return FileTypes::HyperLink;
|
||||
@ -65,6 +65,8 @@ namespace OOX
|
||||
{
|
||||
return type().DefaultFileName();
|
||||
}
|
||||
|
||||
bool bHyperlink; // in pptx link to slide perhaps
|
||||
};
|
||||
} // namespace OOX
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ namespace OOX
|
||||
}
|
||||
Audio(const CPath& filename)
|
||||
{
|
||||
read(filename);
|
||||
}
|
||||
virtual ~Audio()
|
||||
{
|
||||
|
||||
@ -1,5 +1,20 @@
|
||||
DEFINES += HAVE_VA_COPY
|
||||
|
||||
core_static_link_xml_full {
|
||||
DEFINES += \
|
||||
LIBXML_READER_ENABLED \
|
||||
LIBXML_PUSH_ENABLED \
|
||||
LIBXML_HTML_ENABLED \
|
||||
LIBXML_XPATH_ENABLED \
|
||||
LIBXML_OUTPUT_ENABLED \
|
||||
LIBXML_C14N_ENABLED \
|
||||
LIBXML_SAX1_ENABLED \
|
||||
LIBXML_TREE_ENABLED \
|
||||
LIBXML_XPTR_ENABLED \
|
||||
IN_LIBXML \
|
||||
LIBXML_STATIC
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PWD/../../libxml2/include \
|
||||
$$PWD/../../libxml2/include/libxml \
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
#ifndef _XMLSIGNER_CERTIFICATE_H_
|
||||
#define _XMLSIGNER_CERTIFICATE_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include "XmlSigner_mscrypto.h"
|
||||
#define CCertificate CCertificate_mscrypto
|
||||
#endif
|
||||
|
||||
#if defined(_LINUX) && !defined(_MAC)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MAC
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _XMLSIGNER_CERTIFICATE_H_
|
||||
@ -1,55 +0,0 @@
|
||||
#ifndef _XMLSIGNER_BASE_H_
|
||||
#define _XMLSIGNER_BASE_H_
|
||||
|
||||
#include "../../common/File.h"
|
||||
#include "../../common/BigInteger.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#define OOXML_HASH_ALG_SHA1 0
|
||||
#define OOXML_HASH_ALG_INVALID 1
|
||||
|
||||
class ICertificate
|
||||
{
|
||||
public:
|
||||
ICertificate()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ICertificate()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string GetNumber() = 0;
|
||||
virtual std::wstring GetSignerName() = 0;
|
||||
|
||||
virtual std::string GetCertificateBase64() = 0;
|
||||
virtual std::string GetCertificateHash() = 0;
|
||||
|
||||
public:
|
||||
virtual std::string Sign(std::string sXml) = 0;
|
||||
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg) = 0;
|
||||
virtual std::string GetHash(std::string& sXml, int nAlg) = 0;
|
||||
virtual std::string GetHash(std::wstring& sXmlFile, int nAlg) = 0;
|
||||
virtual bool Verify(std::string& sXml, std::string& sXmlSignature, int nAlg) = 0;
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data) = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
|
||||
static int 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;
|
||||
|
||||
return OOXML_HASH_ALG_INVALID;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _XMLSIGNER_BASE_H_
|
||||
23
DesktopEditor/xmlsec/src/include/OOXMLSigner.h
Normal file
23
DesktopEditor/xmlsec/src/include/OOXMLSigner.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef _XML_OOXMLSIGNER_H_
|
||||
#define _XML_OOXMLSIGNER_H_
|
||||
|
||||
#include "./XmlCertificate.h"
|
||||
|
||||
class COOXMLSigner_private;
|
||||
class Q_DECL_EXPORT COOXMLSigner
|
||||
{
|
||||
public:
|
||||
COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext);
|
||||
~COOXMLSigner();
|
||||
|
||||
void SetGuid(const std::wstring& guid);
|
||||
void SetImageValid(const std::wstring& file);
|
||||
void SetImageInvalid(const std::wstring& file);
|
||||
|
||||
void Sign();
|
||||
|
||||
private:
|
||||
COOXMLSigner_private* m_internal;
|
||||
};
|
||||
|
||||
#endif //_XML_OOXMLSIGNER_H_
|
||||
48
DesktopEditor/xmlsec/src/include/OOXMLVerifier.h
Normal file
48
DesktopEditor/xmlsec/src/include/OOXMLVerifier.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef _XML_OOXMLVERIFIER_H_
|
||||
#define _XML_OOXMLVERIFIER_H_
|
||||
|
||||
#include "./XmlCertificate.h"
|
||||
|
||||
#define OOXML_SIGNATURE_VALID 0
|
||||
#define OOXML_SIGNATURE_INVALID 1
|
||||
#define OOXML_SIGNATURE_NOTSUPPORTED 2
|
||||
#define OOXML_SIGNATURE_BAD 3
|
||||
|
||||
class COOXMLSignature_private;
|
||||
class Q_DECL_EXPORT COOXMLSignature
|
||||
{
|
||||
public:
|
||||
COOXMLSignature();
|
||||
~COOXMLSignature();
|
||||
|
||||
public:
|
||||
int GetValid();
|
||||
std::string GetGuid();
|
||||
ICertificate* GetCertificate();
|
||||
std::string GetImageValidBase64();
|
||||
std::string GetImageInvalidBase64();
|
||||
|
||||
public:
|
||||
void Check();
|
||||
|
||||
friend class COOXMLVerifier_private;
|
||||
friend class COOXMLVerifier;
|
||||
private:
|
||||
COOXMLSignature_private* m_internal;
|
||||
};
|
||||
|
||||
class COOXMLVerifier_private;
|
||||
class Q_DECL_EXPORT COOXMLVerifier
|
||||
{
|
||||
public:
|
||||
COOXMLVerifier(const std::wstring& sFolder);
|
||||
~COOXMLVerifier();
|
||||
|
||||
int GetSignatureCount();
|
||||
COOXMLSignature* GetSignature(const int& index);
|
||||
|
||||
private:
|
||||
COOXMLVerifier_private* m_internal;
|
||||
};
|
||||
|
||||
#endif //_XML_OOXMLVERIFIER_H_
|
||||
47
DesktopEditor/xmlsec/src/include/XmlCertificate.h
Normal file
47
DesktopEditor/xmlsec/src/include/XmlCertificate.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef _XML_SERTIFICATE_BASE_H_
|
||||
#define _XML_SERTIFICATE_BASE_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../../../common/base_export.h"
|
||||
|
||||
#define OOXML_HASH_ALG_SHA1 0
|
||||
#define OOXML_HASH_ALG_INVALID 1
|
||||
|
||||
class Q_DECL_EXPORT ICertificate
|
||||
{
|
||||
public:
|
||||
ICertificate()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ICertificate()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string GetNumber() = 0;
|
||||
virtual std::wstring GetSignerName() = 0;
|
||||
|
||||
virtual std::string GetCertificateBase64() = 0;
|
||||
virtual std::string GetCertificateHash() = 0;
|
||||
|
||||
public:
|
||||
virtual std::string Sign(const std::string& sXml) = 0;
|
||||
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg) = 0;
|
||||
virtual std::string GetHash(const std::string& sXml, int nAlg) = 0;
|
||||
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;
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog() = 0;
|
||||
virtual int ShowCertificate() = 0;
|
||||
|
||||
public:
|
||||
static int GetOOXMLHashAlg(const std::string& sAlg);
|
||||
static ICertificate* CreateInstance();
|
||||
};
|
||||
|
||||
#endif // _XML_SERTIFICATE_BASE_H_
|
||||
48
DesktopEditor/xmlsec/src/ooxmlsignature.pro
Normal file
48
DesktopEditor/xmlsec/src/ooxmlsignature.pro
Normal file
@ -0,0 +1,48 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.1
|
||||
TARGET = ooxmlsignature
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
CONFIG += core_static_link_xml_full
|
||||
include($$CORE_ROOT_DIR/DesktopEditor/xml/build/qt/libxml2.pri)
|
||||
|
||||
DEFINES -= UNICODE
|
||||
|
||||
HEADERS += \
|
||||
include/XmlCertificate.h \
|
||||
include/OOXMLSigner.h \
|
||||
include/OOXMLVerifier.h
|
||||
|
||||
HEADERS += \
|
||||
src/XmlCanonicalizator.h \
|
||||
src/XmlRels.h \
|
||||
src/XmlTransform.h \
|
||||
src/XmlSigner_mscrypto.h \
|
||||
src/XmlSigner_openssl.h
|
||||
|
||||
SOURCES += \
|
||||
src/XmlTransform.cpp \
|
||||
src/XmlCertificate.cpp \
|
||||
src/OOXMLSigner.cpp \
|
||||
src/OOXMLVerifier.cpp
|
||||
|
||||
core_windows {
|
||||
|
||||
LIBS += -lcrypt32
|
||||
LIBS += -lcryptui
|
||||
LIBS += -lAdvapi32
|
||||
|
||||
}
|
||||
@ -1,11 +1,7 @@
|
||||
#ifndef _XML_OOXMLSIGNER_H_
|
||||
#define _XML_OOXMLSIGNER_H_
|
||||
#include "./../include/OOXMLSigner.h"
|
||||
#include "./../src/XmlTransform.h"
|
||||
|
||||
#include "./XmlCanonicalizator.h"
|
||||
#include "./XmlSignerBase.h"
|
||||
#include "./XmlTransform.h"
|
||||
|
||||
class COOXMLSigner
|
||||
class COOXMLSigner_private
|
||||
{
|
||||
public:
|
||||
ICertificate* m_certificate;
|
||||
@ -25,7 +21,7 @@ public:
|
||||
std::wstring m_guid;
|
||||
|
||||
public:
|
||||
COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext)
|
||||
COOXMLSigner_private(const std::wstring& sFolder, ICertificate* pContext)
|
||||
{
|
||||
m_sFolder = sFolder;
|
||||
m_certificate = pContext;
|
||||
@ -35,7 +31,7 @@ public:
|
||||
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\"/>");
|
||||
}
|
||||
~COOXMLSigner()
|
||||
~COOXMLSigner_private()
|
||||
{
|
||||
}
|
||||
|
||||
@ -44,7 +40,8 @@ public:
|
||||
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"<DigestValue>";
|
||||
sXml += UTF8_TO_U(m_certificate->GetHash(m_sFolder + file, OOXML_HASH_ALG_SHA1));
|
||||
std::string sTmp = m_certificate->GetHash(m_sFolder + file, OOXML_HASH_ALG_SHA1);
|
||||
sXml += UTF8_TO_U(sTmp);
|
||||
sXml += L"</DigestValue>";
|
||||
sXml += L"</Reference>";
|
||||
return sXml;
|
||||
@ -560,4 +557,32 @@ Type=\"http://schemas.openxmlformats.org/package/2006/relationships/digital-sign
|
||||
}
|
||||
};
|
||||
|
||||
#endif //_XML_OOXMLSIGNER_H_
|
||||
COOXMLSigner::COOXMLSigner(const std::wstring& sFolder, ICertificate* pContext)
|
||||
{
|
||||
m_internal = new COOXMLSigner_private(sFolder, pContext);
|
||||
}
|
||||
|
||||
COOXMLSigner::~COOXMLSigner()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
void COOXMLSigner::SetGuid(const std::wstring& guid)
|
||||
{
|
||||
m_internal->SetGuid(guid);
|
||||
}
|
||||
|
||||
void COOXMLSigner::SetImageValid(const std::wstring& file)
|
||||
{
|
||||
m_internal->SetImageValid(file);
|
||||
}
|
||||
|
||||
void COOXMLSigner::SetImageInvalid(const std::wstring& file)
|
||||
{
|
||||
m_internal->SetImageInvalid(file);
|
||||
}
|
||||
|
||||
void COOXMLSigner::Sign()
|
||||
{
|
||||
m_internal->Sign();
|
||||
}
|
||||
@ -1,18 +1,10 @@
|
||||
#ifndef _XML_OOXMLVERIFIER_H_
|
||||
#define _XML_OOXMLVERIFIER_H_
|
||||
|
||||
#include "./XmlCanonicalizator.h"
|
||||
#include "./XmlTransform.h"
|
||||
#include "./XmlCertificate.h"
|
||||
#include "./../include/OOXMLVerifier.h"
|
||||
|
||||
#define OOXML_SIGNATURE_VALID 0
|
||||
#define OOXML_SIGNATURE_INVALID 1
|
||||
#define OOXML_SIGNATURE_NOTSUPPORTED 2
|
||||
#define OOXML_SIGNATURE_BAD 3
|
||||
|
||||
class COOXMLSignature
|
||||
class COOXMLSignature_private
|
||||
{
|
||||
private:
|
||||
public:
|
||||
int m_valid;
|
||||
std::string m_guid;
|
||||
ICertificate* m_cert;
|
||||
@ -22,7 +14,6 @@ private:
|
||||
|
||||
std::wstring m_sFolder;
|
||||
|
||||
private:
|
||||
XmlUtils::CXmlNode m_node; // signature file
|
||||
|
||||
class CXmlStackNamespaces
|
||||
@ -133,13 +124,13 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
COOXMLSignature()
|
||||
COOXMLSignature_private()
|
||||
{
|
||||
m_valid = OOXML_SIGNATURE_INVALID;
|
||||
m_guid = "";
|
||||
m_cert = NULL;
|
||||
}
|
||||
~COOXMLSignature()
|
||||
~COOXMLSignature_private()
|
||||
{
|
||||
RELEASEOBJECT(m_cert);
|
||||
}
|
||||
@ -176,7 +167,7 @@ public:
|
||||
m_valid = OOXML_SIGNATURE_NOTSUPPORTED;
|
||||
return;
|
||||
}
|
||||
m_cert = new CCertificate();
|
||||
m_cert = ICertificate::CreateInstance();
|
||||
if (!m_cert->LoadFromBase64Data(U_TO_UTF8(oNodeCert.GetText())))
|
||||
{
|
||||
m_valid = OOXML_SIGNATURE_NOTSUPPORTED;
|
||||
@ -273,7 +264,7 @@ public:
|
||||
|
||||
friend class COOXMLVerifier;
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
int CheckManifestReference(XmlUtils::CXmlNode& node)
|
||||
{
|
||||
@ -391,14 +382,54 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
class COOXMLVerifier
|
||||
COOXMLSignature::COOXMLSignature()
|
||||
{
|
||||
m_internal = new COOXMLSignature_private();
|
||||
}
|
||||
|
||||
COOXMLSignature::~COOXMLSignature()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
int COOXMLSignature::GetValid()
|
||||
{
|
||||
return m_internal->GetValid();
|
||||
}
|
||||
|
||||
std::string COOXMLSignature::GetGuid()
|
||||
{
|
||||
return m_internal->GetGuid();
|
||||
}
|
||||
|
||||
ICertificate* COOXMLSignature::GetCertificate()
|
||||
{
|
||||
return m_internal->GetCertificate();
|
||||
}
|
||||
|
||||
std::string COOXMLSignature::GetImageValidBase64()
|
||||
{
|
||||
return m_internal->GetImageValidBase64();
|
||||
}
|
||||
|
||||
std::string COOXMLSignature::GetImageInvalidBase64()
|
||||
{
|
||||
return m_internal->GetImageInvalidBase64();
|
||||
}
|
||||
|
||||
void COOXMLSignature::Check()
|
||||
{
|
||||
m_internal->Check();
|
||||
}
|
||||
|
||||
class COOXMLVerifier_private
|
||||
{
|
||||
public:
|
||||
std::wstring m_sFolder;
|
||||
std::vector<COOXMLSignature*> m_arSignatures;
|
||||
|
||||
public:
|
||||
COOXMLVerifier(const std::wstring& sFolder)
|
||||
COOXMLVerifier_private(const std::wstring& sFolder)
|
||||
{
|
||||
m_sFolder = sFolder;
|
||||
|
||||
@ -429,14 +460,14 @@ public:
|
||||
continue;
|
||||
|
||||
COOXMLSignature* pSignature = new COOXMLSignature();
|
||||
pSignature->m_node = nodeSig;
|
||||
pSignature->m_sFolder = m_sFolder;
|
||||
pSignature->m_internal->m_node = nodeSig;
|
||||
pSignature->m_internal->m_sFolder = m_sFolder;
|
||||
pSignature->Check();
|
||||
|
||||
m_arSignatures.push_back(pSignature);
|
||||
}
|
||||
}
|
||||
~COOXMLVerifier()
|
||||
~COOXMLVerifier_private()
|
||||
{
|
||||
for (std::vector<COOXMLSignature*>::iterator i = m_arSignatures.begin(); i != m_arSignatures.end(); i++)
|
||||
{
|
||||
@ -447,4 +478,22 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#endif //_XML_OOXMLVERIFIER_H_
|
||||
COOXMLVerifier::COOXMLVerifier(const std::wstring& sFolder)
|
||||
{
|
||||
m_internal = new COOXMLVerifier_private(sFolder);
|
||||
}
|
||||
|
||||
COOXMLVerifier::~COOXMLVerifier()
|
||||
{
|
||||
RELEASEOBJECT(m_internal);
|
||||
}
|
||||
|
||||
int COOXMLVerifier::GetSignatureCount()
|
||||
{
|
||||
return (int)m_internal->m_arSignatures.size();
|
||||
}
|
||||
|
||||
COOXMLSignature* COOXMLVerifier::GetSignature(const int& index)
|
||||
{
|
||||
return m_internal->m_arSignatures[index];
|
||||
}
|
||||
@ -1,12 +1,12 @@
|
||||
#ifndef _XML_CANONICALIZATOR_H_
|
||||
#define _XML_CANONICALIZATOR_H_
|
||||
|
||||
#include "../../common/File.h"
|
||||
#include "../../common/Directory.h"
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/Directory.h"
|
||||
|
||||
#include "../../common/StringBuilder.h"
|
||||
#include "../../xml/include/xmlutils.h"
|
||||
#include "../../xml/libxml2/include/libxml/c14n.h"
|
||||
#include "../../../common/StringBuilder.h"
|
||||
#include "../../../xml/include/xmlutils.h"
|
||||
#include "../../../xml/libxml2/include/libxml/c14n.h"
|
||||
|
||||
#ifndef XML_UNUSED
|
||||
#define XML_UNUSED( arg ) ( (arg) = (arg) )
|
||||
28
DesktopEditor/xmlsec/src/src/XmlCertificate.cpp
Normal file
28
DesktopEditor/xmlsec/src/src/XmlCertificate.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#ifdef WIN32
|
||||
#include "./XmlSigner_mscrypto.h"
|
||||
#define CCertificate CCertificate_mscrypto
|
||||
#endif
|
||||
|
||||
#if defined(_LINUX) && !defined(_MAC)
|
||||
#include "./XmlSigner_openssl.h"
|
||||
#define CCertificate CCertificate_openssl
|
||||
#endif
|
||||
|
||||
#ifdef _MAC
|
||||
#include "./XmlSigner_openssl.h"
|
||||
#define CCertificate CCertificate_openssl
|
||||
#endif
|
||||
|
||||
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;
|
||||
|
||||
return OOXML_HASH_ALG_INVALID;
|
||||
}
|
||||
|
||||
ICertificate* ICertificate::CreateInstance()
|
||||
{
|
||||
return new CCertificate();
|
||||
}
|
||||
@ -154,7 +154,7 @@ public:
|
||||
return builder.GetData();
|
||||
}
|
||||
|
||||
void CheckOriginSigs(std::wstring& file)
|
||||
void CheckOriginSigs(const std::wstring& file)
|
||||
{
|
||||
int rId = 0;
|
||||
std::vector<COOXMLRelationship>::iterator i = rels.begin();
|
||||
@ -1,13 +1,16 @@
|
||||
#ifndef _XMLSIGNER_MSCRYPTO_H_
|
||||
#define _XMLSIGNER_MSCRYPTO_H_
|
||||
|
||||
#include "./XmlSignerBase.h"
|
||||
#include "./include/XmlCertificate.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#include <cryptuiapi.h>
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
class CCertificate_mscrypto : public ICertificate
|
||||
{
|
||||
public:
|
||||
@ -97,7 +100,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string Sign(std::string sXml)
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
BOOL bResult = TRUE;
|
||||
DWORD dwKeySpec = 0;
|
||||
@ -237,12 +240,12 @@ public:
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
virtual std::string GetHash(std::string& sXml, int nAlg)
|
||||
virtual std::string GetHash(const std::string& sXml, int nAlg)
|
||||
{
|
||||
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length(), nAlg);
|
||||
}
|
||||
|
||||
virtual std::string GetHash(std::wstring& sXmlFile, int nAlg)
|
||||
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg)
|
||||
{
|
||||
BYTE* pFileData = NULL;
|
||||
DWORD dwFileDataLen = 0;
|
||||
@ -257,7 +260,7 @@ public:
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
virtual bool Verify(std::string& sXml, std::string& sXmlSignature, int nAlg)
|
||||
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
|
||||
{
|
||||
DWORD dwKeySpec = 0;
|
||||
HCRYPTHASH hHash = NULL;
|
||||
101
DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h
Normal file
101
DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h
Normal file
@ -0,0 +1,101 @@
|
||||
#ifndef _XMLSIGNER_OPENSSL_H_
|
||||
#define _XMLSIGNER_OPENSSL_H_
|
||||
|
||||
#include "./include/XmlCertificate.h"
|
||||
|
||||
#include "../../../common/File.h"
|
||||
#include "../../../common/BigInteger.h"
|
||||
|
||||
class CCertificate_openssl : public ICertificate
|
||||
{
|
||||
public:
|
||||
|
||||
protected:
|
||||
BYTE* m_rawData;
|
||||
int m_rawDataLen;
|
||||
|
||||
public:
|
||||
CCertificate_openssl() : ICertificate()
|
||||
{
|
||||
m_rawData = NULL;
|
||||
m_rawDataLen = 0;
|
||||
}
|
||||
virtual ~CCertificate_openssl()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string GetNumber()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::wstring GetSignerName()
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
virtual std::string GetCertificateBase64()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::string GetCertificateHash()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::string Sign(const std::string& sXml)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual std::string GetHash(const std::string& sXml, int nAlg)
|
||||
{
|
||||
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length(), nAlg);
|
||||
}
|
||||
|
||||
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg)
|
||||
{
|
||||
BYTE* pFileData = NULL;
|
||||
DWORD dwFileDataLen = 0;
|
||||
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
|
||||
|
||||
if (0 == dwFileDataLen)
|
||||
return "";
|
||||
|
||||
std::string sReturn = GetHash(pFileData, dwFileDataLen, nAlg);
|
||||
|
||||
RELEASEARRAYOBJECTS(pFileData);
|
||||
return sReturn;
|
||||
}
|
||||
|
||||
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool LoadFromBase64Data(const std::string& data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int ShowCertificate()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual bool ShowSelectDialog()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _XMLSIGNER_OPENSSL_H_
|
||||
21
DesktopEditor/xmlsec/src/src/XmlTransform.cpp
Normal file
21
DesktopEditor/xmlsec/src/src/XmlTransform.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "./XmlTransform.h"
|
||||
|
||||
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg)
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformRelationship* transform = new CXmlTransformRelationship();
|
||||
if (transform->m_algorithm == alg)
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformC14N* transform = new CXmlTransformC14N();
|
||||
if (transform->CheckC14NTransform(alg))
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -122,26 +122,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
IXmlTransform* IXmlTransform::GetFromType(const std::string& alg)
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformRelationship* transform = new CXmlTransformRelationship();
|
||||
if (transform->m_algorithm == alg)
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
if (true)
|
||||
{
|
||||
CXmlTransformC14N* transform = new CXmlTransformC14N();
|
||||
if (transform->CheckC14NTransform(alg))
|
||||
return transform;
|
||||
RELEASEOBJECT(transform);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
class CXmlTransforms
|
||||
{
|
||||
protected:
|
||||
@ -1,12 +1,10 @@
|
||||
#include "../../src/XmlCertificate.h"
|
||||
#include "../../src/OOXMLSigner.h"
|
||||
#include "../../src/OOXMLVerifier.h"
|
||||
#include "../../src/include/XmlCertificate.h"
|
||||
#include "../../src/include/OOXMLSigner.h"
|
||||
#include "../../src/include/OOXMLVerifier.h"
|
||||
|
||||
#pragma comment (lib, "crypt32.lib")
|
||||
#pragma comment (lib, "cryptui.lib")
|
||||
#pragma comment (lib, "Advapi32.lib")
|
||||
#include "../../../common/File.h"
|
||||
|
||||
void main(void)
|
||||
int main(void)
|
||||
{
|
||||
//std::wstring sFolderOOOXML = NSFile::GetProcessDirectory() + L"/ImageStamp";
|
||||
//std::wstring sSignId = L"{39B6B9C7-60AD-45A2-9F61-40C74A24042E}";
|
||||
@ -17,31 +15,35 @@ void main(void)
|
||||
{
|
||||
std::wstring sSignId = L"{9792D33F-AB37-4E5B-A465-481B9465818B}";
|
||||
|
||||
CCertificate oCertificate;
|
||||
if (!oCertificate.ShowSelectDialog())
|
||||
return;
|
||||
ICertificate* pCertificate = ICertificate::CreateInstance();
|
||||
if (!pCertificate->ShowSelectDialog())
|
||||
{
|
||||
RELEASEOBJECT(pCertificate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
COOXMLSigner oOOXMLSigner(sFolderOOXML, &oCertificate);
|
||||
COOXMLSigner oOOXMLSigner(sFolderOOXML, pCertificate);
|
||||
|
||||
oOOXMLSigner.SetGuid(sSignId);
|
||||
oOOXMLSigner.SetImageValid(NSFile::GetProcessDirectory() + L"/../../../resources/valid.png");
|
||||
oOOXMLSigner.SetImageInvalid(NSFile::GetProcessDirectory() + L"/../../../resources/invalid.png");
|
||||
|
||||
oOOXMLSigner.Sign();
|
||||
|
||||
RELEASEOBJECT(pCertificate);
|
||||
}
|
||||
else
|
||||
{
|
||||
COOXMLVerifier oVerifier(sFolderOOXML);
|
||||
|
||||
size_t nCount = oVerifier.m_arSignatures.size();
|
||||
for (std::vector<COOXMLSignature*>::iterator i = oVerifier.m_arSignatures.begin(); i != oVerifier.m_arSignatures.end(); i++)
|
||||
int nCount = oVerifier.GetSignatureCount();
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
COOXMLSignature* pSign = *i;
|
||||
COOXMLSignature* pSign = oVerifier.GetSignature(i);
|
||||
int nRes = pSign->GetValid();
|
||||
XML_UNUSED(pSign);
|
||||
XML_UNUSED(nRes);
|
||||
pSign = pSign;
|
||||
nRes = nRes;
|
||||
}
|
||||
|
||||
XML_UNUSED(nCount);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -10,26 +10,8 @@ CORE_ROOT_DIR = $$PWD/../../../../
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
DEFINES -= UNICODE
|
||||
|
||||
DEFINES += \
|
||||
LIBXML_READER_ENABLED \
|
||||
LIBXML_PUSH_ENABLED \
|
||||
LIBXML_HTML_ENABLED \
|
||||
LIBXML_XPATH_ENABLED \
|
||||
LIBXML_OUTPUT_ENABLED \
|
||||
LIBXML_C14N_ENABLED \
|
||||
LIBXML_SAX1_ENABLED \
|
||||
LIBXML_TREE_ENABLED \
|
||||
LIBXML_XPTR_ENABLED \
|
||||
LIBXML_STATIC
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -llibxml
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/xml/libxml2/include/libxml
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -looxmlsignature
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user