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

(1.2.0.102): ASCOfficeOdfFileW


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57515 954022d7-b5bf-4e40-9824-e11837661b57
parent 3c8678f7
......@@ -52,10 +52,72 @@ void odf_text_context::set_single_object(bool val, style_paragraph_properties *p
}
void odf_text_context::add_text_content(const std::wstring & text)
void odf_text_context::add_text_content(std::wstring & text)
{
if (current_level_.size() > 0 )
current_level_.back().elm->add_text(text);
if (current_level_.size() < 1) return;
//boost::wregex re(L"?:([ ]{2,})|(.+)");//(L"(\\w+)");
//std::list<std::wstring> result;
////boost::match_results<std::wstring::const_iterator> result;
////bool b = boost::regex_match(text, result, re);
//std::wstring t = text;
//bool b = boost::regex_split(std::back_inserter(result),t, re);
//int res;
//int sz=0;
//for (std::list<std::wstring>::iterator i=result.begin(); i!=result.end(); ++i)
//{
// office_element_ptr elm;
// text = *i;
// sz = text.length();
// if (res = text.find(L" "))
// {
// add_text_space(sz);
// }
// else
// current_level_.back().elm->add_text(text);
//}
//std::string expression = "1a234bc43";
boost::wregex re(L"[ ]{2,}");
boost::wsregex_iterator i(
text.begin (),
text.end (),
re);
boost::wsregex_iterator j;
size_t pos=0;
for(; i!=j;++i)
{
std::wstring s = text.substr(pos, (*i).position()-pos);
if (s.length() > 0)current_level_.back().elm->add_text(s);
std::wstringstream s1;
s1 << (*i);
s= s1.str();
if (s.length() >0)
add_text_space(s.length());
pos = (*i).position() + s.length();
}
std::wstring last = text.substr(pos);
if (last.length() > 0)current_level_.back().elm->add_text(last);
}
void odf_text_context::add_text_space(int count)
{
office_element_ptr s_elm;
create_element(L"text", L"s", s_elm, odf_context_);
text_s* s = dynamic_cast<text_s*>(s_elm.get());
if (s)s->text_c_ = count;
// ..
//int level = current_level_.size();
//odf_element_state state={ s_elm, L"", office_element_ptr(), level};
//text_elements_list_.push_back(state);
if (current_level_.size()>0)
current_level_.back().elm->add_child_element(s_elm);
}
void odf_text_context::set_symbol_font(std::wstring & font)
{
......
......@@ -34,7 +34,10 @@ public:
void add_text_style(office_element_ptr & style_elm, std::wstring style_name);
void set_single_object(bool val, style_paragraph_properties *para_props, style_text_properties *text_props);
void add_text_content(const std::wstring & text);
void add_text_content(std::wstring & text);
void add_text_space(int count);
void set_symbol_font(std::wstring & font);
void set_symbol_text(int sym);
......
......@@ -7,14 +7,12 @@
#include <cpdoccore/CPWeakPtr.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/attributes.h>
//#include <cpdoccore/common/readdocelement.h>
//#include <cpdoccore/common/writedocelement.h>
#include <cpdoccore/CPAssert.h>
#include "office_elements_type.h"
#include "visitor.h"
//#include "..\conversionelement.h"
namespace cpdoccore {
namespace odf {
......
......@@ -1125,15 +1125,16 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf::style_tex
{
if (oox_run_pr->m_oRFonts->m_sAscii.IsInit())
text_properties->content().fo_font_family_ = string2std_string(oox_run_pr->m_oRFonts->m_sAscii.get());
else convert(oox_run_pr->m_oRFonts->m_oAsciiTheme.GetPointer(), text_properties->content().fo_font_family_);
if (oox_run_pr->m_oRFonts->m_sCs.IsInit())
text_properties->content().style_font_family_complex_ = string2std_string(oox_run_pr->m_oRFonts->m_sCs.get());
else convert(oox_run_pr->m_oRFonts->m_oCsTheme.GetPointer(), text_properties->content().style_font_family_complex_);
if (oox_run_pr->m_oRFonts->m_sEastAsia.IsInit())
text_properties->content().style_font_family_asian_= string2std_string(oox_run_pr->m_oRFonts->m_sEastAsia.get());
//nullable<CString > m_sAscii;
//nullable<SimpleTypes::CTheme<>> m_oAsciiTheme;
//nullable<SimpleTypes::CTheme<>> m_oCsTheme;
//nullable<CString > m_sEastAsia;
//nullable<SimpleTypes::CTheme<>> m_oEastAsiaTheme;
else convert(oox_run_pr->m_oRFonts->m_oEastAsiaTheme.GetPointer(), text_properties->content().style_font_family_asian_);
//nullable<CString > m_sHAnsi;
//nullable<SimpleTypes::CTheme<>> m_oHAnsiTheme;
//nullable<SimpleTypes::CHint<> > m_oHint;
......@@ -1186,10 +1187,77 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf::style_tex
}
}
void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::wstring) & odf_font_name)
{
if (oox_font_theme == NULL) return;
OOX::CTheme * docx_theme= docx_document->GetTheme();
if (docx_theme == NULL) return;
std::wstring font;
switch(oox_font_theme->GetValue())
{
case SimpleTypes::themeMajorAscii:
case SimpleTypes::themeMajorHAnsi :
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace.IsInit())
{
font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oLatin.m_oTypeFace->GetValue());
if (font.length() > 0) odf_font_name = font;
}
break;
case SimpleTypes::themeMajorBidi:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace.IsInit())
{
font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oCs.m_oTypeFace->GetValue());
if (font.length() > 0) odf_font_name = font;
}
break;
case SimpleTypes::themeMajorEastAsia:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace.IsInit())
{
font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMajorFont.m_oEa.m_oTypeFace->GetValue());
if (font.length() > 0) odf_font_name = font;
}
break;
case SimpleTypes::themeMinorAscii:
case SimpleTypes::themeMinorHAnsi:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace.IsInit())
{
font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oLatin.m_oTypeFace->GetValue());
if (font.length() > 0) odf_font_name = font;
}
break;
case SimpleTypes::themeMinorBidi:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace.IsInit())
{
font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oCs.m_oTypeFace->GetValue());
if (font.length() > 0) odf_font_name = font;
}
break;
case SimpleTypes::themeMinorEastAsia:
if (docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace.IsInit())
{
font = string2std_string(docx_theme->m_oThemeElements.m_oFontScheme.m_oMinorFont.m_oEa.m_oTypeFace->GetValue());
if (font.length() > 0) odf_font_name = font;
}
break;
}
}
void DocxConverter::convert(OOX::Logic::CText *oox_text)
{
if (oox_text == NULL) return;
if (oox_text->m_oSpace.IsInit())
{
if (oox_text->m_oSpace->GetValue() == SimpleTypes::xmlspacePreserve)
{
}
//odt_context->text_context()->add_text_space(26);
}
odt_context->add_text_content(string2std_string(oox_text->m_sText));
}
void DocxConverter::convert(OOX::Logic::CAlternateContent *oox_alt_content)
......@@ -1755,9 +1823,20 @@ void DocxConverter::convert(OOX::CDocDefaults *def_style)
odt_context->styles_context()->create_default_style(odf::style_family::Paragraph);
odf::style_paragraph_properties * paragraph_properties = odt_context->styles_context()->last_state().get_paragraph_properties();
convert(def_style->m_oParPr.GetPointer(), paragraph_properties/*, text_properties*/);
convert(def_style->m_oParPr.GetPointer(), paragraph_properties);
if (def_style->m_oParPr->m_oRPr.IsInit())
{
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
convert(def_style->m_oParPr->m_oRPr.GetPointer(), text_properties);
}
else if (def_style->m_oRunPr.IsInit())
{
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
convert(def_style->m_oRunPr.GetPointer(), text_properties);
}
}
if (def_style->m_oRunPr.IsInit())
else if (def_style->m_oRunPr.IsInit())
{
odt_context->styles_context()->create_default_style(odf::style_family::Text);
odf::style_text_properties * text_properties = odt_context->styles_context()->last_state().get_text_properties();
......
......@@ -133,6 +133,7 @@ namespace Oox2Odf
void convert(OOX::Drawing::CChart *oox_chart);
void convert(OOX::Drawing::CPicture *oox_picture);
void convert(SimpleTypes::CTheme<> *oox_font_theme,_CP_OPT(std::wstring) & odf_font_name);
void convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf::color) & odf_color);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length) & odf_size);
void convert(SimpleTypes::CUniversalMeasure *oox_size, _CP_OPT(odf::length_or_percent) & odf_size);
......
......@@ -2,6 +2,6 @@
//1
//2
//0
//101
#define INTVER 1,2,0,101
#define STRVER "1,2,0,101\0"
//103
#define INTVER 1,2,0,103
#define STRVER "1,2,0,103\0"
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