Compare commits

...

18 Commits

Author SHA1 Message Date
35a86586ab Merge pull request #849 from ONLYOFFICE/fix/bug-55460
Fix bug #55460
2022-02-15 11:51:25 +03:00
00fa7e7afe Fix bug #55460 2022-02-15 11:38:54 +03:00
dc574f6606 [x2t] For bug 55284 2022-02-06 13:02:42 +03:00
c886341ac1 Fix bug 53831 2022-02-04 15:03:06 +03:00
4a93c91011 Fix bug 47558 2022-01-28 11:39:25 +03:00
209a3874c8 Merge pull request #832 from ONLYOFFICE/fix/v7.0.1-fix-bugs
fix bug #55027
2022-01-21 15:34:22 +03:00
abc74e21d0 fix bug #55027 2022-01-21 15:33:26 +03:00
e78b399810 Merge pull request #830 from ONLYOFFICE/fix/v7.0-fix-bugs
Fix/v7.0 fix bugs
2022-01-19 11:39:52 +03:00
1f976ae79a Merge branch release/v7.0.0 into master 2022-01-17 14:18:57 +00:00
4b9da896ab fix bug #54485 2022-01-13 18:12:26 +03:00
6561216356 fix bug #54819 2022-01-11 19:10:16 +03:00
6d53f5745b [ios] Add NSDictionary and NSString extension 2021-12-16 18:02:27 +03:00
b3d9d4cc6e Merge pull request #806 from ONLYOFFICE/fix/v7-fix-bugs
Fix/v7 fix bugs
2021-12-16 17:25:28 +03:00
03b10cb446 fix bug 2021-12-16 17:24:37 +03:00
b87dad75fc fix bug #54521 2021-12-16 11:57:59 +03:00
0275791b2c fix bug #54461 2021-12-14 17:39:19 +03:00
a30e9ac37f fix bug #54492 2021-12-13 15:33:54 +03:00
cdc74ada43 Fix allfontsgen 2021-12-11 21:17:42 +03:00
23 changed files with 811 additions and 533 deletions

View File

@ -339,7 +339,7 @@ int Binary_CommonReader2::ReadShdComplexType(BYTE type, long length, void* poRes
{
CThemeColor themeColor;
ReadThemeColor(length, themeColor);
themeColor.ToCThemeColor(pShd->m_oColor, pShd->m_oThemeFill, pShd->m_oThemeFillTint, pShd->m_oThemeFillShade);
themeColor.ToCThemeColor(pShd->m_oFill, pShd->m_oThemeFill, pShd->m_oThemeFillTint, pShd->m_oThemeFillShade);
}break;
default:
{
@ -3535,6 +3535,10 @@ int Binary_CustomsTableReader::ReadCustomContent(BYTE type, long length, void* p
{
pCustomXMLProps->m_oCustomXmlContent = m_oBufferedStream.GetString3(length);
}
else if (c_oSerCustoms::ContentA == type)
{
pCustomXMLProps->m_oCustomXmlContentA = m_oBufferedStream.GetString2A();
}
else
res = c_oSerConstants::ReadUnknown;
return res;

View File

@ -1158,7 +1158,8 @@ extern int g_nCurFormatVersion;
Custom = 0,
ItemId = 1,
Uri = 2,
Content = 3
Content = 3,
ContentA = 4
};}
namespace c_oSerApp{enum c_oSerApp
{

View File

@ -309,13 +309,14 @@ void BinaryCommonWriter::WriteShd(const ComplexTypes::Word::CShading& Shd)
if (false != Shd.m_oColor.IsInit())
WriteColor(c_oSerShdType::Color, Shd.m_oColor.get());
WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade);
WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oColor, Shd.m_oThemeColor, Shd.m_oThemeTint, Shd.m_oThemeShade);
//Fill
if (false != Shd.m_oFill.IsInit())
WriteColor(c_oSerShdType::Fill, Shd.m_oFill.get());
WriteThemeColor(c_oSerShdType::FillTheme, Shd.m_oColor, Shd.m_oThemeColor, Shd.m_oThemeTint, Shd.m_oThemeShade);
WriteThemeColor(c_oSerShdType::FillTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade);
}
void BinaryCommonWriter::WritePaddings(const nullable<SimpleTypes::CTwipsMeasure>& left, const nullable<SimpleTypes::CTwipsMeasure>& top,
const nullable<SimpleTypes::CTwipsMeasure>& right, const nullable<SimpleTypes::CTwipsMeasure>& bottom)
@ -9057,11 +9058,8 @@ void BinaryCustomsTableWriter::Write(OOX::CDocument* pDocument)
}
}
int nCurPos2 = m_oBcw.WriteItemStart(c_oSerCustoms::Content);
std::wstring sXml = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)pCustomXml->m_sXmlA.c_str(), pCustomXml->m_sXmlA.length());
m_oBcw.m_oStream.WriteStringW3(sXml);
int nCurPos2 = m_oBcw.WriteItemStart(c_oSerCustoms::ContentA);
m_oBcw.m_oStream.WriteStringA(pCustomXml->m_sXmlA);
m_oBcw.WriteItemEnd(nCurPos2);
m_oBcw.WriteItemEnd(nCurPos);

View File

@ -628,9 +628,16 @@ namespace PPT_FORMAT
//string rect
int nRectCount = (int)pPPTShape->m_arStringTextRects.size();
if (0 != nRectCount)
if (0 != nRectCount && !pPPTShape->m_arStringTextRects[0].empty())
{
pFormulaConverter.ConvertTextRect(pPPTShape->m_arStringTextRects[0]);
if (pPPTShape->m_eType == PPTShapes::sptCNotchedCircularArrow)
{
pFormulaConverter.SetTextRectDefault();
}
else
{
pFormulaConverter.ConvertTextRect(pPPTShape->m_arStringTextRects[0]);
}
}
int nHandlesCount = (int)pPPTShape->m_arHandles.size();

View File

@ -80,23 +80,25 @@ namespace Docx2Txt
OOX::CDocx m_inputFile;
private:
void convert(std::vector<OOX::WritingElement *> & items, std::vector<std::wstring>& textOut, bool isFirstLevel,
void convert(std::vector<OOX::WritingElement *> & items, std::vector<std::wstring>& textOut, bool bEnter,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles);
std::wstring convert( OOX::Logic::CRun* pRun, OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles* pStyles);
void convert(OOX::WritingElement *pItem, std::vector<std::wstring>& textOut, bool bEnter,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles);
void convert(OOX::Logic::CParagraph *pParagraph, std::vector<std::wstring>& textOut, bool bEnter,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles);
std::wstring convert( OOX::Logic::CRun *pRun, OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles* pStyles);
std::vector<bool> m_Field;
int m_lPercent;
int m_lAddition;
bool m_bCancelled;
int ListCount;
std::vector<int> Lists;
int levelPrev;
std::vector<int> levelPrev;
int listNumPrev;
std::wstring convert(OOX::Logic::CParagraph * pParagraph, OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles);
size_t NoteCount;
std::map<std::wstring, std::vector<std::wstring>> Notes;
@ -157,7 +159,7 @@ namespace Docx2Txt
const std::wstring Converter_Impl::m_letters = _T("abcdefghijklmnopqrstuvwxyz");
Converter_Impl::Converter_Impl()
: m_lAddition(0), Lists(NULL), NoteCount(0), levelPrev(-1), listNumPrev(1)
: Lists(NULL), NoteCount(0), listNumPrev(1)
{
}
@ -178,12 +180,14 @@ namespace Docx2Txt
for (int i = 0; i < 9 * ListCount; i++)
Lists.push_back(-1);
for (int i = 0; i < ListCount; i++)
levelPrev.push_back(-1);
}
if (!pDocument) return;
if (pDocument->m_arrItems.empty()) return;
m_lAddition = 800000;
Notes.clear();
convert(pDocument->m_arrItems, m_outputFile.m_listContent, true, pDocument, pNumbering, pStyles);
@ -231,72 +235,98 @@ namespace Docx2Txt
{
m_outputFile.writeAnsi(path);
}
void Converter_Impl::convert(OOX::WritingElement* item, std::vector<std::wstring>& textOut, bool bEnter,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles)
{
if (!item) return;
switch (item->getType())
{
case OOX::et_w_p:
{
convert(dynamic_cast<OOX::Logic::CParagraph*>(item), textOut, bEnter, pDocument, pNumbering, pStyles);
}break;
case OOX::et_w_r:
{
textOut.push_back(convert((dynamic_cast<OOX::Logic::CRun*>(item)), pDocument, pNumbering, pStyles));
}break;
case OOX::et_w_sdt:
{
OOX::Logic::CSdt *sdt = dynamic_cast<OOX::Logic::CSdt*>(item);
if (sdt)
convert(sdt->m_oSdtContent.GetPointer(), textOut, bEnter, pDocument, pNumbering, pStyles);
}break;
default:
{
OOX::WritingElementWithChilds<OOX::WritingElement> *item_with_items = dynamic_cast<OOX::WritingElementWithChilds<OOX::WritingElement>*>(item);
void Converter_Impl::convert(std::vector<OOX::WritingElement*> & items, std::vector<std::wstring>& textOut,
bool isFirstLevel, OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles)
if (item_with_items)
{
convert(item_with_items->m_arrItems, textOut, bEnter, pDocument, pNumbering, pStyles);
}
}break;
}
}
void Converter_Impl::convert(std::vector<OOX::WritingElement*> & items, std::vector<std::wstring>& textOut, bool bEnter,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles *pStyles)
{
if (items.empty()) return;
if(isFirstLevel)
m_lAddition = m_lAddition / items.size();
for (std::vector<OOX::WritingElement*>::iterator it = items.begin(); it != items.end(); ++it)
for (size_t i = 0; i < items.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = items[i];
if (!item)continue;
if (item->getType() == OOX::et_w_p)
switch (item->getType())
{
textOut.push_back(convert((dynamic_cast<OOX::Logic::CParagraph*>(item)), pDocument, pNumbering, pStyles));
}
else if (item->getType() == OOX::et_w_r)
{
textOut.push_back(convert((dynamic_cast<OOX::Logic::CRun*>(item)), pDocument, pNumbering, pStyles));
}
/*else if (item.is<OOX::Logic::List>())
{
BOOST_FOREACH(const OOX::Logic::ListItem& listItem, *item.as<OOX::Logic::List>().m_arrItems)
case OOX::et_w_tc:
{
convert(listItem.m_arrItems);
}
}*/
//else if (item->getType() == OOX::et_w_tbl)
//{
// OOX::Logic::CTbl* tbl = dynamic_cast<OOX::Logic::CTbl*>(item);
// for (int r = 0 ; r < tbl->m_arrItems.size(); r++)
// {
// OOX::WritingElement * item = tbl->m_arrItems[r];
// if (item->getType() == OOX::et_w_tr)
// {
// OOX::Logic::CTr* tr = dynamic_cast<OOX::Logic::CTr*>(item);
// for (int c = 0 ; c < tr->m_arrItems.size(); c++)
// {
// OOX::WritingElement * item = tr->m_arrItems[c];
// if (item->getType() == OOX::et_w_tc)
// {
// OOX::Logic::CTc* tc = dynamic_cast<OOX::Logic::CTc*>(item);
// convert(tc->m_arrItems, Event, false, pDocument, pStyles);
// }
// }
// }
// }
//}
//else if (item->getType() == OOX::et_w_sdt)
//{
// convert((dynamic_cast<OOX::Logic::CSdt*>(item))->m_arrItems, text, Event, false, pDocument, pNumbering, pStyles);
//}
else
{
//todoooo проверить - это общий случай - вместо CSdt ... да и Tbl тож
OOX::WritingElementWithChilds<OOX::WritingElement> *item_with_items = dynamic_cast<OOX::WritingElementWithChilds<OOX::WritingElement>*>(item);
OOX::Logic::CTc *cell = dynamic_cast<OOX::Logic::CTc*>(item);
for (size_t j = 0; cell && j < cell->m_arrItems.size(); ++j)
{
convert(cell->m_arrItems[j], textOut, false, pDocument, pNumbering, pStyles);
if (textOut.empty()) textOut.push_back(L"");
textOut.back() += L" |";
}
}break;
case OOX::et_w_tr:
{
textOut.push_back(L"---------------------------------------------");
textOut.push_back(L"|");
if (item_with_items)
OOX::Logic::CTr *row = dynamic_cast<OOX::Logic::CTr*>(item);
convert(row->m_arrItems, textOut, false, pDocument, pNumbering, pStyles);
}break;
case OOX::et_w_p:
{
convert(item_with_items->m_arrItems, textOut, false, pDocument, pNumbering, pStyles);
}
convert(dynamic_cast<OOX::Logic::CParagraph*>(item), textOut, bEnter, pDocument, pNumbering, pStyles);
}break;
case OOX::et_w_r:
{
textOut.push_back(convert((dynamic_cast<OOX::Logic::CRun*>(item)), pDocument, pNumbering, pStyles));
}break;
case OOX::et_w_sdt:
{
OOX::Logic::CSdt *sdt = dynamic_cast<OOX::Logic::CSdt*>(item);
if (sdt)
convert(sdt->m_oSdtContent.GetPointer(), textOut, bEnter, pDocument, pNumbering, pStyles);
}break;
default:
{
OOX::WritingElementWithChilds<OOX::WritingElement> *item_with_items = dynamic_cast<OOX::WritingElementWithChilds<OOX::WritingElement>*>(item);
if (item_with_items)
{
convert(item_with_items->m_arrItems, textOut, bEnter, pDocument, pNumbering, pStyles);
}
else
{
convert(item, textOut, bEnter, pDocument, pNumbering, pStyles);
}
}break;
}
}
}
@ -366,7 +396,7 @@ namespace Docx2Txt
if (note && note->m_oId == footnote_ref->m_oId)
{
convert(m_inputFile.m_oMain.footnotes->m_arrFootnote[r]->m_arrItems, notes_content, false, pDocument, pNumbering, pStyles);
convert(m_inputFile.m_oMain.footnotes->m_arrFootnote[r]->m_arrItems, notes_content, true, pDocument, pNumbering, pStyles);
}
}
Notes.insert(std::make_pair(ToWString(++NoteCount), notes_content));
@ -380,7 +410,7 @@ namespace Docx2Txt
if (note && note->m_oId == endnote_ref->m_oId)
{
convert(m_inputFile.m_oMain.endnotes->m_arrEndnote[r]->m_arrItems, notes_content, false, pDocument, pNumbering, pStyles);
convert(m_inputFile.m_oMain.endnotes->m_arrEndnote[r]->m_arrItems, notes_content, true, pDocument, pNumbering, pStyles);
}
}
Notes.insert(std::make_pair(ToWString(++NoteCount), notes_content));
@ -394,10 +424,10 @@ namespace Docx2Txt
return line;
}
std::wstring Converter_Impl::convert(OOX::Logic::CParagraph* pParagraph,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles* pStyles)
void Converter_Impl::convert(OOX::Logic::CParagraph* pParagraph, std::vector<std::wstring>& textOut, bool bEnter,
OOX::CDocument *pDocument, OOX::CNumbering* pNumbering, OOX::CStyles* pStyles)
{
if (pParagraph == NULL) return L"";
if (pParagraph == NULL) return;
std::wstring line;
@ -518,9 +548,9 @@ namespace Docx2Txt
else if (*restartLvl >= Lists[start + level])
reset = true;
}
else if (levelPrev >= level) reset = false;
else if (levelPrev[indexNum] >= level) reset = false;
levelPrev = level;
levelPrev[indexNum] = level;
if (reset || Lists[start + level] < 0)
Lists[start + level] = startLvl.IsInit() ? *startLvl : 1;
@ -610,6 +640,10 @@ namespace Docx2Txt
OOX::Logic::CRun *pRun = dynamic_cast<OOX::Logic::CRun*>(pParagraph->m_arrItems[i]);
line += convert(pRun, pDocument, pNumbering, pStyles);
}break;
case OOX::et_w_sdt:
{
convert(pParagraph->m_arrItems[i], textOut, bEnter, pDocument, pNumbering, pStyles);
}break;
case OOX::et_w_hyperlink:
{
OOX::Logic::CHyperlink *pHyperlink = dynamic_cast<OOX::Logic::CHyperlink*>(pParagraph->m_arrItems[i]);
@ -637,7 +671,7 @@ namespace Docx2Txt
for (size_t j = 0; j < pHyperlink->m_arrItems.size(); ++j)
{
convert(pHyperlink->m_arrItems, arDisplay, false, pDocument, pNumbering, pStyles);
convert(pHyperlink->m_arrItems, arDisplay, true, pDocument, pNumbering, pStyles);
}
for (size_t j = 0; j < arDisplay.size(); ++j)
line += arDisplay[j];
@ -650,7 +684,14 @@ namespace Docx2Txt
}break;
}
}
return line;
if (bEnter || textOut.empty())
{
textOut.push_back(line);
}
else
{
textOut.back() += L"" + line;
}
}
std::wstring Converter_Impl::IntToLowerLetter(int number)

View File

@ -87,9 +87,9 @@ void Dv::readFields(CFRecord& record)
record >> PromptTitle >> ErrorTitle >> Prompt >> Error;
formula1.load(record, valType != typeDvCustom);
formula1.load(record, valType != typeDvNone);
formula2.load(record, valType != typeDvCustom && valType != typeDvList && valType != typeDvWhole && typOperator < 2);
formula2.load(record, valType != typeDvCustom && valType != typeDvList && valType != typeDvNone && typOperator < 2);
record >> sqref;
}
@ -117,24 +117,27 @@ int Dv::serialize(std::wostream & stream)
CP_XML_ATTR(L"sqref", sqref.strValue);
switch(typOperator)
if (valType != typeDvCustom && valType != typeDvList && valType != typeDvNone)
{
switch (typOperator)
{
case operatorDvBetween: CP_XML_ATTR(L"operator", L"between"); break;
case operatorDvNotBetween: CP_XML_ATTR(L"operator", L"notBetween"); break;
case operatorDvEquals: CP_XML_ATTR(L"operator", L"equal"); break;
case operatorDvNotEquals: CP_XML_ATTR(L"operator", L"notEqual"); break;
case operatorDvGreaterThan: CP_XML_ATTR(L"operator", L"greaterThan"); break;
case operatorDvLessThan: CP_XML_ATTR(L"operator", L"lessThan"); break;
case operatorDvGreaterThanOrEqual: CP_XML_ATTR(L"operator", L"greaterThanOrEqual");break;
case operatorDvGreaterThanOrEqual: CP_XML_ATTR(L"operator", L"greaterThanOrEqual"); break;
case operatorDvLessThanOrEqual: CP_XML_ATTR(L"operator", L"lessThanOrEqual"); break;
}
}
if (PromptTitle.value().size() > 1)
{
CP_XML_ATTR(L"promtTitle", PromptTitle.value());
CP_XML_ATTR(L"promptTitle", PromptTitle.value());
}
if (Prompt.value().size() > 1)
{
CP_XML_ATTR(L"promt", Prompt.value());
CP_XML_ATTR(L"prompt", Prompt.value());
}
if (ErrorTitle.value().size() > 1)
{
@ -144,11 +147,9 @@ int Dv::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"error", Error.value());
}
if (formula1.IsVolatile())
formula1.set_base_ref(sqref.getLocationFirstCell());
if (formula2.IsVolatile())
formula2.set_base_ref(sqref.getLocationFirstCell());
formula1.set_base_ref(sqref.getLocationFirstCell());
formula2.set_base_ref(sqref.getLocationFirstCell());
std::wstring sFormula1 = formula1.getAssembledFormula();
std::wstring sFormula2 = formula2.getAssembledFormula();

View File

@ -51,14 +51,14 @@ enum _typOperatorDv
};
enum _valTypeDv
{
typeDvCustom = 0,
typeDvDate,
typeDvDecimal,
typeDvList,
typeDvNone,
typeDvTextLength,
typeDvTime,
typeDvWhole
typeDvNone = 0,
typeDvWhole = 1,
typeDvDecimal = 2,
typeDvList = 3,
typeDvDate = 4,
typeDvTime = 5,
typeDvTextLength = 6,
typeDvCustom = 7
};
class Dv: public BiffRecord
{

View File

@ -166,6 +166,7 @@ namespace OOX
WritingStringNullableAttrInt(L"workbookSpinCount", m_oWorkbookSpinCount, m_oWorkbookSpinCount->GetValue());
WritingStringNullableAttrInt(L"lockStructure", m_oLockStructure, m_oLockStructure->ToBool() ? 1 : 0);
WritingStringNullableAttrInt(L"lockWindows", m_oLockWindows, m_oLockWindows->ToBool() ? 1 : 0);
WritingStringNullableAttrString(L"workbookPassword", m_oPassword, m_oPassword.get());
writer.WriteString(L"/>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
@ -194,6 +195,7 @@ namespace OOX
WritingElement_ReadAttributes_Read_else_if(oReader, (L"lockRevision"), m_oLockRevision)
WritingElement_ReadAttributes_Read_else_if(oReader, (L"lockStructure"), m_oLockStructure)
WritingElement_ReadAttributes_Read_else_if(oReader, (L"lockWindows"), m_oLockWindows)
WritingElement_ReadAttributes_Read_else_if(oReader, (L"workbookPassword"), m_oPassword)
WritingElement_ReadAttributes_End(oReader)
}
nullable<SimpleTypes::COnOff<>> m_oLockRevision;
@ -205,6 +207,8 @@ namespace OOX
nullable_string m_oWorkbookHashValue;
nullable_string m_oWorkbookSaltValue;
nullable_string m_oPassword; //for old wrike protection
nullable<SimpleTypes::CCryptAlgoritmName<>> m_oRevisionsAlgorithmName;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oRevisionsSpinCount;
nullable_string m_oRevisionsHashValue;

View File

@ -550,8 +550,8 @@ void CConditionalFormattingRule::toXML2(NSStringUtils::CStringBuilder& writer, b
std::wstring node_name = bExtendedWrite ? L"x14:cfRule" : L"cfRule";
writer.WriteString(L"<" + node_name);
WritingStringAttrString(L"type", m_oType->ToString());
WritingStringAttrInt(L"priority", m_oPriority->GetValue());
WritingStringNullableAttrString(L"type", m_oType, m_oType->ToString());
WritingStringNullableAttrInt(L"priority", m_oPriority, m_oPriority->GetValue());
if (m_oAboveAverage.IsInit() && false == m_oAboveAverage->ToBool())
writer.WriteString(L" aboveAverage=\"0\"");
if (m_oBottom.IsInit() && true == m_oBottom->ToBool())

View File

@ -860,6 +860,7 @@
#define ASC_MENU_EVENT_TYPE_SHOW_CONTENT_CONTROLS_ACTIONS 26001
#define ASC_MENU_EVENT_TYPE_HIDE_CONTENT_CONTROLS_ACTIONS 26002
#define ASC_MENU_EVENT_TYPE_DO_SET_CONTENTCONTROL_PICTURE 26003
#define ASC_MENU_EVENT_TYPE_DO_SET_CONTENTCONTROL_PICTURE_URL 26004
// Others
#define ASC_MENU_EVENT_TYPE_FOCUS_OBJECT 26101

View File

@ -57,7 +57,10 @@
#define MAX_PATH 1024
#endif
#define READ_WRITE_FULL_BUFFER_SIZE 10000000 // 10mb
#ifdef __ANDROID__
#define READ_WRITE_FULL
#define USE_LINUX_SENDFILE_INSTEAD_STREAMS
// Available since API level 21.
@ -1217,6 +1220,45 @@ namespace NSFile
if (strSrc == strDst)
return true;
#ifdef READ_WRITE_FULL
BYTE* pFileData = NULL;
DWORD dwChunkSize = READ_WRITE_FULL_BUFFER_SIZE;
CFileBinary oFileSrc;
CFileBinary oFileDst;
if (oFileSrc.OpenFile(strSrc) && oFileDst.CreateFileW(strDst))
{
DWORD dwFileSrcSize = (DWORD)oFileSrc.GetFileSize();
if (dwChunkSize > dwFileSrcSize)
dwChunkSize = dwFileSrcSize;
BYTE* pTempBuffer = new BYTE[dwChunkSize];
DWORD dwProcessedBytes = 0;
while (dwFileSrcSize != 0)
{
oFileSrc.ReadFile(pTempBuffer, dwChunkSize, dwProcessedBytes);
if (dwProcessedBytes != dwChunkSize)
break;
if (!oFileDst.WriteFile(pTempBuffer, dwChunkSize))
break;
dwFileSrcSize -= dwChunkSize;
if (dwChunkSize > dwFileSrcSize)
dwChunkSize = dwFileSrcSize;
}
oFileSrc.CloseFile();
oFileDst.CloseFile();
RELEASEARRAYOBJECTS(pTempBuffer);
if (0 != dwFileSrcSize)
Remove(strDst);
else
return true;
}
#endif
#if !defined(_WIN32) && !defined(_WIN32_WCE) && !defined(_WIN64)
std::string strSrcA = U_TO_UTF8(strSrc);
std::string strDstA = U_TO_UTF8(strDst);

View File

@ -0,0 +1,37 @@
/*
* (c) Copyright Ascensio System SIA 2010-2021
*
* 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 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* 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
*
*/
#import <Foundation/Foundation.h>
@interface NSDictionary (Utils)
- (NSString*)jsonString;
@end

View File

@ -0,0 +1,50 @@
/*
* (c) Copyright Ascensio System SIA 2010-2021
*
* 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 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* 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
*
*/
#import "NSDictionary+Utils.h"
@implementation NSDictionary (Utils)
- (NSString*)jsonString {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self
options:(NSJSONWritingOptions)NSJSONWritingPrettyPrinted
error:&error];
if (!jsonData) {
NSLog(@"NSDictionary+Utils dictoonary to json: error: %@", error.localizedDescription);
return @"{}";
} else {
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
}
@end

View File

@ -43,5 +43,5 @@
- (std::wstring)stdwstring;
- (std::string)stdstring;
+ (NSString *)queryParameter:(NSURL *)url key:(NSString *)key;
- (NSDictionary *)toDictionary;
@end

View File

@ -110,4 +110,17 @@
return queryItem.value;
}
- (NSDictionary *)toDictionary {
NSError * error = nil;
NSData * data = [self dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary * json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
if (error) {
NSLog(@"%@", error);
return nil;
}
return json;
}
@end

View File

@ -746,7 +746,7 @@ public:
std::wstring sFontFilesWeb = L"";
size_t nFontFilesWeb1 = 0;
size_t nFontFilesWeb2 = 0;
if (!m_pMain->m_sWebFontsDirectory.empty() && !m_pMain->m_sWebAllFontsJSPath.empty())
if (!m_pMain->m_sWebFontsDirectory.empty() && !m_pMain->m_sWebAllFontsJSPath.empty() && !m_bIsCheckThumbnailsMode)
{
sFontFilesWeb = SaveWebFonts(mapFontFiles);
}
@ -1564,14 +1564,32 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
// читаем "новый" набор шрифтов
NSFonts::IApplicationFonts* pApplicationF = NSFonts::NSApplication::Create();
std::vector<std::wstring> strFontsW_CurSrc;
std::vector<std::wstring> strFontsW_Cur;
if (m_bIsUseSystemFonts)
strFontsW_Cur = pApplicationF->GetSetupFontFiles();
strFontsW_CurSrc = pApplicationF->GetSetupFontFiles();
for (std::vector<std::wstring>::iterator i = m_arAdditionalFolders.begin(); i != m_arAdditionalFolders.end(); i++)
{
NSDirectory::GetFiles2(*i, strFontsW_Cur, true);
NSDirectory::GetFiles2(*i, strFontsW_CurSrc, true);
}
// удаляем папки, которые не нужно парсить
strFontsW_Cur.reserve(strFontsW_CurSrc.size());
for (std::vector<std::wstring>::iterator i = strFontsW_CurSrc.begin(); i != strFontsW_CurSrc.end(); i++)
{
#ifdef _WIN32
if (i->find(L"\\.git\\") == std::wstring::npos)
strFontsW_Cur.push_back(*i);
//if (i->find(L"\\.svn\\") == std::wstring::npos)
// strFontsW_Cur.push_back(*i);
#else
if (i->find(L"/.git/") == std::wstring::npos)
strFontsW_Cur.push_back(*i);
//if (i->find(L"/.svn/") == std::wstring::npos)
// strFontsW_Cur.push_back(*i);
#endif
}
// сортируем (нужно для сравнения для старого набора)

View File

@ -281,16 +281,13 @@ namespace ZLibZipUtils
{
char filename_inzipA[256];
wchar_t filename_inzip[256];
wchar_t* filename_withoutpath;
wchar_t* p;
int err=UNZ_OK;
NSFile::CFileBinary oFile;
FILE *fout=NULL;
void* buf;
uInt size_buf;
wchar_t* filename_withoutpath = NULL;
wchar_t* p = NULL;
int err = UNZ_OK;
unz_file_info file_info;
uLong ratio=0;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzipA,sizeof(filename_inzipA),NULL,0,NULL,0);
std::wstring filenameW = codepage_issue_fixFromOEM(filename_inzipA);
@ -301,13 +298,6 @@ namespace ZLibZipUtils
return err;
}
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
if (buf==NULL)
{
return UNZ_INTERNALERROR;
}
p = filename_withoutpath = filename_inzip;
while ((*p) != '\0')
{
@ -333,10 +323,10 @@ namespace ZLibZipUtils
else
write_filename = filename_withoutpath;
err = unzOpenCurrentFilePassword(uf,password);
err = unzOpenCurrentFilePassword(uf, password);
if (((*popt_overwrite)==0) && (err==UNZ_OK))
{
char rep=0;
char rep = 0;
NSFile::CFileBinary oFileTemp;
if (oFileTemp.OpenFile(write_filename))
{
@ -349,6 +339,36 @@ namespace ZLibZipUtils
if (rep == 'A')
*popt_overwrite=1;
}
//-------------------------------------------------------------------------------------------------
char* current_directory = getcwd(NULL, 0);
if (current_directory)
{
std::string current_path(current_directory);
free(current_directory);
current_path += FILE_SEPARATOR_STRA;
replace_all(current_path, "/", FILE_SEPARATOR_STRA);
replace_all(current_path, "\\", FILE_SEPARATOR_STRA);
std::string filename_inzip(filename_inzipA);
replace_all(filename_inzip, "/", FILE_SEPARATOR_STRA);
replace_all(filename_inzip, "\\", FILE_SEPARATOR_STRA);
std::string norm_path = normalize_path(current_path + filename_inzip);
std::string norm_current_path = normalize_path(current_path);
if (std::string::npos == norm_path.find(norm_current_path))
{
return UNZ_INTERNALERROR;
}
}
//-------------------------------------------------------------------------------------------------
NSFile::CFileBinary oFile;
FILE *fout = NULL;
if ((skip==0) && (err==UNZ_OK))
{
@ -356,33 +376,10 @@ namespace ZLibZipUtils
fout = oFile.GetFileNative();
// some zipfile don't contain directory alone before file
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
if ((fout == NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(wchar_t*)filename_inzip))
{
char* current_directory = getcwd(NULL, 0);
if (current_directory)
{
std::string current_path(current_directory);
free(current_directory);
current_path += FILE_SEPARATOR_STRA;
replace_all(current_path, "/", FILE_SEPARATOR_STRA);
replace_all(current_path, "\\", FILE_SEPARATOR_STRA);
std::string filename_inzip(filename_inzipA);
replace_all(filename_inzip, "/", FILE_SEPARATOR_STRA);
replace_all(filename_inzip, "\\", FILE_SEPARATOR_STRA);
std::string norm_path = normalize_path(current_path + filename_inzip);
std::string norm_current_path = normalize_path(current_path);
if (std::string::npos == norm_path.find(norm_current_path))
{
return UNZ_INTERNALERROR;
}
}
char c=*(filename_withoutpath-1);
*(filename_withoutpath-1)='\0';
makedir(write_filename);
@ -395,41 +392,50 @@ namespace ZLibZipUtils
}
}
if (fout!=NULL)
{
do
{
err = unzReadCurrentFile(uf, buf, size_buf);
if (err<0)
{
break;
}
if (err>0)
if (fwrite(buf,err,1,fout)!=1)
{
err=UNZ_ERRNO;
break;
}
}
while (err>0);
//close вызовется в oFile
//if (fout)
// fclose(fout);
uInt size_buf = WRITEBUFFERSIZE;
void* buf = (void*)malloc(size_buf);
if (err==0)
change_file_date(write_filename,file_info.dosDate,
file_info.tmu_date);
if (buf == NULL)
{
return UNZ_INTERNALERROR;
}
if (err==UNZ_OK)
if (fout != NULL)
{
do
{
err = unzReadCurrentFile(uf, buf, size_buf);
if (err<0)
{
break;
}
if (err>0)
if (fwrite(buf, err, 1, fout) != 1)
{
err=UNZ_ERRNO;
break;
}
}
while (err>0);
//close вызовется в oFile
if (err==0)
{
change_file_date(write_filename, file_info.dosDate, file_info.tmu_date);
}
}
if (err == UNZ_OK)
{
err = unzCloseCurrentFile (uf);
}
else
unzCloseCurrentFile(uf); // don't lose the error
unzCloseCurrentFile(uf); // don't lose the error
free(buf);
}
free(buf);
return err;
}

View File

@ -149,13 +149,20 @@ namespace NSUnicodeConverter
std::wstring toUnicode(const char* sInput, const unsigned int& nInputLen, int nCodePage, bool isExact)
{
std::wstring sRes = L"";
if (!isExact && nInputLen > 0)
if (nInputLen > 0)
{
CFStringEncoding nEncodingCF = CFStringConvertWindowsCodepageToEncoding((unsigned int)nCodePage);
if (kCFStringEncodingInvalidId == nEncodingCF)
{
if (isExact)
{
std::string strInputA(sInput, nInputLen);
sRes = std::wstring(strInputA.begin(), strInputA.end());
}
return sRes;
NSStringEncoding nEncodingNS = CFStringConvertEncodingToNSStringEncoding(nEncodingCF);
}
NSStringEncoding nEncodingNS = CFStringConvertEncodingToNSStringEncoding(nEncodingCF);
NSString* sUnicodeNS = [[NSString alloc] initWithBytes:sInput length:nInputLen encoding:nEncodingNS];
sRes = NSStringToStdstring(sUnicodeNS);
}
@ -164,12 +171,19 @@ namespace NSUnicodeConverter
std::wstring toUnicode(const char* sInput, const unsigned int& nInputLen, const char* converterName, bool isExact)
{
std::wstring sRes = L"";
if (!isExact && nInputLen > 0)
if (nInputLen > 0)
{
NSString* sEncodingCF = StringAToNSString(std::string(converterName));
CFStringEncoding nEncodingCF = CFStringConvertIANACharSetNameToEncoding((CFStringRef)sEncodingCF);
if (kCFStringEncodingInvalidId == nEncodingCF)
{
if (isExact)
{
std::string strInputA(sInput, nInputLen);
sRes = std::wstring(strInputA.begin(), strInputA.end());
}
return sRes;
}
NSStringEncoding nEncodingNS = CFStringConvertEncodingToNSStringEncoding(nEncodingCF);
NSString* sUnicodeNS = [[NSString alloc] initWithBytes:sInput length:nInputLen encoding:nEncodingNS];

View File

@ -26,7 +26,7 @@ build_x2t_as_library {
include(X2tConverter.pri)
build_x2t_as_library {
shared:QMAKE_LFLAGS += -exported_symbols_list $$PWD/../../src/dylib/export
!core_debug:shared:QMAKE_LFLAGS += -exported_symbols_list $$PWD/../../src/dylib/export
}

View File

@ -234,7 +234,8 @@ namespace BinXlsxRW
HashValue = 2,
SaltValue = 3,
LockStructure = 4,
LockWindows = 5
LockWindows = 5,
Password
}; }
namespace c_oSerDbPrTypes{enum c_oSerDbPrTypes
{

View File

@ -2183,6 +2183,12 @@ void BinaryWorkbookTableWriter::WriteProtection(const OOX::Spreadsheet::CWorkboo
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(protection.m_oLockWindows->ToBool());
}
if (protection.m_oPassword.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWorkbookProtection::Password);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
m_oBcw.m_oStream.WriteStringW(*protection.m_oPassword);
}
}
void BinaryWorkbookTableWriter::WriteWorkbookPr(const OOX::Spreadsheet::CWorkbookPr& workbookPr)
{

View File

@ -2558,6 +2558,10 @@ int BinaryWorkbookTableReader::ReadProtection(BYTE type, long length, void* poRe
{
m_oWorkbook.m_oWorkbookProtection->m_oWorkbookSaltValue = m_oBufferedStream.GetString4(length);
}
else if (c_oSerWorkbookProtection::Password == type)
{
m_oWorkbook.m_oWorkbookProtection->m_oPassword = m_oBufferedStream.GetString4(length);
}
else if (c_oSerWorkbookProtection::LockStructure == type)
{
m_oWorkbook.m_oWorkbookProtection->m_oLockStructure.Init();
@ -3743,6 +3747,11 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_map<BYTE, std::v
OOX::Spreadsheet::CSheetProtection oProtection;
READ2_DEF_SPREADSHEET(length, res, this->ReadProtection, &oProtection);
SEEK_TO_POS_END(oProtection);
//-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::ProtectedRanges);
OOX::Spreadsheet::CProtectedRanges oProtectedRanges;
READ1_DEF(length, res, this->ReadProtectedRanges, &oProtectedRanges);
SEEK_TO_POS_END(oProtectedRanges);
//-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::Autofilter);
OOX::Spreadsheet::CAutofilter oAutofilter;
@ -3848,11 +3857,6 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_map<BYTE, std::v
OOX::Spreadsheet::CHyperlinks oHyperlinks;
READ1_DEF(length, res, this->ReadHyperlinks, &oHyperlinks);
SEEK_TO_POS_END(oHyperlinks);
//-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::ProtectedRanges);
OOX::Spreadsheet::CProtectedRanges oProtectedRanges;
READ1_DEF(length, res, this->ReadProtectedRanges, &oProtectedRanges);
SEEK_TO_POS_END(oProtectedRanges);
//-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::PrintOptions);
OOX::Spreadsheet::CPrintOptions oPrintOptions;