Compare commits

..

5 Commits

Author SHA1 Message Date
421e58fe34 x2t - 2.4.541 fix after testing 2018-08-01 12:51:13 +03:00
048cac74b6 . 2018-07-30 18:28:40 +03:00
c23ff4c8cd OdfFormatReader - fix after testing.
x2t - version up 2.4.540
2018-07-27 12:59:44 +03:00
ccc27a2e1b x2t - fix after testing 2018-07-26 19:06:06 +03:00
3843f52601 XlsFormat - fix user file 2018-07-26 15:17:54 +03:00
43 changed files with 837 additions and 289 deletions

View File

@ -104,7 +104,7 @@ OleObject::OleObject( const CharacterPropertyExceptions* chpx, WordDocument* doc
szData = szData >> 16;
}
unsigned char* bytes = reader.ReadBytes( szData, true );
if (bytes)
if (bytes && szData < 0xffff)
{
emeddedData = std::string((char*)bytes, szData);
delete []bytes;

View File

@ -32,7 +32,6 @@
#include "formulasconvert.h"
#include <boost/regex.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string.hpp>
#include"../../Common/DocxFormat/Source/XML/Utils.h"
@ -306,9 +305,9 @@ std::wstring forbidden_formulas1[] =
bool is_forbidden1(const std::wstring & formula)
{
BOOST_FOREACH(const std::wstring & s, forbidden_formulas1)
{
if (boost::algorithm::contains(formula, s))
for (size_t i = 0; i < 1; i++)
{
if (boost::algorithm::contains(formula, forbidden_formulas1[i]))
return true;
}
return false;
@ -669,9 +668,10 @@ size_t getColAddressInv(const std::wstring & a_)
size_t mul = 1;
bool f = true;
size_t res = 0;
BOOST_REVERSE_FOREACH(const wchar_t c, a)
for (int i = a.length() - 1; i >= 0; i--)
{
size_t v = c - L'A';
size_t v = a[i] - L'A';
if (f)
f = false;
else
@ -700,14 +700,13 @@ void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring
::XmlUtils::replace_all( a, L"$", L"");
//::XmlUtils::replace_all( a, L"'", L"");
::boost::algorithm::to_upper(a);
BOOST_FOREACH(wchar_t c, a)
for (size_t i = 0; i < a.length(); i++)
{
if (c >= L'0' && c <= L'9')
row +=c;
if (a[i] >= L'0' && a[i] <= L'9')
row += a[i];
else
col += c;
col += a[i];
}
std::reverse(col.begin(), col.end());
std::reverse(row.begin(), row.end());

View File

@ -52,8 +52,10 @@ enum ElementType
typeTextReferenceMarkEnd,
typeTextReferenceRef,
typeTextFieldFieldmarkStart,
typeTextFieldFieldmarkEnd,
typeFieldFieldmarkStart,
typeFieldFieldmarkEnd,
typeFieldFieldmark,
typeFieldParam,
typeTextSpan,
typeTextA,
@ -501,6 +503,7 @@ enum ElementType
typeFormTextarea,
typeFormTime,
typeFormValueRange,
typeFormItem,
typeDrawPage,
typePresentationFooterDecl,

View File

@ -45,7 +45,7 @@ namespace utils {
std::wstring replace_xml_to_text_ImplRegEx(const std::wstring & Text);
std::string replace_xml_to_text_ImplRegEx(const std::string & Text);
std::wstring replace_text_to_xml_ImplReplace(const std::wstring & Text);
std::wstring replace_text_to_xml_ImplReplace(const std::wstring & Text, bool dDeleteUnicode = false);
std::string replace_text_to_xml_ImplReplace(const std::string & Text);
std::wstring replace_amp_text_to_xml_ImplReplace(const std::wstring & Text);
@ -55,7 +55,7 @@ namespace utils {
std::string replace_xml_to_text_ImplReplace(const std::string & Text);
}
std::wstring replace_text_to_xml(const std::wstring & Text);
std::wstring replace_text_to_xml(const std::wstring & Text, bool dDeleteUnicode = false);
std::string replace_text_to_xml(const std::string & Text);
std::wstring replace_amp_text_to_xml(const std::wstring & Text);

View File

@ -31,7 +31,6 @@
*/
#include <string>
#include <boost/foreach.hpp>
#include <cmath>
#include <boost/optional/optional_io.hpp>
@ -78,14 +77,13 @@ std::wstring RGBToString(int r, int g, int b)
color v(r, g, b);
double minDist = (std::numeric_limits<double>::max)();
BOOST_FOREACH(color const & c, colors)
for (size_t i = 0; i < 6; i++)
{
double dist = color_dist(v, c);
double dist = color_dist(v, colors[i]);
if (dist < minDist)
{
minDist = dist;
result = c.name_;
result = colors[i].name_;
}
}

View File

@ -30,9 +30,6 @@
*
*/
#include <boost/foreach.hpp>
#include <iostream>
#include <xml/utils.h>
@ -443,21 +440,7 @@ void docx_conversion_context::start_index_content()
sInstrText += L" \\c \"" + table_content_context_.caption_sequence_name + L"\"";
}
}
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"begin\"/>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:instrText xml:space=\"preserve\">" << sInstrText << L" </w:instrText>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
//output_stream() << L"<w:rPr>
//output_stream() << L"<w:rFonts w:ascii="Minion Pro" w:eastAsia="DejaVuSans" w:hAnsi="Minion Pro"/>
//output_stream() << L"<w:bCs w:val="0"/>
//output_stream() << L"<w:sz w:val="21"/>
//output_stream() << L"<w:szCs w:val="24"/>
//output_stream() << L"</w:rPr>
output_stream() << L"<w:fldChar w:fldCharType=\"separate\"/>";
output_stream() << L"</w:r>";
start_field(sInstrText, L"");
finish_paragraph();
}
@ -466,15 +449,38 @@ void docx_conversion_context::end_index_content()
if (!in_table_content_) return;
start_paragraph(false);
end_field();
finish_paragraph();
}
void docx_conversion_context::start_field(const std::wstring & sInstrText, const std::wstring & sName)
{
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"begin\">";
if (!sName.empty())
{
output_stream() << L"<w:ffData><w:name w:val=\"" << sName << L"\"/><w:enabled/><w:calcOnExit w:val=\"0\"/></w:ffData>";
}
output_stream() << L"</w:fldChar>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:instrText xml:space=\"preserve\">" << sInstrText << L" </w:instrText>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"separate\"/>";
output_stream() << L"</w:r>";
}
void docx_conversion_context::end_field()
{
output_stream() << L"<w:r>";
//output_stream() << L"<w:rPr>";
//output_stream() << L"<w:rFonts w:ascii="Minion Pro" w:hAnsi="Minion Pro"/>";
//output_stream() << L"<w:sz w:val="20"/>
//output_stream() << L"</w:rPr>";
output_stream() << L"<w:fldChar w:fldCharType=\"end\"/>";
output_stream() << L"</w:r>";
finish_paragraph();
output_stream() << L"</w:r>";
}
void docx_conversion_context::end_sdt()
{
@ -917,21 +923,23 @@ xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"
mc:Ignorable=\"w14 wp14\">";
std::vector<int> numIds;
BOOST_FOREACH(odf_reader::list_style_instance_ptr & inst, list_styles.instances())
{
odf_reader::office_element_ptr_array & content = inst->get_text_list_style()->get_content();
odf_reader::list_style_container::instances_array & arListStyles = list_styles.instances();
for (size_t i = 0; i < arListStyles.size(); i++)
{
odf_reader::office_element_ptr_array & content = arListStyles[i]->get_text_list_style()->get_content();
if (content.size() < 1)
continue;
const int abstractNumId = list_styles.id_by_name(inst->get_style_name());
const int abstractNumId = list_styles.id_by_name(arListStyles[i]->get_style_name());
strm << L"<w:abstractNum w:abstractNumId=\"" << abstractNumId << "\">";
numIds.push_back(abstractNumId);
for (size_t i = 0; i < (std::min)( content.size(), (size_t)9); i++)
{
start_text_list_style(inst->get_text_list_style()->get_style_name());
start_text_list_style(arListStyles[i]->get_text_list_style()->get_style_name());
content[i]->docx_convert(*this);
// TODO
end_text_list_style();
@ -963,21 +971,25 @@ void docx_conversion_context::process_fonts()
odf_reader::odf_read_context & context = doc->odf_context();
odf_reader::fonts_container & fonts = context.fontContainer();
BOOST_FOREACH(odf_reader::font_instance_ptr & inst, fonts.instances())
odf_reader::fonts_container::instances_array &arFonts = fonts.instances();
for (size_t i = 0; i < arFonts.size(); i++)
{
strm << L"<w:font w:name=\"" << inst->name() << L"\" >";
if (!arFonts[i]) continue;
if (arFonts[i]->name().empty()) continue;
if (!inst->charset().empty())
strm << L"<w:charset w:val=\"" << inst->charset() <<"\" />";
strm << L"<w:font w:name=\"" << arFonts[i]->name() << L"\" >";
if (!inst->family().empty())
strm << L"<w:family w:val=\"" << inst->family() << "\" />";
if (!arFonts[i]->charset().empty())
strm << L"<w:charset w:val=\"" << arFonts[i]->charset() <<"\" />";
if (!inst->pitch().empty())
strm << L"<w:pitch w:val=\"" << inst->pitch() << "\" />";
if (!arFonts[i]->family().empty())
strm << L"<w:family w:val=\"" << arFonts[i]->family() << "\" />";
if (!inst->alt_name().empty())
strm << L"<w:altName w:val=\"" << inst->alt_name() << "\" />";
if (!arFonts[i]->pitch().empty())
strm << L"<w:pitch w:val=\"" << arFonts[i]->pitch() << "\" />";
if (!arFonts[i]->alt_name().empty())
strm << L"<w:altName w:val=\"" << arFonts[i]->alt_name() << "\" />";
strm << L"</w:font>";
}
@ -1008,9 +1020,11 @@ void docx_conversion_context::process_styles()
odf_reader::styles_container & styles = context.styleContainer();
// add all styles to the map
BOOST_FOREACH(odf_reader::style_instance_ptr & inst, styles.instances())
odf_reader::styles_container::instances_array &arStyles = styles.instances();
for (size_t i = 0; i < arStyles.size(); i++)
{
styles_map_.get(inst->name(), inst->type());
if (!arStyles[i]) continue;
styles_map_.get(arStyles[i]->name(), arStyles[i]->type());
}
_Wostream << L"<w:docDefaults>";
@ -1029,51 +1043,51 @@ void docx_conversion_context::process_styles()
_Wostream << L"</w:docDefaults>";
BOOST_FOREACH(odf_reader::style_instance_ptr & inst, styles.instances())
{
if (!inst->is_automatic() &&
for (size_t i = 0; i < arStyles.size(); i++)
{
if (!arStyles[i]->is_automatic() &&
(
inst->type() == odf_types::style_family::Paragraph ||
inst->type() == odf_types::style_family::Text
arStyles[i]->type() == odf_types::style_family::Paragraph ||
arStyles[i]->type() == odf_types::style_family::Text
))
{
const std::wstring id = styles_map_.get(inst->name(), inst->type());
_Wostream << L"<w:style w:styleId=\"" << id << L"\" w:type=\"" << StyleTypeOdf2Docx(inst->type()) << L"\"";
if (!inst->is_default())
const std::wstring id = styles_map_.get(arStyles[i]->name(), arStyles[i]->type());
_Wostream << L"<w:style w:styleId=\"" << id << L"\" w:type=\"" << StyleTypeOdf2Docx(arStyles[i]->type()) << L"\"";
if (!arStyles[i]->is_default())
{
_Wostream << L" w:customStyle=\"1\"";
}
_Wostream << L">";
const std::wstring displayName = StyleDisplayName(inst->name(), inst->type());
const std::wstring displayName = StyleDisplayName(arStyles[i]->name(), arStyles[i]->type());
_Wostream << L"<w:name w:val=\"" << displayName << L"\" />";
if (odf_reader::style_instance * baseOn = inst->parent())
if (odf_reader::style_instance * baseOn = arStyles[i]->parent())
{
const std::wstring basedOnId = styles_map_.get(baseOn->name(), baseOn->type());
_Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />";
}
else if (!inst->is_default() && styles_map_.check(L"", inst->type()))
else if (!arStyles[i]->is_default() && styles_map_.check(L"", arStyles[i]->type()))
{
const std::wstring basedOnId = styles_map_.get(L"", inst->type());
const std::wstring basedOnId = styles_map_.get(L"", arStyles[i]->type());
_Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />";
}
if (odf_reader::style_instance * next = inst->next())
if (odf_reader::style_instance * next = arStyles[i]->next())
{
const std::wstring nextId = styles_map_.get(next->name(), next->type());
_Wostream << L"<w:next w:val=\"" << nextId << "\" />";
}
else if (inst->is_default())
else if (arStyles[i]->is_default())
{
// self
_Wostream << L"<w:next w:val=\"" << id << "\" />";
}
if (odf_reader::style_content * content = inst->content())
if (odf_reader::style_content * content = arStyles[i]->content())
{
get_styles_context().start_process_style(inst.get());
get_styles_context().start_process_style(arStyles[i].get());
content->docx_convert(*this, true);
get_styles_context().end_process_style();
}
@ -1334,10 +1348,11 @@ void docx_conversion_context::pop_text_properties()
odf_reader::style_text_properties_ptr docx_conversion_context::current_text_properties()
{
odf_reader::style_text_properties_ptr cur = boost::make_shared<odf_reader::style_text_properties>();
BOOST_FOREACH(const odf_reader::style_text_properties * prop, text_properties_stack_)
for (size_t i = 0; i < text_properties_stack_.size(); i++)
{
if (prop)
cur->content().apply_from( prop->content() );
if (text_properties_stack_[i])
cur->content().apply_from( text_properties_stack_[i]->content() );
}
return cur;
}
@ -1754,10 +1769,7 @@ namespace
{
// обработка Header/Footer
// конвертируем содержимое header/footer и сохраняем результат в виде строки
void process_one_header_footer(docx_conversion_context & Context,
const std::wstring & styleName,
odf_reader::office_element * elm,
headers_footers::Type type)
void process_one_header_footer(docx_conversion_context & Context, const std::wstring & styleName, odf_reader::office_element *elm, headers_footers::Type type)
{
if (!elm) return;
@ -1775,13 +1787,7 @@ namespace
Context.dump_hyperlinks(internal_rels, hyperlinks::document_place);
Context.get_headers_footers().add(styleName, dbgStr, type, internal_rels);
if (type == headers_footers::headerLeft || type == headers_footers::footerLeft)
{
Context.set_settings_property(odf_reader::_property(L"evenAndOddHeaders",true));
}
}
}
}
void docx_conversion_context::set_settings_property(const odf_reader::_property & prop)
{
@ -1803,21 +1809,39 @@ void docx_conversion_context::process_headers_footers()
odf_reader::page_layout_container & pageLayouts = context.pageLayoutContainer();
// проходим по всем page layout
BOOST_FOREACH(const odf_reader::style_master_page* page, pageLayouts.master_pages())
{
const std::wstring & styleName = page->attlist_.style_name_.get_value_or( L"" );
const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName);
add_page_properties(masterPageNameLayout);
process_one_header_footer(*this, styleName, page->style_header_.get(), headers_footers::header);
process_one_header_footer(*this, styleName, page->style_footer_.get(), headers_footers::footer );
process_one_header_footer(*this, styleName, page->style_header_first_.get(), headers_footers::headerFirst);
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 );
std::vector<odf_reader::style_master_page*> & master_pages = pageLayouts.master_pages();
if (!page->style_header_ && !page->style_footer_ && !page->style_header_first_ && !page->style_footer_first_
&& !page->style_header_left_ && !page->style_footer_left_)
bool bOddEvenPages = false;
for (size_t i = 0; i < master_pages.size(); i++)
{
if (master_pages[i]->style_header_left_ || master_pages[i]->style_footer_left_)
bOddEvenPages = true;
}
if (bOddEvenPages)
{
set_settings_property(odf_reader::_property(L"evenAndOddHeaders", true));
}
for (size_t i = 0; i < master_pages.size(); i++)
{
const std::wstring & styleName = master_pages[i]->attlist_.style_name_.get_value_or( L"" );
const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName);
add_page_properties(masterPageNameLayout);
process_one_header_footer(*this, styleName, master_pages[i]->style_header_.get(), headers_footers::header);
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_.get(), headers_footers::footer );
process_one_header_footer(*this, styleName, master_pages[i]->style_header_first_.get(), headers_footers::headerFirst);
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_first_.get(), headers_footers::footerFirst );
process_one_header_footer(*this, styleName, master_pages[i]->style_header_left_.get(), headers_footers::headerLeft );
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_left_.get(), headers_footers::footerLeft );
if (bOddEvenPages && !master_pages[i]->style_header_left_)
process_one_header_footer(*this, styleName, master_pages[i]->style_header_.get(), headers_footers::headerLeft);
if (bOddEvenPages && !master_pages[i]->style_footer_left_)
process_one_header_footer(*this, styleName, master_pages[i]->style_footer_.get(), headers_footers::footerLeft );
if (!master_pages[i]->style_header_ && !master_pages[i]->style_footer_ && !master_pages[i]->style_header_first_ && !master_pages[i]->style_footer_first_
&& !master_pages[i]->style_header_left_ && !master_pages[i]->style_footer_left_)
{
//отключенные колонтитулы
rels rels_;

View File

@ -842,8 +842,8 @@ public:
void start_body ();
void end_body ();
void start_office_text ();
void end_office_text ();
void start_office_text ();
void end_office_text ();
void start_sdt (int type);
void end_sdt ();
@ -854,6 +854,9 @@ public:
void start_index_element();
void end_index_element();
void start_field(const std::wstring & sInstrText, const std::wstring & sName);
void end_field();
void process_styles ();
void process_fonts ();

View File

@ -94,8 +94,16 @@ std::wstring docx_table_state::current_row_style() const
double docx_table_state::get_current_cell_width()
{
if (current_table_column_ < columns_width_.size())
return columns_width_[current_table_column_];
if (current_table_column_ + columns_spanned_num_ < columns_width_.size())
{
//return columns_width_[current_table_column_];
double res = 0;
for (int i = 0; i < columns_spanned_num_ + 1; i++)
{
res += columns_width_[current_table_column_ + i];
}
return res;
}
else
return 0;
}

View File

@ -31,7 +31,6 @@
*/
#include "headers_footers.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
namespace cpdoccore {
@ -88,12 +87,12 @@ std::wstring get_rel_type(headers_footers::Type _Type)
void headers_footers::dump_rels(rels & Rels) const//внешние релсы
{
BOOST_FOREACH(const instances_map::value_type & instAr, instances_)
for (boost::unordered_map<std::wstring, instances_array>::const_iterator it = instances_.begin(); it != instances_.end(); ++it)
{
BOOST_FOREACH(const instance_ptr & inst, instAr.second)
for (size_t i = 0; i < it->second.size(); i++)
{
if (inst->type_ == none) continue;
Rels.add( relationship( inst->id_, get_rel_type(inst->type_), inst->name_, L"" ) );
if (it->second[i]->type_ == none) continue;
Rels.add( relationship( it->second[i]->id_, get_rel_type(it->second[i]->type_), it->second[i]->name_, L"" ) );
}
}
}
@ -107,9 +106,13 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_pag
bool first = false, left = false;
bool res = false;
instances_array & pFind = instances_.at(StyleName);
BOOST_FOREACH(const instance_ptr & inst, instances_.at(StyleName))
for (size_t i = 0; i < pFind.size(); i++)
{
instance_ptr & inst = pFind[i];
std::wstring type = L"default";
if ( inst->type_ == headerFirst || inst->type_ == footerFirst )

View File

@ -317,8 +317,8 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
if ((iWrap) && (*iWrap == 0)) CP_XML_ATTR(L"wrap", L"none");
}
_CP_OPT(int) iAlign;
odf_reader::GetProperty(prop,L"textarea-vertical_align",iAlign);
_CP_OPT(int) iAlign, iVert;
odf_reader::GetProperty(prop, L"textarea-vertical_align", iAlign);
if (iAlign)
{
switch (iAlign.get())
@ -336,6 +336,16 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
CP_XML_ATTR(L"anchor", L"just");break;
}
}
odf_reader::GetProperty(prop, L"text_vert", iVert);
if (iVert)
{
switch (iVert.get())
{
case 1: CP_XML_ATTR(L"vert", L"vert"); break;
case 2: CP_XML_ATTR(L"vert", L"vert270"); break;
}
}
_CP_OPT(bool) bAutoGrowHeight;
_CP_OPT(bool) bFitToSize;
odf_reader::GetProperty(prop,L"fit-to-size", bFitToSize);
@ -357,7 +367,7 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
if (bWordArt)
{
_CP_OPT(int) iVal;
odf_reader::GetProperty(prop, L"odf-custom-draw-index",iVal);
odf_reader::GetProperty(prop, L"oox-geom-index", iVal);
if (iVal)
{
std::wstring shapeType = _OO_OOX_wordart[*iVal].oox;

View File

@ -32,7 +32,6 @@
#include "xlsx_borders.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <boost/unordered_set.hpp>
#include <xml/simple_xml_writer.h>
@ -203,9 +202,9 @@ public:
{
std::vector<xlsx_border> inst_array;
BOOST_FOREACH(const xlsx_border & inst, borders_)
for (boost::unordered_set<xlsx_border, boost::hash<xlsx_border>>::iterator it = borders_.begin(); it != borders_.end(); ++it)
{
inst_array.push_back(inst);
inst_array.push_back(*it);
}
std::sort(inst_array.begin(), inst_array.end(), compare_());
@ -215,9 +214,10 @@ public:
CP_XML_NODE(L"borders")
{
CP_XML_ATTR(L"count", inst_array.size());
BOOST_FOREACH( xlsx_border & border, inst_array)
for (size_t i = 0; i < inst_array.size(); i++)
{
cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), border);
cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), inst_array[i]);
}
}
}

View File

@ -34,7 +34,6 @@
#include <xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <boost/unordered_set.hpp>
@ -155,10 +154,10 @@ struct compare_xlsx_fills
void xlsx_fills::serialize(std::wostream & _Wostream) const
{
std::vector<xlsx_fill> inst_array;
BOOST_FOREACH(const xlsx_fill & inst, impl_->fills_)
{
inst_array.push_back(inst);
for (boost::unordered_set<xlsx_fill, boost::hash<xlsx_fill>>::iterator it = impl_->fills_.begin(); it != impl_->fills_.end(); ++it)
{
inst_array.push_back(*it);
}
std::sort(inst_array.begin(), inst_array.end(), compare_xlsx_fills());
@ -169,7 +168,7 @@ void xlsx_fills::serialize(std::wostream & _Wostream) const
{
CP_XML_ATTR(L"count", inst_array.size());
for (int i = 0; i < inst_array.size(); i++)
for (size_t i = 0; i < inst_array.size(); i++)
{
xlsx_serialize(CP_XML_STREAM(), inst_array[i]);
}

View File

@ -35,7 +35,6 @@
#include <xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <boost/unordered_set.hpp>
@ -79,9 +78,9 @@ void xlsx_fonts::Impl::serialize(std::wostream & _Wostream) const
{
std::vector<xlsx_font> fonts;
BOOST_FOREACH(const xlsx_font & fnt, fonts_)
for (boost::unordered_set<xlsx_font, boost::hash<xlsx_font>>::iterator it = fonts_.begin(); it != fonts_.end(); ++it)
{
fonts.push_back(fnt);
fonts.push_back(*it);
}
std::sort(fonts.begin(), fonts.end(), compare_xlsx_fonts());
@ -91,6 +90,7 @@ void xlsx_fonts::Impl::serialize(std::wostream & _Wostream) const
CP_XML_NODE(L"fonts")
{
CP_XML_ATTR(L"count", fonts.size());
for (size_t i = 0; i < fonts.size(); ++i)
{
xlsx_serialize(CP_XML_STREAM(), fonts[i]);

View File

@ -423,6 +423,8 @@ void xlsx_pivots_context::Impl::sort_fields()
bool bAddRepeateRow = false;
bool bAddRepeateCol = false;
bool bShowEmptyCol = true;
bool bShowEmptyRow = true;
int count_items_col = -1, count_items_row = -1;
@ -480,30 +482,15 @@ void xlsx_pivots_context::Impl::sort_fields()
if (count_items_col != current_.fields[i].caches.size())
bAddRepeateCol = true;
}
if (!current_.fields[i].show_empty || !current_.fields[i].repeat_item_labels )
bShowEmptyCol = false;
}
else if (current_.fields[i].name_enabled)
{
count_items_col = 0;
bAddRepeateCol = true; //add col axis
}
//if (current_.fields[i].data_layout)
//{
// bAddRepeateCol = false;
// if ((current_.fields[i].name.empty() && (!current_.identify_categories || current_.fields[i].hierarchy >= 0)) ||
// current_.fields[i].used_in_referenes )
// {
// if ((current_.col_fields.empty()) || (current_.col_fields.back() != -2))
// {
// bAddRepeateCol = true;
// }
// }
//}
//if (current_.fields[i].caches.empty())
// bEmptyColCache = true;
}break;
case 1: // data
{
@ -553,10 +540,20 @@ void xlsx_pivots_context::Impl::sort_fields()
}
else
{
if (count_items_row != current_.fields[i].caches.size())
if (count_items_row < current_.fields[i].caches.size())
bAddRepeateRow = true;
}
}
else if (current_.fields[i].name_enabled)
{
count_items_row = 0;
bAddRepeateRow = true; //add row axis
}
if (!current_.fields[i].show_empty)
bShowEmptyRow = false;
if (!current_.fields[i].repeat_item_labels)
bAddRepeateCol = false;
if (current_.fields[i].data_layout)
{
@ -581,10 +578,10 @@ void xlsx_pivots_context::Impl::sort_fields()
i--;
}
}
if (bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol)) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
if ((bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol))/* && bShowEmptyCol*/) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
current_.col_fields.push_back(-2);
if (bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))/* && bShowEmptyRow*/)
current_.row_fields.push_back(-2);
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)

View File

@ -30,7 +30,6 @@
*
*/
#include <boost/foreach.hpp>
#include "../odf/style_text_properties.h"
#include "../odf/style_paragraph_properties.h"
@ -223,11 +222,11 @@ namespace
void xlsx_style_manager::Impl::serialize_xf(std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName)
{
std::vector<xlsx_xf> xfs_;
BOOST_FOREACH(const xlsx_xf & xfRecord, xfArray)
{
xfs_.push_back(xfRecord);
}
for (boost::unordered_set<xlsx_xf, boost::hash<xlsx_xf>>::iterator it = xfArray.begin(); it != xfArray.end(); ++it)
{
xfs_.push_back(*it);
}
std::sort(xfs_.begin(), xfs_.end(), compare_xlsx_xf());

View File

@ -33,7 +33,6 @@
#include "xlsx_utils.h"
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
@ -90,14 +89,15 @@ std::wstring getCellAddress(size_t col, size_t row)
size_t getColAddressInv(const std::wstring & a_)
{
std::wstring a = a_;
::boost::algorithm::to_upper(a);
boost::algorithm::to_upper(a);
static const size_t r = (L'Z' - L'A' + 1);
size_t mul = 1;
bool f = true;
size_t res = 0;
BOOST_REVERSE_FOREACH(const wchar_t c, a)
{
size_t v = c - L'A';
for (int i = a.length() - 1; i >= 0; i--)
{
size_t v = a[i] - L'A';
if (f)
f = false;
else
@ -129,13 +129,12 @@ void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring
boost::algorithm::to_upper(a);
BOOST_FOREACH(wchar_t c, a)
{
if (c >= L'0' && c <= L'9')
row +=c;
for (size_t i = 0; i < a.length(); i++)
{
if (a[i] >= L'0' && a[i] <= L'9')
row += a[i];
else
col += c;
col += a[i];
}
std::reverse(col.begin(), col.end());
std::reverse(row.begin(), row.end());

View File

@ -201,8 +201,8 @@ style_table_cell_properties_attlist calc_table_cell_properties(const style_insta
std::vector<const style_table_cell_properties*> props;
while (styleInstance)
{
if (const style_content * content = styleInstance->content())
if (const style_table_cell_properties * prop = content->get_style_table_cell_properties())
if (style_content * content = styleInstance->content())
if (style_table_cell_properties * prop = content->get_style_table_cell_properties())
{
props.insert(props.begin(), prop);
}

View File

@ -29,8 +29,6 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <boost/foreach.hpp>
#include "../docx/xlsx_textcontext.h"
#include "../docx/xlsx_num_format_context.h"
@ -61,17 +59,17 @@ class office_element;
typedef shared_ptr<const office_element>::Type office_element_ptr_const;
#define ACCEPT_ALL_CONTENT(VAL) \
BOOST_FOREACH(office_element_ptr & elm, (VAL)) \
for (size_t ii = 0; ii < VAL.size(); ++ii) \
{ \
if (elm) \
elm->accept(*this); \
if (VAL[ii]) \
VAL[ii]->accept(*this); \
}
#define ACCEPT_ALL_CONTENT_CONST(VAL) \
BOOST_FOREACH(const office_element_ptr_const & elm, (VAL)) \
for (size_t ii = 0; ii < VAL.size(); ++ii) \
{ \
if (elm) \
elm->accept(*this); \
if (VAL[ii]) \
VAL[ii]->accept(*this); \
}

View File

@ -774,6 +774,20 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
if (defaultStyle)instances.push_back(defaultStyle);
}
else if (styleInst->content())
{
style_paragraph_properties *para_props = styleInst->content()->get_style_paragraph_properties();
if ((para_props) && (para_props->content_.style_writing_mode_))
{
switch(para_props->content_.style_writing_mode_->get_type())
{
case writing_mode::TbLr:
drawing->additional.push_back(odf_reader::_property(L"text_vert", 2)); break;
case writing_mode::TbRl:
drawing->additional.push_back(odf_reader::_property(L"text_vert", 1)); break;
}
}
}
instances.push_back(styleInst);
}
@ -870,7 +884,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
}
}
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)
{
@ -1232,7 +1246,7 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
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();
/////////
@ -1302,6 +1316,12 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
}
else if (auto_fit_text)
drawing->additional.push_back(_property(L"fit-to-size", auto_fit_text));
if (drawing->cx < 1 && drawing->cy < 1)
{
drawing->cx = 10;
drawing->cy = 10;
}
}
void draw_g::docx_convert(oox::docx_conversion_context & Context)
{
@ -1425,8 +1445,7 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().start_frame(this);
const _CP_OPT(std::wstring) name =
common_draw_attlists_.shape_with_text_and_styles_.
common_shape_draw_attlist_.draw_name_;
common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_name_;
Context.get_drawing_context().add_name_object(name.get_value_or(L"Object"));
@ -1654,6 +1673,11 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
oox::text_forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
if (state.id.empty()) return;
if ((state.type == 6 || state.type == 4) && state.element)
{
return state.element->docx_convert_sdt(Context, this);
}
Context.get_drawing_context().start_shape(NULL);
Context.get_drawing_context().add_name_object(state.name.empty() ? L"Control" : state.name);
@ -1706,7 +1730,7 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
Context.add_new_run(L"");
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
Context.output_stream() << xml::utils::replace_text_to_xml( text );
Context.output_stream() << xml::utils::replace_text_to_xml( text, true );
Context.output_stream() << L"</w:t>";
Context.finish_run();
}

View File

@ -37,7 +37,6 @@
#include <sstream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/regex.h>
#include <xml/xmlchar.h>
@ -438,9 +437,9 @@ int draw_enhanced_geometry::parsing(_CP_OPT(std::wstring) val)
int pos = 0, res = -1;
if (!val) return res;
BOOST_FOREACH(wchar_t c, val.get())
for (size_t i = 0; i < val->length(); i++)
{
if (c < L'0' && c > L'9')
if (val->at(i) < L'0' && val->at(i) > L'9')
return res;
}

View File

@ -32,7 +32,6 @@
#include "number_style.h"
#include <boost/foreach.hpp>
#include <odf/odf_document.h>
#include <xml/xmlchar.h>
@ -78,10 +77,10 @@ void number_style_base::oox_convert_impl(oox::num_format_context & Context)
}
}
BOOST_FOREACH(const office_element_ptr & elm, content_)
for (size_t i = 0; i < content_.size(); i++)
{
number_style_base *number_style_ = dynamic_cast<number_style_base *> (elm.get());
number_element *number_element_ = dynamic_cast<number_element *> (elm.get());
number_style_base *number_style_ = dynamic_cast<number_style_base *> (content_[i].get());
number_element *number_element_ = dynamic_cast<number_element *> (content_[i].get());
if (number_style_) number_style_->oox_convert(Context);
if (number_element_) number_element_->oox_convert(Context);
@ -93,9 +92,9 @@ void number_style_base::oox_convert(oox::num_format_context & Context)
{
if (!style_map_.empty())
{
BOOST_FOREACH(const office_element_ptr & elm, style_map_)
{
if (const style_map * styleMap = dynamic_cast<const style_map *>(elm.get()))
for (size_t i = 0; i < style_map_.size(); i++)
{
if (const style_map * styleMap = dynamic_cast<const style_map *>(style_map_[i].get()))
{
const std::wstring applyStyleName = styleMap->style_apply_style_name_;
const std::wstring condition = styleMap->style_condition_;
@ -309,12 +308,13 @@ void number_currency_symbol::add_text(const std::wstring & Text)
void number_currency_symbol::oox_convert(oox::num_format_context & Context)
{
std::wostream & strm = Context.output();
strm << L"[$";//xml::utils::replace_text_to_xml(L"\"");
BOOST_FOREACH(const std::wstring & t, text_)
strm << L"[$";
for (size_t i = 0; i < text_.size(); i++)
{
strm << xml::utils::replace_text_to_xml(t);
strm << xml::utils::replace_text_to_xml(text_[i]);
}
strm << L"]";;//xml::utils::replace_text_to_xml(L"\"");
strm << L"]";
}

View File

@ -71,7 +71,7 @@ style_instance::style_instance(
style_instance * styles_container::hyperlink_style()
{
if (hyperlink_style_pos_ > 0)
if (hyperlink_style_pos_ > 0 && hyperlink_style_pos_ < instances_.size())
return instances_[hyperlink_style_pos_].get();
else
return NULL;

View File

@ -75,14 +75,22 @@ public:
virtual void afterCreate()
{
if (context_ && this->get_type() != typeTextSection)
if (!context_) return;
ElementType type_ = this->get_type();
if (type_ != typeTextSection)
{
context_->level++;
}
}
virtual void afterReadContent()
{
if (context_ && this->get_type() != typeTextSection)
if (!context_) return;
ElementType type_ = this->get_type();
if (type_ != typeTextSection)
{
if (context_->level == 4)
{

View File

@ -406,12 +406,76 @@ void form_combobox::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
form_element::add_attributes(Attributes);
}
void form_combobox::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"form", L"item")
{
CP_CREATE_ELEMENT(items_);
}
else
{
form_element::add_child_element(Reader, Ns, Name);
}
}
void form_combobox::docx_convert(oox::docx_conversion_context & Context)
{
Context.get_forms_context().start_element(4);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::docx_convert(Context);
}
void form_combobox::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
{
Context.finish_run();
Context.output_stream() << L"<w:sdt>";
Context.output_stream() << L"<w:sdtPr>";
{
if (name_)
{
Context.output_stream() << L"<w:alias w:val=\"" + xml::utils::replace_text_to_xml(*name_) + L"\"/>";
}
Context.output_stream() << L"<w:id w:val=\"" + std::to_wstring(Context.get_drawing_context().get_current_shape_id()) + L"\"/>";
Context.output_stream() << L"<w:dropDownList>";
for (size_t i = 0; i < items_.size(); i++)
{
form_item* item = dynamic_cast<form_item*>(items_[i].get());
if (!item) continue;
Context.output_stream() << L"<w:listItem w:displayText=\"" << (item->text_.empty() ? item->label_ : item->text_);
Context.output_stream() << L"\" w:value=\"" << item->label_ << L"\"/>";
}
Context.output_stream() << L"</w:dropDownList>";
}
Context.output_stream() << L"</w:sdtPr>";
Context.output_stream() << L"<w:sdtContent>";
{
Context.add_new_run(L"");
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
if (current_value_)
{
Context.output_stream() << xml::utils::replace_text_to_xml(*current_value_ );
}
Context.output_stream() << L"</w:t>";
Context.finish_run();
}
Context.output_stream() << L"</w:sdtContent>";
Context.output_stream() << L"</w:sdt>";
if (label_)
{
Context.add_new_run(L"");
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
Context.output_stream() << xml::utils::replace_text_to_xml(*label_ );
Context.output_stream() << L"</w:t>";
Context.finish_run();
}
}
// form:listbox
//----------------------------------------------------------------------------------
const wchar_t * form_listbox::ns = L"form";
@ -427,5 +491,83 @@ void form_listbox::docx_convert(oox::docx_conversion_context & Context)
form_element::docx_convert(Context);
}
// form:button
//----------------------------------------------------------------------------------
const wchar_t * form_date::ns = L"form";
const wchar_t * form_date::name = L"date";
void form_date::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
form_element::add_attributes(Attributes);
}
void form_date::docx_convert(oox::docx_conversion_context & Context)
{
Context.get_forms_context().start_element(6);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::docx_convert(Context);
}
void form_date::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
{
Context.finish_run();
Context.output_stream() << L"<w:sdt>";
Context.output_stream() << L"<w:sdtPr>";
{
if (name_)
{
Context.output_stream() << L"<w:alias w:val=\"" + xml::utils::replace_text_to_xml(*name_) + L"\"/>";
}
Context.output_stream() << L"<w:id w:val=\"" + std::to_wstring(Context.get_drawing_context().get_current_shape_id()) + L"\"/>";
Context.output_stream() << L"<w:date>";
Context.output_stream() << L"<w:dateFormat w:val=\"\"/>";
Context.output_stream() << L"<w:lid w:val=\"en-US\"/>";
Context.output_stream() << L"<w:storeMappedDataAs w:val=\"dateTime\"/>";
Context.output_stream() << L"<w:calendar w:val=\"gregorian\"/>";
Context.output_stream() << L"</w:date>";
}
Context.output_stream() << L"</w:sdtPr>";
Context.output_stream() << L"<w:sdtContent>";
{
Context.add_new_run(L"");
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
if (current_value_)
{
Context.output_stream() << xml::utils::replace_text_to_xml(*current_value_ );
}
else
{
Context.output_stream() << L"[Insert date]";
}
Context.output_stream() << L"</w:t>";
Context.finish_run();
}
Context.output_stream() << L"</w:sdtContent>";
Context.output_stream() << L"</w:sdt>";
if (label_)
{
Context.add_new_run(L"");
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
Context.output_stream() << xml::utils::replace_text_to_xml(*label_ );
Context.output_stream() << L"</w:t>";
Context.finish_run();
}
}
// form:item
//----------------------------------------------------------------------------------
const wchar_t * form_item::ns = L"form";
const wchar_t * form_item::name = L"item";
void form_item::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"form:label", label_, std::wstring(L""));
}
void form_item::add_text(const std::wstring & Text)
{
text_ = Text;
}
}
}

View File

@ -337,10 +337,16 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
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:
_CP_OPT(odf_types::Bool) dropdown_;
office_element_ptr_array items_;
_CP_OPT(int ) size_;
//form:list-source-type
//form:size
//form:auto-complete
@ -367,10 +373,9 @@ private:
public:
//form:list-source-type
//form:size
//form:list-source
//form:source-cell-range
//form:dropdown
//form:bound-column
//form:xforms-list-source
//form:multiple
@ -380,10 +385,50 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(form_listbox);
// form:date
class form_date : public form_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeFormDate;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
};
CP_REGISTER_OFFICE_ELEMENT2(form_date);
// form:item
class form_item : public office_element_impl<form_item>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeFormItem;
CPDOCCORE_DEFINE_VISITABLE();
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);
public:
std::wstring label_;
std::wstring text_;
};
CP_REGISTER_OFFICE_ELEMENT2(form_item);
}
}
//<form:connection-resource>7.6.2,
//<form:date> 13.5.8,
//<form:connection-resource>7.6.2,
//<form:file> 13.5.5,
//<form:fixed-text> 13.5.10,
//<form:form> 13.3,

View File

@ -122,7 +122,7 @@ const wchar_t * text::name = L"";
std::wostream & text::text_to_stream(std::wostream & _Wostream) const
{
_Wostream << xml::utils::replace_text_to_xml( text_ );
_Wostream << xml::utils::replace_text_to_xml( text_, true );
return _Wostream;
}
@ -174,7 +174,7 @@ void text::docx_convert(oox::docx_conversion_context & Context)
Context.output_stream() << L" xml:space=\"preserve\"";
Context.output_stream() << L">";
Context.output_stream() << xml::utils::replace_text_to_xml( text_ );
Context.output_stream() << xml::utils::replace_text_to_xml( text_, true );
Context.output_stream() << L"</" << textNode << L">";
if (add_del_run)
@ -1647,17 +1647,23 @@ void bibliography_mark::add_attributes( const xml::attributes_wc_ptr & Attribute
CP_APPLY_ATTR(L"text:school", school_);
CP_APPLY_ATTR(L"text:series", series_);
CP_APPLY_ATTR(L"text:volume", volume_);
if (std::wstring::npos != identifier_.find(L"CITATION "))
{
XmlUtils::replace_all(identifier_, L"CITATION ", L"");
}
XmlUtils::replace_all(identifier_, L" ", L"");
XmlUtils::replace_all(identifier_, L"\\", L"");
}
void bibliography_mark::add_text(const std::wstring & Text)
{
office_element_ptr elm = text::create(Text) ;
content_ = elm;
text_ = text::create(Text) ;
}
std::wostream & bibliography_mark::text_to_stream(std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(content_);
CP_SERIALIZE_TEXT(text_);
return _Wostream;
}
void bibliography_mark::serialize(std::wostream & strm)
@ -1826,6 +1832,20 @@ void bibliography_mark::docx_convert(oox::docx_conversion_context & Context)
serialize(strm);
Context.add_bibliography_item(strm.str());
if (text_)
{
docx_serialize_field(L"CITATION " + XmlUtils::EncodeXmlString(identifier_), text_, Context, false);
//Context.finish_run();
//Context.output_stream() << L"<w:fldSimple w:instr=\" CITATION " << content_ << L" \\h\"/>";
//Context.add_new_run();
// content_->docx_convert(Context);
//Context.finish_run();
//Context.output_stream() << L"</w:fldSimple>";
}
}
void bibliography_mark::pptx_convert(oox::pptx_conversion_context & Context)
@ -2030,8 +2050,103 @@ void field_fieldmark_start::add_attributes( const xml::attributes_wc_ptr & Attri
CP_APPLY_ATTR(L"text:name", text_name_);
CP_APPLY_ATTR(L"field:type", field_type_);
}
void field_fieldmark_start::docx_convert(oox::docx_conversion_context & Context)
{
if (!field_type_) return;
if (!text_name_) return;
if (std::wstring::npos != field_type_->find(L"vnd.oasis.opendocument.field."))
{
Context.start_field(field_type_->substr(29), *text_name_);
}
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * field_fieldmark_end::ns = L"field";
const wchar_t * field_fieldmark_end::name = L"fieldmark-end";
void field_fieldmark_end::docx_convert(oox::docx_conversion_context & Context)
{
Context.end_field();
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * field_fieldmark::ns = L"field";
const wchar_t * field_fieldmark::name = L"fieldmark";
void field_fieldmark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", text_name_);
CP_APPLY_ATTR(L"field:type", field_type_);
}
void field_fieldmark::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(field_params_);
}
void field_fieldmark::docx_convert(oox::docx_conversion_context & Context)
{
if (!field_type_) return;
if (!text_name_) return;
if (std::wstring::npos != field_type_->find(L"FORMCHECKBOX"))
{
XmlUtils::replace_all( *text_name_, L" ", L"_");
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"begin\"><w:ffData><w:name w:val=\"" << *text_name_ << L"\"/><w:enabled/>";
Context.output_stream() << L"<w:checkBox>";
//Context.output_stream() << L"<w:default w:val=\"" << std::to_wstring(current_state_) << L"\"/>
Context.output_stream() << L"<w:sizeAuto/>";
for (size_t i = 0; i < field_params_.size(); i++)
{
field_param *param = dynamic_cast<field_param*>(field_params_[i].get());
if ((param) && (param->field_name_) && (std::wstring::npos != param->field_name_->find(L"Checkbox_Checked")))
{
odf_types::Bool value = Bool::parse(*param->field_value_);
if (value.get())
Context.output_stream() << L"<w:checked/>";
break;
}
}
Context.output_stream() << L"</w:checkBox></w:ffData>";
Context.output_stream() << L"</w:fldChar></w:r>";
Context.output_stream() << L"<w:r><w:instrText>FORMCHECKBOX</w:instrText></w:r>";
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
Context.output_stream() << L"<w:r><w:t>" << L"" << L"</w:t></w:r>";
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
else if (std::wstring::npos != field_type_->find(L"FORMDROPDOWN"))
{
std::wostream & strm = Context.output_stream();
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"><w:ffData><w:name w:val=\"" << text_name_.get_value_or(L"") << L"\"/><w:enabled/>";
strm << L"<w:ddList><w:result w:val=\"0\"/>";
for (size_t i = 0; i < field_params_.size(); i++)
{
field_params_[i]->docx_convert(Context);
}
strm << L"</w:ddList></w:ffData>";
strm << L"</w:fldChar></w:r>";
strm << L"<w:r><w:instrText>FORMDROPDOWN</w:instrText></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
else if (std::wstring::npos != field_type_->find(L"FORMTEXT"))
{
}
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * field_param::ns = L"field";
const wchar_t * field_param::name = L"param";
void field_param::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"field:name", field_name_);
CP_APPLY_ATTR(L"field:value", field_value_);
}
void field_param::docx_convert(oox::docx_conversion_context & Context)
{
}
}
}

View File

@ -1295,7 +1295,7 @@ public:
_CP_OPT(std::wstring) series_;
_CP_OPT(std::wstring) volume_;
office_element_ptr content_;
office_element_ptr text_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
@ -1585,11 +1585,13 @@ public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextFieldFieldmarkStart;
static const ElementType type = typeFieldFieldmarkStart;
CPDOCCORE_DEFINE_VISITABLE();
_CP_OPT(std::wstring) text_name_;
_CP_OPT(std::wstring) field_type_;
void docx_convert(oox::docx_conversion_context & Context);
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) {}
@ -1605,14 +1607,60 @@ public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextFieldFieldmarkStart;
static const ElementType type = typeFieldFieldmarkStart;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
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(field_fieldmark_end);
//-------------------------------------------------------------------------------------------------------------------
// field:fieldmark
//-------------------------------------------------------------------------------------------------------------------
class field_fieldmark : public text::paragraph_content_element<field_fieldmark>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeFieldFieldmark;
CPDOCCORE_DEFINE_VISITABLE();
_CP_OPT(std::wstring) text_name_;
_CP_OPT(std::wstring) field_type_;
office_element_ptr_array field_params_;
void docx_convert(oox::docx_conversion_context & Context);
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(field_fieldmark);
//-------------------------------------------------------------------------------------------------------------------
// field:param
//-------------------------------------------------------------------------------------------------------------------
class field_param : public text::paragraph_content_element<field_param>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeFieldParam;
CPDOCCORE_DEFINE_VISITABLE();
_CP_OPT(std::wstring) field_name_;
_CP_OPT(std::wstring) field_value_;
void docx_convert(oox::docx_conversion_context & Context);
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(field_param);
} // namespace odf_reader
} // namespace cpdoccore

View File

@ -207,29 +207,45 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
{
std::wostream & strm = Context.output_stream();
double page_width = 0;
const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();
if ((pp) && (pp->properties()))
{
style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
if (attr_page.fo_page_width_)
{
page_width = attr_page.fo_page_width_->get_value_unit(odf_types::length::pt);
}
if (attr_page.common_horizontal_margin_attlist_.fo_margin_left_)
{
page_width -= attr_page.common_horizontal_margin_attlist_.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt);
}
if (attr_page.common_horizontal_margin_attlist_.fo_margin_right_)
{
page_width -= attr_page.common_horizontal_margin_attlist_.fo_margin_right_->get_length().get_value_unit(odf_types::length::pt);
}
}
if (attlist_.style_column_width_)
{
double kf_max_width_ms = 1.;
const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();//
if ((pp) && (pp->properties()))
{
style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
if (attr_page.fo_page_width_)
{
int val = 0.5 + 20.0 * attr_page.fo_page_width_->get_value_unit(length::pt);
if (val > 31680.)
kf_max_width_ms = 31680./val;
}
}
int val = 0.5 + 20.0 * page_width;
if (val > 31680.)
kf_max_width_ms = 31680./val;
int val = attlist_.style_column_width_->get_value_unit(length::pt);
double width = 0.5 + 20.0 * val * kf_max_width_ms;
double width = 0.5 + 20.0 * attlist_.style_column_width_->get_value_unit(length::pt) * kf_max_width_ms;
Context.get_table_context().add_column_width(width);
strm << L"<w:gridCol w:w=\"" << (int)(width) << "\"/>";
}
else if ((attlist_.style_rel_column_width_) && (attlist_.style_rel_column_width_->get_unit() == length::rel))
{
double width = 0.5 + 20.0 * page_width * attlist_.style_rel_column_width_->get_value() / 65534.;
Context.get_table_context().add_column_width(width);
strm << L"<w:gridCol w:w=\"" << (int)(width) << "\"/>";
}
else
{
Context.get_table_context().add_column_width(0);

View File

@ -244,6 +244,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
style_table_cell_properties() {}
virtual void docx_convert(oox::docx_conversion_context & Context) ;
private:

View File

@ -176,9 +176,12 @@ style_section_properties * style_content::get_style_section_properties() const
return dynamic_cast<style_section_properties *>(style_section_properties_.get());
}
style_table_cell_properties * style_content::get_style_table_cell_properties() const
style_table_cell_properties * style_content::get_style_table_cell_properties(bool always)
{
return dynamic_cast<style_table_cell_properties *>(style_table_cell_properties_.get());
if (!style_table_cell_properties_ && always)
style_table_cell_properties_ = boost::make_shared<style_table_cell_properties>();
return dynamic_cast<style_table_cell_properties *>(style_table_cell_properties_.get());
}
style_table_row_properties * style_content::get_style_table_row_properties() const

View File

@ -96,11 +96,11 @@ public:
style_paragraph_properties * get_style_paragraph_properties() const;
style_table_properties * get_style_table_properties() const;
style_section_properties * get_style_section_properties() const;
style_table_cell_properties * get_style_table_cell_properties() const;
style_table_row_properties * get_style_table_row_properties() const;
style_table_column_properties * get_style_table_column_properties() const;
style_chart_properties * get_style_chart_properties() const;
style_drawing_page_properties* get_style_drawing_page_properties() const;
style_table_cell_properties * get_style_table_cell_properties (bool always =false);
private:
odf_types::style_family style_family_;

View File

@ -69,15 +69,32 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
const std::wstring styleName = attlist_.table_style_name_.get_value_or(L"");
const std::wstring defaultCellStyle = attlist_.table_default_cell_style_name_.get_value_or(L"");
const style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name( styleName , style_family::TableRow,Context.process_headers_footers_);
style_table_cell_properties* cell_props = NULL;
style_table_row_properties* row_props = NULL;
if (inst && inst->content())
{
cell_props = inst->content()->get_style_table_cell_properties(true);
row_props = inst->content()->get_style_table_row_properties();
if ((row_props) && (row_props->attlist_.common_background_color_attlist_.fo_background_color_))
{
if (!cell_props->attlist_.common_background_color_attlist_.fo_background_color_)
cell_props->attlist_.common_background_color_attlist_.fo_background_color_ = row_props->attlist_.common_background_color_attlist_.fo_background_color_;
}
}
for (unsigned int i = 0; i < attlist_.table_number_rows_repeated_; ++i)
{
_Wostream << L"<w:tr>";
const style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name( styleName , style_family::TableRow,Context.process_headers_footers_);
_Wostream << L"<w:trPr>";
_Wostream << L"<w:cantSplit w:val=\"false\" />";
if (inst && inst->content())inst->content()->docx_convert(Context);
if (cell_props)
cell_props->docx_convert(Context);
_Wostream << L"</w:trPr>";
Context.get_table_context().start_row(styleName, defaultCellStyle);
@ -304,28 +321,45 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
);
}
if (attlist_extra_.table_number_columns_spanned_ > 1)
{
_Wostream << L"<w:gridSpan w:val=\"" << attlist_extra_.table_number_columns_spanned_ << "\"/>";
Context.get_table_context().set_columns_spanned(attlist_extra_.table_number_columns_spanned_ - 1);
}
double width = Context.get_table_context().get_current_cell_width();
if (width > 0.01)
{
_Wostream << L"<w:tcW w:w=\"" << (int)width << L"\" w:type=\"dxa\"/>";
}
if (attlist_extra_.table_number_columns_spanned_ > 1)
{
_Wostream << L"<w:gridSpan w:val=\"" << attlist_extra_.table_number_columns_spanned_ << "\"/>";
Context.get_table_context().set_columns_spanned(attlist_extra_.table_number_columns_spanned_ - 1);
}
const style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name( styleName , style_family::TableCell,Context.process_headers_footers_);
Context.root()->odf_context().styleContainer().style_by_name( styleName , style_family::TableCell, Context.process_headers_footers_);
if (inst && inst->content())
{
if (inst->content()->get_style_table_cell_properties())
{
inst->content()->get_style_table_cell_properties()->docx_convert(Context);
}
const std::wstring & currentRowStyle = Context.get_table_context().current_row_style();
const style_instance * inst_row =
Context.root()->odf_context().styleContainer().style_by_name(currentRowStyle, style_family::TableRow, Context.process_headers_footers_);
style_table_cell_properties *row_cell_props = NULL;
if (inst_row && inst_row->content())
{
row_cell_props = inst_row->content()->get_style_table_cell_properties();
}
if (inst && inst->content())
{
style_table_cell_properties merge_cell_props;
style_table_cell_properties * cell_props = inst->content()->get_style_table_cell_properties();
if (row_cell_props)
merge_cell_props.attlist_.apply_from(row_cell_props->attlist_);
if (cell_props)
merge_cell_props.attlist_.apply_from(cell_props->attlist_);
merge_cell_props.docx_convert(Context);
if (inst->content()->get_style_text_properties())
{
@ -341,7 +375,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
Context.get_table_context().get_default_cell_style_col(Context.get_table_context().current_column());
if (const style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyle, style_family::TableCell,Context.process_headers_footers_))
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyle, style_family::TableCell, Context.process_headers_footers_))
{
if (const style_content * content = inst->content())
{
@ -359,7 +393,7 @@ void table_table_cell::docx_convert(oox::docx_conversion_context & Context)
const std::wstring & defaultCellStyle = Context.get_table_context().get_default_cell_style_row();
if (const style_instance * inst =
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyle, style_family::TableCell,Context.process_headers_footers_))
Context.root()->odf_context().styleContainer().style_by_name(defaultCellStyle, style_family::TableCell, Context.process_headers_footers_))
{
if (const style_content * content = inst->content())
{

View File

@ -688,7 +688,44 @@ void section::docx_convert(oox::docx_conversion_context & Context)
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
if (content_[i]->element_style_name)
{
std::wstring text___ = *content_[i]->element_style_name;
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(*content_[i]->element_style_name);
if (masterPageName)
{
std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(*masterPageName);
if (false == masterPageNameLayout.empty())
{
Context.set_master_page_name(*masterPageName); //проверка на то что тема действительно существует????
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
}
}
}
if (content_[i]->next_element_style_name)
{
std::wstring text___ = *content_[i]->next_element_style_name;
// проверяем не сменится ли свойства страницы.
// если да — устанавливаем контексту флаг на то что необходимо в текущем параграфе
// распечатать свойства раздела/секции
//проверить ... не она ли текущая - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(*content_[i]->next_element_style_name);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
{
if (false == Context.root()->odf_context().pageLayoutContainer().compare_page_properties(Context.get_master_page_name(), *next_masterPageName))
{
Context.next_dump_page_properties(true);
//is_empty = false;
}
}
}
content_[i]->docx_convert(Context);
}
}
@ -843,6 +880,11 @@ void table_of_content::add_child_element( xml::sax * Reader, const std::wstring
}
void table_of_content::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring current_page_properties = Context.get_page_properties();
Context.get_section_context().add_section (section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties);
Context.add_page_properties(current_page_properties);
if (index_body_)
{
Context.start_sdt(1);

View File

@ -34,8 +34,6 @@
#include <string>
#include <iostream>
#include <boost/foreach.hpp>
#include "../../include/xml/attributes.h"
#include "../../include/xml/sax.h"

View File

@ -96,9 +96,9 @@ std::string replace_xml_to_text_ImplRegEx(const std::string & Text)
return boost::regex_replace(Text, replace_xml_to_text_expr, replace_xml_to_text_fmt, boost::match_default | boost::format_all);
}
std::wstring replace_text_to_xml_ImplReplace(const std::wstring & Text)
std::wstring replace_text_to_xml_ImplReplace(const std::wstring & Text, bool dDeleteUnicode)
{
return XmlUtils::EncodeXmlString(Text);
return XmlUtils::EncodeXmlString(Text, dDeleteUnicode);
}
std::string replace_text_to_xml_ImplReplace(const std::string & Text)
@ -164,9 +164,9 @@ std::wstring replace_amp_text_to_xml(const std::wstring & Text)
{
return details::replace_amp_text_to_xml_ImplReplace(Text);
}
std::wstring replace_text_to_xml(const std::wstring & Text)
std::wstring replace_text_to_xml(const std::wstring & Text, bool dDeleteUnicode)
{
return details::replace_text_to_xml_ImplReplace(Text);
return details::replace_text_to_xml_ImplReplace(Text, dDeleteUnicode);
}
std::string replace_text_to_xml(const std::string & Text)

View File

@ -1519,6 +1519,10 @@
RelativePath="..\src\odf\odf_document_impl.h"
>
</File>
<File
RelativePath="..\include\odf\odf_elements_type.h"
>
</File>
<File
RelativePath="..\src\odf\odfcontext.cpp"
>
@ -1571,10 +1575,6 @@
RelativePath="..\src\odf\office_elements.h"
>
</File>
<File
RelativePath="..\src\odf\office_elements_type.h"
>
</File>
<File
RelativePath="..\src\odf\office_event_listeners.cpp"
>

View File

@ -47,12 +47,15 @@
#if defined(_DEBUG)
#pragma comment(lib, "../../build/lib/win_32/DEBUG/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/UnicodeConverter.lib")
#else
#pragma comment(lib, "../../build/lib/win_32/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/UnicodeConverter.lib")
#endif
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
HRESULT convert_single(std::wstring srcFileName)
{
int n1 = srcFileName.rfind(_T('.'));

View File

@ -383,10 +383,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\FontProcessor.cpp"
>
@ -411,10 +407,6 @@
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>

View File

@ -48,6 +48,16 @@
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#if defined(_DEBUG)
#pragma comment(lib, "../../build/lib/win_32/DEBUG/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/UnicodeConverter.lib")
#else
#pragma comment(lib, "../../build/lib/win_32/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/UnicodeConverter.lib")
#endif
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif

View File

@ -335,18 +335,6 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\XlsFormatTest.cpp"
>
@ -424,14 +412,6 @@
>
</File>
</Filter>
<File
RelativePath="..\..\build\lib\win_32\DEBUG\graphics.lib"
>
</File>
<File
RelativePath="..\..\build\lib\win_32\DEBUG\kernel.lib"
>
</File>
</Files>
<Globals>
</Globals>

View File

@ -212,6 +212,10 @@ int SUPBOOK::serialize(std::wostream & strm)
int SUPBOOK::serialize_book(std::wostream & strm)
{
SupBook *book = dynamic_cast<SupBook*>(m_SupBook.get());
if (book->virtPath.empty())
return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"externalBook")
@ -219,7 +223,7 @@ int SUPBOOK::serialize_book(std::wostream & strm)
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", L"rId1");
sExternPathLink = book->virtPath.back();
sExternPathLink = book->virtPath.back();
if (!m_arXCT.empty() && !book->rgst.empty())
{
@ -355,6 +359,10 @@ int SUPBOOK::serialize_book(std::wostream & strm)
int SUPBOOK::serialize_dde(std::wostream & strm)
{
SupBook *book = dynamic_cast<SupBook*>(m_SupBook.get());
if (book->virtPath.empty())
return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"ddeLink")

View File

@ -1 +1 @@
2.4.539.0
2.4.541.0

View File

@ -41,6 +41,32 @@
namespace NSFonts
{
void makeLower(std::wstring& name)
{
int nLen = (int)name.length();
wchar_t* pStr = (wchar_t*)name.c_str();
for (int i = 0; i < nLen; ++i)
{
if (pStr[i] >= 'A' && pStr[i] <= 'Z')
pStr[i] = pStr[i] + 'a' - 'A';
}
}
std::wstring prepareFont3000(std::wstring& name)
{
std::wstring sRet;
int nLen = (int)name.length();
wchar_t* pStr = (wchar_t*)name.c_str();
for (int i = 0; i < nLen; ++i)
{
if (pStr[i] == ' ' || pStr[i] == '-')
continue;
sRet.append(pStr + i, 1);
}
return sRet;
}
CFontInfo* FromBuffer(BYTE*& pBuffer, std::wstring strDir)
{
// name
@ -729,7 +755,7 @@ int CFontList::GetFaceNamePenalty(std::wstring sCandName, std::wstring sReqName,
else if ( std::wstring::npos != sReqName.find( sCandName ) || std::wstring::npos != sCandName.find( sReqName ) )
return 1000;
if (NULL != pArrayLikes)
if (NULL != pArrayLikes)
{
for (std::vector<std::wstring>::iterator iter = pArrayLikes->begin(); iter != pArrayLikes->end(); iter++)
{
@ -738,6 +764,19 @@ int CFontList::GetFaceNamePenalty(std::wstring sCandName, std::wstring sReqName,
}
}
/*
NSFonts::makeLower(sCandName);
NSFonts::makeLower(sReqName);
if ( sReqName == sCandName )
return 1500;
sCandName = NSFonts::prepareFont3000(sCandName);
sReqName = NSFonts::prepareFont3000(sReqName);
if ( sReqName == sCandName )
return 3000;
*/
return 10000;
}