Commit b3b3bb48 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

......

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63408 954022d7-b5bf-4e40-9824-e11837661b57
parent a546bcfa
......@@ -178,7 +178,10 @@ std::wstring docx_conversion_context::add_hyperlink(const std::wstring & href, b
else if (process_note_ == footNote || process_note_ == footNoteRefSet) type = hyperlinks::footnote_place;
else if (process_note_ == endNote || process_note_ == endNoteRefSet ) type = hyperlinks::endnote_place;
return hyperlinks_.add(href, type, draw);
std::wstring href_correct = xml::utils::replace_text_to_xml(href);
boost::algorithm::replace_all(href_correct, L" .", L".");//1 (130).odt
return hyperlinks_.add(href_correct, type, draw);
}
hyperlinks::_ref docx_conversion_context::last_hyperlink()
{
......@@ -671,28 +674,24 @@ odf_reader::style_text_properties_ptr docx_conversion_context::current_text_prop
return cur;
}
void docx_conversion_context::add_page_break_after()
void docx_conversion_context::set_page_break_after(bool val)
{
page_break_after_ = true;
page_break_after_ = val;
}
bool docx_conversion_context::check_page_break_after()
bool docx_conversion_context::get_page_break_after()
{
bool t = page_break_after_;
page_break_after_ = false;
return t;
return page_break_after_ ;
}
void docx_conversion_context::add_page_break_before()
void docx_conversion_context::set_page_break_before(bool val)
{
page_break_before_ = true;
page_break_before_ = val;
}
bool docx_conversion_context::check_page_break_before()
bool docx_conversion_context::get_page_break_before()
{
bool t = page_break_before_;
page_break_before_ = false;
return t;
return page_break_before_;
}
......@@ -829,7 +828,10 @@ void docx_conversion_context::add_delayed_element(odf_reader::office_element * E
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
delayed_converting_ = true;
while(!delayed_elements_.empty())
......@@ -930,6 +932,14 @@ void docx_conversion_context::process_headers_footers()
process_one_header_footer(*this, styleName, page->style_footer_first_.get(), headers_footers::footerFirst );
process_one_header_footer(*this, styleName, page->style_header_left_.get(), headers_footers::headerLeft );
process_one_header_footer(*this, styleName, page->style_footer_left_.get(), headers_footers::footerLeft );
if (!page->style_header_ && !page->style_footer_ && !page->style_header_first_ && !page->style_footer_first_
&& !page->style_header_left_ && !page->style_footer_left_)
{
//
rels rels_;
get_headers_footers().add(styleName, L"", headers_footers::none, rels_);
}
}
process_headers_footers_ = false;
}
......
......@@ -436,11 +436,11 @@ public:
void pop_text_properties();
odf_reader::style_text_properties_ptr current_text_properties();
void add_page_break_after();
bool check_page_break_after();
void set_page_break_after(bool val);
bool get_page_break_after();
void add_page_break_before();
bool check_page_break_before();
void set_page_break_before(bool val);
bool get_page_break_before();
void set_page_properties(const std::wstring & StyleName);
const std::wstring & get_page_properties() const;
......
......@@ -201,6 +201,8 @@ void headers_footers_elements::write(const std::wstring & RootPath)
{
BOOST_FOREACH(const headers_footers::instance_ptr & inst, instAr.second)
{
if (inst->type_ == headers_footers::none) continue;
simple_element(inst->name_, inst->content_).write(RootPath);
if (document * doc = this->get_main_document())
......
......@@ -23,9 +23,14 @@ std::wstring headers_footers::add(const std::wstring & StyleName,
rels &_rels
)
{
size_++;
const std::wstring id = create_id(size_);
const std::wstring name = create_name(size_, type);
std::wstring id, name;
if (type != headers_footers::none)
{
size_++;
id = create_id(size_);
name = create_name(size_, type);
}
instance_ptr inst = instance_ptr( new instance(id, Content, type, name) );
BOOST_FOREACH(const relationship & r, _rels.relationships())
......@@ -81,11 +86,16 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream
left=true;
}
std::wstring name = L"w:headerReference";
std::wstring name;
if (inst->type_ == footer || inst->type_ == footerLeft || inst->type_ == footerFirst )
name =L"w:footerReference";
else if (inst->type_ == header || inst->type_ == headerLeft || inst->type_ == headerFirst )
name =L"w:headerReference";
_Wostream << L"<" << name << L" r:id=\"" << inst->id_ << L"\" w:type=\"" << type << "\" />";
if (!name.empty())
{
_Wostream << L"<" << name << L" r:id=\"" << inst->id_ << L"\" w:type=\"" << type << "\" />";
}
if (first)_Wostream << L"<w:titlePg/>";
res=true;
......
......@@ -19,7 +19,7 @@ class headers_footers
{
public:
headers_footers() : size_(0),enable_write_(false){}
enum Type { header, footer, headerLeft, footerLeft, headerFirst, footerFirst };
enum Type { header, footer, headerLeft, footerLeft, headerFirst, footerFirst, none };
std::wstring add(const std::wstring & StyleName, const std::wstring & Content, Type type,rels &_rels);
struct instance
......
......@@ -2,6 +2,7 @@
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/odf/odf_document.h>
#include "mediaitems_utils.h"
......@@ -272,12 +273,15 @@ void pptx_slide_context::set_fill(_oox_fill & fill)
impl_->object_description_.fill_= fill;
}
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & ref,bool object)
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & href,bool object)
{
++hlinks_size_;
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
_hlink_desc desc={hId, ref, object};
std::wstring href_correct = xml::utils::replace_text_to_xml(href);
boost::algorithm::replace_all(href_correct, L" .", L".");//1 (130).odt
_hlink_desc desc={hId, href_correct, object};
impl_->object_description_.hlinks_.push_back(desc);
return hId;
......
#include <boost/foreach.hpp>
#include <iostream>
#include "../formulasconvert/formulasconvert.h"
#include <cpdoccore/xml/utils.h>
#include "mediaitems_utils.h"
......@@ -12,6 +12,7 @@
#include "xlsx_table_metrics.h"
#include "../odf/draw_common.h"
#include "../formulasconvert/formulasconvert.h"
#include "drawing_object_description.h"
......@@ -234,12 +235,16 @@ void xlsx_drawing_context::set_fill(_oox_fill & fill)
{
impl_->object_description_.fill_= fill;
}
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & ref,bool object)
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href,bool object)
{
++hlinks_size_;
std::wstring hId=std::wstring(L"hId") + boost::lexical_cast<std::wstring>(hlinks_size_);
_hlink_desc desc={hId, ref, object};
std::wstring href_correct = xml::utils::replace_text_to_xml(href);
boost::algorithm::replace_all(href_correct, L" .", L".");//1 (130).odt
_hlink_desc desc = {hId, href_correct, object}; // ms office open office ->
//todooo
impl_->object_description_.hlinks_.push_back(desc);
return hId;
......
......@@ -146,9 +146,9 @@ void chart_build::xlsx_convert(oox::xlsx_conversion_context & Context)
{
office_text_->xlsx_convert(Context);
}
else if (object_type_ == 3 && math_math_)
else if (object_type_ == 3 && office_math_)
{
math_math_->xlsx_convert(Context);
office_math_->xlsx_convert(Context);
}
}
void chart_build::docx_convert(oox::docx_conversion_context & Context)
......@@ -166,9 +166,9 @@ void chart_build::docx_convert(oox::docx_conversion_context & Context)
{
office_text_->docx_convert(Context);
}
else if (object_type_ == 3 && math_math_)
else if (object_type_ == 3 && office_math_)
{
math_math_->docx_convert(Context);
office_math_->docx_convert(Context);
}
}
void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
......@@ -186,9 +186,9 @@ void chart_build::pptx_convert(oox::pptx_conversion_context & Context)
{
office_text_->pptx_convert(Context);
}
else if (object_type_ == 3 && math_math_)
else if (object_type_ == 3 && office_math_)
{
math_math_->pptx_convert(Context);
office_math_->pptx_convert(Context);
}
}
void chart_build::calc_cash_series(std::wstring adress, std::vector<std::wstring> & cash)
......@@ -425,7 +425,7 @@ void process_build_chart::visit(office_text& val)
chart_build_.object_type_ = 2;
chart_build_.office_text_ = &val;//
}
void process_build_chart::visit(const math_math& val)
void process_build_chart::visit(const math& val)
{
chart_build_.object_type_ = 3;
//chart_build_.math_semantics_ = &val.semantics_;//
......
......@@ -32,8 +32,8 @@ namespace {
struct class_type_pair
{
chart::class_type class_type_;
std::wstring class_type_str_;
chart::class_type class_type_;
std::wstring class_type_str_;
};
static const class_type_pair class_type_str[] =
......@@ -82,7 +82,7 @@ public:
columns_count_(0),
object_type_(0),
office_text_(NULL),
math_math_(NULL)
office_math_(NULL)
{
}
......@@ -121,7 +121,7 @@ public:
int object_type_;
office_text *office_text_;
math_math *math_math_;
math *office_math_;
std::wstring str_class_;
chart::class_type class_;
......@@ -180,7 +180,7 @@ class process_build_chart : public base_visitor,
public visitor<office_text>,
public const_visitor<math_math>,
public const_visitor<math>,
public const_visitor<chart_chart>,
......@@ -251,7 +251,7 @@ public:
virtual void visit(office_body& val);
virtual void visit(office_chart& val);
virtual void visit(office_text& val);
virtual void visit(const math_math& val);
virtual void visit(const math& val);
virtual void visit(const chart_chart& val);
virtual void visit(const chart_title& val);
virtual void visit(const chart_subtitle& val);
......
......@@ -1075,7 +1075,12 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
{
if (Context.get_drawing_context().get_current_level() >1 )return;
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::docx_conversion_context::StreamsManPtr prev = Context.get_stream_man();
......
......@@ -13,32 +13,36 @@ namespace cpdoccore {
namespace odf_reader {
// math
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * math::ns = L"";
const wchar_t * math::name = L"math";
// math:math
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * math_math::ns = L"math";
const wchar_t * math_math::name = L"math";
void math_math::add_attributes( const xml::attributes_wc_ptr & Attributes )
void math::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}
void math_math::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
void math::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
void math_math::docx_convert(oox::docx_conversion_context & Context)
void math::docx_convert(oox::docx_conversion_context & Context)
{
}
void math_math::xlsx_convert(oox::xlsx_conversion_context & Context)
void math::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
void math_math::pptx_convert(oox::pptx_conversion_context & Context)
void math::pptx_convert(oox::pptx_conversion_context & Context)
{
}
......
......@@ -10,15 +10,14 @@
namespace cpdoccore {
namespace odf_reader {
class math_math : public office_element_impl<math_math>
class math : public office_element_impl<math>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathMath;
static const ElementType type = typeMath;
//virtual std::wostream & text_to_stream(::std::wostream & _Wostream) const;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context);
......@@ -28,11 +27,27 @@ public:
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);
//virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(math);
//--------------------------------------------------------------------
class math_math : public math
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeMathMath;
CPDOCCORE_DEFINE_VISITABLE();
};
CP_REGISTER_OFFICE_ELEMENT2(math_math);
//--------------------------------------------------------------------
}
}
......@@ -49,7 +49,7 @@ void content_xml_t::add_child_element( xml::sax * Reader, const ::std::wstring &
{
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
}
else if CP_CHECK_NAME(L"math", L"math")
else if ( CP_CHECK_NAME(L"math", L"math") || CP_CHECK_NAME(L"", L"math"))
{
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
}
......
......@@ -169,6 +169,7 @@ enum ElementType
typeOfficeDocumentMeta,
typeOfficeDocumentSettings,
typeMath,
typeMathMath,
typeManifest,
......
......@@ -183,8 +183,9 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co
CP_XML_NODE(L"w:textAlignment"){CP_XML_ATTR(L"w:val", L"baseline");}
}
if (Context.check_page_break_before())
if (Context.get_page_break_before())
{
Context.set_page_break_before(false);
CP_XML_NODE(L"w:pageBreakBefore"){CP_XML_ATTR(L"w:val", L"true"); }
}
else if (fo_break_before_)
......@@ -367,7 +368,7 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co
{
if (Context.in_automatic_style())
{
Context.add_page_break_after();
Context.set_page_break_after(true);
}
}
if (style_tab_stops_)
......
......@@ -97,7 +97,7 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (common_break_attlist_.fo_break_before_)
{
if (common_break_attlist_.fo_break_before_->get_type() == fo_break::Page)
Context.add_page_break_before();
Context.set_page_break_before(true);
}
if (table_align_)
......
......@@ -47,7 +47,7 @@ void process_page_break_after(const style_instance * styleInst, oox::docx_conver
{
if (fo_break_val->get_type() == fo_break::Page)
{
Context.add_page_break_after();
Context.set_page_break_after(true);
break;
}
else if (fo_break_val->get_type() == fo_break::Auto)
......@@ -295,14 +295,14 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
}
bool is_empty= paragraph_content_.size()==0;
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
{
if (elm->get_type() == typeTextSoftPageBreak && !Context.check_page_break_after() && !Context.check_page_break_before() && !(next_section_ || next_end_section_))
{//1 (206).odt - soft-break
Context.add_page_break_before();
}
}
// BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
// {
// if (elm->get_type() == typeTextSoftPageBreak && !Context.get_page_break_after() && !Context.get_page_break_before() && !(next_section_ || next_end_section_))
// {//1 (206).odt - soft-break
// // 1 (130).odt (
// Context.set_page_break_before(true);
// }
//}
Context.start_paragraph();
......@@ -368,12 +368,12 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
if (Context.get_drop_cap_context().state() >0)
Context.get_drop_cap_context().state(0);//disable
if (elm->get_type() == typeTextSoftPageBreak && !Context.check_page_break_after() && !Context.check_page_break_before())
if (elm->get_type() == typeTextSoftPageBreak && !Context.get_page_break_after() && !Context.get_page_break_before())
{
_Wostream << L"<w:lastRenderedPageBreak/>";
if (next_section_ || next_end_section_)
Context.add_page_break_before();
Context.set_page_break_before(true);
}
}
......@@ -392,8 +392,10 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
Context.docx_convert_delayed();
}
if (Context.check_page_break_after())
if (Context.get_page_break_after())
{
Context.set_page_break_after(false);
is_empty = false;
Context.add_new_run(_T(""));
_Wostream << L"<w:br w:type=\"page\" />";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment