Compare commits

..

11 Commits

Author SHA1 Message Date
ad0f2c89e0 fix bug #35277
XlsFormatReader - adding decrypt for format 1995, adding xor method decrypting
2018-02-05 17:38:14 +03:00
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
34 changed files with 749 additions and 217 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

@ -60,7 +60,7 @@ HRESULT convert_single(std::wstring srcFileName)
std::wstring dstPath;
bool bMacros = true;
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password", L"C:\\Windows\\Fonts", L"C:\\Windows\\Temp", NULL, bMacros);
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"2222", L"C:\\Windows\\Fonts", L"C:\\Windows\\Temp", NULL, bMacros);
if (bMacros)
{

View File

@ -56,6 +56,8 @@ CFRecord::CFRecord(CFStreamPtr stream, GlobalWorkbookInfoPtr global_info)
stream->read(data_, size_);
if(global_info->decryptor && 0 != size_)
{
size_t block_size = global_info->Version == 0x0500 ? 16 : 1024;
switch (type_id_) // this would decrease number of checks
{
case rt_BOF:
@ -67,11 +69,16 @@ CFRecord::CFRecord(CFStreamPtr stream, GlobalWorkbookInfoPtr global_info)
case rt_RRDHead:
break;
case rt_BoundSheet8:
global_info->decryptor->Decrypt(data_ + sizeof(unsigned int), size_ - sizeof(unsigned int), rec_data_pos + sizeof(unsigned int), 1024);
break;
{
if (global_info->Version == 0x0500)
global_info->decryptor->Decrypt(data_/* + sizeof(unsigned int)*/, size_/* - sizeof(unsigned int)*/, rec_data_pos, block_size);
else
global_info->decryptor->Decrypt(data_ + sizeof(unsigned int), size_ - sizeof(unsigned int), rec_data_pos + sizeof(unsigned int), block_size);
}break;
default:
global_info->decryptor->Decrypt(data_, size_, rec_data_pos, 1024);
break;
{
global_info->decryptor->Decrypt(data_, size_, rec_data_pos, block_size);
}break;
}
}
}

View File

@ -71,13 +71,6 @@ namespace CRYPT
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size) = 0;
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index) = 0;
typedef enum
{
RC4,
RC4CryptoAPI,
XOR
} crypt_type;
virtual bool IsVerify() = 0;
};

View File

@ -33,6 +33,7 @@
#include "Decryptor.h"
#include "RC4Crypt.h"
#include "XORCrypt.h"
#include <Logic/Biff_structures/RC4EncryptionHeader.h>
namespace CRYPT
@ -61,6 +62,37 @@ namespace CRYPT
crypt.reset();
crypt = CryptPtr(new RC4Crypt(crypt_data, password));
if (crypt) return crypt->IsVerify();
else return false;
}
//----------------------------------------------------------------------------------------
XOR::XOR(int type, unsigned short key, unsigned short hash, std::wstring password) :
crypt(new XORCrypt(type, key, hash, password))
{
nKey = key;
nHash = hash;
nType = type;
}
void XOR::Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size)
{
crypt->Decrypt(data, size, stream_pos, block_size);
}
void XOR::Decrypt(char* data, const size_t size, const unsigned long block_index)
{
crypt->Decrypt(data, size, block_index);
}
bool XOR::IsVerify()
{
return crypt->IsVerify();
}
bool XOR::SetPassword(std::wstring password)
{
crypt.reset();
crypt = CryptPtr(new XORCrypt(nType, nKey, nHash, password));
if (crypt) return crypt->IsVerify();
else return false;
}

View File

@ -37,6 +37,27 @@
namespace CRYPT
{
class XOR : public Decryptor
{
public:
XOR(int type, unsigned short key, unsigned short hash, std::wstring password);
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size);
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index);
virtual bool SetPassword(std::wstring password);
virtual bool IsVerify();
private:
CryptPtr crypt;
unsigned short nKey;
unsigned short nHash;
unsigned short nType;
};
typedef boost::shared_ptr<XOR> XORPtr;
class RC4Decryptor : public Decryptor
{
public:

View File

@ -0,0 +1,218 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* 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 "XORCrypt.h"
#include <boost/scoped_array.hpp>
typedef unsigned char SVBT16[2];
inline void ShortToSVBT16( unsigned short n, SVBT16 p ) { p[0] = (unsigned char) n;
p[1] = (unsigned char)(n >> 8); }
template< typename Type >
inline void lclRotateLeft( Type& rnValue, int nBits )
{
//OSL_ASSERT(
// nBits >= 0 &&
// sal::static_int_cast< unsigned int >(nBits) < sizeof( Type ) * 8 );
rnValue = static_cast< Type >( (rnValue << nBits) | (rnValue >> (sizeof( Type ) * 8 - nBits)) );
}
template< typename Type >
inline void lclRotateLeft( Type& rnValue, unsigned char nBits, unsigned char nWidth )
{
//OSL_ASSERT( (nBits < nWidth) && (nWidth < sizeof( Type ) * 8) );
Type nMask = static_cast< Type >( (1UL << nWidth) - 1 );
rnValue = static_cast< Type >(
((rnValue << nBits) | ((rnValue & nMask) >> (nWidth - nBits))) & nMask );
}
namespace CRYPT
{
size_t lclGetLen( const unsigned char* pnPassData, size_t nBufferSize )
{
size_t nLen = 0;
while( (nLen < nBufferSize) && pnPassData[ nLen ] ) ++nLen;
return nLen;
}
unsigned short lclGetKey( const unsigned char* pnPassData, size_t nBufferSize )
{
size_t nLen = lclGetLen( pnPassData, nBufferSize );
if( !nLen ) return 0;
unsigned short nKey = 0;
unsigned short nKeyBase = 0x8000;
unsigned short nKeyEnd = 0xFFFF;
const unsigned char* pnChar = pnPassData + nLen - 1;
for( size_t nIndex = 0; nIndex < nLen; ++nIndex, --pnChar )
{
unsigned char cChar = *pnChar & 0x7F;
for( unsigned char nBit = 0; nBit < 8; ++nBit )
{
lclRotateLeft( nKeyBase, 1 );
if( nKeyBase & 1 ) nKeyBase ^= 0x1020;
if( cChar & 1 ) nKey ^= nKeyBase;
cChar >>= 1;
lclRotateLeft( nKeyEnd, 1 );
if( nKeyEnd & 1 ) nKeyEnd ^= 0x1020;
}
}
return nKey ^ nKeyEnd;
}
unsigned short lclGetHash( const unsigned char* pnPassData, size_t nBufferSize )
{
size_t nLen = lclGetLen( pnPassData, nBufferSize );
unsigned short nHash = static_cast< unsigned short >( nLen );
if( nLen )
nHash ^= 0xCE4B;
const unsigned char* pnChar = pnPassData;
for( size_t nIndex = 0; nIndex < nLen; ++nIndex, ++pnChar )
{
unsigned short cChar = *pnChar;
unsigned char nRot = static_cast< unsigned char >( (nIndex + 1) % 15 );
lclRotateLeft( cChar, nRot, 15 );
nHash ^= cChar;
}
return nHash;
}
XORCrypt::XORCrypt(int type, unsigned short key, unsigned short hash, std::wstring password) :
m_nOffset(0),
m_nKey(0),
m_nHash(0)
{
if (type == 1) m_nRotateDistance = 7; //doc
else if (type == 2) m_nRotateDistance = 2; //xls
memset( m_pnKey, 0, sizeof( m_pnKey ) );
m_VerifyPassword = false;
size_t nLen = password.length();
if (nLen > 16) return;
m_sPassword = std::string(password.begin(), password.end());
unsigned char* pnPassData = (unsigned char*)m_sPassword.c_str();
m_nKey = lclGetKey( pnPassData, 16 );
m_nHash = lclGetHash( pnPassData, 16 );
memcpy( m_pnKey, pnPassData, 16 );
static const unsigned char spnFillChars[] =
{
0xBB, 0xFF, 0xFF, 0xBA, 0xFF, 0xFF, 0xB9, 0x80, 0x00, 0xBE, 0x0F, 0x00, 0xBF, 0x0F, 0x00
};
nLen = lclGetLen( pnPassData, 16 );
const unsigned char* pnFillChar = spnFillChars;
for ( size_t nIndex = nLen; nIndex < sizeof( m_pnKey ); ++nIndex, ++pnFillChar )
m_pnKey[ nIndex ] = *pnFillChar;
SVBT16 pnOrigKey;
ShortToSVBT16( m_nKey, pnOrigKey );
unsigned char* pnKeyChar = m_pnKey;
for ( size_t nIndex = 0; nIndex < sizeof( m_pnKey ); ++nIndex, ++pnKeyChar )
{
*pnKeyChar ^= pnOrigKey[ nIndex & 0x01 ];
lclRotateLeft( *pnKeyChar, m_nRotateDistance );
}
m_VerifyPassword = (key == m_nKey) && (hash == m_nHash);
}
bool XORCrypt::IsVerify()
{
return m_VerifyPassword;
}
void XORCrypt::Decrypt(char* data, const size_t size, const unsigned long block_index)
{
}
void XORCrypt::Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size)
{
m_nOffset = (stream_pos + size) & 0x0F;
unsigned char* pnData = (unsigned char*)data;
const unsigned char* pnCurrKey = m_pnKey + m_nOffset;
const unsigned char* pnKeyLast = m_pnKey + 0x0F;
if (m_nRotateDistance == 7)
{
for( const unsigned char* pnDataEnd = pnData + size; pnData < pnDataEnd; ++pnData )
{
const unsigned char cChar = *pnData ^ *pnCurrKey;
if (*pnData && cChar)
*pnData = cChar;
if( pnCurrKey < pnKeyLast )
++pnCurrKey;
else
pnCurrKey = m_pnKey;
}
}
if (m_nRotateDistance == 2)
{
for( const unsigned char* pnDataEnd = pnData + size; pnData < pnDataEnd; ++pnData )
{
lclRotateLeft( *pnData, 3 );
*pnData ^= *pnCurrKey;
if( pnCurrKey < pnKeyLast )
++pnCurrKey;
else
pnCurrKey = m_pnKey;
}
}
}
void XORCrypt::Skip( size_t size )
{
m_nOffset = (m_nOffset + size) & 0x0F;
}
};

View File

@ -0,0 +1,66 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* 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
*
*/
#pragma once
#include "Crypt.h"
#include <Logic/Biff_structures/RC4EncryptionHeader.h>
#include "BiffDecoder_RCF.h"
namespace CRYPT
{
class XORCrypt : public Crypt
{
public:
XORCrypt(int type, unsigned short key, unsigned short hash, std::wstring password);
virtual void Decrypt(char* data, const size_t size, const unsigned long stream_pos, const size_t block_size);
virtual void Decrypt(char* data, const size_t size, const unsigned long block_index);
virtual bool IsVerify();
private:
void Skip( size_t size );
unsigned short m_nKey;
unsigned short m_nHash;
std::string m_sPassword;
bool m_VerifyPassword;
unsigned char m_pnKey[ 16 ]; // Encryption key.
size_t m_nOffset; // Key offset.
int m_nRotateDistance;
};
} // namespace CRYPT

View File

@ -54,48 +54,51 @@ BaseObjectPtr FilePass::clone()
void FilePass::readFields(CFRecord& record)
{
bool bEnabled = false;
record >> wEncryptionType;
if(wEncryptionType == 0)
if (record.getGlobalWorkbookInfo()->Version == 0x0500)
{
record >> key;
Log::info("FilePass: Encryption type: XOR");
return;
record >> key.key >> key.verificationBytes;
record.getGlobalWorkbookInfo()->decryptor =
CRYPT::DecryptorPtr(new CRYPT::XOR(2, key.key, key.verificationBytes, record.getGlobalWorkbookInfo()->password));
}
else
{
bEnabled = true;
majorVer = *record.getCurData<unsigned short>();
cryptHeaderPtr = CRYPTO::RC4EncryptionHeaderPtr(new CRYPTO::RC4EncryptionHeader());
cryptHeaderPtr->bStandard = 0x0001 == majorVer ? true : false; // _S2dvT1xU_R3bOPwre4_.xls
cryptHeaderPtr->load (record);
record >> wEncryptionType;
if (cryptHeaderPtr->bStandard)
if(wEncryptionType == 0)
{
record >> key;
record.getGlobalWorkbookInfo()->decryptor =
CRYPT::DecryptorPtr(new CRYPT::RC4Decryptor(cryptHeaderPtr->crypt_data_rc4, record.getGlobalWorkbookInfo()->password));
CRYPT::DecryptorPtr(new CRYPT::XOR(2, key.key, key.verificationBytes, record.getGlobalWorkbookInfo()->password));
}
else
{
record.getGlobalWorkbookInfo()->decryptor =
CRYPT::DecryptorPtr(new CRYPT::ECMADecryptor());
CRYPT::ECMADecryptor *crypter = dynamic_cast<CRYPT::ECMADecryptor *>(record.getGlobalWorkbookInfo()->decryptor.get());
majorVer = *record.getCurData<unsigned short>();
crypter->SetCryptData(cryptHeaderPtr->crypt_data_aes);
crypter->SetPassword(record.getGlobalWorkbookInfo()->password);
cryptHeaderPtr = CRYPTO::RC4EncryptionHeaderPtr(new CRYPTO::RC4EncryptionHeader());
cryptHeaderPtr->bStandard = 0x0001 == majorVer ? true : false; // _S2dvT1xU_R3bOPwre4_.xls
cryptHeaderPtr->load (record);
if (cryptHeaderPtr->bStandard)
{
record.getGlobalWorkbookInfo()->decryptor =
CRYPT::DecryptorPtr(new CRYPT::RC4Decryptor(cryptHeaderPtr->crypt_data_rc4, record.getGlobalWorkbookInfo()->password));
}
else
{
record.getGlobalWorkbookInfo()->decryptor =
CRYPT::DecryptorPtr(new CRYPT::ECMADecryptor());
CRYPT::ECMADecryptor *crypter = dynamic_cast<CRYPT::ECMADecryptor *>(record.getGlobalWorkbookInfo()->decryptor.get());
crypter->SetCryptData(cryptHeaderPtr->crypt_data_aes);
crypter->SetPassword(record.getGlobalWorkbookInfo()->password);
}
}
}
if (bEnabled == false && record.getGlobalWorkbookInfo()->decryptor)
record.getGlobalWorkbookInfo()->decryptor.reset();
}
} // namespace XLS

View File

@ -32,8 +32,6 @@
#pragma once
#include "BiffStructure.h"
//#include <Logic/Biff_structures/Phs.h>
//#include <Logic/Biff_structures/BiffString.h>
namespace XLS
{

View File

@ -822,6 +822,7 @@ SOURCES += \
../XlsFormat/Crypt/BinaryCodec_RCF.cpp \
../XlsFormat/Crypt/Decryptor.cpp \
../XlsFormat/Crypt/RC4Crypt.cpp \
../XlsFormat/Crypt/XORCrypt.cpp \
../XlsFormat/Logging/Log.cpp \
../XlsFormat/Logging/Logger.cpp \
../Common/utils.cpp \
@ -1179,6 +1180,7 @@ HEADERS += \
../XlsFormat/Crypt/Crypt.h \
../XlsFormat/Crypt/Decryptor.h \
../XlsFormat/Crypt/RC4Crypt.h \
../XlsFormat/Crypt/XORCrypt.h \
../XlsFormat/Logging/Log.h \
../XlsFormat/Logging/Logger.h \
../XlsFormat/Logic/Biff_structures/AddinUdf.h \

View File

@ -6612,6 +6612,14 @@
RelativePath="..\XlsFormat\Crypt\RC4Crypt.h"
>
</File>
<File
RelativePath="..\XlsFormat\Crypt\XORCrypt.cpp"
>
</File>
<File
RelativePath="..\XlsFormat\Crypt\XORCrypt.h"
>
</File>
<Filter
Name="rtl"
>

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

@ -1,4 +1,4 @@
VERSION = 2.4.515.0
VERSION = 2.4.516.0
DEFINES += INTVER=$$VERSION
# CONFIGURATION

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);