Compare commits

..

10 Commits

Author SHA1 Message Date
e15c75b6aa add sha-256 hash agrorithm 2018-02-05 13:52:29 +03:00
b2fb7f0fe7 . 2018-02-05 12:52:24 +03:00
410e5ebd75 . 2018-02-05 12:11:35 +03:00
9c57088ef1 RtfFormatWriter - add application property for info
OdfFormatWriter - ods - fix theme color in font
2018-02-03 18:55:49 +03:00
24230e12a3 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-02-02 18:26:11 +03:00
2acef0d4a2 . 2018-02-02 18:25:30 +03:00
aca5ffa36f add standard priority to "Wingdings" font-family 2018-02-02 16:58:10 +03:00
4fc3726f37 fix read strict ooxml textbox (namespace wne) 2018-02-02 15:08:11 +03:00
2682e1fbac Ooxml - fix vml image without image 2018-02-02 14:52:15 +03:00
f5c3ae779b . 2018-02-02 13:59:58 +03:00
22 changed files with 357 additions and 173 deletions

View File

@ -82,11 +82,11 @@ void chart_chart::add_child_element( xml::sax * Reader, const std::wstring & Ns,
{
if CP_CHECK_NAME(L"text", L"tracked-changes")
{
CP_CREATE_ELEMENT(tracked_changes_);
//CP_CREATE_ELEMENT(tracked_changes_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
//CP_CREATE_ELEMENT(content_validations_);
}
else
CP_CREATE_ELEMENT(content_);

View File

@ -313,25 +313,25 @@ void odf_number_styles_context::create_default(int oox_num_fmt, std::wstring for
default:
/////////////////////////////////// с неопределенным formatCode .. он задается в файле
if (oox_num_fmt >=5 && oox_num_fmt <=8)state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=43 && oox_num_fmt <=44)state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=5 && oox_num_fmt <=8) state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=43 && oox_num_fmt <=44) state.ods_type =office_value_type::Currency;
if (oox_num_fmt >=27 && oox_num_fmt <=31)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=50 && oox_num_fmt <=54)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=57 && oox_num_fmt <=58)state.ods_type =office_value_type::Date;
if (oox_num_fmt ==36)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=27 && oox_num_fmt <=31) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=50 && oox_num_fmt <=54) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=57 && oox_num_fmt <=58) state.ods_type =office_value_type::Date;
if (oox_num_fmt ==36) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=32 && oox_num_fmt <=35)state.ods_type =office_value_type::Time;
if (oox_num_fmt >=55 && oox_num_fmt <=56)state.ods_type =office_value_type::Time;
if (oox_num_fmt >=32 && oox_num_fmt <=35) state.ods_type =office_value_type::Time;
if (oox_num_fmt >=55 && oox_num_fmt <=56) state.ods_type =office_value_type::Time;
if (oox_num_fmt >=60 && oox_num_fmt <=62)state.ods_type =office_value_type::Float;
if (oox_num_fmt >=69 && oox_num_fmt <=70)state.ods_type =office_value_type::Float;
if (oox_num_fmt >=60 && oox_num_fmt <=62) state.ods_type =office_value_type::Float;
if (oox_num_fmt >=69 && oox_num_fmt <=70) state.ods_type =office_value_type::Float;
if (oox_num_fmt >=67 && oox_num_fmt <=68)state.ods_type =office_value_type::Percentage;
if (oox_num_fmt >=67 && oox_num_fmt <=68) state.ods_type =office_value_type::Percentage;
if (oox_num_fmt >=71 && oox_num_fmt <=74)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=75 && oox_num_fmt <=80)state.ods_type =office_value_type::Time;
if (oox_num_fmt ==81)state.ods_type =office_value_type::Date;
if (oox_num_fmt >=71 && oox_num_fmt <=74) state.ods_type =office_value_type::Date;
if (oox_num_fmt >=75 && oox_num_fmt <=80) state.ods_type =office_value_type::Time;
if (oox_num_fmt ==81) state.ods_type =office_value_type::Date;
}
boost::algorithm::split(state.format_code, formatCode, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
@ -402,53 +402,122 @@ void odf_number_styles_context::create_number_style(number_format_state & state,
{
office_element_ptr elm;
create_numbers(state, elm);
root_elm->add_child_element(elm);
create_numbers(state, elm, root_elm);
}
}
void odf_number_styles_context::create_numbers(number_format_state & state, office_element_ptr & elm)
void odf_number_styles_context::create_numbers(number_format_state & state, office_element_ptr & elm, office_element_ptr & root_elm)
{
optional< int>::Type min_digit, min_decimal;
create_element(L"number", L"number", elm, odf_context_);
styles_elments.push_back(elm);
office_element_ptr elm_text;
number_number* number_number_ = dynamic_cast<number_number*>(elm.get());
if (!number_number_) return;
if (number_number_)
bool bText = false;
int indText = -1;
int indNumber = -1;
if (state.format_code[0].empty())
{
if (state.format_code[0].length()>0)
//формат не определен .. дефолтный
min_digit =1;
}
else
{
std::vector<std::wstring> splits;
boost::algorithm::split(splits, state.format_code[0], boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < splits.size(); i++)
{
std::wstring str1,str2;
boost::wregex re1(L"([^0-9.,]+)");
boost::wsmatch result;
boost::wregex re2(L"([^#.,]+)");
str1 = boost::regex_replace(state.format_code[0], re1, L"",boost::match_default | boost::format_all);
str2 = boost::regex_replace(state.format_code[0], re2, L"",boost::match_default | boost::format_all);
if (str1.length()<str2.length())str1=str2;
std::vector<std::wstring> numbers;
boost::algorithm::split(numbers, str1, boost::algorithm::is_any_of(L".,"), boost::algorithm::token_compress_on);
int ind=1;//
for (size_t i = 0;i < numbers.size(); i++)
if (std::wstring::npos != splits[i].find(L"\""))
{
if (numbers[i].length()<1)continue;
if (ind==1)min_digit= numbers[i].length();
if (ind==2)min_decimal= numbers[i].length();
ind++;
bText = true;
indText = i;
break;
}
}
for (size_t i = 0; i < splits.size(); i++)
{
if (i != indText)
{
indNumber = i;
break;
}
}
std::wstring str1,str2;
boost::wregex re1(L"([^0-9.,]+)");
boost::wsmatch result;
boost::wregex re2(L"([^#.,]+)");
str1 = boost::regex_replace(splits[indNumber], re1, L"", boost::match_default | boost::format_all);
str2 = boost::regex_replace(splits[indNumber], re2, L"", boost::match_default | boost::format_all);
if (str1.length() < str2.length()) str1 = str2;
std::vector<std::wstring> numbers;
boost::algorithm::split(numbers, str1, boost::algorithm::is_any_of(L".,"), boost::algorithm::token_compress_on);
int ind = 1;//
for (size_t i = 0; i < numbers.size(); i++)
{
if (numbers[i].empty())continue;
if (ind == 1) min_digit= numbers[i].length();
if (ind == 2) min_decimal= numbers[i].length();
ind++;
}
if (bText && root_elm)
{
int res1 = (int) splits[indText].find(L"\"");
int res2 = (int) splits[indText].find(L"\"", res1 + 1);
if (res2 > 0)
{
std::wstring text = splits[indText].substr(res1 + 1, res2 - res1 - 1);
if (!text.empty())
{
if (indText < indNumber) text = text + L" ";
else text = L" " + text;
create_element(L"number", L"text", elm_text, odf_context_);
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
if (number_text_)
number_text_->add_text(text);
}
}
}
}
number_number_->number_min_integer_digits_ = min_digit;
number_number_->number_decimal_places_ = min_decimal;
if (root_elm)
{
if (bText)
{
number_number_->number_grouping_ = true;
if (indText < indNumber)
{
root_elm->add_child_element(elm_text);
root_elm->add_child_element(elm);
}
else
{
root_elm->add_child_element(elm);
root_elm->add_child_element(elm_text);
}
}
else
{
//формат не определен .. дефолтный
min_digit =1;
root_elm->add_child_element(elm);
}
number_number_->number_min_integer_digits_= min_digit;
number_number_->number_decimal_places_= min_decimal;
//number_number_->number_grouping_ = true;
}
}
void odf_number_styles_context::create_percentage_style(number_format_state & state, office_element_ptr & root_elm)
@ -457,7 +526,8 @@ void odf_number_styles_context::create_percentage_style(number_format_state & st
office_element_ptr elm;
create_numbers(state, elm);
office_element_ptr empty;
create_numbers(state, elm, empty);
root_elm->add_child_element(elm);
create_element(L"number", L"text", elm, odf_context_);
@ -472,9 +542,9 @@ void odf_number_styles_context::create_currency_style(number_format_state & stat
{
create_element(L"number", L"currency-style", root_elm, odf_context_);
{
int res1= state.format_code[0].rfind(L"]");
int res2= state.format_code[0].rfind(L"#");
int res3= state.format_code[0].rfind(L"0");
int res1 = state.format_code[0].rfind(L"]");
int res2 = state.format_code[0].rfind(L"#");
int res3 = state.format_code[0].rfind(L"0");
office_element_ptr elm_symbol;
create_element(L"number", L"currency-symbol", elm_symbol, odf_context_);
@ -485,7 +555,7 @@ void odf_number_styles_context::create_currency_style(number_format_state & stat
{
std::wstring number_country,number_language;
for (long i=0; state.language_code >0 && i < sizeof(LanguageCodeTable)/sizeof(def_language_code); i++)
for (long i = 0; state.language_code > 0 && i < sizeof(LanguageCodeTable)/sizeof(def_language_code); i++)
{
if (LanguageCodeTable[i].id == state.language_code)
{
@ -507,11 +577,12 @@ void odf_number_styles_context::create_currency_style(number_format_state & stat
}
///////////////////
office_element_ptr elm_number;
create_numbers(state, elm_number);
office_element_ptr empty;
create_numbers(state, elm_number, empty);
//////////////////////////////////////////
office_element_ptr elm_text;
create_element(L"number", L"text", elm_text, odf_context_);
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
number_text* number_text_ = dynamic_cast<number_text*>(elm_text.get());
if (number_text_)number_text_->add_text(L" ");
styles_elments.push_back(elm_text);
////////////////////////////////////////////
@ -595,7 +666,7 @@ void odf_number_styles_context::create_date_style(number_format_state & state, o
}
else
{ //////////////////// делитель ////////////////////
if(sz>1)
if(sz > 1)
{
//выкинем "лишние" слэши
XmlUtils::replace_all( s, L"\\", L"");
@ -671,7 +742,7 @@ void odf_number_styles_context::create_time_style(number_format_state & state, o
else if((res=s.find(L"pm")) <0)//так уж формат делится .. а этот текст нам не нужен
{
//////////////////// делитель ////////////////////
if(sz>1)
if(sz > 1)
{
//выкинем "лишние" слэши
XmlUtils::replace_all( s, L"\\", L"");
@ -701,14 +772,14 @@ void odf_number_styles_context::create_text_style(number_format_state & state, o
void odf_number_styles_context::detect_format(number_format_state & state)
{
if (state.ods_type != office_value_type::Custom)return;
if (state.format_code.size()<1)return;
if (state.format_code.empty())return;
//find [$<Currency String>-<language info>].
boost::wregex re(L"(?:\\[)(?:\\$)(\\S+)?\-(\\S+)(?:\\])");
boost::wsmatch result;
bool b = boost::regex_search(state.format_code[0], result, re);
if (b && result.size()==3)
if (b && result.size() == 3)
{
state.currency_str=result[1];
int code = -1;
@ -721,48 +792,58 @@ void odf_number_styles_context::detect_format(number_format_state & state)
//state.format_code[0] = boost::regex_replace( state.format_code[0],re,L"");
}
if (state.currency_str.length()>0)
if (!state.currency_str.empty() && state.language_code != 0xF400 && state.language_code != 0xF800)
{
state.ods_type = office_value_type::Currency;
return;
}
std::wstring tmp = state.format_code[0];
XmlUtils::GetLower(tmp);
if (state.format_code.size() == 1)//any
//if (state.format_code.size() == 2)//>0, <0
//{
//}
//else if (state.format_code.size() == 3)//>0, <0, ==0
//{
//}
if (state.format_code.size() > 0) //any
{
int res=0;
if ((res=tmp.find(L"at"))>=0 || (res=tmp.find(L"pm"))>=0 ||
(res=tmp.find(L"h"))>=0 || (res=tmp.find(L"s"))>=0 || state.language_code == 0xF400)
std::wstring tmp = state.format_code[0];
XmlUtils::GetLower(tmp);
if (std::wstring::npos != tmp.find(L"at") ||
std::wstring::npos != tmp.find(L"pm") ||
std::wstring::npos != tmp.find(L"h") ||
std::wstring::npos != tmp.find(L"s") || state.language_code == 0xF400)
{
state.ods_type = office_value_type::Time;
if (b)state.format_code[0] = boost::regex_replace( state.format_code[0],re,L"");
if (b)
state.format_code[0] = boost::regex_replace( state.format_code[0], re, L"");
return;
}
if ((res=tmp.find(L"y"))>=0 || (res=tmp.find(L"d"))>=0 || (res=tmp.find(L"m"))>=0)//minutes отсеялись выше
if (std::wstring::npos != tmp.find(L"y") ||
std::wstring::npos != tmp.find(L"d") ||
std::wstring::npos != tmp.find(L"m") || state.language_code == 0xF800)//minutes отсеялись выше
{
state.ods_type = office_value_type::Date;
if (b)state.format_code[0] = boost::regex_replace( state.format_code[0],re,L"");
if (b)
state.format_code[0] = boost::regex_replace( state.format_code[0], re, L"");
return;
}
if ((res=tmp.find(L"%"))>=0)
if (std::wstring::npos != tmp.find(L"%"))
{
state.ods_type = office_value_type::Percentage;
return;
}
state.ods_type = office_value_type::Float;
return;
if (std::wstring::npos != tmp.find(L"#") ||
std::wstring::npos != tmp.find(L"?") ||
std::wstring::npos != tmp.find(L"0"))
{
state.ods_type = office_value_type::Float;
return;
}
}
else if (state.format_code.size() == 2)//>0, <0
{
}
else if (state.format_code.size() == 3)//>0, <0, ==0
{
}
///////////////////////////////
}
}
}

View File

@ -93,7 +93,7 @@ private:
void create_text_style (number_format_state & state, office_element_ptr & root_elm);
void create_percentage_style(number_format_state & state, office_element_ptr & root_elm);
void create_numbers(number_format_state & state, office_element_ptr & elm);
void create_numbers(number_format_state & state, office_element_ptr & elm, office_element_ptr & root_elm);
};

View File

@ -556,7 +556,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCell *oox_cell)
int ifx_style = oox_cell->m_oStyle.IsInit() ? oox_cell->m_oStyle->GetValue() : -1;
ods_context->start_cell(ref,ifx_style);
ods_context->start_cell(ref, ifx_style);
int value_type = -1;//not defined
if (oox_cell->m_oType.IsInit())
@ -1636,7 +1636,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
{
if (!color)return;
unsigned char ucA=0, ucR=0, ucG=0, ucB=0;
unsigned char ucA = 0, ucR =0, ucG =0, ucB = 0;
bool result = false;
if(color->m_oRgb.IsInit())//easy, faster,realy !!
@ -1648,18 +1648,18 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
result = true;
}
if(color->m_oThemeColor.IsInit())
if(color->m_oThemeColor.IsInit() && xlsx_document->m_pTheme.IsInit())
{
std::wstring sColor = color->m_oThemeColor->ToString();
DWORD argb = 0;
result = OoxConverter::convert(sColor, argb) ;
DWORD argb = 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;
result = true;
}
if(color->m_oIndexed.IsInit())
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->m_pStyles;

View File

@ -3986,8 +3986,19 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
nullable_string sRid;
oNodeFill.ReadAttributeBase(L"r:id", sRid);
if (sRid.is_init())
{
PPTX::Logic::BlipFill* pBlipFill = new PPTX::Logic::BlipFill();
{
PPTX::Logic::BlipFill* pBlipFill = NULL;
if (pPicture)
{
pBlipFill = &pPicture->blipFill;
}
else
{
pBlipFill = new PPTX::Logic::BlipFill();
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
pBlipFill->m_namespace = L"a";
pBlipFill->blip = new PPTX::Logic::Blip();
pBlipFill->blip->embed = new OOX::RId(*sRid);
@ -4000,9 +4011,6 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
{
pBlipFill->stretch = new PPTX::Logic::Stretch();
}
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
nullable_string sRotate;
oNodeFill.ReadAttributeBase(L"rotate", sRotate);
@ -4129,7 +4137,19 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
nullable_string sType;
oNodeFillID.ReadAttributeBase(L"type", sType);
PPTX::Logic::BlipFill* pBlipFill = new PPTX::Logic::BlipFill();
PPTX::Logic::BlipFill* pBlipFill = NULL;
if (pPicture)
{
pBlipFill = &pPicture->blipFill;
}
else
{
pBlipFill = new PPTX::Logic::BlipFill();
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
pBlipFill->m_namespace = L"a";
pBlipFill->blip = new PPTX::Logic::Blip();
@ -4181,51 +4201,50 @@ void CDrawingConverter::CheckBrushShape(PPTX::Logic::SpTreeElem* oElem, XmlUtils
else
pBlipFill->srcRect->b = str0;
}
if (pShape)
{
pSpPr->Fill.m_type = PPTX::Logic::UniFill::blipFill;
pSpPr->Fill.Fill = pBlipFill;
}
if (pPicture)
{
pSpPr->Fill.m_type = PPTX::Logic::UniFill::notInit;
pPicture->blipFill = *pBlipFill;
}
}
}
}
// default params
if (!pSpPr->Fill.Fill.is_init())
if (pPicture)
{
if (pPPTShape->IsWordArt())
{
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a";
pSpPr->Fill.m_type = PPTX::Logic::UniFill::notInit;
pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pSpPr->Fill.Fill = pNoFill;
if (false == pPicture->blipFill.blip.is_init())
{//MSF_Lec3-4.docx
oElem->InitElem(NULL);
}
else
}
else
{
// default params for fill shape
if (!pSpPr->Fill.Fill.is_init())
{
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(0xFF, 0xFF, 0xFF);
pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pSpPr->Fill.Fill = pSolid;
if (sOpacity.is_init())
if (pPPTShape->IsWordArt())
{
BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
PPTX::Logic::ColorModifier oMod;
oMod.name = L"alpha";
int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA;
pSolid->Color.Color->Modifiers.push_back(oMod);
PPTX::Logic::NoFill* pNoFill = new PPTX::Logic::NoFill();
pNoFill->m_namespace = L"a";
pSpPr->Fill.m_type = PPTX::Logic::UniFill::noFill;
pSpPr->Fill.Fill = pNoFill;
}
else
{
PPTX::Logic::SolidFill* pSolid = new PPTX::Logic::SolidFill();
pSolid->m_namespace = L"a";
pSolid->Color.Color = new PPTX::Logic::SrgbClr();
pSolid->Color.Color->SetRGB(0xFF, 0xFF, 0xFF);
pSpPr->Fill.m_type = PPTX::Logic::UniFill::solidFill;
pSpPr->Fill.Fill = pSolid;
if (sOpacity.is_init())
{
BYTE lAlpha = NS_DWC_Common::getOpacityFromString(*sOpacity);
PPTX::Logic::ColorModifier oMod;
oMod.name = L"alpha";
int nA = (int)(lAlpha * 100000.0 / 255.0);
oMod.val = nA;
pSolid->Color.Color->Modifiers.push_back(oMod);
}
}
}
}

View File

@ -288,7 +288,7 @@ namespace PPTX
}
else if (7 == _at)//OleObject Binary FileName (bin, xls, doc, ... other stream file)
{
m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
std::wstring strOlePath = pReader->GetString2();
m_OleObjectFile->set_filename(strOlePath, false); //temp !!! for ImageManager original file name
}
@ -297,8 +297,9 @@ namespace PPTX
}
if (m_sData.IsInit() && m_OleObjectFile.IsInit() == false)
m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
{
m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
}
BYTE embedded_type = 0;
@ -874,7 +875,7 @@ namespace PPTX
if(oleObject.IsInit() && blipFill.blip.IsInit())
{
if (oleObject->m_OleObjectFile.IsInit() == false)
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);
@ -958,7 +959,7 @@ namespace PPTX
if (oleObject->m_OleObjectFile.IsInit() == false)
{
oleObject->m_OleObjectFile = new OOX::OleObject(false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile = new OOX::OleObject(NULL, false, pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX);
oleObject->m_OleObjectFile->set_filename (blipFill.blip->oleFilepathBin, false);
oleObject->m_OleObjectFile->set_filename_cache (blipFill.blip->oleFilepathImage);

View File

@ -47,7 +47,6 @@ namespace PPTX
public:
PPTX_LOGIC_BASE(ThemeElements)
public:
virtual void fromXML(XmlUtils::CXmlNode& node)
{
clrScheme = node.ReadNode(_T("a:clrScheme"));
@ -117,7 +116,6 @@ namespace PPTX
pReader->Seek(_end_rec);
}
public:
ClrScheme clrScheme;
FontScheme fontScheme;
FmtScheme fmtScheme;

View File

@ -67,10 +67,11 @@ public:
{
oParam.oRtf->m_oInformation.m_nNumberOfCharactersWithSpace = m_ooxApp->m_nCharactersWithSpaces.get2();
}
if(m_ooxApp->m_sAppVersion.IsInit())
if (m_ooxApp->m_sApplication.IsInit())
{
oParam.oRtf->m_oInformation.m_nVersion= Strings::ToInteger( m_ooxApp->m_sAppVersion.get2() );
}
oParam.oRtf->m_oInformation.m_sApplication = m_ooxApp->m_sApplication.get2();
}
return true;
}

View File

@ -1571,7 +1571,7 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapePtr& pOutput)
if( m_ooxGroup->grpSpPr.xfrm.IsInit())
{
double rot = m_ooxGroup->grpSpPr.xfrm->rot.get() / 60000.;
double rot = m_ooxGroup->grpSpPr.xfrm->rot.IsInit() ? m_ooxGroup->grpSpPr.xfrm->rot.get() / 60000. : 0.;
if (rot > 0.01)
pOutput->m_nRotation = (int)(rot * 65535);

View File

@ -2917,10 +2917,10 @@ std::wstring RtfInformation::RenderToRtf(RenderParameter oRenderParameter)
{
sResult += L"{\\comment "; sResult += RtfChar::renderRtfText( m_sComment, oRenderParameter.poDocument ); sResult += L"}";
}
if( PROP_DEF != m_nVersion )
sResult += L"{\\version" + std::to_wstring(m_nVersion) + L"}";
if( !m_sDocCom.empty() )
{
sResult += L"{\\doccomm "; sResult += RtfChar::renderRtfText( m_sDocCom, oRenderParameter.poDocument ); sResult += L"}";
}
if( !m_sDocCom.empty() )
{
sResult += L"{\\doccomm "; sResult += RtfChar::renderRtfText( m_sDocCom, oRenderParameter.poDocument ); sResult += L"}";
@ -2978,6 +2978,21 @@ std::wstring RtfInformation::RenderToRtf(RenderParameter oRenderParameter)
if( PROP_DEF != m_nInternalId )
sResult += L"{\\id" + std::to_wstring(m_nInternalId) + L"}";
m_sApplication = L"ONLYOFFICE";
#if defined(INTVER)
std::string s = VALUE2STR(INTVER);
m_sApplication += L"/" + std::wstring(s.begin(), s.end());
#endif
if( !m_sApplication.empty() )
{
sResult += L"{\\*\\userprops ";
sResult += L"{\\propname Application}";
sResult += L"\\proptype30";
sResult += L"{\\staticval " + RtfChar::renderRtfText( m_sApplication, oRenderParameter.poDocument ) + L"}";
sResult += L"}";
}
if( !sResult.empty() )
sResult = L"{\\info" + sResult + L"}";
return sResult;

View File

@ -2926,6 +2926,9 @@ public:
std::wstring m_sComment;
std::wstring m_sDocCom;
std::wstring m_sLinkBase;
std::wstring m_sApplication;
RtfTime m_oCreateTime;
RtfTime m_oRevTime;
RtfTime m_oPrintTime;

View File

@ -47,6 +47,8 @@ namespace OOX
std::wstring sName = oReader.GetName();
if ( _T("mc:Choice") == sName )
{
ReadAttributes(oReader, m_oChoiceRequires);
CRun altRun(oReader);
for ( size_t i = 0; i < altRun.m_arrItems.size(); ++i)
@ -62,6 +64,11 @@ namespace OOX
}
else if ( _T("mc:Fallback") == sName )
{
if (m_oChoiceRequires.is_init() && !m_arrChoiceItems.empty())
{
continue; // не зачем баласт читать - берем более современную или оригинальную версию.
}
CRun altRun(oReader);
for ( size_t i = 0; i < altRun.m_arrItems.size(); ++i)

View File

@ -83,9 +83,17 @@ namespace OOX
{
return OOX::et_mc_alternateContent;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader, nullable_string & oRequires)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, (L"Requires"), oRequires )
WritingElement_ReadAttributes_End( oReader )
}
nullable_string m_oChoiceRequires;
std::vector<WritingElement *> m_arrChoiceItems;
std::vector<WritingElement *> m_arrFallbackItems;
std::vector<WritingElement *> m_arrChoiceItems;
std::vector<WritingElement *> m_arrFallbackItems;
};
} // namespace Words
} // namespace OOX

View File

@ -132,9 +132,9 @@ namespace OOX
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"w:txbxContent" == sName )
if ( L"txbxContent" == sName) //namespaces w & wne
m_oTxtbxContent = oReader;
}
}

View File

@ -2454,9 +2454,9 @@ namespace OOX
int nCurDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = oReader.GetName();
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("w:txbxContent") == sName )
if ( L"txbxContent" == sName ) //namespaces w & wne
m_oTxtbxContent = oReader;
}
}

View File

@ -312,9 +312,26 @@ namespace SimpleTypes
}
return this->m_eValue;
}
virtual std::wstring ToString () const
virtual std::wstring ToString () const
{
return _T("0");
switch(this->m_eValue)
{
case themecolorLight1: return L"lt1";
case themecolorDark1: return L"dk1";
case themecolorLight2: return L"lt2";
case themecolorDark2: return L"dk2";
case themecolorAccent1: return L"accent1";
case themecolorAccent2: return L"accent2";
case themecolorAccent3: return L"accent3";
case themecolorAccent4: return L"accent4";
case themecolorAccent5: return L"accent5";
case themecolorAccent6: return L"accent6";
case themecolorHyperlink: return L"hlink";
case themecolorFollowedHyperlink: return L"folHlink";
default:
return L"";
}
return _T("");
}
SimpleType_FromString (EThemeColor)

View File

@ -621,6 +621,7 @@ namespace NSCommon
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Nirmala UI", 20));
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Batang", 21));
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"MS Mincho", 22));
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Wingdings", 23));
CApplicationFontsSymbols oApplicationChecker;

View File

@ -7,6 +7,7 @@
#define OOXML_HASH_ALG_SHA1 0
#define OOXML_HASH_ALG_INVALID 1
#define OOXML_HASH_ALG_SHA256 2
#define OPEN_SSL_WARNING_OK 0
#define OPEN_SSL_WARNING_ERR 1

View File

@ -206,11 +206,15 @@ public:
return sReturn;
}
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlgS)
{
if (nAlg == OOXML_HASH_ALG_INVALID)
if (nAlgS == OOXML_HASH_ALG_INVALID)
return "";
int nAlg = nAlgS;
if ((nAlg == OOXML_HASH_ALG_SHA256) && !IsWindowsVistaOrGreater())
nAlg = OOXML_HASH_ALG_SHA1;
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
@ -222,7 +226,7 @@ public:
bResult = (NULL != m_context) ? CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL) : FALSE;
if (!bResult)
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, (nAlg == OOXML_HASH_ALG_SHA256) ? PROV_RSA_AES : PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
if (!bResult)
return "";
@ -400,10 +404,27 @@ private:
{
case OOXML_HASH_ALG_SHA1:
return CALG_SHA1;
case OOXML_HASH_ALG_SHA256:
return CALG_SHA_256;
default:
return CALG_SHA1;
}
}
bool IsWindowsVistaOrGreater()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_VISTA);
osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA);
osvi.wServicePackMajor = 0;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
};
#endif // _XMLSIGNER_MSCRYPTO_H_

View File

@ -255,6 +255,20 @@ public:
return sReturn;
}
else if (nAlg == OOXML_HASH_ALG_SHA256)
{
unsigned char obuf[32];
SHA256(pData, (size_t)nSize, obuf);
char* pBase64_hash = NULL;
int nBase64Len_hash = 0;
NSFile::CBase64Converter::Encode(obuf, 32, pBase64_hash, nBase64Len_hash, NSBase64::B64_BASE64_FLAG_NOCRLF);
std::string sReturn(pBase64_hash, nBase64Len_hash);
delete [] pBase64_hash;
return sReturn;
}
return "";
}

View File

@ -509,7 +509,7 @@ namespace NExtractTools
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
return m_oCXlsxSerializer.saveToFile (sTo, sXlsxDir, bXmlOptions ? params.getXmlOptions() : L"") ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return m_oCXlsxSerializer.saveToFile (sTo, sXlsxDir, bXmlOptions ? params.getXmlOptions() : L"");
}
// xslx -> xslt
@ -572,7 +572,7 @@ namespace NExtractTools
if(SUCCEEDED_X2T(nRes))
{
nRes = m_oCXlsxSerializer.loadFromFile (sTargetBin, sTo, sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
nRes = m_oCXlsxSerializer.loadFromFile (sTargetBin, sTo, sXmlOptions, sMediaPath, sEmbedPath);
}
//удаляем EditorWithChanges, потому что он не в Temp
if (sFrom != sTargetBin)
@ -1002,10 +1002,10 @@ namespace NExtractTools
std::wstring sMediaPath;
std::wstring sEmbedPath;
int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sCSV, params.getXmlOptions());
if (SUCCEEDED_X2T(nRes))
{
nRes = m_oCXlsxSerializer.loadFromFile(sResultXlstFileEditor, sTempUnpackedXLSX, params.getXmlOptions(), sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
nRes = m_oCXlsxSerializer.loadFromFile(sResultXlstFileEditor, sTempUnpackedXLSX, params.getXmlOptions(), sMediaPath, sEmbedPath);
if (SUCCEEDED_X2T(nRes))
{
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedXLSX, sTo, true)) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
@ -1022,7 +1022,7 @@ namespace NExtractTools
m_oCXlsxSerializer.setIsNoBase64(params.getIsNoBase64());
m_oCXlsxSerializer.setFontDir(params.getFontPath());
return m_oCXlsxSerializer.saveToFile(sTo, sFrom, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return m_oCXlsxSerializer.saveToFile(sTo, sFrom, params.getXmlOptions());
}
// xlst -> csv
int xlst2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
@ -1047,7 +1047,7 @@ namespace NExtractTools
std::wstring sMediaPath;
std::wstring sEmbedPath;
return m_oCXlsxSerializer.loadFromFile (sTempXlstFileEditor, sCSV, params.getXmlOptions(), sMediaPath, sEmbedPath) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return m_oCXlsxSerializer.loadFromFile (sTempXlstFileEditor, sCSV, params.getXmlOptions(), sMediaPath, sEmbedPath);
}
// xslx -> csv
int xlsx2csv (const std::wstring &sFrom, const std::wstring &sTo, const std::wstring &sTemp, InputParams& params)
@ -1071,13 +1071,13 @@ namespace NExtractTools
m_oCXlsxSerializer.setFontDir(params.getFontPath());
std::wstring sXMLOptions = _T("");
int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sTempUnpackedXLSX, sXMLOptions) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
int nRes = m_oCXlsxSerializer.saveToFile (sResultXlstFileEditor, sTempUnpackedXLSX, sXMLOptions);
if (SUCCEEDED_X2T(nRes))
{
std::wstring sMediaPath;
std::wstring sEmbedPath;
nRes = m_oCXlsxSerializer.loadFromFile (sResultXlstDir, sCSV, sXMLOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
nRes = m_oCXlsxSerializer.loadFromFile (sResultXlstDir, sCSV, sXMLOptions, sMediaPath, sEmbedPath);
}
return nRes;
@ -1108,7 +1108,7 @@ namespace NExtractTools
m_oCXlsxSerializer.CreateXlsxFolders (sXmlOptions, sTemp, sMediaPath, sEmbedPath);
nRes = m_oCXlsxSerializer.loadFromFile(sTargetBin, sToTemp, sXmlOptions, sMediaPath, sEmbedPath) ? nRes : AVS_FILEUTILS_ERROR_CONVERT;
nRes = m_oCXlsxSerializer.loadFromFile(sTargetBin, sToTemp, sXmlOptions, sMediaPath, sEmbedPath);
//пишем в Temp и копируем, чтобы не возникало лишних файлов рядом с sTo, а лучше перейти на отдельный метод
if(SUCCEEDED_X2T(nRes))
@ -3747,10 +3747,7 @@ namespace NExtractTools
m_oCXlsxSerializer.setFontDir(params.getFontPath());
int res = m_oCXlsxSerializer.saveToFile (sTo, sResultXlsxDir, params.getXmlOptions()) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
return res;
return m_oCXlsxSerializer.saveToFile (sTo, sResultXlsxDir, params.getXmlOptions());
}
return AVS_FILEUTILS_ERROR_CONVERT;
}

View File

@ -3296,14 +3296,14 @@ namespace BinXlsxRW
if (pathImageCache.GetPath().empty() == false)
{
//add image rels to VmlDrawing
NSCommon::smart_ptr<OOX::Image> pImageFileVml(new OOX::Image(false));
NSCommon::smart_ptr<OOX::Image> pImageFileVml(new OOX::Image(NULL, false));
pImageFileVml->set_filename(pathImageCache, false);
smart_ptr<OOX::File> pFileVml = pImageFileVml.smart_dynamic_cast<OOX::File>();
m_pCurVmlDrawing->Add(*oPic.blipFill.blip->embed, pFileVml);
//add image rels to Worksheet
NSCommon::smart_ptr<OOX::Image> pImageFileWorksheet(new OOX::Image(false));
NSCommon::smart_ptr<OOX::Image> pImageFileWorksheet(new OOX::Image(NULL, false));
pImageFileWorksheet->set_filename(pathImageCache, false);