Compare commits

...

39 Commits

Author SHA1 Message Date
13b7306b99 . 2016-12-06 20:07:10 +03:00
b98a545d8c OdfFormatReader - ole embedded .... 2016-12-06 20:05:17 +03:00
ceb2c7863b Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2016-12-06 15:03:45 +03:00
26cedc30fa OdfFormatReader - embedded objects (ods in odt example) 2016-12-06 14:58:58 +03:00
c0f29521c4 Merge tag 'v4.2.1' into develop
v4.2.1
2016-12-06 14:52:30 +03:00
13d57361e4 Merge branch 'hotfix/v4.2.1' 2016-12-06 14:52:20 +03:00
1e04770e31 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  DocFormatReader - fix users file
  Revert "DocFormatReader - users file fix"
  DocFormatReader - users file fix OdfFormatReader - fix alphabetic text index
  DocFormatReaer - users file fix OdfFormatReader - fix alphabetic text index
  Removed version number
2016-12-05 17:38:07 +03:00
6666ba0236 insert images in collaboration mode 2016-12-05 17:37:59 +03:00
e6c334199f DocFormatReader - fix users file 2016-12-05 15:51:49 +03:00
6d75b03cc0 . 2016-12-05 15:48:23 +03:00
303b62c2a1 DocFormatReader - fix users file 2016-12-05 15:48:04 +03:00
5109acb888 Revert "DocFormatReader - users file fix"
This reverts commit cbc4a5d334.
2016-12-05 15:46:36 +03:00
cbc4a5d334 DocFormatReader - users file fix
OdfFormatReader - fix alphabetic text index
2016-12-05 15:46:05 +03:00
a639fc9eaf Revert "Merge branch 'develop' into hotfix/v4.2.1"
This reverts commit 9cc54393a0, reversing
changes made to 29b4a10435.
2016-12-05 15:37:35 +03:00
9cc54393a0 Merge branch 'develop' into hotfix/v4.2.1 2016-12-05 15:31:00 +03:00
16386f4b5c DocFormatReaer - users file fix
OdfFormatReader - fix alphabetic text index
2016-12-05 15:17:40 +03:00
149c0ae72a Merge tag 'v4.2.0' into develop
v4.2.0 v4.2.0
2016-12-05 11:39:08 +03:00
29b4a10435 Merge branch 'release/v4.2.0' 2016-12-05 11:39:06 +03:00
1cf9401e0a Removed version number 2016-12-02 18:43:51 +03:00
c6a05e493f OdfFormatReader - .. 2016-12-01 20:06:19 +03:00
82e82971d0 Changed architecture detection for linux and macos 2016-12-01 18:00:15 +03:00
4b8c2b4f6d Update Makefile 2016-12-01 16:09:25 +03:00
a7e3158c06 Merge branch 'release/v4.2.0' into develop 2016-11-30 16:18:25 +03:00
329077caaf . 2016-11-30 14:20:09 +03:00
b75495c4ba write tableStyle without tableStyleElement 2016-11-30 12:21:01 +03:00
807eace056 . 2016-11-30 12:03:55 +03:00
cfdc8c9051 x2t version up 2.0.2.417 2016-11-29 19:39:27 +03:00
da18ecd89c OdfFormatReader - fix same small bags 2016-11-29 19:35:08 +03:00
7ae68b53db OdfFormatReader - fix same small bags 2016-11-29 16:55:22 +03:00
57bd7a0d93 for bug 33110 2016-11-29 16:46:23 +03:00
daba1ad2a3 DocFormatReader - fix bug #33397 2016-11-29 14:38:57 +03:00
755ea97af8 OdfFormatReader - fix same bugs 2016-11-28 19:20:53 +03:00
0f9669aa2b x2t version up 2.0.2.415 2016-11-28 11:07:18 +03:00
71aabb5f3f OdfFormatReader - fix bugs in track changes 2016-11-28 10:19:08 +03:00
18a963231a PPTFormatReader - shape convert fix 2016-11-27 17:09:36 +03:00
e3d6d370f7 Update Makefile 2016-11-26 11:30:39 +03:00
b06681bd97 OdfFormatReader - fix mac build, ... 2016-11-25 18:37:01 +03:00
ab4412155d Switched build sequence for the all target
It done in hope to escape double building the libraries.
2016-11-25 18:13:53 +03:00
f37394db00 OdfFormatReader - fix errors content 2016-11-24 18:29:51 +03:00
80 changed files with 1618 additions and 1110 deletions

View File

@ -41,7 +41,7 @@
namespace DocFileFormat
{
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller) : _skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL),
_fldCharCounter(0), AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_endnoteNr(0), _commentNr(0), _caller(caller)
{
@ -53,6 +53,10 @@ namespace DocFileFormat
_writeInstrText = false;
_isSectionPageBreak = 0;
_isTextBoxContent = false;
//--------------------------------------------
_embeddedObject = false;
_writeInstrText = false;
}
DocumentMapping::DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller):_skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL), _writeInstrText(false),
@ -67,6 +71,7 @@ namespace DocFileFormat
_writeInstrText = false;
_isSectionPageBreak = 0;
_isTextBoxContent = false;
_embeddedObject = false;
}
DocumentMapping::~DocumentMapping()
@ -643,13 +648,13 @@ namespace DocFileFormat
}
cpFieldSep1 = cpFieldSep2;
}
_skipRuns = 5;
_skipRuns = 5; //with separator
}
}
else if ( bEMBED || bLINK || bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
@ -731,14 +736,8 @@ namespace DocFileFormat
}
}
if (bEMBED)
{
//Приложения_011015.doc(9 стр) ellipt_eq.doc конфликтные
cp = cpFieldEnd;
_skipRuns = 3;
}
else
_skipRuns = 5;
_skipRuns = 3;
_embeddedObject = true;
}
else
{
@ -759,6 +758,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteString( elem.GetXMLString().c_str() );
}
if (_embeddedObject) _skipRuns += 2;
}
else if (TextMark::FieldEndMark == code)
{
@ -781,6 +781,7 @@ namespace DocFileFormat
{
_writeInstrText = false;
}
_embeddedObject = false;
}
else if ((TextMark::Symbol == code) && fSpec)
{

View File

@ -137,6 +137,7 @@ namespace DocFileFormat
ParagraphPropertyExceptions* _lastValidPapx;
SectionPropertyExceptions* _lastValidSepx;
bool _embeddedObject;
int _skipRuns;
int _sectionNr;
int _footnoteNr;

View File

@ -87,19 +87,19 @@ namespace DocFileFormat
case sprmOldTDefTable:
case sprmTDefTable:
{ //table definition
{
//table definition
SprmTDefTable tDef( iter->Arguments, iter->argumentsSize );
//Workaround for retrieving the indent of the table:
//In some files there is a indent but no sprmTWidthIndent is set.
//For this cases we can calculate the indent of the table by getting the
//first boundary of the TDef and adding the padding of the cells
tblIndent = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
//add the gabHalf
tblIndent += gabHalf;
//If there follows a real sprmTWidthIndent, this value will be overwritten
tblIndent = (std::max)((int)tblIndent,0);
//tblIndent = (std::max)((int)tblIndent,0); //cerere.doc
}
break;

View File

@ -76,7 +76,7 @@ public:
{}
std::wostream & xml_to_stream(std::wostream & _Wostream) const;
const std::wstring & part_name() const { return part_name_; }
const std::wstring & part_name() const { return part_name_; }
const std::wstring & content_type() const { return content_type_; }
public:

View File

@ -82,12 +82,15 @@ void text_tracked_context::start_changes_content()
void text_tracked_context::end_changes_content()
{
docx_context_.finish_run(); //0106GS-GettingStartedWithWriter_el.odt - удаленный заголовок
current_state_.content.push_back(changes_stream_.str());
docx_context_.set_delete_text_state (false);
docx_context_.set_paragraph_state (bParaStateDocx_);
docx_context_.set_run_state (bRunStateDocx_);
docx_context_.set_delete_text_state (false);
current_state_.content = changes_stream_.str();
docx_context_.set_stream_man(docx_stream_);
docx_context_.set_stream_man (docx_stream_);
}
void text_tracked_context::start_change (std::wstring id)
{
@ -129,29 +132,29 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
mediaitems_ (OdfDocument->get_folder() ),
next_dump_page_properties_(false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
text_tracked_context_ (*this),
table_context_ (*this),
output_document_ (NULL),
section_properties_in_table_(NULL),
process_note_ (noNote),
new_list_style_number_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_(false),
process_comment_ (false),
math_context_ (false),
odf_document_ (OdfDocument)
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
text_tracked_context_ (*this),
table_context_ (*this),
output_document_ (NULL),
process_note_ (noNote),
new_list_style_number_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_ (false),
process_comment_ (false),
mediaitems_ (OdfDocument->get_folder() ),
math_context_ (OdfDocument->odf_context().fontContainer(), false),
odf_document_ (OdfDocument)
{
streams_man_ = streams_man::create(temp_stream_);
applicationFonts_ = new CApplicationFonts();
@ -832,13 +835,20 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
//in_styles = true -> styles.xml
//почему то конструкция <pPr><rPr/></pPr><rPr/> "не работает" в части в rPr в ms2010 )
{
bool in_drawing = false;
if (get_drawing_context().get_current_shape() || get_drawing_context().get_current_frame())
{
in_drawing = true;
}
std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes();
std::wstringstream & run_style = get_styles_context().text_style();
CP_XML_WRITER(strm)
{
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
&& !get_table_context().in_table())
&& !get_table_context().in_table() && !in_drawing)
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
CP_XML_NODE(L"w:pPr")
{
@ -853,7 +863,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
{
CP_XML_NODE(L"w:pPr")
{
if ( !get_table_context().in_table() )
if ( !get_table_context().in_table() && !in_drawing)
{
CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();
@ -1102,7 +1112,7 @@ void docx_conversion_context::docx_serialize_list_properties(std::wostream & str
void docx_conversion_context::add_delayed_element(odf_reader::office_element * Elm)
{
delayed_elements_.push_back(Elm);
delayed_elements_.push_back(Elm);
}
void docx_conversion_context::docx_convert_delayed()
@ -1110,14 +1120,15 @@ void docx_conversion_context::docx_convert_delayed()
if (delayed_elements_.empty()) return;
if(delayed_converting_)return; //зацикливание иначе
if(get_drawing_context().get_current_level() > 0 )return; //вложенный frame
if(get_drawing_context().get_current_level() > 0 )
return; //вложенный frame
delayed_converting_ = true;
while(!delayed_elements_.empty())
{
odf_reader::office_element * elm = delayed_elements_.front();
elm->docx_convert(*this);
delayed_elements_.pop_front();
delayed_elements_.pop_front();
}
delayed_converting_=false;
}
@ -1128,19 +1139,6 @@ void section_context::add_section(const std::wstring & SectionName, const std::w
sections_.push_back(newSec);
}
void docx_conversion_context::section_properties_in_table(odf_reader::office_element * Elm)
{
section_properties_in_table_ = Elm;
}
odf_reader::office_element * docx_conversion_context::get_section_properties_in_table()
{
odf_reader::office_element * elm = section_properties_in_table_;
section_properties_in_table_ = NULL;
return elm;
}
namespace
{
// обработка Header/Footer
@ -1273,31 +1271,47 @@ typedef std::map<std::wstring, text_tracked_context::_state>::iterator map_chang
void docx_conversion_context::start_text_changes (std::wstring id)
{
text_tracked_context::_state &state = text_tracked_context_.get_tracked_change(id);
if (state.id != id) return;
text_tracked_context::_state &state_add = text_tracked_context_.get_tracked_change(id);
if (state_add.id != id) return;
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state));
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state_add));
if (in_paragraph_ && (state.type == 1 || state.type == 2))
if (in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
{
finish_run();
if (state.type == 1) output_stream() << L"<w:ins";
if (state.type == 2) output_stream() << L"<w:del";
output_stream() << L" w:date=\"" << state.date << L"\"";
output_stream() << L" w:author=\"" << state.author << L"\"";
output_stream() << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\"";
output_stream() << L">";
map_changes_iterator it = map_current_changes_.find(id);
text_tracked_context::_state &state = it->second;
if (state.type == 2)
output_stream() << state.content;
std::wstring format_change = L" w:date=\"" + state.date + L"\"" +
L" w:author=\"" + state.author + L"\"" ;
finish_run();
state.active = true;
if (state.type == 1)
{
output_stream() << L"<w:ins" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
}
if (state.type == 2)
{
for (int i = 0 ; i < state.content.size(); i++)
{
output_stream() << L"<w:del" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
output_stream() << state.content[i];
output_stream() << L"</w:del>";
}
map_current_changes_.erase(it);
}
}
}
void docx_conversion_context::start_changes()
{
if (map_current_changes_.empty()) return;
if (process_comment_) return;
text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear();
@ -1309,8 +1323,8 @@ void docx_conversion_context::start_changes()
{
text_tracked_context::_state &state = it->second;
if (state.type == 0) continue; //unknown change ... todooo
if (state.type == 0) continue; //unknown change ... todooo
if (state.active) continue;
std::wstring change_attr;
change_attr += L" w:date=\"" + state.date + L"\"";
@ -1396,16 +1410,21 @@ void docx_conversion_context::start_changes()
void docx_conversion_context::end_changes()
{
//for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
//{
// text_tracked_context::_state &state = it->second;
if (process_comment_) return;
// if (state.type == 0) continue; //unknown change ... libra format change skip
// if (state.type == 3) continue;
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
{
text_tracked_context::_state &state = it->second;
// if (state.type == 1) output_stream() << L"</w:ins>";
// if (state.type == 2) output_stream() << L"</w:del>";
//}
if (state.type == 0) continue; //unknown change ... libra format change skip
if (state.type == 3) continue;
if (!state.active) continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
state.active = false;
}
text_tracked_context_.dumpTcPr_.clear();
text_tracked_context_.dumpTblPr_.clear();
@ -1421,14 +1440,15 @@ void docx_conversion_context::end_text_changes (std::wstring id)
if (it == map_current_changes_.end()) return;
if (in_paragraph_)
text_tracked_context::_state &state = it->second;
if (state.active)
{
finish_run();
text_tracked_context::_state &state = it->second;
if (in_paragraph_)
finish_run();
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
}
map_current_changes_.erase(it);

View File

@ -490,13 +490,14 @@ class text_tracked_context
public:
struct _state
{
std::wstring id;
std::wstring author;
std::wstring date;
int type;
std::wstring content; //delete elements
std::wstring style_name;
std::wstring id;
std::wstring author;
std::wstring date;
int type;
std::wstring style_name;
std::vector<std::wstring> content; //delete elements
bool active;
void clear()
{
type = 0;
@ -504,6 +505,7 @@ public:
author.clear();
date.clear();
content.clear();
active = false;
}
};
std::wstring dumpPPr_;
@ -683,9 +685,6 @@ public:
docx_table_context & get_table_context() { return table_context_; }
odf_reader::office_element * get_section_properties_in_table();
void section_properties_in_table (odf_reader::office_element * Elm);
StreamsManPtr get_stream_man() const { return streams_man_; }
void set_stream_man(StreamsManPtr Sm) { streams_man_ = Sm; }
@ -752,23 +751,23 @@ private:
odf_reader::odf_document * odf_document_;
CApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_;
std::vector<odf_reader::_property> settings_properties_;
hyperlinks hyperlinks_;
mediaitems mediaitems_;
hyperlinks hyperlinks_;
mediaitems mediaitems_;
std::vector<oox_chart_context_ptr> charts_;
headers_footers headers_footers_;
std::wstring automatic_parent_style_;
std::list< const odf_reader::style_text_properties * > text_properties_stack_;
std::wstring automatic_parent_style_;
std::wstring current_master_page_name_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool page_break_after_;
bool page_break_before_;
bool page_break_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool in_automatic_style_;
bool in_drawing_content_;
bool in_paragraph_;
@ -777,25 +776,14 @@ private:
bool is_delete_text_;
bool is_rtl_; // right-to-left
bool is_paragraph_keep_;
NoteType process_note_;
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
NoteType process_note_;
std::list<odf_reader::office_element *> delayed_elements_;
std::vector<oox_chart_context_ptr> charts_;
odf_reader::office_element * section_properties_in_table_;
headers_footers headers_footers_;
std::wstring current_master_page_name_;
// счетчик для нумерации имен созданных в процессе конвертации стилей
int new_list_style_number_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
// цепочки переименований нумераций
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;
std::list< const odf_reader::style_text_properties * > text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций
};
}

View File

@ -187,12 +187,10 @@ void serialize_wrap(std::wostream & strm, _docx_drawing const & val)
}
}
void docx_serialize_text(std::wostream & strm, _docx_drawing & val)
void _docx_drawing::serialize_text(std::wostream & strm)
{
const std::vector<odf_reader::_property> & properties = val.additional;
_CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty(properties,L"text-content",strTextContent);
odf_reader::GetProperty(additional, L"text-content", strTextContent);
CP_XML_WRITER(strm)
{
@ -209,7 +207,7 @@ void docx_serialize_text(std::wostream & strm, _docx_drawing & val)
}
}
oox_serialize_bodyPr(strm, val, L"wps");
serialize_bodyPr(strm, L"wps");
}
//--------------------------------------------------------------------
@ -240,11 +238,11 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"pic:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(), val);
val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst",L"rect");
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
@ -280,13 +278,12 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
}
CP_XML_NODE(L"wps:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
oox_serialize_shape(CP_XML_STREAM(),val);
val.serialize_xfrm (CP_XML_STREAM());
val.serialize_shape (CP_XML_STREAM());
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
docx_serialize_text(CP_XML_STREAM(),val);
val.serialize_text(CP_XML_STREAM());
}
}
}
@ -306,13 +303,14 @@ void docx_serialize_group_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"wpg:grpSpPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
}
CP_XML_STREAM() << val.content_group_;
}
}
}
void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
@ -321,7 +319,7 @@ void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
@ -332,9 +330,9 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
{
CP_XML_NODE(L"wp:docPr")
{
CP_XML_ATTR(L"name",val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
}
CP_XML_NODE(L"wp:cNvGraphicFramePr")
@ -355,6 +353,11 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
docx_serialize_shape_child(CP_XML_STREAM(), val);
}
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
else if (val.type == typeImage)
{
CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
@ -365,11 +368,6 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
docx_serialize_chart_child(CP_XML_STREAM(), val);
}
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
}
}
}
@ -435,12 +433,11 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"y",0);
}
CP_XML_NODE(L"wp:positionH")
{
std::wstring relativeFrom = L"margin";
if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
CP_XML_ATTR(L"relativeFrom", relativeFrom);
if (val.styleHorizontalPos &&
@ -453,16 +450,15 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
else
{
CP_XML_NODE(L"wp:posOffset") {CP_XML_STREAM() << val.posOffsetH;}
}
}
}
CP_XML_NODE(L"wp:positionV")
{
std::wstring relativeFrom = L"margin";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
std::wstring relativeFrom = L"paragraph";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
CP_XML_ATTR(L"relativeFrom",relativeFrom);
CP_XML_ATTR(L"relativeFrom", relativeFrom);
if (val.styleVerticalPos &&
val.styleVerticalPos->get_type() != odf_types::vertical_pos::FromTop &&
@ -481,17 +477,49 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
}
}
}
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx",val.cx);
CP_XML_ATTR(L"cy",val.cy);
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
serialize_wrap(CP_XML_STREAM(), val);
}
docx_serialize_common(CP_XML_STREAM(), val);
if (val.pctWidth)
{
std::wstring relativeFrom = L"margin";
if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
if (relativeFrom == L"column") relativeFrom = L"margin";
CP_XML_NODE(L"wp14:sizeRelH")
{
CP_XML_ATTR(L"relativeFrom", relativeFrom);
CP_XML_NODE(L"wp14:pctWidth")
{
CP_XML_STREAM() << (val.pctWidth.get() * 1000);
}
}
}
if (val.pctHeight)
{
std::wstring relativeFrom = L"paragraph";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
if (relativeFrom == L"paragraph") relativeFrom = L"margin";
CP_XML_NODE(L"wp14:sizeRelV")
{
CP_XML_ATTR(L"relativeFrom", relativeFrom);
CP_XML_NODE(L"wp14:pctHeight")
{
CP_XML_STREAM() << (val.pctHeight.get() * 1000);
}
}
}
}
}
}
@ -547,16 +575,64 @@ void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val)
}
}
}
void docx_serialize(std::wostream & strm, _docx_drawing & val, bool insideOtherDrawing)
void docx_serialize_object(std::wostream & strm, _docx_drawing & val)
{
if (val.inGroup)
return docx_serialize_child(strm, val);
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:object")
{
CP_XML_NODE(L"v:shape")
{
CP_XML_ATTR(L"id", L"ole_" + val.objectId);
CP_XML_ATTR(L"o:ole", "");
std::wstring style_str; // = L"width:730.6pt; height:261.8pt";
style_str += L"width:" + std::to_wstring(val.cx / 12700.) + L"pt;";
style_str += L"height:" + std::to_wstring(val.cy / 12700.) + L"pt;";
CP_XML_ATTR(L"style", style_str);
if (val.fill.bitmap)
{
CP_XML_NODE(L"v:imagedata")
{
CP_XML_ATTR(L"o:title", val.name);
CP_XML_ATTR(L"r:id", val.fill.bitmap->rId);
}
}
}
CP_XML_NODE(L"o:OLEObject")
{
CP_XML_ATTR(L"Type", L"Embed");
CP_XML_ATTR(L"ProgID", val.objectProgId);
CP_XML_ATTR(L"ShapeID", L"ole_" + val.objectId);
CP_XML_ATTR(L"DrawAspect", L"Content" );
CP_XML_ATTR(L"ObjectID", 0x583A3000 + val.id );
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
}
void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
{
if (type == typeUnknown) return;
if (inGroup)
return docx_serialize_child(strm, *this);
//if (insideOtherDrawing)
docx_serialize_wps(strm, val);
//else
// docx_serialize_alt_content(strm, val);
if (type == typeObject)
{
docx_serialize_object(strm, *this);
}
else
{
//if (insideOtherDrawing)
docx_serialize_wps(strm, *this);
//else
// docx_serialize_alt_content(strm, val);
}
}

View File

@ -44,22 +44,24 @@
namespace cpdoccore {
namespace oox {
struct _docx_drawing : _oox_drawing
class _docx_drawing : public _oox_drawing
{
_docx_drawing():_oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
public:
_docx_drawing() : _oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
{
}
unsigned int parallel;
bool isInline;
unsigned int parallel;
//_CP_OPT(run_through) styleRunThrough ;
//_CP_OPT(run_through) styleRunThrough ;
_CP_OPT(odf_types::horizontal_rel) styleHorizontalRel;
_CP_OPT(odf_types::horizontal_pos) styleHorizontalPos;
_CP_OPT(odf_types::vertical_pos) styleVerticalPos;
_CP_OPT(odf_types::vertical_rel) styleVerticalRel;
_CP_OPT(odf_types::style_wrap) styleWrap;
_CP_OPT(odf_types::style_wrap) styleWrap;
bool isInline;
int number_wrapped_paragraphs;
std::wstring relativeHeight;
@ -67,16 +69,16 @@ struct _docx_drawing : _oox_drawing
int posOffsetV;
int posOffsetH;
_CP_OPT(int) pctWidth;
_CP_OPT(int) pctHeight;
int margin_rect[4];//0-left, 1 -top, 2- right, 3 - bottom
//std::wstring distB;
// std::wstring distT;
// std::wstring distL;
// std::wstring distR;
int margin_rect[4]; //0-left, 1 -top, 2- right, 3 - bottom
std::wstring content_group_;
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val, bool insideOtherDrawing);
void serialize_text (std::wostream & strm);
void serialize (std::wostream & strm/*, bool insideOtherDrawing*/);
};
}
}

View File

@ -96,8 +96,13 @@ void word_files::write(const std::wstring & RootPath)
{
media_->write( path );
}
if (embeddings_)
{
embeddings_->write( path );
}
if (headers_footers_)
if (headers_footers_)
{
headers_footers_->write( path );
}
@ -136,7 +141,15 @@ void word_files::update_rels(docx_conversion_context & Context)
void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
if (_Mediaitems.count_image > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
embeddings_->set_main_document( get_main_document() );
}
}
void word_files::set_styles(element_ptr Element)
@ -197,6 +210,7 @@ void docx_charts_files::add_chart(chart_content_ptr chart)
{
charts_.push_back(chart);
}
void docx_charts_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";

View File

@ -148,6 +148,7 @@ private:
element_ptr fontTable_;
element_ptr numbering_;
element_ptr media_;
element_ptr embeddings_;
element_ptr headers_footers_;
element_ptr notes_;
element_ptr settings_;

View File

@ -97,9 +97,12 @@ void headers_footers::dump_rels(rels & Rels) const//внешние релсы
}
}
bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const
bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_page/*not used*/, std::wostream & _Wostream)
{
if (!instances_.count(StyleName))return false;
if (!instances_.count(StyleName)) return false;
if (last_write_style_ == StyleName) return true;
last_write_style_ = StyleName;
bool first = false, left = false;
bool res = false;

View File

@ -49,7 +49,8 @@ namespace oox {
class headers_footers
{
public:
headers_footers() : size_(0),enable_write_(false){}
headers_footers() : size_(0) {}
enum Type { header, footer, headerLeft, footerLeft, headerFirst, footerFirst, none };
std::wstring add(const std::wstring & StyleName, const std::wstring & Content, Type type,rels &_rels);
@ -66,18 +67,17 @@ public:
};
void dump_rels(rels & Rels) const;
bool write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const;
bool write_sectPr(const std::wstring & StyleName, bool next_page, std::wostream & _Wostream);
typedef boost::shared_ptr<instance> instance_ptr;
typedef std::vector<instance_ptr> instances_array;
typedef boost::unordered_map<std::wstring, instances_array> instances_map;
const instances_map & instances() const { return instances_; }
bool get_enable_write(){return enable_write_;}
void set_enable_write(bool val){enable_write_ = val;}
const instances_map & instances() const { return instances_; }
private:
bool enable_write_;
std::wstring last_write_style_;
static std::wstring create_id(size_t i);
static std::wstring create_name(size_t i, Type _Type);
instances_map instances_;

View File

@ -82,6 +82,8 @@ std::wstring static get_default_file_name(RelsType type)
return L"chart";
case typeMedia:
return L"media";
case typeObject:
return L"oleObject";
default:
return L"";
}
@ -120,6 +122,9 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
sExt = uri.substr(n);
}
}
if (type == typeObject && sExt.empty())
sExt = L".bin";
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
}
@ -156,21 +161,26 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
sub_path = L"charts/";
}
if ( type == typeObject)
{
sub_path = L"embeddings/";
}
int number=0;
if ( type == typeChart) number = count_charts + 1;
else if ( type == typeImage) number = count_image + 1;
else if ( type == typeShape) number = count_shape + 1;
else if ( type == typeMedia) number = count_media + 1;
else if ( type == typeObject) number = count_object + 1;
else
number = items_.size()+1;
number = items_.size() + 1;
inputFileName = create_file_name(href, type, isMediaInternal, number);
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart) outputPath= outputPath + L".xml";
if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id;
for (int i = 0 ; i < items_.size(); i++)
@ -192,7 +202,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
if ( type == typeChart)
{
id = std::wstring(L"chId") + std::to_wstring(count_charts+1);
id = std::wstring(L"chId") + std::to_wstring(count_charts + 1);
count_charts++;
}
else if ( type == typeImage)
@ -205,12 +215,17 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
//------------------------------------------------
if (inputFileName.empty()) return L"";
id = std::wstring(L"picId") + std::to_wstring(count_image+1);
id = std::wstring(L"picId") + std::to_wstring(count_image + 1);
count_image++;
}
else if ( type == typeObject)
{
id = std::wstring(L"objId") + std::to_wstring(count_object + 1);
count_object++;
}
else
{
id = std::wstring(L"rId") + std::to_wstring(count_shape+1);
id = std::wstring(L"rId") + std::to_wstring(count_shape + 1);
count_shape++;
}

View File

@ -50,7 +50,7 @@ public:
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
}
struct item
@ -77,6 +77,7 @@ public:
size_t count_media;
size_t count_shape;
size_t count_tables;
size_t count_object;
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);

View File

@ -57,18 +57,26 @@ bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
return FileSystem::Directory::IsExist(resultPath);
return FileSystem::Directory::IsExist(resultPath) || FileSystem::Directory::IsExist(mediaPath);
}
std::wstring get_rel_type(RelsType type)
{
switch (type)
{
case typeImage:
case typeImage:
{
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case typeChart:
}
case typeChart:
{
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
default:
}
case typeObject:
{
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
}break;
default:
return L"";
}
}

View File

@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
}
namespace oox
{
math_context::math_context(bool graphic) : base_font_size_(12)
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) : base_font_size_(12), fonts_container_(fonts)
{
graphRPR_ = graphic;

View File

@ -44,6 +44,7 @@ namespace odf_reader
{
class style_instance;
class style_text_properties;
class fonts_container;
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
};
@ -90,7 +91,7 @@ namespace oox {
class math_context : boost::noncopyable
{
public:
math_context(bool graphic = false);
math_context(odf_reader::fonts_container & fonts, bool graphic = false);
void start();
std::wstring end();
@ -99,6 +100,7 @@ namespace oox {
std::wstringstream & math_style_stream() { return math_style_stream_; }
odf_reader::fonts_container & fonts_container_;
int base_font_size_;
odf_reader::style_text_properties_ptr text_properties_;

View File

@ -37,6 +37,19 @@
namespace cpdoccore {
static const std::wstring _ooxShapeType[]=
{
L"rect", //frame
L"rect", //text box
L"rect", //shape
L"ellipse",
L"ellipse",
L"line",
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
};
void svg_path::oox_serialize(std::wostream & strm, std::vector<svg_path::_polyline> & path)
{
CP_XML_WRITER(strm)
@ -55,7 +68,7 @@ void svg_path::oox_serialize(std::wostream & strm, svg_path::_polyline const & v
{
BOOST_FOREACH(svg_path::_point const & p, val.points)
{
oox_serialize(CP_XML_STREAM() ,p);
oox_serialize(CP_XML_STREAM(), p);
}
}
}
@ -235,9 +248,9 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
}
}
}
void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_)
void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & namespace_)
{
const std::vector<odf_reader::_property> & prop = val.additional;
const std::vector<odf_reader::_property> & prop = additional;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(prop,L"wordArt", bWordArt);
@ -257,11 +270,11 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop));
if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom));
if (val.inGroup == false)
if (inGroup == false)
{
_CP_OPT(int) iWrap;
odf_reader::GetProperty(prop,L"text-wrap" , iWrap);
if ((iWrap) && (*iWrap == 0))CP_XML_ATTR(L"wrap", L"none");
odf_reader::GetProperty(prop, L"text-wrap" , iWrap);
if ((iWrap) && (*iWrap == 0)) CP_XML_ATTR(L"wrap", L"none");
}
_CP_OPT(int) iAlign;
@ -319,7 +332,7 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
}
}
void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
void _oox_drawing::serialize_shape(std::wostream & strm)
{
_CP_OPT(std::wstring) strVal;
_CP_OPT(double) dVal;
@ -327,60 +340,61 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
std::wstring shapeType;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(val.additional,L"wordArt", bWordArt);
odf_reader::GetProperty(additional,L"wordArt", bWordArt);
if (val.sub_type == 7)//custom
if (sub_type == 7)//custom
{
_CP_OPT(int) iVal;
odf_reader::GetProperty(val.additional, L"odf-custom-draw-index",iVal);
odf_reader::GetProperty(additional, L"odf-custom-draw-index",iVal);
if (iVal)
shapeType = _OO_OOX_custom_shapes[*iVal].oox;
else
val.sub_type = 6; //path
sub_type = 6; //path
if (shapeType == L"textBox")
{
val.sub_type = 1;
sub_type = 1;
shapeType = L"rect";
}
}
else if (val.sub_type < 9 && val.sub_type >= 0)
else if (sub_type < 9 && sub_type >= 0)
{
shapeType = _ooxShapeType[val.sub_type];
shapeType = _ooxShapeType[sub_type];
}
if (bWordArt) val.sub_type = 1;
if (bWordArt) sub_type = 1;
CP_XML_WRITER(strm)
{
if (val.sub_type == 6 || val.sub_type == 8)
if (sub_type == 6 || sub_type == 8)
{
CP_XML_NODE(L"a:custGeom")
{
oox_serialize_aLst(CP_XML_STREAM(), val.additional);
oox_serialize_aLst(CP_XML_STREAM(), additional);
CP_XML_NODE(L"a:ahLst");
CP_XML_NODE(L"a:gdLst");
CP_XML_NODE(L"a:rect")
{
CP_XML_ATTR(L"b",L"b");
CP_XML_ATTR(L"l",0);
CP_XML_ATTR(L"r",L"r");
CP_XML_ATTR(L"t",0);
CP_XML_ATTR(L"b", L"b");
CP_XML_ATTR(L"l", 0);
CP_XML_ATTR(L"r", L"r");
CP_XML_ATTR(L"t", 0);
}
//<a:rect b="b" l="0" r="r" t="0"/>
if (odf_reader::GetProperty(val.additional, L"custom_path", strVal))
if (odf_reader::GetProperty(additional, L"custom_path", strVal))
{
_CP_OPT(int) w, h;
odf_reader::GetProperty(val.additional, L"custom_path_w", w);
odf_reader::GetProperty(val.additional, L"custom_path_h", h);
odf_reader::GetProperty(additional, L"custom_path_w", w);
odf_reader::GetProperty(additional, L"custom_path_h", h);
CP_XML_NODE(L"a:pathLst")
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : val.cx);
CP_XML_ATTR(L"h", h ? *h : val.cy);
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
CP_XML_STREAM() << strVal.get();
}
@ -393,12 +407,12 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
if (shapeType.length() < 1)
{
shapeType = L"rect";
val.sub_type = 2;
sub_type = 2;
}
CP_XML_NODE(L"a:prstGeom")//автофигура
{
CP_XML_ATTR(L"prst", shapeType);
if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), val.additional);
if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), additional);
}
}
if (bWordArt)
@ -407,25 +421,25 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
oox_serialize_fill(strm, no_fill);
}
else
oox_serialize_fill(strm, val.fill);
oox_serialize_fill(strm, fill);
}
}
void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wstring name_space)
void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & name_space)
{
CP_XML_WRITER(strm)
{
std::wstring xfrm = name_space + L":xfrm";
_CP_OPT(double) dRotate;
odf_reader::GetProperty(val.additional,L"svg:rotate",dRotate);
odf_reader::GetProperty(additional, L"svg:rotate", dRotate);
_CP_OPT(double) dSkewX;
odf_reader::GetProperty(val.additional,L"svg:skewX",dSkewX);
odf_reader::GetProperty(additional, L"svg:skewX", dSkewX);
_CP_OPT(double) dSkewY;
odf_reader::GetProperty(val.additional,L"svg:skewY",dSkewY);
odf_reader::GetProperty(additional, L"svg:skewY", dSkewY);
_CP_OPT(double) dRotateAngle;
@ -443,36 +457,44 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
{
if (dRotateAngle)
{
double d =360-dRotateAngle.get()*180./3.14159265358979323846;
double d =360 - dRotateAngle.get() * 180. / 3.14159265358979323846;
d *= 60000; //60 000 per 1 gr - 19.5.5 oox
CP_XML_ATTR(L"rot", (int)d);
}
_CP_OPT(bool)bVal;
if (odf_reader::GetProperty(val.additional,L"flipH",bVal))
if (odf_reader::GetProperty(additional,L"flipH", bVal))
CP_XML_ATTR(L"flipH", bVal.get());
if (odf_reader::GetProperty(val.additional,L"flipV",bVal))
if (odf_reader::GetProperty(additional,L"flipV", bVal))
CP_XML_ATTR(L"flipV", bVal.get());
CP_XML_NODE(L"a:off")
{
CP_XML_ATTR(L"x", val.x);
CP_XML_ATTR(L"y", val.y);
if (inGroup)
{
CP_XML_ATTR(L"x", x);
CP_XML_ATTR(L"y", y);
}
else
{
CP_XML_ATTR(L"x", 0);
CP_XML_ATTR(L"y", 0);
}
}
if (val.cx >0 || val.cy >0)
if (cx > 0 || cy > 0)
{
CP_XML_NODE(L"a:ext")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
}else
{
_CP_LOG << L"[error!!!] not set size object\n";
}
if (val.type == typeGroupShape)
if (type == typeGroupShape)
{
CP_XML_NODE(L"a:chOff")
{
@ -481,8 +503,8 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
}
CP_XML_NODE(L"a:chExt")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
}
}
@ -494,7 +516,7 @@ void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const &
{
BOOST_FOREACH(const _hlink_desc & h, val)
{
if (h.object == true)
if (h.in_object == true)
{
CP_XML_NODE(L"a:hlinkClick")
{

View File

@ -42,22 +42,6 @@
#include "../../../Common/DocxFormat/Source/Base/Types_32.h"
static const int _odf_to_oox_ShapeType[]=
{ 4,4,4,34,};
static const std::wstring _ooxShapeType[]=
{
L"rect", //frame
L"rect", //text box
L"rect", //shape
L"ellipse",
L"ellipse",
L"line",
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
};
namespace cpdoccore {
namespace oox {
@ -65,38 +49,47 @@ namespace oox {
{
std::wstring hId;
std::wstring hRef;
bool object;
bool in_object;
};
struct _oox_drawing
class _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object")
{
}
RelsType type;
RelsType type;
bool inGroup;
size_t id;
bool inGroup;
size_t id;
std::wstring name;
std::wstring name;
int sub_type; //odf
_INT32 x, y;
_INT32 cx, cy;
_INT32 x, y;
_INT32 cx, cy;
_oox_fill fill;
_oox_fill fill;
int sub_type; //odf
std::wstring chartId;
std::wstring objectId;
std::wstring objectProgId;
std::vector<_hlink_desc> hlinks;
std::vector<_hlink_desc> hlinks;
std::vector<odf_reader::_property> additional;
std::vector<odf_reader::_property> additional;
virtual void serialize (std::wostream & strm) = 0;
void serialize_shape (std::wostream & strm);
void serialize_xfrm (std::wostream & strm, const std::wstring & namespace_ = L"a");
void serialize_bodyPr (std::wostream & strm, const std::wstring & namespace_ = L"a");
};
void oox_serialize_xfrm (std::wostream & strm, _oox_drawing & val, const std::wstring namespace_ = L"a");
void oox_serialize_shape (std::wostream & strm, _oox_drawing & val);
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val);
void oox_serialize_bodyPr (std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_ = L"a");
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val);
}
}

View File

@ -61,18 +61,21 @@ static void ConvertSvmToImage(std::wstring &file_svm, std::wstring &file_png, CA
static std::wstring get_mime_type(const std::wstring & extension)
{
if (L"eps" == extension) return L"image/x-eps";
if (L"wmf" == extension) return L"image/x-wmf";
if (L"emf" == extension) return L"image/x-emf";
if (L"gif" == extension) return L"image/x-gif";
if (L"png" == extension) return L"image/x-png";
if (L"jpg" == extension) return L"image/x-jpeg";
if (L"jpeg" == extension) return L"image/x-jpeg";
if (L"tiff" == extension) return L"image/x-tiff";
if (L"pdf" == extension) return L"application/pdf";
if (L"wav" == extension) return L"audio/wav";
if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
if (L"eps" == extension) return L"image/x-eps";
else if (L"wmf" == extension) return L"image/x-wmf";
else if (L"emf" == extension) return L"image/x-emf";
else if (L"gif" == extension) return L"image/x-gif";
else if (L"png" == extension) return L"image/x-png";
else if (L"jpg" == extension) return L"image/x-jpeg";
else if (L"jpeg" == extension) return L"image/x-jpeg";
else if (L"tif" == extension) return L"image/x-tiff";
else if (L"tiff" == extension) return L"image/x-tiff";
else if (L"pdf" == extension) return L"application/pdf";
else if (L"wav" == extension) return L"audio/wav";
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
else if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
else return L"application/octet-stream";
return L"";
}
@ -109,14 +112,40 @@ content_type_content * content_types_file::content()
bool content_types_file::add_or_find_default(const std::wstring & extension)
{
for (int i = 0 ; i < content_type_content_.get_default().size(); i++)
std::vector<default_content_type> & defaults = content_type_content_.get_default();
for (int i = 0 ; i < defaults.size(); i++)
{
if (content_type_content_.get_default()[i].extension() == extension)
if (defaults[i].extension() == extension)
return true;
}
content_type_content_.add_default(extension, get_mime_type(extension));
return true;
}
bool content_types_file::add_or_find_override(const std::wstring & fileName)
{
std::vector<override_content_type> & override_ = content_type_content_.get_override();
for (int i = 0 ; i < override_.size(); i++)
{
if (override_[i].part_name() == fileName)
return true;
}
std::wstring content_type;
int pos = fileName.rfind(L".");
std::wstring extension = pos >= 0 ? fileName.substr(pos + 1) : L"";
if (extension == L"xlsx")
content_type = L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
content_type_content_.add_override(fileName, content_type);
//add_or_find_default(extension);
}
void content_types_file::set_media(mediaitems & _Mediaitems)
{
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() )
@ -282,7 +311,7 @@ void media::write(const std::wstring & RootPath)
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{
if (item.mediaInternal && item.valid && item.type == typeImage )
if (item.mediaInternal && item.valid && (item.type == typeImage || item.type == typeMedia))
{
std::wstring & file_name = item.href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
@ -298,9 +327,7 @@ void media::write(const std::wstring & RootPath)
}
}
///////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------------------------------------
charts::charts(mediaitems & _ChartsItems) : chartsitems_(_ChartsItems)
{
}
@ -309,6 +336,30 @@ void charts::write(const std::wstring & RootPath)
{
}
//--------------------------------------------------------------------------------------------------------------
embeddings::embeddings(mediaitems & _EmbeddingsItems) : embeddingsitems_(_EmbeddingsItems)
{
}
void embeddings::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"embeddings";
FileSystem::Directory::CreateDirectory(path.c_str());
content_types_file & content_types = get_main_document()->get_content_types_file();
BOOST_FOREACH( mediaitems::item & item, embeddingsitems_.items() )
{
if (item.mediaInternal && item.valid && item.type == typeObject )
{
content_types.add_or_find_override(std::wstring(L"/word/") + item.outputName);
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
NSFile::CFileBinary::Copy(item.href, file_name_out);
}
}
}
}
}
}

View File

@ -81,6 +81,7 @@ public:
content_types_file ();
void write (const std::wstring & RootPath);
bool add_or_find_default (const std::wstring & extension);
bool add_or_find_override(const std::wstring & fileName);
void set_media (mediaitems & _Mediaitems);
content_type_content * content ();
@ -224,7 +225,18 @@ private:
mediaitems & chartsitems_;
};
class embeddings : public element
{
public:
embeddings(mediaitems & _EmbeddingsItems);
public:
virtual void write(const std::wstring & RootPath);
private:
mediaitems & embeddingsitems_;
};
} // namespace package
} // namespace oox
} // namespace cpdoccore

View File

@ -40,7 +40,7 @@
namespace cpdoccore {
namespace oox {
enum RelsType { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroupShape};
enum RelsType { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroupShape, typeObject};
struct _rel
{

View File

@ -61,16 +61,16 @@ namespace package
class pptx_document;
}
pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument):
output_document_(NULL)
,odf_document_(odfDocument)
,pptx_text_context_(odf_document_->odf_context(),*this)
,pptx_table_context_(*this)
,pptx_comments_context_(comments_context_handle_)
,pptx_slide_context_(*this/*, pptx_text_context_*/)
,math_context_(true)
,last_idx_placeHolder(1)
,last_uniq_big_id(1)
pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument)
:output_document_ (NULL)
,odf_document_ (odfDocument)
,pptx_text_context_ (odf_document_->odf_context(), *this)
,pptx_table_context_ (*this)
,pptx_comments_context_ (comments_context_handle_)
,pptx_slide_context_ (*this/*, pptx_text_context_*/)
,math_context_ (odf_document_->odf_context().fontContainer(), true)
,last_idx_placeHolder (1)
,last_uniq_big_id (1)
{
applicationFonts_ = new CApplicationFonts();
}

View File

@ -61,7 +61,8 @@ void pptx_serialize_text(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_NODE(L"p:txBody")
{
oox_serialize_bodyPr(CP_XML_STREAM(), val);
val.serialize_bodyPr(CP_XML_STREAM());
if (strTextContent)
{
CP_XML_STREAM() << strTextContent.get();
@ -106,14 +107,14 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(),val.additional);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
//_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent);
@ -169,13 +170,13 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
if (!bNoRect)
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
val.serialize_shape(CP_XML_STREAM());
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
}
pptx_serialize_text(CP_XML_STREAM(), val);
pptx_serialize_text(CP_XML_STREAM(), val);
}
} // CP_XML_WRITER
}
@ -197,7 +198,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr");
}
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p");
val.serialize_xfrm(CP_XML_STREAM(), L"p");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
@ -210,7 +211,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
@ -235,7 +236,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr");
}
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p");
val.serialize_xfrm(CP_XML_STREAM(), L"p");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
@ -258,23 +259,24 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
} // CP_XML_WRITER
}
void pptx_serialize(std::wostream & strm, _pptx_drawing & val)
void _pptx_drawing::serialize(std::wostream & strm)
{
if (val.type == typeShape)
if (type == typeShape)
{
pptx_serialize_shape(strm,val);
serialize_shape(strm);
}
else if (val.type == typeImage)
else if (type == typeImage)
{
pptx_serialize_image(strm,val);
pptx_serialize_image(strm, *this);
}
else if (val.type == typeChart)
else if (type == typeChart)
{
pptx_serialize_chart(strm,val);
pptx_serialize_chart(strm, *this);
}
else if (val.type == typeTable)
else if (type == typeTable)
{
pptx_serialize_table(strm,val);
pptx_serialize_table(strm, *this);
}
}

View File

@ -43,13 +43,15 @@
namespace cpdoccore {
namespace oox {
struct _pptx_drawing : _oox_drawing
class _pptx_drawing : public _oox_drawing
{
_pptx_drawing(): place_holder_idx_(-1){}
std::wstring place_holder_type_;
int place_holder_idx_;
public:
_pptx_drawing(): _oox_drawing(), place_holder_idx_(-1) {}
std::wstring place_holder_type_;
int place_holder_idx_;
friend void pptx_serialize(std::wostream & _Wostream, _pptx_drawing & val);
void serialize (std::wostream & _Wostream);
};
}

View File

@ -92,9 +92,9 @@ public:
}
void serialize(std::wostream & strm)
{
BOOST_FOREACH(_pptx_drawing & d, pptx_drawings_)
for (int i = 0; i < pptx_drawings_.size(); i++)
{
pptx_serialize(strm,d);
pptx_drawings_[i].serialize(strm);
}
}

View File

@ -40,8 +40,7 @@
namespace cpdoccore {
namespace oox {
struct _pptx_drawing;
class _pptx_drawing;
class rels;
class pptx_drawings;

View File

@ -89,11 +89,14 @@ void pptx_xml_slide::write_to(std::wostream & strm)
{
CP_XML_NODE(L"p:sld")
{
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_NODE(L"p:cSld")
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"p:cSld")
{
CP_XML_ATTR(L"name", name());
@ -147,15 +150,19 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm)
{
CP_XML_NODE(L"p:sldLayout")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
//if (slideLayoutData_.str().length()<0)
// CP_XML_ATTR(L"type",L"cust");//---------------------------!!!!!!!!!!!!
//else
// CP_XML_ATTR(L"type",L"cust");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_NODE(L"p:cSld")
// CP_XML_ATTR(L"type",L"cust");
CP_XML_NODE(L"p:cSld")
{
CP_XML_NODE(L"p:spTree")
{
@ -239,9 +246,12 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
{
CP_XML_NODE(L"p:sldMaster")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"p:cSld")
{

View File

@ -477,8 +477,8 @@ void pptx_slide_context::process_charts()
////////////////////////////////////////////////////////////////
std::wstring ref;
bool isMediaInternal = true;
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, typeChart);
drawing.objectId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.objectId, ref, typeChart);
}
}
@ -707,10 +707,10 @@ void pptx_slide_context::serialize_objects(std::wostream & strm)
{
CP_XML_NODE(L"a:xfrm")
{
CP_XML_NODE(L"a:off") {CP_XML_ATTR(L"x",0); CP_XML_ATTR(L"y",0);}
CP_XML_NODE(L"a:ext") {CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0);}
CP_XML_NODE(L"a:chOff") {CP_XML_ATTR(L"x",0); CP_XML_ATTR(L"y",0);}
CP_XML_NODE(L"a:chExt") {CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0);}
CP_XML_NODE(L"a:off") { CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"y", 0); }
CP_XML_NODE(L"a:ext") { CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0); }
CP_XML_NODE(L"a:chOff") { CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"y", 0); }
CP_XML_NODE(L"a:chExt") { CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0); }
}
}
}

View File

@ -363,19 +363,20 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
odf_reader::paragraph_format_properties paragraph_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_,odf_types::style_family::Paragraph);
ApplyListProperties (paragraph_properties_,level);//выравнивания листа накатим на свойства параграфа
ApplyListProperties (paragraph_properties_, level);//выравнивания листа накатим на свойства параграфа
paragraph_properties_.pptx_convert(pptx_context_);
const std::wstring & paragraphAttr = get_styles_context().paragraph_attr().str();
const std::wstring & paragraphNodes = get_styles_context().paragraph_nodes().str();
if (level < 0 && paragraphAttr.length() <1 && paragraphNodes.length()<1) return;
if (level < 0 && paragraphAttr.length() < 1 && !paragraphNodes.empty()) return;
strm << L"<a:pPr ";
if (level>=0)
if (level >= 0)
{
if (level > 8) level = 0;
strm << L"lvl=\"" << level << L"\" ";
}
@ -384,7 +385,7 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
strm << ">";
strm << paragraphNodes;
if (level >=0 )
if (level >= 0 )
{

View File

@ -48,7 +48,7 @@ std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t
}
}
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
{
_CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent);
@ -60,7 +60,8 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
{
CP_XML_NODE(L"xdr:txBody")
{
oox_serialize_bodyPr(CP_XML_STREAM(), val);
val.serialize_bodyPr(CP_XML_STREAM());
CP_XML_NODE(L"a:lstStyle");
if (strTextContent)
{
@ -70,30 +71,30 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
}
}
void xlsx_serialize(std::wostream & strm, const xlsx_drawing_position & val)
void xlsx_drawing_position::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(std::wstring(L"xdr:") + (val.type == xlsx_drawing_position::from ? L"from" : L"to") )
CP_XML_NODE(std::wstring(L"xdr:") + (type == xlsx_drawing_position::from ? L"from" : L"to") )
{
CP_XML_NODE(L"xdr:col")
{
CP_XML_CONTENT(val.position.col);
CP_XML_CONTENT(position.col);
}
CP_XML_NODE(L"xdr:colOff")
{
CP_XML_CONTENT(static_cast<size_t>(val.position.colOff));
CP_XML_CONTENT(static_cast<size_t>(position.colOff));
}
CP_XML_NODE(L"xdr:row")
{
CP_XML_CONTENT(val.position.row);
CP_XML_CONTENT(position.row);
}
CP_XML_NODE(L"xdr:rowOff")
{
CP_XML_CONTENT(static_cast<size_t>(val.position.rowOff));
CP_XML_CONTENT(static_cast<size_t>(position.rowOff));
}
}
}
@ -129,7 +130,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom")
{
@ -166,9 +167,9 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
} // xdr:nv_Pr
CP_XML_NODE(L"xdr:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_shape(CP_XML_STREAM(),val);
val.serialize_shape(CP_XML_STREAM());
bool draw_always = false;
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
@ -198,7 +199,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
}
CP_XML_NODE(L"xdr:grpSpPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_xfrm(CP_XML_STREAM());
}
CP_XML_STREAM() << val.content_group_;
@ -222,7 +223,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:cNvGraphicFramePr");
}
oox_serialize_xfrm(CP_XML_STREAM(),val,L"xdr");
val.serialize_xfrm(CP_XML_STREAM(), L"xdr");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
@ -235,7 +236,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.chartId);
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
@ -261,22 +262,24 @@ void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
xlsx_serialize_group(strm, val);
}
}
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
void _xlsx_drawing::serialize(std::wostream & strm)
{
if (val.inGroup) return xlsx_serialize_object(strm, val);
if (inGroup)
return xlsx_serialize_object(strm, *this);
CP_XML_WRITER(strm)
{
if (val.type_anchor == 1)
if (type_anchor == 1)
{
CP_XML_NODE(L"xdr:twoCellAnchor")
{
CP_XML_ATTR(L"editAs", L"oneCell");//"absolute");oneCell
xlsx_serialize (CP_XML_STREAM(), val.from_);
xlsx_serialize (CP_XML_STREAM(), val.to_);
from_.serialize (CP_XML_STREAM());
to_.serialize (CP_XML_STREAM());
xlsx_serialize_object (CP_XML_STREAM(),val);
xlsx_serialize_object (CP_XML_STREAM(), *this);
CP_XML_NODE(L"xdr:clientData");
}
@ -287,17 +290,17 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_NODE(L"xdr:pos")
{
CP_XML_ATTR(L"x", val.x);
CP_XML_ATTR(L"y", val.y);
CP_XML_ATTR(L"x", x);
CP_XML_ATTR(L"y", y);
}
CP_XML_NODE(L"xdr:ext")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
xlsx_serialize_object (CP_XML_STREAM(),val);
xlsx_serialize_object (CP_XML_STREAM(), *this);
CP_XML_NODE(L"xdr:clientData");
}

View File

@ -46,16 +46,16 @@ namespace oox {
struct xlsx_drawing_position
{
enum type_t {from, to};
type_t type;
xlsx_table_position position;
enum type_t {from, to} type;
xlsx_table_position position;
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawing_position const & val);
void serialize(std::wostream & _Wostream);
};
struct _xlsx_drawing : _oox_drawing
class _xlsx_drawing : public _oox_drawing
{
public:
_xlsx_drawing() : _oox_drawing(), type_anchor(1) {}
int type_anchor;
@ -65,8 +65,7 @@ struct _xlsx_drawing : _oox_drawing
std::wstring content_group_;
friend void xlsx_serialize(std::wostream & _Wostream, _xlsx_drawing & val);
void serialize (std::wostream & _Wostream);
};
}
}

View File

@ -535,11 +535,11 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
std::wstring ref;
bool isMediaInternal = true;
drawing.chartId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, drawing.chartId, ref, obj.type_);
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.chartId, ref, obj.type_); // не объект
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
}
void xlsx_drawing_context::process_shape(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)

View File

@ -86,7 +86,7 @@ public:
{
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_serialize(strm, xlsx_drawings_[i]);
xlsx_drawings_[i].serialize(strm);
}
}
else
@ -101,7 +101,7 @@ public:
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_serialize(CP_XML_STREAM(), xlsx_drawings_[i]);
xlsx_drawings_[i].serialize(CP_XML_STREAM());
}
}
}

View File

@ -223,7 +223,7 @@ public:
const std::pair<int, double> c = cols_.search (x_pt);
const std::pair<int, double> r = rows_.search (y_pt);
xlsx_table_position res = {(size_t)c.first, c.second, (size_t)r.first, r.second};
xlsx_table_position res = {(size_t)c.first, c.second, (size_t)r.first, r.second};
return res;
}
@ -236,7 +236,7 @@ public:
r = rows_.search(offset_row, y_pt);
xlsx_table_position res = {(size_t)c.first, c.second, (size_t)r.first, r.second};
xlsx_table_position res = {(size_t)c.first, c.second, (size_t)r.first, r.second};
return res;
}
@ -246,7 +246,7 @@ public:
std::pair<int, double> r = rows_.search (last_row, 0);
xlsx_table_position res = {(size_t)c.first, c.second, (size_t)r.first, r.second};
xlsx_table_position res = {(size_t)c.first, c.second, (size_t)r.first, r.second};
return res;
}

View File

@ -66,7 +66,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
num_format_context_ (odf_document_->odf_context()),
xlsx_text_context_ (odf_document_->odf_context().styleContainer()),
xlsx_table_context_ (this, xlsx_text_context_),
math_context_ (true),
math_context_ (odf_document_->odf_context().fontContainer(), true),
xlsx_style_ (this),
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),

View File

@ -225,6 +225,10 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
}
else if(object_type_ == 4 && office_spreadsheet_)
{
//office_spreadsheet_
}
}
void object_odf_context::pptx_convert(oox::pptx_conversion_context & Context)
{
@ -544,7 +548,7 @@ bool process_build_object::visit_rows(unsigned int repeated)
//////////////////////////////////////////////////
void process_build_object::on_not_impl(std::string const & message)
{
_CP_LOG << L"[process_draw_chart visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl;
_CP_LOG << L"[process_object visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl;
}
//////////////////////////////////////////////////
@ -570,14 +574,18 @@ void process_build_object::visit(office_chart& val)
void process_build_object::visit(office_text& val)
{
object_odf_context_.object_type_ = 2;
object_odf_context_.office_text_ = &val;//конвертация будет уровнем выше
object_odf_context_.office_text_ = &val; //конвертация будет уровнем выше
}
void process_build_object::visit(office_math& val)
{
object_odf_context_.object_type_ = 3; //0;//временно замещающая картинка
object_odf_context_.office_math_ = &val;//конвертация будет уровнем выше
object_odf_context_.object_type_ = 3; //= 0 - временно замещающая картинка
object_odf_context_.office_math_ = &val; //конвертация будет уровнем выше
}
void process_build_object::visit(office_spreadsheet& val)
{
object_odf_context_.object_type_ = 4;
object_odf_context_.office_spreadsheet_ = &val; //конвертация будет уровнем выше
}
void process_build_object::visit(const chart_chart& val)
{
object_odf_context_.object_type_ = 1;

View File

@ -52,6 +52,7 @@
#include "office_body.h"
#include "office_chart.h"
#include "office_text.h"
#include "office_spreadsheet.h"
#include "math_elements.h"
#include "table.h"
#include "odfcontext.h"
@ -118,6 +119,7 @@ public:
object_type_ (0),
office_text_ (NULL),
office_math_ (NULL),
office_spreadsheet_ (NULL),
baseRef_ (ref),
baseFontHeight_ (12)
{
@ -159,6 +161,7 @@ public:
int object_type_;
office_text *office_text_;
office_math *office_math_;
office_spreadsheet *office_spreadsheet_;
int baseFontHeight_;
std::wstring baseRef_;
@ -211,7 +214,6 @@ public:
///////////////////////////////////////////
};
// Класс для обхода всех элеменов office:object для построения диаграммы
class process_build_object
: public base_visitor,
@ -222,7 +224,8 @@ class process_build_object
public visitor<office_chart>,
public visitor<office_text>,
public visitor<office_math>,
public visitor<office_spreadsheet>,
public const_visitor<chart_chart>,
public const_visitor<chart_title>,
@ -283,47 +286,48 @@ private:
public:
virtual void visit(const office_document_content& val);
virtual void visit(office_document_content& val);
virtual void visit(office_document_content & val);
virtual void visit(office_body & val);
virtual void visit(office_chart & val);
virtual void visit(office_text & val);
virtual void visit(office_math & val);
virtual void visit(office_body & val);
virtual void visit(office_chart & val);
virtual void visit(office_text & val);
virtual void visit(office_math & val);
virtual void visit(office_spreadsheet & val);
virtual void visit(const chart_chart& val);
virtual void visit(const chart_title& val);
virtual void visit(const chart_subtitle& val);
virtual void visit(const chart_footer& val);
virtual void visit(const chart_legend& val);
virtual void visit(const chart_chart & val);
virtual void visit(const chart_title & val);
virtual void visit(const chart_subtitle & val);
virtual void visit(const chart_footer & val);
virtual void visit(const chart_legend & val);
virtual void visit(const chart_plot_area& val);
virtual void visit(const chart_axis& val);
virtual void visit(const chart_series& val);
virtual void visit(const chart_domain& val);
virtual void visit(const chart_data_point & val);
virtual void visit(const chart_mean_value & val);
virtual void visit(const chart_error_indicator & val);
virtual void visit(const chart_axis & val);
virtual void visit(const chart_series & val);
virtual void visit(const chart_domain & val);
virtual void visit(const chart_data_point & val);
virtual void visit(const chart_mean_value & val);
virtual void visit(const chart_error_indicator & val);
virtual void visit(const chart_regression_curve & val);
virtual void visit(const chart_equation & val);
virtual void visit(const chart_categories& val);
virtual void visit(const chart_grid& val);
virtual void visit(const chart_wall& val);
virtual void visit(const chart_floor& val);
virtual void visit(const table_table& val);
virtual void visit(const chart_equation & val);
virtual void visit(const chart_categories & val);
virtual void visit(const chart_grid & val);
virtual void visit(const chart_wall & val);
virtual void visit(const chart_floor & val);
virtual void visit(const table_table & val);
virtual void visit(const table_table_rows& val);
virtual void visit(const table_rows_no_group& val);
virtual void visit(const table_table_row_group& val);
virtual void visit(const table_table_rows & val);
virtual void visit(const table_rows_no_group & val);
virtual void visit(const table_table_row_group & val);
virtual void visit(const table_table_header_rows& val);
virtual void visit(table_table_header_rows& val);
virtual void visit(table_table_header_rows & val);
virtual void visit(table_table_rows& val);
virtual void visit(const table_table_row& val);
virtual void visit(table_table_rows & val);
virtual void visit(const table_table_row & val);
virtual void visit(const table_columns_no_group& val);
virtual void visit(table_table_header_columns& val);
virtual void visit(table_table_columns& val);
virtual void visit(const table_columns_no_group & val);
virtual void visit(table_table_header_columns & val);
virtual void visit(table_table_columns & val);
virtual void visit(const table_table_column_group& val);
virtual void visit(const table_table_column& val);
virtual void visit(const table_table_column & val);
virtual void visit(const table_table_cell& val);

View File

@ -533,8 +533,9 @@ void common_draw_rel_size_attlist::apply_from(const common_draw_rel_size_attlist
void common_draw_rel_size_attlist::serialize(CP_ATTR_NODE)
{
common_draw_size_attlist_.serialize(CP_GET_XML_NODE());
CP_XML_ATTR_OPT(L"style:rel-width", style_rel_width_);
CP_XML_ATTR_OPT(L"style:rel-height", style_rel_height_);
CP_XML_ATTR_OPT(L"style:rel-width", style_rel_width_);
CP_XML_ATTR_OPT(L"style:rel-height", style_rel_height_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -443,10 +443,10 @@ public:
void apply_from(const common_draw_rel_size_attlist & Other);
void serialize(CP_ATTR_NODE);
public:
common_draw_size_attlist common_draw_size_attlist_;
_CP_OPT(percent_or_scale) style_rel_width_;
_CP_OPT(percent_or_scale) style_rel_height_;
common_draw_size_attlist common_draw_size_attlist_;
_CP_OPT(percent_or_scale) style_rel_width_;
_CP_OPT(percent_or_scale) style_rel_height_;
};
/// common-vertical-rel-attlist

View File

@ -52,10 +52,10 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"hexagon" ,L"hexagon" ,0 ,0 ,0 },
{L"octagon" ,L"octagon" ,0 ,0 ,0 },
{L"star4" ,L"star4" ,1 ,0 ,50000 },
{L"star5" ,L"star5" ,1 ,0 ,50000 },
{L"star5" ,L"star5" ,0 ,0 ,50000 },//??? 19098 неверно
{L"star8" ,L"star8" ,1 ,0 ,50000 },
{L"star24" ,L"star24" ,1 ,0 ,50000 },
{L"star6" ,L"star6" ,1 ,0 ,50000 },
{L"star6" ,L"star6" ,0 ,0 ,50000 },
{L"star12" ,L"star12" ,1 ,0 ,50000 },
{L"round-rectangle" ,L"roundRect" ,0 ,0 ,0 },
{L"ellipse" ,L"ellipse" ,0 ,0 ,0 },
@ -137,6 +137,7 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"mso-spt14" ,L"thickArrow" ,0 ,0 ,0 },
{L"mso-spt17" ,L"Balloon" ,0 ,0 ,0 },
{L"mso-spt18" ,L"irregularSeal1" ,0 ,0 ,0 },
{L"mso-spt19" ,L"rect" ,0 ,0 ,0 },
{L"mso-spt24" ,L"textBox" ,0 ,0 ,0 },
{L"mso-spt25" ,L"" ,0 ,0 ,0 },
{L"mso-spt26" ,L"" ,0 ,0 ,0 },
@ -185,6 +186,7 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"mso-spt179" ,L"" ,0 ,0 ,0 },
{L"mso-spt180" ,L"" ,0 ,0 ,0 },
{L"mso-spt182" ,L"leftRightUpArrow" ,0 ,0 ,0 },
{L"mso-spt188" ,L"flowChartPunchedTape",0 ,0 ,0 },
{L"mso-spt189" ,L"actionButtonBlank" ,0 ,0 ,0 },
{L"mso-spt190" ,L"actionButtonHome" ,0 ,0 ,0 },
{L"mso-spt191" ,L"actionButtonHelp" ,0 ,0 ,0 },
@ -284,7 +286,7 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"fontwork-triangle-up" ,L"textTriangle" ,0 ,0 ,0 },
{L"fontwork-triangle-down" ,L"textTriangleInverted" ,0 ,0 ,0 },
{L"fontwork-circle-pour" ,L"textCirclePour" ,0 ,0 ,0 },
{L"fontwork-circle-pour" ,L"textCirclePour" ,0 ,0 ,0 },
{L"fontwork-circle-curve" ,L"textCircle" ,0 ,0 ,0 },
{L"fontwork-open-circle-curve" ,L"textPlain" ,1 ,30000 , 70000 },
{L"fontwork-open-circle-pour" ,L"textPlain" ,1 ,30000 , 70000 },
@ -296,18 +298,18 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"mso-spt142" ,L"textRingInside" ,0 ,0 ,0 },
{L"mso-spt143" ,L"textRingOutside" ,0 ,0 ,0 },
{L"mso-spt157" ,L"textWave2" ,0 ,0 ,0 },
{L"mso-spt157" ,L"textWave2" ,0 ,0 ,0 },
{L"mso-spt158" ,L"textDoubleWave1" ,0 ,0 ,0 },
{L"mso-spt159" ,L"textWave4" ,0 ,0 ,0 },
{L"mso-spt160" ,L"textInflate" ,0 ,0 ,0 },//???
{L"mso-spt161" ,L"textDeflate" ,0 ,0 ,0 },
{L"mso-spt159" ,L"textWave4" ,0 ,0 ,0 },
{L"mso-spt160" ,L"textInflate" ,0 ,0 ,0 },//???
{L"mso-spt161" ,L"textDeflate" ,0 ,0 ,0 },
{L"mso-spt162" ,L"textInflateBottom" ,0 ,0 ,0 },
{L"mso-spt163" ,L"textDeflateBottom" ,0 ,0 ,0 },
{L"mso-spt164" ,L"textInflateTop" ,0 ,0 ,0 },
{L"mso-spt165" ,L"textDeflateTop" ,0 ,0 ,0 },
{L"mso-spt166" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
{L"mso-spt174" ,L"textCanUp" ,0 ,0 ,0 },
{L"mso-spt175" ,L"textCanDown" ,0 ,0 ,0 },
{L"mso-spt174" ,L"textCanUp" ,0 ,0 ,0 },
{L"mso-spt175" ,L"textCanDown" ,0 ,0 ,0 },
{L"mso-spt188" ,L"textDoubleWave1" ,0 ,0 ,0 },
};

View File

@ -31,12 +31,11 @@
*/
#include "length.h"
#include "../../../../Common/DocxFormat/Source/Base/Types_32.h"
#include <iostream>
#include <sstream>
#include <boost/lexical_cast.hpp>
namespace cpdoccore { namespace odf_types {
std::wostream & operator << (std::wostream & _Wostream, const length::unit _Unit)
@ -185,7 +184,7 @@ double inch_to_pt(double Val)
double emu_to_pt(double Val)
{
return Val * 72.0 / (360000.0 * 2.54);
return Val / 12700; // 1 / 12700 = 72.0 / (360000.0 * 2.54);
}
double px_to_pt(double Val)
{
@ -223,9 +222,9 @@ double to_pt(const length & Val)
return 0.0;
}
int pt_to_emu(double Val)
_INT64 pt_to_emu(double Val)
{
return static_cast<int>(Val * 360000 * 2.54) / 72;
return static_cast<_INT64>(Val * 360000 * 2.54) / 72;
}
}

View File

@ -35,12 +35,20 @@
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements.h"
#include "office_elements_create.h"
#include "datatypes/common_attlists.h"
#include "../docx/xlsxconversioncontext.h"
//#include "../docx/xlsxconversioncontext.h"
namespace cpdoccore {
namespace oox
{
class _oox_drawing;
}
typedef shared_ptr<oox::_oox_drawing>::Type oox_drawing_ptr;
namespace odf_reader {
/// draw-image-attlist
@ -54,7 +62,6 @@ public:
};
class draw_image : public office_element_impl<draw_image>
{
public:
@ -150,20 +157,17 @@ public:
static const ElementType type = typeDrawFrame;
CPDOCCORE_DEFINE_VISITABLE();
draw_frame() : oox_drawing_(NULL) {}
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
virtual void pptx_convert_placeHolder(oox::pptx_conversion_context & Context);
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
int idx_in_owner ;
odf_types::common_presentation_attlist common_presentation_attlist_;
odf_types::union_common_draw_attlists common_draw_attlists_;
@ -184,6 +188,13 @@ public:
friend class odf_document;
friend class draw_image;
friend class draw_chart;
oox_drawing_ptr oox_drawing_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_frame);
@ -324,7 +335,7 @@ private:
public:
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);

View File

@ -49,6 +49,7 @@
#include "draw_common.h"
#include "../docx/docx_drawing.h"
#include "../docx/xlsx_package.h"
#include "chart_build_oox.h"
#include "calcs_styles.h"
@ -56,6 +57,8 @@
#include "datatypes/length.h"
#include "datatypes/borderstyle.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
namespace cpdoccore {
using namespace odf_types;
@ -762,7 +765,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
}
void common_draw_docx_convert(oox::docx_conversion_context & Context, const union_common_draw_attlists & attlists_,oox::_docx_drawing &drawing)
void common_draw_docx_convert(oox::docx_conversion_context & Context, const union_common_draw_attlists & attlists_, oox::_docx_drawing *drawing)
{
const _CP_OPT(style_ref) & styleRef = attlists_.shape_with_text_and_styles_.
common_draw_shape_with_styles_attlist_.common_draw_style_name_attlist_.draw_style_name_;
@ -773,7 +776,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
odf_reader::style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,Context.process_headers_footers_);
if (styleInst)
{
if (drawing.sub_type > 1) //without text-box
if (drawing->sub_type > 1) //without text-box
{
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
if (defaultStyle)instances.push_back(defaultStyle);
@ -797,20 +800,20 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
/////////////////////////////////////////////////////////////////////////////////////////////
drawing.styleWrap = graphicProperties.style_wrap_;
drawing->styleWrap = graphicProperties.style_wrap_;
if (drawing.styleWrap && drawing.styleWrap->get_type() == style_wrap::Parallel)
if (drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::Parallel)
{
if (graphicProperties.style_number_wrapped_paragraphs_)
drawing.parallel = graphicProperties.style_number_wrapped_paragraphs_->get_value();
drawing->parallel = graphicProperties.style_number_wrapped_paragraphs_->get_value();
}
_CP_OPT(run_through) styleRunThrough = graphicProperties.style_run_through_;
drawing.styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
drawing.styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
drawing.styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
drawing.styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
drawing->styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
drawing->styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
drawing->styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
drawing->styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
_CP_OPT(anchor_type) anchor =
attlists_.shape_with_text_and_styles_.
@ -821,102 +824,116 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
int level_drawing = Context.get_drawing_context().get_current_level();
if (drawing.parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
if (drawing->parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
{
drawing.isInline = true;
drawing->isInline = true;
}
if (attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_)
{
std::wstring transformStr = attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_transform_attlist_.draw_transform_.get();
oox_convert_transforms(transformStr, drawing.additional);
oox_convert_transforms(transformStr, drawing->additional);
}
if (!drawing.isInline)
if (!drawing->isInline)
{
if (!drawing.styleWrap)
drawing.styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
if (!drawing->styleWrap)
drawing->styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
drawing.relativeHeight = L"2";
drawing.behindDoc = L"0";
drawing->relativeHeight = L"2";
drawing->behindDoc = L"0";
_CP_OPT(int) zIndex = attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_.common_draw_z_index_attlist_.draw_z_index_;
if (zIndex)//порядок отрисовки объектов
{
if (*zIndex < 0)
drawing.relativeHeight = L"0";
drawing->relativeHeight = L"0";
else
drawing.relativeHeight = boost::lexical_cast<std::wstring>( 2 + *zIndex );
drawing->relativeHeight = boost::lexical_cast<std::wstring>( 2 + *zIndex );
}
if (drawing.styleWrap && drawing.styleWrap->get_type() == style_wrap::RunThrough
if (drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::RunThrough
&& styleRunThrough && styleRunThrough->get_type() == run_through::Background
)
{
drawing. behindDoc = L"1";
drawing-> behindDoc = L"1";
}
drawing->margin_rect[0] = GetMargin(graphicProperties, sideLeft);
drawing->margin_rect[1] = GetMargin(graphicProperties, sideTop);
drawing->margin_rect[2] = GetMargin(graphicProperties, sideRight);
drawing->margin_rect[3] = GetMargin(graphicProperties, sideBottom);
drawing.margin_rect[0] = GetMargin(graphicProperties, sideLeft);
drawing.margin_rect[1] = GetMargin(graphicProperties, sideTop);
drawing.margin_rect[2] = GetMargin(graphicProperties, sideRight);
drawing.margin_rect[3] = GetMargin(graphicProperties, sideBottom);
drawing->posOffsetH = ComputeMarginX(pagePropertiesNode, pageProperties, attlists_, graphicProperties, drawing->additional);
drawing->posOffsetV = ComputeMarginY( pageProperties, attlists_, graphicProperties, drawing->additional);
drawing.posOffsetH = ComputeMarginX(pagePropertiesNode, pageProperties, attlists_, graphicProperties, drawing.additional);
drawing.posOffsetV = ComputeMarginY( pageProperties, attlists_, graphicProperties, drawing.additional);
if (attlists_.rel_size_.style_rel_width_)
{
int type = attlists_.rel_size_.style_rel_width_->get_type();
if (type == odf_types::percent_or_scale::Percent)
drawing->pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value();
}
if (attlists_.rel_size_.style_rel_height_ )
{
int type = attlists_.rel_size_.style_rel_height_->get_type();
if (type == odf_types::percent_or_scale::Percent)
drawing->pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
}
}
drawing.number_wrapped_paragraphs=graphicProperties.style_number_wrapped_paragraphs_.
drawing->number_wrapped_paragraphs=graphicProperties.style_number_wrapped_paragraphs_.
get_value_or( integer_or_nolimit( integer_or_nolimit::NoLimit) ).get_value();
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing.posOffsetV< 0)
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV< 0)
{
drawing.posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
drawing->posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
}
//////////////////////////////////////////////
graphicProperties.apply_to(drawing.additional);
graphicProperties.apply_to(drawing->additional);
//////////////////////////////////////////
bool bTxbx = (drawing.sub_type == 1);
bool bTxbx = (drawing->sub_type == 1);
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing.fill, bTxbx);
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing->fill, bTxbx);
if ((drawing.fill.bitmap) && (drawing.fill.bitmap->rId.length() < 1))
if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.length() < 1))
{
std::wstring href = drawing.fill.bitmap->xlink_href_;
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing.fill.bitmap->isInternal, href);
std::wstring href = drawing->fill.bitmap->xlink_href_;
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
}
////////////////////////////////////////////////////
drawing.additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft)));
drawing.additional.push_back(odf_reader::_property(L"border_width_top", Compute_BorderWidth(graphicProperties, sideTop)));
drawing.additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight)));
drawing.additional.push_back(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(graphicProperties, sideBottom)));
drawing->additional.push_back(odf_reader::_property(L"border_width_left", Compute_BorderWidth(graphicProperties, sideLeft)));
drawing->additional.push_back(odf_reader::_property(L"border_width_top", Compute_BorderWidth(graphicProperties, sideTop)));
drawing->additional.push_back(odf_reader::_property(L"border_width_right", Compute_BorderWidth(graphicProperties, sideRight)));
drawing->additional.push_back(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(graphicProperties, sideBottom)));
if (graphicProperties.common_border_attlist_.fo_border_)
{
if (graphicProperties.common_border_attlist_.fo_border_->is_none() == false)
{
drawing.additional.push_back(_property(L"stroke-color", graphicProperties.common_border_attlist_.fo_border_->get_color().get_hex_value() ));
drawing.additional.push_back(_property(L"stroke-width", graphicProperties.common_border_attlist_.fo_border_->get_length().get_value_unit(odf_types::length::pt) ));
drawing->additional.push_back(_property(L"stroke-color", graphicProperties.common_border_attlist_.fo_border_->get_color().get_hex_value() ));
drawing->additional.push_back(_property(L"stroke-width", graphicProperties.common_border_attlist_.fo_border_->get_length().get_value_unit(odf_types::length::pt) ));
}
}
///////////////////////////
drawing.x = get_value_emu(attlists_.position_.svg_x_);
drawing.y = get_value_emu(attlists_.position_.svg_y_);
drawing->x = get_value_emu(attlists_.position_.svg_x_);
drawing->y = get_value_emu(attlists_.position_.svg_y_);
drawing.cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
drawing.cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
drawing->cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
drawing->cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
if (drawing.cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
if (drawing->cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
{
drawing.cx = -drawing.cx;
drawing.additional.push_back(_property(L"fit-to-size", true));
drawing->cx = -drawing->cx;
drawing->additional.push_back(_property(L"fit-to-size", true));
}
if (drawing.cy < 0)
drawing.cy = 0;
if (drawing->cy < 0)
drawing->cy = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////
if ((drawing.styleWrap) && (drawing.styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
if ((drawing->styleWrap) && (drawing->styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
{
int max_width = get_value_emu(pageProperties.fo_page_width_);
int max_height = get_value_emu(pageProperties.fo_page_height_);
@ -949,57 +966,56 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
// }
//}
//if (drawing.cx<1 && max_width >0)
//if (drawing->cx<1 && max_width >0)
//{
// drawing.cx = std::min(762000,max_width);
// drawing->cx = std::min(762000,max_width);
//}
//if (drawing.cy <1 && max_height >0)
//if (drawing->cy <1 && max_height >0)
//{
// drawing.cy = std::min(142875,max_height);
// drawing->cy = std::min(142875,max_height);
//}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
_CP_OPT(double) dVal;
GetProperty(drawing.additional, L"svg:scale_x",dVal);
if (dVal)drawing.cx = (int)(0.5 + drawing.cx * dVal.get());
GetProperty(drawing->additional, L"svg:scale_x",dVal);
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
GetProperty(drawing.additional, L"svg:scale_y",dVal);
if (dVal)drawing.cy = (int)(0.5 + drawing.cy * dVal.get());
GetProperty(drawing->additional, L"svg:scale_y",dVal);
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
GetProperty(drawing.additional, L"svg:translate_x", dVal);
GetProperty(drawing->additional, L"svg:translate_x", dVal);
if (dVal)
{
int val = get_value_emu(dVal.get());
drawing.x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
drawing->x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
}
GetProperty(drawing.additional,L"svg:translate_y", dVal);
GetProperty(drawing->additional,L"svg:translate_y", dVal);
if (dVal)
{
int val = get_value_emu(dVal.get());
drawing.y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
drawing->y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
}
if (drawing.inGroup && drawing.type != oox::typeGroupShape)
if (drawing->inGroup && drawing->type != oox::typeGroupShape)
{
Context.get_drawing_context().set_position_child_group(drawing.x, drawing.y);
Context.get_drawing_context().set_size_child_group(drawing.cx + drawing.x, drawing.cy + drawing.y);
Context.get_drawing_context().set_position_child_group (drawing->x, drawing->y);
Context.get_drawing_context().set_size_child_group (drawing->cx + drawing->x, drawing->cy + drawing->y);
// ваще то тут "несовсем" всерно ... нужно сначала все стартовые позиции добавить ..
_INT32 x_group_offset, y_group_offset;
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
drawing.x -= x_group_offset;
drawing.y -= y_group_offset;
drawing->x -= x_group_offset;
drawing->y -= y_group_offset;
}
}
void draw_shape::docx_convert(oox::docx_conversion_context & Context)
{
/////...../////
//--------------------------------------------------------------------------------------------------
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::typeShape;
@ -1016,10 +1032,17 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
}
Context.get_drawing_context().clear_stream_shape();
/////////
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
common_draw_docx_convert(Context, common_draw_attlists_, &drawing);
/////////
if (bad_shape_ && drawing.fill.bitmap) // CV_Kucheruk_Maria(rus).odt - картинка по дебильному
{
drawing.sub_type = 1;
bad_shape_ = false;
}
if (drawing.fill.type < 1 && !IsExistProperty(drawing.additional,L"stroke"))//бывает что и не определено ничего
{
drawing.fill.solid = oox::oox_solid_fill::create();
@ -1027,6 +1050,12 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
drawing.fill.type = 1;
}
if (bad_shape_)
{
Context.get_drawing_context().stop_shape();
return;
}
std::wostream & strm = Context.output_stream();
bool pState = Context.get_paragraph_state();
@ -1041,7 +1070,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
else
Context.add_new_run(_T(""));
docx_serialize(strm, drawing, Context.get_drawing_state_content());
drawing.serialize(strm/*, Context.get_drawing_state_content()*/);
if (new_run) Context.finish_run();
@ -1062,11 +1091,18 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
if (!frame)
return;
if (pos_replaicement >=0 && !Context.get_drawing_context().get_use_image_replace())
return;//заменяемый объект
//--------------------------------------------------
//тут может быть не только текст , но и таблицы, другие объекты ...
oox::StreamsManPtr prev = Context.get_stream_man();
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
if (pos_replaicement >= 0 && !Context.get_drawing_context().get_use_image_replace())
{
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
}
if (drawing->type == oox::typeUnknown)
drawing->type = oox::typeImage;
oox::StreamsManPtr prev = Context.get_stream_man();
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_frame());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
@ -1087,14 +1123,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
Context.set_stream_man(prev);
//--------------------------------------------------
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::typeImage;
drawing.id = Context.get_drawing_context().get_current_frame_id ();
drawing.name = Context.get_drawing_context().get_current_object_name ();
drawing.inGroup = Context.get_drawing_context().in_group();
//--------------------------------------------------
oox::hyperlinks::_ref hyperlink = Context.last_hyperlink();
//нужно еще систему конроля - могут придте уже "использованные" линки с картинок - из колонтитулов (но на них уже использовали релсы)
@ -1102,20 +1131,14 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
if (hyperlink.drawing == true && hyperlink.used_rels == false)
{
oox::_hlink_desc desc = {hyperlink.id, hyperlink.href, true};
drawing.hlinks.push_back(desc);
drawing->hlinks.push_back(desc);
}
//if (Context.get_drawing_context().get_current_level() > 1)
// drawing.isInline = true;
/////////
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
/////////
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.fill.type = 2;
drawing.fill.bitmap->isInternal = false;
drawing.fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing.fill.bitmap->isInternal,href);
drawing.fill.bitmap->bStretch = true;
drawing->fill.bitmap = oox::oox_bitmap_fill::create();
drawing->fill.type = 2;
drawing->fill.bitmap->isInternal = false;
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal,href);
drawing->fill.bitmap->bStretch = true;
const _CP_OPT(style_ref) & styleRef = frame->common_draw_attlists_.shape_with_text_and_styles_.
common_draw_shape_with_styles_attlist_.
@ -1131,52 +1154,20 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
////////////////
if (properties)
{
if (properties->content().fo_clip_ && drawing.fill.bitmap)
if (properties->content().fo_clip_ && drawing->fill.bitmap)
{
std::wstring strRectClip = properties->content().fo_clip_.get();
strRectClip = strRectClip.substr(5,strRectClip.length()-6);
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR+ href;
drawing.fill.bitmap->bCrop = parse_clipping(strRectClip,fileName,drawing.fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::wostream & strm = Context.output_stream();
runState = Context.get_run_state();
pState = Context.get_paragraph_state();
if (!Context.get_drawing_context().in_group() && !pState)
{
Context.start_paragraph();
Context.set_paragraph_keep(true);
pState = Context.get_paragraph_state();
}
Context.set_paragraph_state(false);
if (!Context.get_drawing_context().in_group())//user_test-odt.odt
Context.add_new_run(_T(""));
docx_serialize(strm, drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_paragraph_state(pState);
}
void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
{
// if (Context.get_drawing_context().get_current_level() > 1 )
//{
// if(Context.delayed_converting_ == false)
// Context.add_delayed_element(Context.get_drawing_context().get_current_frame());
// return;
//}
//тут может быть не только текст , но и таблицы, другие объекты ...
oox::StreamsManPtr prev = Context.get_stream_man();
@ -1185,11 +1176,11 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
bool pState = Context.get_paragraph_state ();
bool runState = Context.get_run_state ();
bool keepState = Context.get_paragraph_keep ();
Context.set_run_state (false);
Context.set_paragraph_state (false);
bool drState = Context.get_drawing_state_content();
Context.set_drawing_state_content(true);
@ -1205,30 +1196,28 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_drawing_state_content (drState);
Context.set_paragraph_keep (keepState);
/////...../////
//---------------------------------------------------------------------------------------------------------
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
if (!frame)
return;
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
drawing.sub_type = 1; //textBox
drawing->type = oox::typeShape;
drawing->sub_type = 1; //textBox
const std::wstring & content = Context.get_drawing_context().get_text_stream_frame();
drawing.additional.push_back(_property(L"text-content",content));
drawing->additional.push_back(_property(L"text-content",content));
Context.get_drawing_context().clear_stream_frame();
/////////
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
//+ локальные
/////////
bool auto_fit_text = false;
bool auto_fit_shape = false;
if (!draw_text_box_attlist_.fo_min_height_) draw_text_box_attlist_.fo_min_height_ = frame->draw_frame_attlist_.fo_min_height_;
if (!draw_text_box_attlist_.fo_min_width_) draw_text_box_attlist_.fo_min_width_ = frame->draw_frame_attlist_.fo_min_width_;
@ -1236,59 +1225,44 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
if ((draw_text_box_attlist_.fo_min_height_) && (draw_text_box_attlist_.fo_min_height_->get_type()==length_or_percent::Length))
{
size_t min_y = get_value_emu(draw_text_box_attlist_.fo_min_height_->get_length());
if (drawing.cy < min_y)
if (drawing->cy < min_y)
{
drawing.cy = min_y;
auto_fit_text = true;
drawing->cy = min_y;
}
if (drawing->cy < 36000) auto_fit_shape = true;
}
if ((draw_text_box_attlist_.fo_min_width_) && (draw_text_box_attlist_.fo_min_width_->get_type()==length_or_percent::Length))
{
size_t min_x = get_value_emu(draw_text_box_attlist_.fo_min_width_->get_length());
if (drawing.cx < min_x)
if (drawing->cx < min_x)
{
drawing.cx = min_x;
auto_fit_text = true;
drawing->cx = min_x;
}
if (drawing->cx < 36000) auto_fit_shape = true;
}
if ((draw_text_box_attlist_.fo_max_height_) && (draw_text_box_attlist_.fo_max_height_->get_type()==length_or_percent::Length))
{
size_t max_y = get_value_emu(draw_text_box_attlist_.fo_max_height_->get_length());
if (drawing.cy > max_y) drawing.cy = max_y;
if (drawing->cy > max_y) drawing->cy = max_y;
}
if ((draw_text_box_attlist_.fo_max_width_) && (draw_text_box_attlist_.fo_max_width_->get_type()==length_or_percent::Length))
{
size_t max_x = get_value_emu(draw_text_box_attlist_.fo_max_width_->get_length());
if (drawing.cx > max_x) drawing.cy = max_x;
if (drawing->cx > max_x) drawing->cy = max_x;
}
if (auto_fit_text)
drawing.additional.push_back(_property(L"fit-to-size", auto_fit_text));
///////////////////////////////////////////////////////////////////
std::wostream & strm = Context.output_stream();
runState = Context.get_run_state();
pState = Context.get_paragraph_state();
if (!Context.get_drawing_context().in_group() && !pState)
if (auto_fit_shape)
{
Context.start_paragraph();
Context.set_paragraph_keep(true);
pState = Context.get_paragraph_state();
drawing->additional.push_back(_property(L"text-wrap" , 0));
drawing->additional.push_back(_property(L"auto-grow-height", auto_fit_shape));
}
Context.set_paragraph_state(false);
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm, drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_paragraph_state(pState);
else if (auto_fit_text)
drawing->additional.push_back(_property(L"fit-to-size", auto_fit_text));
}
void draw_g::docx_convert(oox::docx_conversion_context & Context)
{
@ -1297,16 +1271,6 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
Context.add_delayed_element(this);
return;
}
//if (Context.get_drawing_state_content())
//{
// BOOST_FOREACH(const office_element_ptr & elm, content_)
// {
// ElementType type = elm->get_type();
// elm->docx_convert(Context);
// }
// return;
//}
oox::_docx_drawing drawing = oox::_docx_drawing();
@ -1326,7 +1290,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
drawing.name = Context.get_drawing_context().get_current_object_name();
//--------------------------------------------------
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
common_draw_docx_convert(Context, common_draw_attlists_, &drawing);
//--------------------------------------------------
oox::StreamsManPtr prev = Context.get_stream_man();
@ -1396,7 +1360,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(strm, drawing, Context.get_drawing_state_content());
drawing.serialize(strm/*, Context.get_drawing_state_content()*/);
if (!Context.get_drawing_context().in_group())
Context.finish_run();
@ -1406,30 +1370,59 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
}
void draw_frame::docx_convert(oox::docx_conversion_context & Context)
{
//if ((!Context.get_paragraph_state() && !Context.get_drawing_context().in_group()) && !Context.delayed_converting_)
if (Context.get_drawing_context().get_current_level() > 0 && !Context.get_drawing_context().in_group() )
{
Context.add_delayed_element(this);
return;
}
oox_drawing_ = oox_drawing_ptr(new oox::_docx_drawing());
Context.get_drawing_context().start_frame(this);
const _CP_OPT(std::wstring) name =
common_draw_attlists_.shape_with_text_and_styles_.
common_draw_shape_with_styles_attlist_.
common_draw_name_attlist_.draw_name_;
BOOST_FOREACH(const office_element_ptr & elm, content_)
Context.get_drawing_context().add_name_object(name.get_value_or(L"Object"));
oox::_docx_drawing* drawing = dynamic_cast<oox::_docx_drawing *>(oox_drawing_.get());
drawing->id = Context.get_drawing_context().get_current_frame_id();
drawing->name = Context.get_drawing_context().get_current_object_name();
drawing->inGroup = Context.get_drawing_context().in_group();
common_draw_docx_convert(Context, common_draw_attlists_, drawing);
for (int i = 0 ; i < content_.size(); i++)
{
ElementType type = elm->get_type();
Context.get_drawing_context().add_name_object(name.get_value_or(L"Object"));
elm->docx_convert(Context);
content_[i]->docx_convert(Context);
}
//-----------------------------------------------------------------------------------------------------
bool runState = Context.get_run_state();
bool pState = Context.get_paragraph_state();
bool keepState = Context.get_paragraph_keep();
Context.set_run_state (false);
Context.set_paragraph_state (false);
if (!Context.get_drawing_context().in_group() && !runState)
Context.add_new_run(_T(""));
drawing->serialize(Context.output_stream()/*, Context.get_drawing_state_content()*/);
if (!Context.get_drawing_context().in_group() && !runState)
Context.finish_run();
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_paragraph_keep (keepState);
Context.get_drawing_context().stop_frame();
}
void draw_object::docx_convert(oox::docx_conversion_context & Context)
{
try
@ -1440,7 +1433,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
std::wstring folderPath = odf_reader->get_folder();
std::wstring objectPath = folderPath +FILE_SEPARATOR_STR + href;
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
//normalize path ??? todooo
boost::algorithm::replace_all(objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
@ -1448,13 +1441,14 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath ,NULL);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//функциональная часть
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
draw_frame *frame = NULL;
object_odf_context objectBuild(href);
office_element* contentSubDoc = objectSubDoc.get_impl()->get_content();
draw_frame* frame = NULL;
oox::_docx_drawing * drawing = NULL;
//if (!contentSubDoc)//Diagramma.odt - кривые ссылки на объекты
// return;
object_odf_context objectBuild (href);
if (contentSubDoc)
{
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
@ -1463,82 +1457,48 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
objectBuild.docx_convert(Context);
frame = Context.get_drawing_context().get_current_frame();//owner
drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
}
//------------------------------------------------------------------------------------------------------------
if (objectBuild.object_type_ == 1 && frame) //диаграмма
{
oox::_docx_drawing drawing = oox::_docx_drawing();
if (!frame || !drawing)
{
objectBuild.object_type_ = 0;
}
drawing.type = oox::typeChart;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
if (objectBuild.object_type_ == 1) //диаграмма
{
drawing->type = oox::typeChart;
bool isMediaInternal = true;
drawing.chartId = Context.add_mediaitem(href, drawing.type, isMediaInternal, href);
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
bool runState = Context.get_run_state();
bool pState = Context.get_paragraph_state();
Context.set_run_state(false);
Context.set_paragraph_state(false);
if (!Context.get_drawing_context().in_group() && !runState)
Context.add_new_run(_T(""));
docx_serialize(Context.output_stream(), drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group() && !runState)
Context.finish_run();
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
}
else if (objectBuild.object_type_ == 3 && frame) //мат формулы
{
oox::_docx_drawing drawing = oox::_docx_drawing();
else if (objectBuild.object_type_ == 3) //мат формулы
{
//skip replacement image !!!
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_frame_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
common_draw_docx_convert(Context, frame->common_draw_attlists_, drawing);
const std::wstring & content = Context.get_drawing_context().get_text_stream_frame();
bool in_frame = !drawing.isInline;
bool in_frame = !drawing->isInline;
bool runState = Context.get_run_state();
bool pState = Context.get_paragraph_state();
if (drawing.fill.type > 0)
if (drawing->fill.type > 0)
in_frame = true;
if (in_frame)
{
drawing.additional.push_back(_property(L"fit-to-size", true));
drawing.additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") +
drawing->type = oox::typeShape;
drawing->additional.push_back(_property(L"fit-to-size", true));
drawing->additional.push_back(_property(L"text-content", std::wstring(L"<w:p><m:oMathPara><m:oMathParaPr/>") +
content + std::wstring(L"</m:oMathPara></w:p>")));
Context.set_run_state(false);
Context.set_paragraph_state(false);
if (!Context.get_drawing_context().in_group())
Context.add_new_run(_T(""));
docx_serialize(Context.output_stream(), drawing, Context.get_drawing_state_content());
if (!Context.get_drawing_context().in_group())
Context.finish_run();
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
}
else
{//in text
drawing->type = oox::typeUnknown;
if (runState) Context.finish_run();
//if (pState == false)
{
@ -1555,7 +1515,44 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
}
Context.get_drawing_context().clear_stream_frame();
}
else if (objectBuild.object_type_ == 0)
if (objectBuild.object_type_ == 4) //embedded sheet
{
bool & use_image_replace = Context.get_drawing_context().get_use_image_replace();
use_image_replace = true;
oox::package::xlsx_document outputXlsx;
oox::xlsx_conversion_context conversionXlsxContext ( &objectSubDoc);
conversionXlsxContext.set_output_document (&outputXlsx);
//conversionContext.set_font_directory (fontsPath);
if (objectSubDoc.xlsx_convert(conversionXlsxContext))
{
drawing->type = oox::typeObject;
std::wstring objectXlsxPath = FileSystem::Directory::CreateDirectoryWithUniqueName(folderPath);
outputXlsx.write(objectXlsxPath);
href = Context.get_drawing_context().get_current_object_name() + L".xlsx";
std::wstring temp_file = folderPath + FILE_SEPARATOR_STR + href;
COfficeUtils oCOfficeUtils(NULL);
oCOfficeUtils.CompressFileOrDirectory(objectXlsxPath.c_str(), temp_file.c_str(), -1);
FileSystem::Directory::DeleteDirectory(objectXlsxPath);
bool isMediaInternal = true;
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, temp_file);
drawing->objectProgId = L"Excel.Sheet.12";
}
else
{
objectBuild.object_type_ = 0;
}
}
if (objectBuild.object_type_ == 0)
{
//замещающая картинка(если она конечно присутствует)
@ -1576,6 +1573,20 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
bool & use_image_replace = Context.get_drawing_context().get_use_image_replace();
use_image_replace = true;
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
if (href.empty()) return;
draw_frame* frame = Context.get_drawing_context().get_current_frame(); //owner
if (!frame) return;
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
drawing->type = oox::typeObject;
bool isMediaInternal = true;
drawing->objectId = Context.add_mediaitem(href, drawing->type, isMediaInternal, href);
drawing->objectProgId = L""; //detect ???
}
}

View File

@ -55,7 +55,7 @@
#include "odf_document_impl.h"
#include "calcs_styles.h"
#include "../docx/oox_drawing.h"
#include "../docx/pptx_drawing.h"
#include "chart_build_oox.h"
#include "datatypes/length.h"
@ -109,8 +109,8 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
double x_pt = common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
double y_pt = common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
if (x_pt <0) x_pt =0;
if (y_pt <0) y_pt =0;
if (x_pt < 0) x_pt =0;
if (y_pt < 0) y_pt =0;
Context.get_slide_context().set_rect(width_pt, height_pt, x_pt, y_pt);
}
@ -198,14 +198,11 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_text_context().start_base_style(baseStyleName ,odf_types::style_family::Presentation);
////////////////////////////////////////////////
int i=0;
int size = content_.size();
while(true)
oox_drawing_ = oox_drawing_ptr(new oox::_pptx_drawing());
for (int i = 0; i < content_.size(); i++)
{
if (i>=size)break;
office_element_ptr const & elm = content_[i];
elm->pptx_convert(Context);
i++;
content_[i]->pptx_convert(Context);
}
Context.get_text_context().end_base_style();
@ -219,13 +216,9 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
////////////////////////////////////в принципе достаточно общая часть ...
Context.get_text_context().start_object();
int i=0;
int size = content_.size();
while(true)
for (int i = 0; i < content_.size(); i++)
{
if (i>=size)break;
content_[i]->pptx_convert(Context);
i++;
content_[i]->pptx_convert(Context);
}
std::wstring text_content_ = Context.get_text_context().end_object();
@ -241,13 +234,9 @@ void draw_chart::pptx_convert(oox::pptx_conversion_context & Context)
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
Context.get_slide_context().start_chart(href);
int i=0;
int size = content_.size();
while(true)
for (int i = 0; i < content_.size(); i++)
{
if (i>=size)break;
content_[i]->pptx_convert(Context);
i++;
content_[i]->pptx_convert(Context);
}
Context.get_slide_context().end_chart();
}
@ -256,14 +245,11 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_shape(2);//rect с наваротами
Context.get_text_context().start_object();
int i=0;
int size = content_.size();
while(true)
for (int i = 0; i < content_.size(); i++)
{
if (i>=size)break;
content_[i]->pptx_convert(Context);
i++;
content_[i]->pptx_convert(Context);
}
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
@ -330,7 +316,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
std::wstring text_content_ = Context.get_text_context().end_object();
Context.get_text_context().set_local_styles_container(NULL);//вытираем вручную ...
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
}

View File

@ -53,7 +53,7 @@
#include "odf_document_impl.h"
#include "calcs_styles.h"
#include "../docx/oox_drawing.h"
#include "../docx/xlsx_drawing.h"
#include "chart_build_oox.h"
#include "datatypes/length.h"
@ -190,6 +190,9 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill);
oox_drawing_ = oox_drawing_ptr(new oox::_xlsx_drawing());
////////////////////////////////////////////////
for (int i = 0 ; i < content_.size(); i++)
{

View File

@ -230,7 +230,11 @@ void draw_path::add_attributes( const xml::attributes_wc_ptr & Attributes )
}
void draw_path::reset_svg_path()
{
if (draw_path_attlist_.svg_d_)
if (!draw_path_attlist_.svg_d_)
{
bad_shape_ = true;
}
else
{
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;
@ -286,7 +290,11 @@ void draw_polygon::add_attributes( const xml::attributes_wc_ptr & Attributes )
}
void draw_polygon::reset_polygon_path()
{
if (draw_polygon_attlist_.draw_points_)
if (!draw_polygon_attlist_.draw_points_)
{
bad_shape_ = true;
}
else
{
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;
@ -338,7 +346,11 @@ void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
}
void draw_polyline::reset_polyline_path()
{
if (draw_polyline_attlist_.draw_points_)
if (!draw_polyline_attlist_.draw_points_)
{
bad_shape_ = true;
}
else
{
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;
@ -467,8 +479,6 @@ void draw_enhanced_geometry::add_child_element( xml::sax * Reader, const std::ws
}
void draw_enhanced_geometry::find_draw_type_oox()
{
word_art_ = false;
if (draw_enhanced_geometry_attlist_.draw_text_path_ &&
*draw_enhanced_geometry_attlist_.draw_text_path_ == true)
{
@ -489,12 +499,13 @@ void draw_enhanced_geometry::find_draw_type_oox()
{
if (_OO_OOX_wordart[i].odf_reader == odf_type)
{
word_art_ = true;
draw_type_oox_index_ = i;
break;
}
}
}
else
if (!draw_type_oox_index_)
{
int count = sizeof(_OO_OOX_custom_shapes) / sizeof(_shape_converter);
int pos = odf_type.find(L"ooxml-");
@ -546,7 +557,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
catch(...)
{
}
if (min <0 ) min=0;
if (min < 0 ) min=0;
try
{
@ -602,7 +613,11 @@ void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
}
void draw_connector::reset_svg_path()
{
if (draw_connector_attlist_.svg_d_)
if (!draw_connector_attlist_.svg_d_)
{
bad_shape_ = true;
}
else
{
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;

View File

@ -65,6 +65,8 @@ public:
static const ElementType type = typeDrawShape;
static const xml::NodeType xml_type = xml::typeElement;
draw_shape() : bad_shape_(false), word_art_(false) {}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
@ -87,6 +89,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
friend class odf_document;
//----------------------------------------------------------------------------------------------
bool bad_shape_;
bool word_art_;
int sub_type_;
std::vector<odf_reader::_property> additional_;

View File

@ -60,8 +60,6 @@ namespace cpdoccore {
namespace odf_reader {
void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
{
Context.get_drawing_context().start_shape(this);
@ -115,7 +113,6 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
}
void draw_rect::docx_convert(oox::docx_conversion_context & Context)
{
//if (Context.get_drawing_context().get_current_level() >0 )return;
if (Context.get_drawing_context().get_current_level() > 0 && !Context.get_drawing_context().in_group() )
{
if(Context.delayed_converting_ == false)
@ -245,17 +242,21 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape->word_art_ = word_art_;
bool set_shape = false;
if (draw_type_oox_index_)
{
shape->additional_.push_back(_property(L"odf-custom-draw-index", draw_type_oox_index_.get()));
if (shape->word_art_ == true)
shape->additional_.push_back(_property(L"wordArt", true));
shape->additional_.push_back(_property(L"wordArt", true));
set_shape = true;
}
if (sub_type_)
{
shape->sub_type_ = sub_type_.get();
set_shape = true;
}
if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
@ -279,6 +280,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
std::wstringstream output_;
svg_path::oox_serialize(output_, o_Polyline);
shape->additional_.push_back(odf_reader::_property(L"custom_path", output_.str()));
set_shape = true;
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
@ -303,12 +306,9 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
}
}
}
else if (!draw_type_oox_index_)
{
draw_type_oox_index_ = 0;
}
}
else if (draw_enhanced_geometry_attlist_.draw_modifiers_)
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
{
shape->additional_.push_back(_property(L"draw-modifiers",draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
if (draw_handle_geometry_.size()>0)
@ -320,6 +320,12 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
}
}
}
if (!set_shape)
{
shape->bad_shape_ = true;
}
}
}
}

View File

@ -166,8 +166,6 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
}
//Context.get_slide_context().end_drawing();
}
void draw_rect::pptx_convert(oox::pptx_conversion_context & Context)
{
@ -304,6 +302,8 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
{
find_draw_type_oox();
bool set_shape = false;
if (draw_type_oox_index_)
{
Context.get_slide_context().set_property(_property(L"odf-custom-draw-index", draw_type_oox_index_.get()));
@ -311,10 +311,12 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
if (word_art_ == true)
Context.get_slide_context().set_property(_property(L"wordArt", true));
set_shape = true;
}
if (sub_type_)
{
Context.get_slide_context().start_shape(sub_type_.get());
set_shape = true;
}
if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
@ -339,6 +341,8 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
svg_path::oox_serialize(output_, o_Polyline);
Context.get_slide_context().set_property(odf_reader::_property(L"custom_path", output_.str()));
set_shape = true;
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
@ -362,10 +366,6 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
}
}
}
else if (!draw_type_oox_index_)
{
draw_type_oox_index_ = 0;
}
}
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
{
@ -380,6 +380,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
}
}
}
if (!set_shape)
{
Context.get_slide_context().start_shape(1); //restart type shape
}
}
}
}

View File

@ -292,7 +292,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
{
CP_XML_NODE(L"m:ctrlPr")
{
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
}
}
}
@ -317,7 +317,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
{
CP_XML_NODE(L"m:ctrlPr")
{
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
}
}
}

View File

@ -94,8 +94,10 @@ void math_mtr::oox_convert(oox::math_context & Context)
strm << L"<m:mr>";
for (int i = 0; i < content_.size(); i++)
{
strm << L"<m:e>";
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
}
strm << L"</m:mr>";
}

View File

@ -114,7 +114,7 @@ void math_mi::oox_convert(oox::math_context & Context)
}
}
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
CP_XML_NODE(L"m:t")
{
@ -162,7 +162,7 @@ void math_mo::oox_convert(oox::math_context & Context)
{
// + доп стили текста ... todoooo
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
CP_XML_NODE(L"m:t")
{
@ -203,7 +203,7 @@ void math_mn::oox_convert(oox::math_context & Context)
{
// + доп стили текста ... todoooo
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
CP_XML_NODE(L"m:t")
{

View File

@ -128,8 +128,6 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
if (content_)
content_->docx_convert(Context);
Context.get_headers_footers().set_enable_write(true);
if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
{
Context.output_stream() << Context.get_section_context().dump_;

View File

@ -147,6 +147,14 @@ void office_text::pptx_convert(oox::pptx_conversion_context & Context)
const wchar_t * office_change_info::ns = L"office";
const wchar_t * office_change_info::name = L"change-info";
void office_change_info::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
int count = Attributes->size();
CP_APPLY_ATTR(L"office:chg-author", office_chg_author_);
CP_APPLY_ATTR(L"office:chg-date-time", office_chg_date_time_);
}
void office_change_info::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"dc", L"date")
@ -165,14 +173,23 @@ void office_change_info::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring date;
std::wstring author;
if (dc_date_)
{
date = xml::utils::replace_text_to_xml(dynamic_cast<dc_date * >(dc_date_.get())->content_);
}
else if (office_chg_date_time_)
{
date = *office_chg_date_time_;
}
if (dc_creator_)
{
author = xml::utils::replace_text_to_xml(dynamic_cast<dc_creator * >(dc_creator_.get())->content_);
}
else if (office_chg_author_)
{
author = *office_chg_author_;
}
Context.get_text_tracked_context().set_user_info(author, date);
}

View File

@ -88,11 +88,14 @@ public:
virtual void docx_convert(oox::docx_conversion_context & Context) ;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr dc_date_;
office_element_ptr dc_creator_;
_CP_OPT(std::wstring) office_chg_author_;
_CP_OPT(std::wstring) office_chg_date_time_;
};
CP_REGISTER_OFFICE_ELEMENT2(office_change_info)

View File

@ -332,7 +332,7 @@ const wchar_t * span::name = L"span";
std::wostream & span::text_to_stream(std::wostream & _Wostream) const
{
BOOST_FOREACH(const office_element_ptr & parElement, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & parElement, content_)
{
parElement->text_to_stream(_Wostream);
}
@ -359,13 +359,13 @@ void span::add_attributes( const xml::attributes_wc_ptr & Attributes )
void span::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(paragraph_content_);
CP_CREATE_ELEMENT(content_);
}
void span::add_text(const std::wstring & Text)
{
office_element_ptr elm = text::create(Text);
paragraph_content_.push_back( elm );
content_.push_back( elm );
}
void span::docx_convert(oox::docx_conversion_context & Context)
@ -406,7 +406,7 @@ void span::docx_convert(oox::docx_conversion_context & Context)
if (!addNewRun)Context.add_new_run();
BOOST_FOREACH(const office_element_ptr & parElement, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & parElement, content_)
{
parElement->docx_convert(Context);
}
@ -420,7 +420,7 @@ void span::docx_convert(oox::docx_conversion_context & Context)
void span::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.start_span(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->xlsx_convert(Context);
}
@ -432,7 +432,7 @@ void span::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_text_context().get_styles_context().start_process_style(styleInst);
Context.get_text_context().start_span(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->pptx_convert(Context);
}
@ -446,7 +446,7 @@ const wchar_t * a::name = L"a";
std::wostream & a::text_to_stream(std::wostream & _Wostream) const
{
BOOST_FOREACH(const office_element_ptr & element, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & element, content_)
{
element->text_to_stream(_Wostream);
}
@ -465,13 +465,13 @@ void a::add_attributes( const xml::attributes_wc_ptr & Attributes )
void a::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(paragraph_content_);
CP_CREATE_ELEMENT(content_);
}
void a::add_text(const std::wstring & Text)
{
office_element_ptr elm = text::create(Text) ;
paragraph_content_.push_back( elm );
content_.push_back( elm );
}
void a::docx_convert(oox::docx_conversion_context & Context)
@ -527,7 +527,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
if (!addNewRun)
Context.add_new_run();
BOOST_FOREACH(const office_element_ptr & parElement, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & parElement, content_)
{
parElement->docx_convert(Context);
}
@ -542,7 +542,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
void a::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.start_hyperlink(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->xlsx_convert(Context);
}
@ -551,7 +551,7 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context)
void a::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_hyperlink();
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->pptx_convert(Context);
}

View File

@ -378,7 +378,7 @@ public:
span() {}
office_element_ptr_array paragraph_content_;
office_element_ptr_array content_;
odf_types::style_ref text_style_name_;
odf_types::style_ref_array text_class_names_;
@ -424,7 +424,7 @@ private:
odf_types::style_ref text_style_name_;
odf_types::style_ref text_visited_style_name_;
office_element_ptr_array paragraph_content_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(a);

View File

@ -55,7 +55,7 @@ const wchar_t * ruby_base::name = L"ruby-base";
std::wostream & ruby_base::text_to_stream(std::wostream & _Wostream) const
{
serialize_elements_text(_Wostream, paragraph_content_);
serialize_elements_text(_Wostream, content_);
return _Wostream;
}
@ -65,13 +65,13 @@ void ruby_base::add_attributes( const xml::attributes_wc_ptr & Attributes )
void ruby_base::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(paragraph_content_);
CP_CREATE_ELEMENT(content_);
}
void ruby_base::add_text(const std::wstring & Text)
{
office_element_ptr elm = text::create(Text) ;
paragraph_content_.push_back( elm );
content_.push_back( elm );
}
// text:ruby-text

View File

@ -64,7 +64,7 @@ private:
virtual void add_text(const std::wstring & Text);
private:
office_element_ptr_array paragraph_content_;
office_element_ptr_array content_;
};
@ -94,8 +94,8 @@ private:
virtual void add_text(const std::wstring & Text);
private:
odf_types::style_ref text_style_name_;
office_element_ptr_array content_;
odf_types::style_ref text_style_name_;
office_element_ptr_array content_;
};

View File

@ -276,25 +276,6 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
{
std::wstringstream & _pPr = Context.get_text_context().get_styles_context().paragraph_attr();
//сначала аттрибуты к самому pPr или defPPr
if (fo_text_align_)
{
std::wstring jc;
switch(fo_text_align_->get_type())
{
case text_align::Start:
case text_align::Left:
jc = L"l"; break;
case text_align::End:
case text_align::Right:
jc = L"r"; break;
case text_align::Center:
jc = L"ctr"; break;
case text_align::Justify:
jc = L"just"; break;
}
if (jc.length()>0) _pPr << L"algn=\"" << jc << "\" ";
}
if (fo_margin_left_ || fo_margin_right_ || fo_text_indent_ )
{
// TODO auto indent
@ -315,6 +296,26 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
if (!w_firstLine.empty())
_pPr << L"indent=\"" << w_firstLine << "\" ";
}
if (fo_text_align_)
{
std::wstring jc;
switch(fo_text_align_->get_type())
{
case text_align::Start:
case text_align::Left:
jc = L"l"; break;
case text_align::End:
case text_align::Right:
jc = L"r"; break;
case text_align::Center:
jc = L"ctr"; break;
case text_align::Justify:
jc = L"just"; break;
}
if (jc.length()>0) _pPr << L"algn=\"" << jc << "\" ";
}
if (style_vertical_align_)
{
std::wstring w_val;
@ -329,7 +330,6 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
if (!w_val.empty())
_pPr << L"fontAlgn=\"" << w_val << "\" ";
}
//if (style_writing_mode_)
//{

View File

@ -87,27 +87,6 @@ bool table_format_properties::add_child_element( xml::sax * Reader, const std::w
}
}
/*
[ ] w:tblStyle Referenced Table Style
[ ] w:tblpPr Floating Table Positioning
[ ] w:tblOverlap Floating Table Allows Other Tables to Overlap
[ ] w:bidiVisual Visually Right to Left Table
[ ] w:tblStyleRowBandSize Number of Rows in Row Band
[ ] w:tblStyleColBandSize Number of Columns in Column Band
[x] w:tblW Preferred Table Width
[x] w:jc Table Alignment
[ ] w:tblCellSpacing Table Cell Spacing Default
[ ] w:tblInd Table Indent from Leading Margin
[ ] w:tblBorders Table Borders
[ ] w:shd Table Shading
[ ] w:tblLayout Table Layout
[ ] w:tblCellMar Table Cell Margin Defaults
[ ] w:tblLook Table Style Conditional Formatting Settings
[ ] w:tblPrChange Revision Information for Table Properties
*/
void table_format_properties::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & _tblPr = Context.get_styles_context().table_style();
@ -137,7 +116,7 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (table_align_)
{
std::wstring w_val = L"left";
if (table_align_->get_type() == table_align::Margins)
if (table_align_->get_type() == table_align::Margins || table_align_->get_type() == table_align::Left)
{
if (common_horizontal_margin_attlist_.fo_margin_left_ && common_horizontal_margin_attlist_.fo_margin_right_)
{
@ -147,19 +126,16 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (w_val != L"center" && common_horizontal_margin_attlist_.fo_margin_left_ )
{
odf_types::length indent = common_horizontal_margin_attlist_.fo_margin_left_->get_length();
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20<< "\" w:type=\"dxa\" />";
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\" />";
}
}
else
else //if (table_align_->get_type() == table_align::Center)
w_val = boost::lexical_cast<std::wstring>(*table_align_);
_tblPr << L"<w:jc w:val=\"" << w_val << "\" />";
}
if (table_align_ && table_align_->get_type() == table_align::Center)
{
// TODO ()
}
_tblPr << "<w:tblLayout w:type=\"fixed\" />";
if (common_background_color_attlist_.fo_background_color_)

View File

@ -276,18 +276,20 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
{
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
if (w_font.length() < 1)
if (w_font.empty())
{
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: L"");
std::wstring w_eastAsia = (style_font_name_asian_ ? *style_font_name_asian_: L"");
std::wstring w_cs = (style_font_name_complex_ ? *style_font_name_complex_: L"");
std::wstring w_ascii = (style_font_name_ ? *style_font_name_ : L"");
std::wstring w_eastAsia = (style_font_name_asian_ ? *style_font_name_asian_ : L"");
std::wstring w_cs = (style_font_name_complex_ ? *style_font_name_complex_ : L"");
fonts_container & fonts = Context.root()->odf_context().fontContainer();
font_instance * font = fonts.font_by_style_name(w_ascii);
if (font == NULL)font = fonts.font_by_style_name(w_eastAsia);
if (font == NULL)font = fonts.font_by_style_name(w_cs);
if (font)w_font = font->name();
font_instance * font = fonts.font_by_style_name(w_ascii);
if (font == NULL) font = fonts.font_by_style_name(w_eastAsia);
if (font == NULL) font = fonts.font_by_style_name(w_cs);
if (font)
w_font = font->name();
//'Arial' глючит
removeCharsFromString(w_font, _T("'"));
@ -343,7 +345,18 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
CP_XML_ATTR(L"cap", "small");
}
}
// underline
if (fo_text_transform_)
{
if (fo_text_transform_->get_type() == text_transform::Uppercase)
{
CP_XML_ATTR(L"cap", "all");
}
else if (fo_text_transform_->get_type() == text_transform::Lowercase)
{
CP_XML_ATTR(L"cap", "small");
}
}
// underline
line_width under = style_text_underline_width_.get_value_or(line_width::Auto);
bool underlineBold = under.get_type() == line_width::Bold ||
under.get_type() == line_width::Thick;
@ -363,7 +376,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
switch (style_text_underline_type_->get_type())
{
case line_type::Single: underline = L"sng"; break;
case line_type::Double: underline = L"double"; break;
case line_type::Double: underline = L"dbl"; break;
}
}
else if (style_text_underline_style_)
@ -397,8 +410,8 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
case line_style::Wave:
if (underlineBold) underline = L"wavyHeavy";
else if (style_text_underline_type_.get_value_or( line_type(line_type::Single) ).get_type() == line_type::Double)
underline = L"wavyDouble";
else underline = L"wave";
underline = L"wavyDbl";
else underline = L"wavy";
break;
}
}
@ -425,12 +438,12 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
if (fo_language_ || style_language_asian_ || style_language_complex_)
{
std::wstring w_val;
if (fo_language_) w_val = *fo_language_;
else if (fo_country_) w_val = *fo_country_;
else if (style_country_asian_)w_val = *style_country_asian_;
else if (style_language_asian_)w_val = *style_language_asian_;
else if (style_language_complex_)w_val = *style_language_complex_;
else if (style_country_complex_)w_val = *style_country_complex_;
if (fo_language_) w_val = *fo_language_;
else if (fo_country_) w_val = *fo_country_;
else if (style_country_asian_) w_val = *style_country_asian_;
else if (style_language_asian_) w_val = *style_language_asian_;
else if (style_language_complex_) w_val = *style_language_complex_;
else if (style_country_complex_) w_val = *style_country_complex_;
CP_XML_ATTR(L"lang", w_val);
}
@ -444,23 +457,45 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
}
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
{
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: w_font);
if (w_ascii.length()>0)
{
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_ascii));}
}
fonts_container & fonts = Context.root()->odf_context().fontContainer();
if (style_font_name_asian_)
{
std::wstring w_eastAsia = *style_font_name_asian_;
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_eastAsia));}
}
std::wstring w_eastAsia;
std::wstring w_hAnsi;
std::wstring w_cs;
std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
if (style_font_name_complex_)
{
std::wstring w_cs = *style_font_name_complex_;
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_cs));}
font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
if (font)
w_cs = font->name();
}
if (style_font_name_asian_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
if (font)
w_eastAsia = font->name();
}
if (style_font_name_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_);
if (font)
w_ascii = w_hAnsi = font->name();
}
if (!w_ascii.empty())
{
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_ascii));}
}
if (!w_eastAsia.empty())
{
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_eastAsia));}
}
if (!w_cs.empty())
{
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_cs));}
}
}
@ -619,7 +654,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
underline = L"single";
break;
case line_type::Double:
underline = L"double";
underline = L"dbl";
break;
}
}
@ -666,9 +701,9 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
if (underlineBold)
underline = L"wavyHeavy";
else if (style_text_underline_type_.get_value_or( line_type(line_type::Single) ).get_type() == line_type::Double)
underline = L"wavyDouble";
underline = L"wavyDbl";
else
underline = L"wave";
underline = L"wavy";
break;
}
}
@ -841,22 +876,38 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
{
fonts_container & fonts = Context.root()->odf_context().fontContainer();
std::wstring w_eastAsia;
std::wstring w_hAnsi;
std::wstring w_cs;
std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
_rPr << L"<w:rFonts ";
if (!w_ascii.empty())
_rPr << L"w:ascii=\"" << w_ascii <<"\" ";
if (!w_hAnsi.empty())
_rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
if (!w_eastAsia.empty())
_rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
if (!w_cs.empty())
_rPr << L"w:cs=\"" << w_cs <<"\" ";
if (style_font_name_complex_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
if (font)
w_cs = font->name();
}
if (style_font_name_asian_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
if (font)
w_eastAsia = font->name();
}
if (style_font_name_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_);
if (font)
w_ascii = w_hAnsi = font->name();
}
_rPr << L" />";
_rPr << L"<w:rFonts";
if (!w_ascii.empty()) _rPr << L" w:ascii=\"" << w_ascii <<"\"";
if (!w_hAnsi.empty()) _rPr << L" w:hAnsi=\"" << w_hAnsi <<"\"";
if (!w_eastAsia.empty()) _rPr << L" w:eastAsia=\"" << w_eastAsia <<"\"";
if (!w_cs.empty()) _rPr << L" w:cs=\"" << w_cs <<"\"";
_rPr << L"/>";
}
_CP_OPT(color) color_text = fo_color_;
@ -963,12 +1014,12 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
}
void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic)
void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic, fonts_container & fonts)
{
const int W = process_font_weight (fo_font_weight_);
const int fontStyle = process_font_style (fo_font_style_);
const int WCs = process_font_weight (style_font_weight_complex_);
if (graphic)
{
_rPr << L"<a:rPr";
@ -1109,7 +1160,7 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
underline = L"single";
break;
case line_type::Double:
underline = L"double";
underline = L"dbl";
break;
}
}
@ -1156,9 +1207,9 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
if (underlineBold)
underline = L"wavyHeavy";
else if (style_text_underline_type_.get_value_or( line_type(line_type::Single) ).get_type() == line_type::Double)
underline = L"wavyDouble";
underline = L"wavyDbl";
else
underline = L"wave";
underline = L"wavy";
break;
}
}
@ -1313,19 +1364,33 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
std::wstring w_eastAsia;
std::wstring w_hAnsi;
std::wstring w_cs;
std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
if (style_font_name_complex_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
if (font)
w_cs = font->name();
}
if (style_font_name_asian_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
if (font)
w_eastAsia = font->name();
}
if (style_font_name_)
{
font_instance * font = fonts.font_by_style_name(*style_font_name_);
if (font)
w_ascii = w_hAnsi = font->name();
}
_rPr << L"<w:rFonts ";
if (!w_ascii.empty())
_rPr << L"w:ascii=\"" << w_ascii <<"\" ";
if (!w_hAnsi.empty())
_rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
if (!w_eastAsia.empty())
_rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
if (!w_cs.empty())
_rPr << L"w:cs=\"" << w_cs <<"\" ";
_rPr << L" />";
_rPr << L"<w:rFonts";
if (!w_ascii.empty()) _rPr << L" w:ascii=\"" << w_ascii <<"\"";
if (!w_hAnsi.empty()) _rPr << L" w:hAnsi=\"" << w_hAnsi <<"\"";
if (!w_eastAsia.empty()) _rPr << L" w:eastAsia=\"" << w_eastAsia <<"\"";
if (!w_cs.empty()) _rPr << L" w:cs=\"" << w_cs <<"\"";
_rPr << L"/>";
}
_CP_OPT(color) color_text = fo_color_;

View File

@ -69,6 +69,7 @@ namespace cpdoccore {
namespace odf_reader {
class style_instance;
class fonts_container;
// 15.4
class text_format_properties_content : public oox::conversion_element
@ -79,7 +80,8 @@ public:
void docx_convert (oox::docx_conversion_context & Context);
void pptx_convert (oox::pptx_conversion_context & Context);
void pptx_convert_as_list (oox::pptx_conversion_context & Context);
void oox_convert (std::wostream & stream, bool graphic);
void oox_convert (std::wostream & stream, bool graphic, fonts_container & fonts);
void apply_from (const text_format_properties_content & Other);
void apply_to (std::vector<_property> & properties);

View File

@ -747,11 +747,11 @@ const wchar_t * style_column::name = L"column";
void style_column::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"fo:start-indent", fo_start_indent_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:end-indent", fo_end_indent_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:space-before", fo_space_before_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:space-after", fo_space_after_, length(0.0, length::cm));
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"fo:start-indent", fo_start_indent_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:end-indent", fo_end_indent_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:space-before", fo_space_before_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:space-after", fo_space_after_, length(0.0, length::cm));
}
@ -1134,14 +1134,14 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
CP_XML_NODE(L"w:pgMar")
{
CP_XML_ATTR(L"w:header" , process_page_margin(common_vertical_margin_attlist_.fo_margin_top_ ) );
CP_XML_ATTR(L"w:footer" , process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
CP_XML_ATTR(L"w:gutter" , 0 );
CP_XML_ATTR(L"w:left" , process_page_margin(common_horizontal_margin_attlist_.fo_margin_left_ , margin_left_length) );
CP_XML_ATTR(L"w:right" , process_page_margin(common_horizontal_margin_attlist_.fo_margin_right_, margin_right_length) );
CP_XML_ATTR(L"w:top" , process_page_margin(common_vertical_margin_attlist_.fo_margin_top_ , Context.get_header_footer_context().header()) );
CP_XML_ATTR(L"w:bottom" , process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ , Context.get_header_footer_context().footer()) );
CP_XML_ATTR(L"w:header" , process_page_margin(common_vertical_margin_attlist_.fo_margin_top_ ) );
CP_XML_ATTR(L"w:footer" , process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
CP_XML_ATTR(L"w:gutter" , 0 );
}
}
@ -1177,20 +1177,23 @@ void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_con
if (fo_page_width_ || fo_page_height_ || style_print_orientation_)
{
std::wstring w_w = L"",w_h = L"";
std::wstring w_w, w_h;
int h=0,w=0;
_INT64 h = 0, w = 0;
if (fo_page_width_)
{
w = fo_page_width_->get_value_unit(length::emu);
if (w < 914400) w = 914400;
w_w = boost::lexical_cast<std::wstring>(w);
w_w = std::to_wstring(w);
}
if (fo_page_height_)
{
h = fo_page_height_->get_value_unit(length::emu);
w_h = boost::lexical_cast<std::wstring>(h);
if (h < 914400) h = 914400;
w_h = std::to_wstring(h);
}
std::wstring w_orient = L"custom";
@ -1219,13 +1222,13 @@ void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_con
// style-footnote-sep-attlist
void style_footnote_sep_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:width", style_width_);
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"style:color", style_color_);
CP_APPLY_ATTR(L"style:line-style", style_line_style_);
CP_APPLY_ATTR(L"style:type", style_adjustment_, style_type(style_type::Left)); // default Left
CP_APPLY_ATTR(L"style:distance-before-sep", style_distance_before_sep_);
CP_APPLY_ATTR(L"style:distance-after-sep", style_distance_after_sep_);
CP_APPLY_ATTR(L"style:width", style_width_);
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"style:color", style_color_);
CP_APPLY_ATTR(L"style:line-style", style_line_style_);
CP_APPLY_ATTR(L"style:type", style_adjustment_, style_type(style_type::Left)); // default Left
CP_APPLY_ATTR(L"style:distance-before-sep", style_distance_before_sep_);
CP_APPLY_ATTR(L"style:distance-after-sep", style_distance_after_sep_);
}
/// style:footnote-sep
@ -1275,13 +1278,6 @@ bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox
}
void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{
if (Context.get_table_context().in_table())
{
// мы находимся внутри таблицы, устанавливаем специальное значение
Context.section_properties_in_table(this);
return;
}
style_columns * columns = dynamic_cast<style_columns *>( style_page_layout_properties_elements_.style_columns_.get());
CP_XML_WRITER(strm)
@ -1290,19 +1286,17 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
{
Context.process_section( CP_XML_STREAM(), columns);
bool next_page = Context.is_next_dump_page_properties();
CP_XML_NODE(L"w:type")
{
if (Context.is_next_dump_page_properties())
{
CP_XML_ATTR(L"w:val", L"nextPage");
}else
{
CP_XML_ATTR(L"w:val", L"continuous");
}
if (next_page) CP_XML_ATTR(L"w:val", L"nextPage");
else CP_XML_ATTR(L"w:val", L"continuous");
}
std::wstring masterPageName = Context.get_master_page_name();
bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
if (res == false)
{
// default???
@ -1312,7 +1306,7 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
}
oox::section_context::_section & section = Context.get_section_context().get();
@ -1462,39 +1456,42 @@ void style_master_page::pptx_convert(oox::pptx_conversion_context & Context)
////////////////
const wchar_t * hdrHeader = L"<w:hdr \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
mc:Ignorable=\"w14 wp14\">";
const wchar_t * ftrHeader = L"<w:ftr \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
mc:Ignorable=\"w14 wp14\">";
void style_header::docx_convert(oox::docx_conversion_context & Context)

View File

@ -754,7 +754,7 @@ namespace svg_path
}
}
if ((aCurrPoly.points.size() > 0 || !bIsClosed) && !aCurrPoly.command.empty())
if ((aCurrPoly.points.size() > 0 || !bIsClosed) && !aCurrPoly.command.empty() && aCurrPoly.command != L"a:cubicBezTo")
{
// end-process last poly

View File

@ -175,18 +175,6 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
Context.get_table_context().end_table();
_Wostream << L"</w:tbl>";
if (office_element * elm = Context.get_section_properties_in_table())
{
if (Context.get_table_context().in_table())
Context.section_properties_in_table(elm);
else
{
_Wostream << L"<w:p><w:pPr>";
elm->docx_convert(Context);
_Wostream << L"</w:pPr></w:p>";
}
}
}
void table_columns::docx_convert(oox::docx_conversion_context & Context)

View File

@ -137,7 +137,14 @@ typedef std::map<std::wstring, oox::text_tracked_context::_state>::iterator map_
int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
{
if (!Attr.text_style_name_.empty())
bool in_drawing = false;
if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
{
in_drawing = true;
}
if (!Attr.text_style_name_.empty())
{
if (style_instance * styleInst =
Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_.style_name(), style_family::Paragraph, Context.process_headers_footers_)
@ -180,7 +187,7 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
Context.end_automatic_style();
Context.push_text_properties(styleContent->get_style_text_properties());
return 1;
return 1;
}
}
else
@ -188,21 +195,27 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
const std::wstring id = Context.styles_map_.get( styleInst->name(), styleInst->type() );
Context.output_stream() << L"<w:pPr>";
//todooo причесать
if (Context.is_paragraph_header() && !Context.get_section_context().dump_.empty())
if (!Context.get_section_context().dump_.empty()
&& !Context.get_table_context().in_table()
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
&& !in_drawing)
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
if (Context.is_paragraph_header() )
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
Context.output_stream() << L"</w:pPr>";
Context.finish_paragraph();
Context.start_paragraph();
Context.output_stream() << L"<w:pPr>";
Context.output_stream() << L"</w:pPr>";
Context.finish_paragraph();
Context.start_paragraph();
Context.output_stream() << L"<w:pPr>";
}
else
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
}
}
else if ( !Context.get_table_context().in_table())
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
}
Context.output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
@ -231,7 +244,10 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
}
}
}
if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
if (!Context.get_section_context().dump_.empty()
&& !Context.get_table_context().in_table()
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
&& !in_drawing)
{
Context.output_stream() << L"<w:pPr>";
Context.output_stream() << Context.get_section_context().dump_;
@ -249,25 +265,25 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
std::wostream & paragraph::text_to_stream(std::wostream & _Wostream) const
{
// TODO!!!!
CP_SERIALIZE_TEXT(paragraph_content_);
CP_SERIALIZE_TEXT(content_);
_Wostream << L"\n";
return _Wostream;
}
void paragraph::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
paragraph_attrs_.add_attributes(Attributes);
attrs_.add_attributes(Attributes);
}
void paragraph::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
{
CP_CREATE_ELEMENT_SIMPLE(paragraph_content_);
CP_CREATE_ELEMENT_SIMPLE(content_);
}
void paragraph::add_text(const std::wstring & Text)
{
office_element_ptr elm = text::create(Text) ;
paragraph_content_.push_back( elm );
content_.push_back( elm );
}
void paragraph::afterCreate(document_context * Context)
@ -301,7 +317,7 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
str = store_str.substr(0,Context.get_drop_cap_context().Length);
int textStyle = process_paragraph_attr(paragraph_attrs_, Context);
int textStyle = process_paragraph_attr(attrs_, Context);
first_text_paragraph->docx_convert(Context);
int str_start = Context.get_drop_cap_context().Length;
@ -314,16 +330,16 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
}
void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
{
if ( paragraph_content_.empty()) return;
if ( content_.empty()) return;
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!- todooo сделать возможным множественным span
if ( paragraph_content_[0]->get_type() == typeTextText)
if ( content_[0]->get_type() == typeTextText)
{
drop_cap_text_docx_convert(paragraph_content_[0],Context);
drop_cap_text_docx_convert(content_[0],Context);
}
else if (paragraph_content_[0]->get_type() == typeTextSpan)
else if (content_[0]->get_type() == typeTextSpan)
{
span* first_span_in_paragraph = dynamic_cast<span*>(paragraph_content_[0].get());
span* first_span_in_paragraph = dynamic_cast<span*>(content_[0].get());
if (Context.get_drop_cap_context().FontSize < 1)
{
style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(first_span_in_paragraph->text_style_name_.style_name(), style_family::Text,Context.process_headers_footers_);
@ -343,49 +359,43 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
}
}
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!
if ((first_span_in_paragraph->paragraph_content_.size()>0) &&
(first_span_in_paragraph->paragraph_content_[0]->get_type() == typeTextText))
if ((first_span_in_paragraph->content_.size()>0) &&
(first_span_in_paragraph->content_[0]->get_type() == typeTextText))
{
drop_cap_text_docx_convert(first_span_in_paragraph->paragraph_content_[0],Context);
drop_cap_text_docx_convert(first_span_in_paragraph->content_[0],Context);
}
}
}
void paragraph::docx_convert(oox::docx_conversion_context & Context)
{
bool drawing = false;
const std::wstring & styleName = attrs_.text_style_name_.style_name();
bool in_drawing = false;
if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
{
drawing = true;
in_drawing = true;
}
bool bIsNewParagraph = true;
if (Context.get_paragraph_state() && (Context.get_process_note() == oox::docx_conversion_context::noNote) && !drawing )
{//вложеннные элементы
if (paragraph_content_.empty())//??
{
Context.output_stream() << L"<w:p>";
Context.output_stream() << emptyParagraphContent;
Context.output_stream() << L"</w:p>";
bool is_empty = content_.empty();
if (Context.get_paragraph_state() && (Context.get_process_note() == oox::docx_conversion_context::noNote) && !in_drawing)
{//вложеннные элементы ... или после графики embedded_linux_kernel_and_drivers_labs_zh_TW.odt
bIsNewParagraph = false;
if (!Context.get_paragraph_keep())// например Appendix I_IPP.odt - tracked elements (
{
for (int i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
}
if (!Context.get_delete_text_state())
Context.set_paragraph_state(false);// например Appendix I_IPP.odt - tracked elements (вложенные списки из 2 элементов)
return;
}
else
{
bIsNewParagraph = false;
if (!Context.get_paragraph_keep())
{
for (int i = 0; i < paragraph_content_.size(); i++)
{
paragraph_content_[i]->docx_convert(Context);
}
return;
}
}
}
bool is_empty = paragraph_content_.empty();
if (bIsNewParagraph)
Context.start_paragraph(is_header_);
@ -398,7 +408,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
// если да — устанавливаем контексту флаг на то что необходимо в конце текущего параграфа
// распечатать свойства секции
//проверить ... не она ли основная - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const std::wstring & next_styleName = next_par_->paragraph_attrs_.text_style_name_.style_name();
const std::wstring & next_styleName = next_par_->attrs_.text_style_name_.style_name();
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
@ -413,7 +423,6 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty = false;
}
const std::wstring & styleName = paragraph_attrs_.text_style_name_.style_name();
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName);
if (masterPageName)
@ -425,12 +434,10 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
Context.set_page_break(true);
is_empty = false;
}
process_paragraph_drop_cap_attr(paragraph_attrs_, Context);
process_paragraph_drop_cap_attr(attrs_, Context);
if (Context.get_drop_cap_context().state() == 2)//active
{
@ -444,16 +451,17 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
}
int textStyle = process_paragraph_attr(paragraph_attrs_, Context);
int textStyle = process_paragraph_attr(attrs_, Context);
Context.add_note_reference();
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
if (Context.get_page_break())
{
if (Context.process_headers_footers_ == false)
_Wostream << L"<w:lastRenderedPageBreak/>";
//_Wostream << L"<w:lastRenderedPageBreak/>";
_Wostream << L"<w:br w:type=\"page\"/>";
Context.set_page_break(false);
}
elm->docx_convert(Context);
@ -482,7 +490,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty = false;
Context.add_new_run(_T(""));
_Wostream << L"<w:br w:type=\"page\" />";
_Wostream << L"<w:br w:type=\"page\"/>";
Context.finish_run();
}
@ -501,8 +509,8 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.start_paragraph(paragraph_attrs_.text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
Context.start_paragraph(attrs_.text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->xlsx_convert(Context);
}
@ -510,12 +518,14 @@ void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
}
void paragraph::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_paragraph(paragraph_attrs_.text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
Context.get_text_context().start_paragraph(attrs_.text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->pptx_convert(Context);
}
Context.get_text_context().end_paragraph();
Context.get_text_context().end_paragraph();
}
///////////////////////////////////////////
void soft_page_break::docx_convert(oox::docx_conversion_context & Context)
@ -546,7 +556,7 @@ void h::add_attributes( const xml::attributes_wc_ptr & Attributes )
paragraph_.add_attributes(Attributes);
paragraph_.is_header_ = true;
paragraph_.paragraph_attrs_.outline_level_ = text_outline_level_;
paragraph_.attrs_.outline_level_ = text_outline_level_;
}
void h::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -965,9 +975,39 @@ void text_table_index::add_child_element( xml::sax * Reader, const std::wstring
const wchar_t * text_illustration_index::ns = L"text";
const wchar_t * text_illustration_index::name = L"illustration-index";
void text_illustration_index::afterCreate()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_section(true);
}
}
}
void text_illustration_index::afterReadContent()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_end_section(true);
}
}
}
void text_illustration_index::docx_convert(oox::docx_conversion_context & Context)
{
if (text_index_body_)
std::wstring current_page_properties = Context.get_page_properties();
Context.get_section_context().add_section(
text_section_attr_.text_name_,
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
current_page_properties
);
Context.add_page_properties(current_page_properties);
if (text_index_body_)
text_index_body_->docx_convert(Context);
}
@ -995,8 +1035,77 @@ void text_illustration_index::add_child_element( xml::sax * Reader, const std::w
{
CP_CREATE_ELEMENT(text_index_body_);
}
// TODO text-illustration-index-source
// todooo text-illustration-index-source
}
// text:alphabetical-index
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * text_alphabetical_index::ns = L"text";
const wchar_t * text_alphabetical_index::name = L"alphabetical-index";
void text_alphabetical_index::afterCreate()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_section(true);
}
}
}
void text_alphabetical_index::afterReadContent()
{
if (document_context * context = getContext())
{
if (paragraph * lastPar = context->get_last_paragraph())
{
lastPar->set_next_end_section(true);
}
}
}
void text_alphabetical_index::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring current_page_properties = Context.get_page_properties();
Context.get_section_context().add_section(
text_section_attr_.text_name_,
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
current_page_properties
);
Context.add_page_properties(current_page_properties);
if (text_index_body_)
text_index_body_->docx_convert(Context);
}
void text_alphabetical_index::pptx_convert(oox::pptx_conversion_context & Context)
{
if (text_index_body_)
text_index_body_->pptx_convert(Context);
}
std::wostream & text_alphabetical_index::text_to_stream(std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(text_index_body_);
return _Wostream;
}
void text_alphabetical_index::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
text_section_attr_.add_attributes( Attributes );
}
void text_alphabetical_index::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"index-body")
{
CP_CREATE_ELEMENT(text_index_body_);
}
// todooo text-alphabetical-index-source
}
//--------------------------------------------------------------------------------------------------------
// text:tracked-changes
const wchar_t * text_tracked_changes::ns = L"text";
@ -1031,14 +1140,19 @@ void text_changed_region::add_attributes( const xml::attributes_wc_ptr & Attribu
void text_changed_region::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(element_);
CP_CREATE_ELEMENT(content_);
}
void text_changed_region::docx_convert(oox::docx_conversion_context & Context)
{
if (!element_ || !text_id_) return;
if (content_.empty() || !text_id_) return;
Context.get_text_tracked_context().start_change (*text_id_);
element_->docx_convert(Context);
for (int i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
}
Context.get_text_tracked_context().end_change ();
}
@ -1066,12 +1180,30 @@ void text_unknown_base_change::docx_convert(oox::docx_conversion_context & Conte
if (content_.empty()) return;
//тут удаленный текст. не по стандарту сделать бы и форматы - стилями чтоли ....
Context.get_text_tracked_context().start_changes_content();
for (int i = 0; i < content_.size(); i++)
for (int i = 0; i < content_.size(); i++)
{
Context.get_text_tracked_context().start_changes_content();
{
content_[i]->docx_convert(Context);
//h *h_ = dynamic_cast<h*>(content_[i].get());
//p *p_ = dynamic_cast<p*>(content_[i].get());
//paragraph *para = NULL;
//if (h_) para = &h_->paragraph_;
//if (p_) para = &p_->paragraph_;
//if (para)
//{
// for (int j = 0; j < para->content_.size(); j++)
// {
// para->content_[j]->docx_convert(Context);
// }
//}
}
Context.get_text_tracked_context().end_changes_content();
Context.get_text_tracked_context().end_changes_content();
}
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_insertion::ns = L"text";

View File

@ -56,12 +56,12 @@ public:
std::wostream & text_to_stream(std::wostream & _Wostream) const;
void add_attributes( const xml::attributes_wc_ptr & Attributes );
void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
void add_text(const std::wstring & Text);
void add_attributes ( const xml::attributes_wc_ptr & Attributes );
void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
void add_text (const std::wstring & Text);
paragraph * get_next() { return next_par_; }
void set_next(paragraph * next) {next_par_ = next;}
paragraph * get_next() { return next_par_; }
void set_next(paragraph * next) {next_par_ = next;}
void set_next_section(bool Val)
{
@ -75,17 +75,17 @@ public:
void afterCreate(document_context * ctx);
void docx_convert(oox::docx_conversion_context & Context) ;
void xlsx_convert(oox::xlsx_conversion_context & Context) ;
void pptx_convert(oox::pptx_conversion_context & Context) ;
void docx_convert (oox::docx_conversion_context & Context) ;
void xlsx_convert (oox::xlsx_conversion_context & Context) ;
void pptx_convert (oox::pptx_conversion_context & Context) ;
void drop_cap_docx_convert(oox::docx_conversion_context & Context);
office_element_ptr_array content_;
private:
void drop_cap_text_docx_convert(office_element_ptr first_text_paragraph,oox::docx_conversion_context & Context);
paragraph_attrs paragraph_attrs_;
office_element_ptr_array paragraph_content_;
paragraph_attrs attrs_;
paragraph *next_par_;
@ -117,6 +117,7 @@ public:
virtual void afterCreate();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
paragraph paragraph_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
@ -130,8 +131,6 @@ private:
_CP_OPT(bool) text_is_list_header_;
_CP_OPT(std::wstring) text_number_;
paragraph paragraph_;
friend class par_docx_convert_class;
};
@ -361,6 +360,9 @@ public:
static const ElementType type = typeTextIllustrationIndex;
CPDOCCORE_DEFINE_VISITABLE();
virtual void afterCreate();
virtual void afterReadContent();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
@ -378,6 +380,36 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(text_illustration_index);
//---------------------------------------------------------------------------------------------------
class text_alphabetical_index : public text_content_impl<text_alphabetical_index>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextAlphabeticalIndex;
CPDOCCORE_DEFINE_VISITABLE();
virtual void afterCreate();
virtual void afterReadContent();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
text_section_attr text_section_attr_;
office_element_ptr text_alphabetical_index_source_;
office_element_ptr text_index_body_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_alphabetical_index);
//---------------------------------------------------------------------------------------------------
class text_index_body : public text_content_impl<text_index_body>
@ -545,8 +577,8 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
_CP_OPT(std::wstring) text_id_; //== xml:id
office_element_ptr element_;
_CP_OPT(std::wstring) text_id_; //== xml:id
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_changed_region);

View File

@ -369,6 +369,14 @@
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\DocWrapper\DocxSerializer.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/bigobj"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>

View File

@ -4206,7 +4206,7 @@ HRESULT CDrawingConverter::SaveObject(LONG lStart, LONG lLength, const CString&
if (-1 == nIndexF)
return S_FALSE;
int nIndexTail = (std::min)(strMainProps.Find(_T("<wp14:sizeRelH")), strMainProps.Find(_T("<wp14:sizeRelV")));
int nIndexTail = strMainProps.Find(_T("<wp14:sizeRel"));
if(-1 != nIndexTail)
{
strMainPropsTail = strMainProps.Right(strMainProps.GetLength() - nIndexTail);

View File

@ -116,42 +116,44 @@ namespace NSGuidesVML
ptValue = 2
};
static LONG GetValue(CString strParam, ParamType& ptType, bool& bRes,
static long GetValue(CString strParam, ParamType& ptType, bool& bRes,
long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML)
{
ptType = ptValue;
bRes = true;
ptType = ptValue;
bRes = true;
long val = 0;
if ('#' == strParam[0])
{
ptType = ptAdjust;
return (LONG)XmlUtils::GetInteger(strParam.Mid(1));
val = XmlUtils::GetInteger(strParam.Mid(1));
}
else if ('@' == strParam[0])
{
ptType = ptFormula;
return (LONG)XmlUtils::GetInteger(strParam.Mid(1));
val = XmlUtils::GetInteger(strParam.Mid(1));
}
else if (!NSStringUtils::IsNumber(strParam))
{
if (_T("width") == strParam)
{
return lShapeWidth;
val = lShapeWidth;
}
else if (_T("height") == strParam)
{
return lShapeHeight;
val = lShapeHeight;
}
else if (_T("pixelWidth") == strParam)
{
return lShapeWidth;
val = lShapeWidth;
}
else if (_T("pixelHeight") == strParam)
{
return lShapeHeight;
val = lShapeHeight;
}
else if (_T("pixelLineWidth") == strParam || _T("lineDrawn") == strParam)
{
return 1;
val = 1;
}
else
{
@ -162,8 +164,9 @@ namespace NSGuidesVML
else
{
ptType = ptValue;
return (LONG)XmlUtils::GetInteger(strParam);
val = XmlUtils::GetInteger(strParam);
}
return val;
}
static FormulaType GetFormula(CString strName, bool& bRes)

View File

@ -2669,6 +2669,11 @@ namespace NSGuidesVML
{
if (0 != m_arSlicesPath.size())
{
if ( lValue >= 0x7fffff00 || lValue <= -0x7fffff00)
{
lValue = 0; //process(2).ppt - todooo разобраться что за хрень это ваще приплыла
}
m_arSlicesPath[m_arSlicesPath.size() - 1].AddParam(lValue, eParamType);
}
}

View File

@ -324,14 +324,14 @@ namespace NSBinPptxRW
m_lFlag = 0;
m_lGroupIndex = 0;
m_lObjectId = 0;
m_lObjectIdVML = 0;
m_lObjectIdVML = 0;
m_lObjectIdOle = 0;
m_bIsUseOffice2007 = false;
m_strStyleMain = _T("");
m_strStyleMain = _T("");
m_strAttributesMain = _T("");
m_strNodes = _T("");
m_strOleXlsx = _T("");
m_strNodes = _T("");
m_strOleXlsx = _T("");
m_pOOXToVMLRenderer = NULL;
m_bIsTop = false;

View File

@ -744,11 +744,14 @@
#define ASC_MENU_EVENT_TYPE_ERROR 500
#define ASC_MENU_EVENT_TYPE_COLOR_SCHEMES 2404 // CAscColorSchemes
#define ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME 2415 // SET(int)
#define ASC_COAUTH_EVENT_TYPE_PARTICIPANTS_CHANGED 20101
#define ASC_COAUTH_EVENT_TYPE_LOST_CONNECTION 20102
#define ASC_COAUTH_EVENT_TYPE_DROP_CONNECTION 20103
#define ASC_MENU_EVENT_TYPE_COLOR_SCHEMES 2404 // CAscColorSchemes
#define ASC_MENU_EVENT_TYPE_CHANGE_COLOR_SCHEME 2415 // SET(int)
#define ASC_MENU_EVENT_TYPE_AUTH_PARTICIPANTS_CHANGED 2416
#define ASC_MENU_EVENT_TYPE_LOST_CONNECTION 2420
#define ASC_MENU_EVENT_TYPE_DROP_CONNECTION 2421
#define ASC_COAUTH_EVENT_TYPE_INSERT_URL_IMAGE 21000
#endif //_BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_

View File

@ -46,7 +46,7 @@
//#define ONLINE_WORD_TO_PDF
//#define TO_PDF
#define TO_HTML_RENDERER
//#define ONLY_TEXT
#define ONLY_TEXT
int main(int argc, char *argv[])
{
@ -97,7 +97,7 @@ int main(int argc, char *argv[])
//std::wstring sFile = L"D:\\bankomats.xps";
//std::wstring sFile = L"\\\\kirillov8\\_Office\\DJVU\\Основы разработки приложений на платформе Microsoft .NET Framework. Учебный курс Microsoft экзамен 70-536.djvu";
//std::wstring sFile = L"D:\\TESTFILES\\Алгоритмы - построение и анализ.djvu";
std::wstring sFile = L"D:\\knopk5_0.pdf";
std::wstring sFile = L"D:\\TESTFILES\\PDF 1-7 (756p).pdf";
std::wstring sDst = L"D:\\test\\Document";
//std::wstring sFile = L"/home/oleg/activex/Android intro(2p).pdf";
@ -170,7 +170,5 @@ int main(int argc, char *argv[])
oRenderer.SaveToFile(L"/home/oleg/activex/1/1.pdf");
#endif
RELEASEOBJECT(pReader);
return 0;
}

View File

@ -226,7 +226,7 @@ endef
.PHONY : all bin lib clean
all: lib bin
all: lib bin
bin: $(X2T) $(ALLFONTSGEN)

View File

@ -1,5 +1,5 @@
[![License](https://img.shields.io/badge/License-GNU%20AGPL%20V3-green.svg?style=flat)](http://www.gnu.org/licenses/agpl-3.0.ru.html) ![Release](https://img.shields.io/badge/Release-v4.1.2-blue.svg?style=flat) ![x2tconverter](https://img.shields.io/badge/x2tconverter-v2.0.2.376-blue.svg?style=flat) ![Platforms Windows | OS X | Linux](https://img.shields.io/badge/Platforms-Windows%20%7C%20OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat)
[![License](https://img.shields.io/badge/License-GNU%20AGPL%20V3-green.svg?style=flat)](http://www.gnu.org/licenses/agpl-3.0.ru.html) ![x2tconverter](https://img.shields.io/badge/x2tconverter-v2.0.2.376-blue.svg?style=flat) ![Platforms Windows | OS X | Linux](https://img.shields.io/badge/Platforms-Windows%20%7C%20OS%20X%20%7C%20Linux%20-lightgray.svg?style=flat)
## Core
Server core components which are a part of [ONLYOFFICE Document Server][2]. Enable the conversion between the most popular office document formats: DOC, DOCX, ODT, RTF, TXT, PDF, HTML, EPUB, XPS, DjVu, XLS, XLSX, ODS, CSV, PPT, PPTX, ODP.

View File

@ -7,7 +7,7 @@
QT -= core
QT -= gui
VERSION = 2.0.2.412
VERSION = 2.0.2.417
DEFINES += INTVER=$$VERSION
TARGET = x2t

View File

@ -33,4 +33,4 @@ core_linux_32 {
}
core_mac {
DESTDIR = $$DESTDIR/mac_64
}
}