Compare commits

..

19 Commits

Author SHA1 Message Date
d12cc81745 [x2t] Add app/core.xml to Editor.bin 2018-10-31 20:27:03 +03:00
e21e0afb45 Fix bug with rendering some emf files 2018-10-30 15:01:34 +03:00
f40d82a097 Fix issue https://github.com/ONLYOFFICE/DocumentServer/issues/413 2018-10-29 15:20:48 +03:00
9112c87b1f Merge remote-tracking branch 'origin/feature/fix2_v5.2.3' into develop 2018-10-29 13:19:17 +03:00
01691950b9 . 2018-10-29 13:18:34 +03:00
78bbaecefe Merge remote-tracking branch 'origin/feature/fix2_v5.2.3' into develop 2018-10-29 11:39:01 +03:00
9e085c5ae8 OdfFormat - fix conditional formatting 2018-10-28 17:45:25 +03:00
f55cafa2af OdfFormat -fix after testing 2018-10-26 19:51:12 +03:00
17bc27199c OdfFormatWriter - fix bug#39467 2018-10-25 18:51:07 +03:00
ee4167ec8c Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-25 17:48:00 +03:00
e436c13fcc [x2t] Fix bug 39456 2018-10-25 17:45:03 +03:00
8e2c980152 OdfFormat - fix after testing (#118)
OdfFormat - fix after testing
2018-10-25 17:43:11 +03:00
658bfbc348 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-23 13:35:31 +03:00
ff9ef8f941 PptFormatReader - fix users files 2018-10-23 13:19:30 +03:00
0a2401471e [x2t] Fix bug 39391
Fix writing only last ConditionalFormatting from Editor.bin
2018-10-23 11:37:06 +03:00
5ca5597c58 [ios][pe] translations 2018-10-22 16:22:53 +03:00
e55dc5ea75 . 2018-10-22 15:47:09 +03:00
e2db849b03 Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-22 12:01:03 +03:00
fef30772fd OdfFormatWriter - fix after testing 2018-10-21 18:10:29 +03:00
66 changed files with 1414 additions and 410 deletions

View File

@ -145,7 +145,8 @@ extern int g_nCurFormatVersion;
Endnotes = 11,
Background = 12,
VbaProject = 13,
App = 14
App = 15,
Core = 16
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{

View File

@ -36,6 +36,8 @@
#include "../DocWrapper/FontProcessor.h"
#include "../../Common/Base64.h"
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/App.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/Core.h"
#include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "BinEquationWriter.h"
@ -7961,38 +7963,6 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
};
class BinaryAppTableWriter
{
BinaryCommonWriter m_oBcw;
ParamsWriter& m_oParamsWriter;
public:
BinaryAppTableWriter(ParamsWriter& oParamsWriter):
m_oBcw(oParamsWriter),m_oParamsWriter(oParamsWriter)
{
}
void Write(OOX::CApp& oApp)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteProperties(oApp);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteProperties(OOX::CApp& oApp)
{
int nCurPos = 0;
if (oApp.m_sApplication.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::Application);
m_oBcw.m_oStream.WriteStringW3(oApp.m_sApplication.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oApp.m_sAppVersion.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::AppVersion);
m_oBcw.m_oStream.WriteStringW3(oApp.m_sAppVersion.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
class BinaryFileWriter
{
BinaryCommonWriter m_oBcw;
@ -8148,9 +8118,15 @@ namespace BinDocxRW
//Write App
if(NULL != oDocx.m_pApp)
{
BinDocxRW::BinaryAppTableWriter oBinaryAppWriter(m_oParamsWriter);
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::App);
oBinaryAppWriter.Write(*oDocx.m_pApp);
oDocx.m_pApp->ToPptxApp()->toPPTY(&oBufferedStream);
this->WriteTableEnd(nCurPos);
}
if(NULL != oDocx.m_pCore)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Core);
oDocx.m_pCore->ToPptxCore()->toPPTY(&oBufferedStream);
this->WriteTableEnd(nCurPos);
}

View File

@ -95,7 +95,7 @@ namespace formulasconvert {
bool odf2oox_converter::Impl::find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref)
{
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([\\w^0-9\\$]+\\d+)(?::\\.([\\w^0-9]+\\d+)){0,1}\\]");
boost::wsmatch result;
bool b = boost::regex_search(expr, result, re);
@ -211,7 +211,7 @@ namespace formulasconvert {
}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
{
boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)(?::\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)){0,1}");
std::wstring expr = what[1].str();
const std::wstring res = boost::regex_replace(
@ -235,7 +235,7 @@ namespace formulasconvert {
{
convert_with_TableName = withTableName;
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]");
/*
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
*/
@ -252,7 +252,7 @@ namespace formulasconvert {
convert_with_TableName = withTableName;
//boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}");
const std::wstring res = boost::regex_replace(
expr,
@ -358,35 +358,52 @@ namespace formulasconvert {
return L"";
}
void odf_replace_tmp_back(std::wstring &expr)
{
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
XmlUtils::replace_all( expr, L"VOSKL", L"!");
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( expr, L"PROBEL", L" ");
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
}
void odf_replace_tmp(std::wstring &expr)
{
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
XmlUtils::replace_all( expr, L"!", L"VOSKL");
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
XmlUtils::replace_all( expr, L" ", L"PROBEL");
XmlUtils::replace_all( expr, L"'", L"APOSTROF");
XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
}
std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
odf_replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
odf_replace_tmp(inner);
return inner;
}
else if (what[3].matched)
@ -492,9 +509,9 @@ namespace formulasconvert {
XmlUtils::replace_all( workstr, L"FDIST(", L"_xlfn.F.DIST(");
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
if (std::wstring::npos != workstr.find(L"CONCATINATE"))
{
bool l = true;
//могут быть частично заданы диапазоны
//todooo
}
@ -509,18 +526,7 @@ namespace formulasconvert {
//-----------------------------------------------------------
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"ТОСHKA" , L".");
XmlUtils::replace_all( workstr, L"SCOBCAIN" , L"(");
XmlUtils::replace_all( workstr, L"SCOBCAOUT" , L")");
XmlUtils::replace_all( workstr, L"KVADRATIN" , L"[");
XmlUtils::replace_all( workstr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"KAVYCHKA" , L"\"");
odf_replace_tmp_back(workstr);
return workstr;
}

View File

@ -69,9 +69,42 @@ public:
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::table_name_ = L"";
void oox_replace_tmp_back(std::wstring &expr)
{
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
XmlUtils::replace_all( expr, L"VOSKL", L"!");
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( expr, L"PROBEL", L" ");
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
}
void oox_replace_tmp(std::wstring &expr)
{
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
XmlUtils::replace_all( expr, L"!", L"VOSKL");
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
XmlUtils::replace_all( expr, L" ", L"PROBEL");
XmlUtils::replace_all( expr, L"'", L"APOSTROF");
XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
}
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
{
if ((0 == expr.find(L"KAVYCHKA")) && (expr.length() - 8 == expr.rfind(L"KAVYCHKA") ))
return;
boost::wregex re(L"([:$!])+");
boost::wsmatch result;
@ -79,7 +112,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
if (b)
{
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]*\\d*)\\:?([a-zA-Z$]*\\d*)?");
boost::wregex re1(L"(\\$?\\w+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
@ -111,8 +144,12 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if (!c1.empty() || !c2.empty() || !sheet.empty())
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
{
return c1;
}
else if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
@ -122,9 +159,8 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = std::wstring(L"[") + sheet + L"." +
c1 +
(c2.empty() ? L"" : (L":" + sheet + L"." + c2) ) + std::wstring(L"]");
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
}
return s;
}
@ -186,19 +222,11 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
{
std::wstring &d = distance[i];
XmlUtils::replace_all( d, L"(", L"SCOBCAIN");
XmlUtils::replace_all( d, L")", L"SCOBCAOUT");
XmlUtils::replace_all( d, L" ", L"PROBEL");
XmlUtils::replace_all( d, L"'", L"APOSTROF");
XmlUtils::replace_all( d, L"\"", L"KAVYCHKA");
oox_replace_tmp(d);
replace_cells_range(d);
XmlUtils::replace_all( d, L"SCOBCAIN", L"(");
XmlUtils::replace_all( d, L"SCOBCAOUT", L")");
XmlUtils::replace_all( d, L"PROBEL", L" ");
XmlUtils::replace_all( d, L"APOSTROF", L"'");
XmlUtils::replace_all( d, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(d);
out = out + d + std::wstring(L";");
}
@ -209,11 +237,7 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
if (table_name_.empty() == false)
{
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(table_name_);
}
}
@ -370,32 +394,19 @@ std::wstring replace_(boost::wsmatch const & what)
return L"";
}
std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
oox_replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
oox_replace_tmp(inner);
return inner;
}
else if (what[3].matched)
@ -444,13 +455,13 @@ std::wstring oox2odf_converter::Impl::convert(const std::wstring& expr)
if (is_forbidden1(expr))
return L"NULLFORMULA";
std::wstring workstr = expr;
std::wstring workstr = expr;
replace_cells_range(workstr);
replace_vertical(workstr);
replace_semicolons(workstr);
return workstr;
}
// of:=(Formula) -> (Formula)
// (Formula) -> of:=(Formula)
std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
{
std::wstring workstr = expr;
@ -462,7 +473,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
boost::wregex(L"(?!([\\w^0-9]+\\d*\\())(([\\w^0-9]+\\!)?\\$?[\\w^0-9]*\\$?\\d*(\\:\\$?[\\w^0-9]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
//SUBTOTAL(109,Expense31[Amount])
@ -480,16 +491,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::match_default | boost::format_all);
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"KVADRATIN", L"[");
XmlUtils::replace_all( res, L"KVADRATOUT", L"]");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(res);
replace_vertical(res);
replace_semicolons(res);
@ -498,17 +500,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
if (table_name_.empty() == false)
{
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
XmlUtils::replace_all( table_name_, L"KVADRATIN", L"[");
XmlUtils::replace_all( table_name_, L"KVADRATOUT", L"]");
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
oox_replace_tmp_back(table_name_);
}
return std::wstring(L"of:=") + res;
@ -537,12 +529,7 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
oox_replace_tmp_back( res);
replace_vertical(res);
replace_semicolons(res);

View File

@ -37,9 +37,9 @@
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true), bGrayscale(false)
{
memset(cropRect,0,sizeof(double)*4);
memset(cropRect, 0, sizeof(double)*4);
}
oox_bitmap_fill_ptr oox_bitmap_fill::create(){return boost::make_shared<oox_bitmap_fill>();}
@ -189,7 +189,11 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons
{
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
}
}
}
if (val.bitmap->bGrayscale)
{
CP_XML_NODE(ns + L":grayscl");
}
}
if (val.bitmap->bCrop)
{

View File

@ -70,6 +70,7 @@ namespace oox {
bool bStretch;
bool bCrop;
bool bTile;
bool bGrayscale;
double cropRect[4];//0-left, 1 -top, 2- right, 3 - bottom

View File

@ -538,8 +538,11 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
_CP_OPT(std::wstring) sTextContent, sColorMode;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = typeShape;
@ -549,6 +552,9 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL);
drawing.fill.bitmap->bStretch = true;
if ((sColorMode) && (*sColorMode == L"greyscale"))
drawing.fill.bitmap->bGrayscale = true;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;/// это ссылка на выходной внешний объект

View File

@ -36,8 +36,10 @@
#include <vector>
#include <boost/lexical_cast.hpp>
#include <xml/simple_xml_writer.h>
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../formulasconvert/formulasconvert.h"
namespace cpdoccore {
namespace oox {
@ -148,7 +150,10 @@ public:
//CP_XML_ATTR(L"aboveAverage" , 0);
if (c.rules[j].type == 1)
{
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
if (c.rules[j].formula_type)
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
else
CP_XML_ATTR(L"type", L"cellIs");
if ((c.rules[j].formula) && (!c.rules[j].formula->empty()))
{
CP_XML_NODE(L"formula")
@ -177,13 +182,11 @@ public:
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
if (c.rules[j].color.size() > 0)
CP_XML_NODE(L"color")
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"rgb", c.rules[j].color[0]);
}
}
CP_XML_ATTR(L"rgb", !c.rules[j].color.empty() ? c.rules[j].color[0] : L"FF000000");
}
}
}
else if (c.rules[j].type == 3)
@ -245,7 +248,7 @@ void xlsx_conditionalFormatting_context::add(std::wstring ref)
formulasconvert::odf2oox_converter converter;
impl_->conditionalFormattings_.push_back(conditionalFormatting());
impl_->conditionalFormattings_.back().ref = converter.convert_named_ref(ref, false, L";");
impl_->conditionalFormattings_.back().ref = converter.convert_named_ref(ref, false, L" ");
}
void xlsx_conditionalFormatting_context::add_rule(int type)
@ -260,7 +263,21 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
int pos = -1;
std::wstring val;
if ( 0 <= (pos = f.find(L"formula-is(")))
if ( f == L"unique")
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"uniqueValues";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else if ( f == L"duplicate")
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else if ( f == L"above-average")
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"aboveAverage";
}
else if ( 0 <= (pos = f.find(L"formula-is(")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
val = f.substr(11, f.size() - 12);
@ -292,6 +309,45 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
std::wstring text = f.substr(14, f.length() - 15);
if (std::wstring::npos != text.find(L"IF(") ||
std::wstring::npos != text.find(L"AND(") ||
std::wstring::npos != text.find(L"NOT(") ||
std::wstring::npos != text.find(L"ISERROR(") ||
std::wstring::npos != text.find(L"SEARCH("))
{
impl_->conditionalFormattings_.back().rules.back().text = L"";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert(text);
}
else if (std::wstring::npos != text.find(L"LEN(TRIM(") &&
std::wstring::npos != text.find(L"=0"))
{
impl_->conditionalFormattings_.back().rules.back().text = L"";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else
{
impl_->conditionalFormattings_.back().rules.back().operator_ = L"containsText";
if ( 0 == text.find(L"\"") && text.length() - 1 == text.rfind(L"\""))
{
text = text.substr(1, text.length() - 2);
}
std::wstring ref = impl_->conditionalFormattings_.back().ref;
size_t pos;
if ((pos = ref.find(L":")) != std::wstring::npos)
{
ref = ref.substr(0, pos);
}
impl_->conditionalFormattings_.back().rules.back().text = text;
impl_->conditionalFormattings_.back().rules.back().formula = L"NOT(ISERROR(SEARCH(\"" + text + L"\"," + ref + L")))";
}
}
else if (0 <= (pos = f.find(L"top")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
@ -302,14 +358,10 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
if (0 <= (pos = f.find(L"(")))
{
val = f.substr(pos + 1, f.length() - pos - 2);
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
if (!val.empty())
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
}
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
}
else
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs";
@ -361,6 +413,8 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
impl_->conditionalFormattings_.back().rules.back().operator_ = L"between";
val = f.substr(8, f.length() - 9);
XmlUtils::replace_all(val, L"(", L"");
XmlUtils::replace_all(val, L")", L"");
if (0 <= (pos = val.find(L",")))
{
impl_->conditionalFormattings_.back().rules.back().formula2 = converter.convert_named_expr( val.substr(pos + 1) );
@ -398,7 +452,11 @@ void xlsx_conditionalFormatting_context::add_sfv(int type, std::wstring value)
impl_->conditionalFormattings_.back().rules.back().formula.reset();
}
else if (!value.empty()) cfvo.val = value;
else
{
if (!value.empty()) cfvo.val = value;
else cfvo.val = L"0";
}
impl_->conditionalFormattings_.back().rules.back().cfvo.push_back(cfvo);
}

View File

@ -202,20 +202,25 @@ void xlsx_drawing_context::end_group()
{
if (impl_->groups_.size() < 1) return;
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
group_rect.cy -= group_rect.y;
group_rect.cx -= group_rect.x;
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
if (impl_->groups_.back()->svg_rect_)
{
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
r.y -= group_rect.y;
r.x -= group_rect.x;
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
group_rect.cy -= group_rect.y;
group_rect.cx -= group_rect.x;
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
{
if (!impl_->groups_.back()->child_objects_[i].svg_rect_) continue;
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
r.y -= group_rect.y;
r.x -= group_rect.x;
}
}
if (impl_->groups_.back()->in_group_)
if (impl_->groups_.back()->in_group_ && impl_->groups_.back()->svg_rect_)
{
_rect & objct_rect = impl_->groups_.back()->svg_rect_.get();
@ -251,7 +256,8 @@ void xlsx_drawing_context::start_drawing(std::wstring const & name)
void xlsx_drawing_context::end_drawing()
{
if (impl_->object_description_.in_group_)
if (impl_->object_description_.in_group_ &&
impl_->object_description_.svg_rect_)
{
_rect & objct_rect = impl_->object_description_.svg_rect_.get();
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
@ -533,8 +539,10 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
}
_CP_OPT(std::wstring) sTextContent;
GetProperty(obj.additional_,L"text-content",sTextContent);
_CP_OPT(std::wstring) sTextContent, sColorMode;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
@ -546,6 +554,9 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL/*applicationFonts_*/);
drawing.fill.bitmap->bStretch = true;
if ((sColorMode) && (*sColorMode == L"greyscale"))
drawing.fill.bitmap->bGrayscale = true;
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;

View File

@ -134,10 +134,21 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false),
bEndTable(false)
bEndTable_(false),
bRTL_(false)
{
memset(&group_row_,0,sizeof(_group_row));
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = context_->root()->odf_context().styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
if ((tableStyle) && (tableStyle->content()))
table_prop = tableStyle->content()->get_style_table_properties();
if ((table_prop) && (table_prop->content().common_writing_mode_attlist_.style_writing_mode_))
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
bRTL_ = true;
}
}
void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
@ -149,6 +160,11 @@ void xlsx_table_state::start_column(unsigned int repeated, const std::wstring &
columns_.push_back(repeated);
}
void xlsx_table_state::set_rtl(bool val)
{
bRTL_ = val;
}
unsigned int xlsx_table_state::columns_count() const
{
return columns_count_;
@ -224,10 +240,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
xlsx_merge_cells_.add_merge(current_table_column_, current_table_row_, columnsSpanned, rowsSpanned);
}
if ( current_columns_spaned() > 0 )
{
_CP_LOG << L"[warning] current columns spanned > 0\n";
}
//if ( current_columns_spaned() > 0 )
//{
// _CP_LOG << L"[warning] current columns spanned > 0\n";
//}
columns_spanned_num_ = static_cast<int>(columnsSpanned);
@ -247,10 +263,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
}
else
{
if (rows_spanned_[current_table_column_].num() > 0)
{
_CP_LOG << L"[warning] current rows spanned > 0\n";
}
//if (rows_spanned_[current_table_column_].num() > 0)
//{
// _CP_LOG << L"[warning] current rows spanned > 0\n";
//}
rows_spanned_[current_table_column_].num(static_cast<unsigned int>(rowsSpanned));
rows_spanned_[current_table_column_].column_spanned(static_cast<unsigned int>(columnsSpanned));
for (size_t i = 0; i <= columns_spanned_num_; ++i)
@ -421,6 +437,9 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
CP_XML_ATTR(L"workbookViewId", 0);
if (bRTL_)
CP_XML_ATTR(L"rightToLeft", 1);
std::wstring s_col, s_row;
for (int i = 0; i < odfContext.Settings().get_table_view_count(0, tableName_); i++)
{
@ -458,7 +477,6 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
}
}
// -showRowColHeaders
// -rightToLeft
}
double default_height = (2 * context_->getMaxDigitSize().second * 72. / 96. * 100.) /100.;//in point size.

View File

@ -82,6 +82,8 @@ public:
xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName, int tableId);
std::wstring current_style() const { return table_style_; }
void set_rtl(bool val);
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
@ -92,8 +94,8 @@ public:
void add_empty_row(int count);
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
void set_end_table(){ bEndTable_ = true; }
bool get_end_table(){ return bEndTable_; }
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
@ -147,17 +149,18 @@ public:
struct _group_row
{
bool enabled;
int count;
int level;
bool collapsed;
bool enabled = false;
int count = 0;
int level = 0;
bool collapsed = false;
}group_row_;
friend class xlsx_conversion_context;
friend class xlsx_table_context;
private:
bool bEndTable;
bool bRTL_;
bool bEndTable_;
xlsx_conversion_context * context_;
std::wstring tableName_;

View File

@ -647,19 +647,36 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
odf_reader::odf_read_context & odfContext = root()->odf_context();
instances.push_back(odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell));
instances.push_back(odfContext.styleContainer().style_by_name(L"Default",odf_types::style_family::TableCell,false));
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
if (textFormatProperties.style_font_name_)
font_name = textFormatProperties.style_font_name_.get();
else if (textFormatProperties.style_font_name_complex_)
font_name = textFormatProperties.style_font_name_complex_.get();
else if (textFormatProperties.style_font_name_asian_)
font_name = textFormatProperties.style_font_name_asian_.get();
odf_reader::style_instance *inst = odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell);
if (inst) instances.push_back(inst);
inst = odfContext.styleContainer().style_by_name(L"Default", odf_types::style_family::TableCell, false);
if (inst) instances.push_back(inst);
else
font_name = L"Arial";
{
inst = odfContext.styleContainer().style_by_name(L"Normal", odf_types::style_family::TableCell, false);
if (inst) instances.push_back(inst);
}
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
if (textFormatProperties.fo_font_family_)
font_name = textFormatProperties.fo_font_family_.get();
else
{
std::wstring style_font_name;
if (textFormatProperties.style_font_name_) style_font_name = textFormatProperties.style_font_name_.get();
else if (textFormatProperties.style_font_name_complex_) style_font_name = textFormatProperties.style_font_name_complex_.get();
else if (textFormatProperties.style_font_name_asian_) style_font_name = textFormatProperties.style_font_name_asian_.get();
odf_reader::fonts_container & fonts = odf_document_->odf_context().fontContainer();
odf_reader::font_instance * font = fonts.font_by_style_name(style_font_name);
if (font)
{
font_name = font->name();
}
}
if (font_name.empty()) font_name = L"Arial";
if ((textFormatProperties.fo_font_size_) && (textFormatProperties.fo_font_size_->get_type() == odf_types::font_size::Length))
font_size = (int)(0.5 + textFormatProperties.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));

View File

@ -744,6 +744,9 @@ void process_build_object::visit(chart_title& val)
if (val.attlist_.common_draw_position_attlist_.svg_x_)
{
t.pos_x = val.attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
}
if (val.attlist_.common_draw_position_attlist_.svg_y_)
{
t.pos_y = val.attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
}
t.bEnabled = true;

View File

@ -106,6 +106,13 @@ void common_draw_fill_attlist::add_attributes( const xml::attributes_wc_ptr & At
CP_APPLY_ATTR(L"draw:fill-image-width", draw_fill_image_width_);
CP_APPLY_ATTR(L"draw:fill-image-height", draw_fill_image_height_);
CP_APPLY_ATTR(L"draw:color-mode", draw_color_mode_);
CP_APPLY_ATTR(L"draw:contrast", draw_contrast_);
CP_APPLY_ATTR(L"draw:luminance", draw_luminance_);
CP_APPLY_ATTR(L"draw:gamma", draw_gamma_);
CP_APPLY_ATTR(L"draw:red", draw_red_);
CP_APPLY_ATTR(L"draw:green", draw_green_);
CP_APPLY_ATTR(L"draw:blue", draw_blue_);
}
void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
{
@ -130,6 +137,13 @@ void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"draw:fill-image-width", draw_fill_image_width_);
CP_XML_ATTR_OPT(L"draw:fill-image-height", draw_fill_image_height_);
CP_XML_ATTR_OPT(L"draw:color-mode", draw_color_mode_);
CP_XML_ATTR_OPT(L"draw:contrast", draw_contrast_);
CP_XML_ATTR_OPT(L"draw:luminance", draw_luminance_);
CP_XML_ATTR_OPT(L"draw:gamma", draw_gamma_);
CP_XML_ATTR_OPT(L"draw:red", draw_red_);
CP_XML_ATTR_OPT(L"draw:green", draw_green_);
CP_XML_ATTR_OPT(L"draw:blue", draw_blue_);
}
void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other)
@ -150,6 +164,14 @@ void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other
_CP_APPLY_PROP2(draw_fill_image_width_);
_CP_APPLY_PROP2(draw_fill_image_height_);
_CP_APPLY_PROP2(draw_color_mode_);
_CP_APPLY_PROP2(draw_contrast_);
_CP_APPLY_PROP2(draw_luminance_);
_CP_APPLY_PROP2(draw_gamma_);
_CP_APPLY_PROP2(draw_red_);
_CP_APPLY_PROP2(draw_green_);
_CP_APPLY_PROP2(draw_blue_);
}
void common_horizontal_margin_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )

View File

@ -111,6 +111,14 @@ public:
_CP_OPT(length_or_percent) draw_fill_image_width_;
_CP_OPT(length_or_percent) draw_fill_image_height_;
_CP_OPT(std::wstring) draw_color_mode_;
_CP_OPT(odf_types::percent) draw_contrast_;
_CP_OPT(odf_types::percent) draw_luminance_;
_CP_OPT(odf_types::percent) draw_gamma_;
_CP_OPT(odf_types::percent) draw_red_;
_CP_OPT(odf_types::percent) draw_green_;
_CP_OPT(odf_types::percent) draw_blue_;
};
// common-horizontal-margin-attlist

View File

@ -475,6 +475,8 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
}
}
}
if ((props.draw_color_mode_) && (*props.draw_color_mode_ == L"greyscale"))
fill.bitmap->bGrayscale = true;
}
if (props.draw_fill_gradient_name_)
{

View File

@ -122,6 +122,10 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
if (draw_fit_to_size_) properties.push_back(_property(L"fit-to-size", *draw_fit_to_size_));
if (draw_fit_to_contour_) properties.push_back(_property(L"fit-to-contour", *draw_fit_to_contour_));
if (common_draw_fill_attlist_.draw_color_mode_)
{
properties.push_back(_property(L"color-mode", *common_draw_fill_attlist_.draw_color_mode_));
}
if (common_padding_attlist_.fo_padding_)
{
properties.push_back(_property(L"text-padding-left", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));

View File

@ -431,8 +431,8 @@ namespace {
// see ECMA-376 page 1768
double pixToSize(double pixels, double maxDigitSize)
{
return (int(( pixels - 5)/ maxDigitSize * 100. + 0.5)) /100. * 0.9;
{
return (int(( pixels /*/ 0.75*/ - 5)/ maxDigitSize * 100. + 0.5)) /100. * 0.9; // * 9525. * 72.0 / (360000.0 * 2.54);
}
double cmToChars (double cm)
{

View File

@ -209,7 +209,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeStar6,
{ L"" , 7}, // shapetypeStar7,
{ L"star8" , 7}, // shapetypeStar8,
{ L"" , 9}, // shapetypeStraightConnector1,
{ L"" , 7}, // shapetypeStraightConnector1,
{ L"striped-right-arrow" , 7}, // shapetypeStripedRightArrow,
{ L"" , 7}, // shapetypeSun,
{ L"" , 7}, // shapetypeSwooshArrow,

View File

@ -203,14 +203,14 @@ public:
_handle h1, h2;
h1.position = L"?f8 ?f13";
h1.y_minimum = L"0";
h1.y_maximum = L"100000";
h1.x_minimum = L"0";
h1.x_maximum = L"100000";
handles.push_back(h1);
h2.position = L"0 ?f5";
h2.x_minimum = L"0";
h2.x_maximum = L"?f1";
h2.y_minimum = L"0";
h2.y_maximum = L"?f1";
handles.push_back(h2);
}
};

View File

@ -33,5 +33,16 @@
namespace cpdoccore
{
class oox_shape_StraightConnector1 : public oox_shape
{
public:
oox_shape_StraightConnector1()
{
odf_type_name =L"ooxml-straightConnector1";
enhanced_path = L"M 0 0 L 21600 21600 N";
view_box = L"0 0 21600 21600";
}
};
}

View File

@ -33,7 +33,6 @@
// shapetypeIrregularSeal1,
// shapetypeIrregularSeal2,
// + // shapetypeSun,
// shapetypeWave,
namespace cpdoccore
{
class oox_shape_sun : public oox_shape

View File

@ -314,7 +314,7 @@ public:
{
odf_type_name =L"ooxml-mathPlus";
enhanced_path = L"?f6 ?f12 L ?f7 ?f12 ?f7 ?f11 ?f8 ?f11 ?f8 ?f12 ?f9 ?f12 ?f9 ?f13 ?f8 ?f13 ?f8 ?f14 ?f7 ?f14 ?f7 ?f13 ?f6 ?f13 Z N";
enhanced_path = L"M ?f6 ?f12 L ?f7 ?f12 ?f7 ?f11 ?f8 ?f11 ?f8 ?f12 ?f9 ?f12 ?f9 ?f13 ?f8 ?f13 ?f8 ?f14 ?f7 ?f14 ?f7 ?f13 ?f6 ?f13 Z N";
text_areas = L"?f6 ?f12 ?f9 ?f13";
view_box = L"0 0 0 0";
modifiers = L"23520";

View File

@ -58,6 +58,7 @@
//+ shapetypeTrapezoid
//+ shapetypeBlockArc
//+ shapetypeDonut
//+ shapetypeFrame
#include "../oox_shape_defines.h"
@ -1590,4 +1591,36 @@ public:
handles.push_back(h1);
}
};
class oox_shape_Frame : public oox_shape
{
public:
oox_shape_Frame()
{
odf_type_name =L"ooxml-frame";
modifiers = L"12500";
enhanced_path = L"M 0 0 L ?f8 0 ?f8 ?f7 0 ?f7 Z M ?f2 ?f2 L ?f2 ?f4 ?f3 ?f4 ?f3 ?f2 Z N";
text_areas = L"?f2 ?f2 ?f3 ?f4";
view_box = L"0 0 0 0";
add(L"f0", L"if(0-$0 ,0,if(50000-$0 ,$0 ,50000))");
add(L"f1", L"min(logwidth,logheight)");
add(L"f2", L"?f1 *?f0 /100000");
add(L"f3", L"logwidth+0-?f2 ");
add(L"f4", L"logheight+0-?f2 ");
add(L"f5", L"logwidth/2");
add(L"f6", L"logheight/2");
add(L"f7", L"logheight");
add(L"f8", L"logwidth");
_handle h2;
h2.position = L"?f2 0";
h2.y_maximum= L"50000";
handles.push_back(h2);
/////////////////////////////////////////////////////////
}
};
}

View File

@ -164,6 +164,10 @@ void draw_g::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
if (!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_ = L"";
//брееед ... иначе либра не показывает группу!!!
common_draw_attlists_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < content_.size(); i++)

View File

@ -394,7 +394,6 @@ namespace odf_writer
CP_XML_ATTR(L"office:version", L"1.2");
CP_XML_NODE(L"office:font-face-decls");
if (content)
{
CP_XML_STREAM() << content->styles_str();

View File

@ -41,6 +41,7 @@
#include "odf_conversion_context.h"
#include "odf_rels.h"
#include "styles.h"
#include "style_paragraph_properties.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
@ -263,33 +264,50 @@ void odf_conversion_context::process_settings(_object & object, bool isRoot)
}
void odf_conversion_context::process_styles(_object & object, bool isRoot)
{
{
create_element(L"office", L"font-face-decls", object.content_styles, this, true);
for (boost::unordered_map<std::wstring, int>::const_iterator it = object.mapFonts.begin(); it != object.mapFonts.end(); ++it)
{
office_element_ptr font_elm;
create_element(L"style", L"font-face", font_elm, this, true);
style_font_face* font = dynamic_cast<style_font_face*>(font_elm.get());
if (font)
{
font->style_name_ = it->first;
font->svg_font_family_ = it->first;
object.content_styles.back()->add_child_element(font_elm);
}
}
object.styles.push_back(object.content_styles.back()); //копия
create_element(L"office", L"styles", object.styles, this, true);//общие стили
object.style_context->process_office_styles(object.styles.back());
page_layout_context()->process_office_styles(object.styles.back());
if (isRoot)
{
create_element(L"office", L"font-face-decls", object.styles, this, true);
create_element(L"office", L"automatic-styles", object.styles, this, true);
object.style_context->process_automatic_for_styles(object.styles.back());
page_layout_context()->process_automatic_for_styles(object.styles.back());
create_element(L"office", L"master-styles", object.styles, this, true);
page_layout_context()->process_master_styles(object.styles.back());
create_element(L"office", L"font-face-decls", object.content_styles, this, true);
page_layout_context()->process_master_styles(object.styles.back());
}
create_element(L"office", L"automatic-styles", object.content_styles, this, true);
object.style_context->process_automatic_styles(object.content_styles.back());
}
office_element_ptr odf_conversion_context::start_tabs()
{
create_element(L"style", L"tab-stops", temporary_.elm, this,true);
create_element(L"style", L"tab-stops", temporary_.elm, this, true);
return temporary_.elm;
}
std::wstring odf_conversion_context::add_image(const std::wstring & image_file_name)
@ -390,5 +408,18 @@ void odf_conversion_context::end_tabs()
temporary_.style_name = L"";
}
void odf_conversion_context::add_font(const std::wstring& font_name)
{
if (objects_.empty())return;
if (objects_[current_object_].mapFonts.find(font_name) == objects_[current_object_].mapFonts.end())
{
objects_[current_object_].mapFonts.insert(std::make_pair(font_name, 1));
}
else
{
objects_[current_object_].mapFonts[font_name]++;
}
}
}
}

View File

@ -76,6 +76,8 @@ class odf_conversion_context : boost::noncopyable
odf_style_context_ptr style_context;
odf_settings_context_ptr settings_context;
_mediaitems mediaitems;
boost::unordered_map<std::wstring, int> mapFonts;
};
public:
@ -85,6 +87,7 @@ public:
virtual ~odf_conversion_context();
void set_fonts_directory(std::wstring pathFonts);
void add_font(const std::wstring & font_name);
virtual void start_document() = 0 ;
virtual void end_document();

View File

@ -191,6 +191,7 @@ struct odf_drawing_state
path_ = L"";
view_box_ = L"";
path_last_command_ = L"";
path_closed_ = false;
replacement_ = L"";
oox_shape_preset_ = -1;
@ -199,7 +200,7 @@ struct odf_drawing_state
in_group_ = false;
text_box_tableframe_= false;
flipH_ = flipV_ = false;
flipH_ = flipV_ = false;
}
std::vector<odf_element_state> elements_;
@ -229,6 +230,7 @@ struct odf_drawing_state
std::wstring path_;
std::wstring view_box_;
std::wstring path_last_command_;
bool path_closed_;
oox_shape_ptr oox_shape_;
//----------------------------------------------------------
int oox_shape_preset_;
@ -385,6 +387,8 @@ void odf_drawing_context::start_group()
//если группа топовая - то данные если не записать - сотруться
if (!impl_->current_drawing_state_.name_.empty())
group->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_name_ = impl_->current_drawing_state_.name_;
else
group->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_name_ = L"";
if (impl_->current_drawing_state_.z_order_ >= 0)
group->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_ = impl_->current_drawing_state_.z_order_;
//if (!impl_->current_drawing_state_.description_.empty())
@ -392,7 +396,6 @@ void odf_drawing_context::start_group()
if (impl_->current_drawing_state_.hidden_)
group->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.drawooo_display_ = L"printer";
impl_->current_drawing_state_.name_ = L"";
impl_->current_drawing_state_.z_order_ = -1;
////////////////////////////////////////////////////////////////////////////////////////
@ -427,6 +430,9 @@ void odf_drawing_context::start_group()
if (group)
{
if ((impl_->anchor_settings_.anchor_type_) && (impl_->anchor_settings_.anchor_type_->get_type() == anchor_type::Page) && level == 0)
impl_->anchor_settings_.anchor_type_ = anchor_type::Paragraph;
group->common_draw_attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_ = impl_->anchor_settings_.anchor_type_;
impl_->anchor_settings_.anchor_type_ = boost::none;
}
@ -844,7 +850,7 @@ bool odf_drawing_context::change_text_box_2_wordart()
if (sz == 2) impl_->root_element_ = draw_elm;
return true;
}
draw_base* s = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_.back().elm.get());
draw_rect* s = dynamic_cast<draw_rect*>(impl_->current_drawing_state_.elements_.back().elm.get());
if (s)
{
//------------------------------------------------------------------------
@ -886,7 +892,7 @@ bool odf_drawing_context::change_text_box_2_wordart()
return true;
}
return true;
return false;
}
void odf_drawing_context::end_shape()
@ -1125,6 +1131,11 @@ void odf_drawing_context::end_shape()
end_element();
}
bool odf_drawing_context::isCustomClosed()
{
return impl_->current_drawing_state_.path_closed_;
}
bool odf_drawing_context::isLineShape()
{
if (impl_->current_level_.empty()) return false;
@ -1149,6 +1160,7 @@ bool odf_drawing_context::isLineShape()
case 49: //SimpleTypes::shapetypeCurvedConnector4:
case 50: //SimpleTypes::shapetypeCurvedConnector5:
case 31: //SimpleTypes::shapetypeBracketPair
case 18: //SimpleTypes::shapetypeArc
return true;
case 1000:
if (impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_.get_value_or(draw_fill(draw_fill::solid)).get_type() == draw_fill::none)
@ -1279,6 +1291,12 @@ void odf_drawing_context::set_opacity(double percent_)
break;
}
}
void odf_drawing_context::set_grayscale()
{
if (!impl_->current_graphic_properties)return;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_color_mode_ = L"greyscale";
}
void odf_drawing_context::set_shadow(int type, std::wstring hexColor, _CP_OPT(double) opacity, double dist_pt, double dist_pt_y )
{
if (!impl_->current_graphic_properties)return;
@ -1450,6 +1468,8 @@ void odf_drawing_context::add_path_element(std::wstring command, std::wstring st
impl_->current_drawing_state_.path_ += strE + L" ";
if (command == L"Z")
impl_->current_drawing_state_.path_closed_ = true;
if (command == L"N")
impl_->current_drawing_state_.path_last_command_.clear();
}
@ -2076,14 +2096,24 @@ void odf_drawing_context::set_line_tail(int type, int len, int width)
impl_->current_graphic_properties->draw_marker_end_ = add_marker_style(type);
switch(width)
if (impl_->current_drawing_state_.svg_width_ && impl_->current_drawing_state_.svg_height_)
{
case 0://lineendwidthLarge
impl_->current_graphic_properties->draw_marker_end_width_ = length(0.4, length::cm); break;
case 1://lineendwidthMedium
impl_->current_graphic_properties->draw_marker_end_width_ = length(0.3, length::cm); break;
case 2://lineendwidthSmall
impl_->current_graphic_properties->draw_marker_end_width_ = length(0.2, length::cm); break;
double sz_x =impl_->current_drawing_state_.svg_width_->get_value_unit(odf_types::length::pt);
double sz_y =impl_->current_drawing_state_.svg_height_->get_value_unit(odf_types::length::pt);
impl_->current_graphic_properties->draw_marker_end_width_ = length((std::max)(sz_x, sz_y) / 10., odf_types::length::pt);
}
if (!impl_->current_graphic_properties->draw_marker_end_width_)
{
switch(width)
{
case 0://lineendwidthLarge
impl_->current_graphic_properties->draw_marker_end_width_ = length(0.4, length::cm); break;
case 1://lineendwidthMedium
impl_->current_graphic_properties->draw_marker_end_width_ = length(0.3, length::cm); break;
case 2://lineendwidthSmall
impl_->current_graphic_properties->draw_marker_end_width_ = length(0.2, length::cm); break;
}
}
}
void odf_drawing_context::set_line_head(int type, int len, int width)
@ -2092,14 +2122,24 @@ void odf_drawing_context::set_line_head(int type, int len, int width)
impl_->current_graphic_properties->draw_marker_start_ = add_marker_style(type);
switch(width)
if (impl_->current_drawing_state_.svg_width_ && impl_->current_drawing_state_.svg_height_)
{
case 0://lineendwidthLarge
impl_->current_graphic_properties->draw_marker_start_width_ = length(0.4, length::cm); break;
case 1://lineendwidthMedium
impl_->current_graphic_properties->draw_marker_start_width_ = length(0.3, length::cm); break;
case 2://lineendwidthSmall
impl_->current_graphic_properties->draw_marker_start_width_ = length(0.2, length::cm); break;
double sz_x =impl_->current_drawing_state_.svg_width_->get_value_unit(odf_types::length::pt);
double sz_y =impl_->current_drawing_state_.svg_height_->get_value_unit(odf_types::length::pt);
impl_->current_graphic_properties->draw_marker_start_width_ = length((std::max)(sz_x, sz_y) / 10., odf_types::length::pt);
}
if (!impl_->current_graphic_properties->draw_marker_start_width_)
{
switch(width)
{
case 0://lineendwidthLarge
impl_->current_graphic_properties->draw_marker_start_width_ = length(0.4, length::cm); break;
case 1://lineendwidthMedium
impl_->current_graphic_properties->draw_marker_start_width_ = length(0.3, length::cm); break;
case 2://lineendwidthSmall
impl_->current_graphic_properties->draw_marker_start_width_ = length(0.2, length::cm); break;
}
}
}

View File

@ -158,6 +158,8 @@ public:
void set_program(std::wstring program);
bool isLineShape();
bool isCustomClosed();
void corrected_line_fill();
office_element_ptr & get_root_element();
@ -224,6 +226,7 @@ public:
//void end_shadow_properties();
// пока одной функией ..
void set_shadow (int type, std::wstring hexColor, _CP_OPT(double) opacity, double dist_pt, double dist_pt_y = -1);
void set_grayscale();
void set_text (odf_text_context* text_context);
void set_textarea_vertical_align(int align);

View File

@ -185,12 +185,12 @@ void odf_table_context::end_table()
//последние объединенные ячейки ..
for (size_t i = 0 ; i < impl_->current_table().columns.size(); i++)
{
impl_->current_table().current_column = i + 1;
impl_->current_table().current_column = (int)i + 1;
set_cell_row_span_restart();
}
for (size_t i = 0 ; i < impl_->current_table().rows.size(); i++)
{
impl_->current_table().current_row = i + 1;
impl_->current_table().current_row = (int)i + 1;
set_cell_column_span_restart();
}
style * style_ = dynamic_cast<style *>(impl_->current_table().table.style_elm.get());
@ -432,7 +432,7 @@ int odf_table_context::count_columns ()
{
if (impl_->empty()) return 0;
return impl_->current_table().columns.size();
return (int)impl_->current_table().columns.size();
}
int odf_table_context::count_rows ()
{
@ -498,7 +498,7 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
table_table_cell * cell = dynamic_cast<table_table_cell *>(state_row.spanned_column_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = state_row.spanned_column_cell.size();
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = (unsigned int)state_row.spanned_column_cell.size();
state_row.spanned_column_cell.clear();
}
@ -511,7 +511,7 @@ void odf_table_context::set_cell_column_span_restart()
int row = impl_->current_table().current_row - 1;
odf_row_state & state = impl_->current_table().rows[row];
int sz = state.spanned_column_cell.size();
unsigned int sz = (unsigned int)state.spanned_column_cell.size();
if (sz > 1)
{
table_table_cell * cell = dynamic_cast<table_table_cell *>(state.spanned_column_cell[0].get());
@ -567,7 +567,7 @@ void odf_table_context::set_cell_row_span_restart()
int col = impl_->current_table().current_column - 1;
odf_column_state & state = impl_->current_table().columns[col];
int sz = state.spanned_row_cell.size();
unsigned int sz = (unsigned int)state.spanned_row_cell.size();
if (sz > 1)
{

View File

@ -328,7 +328,7 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref)
std::vector<std::wstring> ref_cells;
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
if (ref_cells.size() !=2) return;//тута однозначно .. по правилам оох
if (ref_cells.size() != 2) return;//тута однозначно .. по правилам оохml
int start_col = -1, start_row = -1;
int end_col = -1, end_row = -1;
@ -336,20 +336,28 @@ void ods_conversion_context::add_merge_cells(const std::wstring & ref)
utils::parsing_ref (ref_cells[0], start_col, start_row);
utils::parsing_ref (ref_cells[1], end_col, end_row);
current_table().set_merge_cells(start_col,start_row, end_col, end_row);
current_table().set_merge_cells(start_col, start_row, end_col, end_row);
}
void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
{
int col = 0, row = 0;
utils::parsing_ref ( ref, col,row);
int col = 0, row = 0, spanned_rows = 0, spanned_cols = 0;
utils::parsing_ref ( ref, col, row);
if (col > current_table().current_column()+1)
bool bCovered = false;
bool bSpanned = current_table().isSpannedCell(col, row, spanned_cols, spanned_rows);
if (!bSpanned)
{
int repeated = col - current_table().current_column() -1;
bCovered = current_table().isCoveredCell(col, row);
}
if (col > current_table().current_column() + 1)
{
int repeated = col - current_table().current_column() - 1;
current_table().add_default_cell(repeated);
current_table().add_default_cell(repeated);//, bCovered);
}
office_element_ptr style_elm;
@ -360,7 +368,7 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
if ( xfd_style >=0)
{
odf_style_state_ptr style_state;
styles_context()->find_odf_style_state(xfd_style, style_family::TableCell,style_state, false, true);
styles_context()->find_odf_style_state(xfd_style, style_family::TableCell, style_state, false, true);
if (style_state)
{
style_elm = style_state->get_office_element();
@ -376,11 +384,26 @@ void ods_conversion_context::start_cell(std::wstring & ref, int xfd_style)
}
office_element_ptr cell_elm;
create_element(L"table", L"table-cell", cell_elm, this);
if (bCovered)
{
create_element(L"table", L"covered-table-cell", cell_elm, this);
}
else
{
create_element(L"table", L"table-cell", cell_elm, this);
}
current_table().start_cell(cell_elm, style_elm);
current_table().set_cell_format_value(format_value_type);
if (bSpanned)
{
current_table().set_cell_spanned(spanned_cols, spanned_rows);
}
if (!bCovered)
{
current_table().set_cell_format_value(format_value_type);
}
}
void ods_conversion_context::end_cell()
@ -412,12 +435,12 @@ void ods_conversion_context::end_columns()
//add default last column - ЕСЛИ они не прописаны в исходном (1024 - от балды)
//вопрос - если и добавлять то с каким стилем???
//if (current_table().current_column() < 1 )
// add_column(current_table().current_column()+1,1024,0,true);
// add_column(current_table().current_column() + 1,1024, 0, true);
//else
int repeat = (std::max)(current_table().dimension_columns,1024) - current_table().current_column();
int repeat = (std::max)(current_table().dimension_columns, 1024) - current_table().current_column();
if (repeat < 0) repeat = 1;
add_column(current_table().current_column()+1,repeat,0,true);
add_column(current_table().current_column() + 1, repeat, 0, true);
}
void ods_conversion_context::start_rows()
{

View File

@ -259,6 +259,7 @@ void ods_table_context::start_table(office_element_ptr & elm)
void ods_table_context::end_table()
{
state().check_spanned_cells();
}
}

View File

@ -265,7 +265,7 @@ void ods_table_state::add_column(office_element_ptr & elm, unsigned int repeated
ods_element_state state(elm, repeated, style_name, style_elm, defaut_column_width_, current_level_.size());
if (repeated > 10000)repeated = 1024;//????
//if (repeated > 10000) repeated = 1024;//????
current_table_column_ += repeated;
columns_.push_back(state);
@ -344,6 +344,17 @@ void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, o
{
current_table_column_ = 0;
current_table_row_ += repeated;
current_covered_cols_ = 0;
for (size_t i = 0; i < current_covered_rows_.size(); ++i)
{
current_covered_rows_[i].count_rows--;
if (current_covered_rows_[i].count_rows <= 0)
{
current_covered_rows_.erase(current_covered_rows_.begin() + i);
i--;
}
}
current_level_.back()->add_child_element(elm);
@ -373,6 +384,16 @@ void ods_table_state::add_row_repeated()
unsigned int t = rows_.back().repeated;
rows_.back().repeated++;
current_table_row_++;
for (size_t i = 0; i < current_covered_rows_.size(); ++i)
{
current_covered_rows_[i].count_rows--;
if (current_covered_rows_[i].count_rows <= 0)
{
current_covered_rows_.erase(current_covered_rows_.begin() + i);
i--;
}
}
row->table_table_row_attlist_.table_number_rows_repeated_ = rows_.back().repeated;
}
void ods_table_state::set_row_hidden(bool Val)
@ -506,22 +527,24 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
{
current_row_element()->add_child_element(elm);
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
if (cell == NULL)return;
std::wstring style_name;
odf_writer::style* style = dynamic_cast<odf_writer::style*>(style_elm.get());
if (style)style_name = style->style_name_;
else style_name = row_default_cell_style_name_;
if (style) style_name = style->style_name_;
else style_name = row_default_cell_style_name_;
if (style_name.length() > 0 && style_name != get_column_default_cell_style(current_column()))
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
if (cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
{
cell->table_table_cell_attlist_.table_style_name_= style_name;
cell->table_table_cell_attlist_.table_style_name_ = style_name;
}
table_covered_table_cell* covered_cell = dynamic_cast<table_covered_table_cell*>(elm.get());
if (covered_cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
{
covered_cell->table_table_cell_attlist_.table_style_name_ = style_name;
}
ods_cell_state state;
state.empty = true;
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
state.row = current_table_row_; state.col = current_table_column_ + 1;
@ -532,6 +555,9 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
current_table_column_ += state.repeated;
cells_.push_back(state);
cells_size_++;
if (current_covered_cols_ > 0 && covered_cell)
current_covered_cols_--;
}
void ods_table_state::set_cell_format_value(office_value_type::type value_type)
@ -644,40 +670,133 @@ void ods_table_state::end_comment(odf_text_context *text_context)
}
}
void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col, int end_row)
void ods_table_state::check_spanned_cells()
{
//потом можно переделать (оптимизировать) - добавлять мержи при добавлении ячеек
//всяко выгоднее хранить данные о мержах, а не шерстить каждый раз ВСЕ ячейки для добавления фенечки
//todooo
//разобраться когда нужно писать covered_cell
if (end_col - start_col < 0)return;
if (end_row - start_row < 0)return;
int spanned_cols = end_col - start_col + 1;
int spanned_rows = end_row - start_row + 1;
if (spanned_cols > 10000)spanned_cols = 1024;
for (size_t i = 0; i < cells_.size(); ++i)
for (std::map<int, std::map<int, _spanned_info>>::iterator it = map_merged_cells.begin(); it != map_merged_cells.end(); ++it)
{
if (cells_[i].row > end_row) break;
for (std::map<int, _spanned_info>::iterator jt = it->second.begin(); jt != it->second.end(); ++jt)
{
int start_row = it->first;
int end_row = it->first + jt->second.spanned_rows;
if (cells_[i].row >= start_row)
{
if (cells_[i].col >= start_col)
int start_col = jt->first;
int end_col = jt->first + jt->second.spanned_cols;
for (size_t i = 0; i < cells_.size(); ++i)
{
table_table_cell* cell_elm = dynamic_cast<table_table_cell*>(cells_[i].elm.get());
if (cell_elm == NULL)return;
if (cells_[i].row > end_row) break;
cell_elm->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell_elm->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
if (cells_[i].row >= start_row)
{
if (cells_[i].col >= start_col)
{
table_table_cell* cell_elm = dynamic_cast<table_table_cell*>(cells_[i].elm.get());
if (cell_elm == NULL)break;
break;
cell_elm->table_table_cell_attlist_extra_.table_number_columns_spanned_ = jt->second.spanned_cols;
cell_elm->table_table_cell_attlist_extra_.table_number_rows_spanned_ = jt->second.spanned_rows;
break;
}
}
}
}
}
}
void ods_table_state::set_merge_cells(int start_col, int start_row, int end_col, int end_row)
{
if (end_col - start_col < 0) return;
if (end_row - start_row < 0) return;
_spanned_info info;
info.spanned_cols = end_col - start_col + 1;
info.spanned_rows = end_row - start_row + 1;
//if (info.spanned_cols > 10000) info.spanned_cols = 1024;
std::map<int, std::map<int, _spanned_info>>::iterator pFindRow = map_merged_cells.find(start_row);
if (pFindRow == map_merged_cells.end())
{
std::map<int, _spanned_info> mapCols;
mapCols.insert(std::make_pair(start_col, info));
map_merged_cells.insert(std::make_pair(start_row, mapCols));
}
else
{
std::map<int, _spanned_info>::iterator pFindCol = pFindRow->second.find(start_col);
if (pFindCol == pFindRow->second.end())
{
pFindRow->second.insert(std::make_pair(start_col, info));
}
//else нереально pFindCol->second.insert(info);
}
}
bool ods_table_state::isSpannedCell(int col, int row, int &spanned_cols, int &spanned_rows )
{
spanned_cols = spanned_rows = 0;
std::map<int, std::map<int, _spanned_info>>::iterator pFindRow = map_merged_cells.find(row);
if (pFindRow != map_merged_cells.end())
{
std::map<int, _spanned_info>::iterator pFindCol = pFindRow->second.find(col);
if (pFindCol != pFindRow->second.end())
{
spanned_cols = pFindCol->second.spanned_cols;
spanned_rows = pFindCol->second.spanned_rows;
current_covered_cols_ = spanned_cols - 1;
if (spanned_rows > 1 && current_covered_cols_ > 0)
{
_covered_info info;
info.start_col = current_table_column_;
info.count_cols = spanned_cols;
info.count_rows = spanned_rows - 1;
current_covered_rows_.push_back(info);
}
pFindRow->second.erase(pFindCol);
if (pFindRow->second.empty())
{
map_merged_cells.erase(pFindRow);
}
return true;
}
}
return false;
}
bool ods_table_state::isCoveredCell( int col, int repeated_cols)
{
if (current_covered_cols_ > 0) return true;
for (size_t i = 0; i < current_covered_rows_.size(); i++)
{
if (current_covered_rows_[i].start_col <= col && col < current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols)
{
current_covered_cols_ = current_covered_rows_[i].count_cols - (col - current_covered_rows_[i].start_col);
return true;
}
}
return false;
}
void ods_table_state::set_cell_spanned(int spanned_cols, int spanned_rows)
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
}
void ods_table_state::set_cell_formula(std::wstring & formula)
{
if (formula.length() < 1)return;
@ -1070,6 +1189,8 @@ void ods_table_state::end_cell()
void ods_table_state::add_default_cell( unsigned int repeated)
{
if (repeated < 1) return;
int comment_idx = is_cell_comment(current_table_column_ + 1, current_table_row_, repeated);
if (comment_idx >= 0 && repeated > 1)
{
@ -1084,32 +1205,120 @@ void ods_table_state::add_default_cell( unsigned int repeated)
}
//////////////////////////////////////////////////
std::map<int, std::map<int, _spanned_info>>::iterator pFindRow = map_merged_cells.find(current_table_row_);
bool bSpanned = false;
if (pFindRow != map_merged_cells.end())
{
for (std::map<int, _spanned_info>::iterator it = pFindRow->second.begin(); !bSpanned && it != pFindRow->second.end(); ++it)
{
if (it->first < current_table_column_ + repeated + 1 && it->first >= current_table_column_ + 1)
{
if (repeated > 1)
{
//делим на 3 - до, с spanned, после;
int c = current_table_column_;
add_default_cell(it->first - c - 1);
add_default_cell(1);
add_default_cell(repeated + c + 1 - it->first);
return;
}
else
{
bSpanned = true;
break;
}
}
}
}
bool bCovered = false;
if (!bSpanned)
{
for (size_t i = 0; i < current_covered_rows_.size(); i++)
{
if (current_covered_rows_[i].start_col <= current_table_column_ && current_table_column_ + repeated <= current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols)
{
current_covered_cols_ = current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols - current_table_column_;
bCovered = true;
break;
}
else if (!( current_table_column_ + repeated < current_covered_rows_[i].start_col ||
current_table_column_ > current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols))
{
int c = current_table_column_;
int split = current_covered_rows_[i].start_col > current_table_column_ ? current_covered_rows_[i].start_col :
current_covered_rows_[i].start_col + current_covered_rows_[i].count_cols;
if (split != current_table_column_ && split != current_table_column_ + repeated)
{
add_default_cell(split - c);
add_default_cell(repeated + c - split);
return;
}
}
}
}
office_element_ptr default_cell_elm;
create_element(L"table", L"table-cell", default_cell_elm, context_);
if (bCovered)
{
create_element(L"table", L"covered-table-cell", default_cell_elm, context_);
}
else
{
create_element(L"table", L"table-cell", default_cell_elm, context_);
}
current_row_element()->add_child_element(default_cell_elm);
table_table_cell* cell = dynamic_cast<table_table_cell*>(default_cell_elm.get());
if (cell == NULL)return;
table_covered_table_cell* covered_cell = dynamic_cast<table_covered_table_cell*>(default_cell_elm.get());
if (bSpanned)
{
int spanned_rows = 0, spanned_cols = 0;
if (cell && isSpannedCell(current_table_column_, current_table_row_, spanned_cols, spanned_rows))
{
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
}
}
ods_cell_state state;
state.empty = true;
state.elm = default_cell_elm; state.repeated = repeated;
state.row=current_table_row_; state.col =current_table_column_+ 1;
state.elm = default_cell_elm;
state.repeated = repeated;
state.row = current_table_row_;
state.col = current_table_column_ + 1;
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
state.comment_idx = comment_idx;
cells_.push_back(state);
cells_size_++;
current_table_column_+= state.repeated;
current_table_column_ += state.repeated;
cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
if (cell)
{
cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
if (row_default_cell_style_name_.length() > 0)
cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
if (!row_default_cell_style_name_.empty())
cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
}
if (covered_cell)
{
covered_cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
if (!row_default_cell_style_name_.empty())
covered_cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
current_covered_cols_ -= repeated;
}
end_cell();
}
///////////////////////////////////////////////////
@ -1184,18 +1393,18 @@ void ods_table_state::start_conditional_rule(int rule_type)
}
switch(rule_type)
{
case 4: condition->attr_.calcext_value_ = L"contains-text( )"; break;
case 5: condition->attr_.calcext_value_ = L"is-error"; break;
case 6: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 8: condition->attr_.calcext_value_ = L"duplicate"; break;
case 9: condition->attr_.calcext_value_ = L"formula-is()"; break;
case 11: condition->attr_.calcext_value_ = L"not-contains-text( )"; break;
case 12: condition->attr_.calcext_value_ = L"is-no-error"; break;
case 0: condition->attr_.calcext_value_ = L"above-average"; break;
case 1: condition->attr_.calcext_value_ = L"begins-with()"; break;
case 4: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 5: condition->attr_.calcext_value_ = L"is-error"; break;
case 6: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 8: condition->attr_.calcext_value_ = L"duplicate"; break;
case 9: condition->attr_.calcext_value_ = L"formula-is()"; break;
case 11: condition->attr_.calcext_value_ = L"not-contains-text()"; break;
case 12: condition->attr_.calcext_value_ = L"is-no-error"; break;
case 13: condition->attr_.calcext_value_ = L"not-contains-text()"; break;
case 15: condition->attr_.calcext_value_ = L"top-elements()"; break;//bottom-elements ???
case 16: condition->attr_.calcext_value_ = L"unique"; break;
case 0: /*aboveAverage*/
case 1: /*beginsWith*/
case 15: condition->attr_.calcext_value_ = L"top-elements()"; break;//bottom-elements ???
case 16: condition->attr_.calcext_value_ = L"unique"; break;
case 2: /*cellIs*/
default: break;
}
@ -1213,28 +1422,32 @@ void ods_table_state::end_conditional_rule()
void ods_table_state::set_conditional_formula(std::wstring formula)
{
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
if (condition)
{
std::wstring odfFormula = formulas_converter_table.convert_conditional_formula(formula);
if (!condition) return;
std::wstring odfFormula = formulas_converter_table.convert_conditional_formula(formula);
std::wstring operator_;
bool s = false;
if (condition->attr_.calcext_value_)//есть опреатор
{
operator_ = *condition->attr_.calcext_value_;
int f = operator_.find(L"(");
if (f > 0)
{
s= true;
operator_ = operator_.substr(0,operator_.length() - 2);
}
}
condition->attr_.calcext_value_= operator_ + (s ? L"(": L"") + odfFormula + (s ? L")": L"");
std::wstring operator_;
bool s = false;
bool split = false;
operator_ = condition->attr_.calcext_value_.get_value_or(L"");
size_t f_start = operator_.find(L"(");
size_t f_end = operator_.rfind(L")");
if (f_start != std::wstring::npos && f_end != std::wstring::npos)
{
if (f_start < f_end - 1) split = true;
s = true;
operator_ = operator_.substr(0, f_end);
}
operator_ += (split ? L"," : L"") + odfFormula + (s ? L")" : L"");
if (std::wstring::npos == operator_.find(L"contains-text") || !split)
condition->attr_.calcext_value_= operator_;
}
void ods_table_state::set_conditional_style_name(std::wstring style_name)
void ods_table_state::set_conditional_style_name(const std::wstring &style_name)
{
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
calcext_date_is* date_is = dynamic_cast<calcext_date_is*> (current_level_.back().get());
@ -1242,6 +1455,29 @@ void ods_table_state::set_conditional_style_name(std::wstring style_name)
if (condition) condition->attr_.calcext_apply_style_name_ = style_name;
if (date_is) date_is->attr_.calcext_style_ = style_name;
}
void ods_table_state::set_conditional_text(const std::wstring &text)
{
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
if ((condition->attr_.calcext_value_) && (std::wstring::npos != condition->attr_.calcext_value_->find(L"contains-text")))
{
std::wstring operator_;
bool s = false;
bool split = false;
operator_ = *condition->attr_.calcext_value_;
size_t f_start = operator_.find(L"(");
size_t f_end = operator_.rfind(L")");
if (f_start != std::wstring::npos && f_end != std::wstring::npos)
{
if (f_start < f_end - 1) split = true;
s = true;
operator_ = operator_.substr(0, f_end);
}
operator_ += (split ? L"," : L"") + std::wstring(L"\"") + text + L"\"" + (s ? L")" : L"");
condition->attr_.calcext_value_= operator_;
}
}
void ods_table_state::set_conditional_operator(int _operator)
{
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
@ -1249,16 +1485,16 @@ void ods_table_state::set_conditional_operator(int _operator)
{
switch(_operator)
{
case 0: condition->attr_.calcext_value_ = L"begins-with()"; break;
case 1: condition->attr_.calcext_value_ = L"between()"; break;
case 2: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 0: condition->attr_.calcext_value_ = L"begins-with()"; break;
case 1: condition->attr_.calcext_value_ = L"between()"; break;
case 2: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 3: condition->attr_.calcext_value_ = L"ends-with()"; break;
case 4: condition->attr_.calcext_value_ = L"="; break;
case 5: condition->attr_.calcext_value_ = L">"; break;
case 4: condition->attr_.calcext_value_ = L"="; break;
case 5: condition->attr_.calcext_value_ = L">"; break;
case 6: condition->attr_.calcext_value_ = L">="; break;
case 7: condition->attr_.calcext_value_ = L"<"; break;
case 7: condition->attr_.calcext_value_ = L"<"; break;
case 8: condition->attr_.calcext_value_ = L"<="; break;
case 9: condition->attr_.calcext_value_ = L"not-between()"; break;
case 9: condition->attr_.calcext_value_ = L"not-between()"; break;
case 10:condition->attr_.calcext_value_ = L"not-contains-text()"; break;
case 11:condition->attr_.calcext_value_ = L"!="; break;
}

View File

@ -277,16 +277,22 @@ public:
void set_row_default_cell_style(std::wstring & style_name);
void add_row_repeated();
bool isSpannedCell(int col, int row, int &spanned_cols, int &spanned_rows );
bool isCoveredCell(int col, int repeated_cols = 1);
void start_cell(office_element_ptr & elm ,office_element_ptr & style);
void end_cell();
void add_default_cell(unsigned int repeated);
void check_spanned_cells();
void set_cell_format_value(odf_types::office_value_type::type value_type);
void set_cell_type(int type);
void set_cell_value(const std::wstring & value, bool need_cash = false);
void set_cell_text(odf_text_context *text_context, bool cash_value = false);
void set_cell_formula(std::wstring &formula);
void set_cell_array_formula(std::wstring & formula, std::wstring ref);
void set_cell_spanned(int spanned_cols, int spanned_rows);
void add_or_find_cell_shared_formula(std::wstring & formula, std::wstring ref, int ind);
static std::wstring replace_cell_row(boost::wsmatch const & what);
@ -303,8 +309,10 @@ public:
void add_conditional_colorscale(int index, _CP_OPT(odf_types::color) color);
void set_conditional_databar_color(_CP_OPT(odf_types::color) color);
void set_conditional_style_name(std::wstring style_name);
void set_conditional_style_name(const std::wstring &style_name);
void set_conditional_operator(int _operator);
void set_conditional_text(const std::wstring &text);
void end_conditional_rule();
void end_conditional_format();
void end_conditional_formats();
@ -349,13 +357,28 @@ public:
std::vector<ods_comment_state> comments_;
private:
struct _spanned_info
{
int spanned_cols = 0;
int spanned_rows = 0;
int state = 0;
};
struct _covered_info
{
int start_col = 0;
int count_cols = 0;
int count_rows = 0; // от текущей строки
};
std::vector<_covered_info> current_covered_rows_;
int current_covered_cols_;
odf_conversion_context * context_;
office_element_ptr office_table_;
style* office_table_style_;//??? может хранить как office_element_ptr ???
office_element_ptr table_defined_expressions_;
std::wstring row_default_cell_style_name_;
static int current_table_column_;
@ -366,6 +389,8 @@ private:
std::vector<ods_element_state> columns_;
std::vector<ods_element_state> rows_;
std::map<int, std::map<int, _spanned_info>> map_merged_cells;
std::vector<office_element_ptr> current_level_;//постоянно меняющийся список уровней ("0-й элемент - сама таблица)

View File

@ -136,7 +136,8 @@ oox_shape_ptr oox_shape::create(int ooxPrstGeomType)
case SimpleTypes::shapetypeBentUpArrow: return boost::make_shared<oox_shape_BentUpArrow>();
case SimpleTypes::shapetypeLeftRightUpArrow: return boost::make_shared<oox_shape_leftRightUpArrow>();
//case SimpleTypes::shapetypeStraightConnector1: return boost::make_shared<oox_shape_straightConnector1>();
case SimpleTypes::shapetypeStraightConnector1: return boost::make_shared<oox_shape_StraightConnector1>();
case SimpleTypes::shapetypeFrame: return boost::make_shared<oox_shape_Frame>();
//case (2001 + SimpleTypes::textshapetypeTextArchDown):
//case (2001 + SimpleTypes::textshapetypeTextArchDownPour):
//case (2001 + SimpleTypes::textshapetypeTextArchUp):

View File

@ -1371,5 +1371,85 @@ void style_presentation_page_layout::serialize(std::wostream & strm)
}
}
}
//-------------------------------------------------------------------------------------------------
const wchar_t * office_font_face_decls::ns = L"office";
const wchar_t * office_font_face_decls::name = L"font-face-decls";
void office_font_face_decls::add_child_element( const office_element_ptr & child)
{
content_.push_back(child);
}
void office_font_face_decls::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"style", L"font-face")
{
CP_CREATE_ELEMENT(content_);
}
}
void office_font_face_decls::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE_SIMPLE()
{
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
const wchar_t * style_font_face::ns = L"style";
const wchar_t * style_font_face::name = L"font-face";
void style_font_face::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"style:name", style_name_);
CP_XML_ATTR_OPT(L"style:font-adornments", style_font_adornments_);
CP_XML_ATTR_OPT(L"style:font-family-generic", style_font_family_generic_);
CP_XML_ATTR_OPT(L"style:font-pitch", style_font_pitch_);
CP_XML_ATTR_OPT(L"style:font-charset", style_font_charset_);
CP_XML_ATTR_OPT(L"svg:font-family", svg_font_family_);
CP_XML_ATTR_OPT(L"svg:font-style", svg_font_style_);
CP_XML_ATTR_OPT(L"svg:font-variant", svg_font_variant_);
CP_XML_ATTR_OPT(L"svg:font-weight", svg_font_weight_);
CP_XML_ATTR_OPT(L"svg:font-stretch", svg_font_stretch_);
CP_XML_ATTR_OPT(L"svg:font-size", svg_font_size_);
CP_XML_ATTR_OPT(L"svg:unicode-range", svg_unicode_range_);
CP_XML_ATTR_OPT(L"svg:units-per-em", svg_units_per_em_);
CP_XML_ATTR_OPT(L"svg:panose-1", svg_panose_1_);
CP_XML_ATTR_OPT(L"svg:stemv", svg_stemv_);
CP_XML_ATTR_OPT(L"svg:stemh", svg_stemh_);
CP_XML_ATTR_OPT(L"svg:slope", svg_slope_);
CP_XML_ATTR_OPT(L"svg:cap-height", svg_cap_height_);
CP_XML_ATTR_OPT(L"svg:x-height", svg_x_height_);
CP_XML_ATTR_OPT(L"svg:accent-height", svg_accent_height_);
CP_XML_ATTR_OPT(L"svg:ascent", svg_ascent_);
CP_XML_ATTR_OPT(L"svg:descent", svg_descent_);
CP_XML_ATTR_OPT(L"svg:widths", svg_widths_);
CP_XML_ATTR_OPT(L"svg:bbox", svg_bbox_);
CP_XML_ATTR_OPT(L"svg:ideographic", svg_ideographic_);
CP_XML_ATTR_OPT(L"svg:alphabetic", svg_alphabetic_);
CP_XML_ATTR_OPT(L"svg:mathematical", svg_mathematical_);
CP_XML_ATTR_OPT(L"svg:hanging", svg_hanging_);
CP_XML_ATTR_OPT(L"svg:v-ideographic", svg_v_ideographic_);
CP_XML_ATTR_OPT(L"svg:v-alphabetic", svg_v_alphabetic_);
CP_XML_ATTR_OPT(L"svg:v-mathematical", svg_v_mathematical_);
CP_XML_ATTR_OPT(L"svg:v-hanging", svg_v_hanging_);
CP_XML_ATTR_OPT(L"svg:underline-position", svg_underline_position_);
CP_XML_ATTR_OPT(L"svg:underline-thickness", svg_underline_thickness_);
CP_XML_ATTR_OPT(L"svg:strikethrough-position", svg_strikethrough_position_);
CP_XML_ATTR_OPT(L"svg:strikethrough-thickness", svg_strikethrough_thickness_);
CP_XML_ATTR_OPT(L"svg:overline-position", svg_overline_position_);
CP_XML_ATTR_OPT(L"svg:overline-thickness", svg_overline_thickness_);
}
}
}
}
}

View File

@ -60,6 +60,12 @@
#include "noteclass.h"
#include "gradientstyle.h"
#include "hatchstyle.h"
#include "fontstyle.h"
#include "fontvariant.h"
#include "fontweight.h"
#include "fontstretch.h"
#include "fontfamilygeneric.h"
#include "fontpitch.h"
#include "common_attlists.h"
@ -864,5 +870,87 @@ CP_REGISTER_OFFICE_ELEMENT2(style_presentation_page_layout)
//----------------------------------------------------------------------------------------------------
// style:font-face
class style_font_face : public office_element_impl<style_font_face>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleFontFace;
CPDOCCORE_DEFINE_VISITABLE();
virtual void serialize(std::wostream & strm);
virtual void create_child_element ( const std::wstring & Ns, const std::wstring & Name){}
virtual void add_child_element ( const office_element_ptr & child){}
//todooo <svg:definition-src> and <svg:font-face-src>
_CP_OPT(std::wstring) style_name_;
_CP_OPT(std::wstring) style_font_adornments_;
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_;
_CP_OPT(odf_types::font_pitch) style_font_pitch_;
_CP_OPT(std::wstring) style_font_charset_;
_CP_OPT(std::wstring) svg_font_family_;
_CP_OPT(odf_types::font_style) svg_font_style_;
_CP_OPT(odf_types::font_variant) svg_font_variant_;
_CP_OPT(odf_types::font_weight) svg_font_weight_;
_CP_OPT(odf_types::font_stretch) svg_font_stretch_;
_CP_OPT(odf_types::length) svg_font_size_;
_CP_OPT(std::wstring) svg_unicode_range_;
_CP_OPT(int) svg_units_per_em_;
_CP_OPT(std::wstring) svg_panose_1_;
_CP_OPT(int) svg_stemv_;
_CP_OPT(int) svg_stemh_;
_CP_OPT(int) svg_slope_;
_CP_OPT(int) svg_cap_height_;
_CP_OPT(int) svg_x_height_;
_CP_OPT(int) svg_accent_height_;
_CP_OPT(int) svg_ascent_;
_CP_OPT(int) svg_descent_;
_CP_OPT(std::wstring) svg_widths_;
_CP_OPT(std::wstring) svg_bbox_;
_CP_OPT(int) svg_ideographic_;
_CP_OPT(int) svg_alphabetic_;
_CP_OPT(int) svg_mathematical_;
_CP_OPT(int) svg_hanging_;
_CP_OPT(int) svg_v_ideographic_;
_CP_OPT(int) svg_v_alphabetic_;
_CP_OPT(int) svg_v_mathematical_;
_CP_OPT(int) svg_v_hanging_;
_CP_OPT(int) svg_underline_position_;
_CP_OPT(int) svg_underline_thickness_;
_CP_OPT(int) svg_strikethrough_position_;
_CP_OPT(int) svg_strikethrough_thickness_;
_CP_OPT(int) svg_overline_position_;
_CP_OPT(int) svg_overline_thickness_;
office_element_ptr_array svg_font_face_uri_;
office_element_ptr_array svg_font_face_name_;
office_element_ptr svg_definition_src_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_font_face);
// office-font-face-decls
class office_font_face_decls : public office_element_impl<office_font_face_decls>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficeFontFaceDecls;
CPDOCCORE_DEFINE_VISITABLE();
virtual void serialize(std::wostream & strm);
virtual void create_child_element ( const std::wstring & Ns, const std::wstring & Name);
virtual void add_child_element ( const office_element_ptr & child);
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(office_font_face_decls);
}
}

View File

@ -372,8 +372,14 @@ void OoxConverter::convert(PPTX::Logic::Pic *oox_picture)
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->t.get_value_or(L"0")) * Height /100. / 96.,
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->r.get_value_or(L"0")) * Width /100. / 96.,
XmlUtils::GetInteger(oox_picture->blipFill.srcRect->b.get_value_or(L"0")) * Height /100. / 96.);
}
}
if (oox_picture->blipFill.blip.IsInit())
{
for (size_t i = 0 ; i < oox_picture->blipFill.blip->Effects.size(); i++)
{
convert(oox_picture->blipFill.blip->Effects[i].Effect.operator->());
}
}
OoxConverter::convert(&oox_picture->nvPicPr.cNvPr);
OoxConverter::convert(&oox_picture->spPr, oox_picture->style.GetPointer());
@ -691,8 +697,8 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
bool bLine = odf_context()->drawing_context()->isLineShape();
//if (custGeom && !custGeom->cxnLst.empty())
// bLine = true;
if (custGeom && !custGeom->cxnLst.empty() && !odf_context()->drawing_context()->isCustomClosed())
bLine = true;
odf_context()->drawing_context()->start_area_properties();
{
@ -892,6 +898,17 @@ void OoxConverter::convert(PPTX::Logic::SoftEdge *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::Grayscl *oox_effect)
{
if (oox_effect == NULL) return;
odf_context()->drawing_context()->set_grayscale();
}
void OoxConverter::convert(PPTX::Logic::Duotone *oox_effect)
{
if (oox_effect == NULL) return;
}
void OoxConverter::convert(PPTX::Logic::InnerShdw *oox_shadow)
{
@ -1892,18 +1909,27 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
PPTX::Logic::GradFill* gradFill = NULL;
PPTX::Logic::SolidFill* solidFill = NULL;
if (oox_run_pr->Fill.is<PPTX::Logic::GradFill>())
if (oox_run_pr->ln.is_init())
{
drawing->start_line_properties(true);
if (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() == OOX::et_a_solidFill )
{
solidFill = &oox_run_pr->ln->Fill.as<PPTX::Logic::SolidFill>();
}
}
if (!solidFill && oox_run_pr->Fill.is<PPTX::Logic::GradFill>())
{
gradFill = &oox_run_pr->Fill.as<PPTX::Logic::GradFill>();
}
else if (!solidFill && oox_run_pr->Fill.is<PPTX::Logic::SolidFill>())
{
solidFill = &oox_run_pr->Fill.as<PPTX::Logic::SolidFill>();
}
if (gradFill && !gradFill->GsLst.empty())
{
convert(&gradFill->GsLst[0].color, hexColorText, opacityText);
}
if (oox_run_pr->Fill.is<PPTX::Logic::SolidFill>())
{
solidFill = &oox_run_pr->Fill.as<PPTX::Logic::SolidFill>();
}
if (solidFill)
{
convert(&solidFill->Color, hexColorText, opacityText);

View File

@ -62,6 +62,8 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Pic.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/AlphaModFix.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Grayscl.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Effects/Duotone.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
@ -477,6 +479,14 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
{
convert(dynamic_cast<PPTX::Logic::SoftEdge*>(oox_unknown));
}break;
case OOX::et_a_grayscl:
{
convert(dynamic_cast<PPTX::Logic::Grayscl*>(oox_unknown));
}break;
case OOX::et_a_duotone:
{
convert(dynamic_cast<PPTX::Logic::Duotone*>(oox_unknown));
}break;
case OOX::et_a_effectDag:
{
convert(dynamic_cast<PPTX::Logic::EffectDag*>(oox_unknown));

View File

@ -341,6 +341,8 @@ namespace PPTX
class Glow;
class Reflection;
class SoftEdge;
class Grayscl;
class Duotone;
}
}
@ -468,6 +470,8 @@ public:
void convert(PPTX::Logic::Glow *oox_effect);
void convert(PPTX::Logic::Reflection *oox_effect);
void convert(PPTX::Logic::SoftEdge *oox_effect);
void convert(PPTX::Logic::Grayscl *oox_effect);
void convert(PPTX::Logic::Duotone *oox_effect);
//.chart............................................................................................................................
void convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart);
void convert(OOX::Spreadsheet::CT_Title *ct_title);

View File

@ -297,6 +297,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
ods_context->end_columns();
//мержи
for (size_t mrg = 0 ; oox_sheet->m_oMergeCells.IsInit() && mrg < oox_sheet->m_oMergeCells->m_arrItems.size(); mrg++)
{
if (oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.IsInit())
ods_context->add_merge_cells(oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.get());
}
//строки
if (oox_sheet->m_oSheetData.IsInit() )
{
@ -313,12 +319,6 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
oox_sheet->m_oSheetData.reset();
}
//мержи
for (size_t mrg = 0 ; oox_sheet->m_oMergeCells.IsInit() && mrg < oox_sheet->m_oMergeCells->m_arrItems.size(); mrg++)
{
if (oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.IsInit())
ods_context->add_merge_cells(oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.get());
}
if (oox_sheet->m_oDrawing.IsInit() && oox_sheet->m_oDrawing->m_oId.IsInit())
{
smart_ptr<OOX::File> oFile = oox_sheet->Find(oox_sheet->m_oDrawing->m_oId->GetValue());
@ -1480,6 +1480,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont *font, odf_writer::style_tex
if ((font->m_oStrike.IsInit()) && (font->m_oStrike->m_oVal.ToBool()))
text_properties->content_.style_text_line_through_type_ = odf_types::line_type(odf_types::line_type::Single);
ods_context->add_font(font_name);
ods_context->calculate_font_metrix(font_name, font_size, font_italic, font_bold);
}
@ -1504,12 +1505,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFill * fill, odf_writer::style_ta
convert(fill->m_oPatternFill->m_oFgColor.GetPointer(),
cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_);
}
else if (fill->m_oPatternFill->m_oBgColor.IsInit())
if (fill->m_oPatternFill->m_oBgColor.IsInit() && !cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_)
{
convert(fill->m_oPatternFill->m_oBgColor.GetPointer(),
cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_);
}
else if (fill->m_oPatternFill->m_oPatternType.IsInit())
if (fill->m_oPatternFill->m_oPatternType.IsInit() && !cell_properties->style_table_cell_properties_attlist_.common_background_color_attlist_.fo_background_color_)
{
switch(fill->m_oPatternFill->m_oPatternType->GetValue())
{
@ -1765,12 +1766,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
if(color->m_oThemeColor.IsInit() && xlsx_document->m_pTheme.IsInit())
{
DWORD argb = xlsx_document->m_pTheme->themeElements.clrScheme.GetARGBFromScheme(color->m_oThemeColor->ToString());
DWORD bgra = xlsx_document->m_pTheme->themeElements.clrScheme.GetARGBFromScheme(color->m_oThemeColor->ToString());
ucR = (argb & 0x0000FF);
ucB = (argb & 0x00FF00) >> 8;
ucG = (argb & 0xFF0000) >> 16;
ucA = argb >> 24;
ucB = (bgra & 0x0000FF);
ucG = (bgra & 0x00FF00) >> 8;
ucR = (bgra & 0xFF0000) >> 16;
ucA = bgra >> 24;
result = true;
}
@ -2268,9 +2269,12 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co
}
if (oox_cond_rule->m_oOperator.IsInit())
ods_context->current_table().set_conditional_operator(oox_cond_rule->m_oOperator->GetValue());
if (oox_cond_rule->m_oText.IsInit())
ods_context->current_table().set_conditional_text(oox_cond_rule->m_oText.get2());
for (size_t i=0; i< oox_cond_rule->m_arrItems.size(); i++)
convert(oox_cond_rule->m_arrItems[i]);
for (size_t i=0; i< oox_cond_rule->m_arrItems.size(); i++)
convert(oox_cond_rule->m_arrItems[i]);
}
ods_context->current_table().end_conditional_rule();
}

View File

@ -144,7 +144,10 @@ namespace _graphics_utils_
}
double calculate_size_symbol_asc(std::wstring name, double size, bool italic, bool bold , NSFonts::IApplicationFonts *appFonts)
{
std::pair<float,float> val = cpdoccore::utils::GetMaxDigitSizePixels(name, size, 96., 0 , appFonts);
if (name.empty())
name = L"Arial";
std::pair<float,float> val = cpdoccore::utils::GetMaxDigitSizePixels(name, size, 96., 0 , appFonts);
return val.first;
}

View File

@ -2015,7 +2015,7 @@ void CPPTUserInfo::LoadNoMainMaster(_UINT32 dwMasterID)
if (pGroup)
{
LoadGroupShapeContainer(pGroup, NULL, NULL, pLayout, pThemeWrapper, pMasterWrapper);
LoadGroupShapeContainer(pGroup, NULL, pTheme, pLayout, pThemeWrapper, pMasterWrapper);
}
else
{

View File

@ -377,6 +377,10 @@
RelativePath="..\..\XlsxSerializerCom\Writer\CSVWriter.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\BinReader\CustormXmlWriter.cpp"
>
</File>
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\DocxSerializer.cpp"
>

View File

@ -98,6 +98,8 @@ namespace PPTX
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
pReader->Skip(4); // len
BYTE _type = pReader->GetUChar();
LONG _e = pReader->GetPos() + pReader->GetLong() + 4;
ULONG count = pReader->GetULong();

View File

@ -100,6 +100,8 @@ namespace PPTX
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
pReader->Skip(4); // len
BYTE _type = pReader->GetUChar();
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes

View File

@ -126,6 +126,8 @@ namespace PPTX
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
pReader->Skip(4); // len
BYTE _type = pReader->GetUChar();
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes

View File

@ -147,8 +147,17 @@ namespace PPTX
{
std::map<std::wstring, Logic::UniColor>::const_iterator pPair = Scheme.find(str);
if (Scheme.end() == pPair)
return 0;
return pPair->second.GetARGB();
{//default color map extension
if (str == L"tx1") pPair = Scheme.find(L"dk1");
else if (str == L"tx2") pPair = Scheme.find(L"dk2");
else if (str == L"bg1") pPair = Scheme.find(L"lt1");
else if (str == L"bg2") pPair = Scheme.find(L"lt1");
if (Scheme.end() == pPair) return 0;
else return pPair->second.GetARGB();
}
else
return pPair->second.GetARGB();
}
virtual DWORD GetBGRAFromScheme(const std::wstring& str)const
{

View File

@ -56,6 +56,8 @@ SOURCES += \
../Source/XlsxFormat/Xlsx.cpp \
../Source/XlsxFormat/Worksheets/Worksheet.cpp \
../Source/XlsxFormat/Worksheets/SheetData.cpp \
../Source/DocxFormat/App.cpp \
../Source/DocxFormat/Core.cpp \
../Source/DocxFormat/FileFactory.cpp \
../Source/DocxFormat/IFileContainer.cpp \
../Source/XlsxFormat/FileFactory_Spreadsheet.cpp \

View File

@ -51,6 +51,8 @@
#include "../Source/DocxFormat/Media/VbaProject.cpp"
#include "../Source/DocxFormat/Media/JsaProject.cpp"
#include "../Source/DocxFormat/Docx.cpp"
#include "../Source/DocxFormat/App.cpp"
#include "../Source/DocxFormat/Core.cpp"
#include "../Source/DocxFormat/FileFactory.cpp"
#include "../Source/DocxFormat/IFileContainer.cpp"
#include "../Source/DocxFormat/Drawing/DrawingExt.cpp"

View File

@ -5428,6 +5428,14 @@
RelativePath="..\Source\DocxFormat\File.h"
>
</File>
<File
RelativePath="..\Source\DocxFormat\App.cpp"
>
</File>
<File
RelativePath="..\Source\DocxFormat\Core.cpp"
>
</File>
<File
RelativePath="..\Source\DocxFormat\FileFactory.cpp"
>

View File

@ -2008,6 +2008,14 @@
RelativePath="..\Source\DocxFormat\File.h"
>
</File>
<File
RelativePath="..\Source\DocxFormat\App.cpp"
>
</File>
<File
RelativePath="..\Source\DocxFormat\Core.cpp"
>
</File>
<File
RelativePath="..\Source\DocxFormat\FileFactory.cpp"
>

View File

@ -558,6 +558,14 @@
<ClCompile Include="..\Source\DocxFormat\Docx.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ClCompile Include="..\Source\DocxFormat\App.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ClCompile Include="..\Source\DocxFormat\Core.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<ClCompile Include="..\Source\DocxFormat\FileFactory.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">/bigobj %(AdditionalOptions)</AdditionalOptions>

View File

@ -811,6 +811,8 @@
<Filter>VectorML</Filter>
</ClCompile>
<ClCompile Include="..\Source\DocxFormat\Docx.cpp" />
<ClCompile Include="..\Source\DocxFormat\App.cpp" />
<ClCompile Include="..\Source\DocxFormat\Core.cpp" />
<ClCompile Include="..\Source\DocxFormat\FileFactory.cpp" />
<ClCompile Include="..\Source\DocxFormat\IFileContainer.cpp" />
</ItemGroup>

View File

@ -0,0 +1,92 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "App.h"
#include "../XlsxFormat/Xlsx.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/App.h"
namespace OOX
{
CApp::CApp(OOX::Document* pMain) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pApp = this;
OOX::Spreadsheet::CXlsx* xlsx = dynamic_cast<OOX::Spreadsheet::CXlsx*>(File::m_pMainDocument);
if (xlsx) xlsx->m_pApp = this;
}
CApp::CApp(OOX::Document* pMain, const CPath& oPath) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pApp = this;
OOX::Spreadsheet::CXlsx* xlsx = dynamic_cast<OOX::Spreadsheet::CXlsx*>(File::m_pMainDocument);
if (xlsx) xlsx->m_pApp = this;
read( oPath );
}
PPTX::App* CApp::ToPptxApp()
{
PPTX::App* res = new PPTX::App(NULL);
if(m_sTemplate.IsInit())
res->Template = m_sTemplate.get();
if(m_nTotalTime.IsInit())
res->TotalTime = m_nTotalTime.get();
if(m_nWords.IsInit())
res->Words = m_nWords.get();
if(m_sApplication.IsInit())
res->Application = m_sApplication.get();
if(m_sPresentationForm.IsInit())
res->PresentationFormat = m_sPresentationForm.get();
if(m_nParagraphs.IsInit())
res->Paragraphs = m_nParagraphs.get();
if(m_nSlides.IsInit())
res->Slides = m_nSlides.get();
if(m_nNotes.IsInit())
res->Notes = m_nNotes.get();
if(m_nHiddenSlides.IsInit())
res->HiddenSlides = m_nHiddenSlides.get();
if(m_nMMClips.IsInit())
res->MMClips = m_nMMClips.get();
if(m_bScaleCrop.IsInit())
res->ScaleCrop = m_bScaleCrop.get();
if(m_sCompany.IsInit())
res->Company = m_sCompany.get();
if(m_bLinksUpToDate.IsInit())
res->LinksUpToDate = m_bLinksUpToDate.get();
if(m_bSharedDoc.IsInit())
res->SharedDoc = m_bSharedDoc.get();
if(m_bHyperlinksChanged.IsInit())
res->HyperlinksChanged = m_bHyperlinksChanged.get();
if(m_sAppVersion.IsInit())
res->AppVersion = m_sAppVersion.get();
return res;
}
} // namespace OOX

View File

@ -40,23 +40,17 @@
#include "../Common/SimpleTypes_Shared.h"
#include "../../../../DesktopEditor/common/SystemUtils.h"
namespace PPTX
{
class App;
}
namespace OOX
{
class CApp : public OOX::File
{
public:
CApp(OOX::Document* pMain) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pApp = this;
}
CApp(OOX::Document* pMain, const CPath& oPath) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pApp = this;
read( oPath );
}
CApp(OOX::Document* pMain);
CApp(OOX::Document* pMain, const CPath& oPath);
virtual ~CApp()
{
}
@ -465,6 +459,8 @@ namespace OOX
{
m_bHyperlinksChanged = bVal;
}
PPTX::App* ToPptxApp();
// TO DO: DigSig
// HeadingPairs
// HLinks

View File

@ -0,0 +1,72 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "Core.h"
#include "../XlsxFormat/Xlsx.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Core.h"
namespace OOX
{
CCore::CCore(OOX::Document* pMain) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pCore = this;
//OOX::Spreadsheet::CXlsx* xlsx = dynamic_cast<OOX::Spreadsheet::CXlsx*>(File::m_pMainDocument);
//if (xlsx) xlsx->m_pCore = this;
}
CCore::CCore(OOX::Document* pMain, const CPath& oPath) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pCore = this;
//OOX::Spreadsheet::CXlsx* xlsx = dynamic_cast<OOX::Spreadsheet::CXlsx*>(File::m_pMainDocument);
//if (xlsx) xlsx->m_pCore = this;
read( oPath );
}
PPTX::Core* CCore::ToPptxCore()
{
PPTX::Core* res = new PPTX::Core(NULL);
if (m_sTitle.IsInit())
res->title = m_sTitle.get();
if (m_sCreator.IsInit())
res->creator = m_sCreator.get();
if (m_sLastModifiedBy.IsInit())
res->lastModifiedBy = m_sLastModifiedBy.get();
if (m_sRevision.IsInit())
res->revision = m_sRevision.get();
if (m_sCreated.IsInit())
res->created = m_sCreated.get();
if (m_sModified.IsInit())
res->modified = m_sModified.get();
return res;
}
} // namespace OOX

View File

@ -37,23 +37,17 @@
#include "File.h"
#include "../Base/Nullable.h"
namespace PPTX
{
class Core;
}
namespace OOX
{
class CCore : public OOX::File
{
public:
CCore(OOX::Document* pMain) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pCore = this;
}
CCore(OOX::Document* pMain, const CPath& oPath) : OOX::File(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pCore = this;
read( oPath );
}
CCore(OOX::Document* pMain);
CCore(OOX::Document* pMain, const CPath& oPath);
virtual ~CCore()
{
}
@ -254,6 +248,7 @@ namespace OOX
{
m_sLastModifiedBy = sVal;
}
PPTX::Core* ToPptxCore();
nullable<std::wstring> m_sCategory;
nullable<std::wstring> m_sContentStatus;

View File

@ -42,6 +42,9 @@
namespace OOX
{
class CApp;
class CCore;
namespace Spreadsheet
{
class CWorksheet;
@ -85,6 +88,9 @@ namespace OOX
}
smart_ptr<PPTX::Theme> m_pTheme;
CApp* m_pApp;
CCore* m_pCore;
CWorkbook* m_pWorkbook;
CSharedStrings* m_pSharedStrings;
CStyles* m_pStyles;
@ -102,6 +108,9 @@ namespace OOX
{
m_bSpreadsheets = true;
m_pApp = NULL;
m_pCore = NULL;
m_pWorkbook = NULL;
m_pSharedStrings = NULL;
m_pStyles = NULL;

View File

@ -1 +1 @@
2.4.551.0
2.4.553.0

View File

@ -782,5 +782,6 @@
#define ASC_MENU_EVENT_TYPE_ADVANCED_OPTIONS 22000
#define ASC_MENU_EVENT_TYPE_SET_PASSWORD 22001
#define ASC_MENU_EVENT_TYPE_SET_TRANSLATIONS 22002
#endif //_BUILD_EDITOR_DEFINES_CROSSPLATFORM_H_

View File

@ -155,7 +155,7 @@ namespace MetaFile
if (lLogicalFontHeight < 0.01)
lLogicalFontHeight = 18;
double dFontHeight = fabs(lLogicalFontHeight * m_dScaleY * m_pFile->GetPixelHeight() / 25.4 * 72);
double dFontHeight = fabs(lLogicalFontHeight * m_dScaleY / 25.4 * 72);
std::wstring wsFaceName = pFont->GetFaceName();
m_pRenderer->put_FontName(wsFaceName);
@ -682,10 +682,9 @@ namespace MetaFile
return false;
int nColor = pPen->GetColor();
double dPixelWidth = m_pFile->GetPixelWidth();
// TODO: dWidth зависит еще от флага PS_GEOMETRIC в стиле карандаша
double dWidth = pPen->GetWidth() * m_dScaleX * dPixelWidth;
double dWidth = pPen->GetWidth() * m_dScaleX;
if (dWidth <= 0.01)
dWidth = 0;
@ -711,7 +710,7 @@ namespace MetaFile
else if (PS_JOIN_MITER == ulPenJoin)
nJoinStyle = Aggplus::LineJoinMiter;
double dMiterLimit = m_pFile->GetMiterLimit() * m_dScaleX * dPixelWidth;
double dMiterLimit = m_pFile->GetMiterLimit() * m_dScaleX;
// TODO: Реализовать PS_USERSTYLE
BYTE nDashStyle = Aggplus::DashStyleSolid;;
@ -719,7 +718,12 @@ namespace MetaFile
// В WinGDI все карандаши толщиной больше 1px рисуются в стиле PS_SOLID
if (1 >= pPen->GetWidth() && PS_SOLID != ulPenStyle)
{
dWidth = 0; // Специальное значение для 1pх карандаша
// TODO: Ранее здесь специально ставилась толщина 0, что любой рендерер должен
// воспринимать как толщину в 1px. Но сейчас это не работает в графическом ренедерере,
// поэтому временно это убрано.
// Толщиной в 1px - именно так рисуется в винде любая пунктирная линия в метафайле.
//dWidth = 0; // Специальное значение для 1pх карандаша
double dDpiX;
m_pRenderer->get_DpiX(&dDpiX);

View File

@ -79,7 +79,9 @@ namespace BinXlsxRW
Styles = 2,
Workbook = 3,
Worksheets = 4,
CalcChain = 5
CalcChain = 5,
App = 6,
Core = 7
};}
namespace c_oSerStylesTypes{enum c_oSerStylesTypes

View File

@ -48,6 +48,8 @@
#include "../../ASCOfficeDocxFile2/DocWrapper/FontProcessor.h"
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/App.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/Core.h"
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
@ -55,6 +57,8 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/WorkbookComments.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
namespace BinXlsxRW
{
@ -4874,6 +4878,20 @@ namespace BinXlsxRW
if( (oXlsx.m_pStyles) && oXlsx.m_pStyles->m_oColors.IsInit() && oXlsx.m_pStyles->m_oColors->m_oIndexedColors.IsInit())
pIndexedColors = oXlsx.m_pStyles->m_oColors->m_oIndexedColors.operator ->();
if(oXlsx.m_pApp)
{
nCurPos = this->WriteTableStart(c_oSerTableTypes::App);
oXlsx.m_pApp->ToPptxApp()->toPPTY(&oBufferedStream);
this->WriteTableEnd(nCurPos);
}
if(oXlsx.m_pCore)
{
nCurPos = this->WriteTableStart(c_oSerTableTypes::Core);
oXlsx.m_pCore->ToPptxCore()->toPPTY(&oBufferedStream);
this->WriteTableEnd(nCurPos);
}
if(oXlsx.m_pSharedStrings)
{
nCurPos = WriteTableStart(c_oSerTableTypes::SharedStrings);

View File

@ -72,17 +72,22 @@
namespace BinXlsxRW
{
#define SEEK_TO_POS_START(type) \
nPos = aSeekPositions[2 * type - 1]; \
length = aSeekPositions[2 * type]; \
if (nPos > 0) \
pFind = mapPos.find(type); \
if (pFind != mapPos.end()) \
{ \
m_oBufferedStream.Seek(nPos); \
for (size_t i = 0; i < pFind->second.size() - 1; i+=2) \
{ \
nPos = pFind->second[i]; \
length = pFind->second[i + 1]; \
m_oBufferedStream.Seek(nPos); \
#define SEEK_TO_POS_END(elem) \
elem.toXML(oStreamWriter); \
elem.toXML(oStreamWriter); \
} \
}
#define SEEK_TO_POS_END2() \
} \
}
class ImageObject
@ -2571,10 +2576,8 @@ namespace BinXlsxRW
m_lObjectIdVML = m_pCurVmlDrawing->m_lObjectIdVML = (long)(1024 * (m_oWorkbook.m_oSheets->m_arrItems.size() + 1) + 1);
//todo bigger then last int c_oSerWorksheetsTypes::
_UINT32 aSeekPositions[2 * 256];
memset(aSeekPositions, 0, (2 * 256) * sizeof(_UINT32));
READ1_DEF(length, res, this->ReadWorksheetSeekPositions, aSeekPositions);
boost::unordered_map<BYTE, std::vector<unsigned int>> mapPos;
READ1_DEF(length, res, this->ReadWorksheetSeekPositions, &mapPos);
m_pCurWorksheet->m_bWriteDirectlyToFile = true;
m_oWorkbook.AssignOutputFilename(oCurWorksheetFile);
@ -2584,7 +2587,7 @@ namespace BinXlsxRW
NSFile::CStreamWriter oStreamWriter;
oStreamWriter.CreateFileW(sWsPath);
m_pCurStreamWriter = &oStreamWriter;
res = ReadWorksheet(aSeekPositions, oStreamWriter, poResult);
res = ReadWorksheet(mapPos, oStreamWriter, poResult);
oStreamWriter.CloseFile();
if(m_pCurSheet->m_oName.IsInit())
@ -2606,16 +2609,28 @@ namespace BinXlsxRW
}
int ReadWorksheetSeekPositions(BYTE type, long length, void* poResult)
{
_UINT32* aSeekPositions = static_cast<_UINT32*>(poResult);
aSeekPositions[2 * type - 1] = m_oBufferedStream.GetPos();
aSeekPositions[2 * type] = length;
boost::unordered_map<BYTE, std::vector<unsigned int>>* mapPos = static_cast<boost::unordered_map<BYTE, std::vector<unsigned int>>*>(poResult);
boost::unordered_map<BYTE, std::vector<unsigned int>>::iterator pFind = mapPos->find(type);
if(pFind != mapPos->end())
{
pFind->second.push_back(m_oBufferedStream.GetPos());
pFind->second.push_back(length);
}
else
{
std::vector<unsigned int> data;
data.push_back(m_oBufferedStream.GetPos());
data.push_back(length);
(*mapPos)[type] = data;
}
return c_oSerConstants::ReadUnknown;
}
int ReadWorksheet(_UINT32* aSeekPositions, NSFile::CStreamWriter& oStreamWriter, void* poResult)
int ReadWorksheet(boost::unordered_map<BYTE, std::vector<unsigned int>>& mapPos, NSFile::CStreamWriter& oStreamWriter, void* poResult)
{
int res = c_oSerConstants::ReadOk;
m_pCurWorksheet->toXMLStart(oStreamWriter);
LONG nOldPos = m_oBufferedStream.GetPos();
boost::unordered_map<BYTE, std::vector<unsigned int>>::iterator pFind;
LONG nPos;
LONG length;
SEEK_TO_POS_START(c_oSerWorksheetsTypes::SheetPr);