Compare commits

..

25 Commits

Author SHA1 Message Date
8df2390d9d [x2t] Сonvert ooxml to pdf/img without Editor.bin with m_sConvertToOrigin param 2022-06-26 19:13:14 +03:00
f5789d5059 Merge pull request #974 from ONLYOFFICE/fix/v7.2.0-fix-bugs
fix bug #57788
2022-06-25 19:15:59 +03:00
f97a7b1ea3 fix bug #57788 2022-06-25 19:14:42 +03:00
1a0ecb17a7 Refactoring GetCurrentContext 2022-06-25 09:47:19 +03:00
bc447c4522 Fix parallel working of js contexts (jsc) 2022-06-24 21:35:07 +03:00
bebdd90aa2 Merge pull request #973 from ONLYOFFICE/fix/v7.2.0-fix-bugs
.
2022-06-24 17:02:50 +03:00
7d91973ddd . 2022-06-24 17:01:04 +03:00
d98d1859b4 Merge pull request #972 from ONLYOFFICE/fix/v7.2.0-fix-bugs
.
2022-06-24 16:51:59 +03:00
2e34600e01 . 2022-06-24 16:51:13 +03:00
4e4d69235d Merge pull request #971 from ONLYOFFICE/fix/v7.2.0-fix-bugs
for bug #57788
2022-06-24 16:47:33 +03:00
29125519d9 for bug #57788 2022-06-24 16:47:03 +03:00
46c6efee45 Merge pull request #970 from ONLYOFFICE/fix/v7.2.0-ppt
fix part of 57689. Add XmlUtils::EncodeXmlString()
2022-06-24 15:52:57 +03:00
690a614ba5 Merge pull request #968 from ONLYOFFICE/fix/v7.2.0-fix-bugs
fix bug #45874
2022-06-24 14:24:20 +03:00
b48e6d508d fix bug #45874 2022-06-24 14:23:44 +03:00
65a469ef92 Merge pull request #967 from ONLYOFFICE/fix/v7.2.0-fix-bugs
Fix/v7.2.0 fix bugs
2022-06-23 20:44:11 +03:00
41a4eedb63 fix bug #57544 2022-06-23 20:43:28 +03:00
19bec43364 fix bug #57702 2022-06-23 17:19:06 +03:00
21f134cf71 Fix writing underline type to binary 2022-06-23 14:27:44 +03:00
80b361fe7d Merge pull request #966 from ONLYOFFICE/fix/v7.2.0-fix-bugs2
Fix/v7.2.0 fix bugs2
2022-06-23 11:46:21 +03:00
32c752a71f for bug #52363
extend xlsx connection
re-place vba xml in binary
2022-06-23 11:45:31 +03:00
1fe41b8b23 fix part of 57689. Add XmlUtils::EncodeXmlString() 2022-06-22 23:24:09 +03:00
464aa7c8c4 xlsx - fix convert ActiveX to Control (FormControlPr) 2022-06-22 19:33:49 +03:00
9646ac25ae Fix project file 2022-06-22 16:48:47 +03:00
b928936f2b fix bug #57677 2022-06-22 12:34:12 +03:00
69448ebba0 fix bug #57682 2022-06-22 12:28:50 +03:00
35 changed files with 1513 additions and 809 deletions

View File

@ -45,7 +45,6 @@ namespace DocFileFormat
m_document = static_cast<WordDocument*>( visited );
//start the document
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_pXmlWriter->WriteNodeBegin( L"w:ftr", TRUE );
//write namespaces

View File

@ -197,6 +197,9 @@ public:
virtual int Seek (int offset, int origin = 0/*STREAM_SEEK_SET*/)
{
if (origin == 2) offset = m_Position + offset;
if (origin == 1) offset = m_Size - offset;
if ( (m_Data != NULL) && (offset >= 0) && ((unsigned int)offset < m_Size) )
return m_Position = offset;

View File

@ -35,8 +35,6 @@
#include "../../Common/Base64.h"
#include "../../Common/OfficeFileFormatChecker.h"
#include "../../ASCOfficeXlsFile2/source/VbaFormat/VbaReader.h"
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/App.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/Core.h"
@ -514,7 +512,7 @@ void Binary_rPrWriter::Write_rPr(OOX::Logic::CRunProperty* rPr)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::Underline);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(SimpleTypes::underlineNone != oU.m_oVal.get().GetValue());
m_oBcw.m_oStream.WriteBYTE(oU.m_oVal.get().GetValue());
}
}
//Strikeout
@ -9407,15 +9405,6 @@ void BinaryFileWriter::intoBindoc(const std::wstring& sDir)
this->WriteTableEnd(nCurPos);
CVbaReader vbaReader(pDocx->m_pVbaProject->filename().GetPath(), L"");
std::wstring sXml = vbaReader.convert();
if (false == sXml.empty())
{
m_oBcw.m_oStream.StartRecord(1);
m_oBcw.m_oStream.WriteStringW(sXml);
m_oBcw.m_oStream.EndRecord();
}
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}

View File

@ -734,7 +734,7 @@ void odf_document::Impl::parse_meta(office_element *element)
context_->DocProps().template_ = meta_generator_->content_;
meta_creation_date * meta_creation_date_ = dynamic_cast<meta_creation_date*>(meta->meta_creation_date_.get());
if (meta_generator_)
if (meta_creation_date_)
context_->DocProps().creation_date_ = meta_creation_date_->content_;
meta_keyword * meta_keyword_ = dynamic_cast<meta_keyword*>(meta->meta_keyword_.get());
@ -750,7 +750,7 @@ void odf_document::Impl::parse_meta(office_element *element)
context_->DocProps().non_whitespace_character_count_ = meta_document_statistic_->non_whitespace_character_count_;
}
meta_editing_cycles * meta_editing_cycles_ = dynamic_cast<meta_editing_cycles*>(meta->meta_editing_cycles_.get());
if (meta_keyword_)
if (meta_editing_cycles_)
context_->DocProps().revision_ = XmlUtils::GetInteger(meta_editing_cycles_->content_);
}

View File

@ -231,18 +231,6 @@ namespace PPTX
pWriter->WriteRecord2(9, m_pJsaProject);
pWriter->WriteRecord2(10, comments);
if (m_pVbaProject.IsInit())
{
CVbaReader vbaReader(m_pVbaProject.smart_dynamic_cast<OOX::Media>()->filename().GetPath(), L"");
std::wstring sXml = vbaReader.convert();
if (false == sXml.empty())
{
pWriter->StartRecord(11);
pWriter->WriteStringW(sXml);
pWriter->EndRecord();
}
}
pWriter->EndRecord();
}
void Presentation::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)

View File

@ -514,7 +514,28 @@ const size_t hex_str2int(const std::wstring::const_iterator& it_begin, const std
//}
std::wstring toStdWString(std::string ansi_string, const _UINT32 code_page)
{
std::string sCodePage;
//#if defined (_WIN32) || defined (_WIN64)
// std::wstring sResult;
//
// int outsize_with_0 = MultiByteToWideChar(code_page, 0, ansi_string.c_str(), -1, NULL, NULL);
//
// sResult.resize(outsize_with_0);
// if (MultiByteToWideChar(code_page, 0, ansi_string.c_str(), -1, (LPWSTR)sResult.c_str(), outsize_with_0) > 0)
// {
// sResult.erase(outsize_with_0 - 1);
// }
// else
// {
// std::locale loc("");
// std::ctype<wchar_t> const &facet = std::use_facet<std::ctype<wchar_t> >(loc);
//
// sResult.resize(ansi_string.size());
//
// facet.widen(ansi_string.c_str(), ansi_string.c_str() + ansi_string.size(), &sResult[0]);
// }
// return sResult;
//#else
std::string sCodePage;
std::map<int, std::string>::const_iterator pFind = NSUnicodeConverter::mapEncodingsICU.find(code_page);
if (pFind != NSUnicodeConverter::mapEncodingsICU.end())
{
@ -543,6 +564,7 @@ std::wstring toStdWString(std::string ansi_string, const _UINT32 code_page)
return result;
}
//#endif
}
std::wstring toStdWString(char* ansi, int size, const _UINT32 code_page)
{

View File

@ -126,7 +126,11 @@ void OfficeArtRGFOPTE::load(XLS::CFRecord& record)
if (rgfopte[i]->fComplex)
{
if (rgfopte[i]->op < 0)
if (rgfopte[i]->op == 0)
{
continue;
}
else if (rgfopte[i]->op < 0)
{
break;
}

View File

@ -72,6 +72,7 @@ bool PropertyString::Read (XLS::CFStreamPtr stream)
for (_INT32 i = size - 1; i >= 0; i--)
{
if (s[i] == 0) size--;
else break;
}
value = size > 0 ? STR::toStdWString(std::string(s, size), code_page) : L"";
@ -97,7 +98,14 @@ bool PropertyWString::Read(XLS::CFStreamPtr stream)
char *s = new char[size];
stream->read(s, size);
value = std::wstring((wchar_t*)s, size / 2);
if (sizeof(wchar_t) == 4)
{
value = convertUtf16ToWString((UTF16*)s, size / 2);
}
else
{
value = std::wstring((wchar_t*)s, size / 2);
}
delete[]s;
}

View File

@ -97,7 +97,7 @@ namespace OLEPS
if (prop)
break;
}
return prop;
return prop;
}
const unsigned short PropertySetStream::GetCodePage()
{
@ -122,7 +122,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Template")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(MANAGER);
@ -130,7 +130,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Manager")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(COMPANY);
@ -138,7 +138,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Company")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(PAGECOUNT);
@ -146,7 +146,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Pages")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(WORDCOUNT);
@ -154,7 +154,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Words")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
//prop = GetProperty(CHARCOUNT);
@ -162,7 +162,7 @@ namespace OLEPS
//{
// CP_XML_NODE(L"CharactersWithSpaces")
// {
// CP_XML_STREAM() << prop->toString();
// CP_XML_STREAM() << prop->toString();
// }
//}
prop = GetProperty(CHARCOUNT);
@ -170,7 +170,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Characters")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(PRESFORMAT);
@ -178,7 +178,7 @@ namespace OLEPS
{
CP_XML_NODE(L"PresentationFormat")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(LINECOUNT);
@ -186,7 +186,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Lines")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(PARACOUNT);
@ -194,7 +194,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Paragraphs")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(SLIDECOUNT);
@ -202,7 +202,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Slides")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(NOTECOUNT);
@ -210,7 +210,7 @@ namespace OLEPS
{
CP_XML_NODE(L"Notes")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(HIDDENCOUNT);
@ -218,7 +218,7 @@ namespace OLEPS
{
CP_XML_NODE(L"HiddenSlides")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(MMCLIPCOUNT);
@ -226,7 +226,7 @@ namespace OLEPS
{
CP_XML_NODE(L"MMClips")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(SCALE);
@ -234,7 +234,7 @@ namespace OLEPS
{
CP_XML_NODE(L"ScaleCrop")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(HEADINGPAIR);
@ -242,7 +242,7 @@ namespace OLEPS
{
CP_XML_NODE(L"HeadingPairs")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(DOCPARTS);
@ -250,7 +250,7 @@ namespace OLEPS
{
CP_XML_NODE(L"TitlesOfParts")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(LINKBASE);
@ -258,7 +258,7 @@ namespace OLEPS
{
CP_XML_NODE(L"LinksUpToDate")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(CCHWITHSPACES);
@ -266,7 +266,7 @@ namespace OLEPS
{
CP_XML_NODE(L"CharactersWithSpaces")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(SHAREDDOC);
@ -274,7 +274,7 @@ namespace OLEPS
{
CP_XML_NODE(L"SharedDoc")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
// LINKBASE = 0x1014,
@ -283,7 +283,7 @@ namespace OLEPS
{
CP_XML_NODE(L"HLinks")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(HYPERLINKSCHANGED);
@ -291,7 +291,7 @@ namespace OLEPS
{
CP_XML_NODE(L"HyperlinksChanged")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
// DIGSIG = 0x1018,
@ -300,7 +300,7 @@ namespace OLEPS
prop = GetProperty(APPNAME);
if (prop)
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
else
{
@ -319,7 +319,7 @@ namespace OLEPS
{
CP_XML_NODE(L"AppVersion")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(DOC_SECURITY);
@ -327,7 +327,7 @@ namespace OLEPS
{
CP_XML_NODE(L"DocSecurity")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
}
@ -355,8 +355,8 @@ namespace OLEPS
if (prop)
{
CP_XML_NODE(L"dc:title")
{
CP_XML_STREAM() << prop->toString();
{
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(SUBJECT);
@ -364,7 +364,9 @@ namespace OLEPS
{
CP_XML_NODE(L"dc:subject")
{
CP_XML_STREAM() << prop->toString();
auto correctedSubject = prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(AUTHOR);
@ -372,7 +374,7 @@ namespace OLEPS
{
CP_XML_NODE(L"dc:creator")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(KEYWORDS);
@ -380,7 +382,7 @@ namespace OLEPS
{
CP_XML_NODE(L"cp:keywords")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(COMMENTS);
@ -388,7 +390,7 @@ namespace OLEPS
{
CP_XML_NODE(L"dc:description")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(LANGUAGE);
@ -396,14 +398,14 @@ namespace OLEPS
{
CP_XML_NODE(L"dc:language")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
} prop = GetProperty(VERSION);
if (prop)
{
CP_XML_NODE(L"cp:version")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(LASTAUTHOR);
@ -411,7 +413,7 @@ namespace OLEPS
{
CP_XML_NODE(L"cp:lastModifiedBy")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(REVNUMBER);
@ -419,7 +421,7 @@ namespace OLEPS
{
CP_XML_NODE(L"cp:revision")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(CREATE_DTM);
@ -428,7 +430,7 @@ namespace OLEPS
CP_XML_NODE(L"dcterms:created")
{
CP_XML_ATTR(L"xsi:type", L"dcterms:W3CDTF");
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(LASTSAVE_DTM);
@ -437,7 +439,7 @@ namespace OLEPS
CP_XML_NODE(L"dcterms:modified")
{
CP_XML_ATTR(L"xsi:type", L"dcterms:W3CDTF");
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(CATEGORY);
@ -445,7 +447,7 @@ namespace OLEPS
{
CP_XML_NODE(L"cp:category")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
prop = GetProperty(CONTENTSTATUS);
@ -453,7 +455,7 @@ namespace OLEPS
{
CP_XML_NODE(L"cp:contentStatus")
{
CP_XML_STREAM() << prop->toString();
CP_XML_STREAM() << prop->toString();
}
}
// BYTECOUNT = 0x1004,

View File

@ -1294,7 +1294,9 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
}
//-----------------------------------------------------------------------------
if (type_object < 0) continue;
if (type_object < 0) continue;
if (group_objects.empty())
break; /// что то с объектами не то ! 2006 02.xls
if (type_object == 0)
{
@ -1799,7 +1801,7 @@ void XlsConverter::convert_blip(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
id += 3000;
std::wstring rId = xlsx_context->get_mediaitems().find_image(id , target, isIternal);
xlsx_context->get_drawing_context().set_fill_texture(target);
xlsx_context->get_drawing_context().set_picture(target);
}break;
case ODRAW::pibName:
{

View File

@ -885,6 +885,9 @@ void xlsx_drawing_context::end_drawing(_drawing_state_ptr & drawing_state)
{
drawing_state->type = external_items::typeImage;
if (!drawing_state->fill.picture_target.empty())
drawing_state->fill.texture_target = drawing_state->fill.picture_target;
if (!drawing_state->fill.texture_target.empty())
{
bool isIternal = false;
@ -2802,7 +2805,7 @@ void xlsx_drawing_context::set_sheet_anchor(int colFrom, int xFrom, int rwFrom,
{
if (current_drawing_states == NULL) return;
if (colTo > 0 && rwTo > 0)
if (colTo > 0 || rwTo > 0)
{// 0 in comment old versions
current_drawing_states->back()->sheet_anchor.colFrom = colFrom;
current_drawing_states->back()->sheet_anchor.colTo = colTo;
@ -2879,6 +2882,22 @@ void xlsx_drawing_context::set_fill_texture(const std::wstring & str)
current_drawing_states->back()->fill.texture_mode = textureStretch;
}
}
void xlsx_drawing_context::set_picture(const std::wstring & str)
{
if (current_drawing_states == NULL) return;
if (current_drawing_states->empty()) return;
if (str.empty()) return;
if (false == current_drawing_states->back()->fill.picture_target.empty()) return;
current_drawing_states->back()->fill.picture_target = str;
if (current_drawing_states->back()->fill.type == fillUndefined)
{
current_drawing_states->back()->fill.type = fillTexture;
current_drawing_states->back()->fill.texture_mode = textureStretch;
}
}
void xlsx_drawing_context::set_picture_crop_top (double val)
{
if (current_drawing_states == NULL) return;

View File

@ -281,6 +281,7 @@ public:
double angle = 0;
std::wstring texture_target;
std::wstring picture_target;
double texture_crop[4];
bool texture_crop_enabled = false;
_texture_mode texture_mode;
@ -418,6 +419,7 @@ public:
void set_picture_contrast (int val);
void set_picture_biLevel (int val);
void set_picture_transparent(int nColor, const std::wstring & sColor);
void set_picture (const std::wstring & str);
void set_rotation (double val);

View File

@ -112,7 +112,6 @@ namespace OOX
}
void ActiveX_xml::read_bin(const CPath& oPath)
{
return;
NSFile::CFileBinary file;
if (false == m_oClassId.IsInit()) return;
@ -186,9 +185,9 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
else if (class_id == L"{4C599241-6926-101B-9992-00000B65C6F9}") return new ActiveXObjectImage();
else if (class_id == L"{8BD21D60-EC42-11CE-9E0D-00AA006002F3}") return new ActiveXObjectMorphData(SimpleTypes::Spreadsheet::objectButton); //Toggle
else
return NULL;
return new ActiveXObjectMorphData(); //from DisplayStyle
}
std::wstring ActiveXObject::ReadString(MemoryStream *stream, size_t size, bool bCompressed)
std::wstring ActiveXObject::readString(MemoryStream *stream, size_t size, bool bCompressed)
{
if (!stream) return L"";
if (stream->GetPosition() + size > stream->GetSize())
@ -215,6 +214,96 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
return result;
}
void ActiveXObject::readTextProps(MemoryStream *stream)
{
if (!stream) return;
int sizeFontName = 0;
bool bCaptionCompressed, bGroupNameCompressed, bValueCompressed, bFontNameCompressed;
int nFontCharSet = 0, nFontPitch = 0, nFontFamily = 0, nParagraphAlign = 0;
unsigned char MinorVersionText = stream->ReadByte();
unsigned char MajorVersionText = stream->ReadByte();
unsigned short cbTextProps = stream->ReadUInt16();
_UINT32 PropMask = stream->ReadUInt32();
bool fFontName = GETBIT(PropMask, 0);
bool fFontEffects = GETBIT(PropMask, 1);
bool fFontHeight = GETBIT(PropMask, 3);
bool fFontCharSet = GETBIT(PropMask, 5);
bool fFontPitchAndFamily = GETBIT(PropMask, 6);
bool fParagraphAlign = GETBIT(PropMask, 7);
bool fFontWeight = GETBIT(PropMask, 8);
if (fFontName)
{
sizeFontName = stream->ReadUInt32();
bFontNameCompressed = GETBIT(sizeFontName, 31);
sizeFontName = GETBITS(sizeFontName, 0, 30);
}
if (fFontEffects)
{
_UINT32 nFontEffects = stream->ReadUInt32();
bool bEnabled = !GETBIT(PropMask, 13);
m_oFontBold = GETBIT(PropMask, 0);
m_oFontItalic = GETBIT(PropMask, 1);
m_oFontUnderline = GETBIT(PropMask, 3);
m_oFontStrikeout = GETBIT(PropMask, 4);
m_oFontAutoColor = GETBIT(PropMask, 30);
}
if (fFontHeight)
{
m_oFontHeight = stream->ReadUInt32() / 20; //twips to pt
}
int count_padding = 4;
if (fFontCharSet)
{
nFontCharSet = stream->ReadByte(); count_padding--;
}
if (fFontPitchAndFamily)
{
_UINT32 nFontPitchAndFamily = stream->ReadByte(); count_padding--;
nFontPitch = GETBITS(nFontPitchAndFamily, 0, 3);
nFontFamily = GETBITS(nFontPitchAndFamily, 4, 7);
}
if (fParagraphAlign)
{
nParagraphAlign = stream->ReadByte(); count_padding--;
}
if (count_padding > 0 && count_padding < 4)
stream->Seek(count_padding, 2);
if (fFontWeight)
{
_UINT32 nFontWeight = stream->ReadByte();
/*Padding4 =*/ stream->ReadUInt16();
}
if (sizeFontName > 0)
{
_UINT16 nX1= stream->ReadUInt16();
_UINT16 nX3 = stream->ReadUInt16();
m_oFontName = readString(stream, sizeFontName, bFontNameCompressed);
}
}
std::pair<boost::shared_array<unsigned char>, size_t> ActiveXObject::readStdPicture(MemoryStream *stream)
{
boost::shared_array<unsigned char> empty;
if (!stream) return std::make_pair(empty, 0);
_UINT32 Preamble = stream->ReadUInt32();
if (Preamble != 0x0000746C) return std::make_pair(empty, 0);
size_t Size = stream->ReadUInt32();
boost::shared_array<unsigned char> buf(stream->ReadBytes(Size, true));
return std::make_pair(buf, Size);
}
void ActiveXObject::toFormControlPr(OOX::Spreadsheet::CFormControlPr* pFormControlPr)
{
if (!pFormControlPr) return;
@ -322,7 +411,12 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
m_oHeight = mem_stream.ReadUInt32();
}
int stream_size = mem_stream.GetSize() - mem_stream.GetPosition();
//MouseIcon
if (fMouseIcon)
{
mem_stream.Seek(16, 2);//guid
m_oMouseIcon = readStdPicture(&mem_stream);
}
}
void ActiveXObjectSpin::Parse(unsigned char* pData, DWORD size)
{
@ -381,7 +475,12 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
m_oHeight = mem_stream.ReadUInt32();
}
int stream_size = mem_stream.GetSize() - mem_stream.GetPosition();
//MouseIcon
if (fMouseIcon)
{
mem_stream.Seek(16, 2);//guid
m_oMouseIcon = readStdPicture(&mem_stream);
}
}
void ActiveXObjectButton::Parse(unsigned char* pData, DWORD size)
{
@ -432,7 +531,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
}
if (fPicture)
{
/*m_oPicture = */ mem_stream.ReadUInt16();
mem_stream.ReadUInt16(); //0 or 0xffff
/*Padding4 =*/ mem_stream.ReadUInt16();
}
if (fAccelerator)
@ -442,12 +541,12 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
}
if (fMouseIcon)
{
/*m_oMouseIcon =*/ mem_stream.ReadUInt16();
mem_stream.ReadUInt16(); //0 or oxffff
/*Padding3 =*/ mem_stream.ReadUInt16();
}
if (sizeCaption > 0)
{
m_oCaption = ReadString(&mem_stream, sizeCaption, bCaptionCompressed);
m_oCaption = readString(&mem_stream, sizeCaption, bCaptionCompressed);
}
if (fSize)
{
@ -455,7 +554,18 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
m_oHeight = mem_stream.ReadUInt32();
}
int stream_size = mem_stream.GetSize() - mem_stream.GetPosition();
//MouseIcon
if (fMouseIcon)
{
mem_stream.Seek(16, 2);//guid
m_oMouseIcon = readStdPicture(&mem_stream);
}
if (fPicture)
{
mem_stream.Seek(16, 2);//guid
m_oPicture = readStdPicture(&mem_stream);
}
readTextProps(&mem_stream);
}
void ActiveXObjectImage::Parse(unsigned char* pData, DWORD size)
{
@ -616,7 +726,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
}
if (sizeCaption > 0)
{
m_oCaption = ReadString(&mem_stream, sizeCaption, bCaptionCompressed);
m_oCaption = readString(&mem_stream, sizeCaption, bCaptionCompressed);
}
if (fSize)
{
@ -624,7 +734,18 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
m_oHeight = mem_stream.ReadUInt32();
}
int stream_size = mem_stream.GetSize() - mem_stream.GetPosition();
//MouseIcon
if (fMouseIcon)
{
mem_stream.Seek(16, 2);//guid
m_oMouseIcon = readStdPicture(&mem_stream);
}
if (fPicture)
{
mem_stream.Seek(16, 2);//guid
m_oPicture = readStdPicture(&mem_stream);
}
readTextProps(&mem_stream);
}
void ActiveXObjectFormControl::Parse(unsigned char* pData, DWORD size)
{
@ -637,9 +758,26 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
unsigned short cb = mem_stream.ReadUInt16();
_UINT32 PropMask = mem_stream.ReadUInt32();
//if (fMouseIcon)
//{
// mem_stream.Seek(16, 2);//guid
// m_oMouseIcon = readStdPicture(&mem_stream);
//}
//if (fGuidAndFont)
//{
// mem_stream.Seek(16, 2);//guid
// m_oFont = readFont(&mem_stream);
//}
//if (fPicture)
//{
// mem_stream.Seek(16, 2);//guid
// m_oPicture = readStdPicture(&mem_stream);
//}
}
void ActiveXObjectMorphData::Parse(unsigned char* pData, DWORD size)
{
{
//CheckBox, ComboBox, ListBox, OptionButton, TextBox, and ToggleButton
MemoryStream mem_stream(pData, size, false);
mem_stream.Seek(16);
@ -683,7 +821,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
bool fPicture = GETBIT(PropMask, 28);
bool fAccelerator = GETBIT(PropMask, 29);
bool fGroupName = GETBIT(PropMask2, 0);
//MorphData-DataBlock
int MaxLength = 0;
if (fVariousPropertyBits) /*VariousPropertyBits =*/ mem_stream.ReadUInt32();
if (fForeColor) m_oForeColor = mem_stream.ReadUInt32();
@ -701,14 +839,27 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
}
if (fDisplayStyle)
{
/*m_oDisplayStyle =*/ mem_stream.ReadByte(); count_padding--;
if (false == m_oObjectType.IsInit()) m_oObjectType.Init();
int nDisplayStyle = mem_stream.ReadByte(); count_padding--;
switch (nDisplayStyle)
{
case 0x01: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectEditBox); break;
case 0x02: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectList); break;
case 0x03: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectDrop); break;
case 0x04: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectCheckBox); break;
case 0x05: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectRadio); break;
case 0x06: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectButton); break; // toggle
case 0x07: m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectList); break;
}
}
if (fMousePointer)
{
/*m_oMousePointer =*/ mem_stream.ReadByte(); count_padding--;
}
if (count_padding > 0 && count_padding < 4)
mem_stream.Seek(mem_stream.GetPosition() + count_padding);
mem_stream.Seek(count_padding, 2);
if (fPasswordChar)
{
m_oPasswordEdit = true;
@ -786,12 +937,12 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
if (fSpecialEffect) /*m_oEffect =*/ mem_stream.ReadUInt32();
if (fMouseIcon)
{
/*m_oMouseIcon =*/ mem_stream.ReadUInt16();
mem_stream.ReadUInt16(); //0 or 0xFFFF
/*Padding3 =*/ mem_stream.ReadUInt16();
}
if (fPicture)
{
/*m_oPicture = */ mem_stream.ReadUInt16();
mem_stream.ReadUInt16();//0 or 0xFFFF
/*Padding4 =*/ mem_stream.ReadUInt16();
}
if (fAccelerator)
@ -806,6 +957,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
bGroupNameCompressed = GETBIT(sizeGroupName, 31);
sizeGroupName = GETBITS(sizeGroupName, 0, 30);
}
//MorphData-ExtraDataBlock
if (fSize)
{
m_oWidth = mem_stream.ReadUInt32();
@ -813,19 +965,31 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\""
}
if (sizeValue > 0)
{
m_oValue = ReadString(&mem_stream, sizeValue, bValueCompressed);
m_oValue = readString(&mem_stream, sizeValue, bValueCompressed);
}
if (sizeCaption > 0)
{
m_oCaption = ReadString(&mem_stream, sizeCaption, bCaptionCompressed);
m_oCaption = readString(&mem_stream, sizeCaption, bCaptionCompressed);
}
std::wstring oGroupName;
if (sizeGroupName > 0 && sizeGroupName < 0xfff0)
{
oGroupName = ReadString(&mem_stream, sizeGroupName, bGroupNameCompressed);
oGroupName = readString(&mem_stream, sizeGroupName, bGroupNameCompressed);
}
//MorphData-StreamData
int stream_size = mem_stream.GetSize() - mem_stream.GetPosition();
//MouseIcon
if (fMouseIcon)
{
mem_stream.Seek(16, 2);//guid
m_oMouseIcon = readStdPicture(&mem_stream);
}
if (fPicture)
{
mem_stream.Seek(16, 2);//guid
m_oPicture = readStdPicture(&mem_stream);
}
readTextProps(&mem_stream);
}
else
{

View File

@ -57,10 +57,13 @@ namespace OOX
virtual void Parse(unsigned char* pData, DWORD size) = 0;
void toFormControlPr(OOX::Spreadsheet::CFormControlPr* pFormControlPr);
std::wstring ReadString(MemoryStream *stream, size_t size, bool bCompressed);
std::wstring readString(MemoryStream *stream, size_t size, bool bCompressed);
void readTextProps(MemoryStream *stream);
std::pair<boost::shared_array<unsigned char>, size_t> readStdPicture(MemoryStream *stream);
nullable<SimpleTypes::Spreadsheet::CObjectType<>> m_oObjectType;
nullable_int m_oForeColor;
nullable_int m_oBackColor;
nullable_int m_oBorderColor;
@ -80,6 +83,17 @@ namespace OOX
nullable_int m_oWidth;
nullable_int m_oHeight;
nullable_string m_oFontName;
nullable_uint m_oFontHeight;
nullable_bool m_oFontBold;
nullable_bool m_oFontItalic;
nullable_bool m_oFontUnderline;
nullable_bool m_oFontStrikeout;
nullable_bool m_oFontAutoColor;
nullable<std::pair<boost::shared_array<unsigned char>, size_t>> m_oPicture;
nullable<std::pair<boost::shared_array<unsigned char>, size_t>> m_oMouseIcon;
};
class ActiveXObjectScroll : public ActiveXObject
@ -140,16 +154,21 @@ namespace OOX
public:
ActiveXObjectFormControl()
{
m_oObjectType = SimpleTypes::Spreadsheet::objectDialog;
m_oObjectType.Init();
m_oObjectType->SetValue(SimpleTypes::Spreadsheet::objectDialog);
}
virtual void Parse(unsigned char* pData, DWORD size);
};
class ActiveXObjectMorphData : public ActiveXObject
{
public:
ActiveXObjectMorphData()
{
}
ActiveXObjectMorphData(SimpleTypes::Spreadsheet::EObjectType type)
{
m_oObjectType = type;
m_oObjectType.Init();
m_oObjectType->SetValue(type);
}
virtual void Parse(unsigned char* pData, DWORD size);
};

View File

@ -40,6 +40,7 @@
#include "../IFileContainer.h"
#include "../../XlsxFormat/FileTypes_Spreadsheet.h"
#include "../../../../../ASCOfficeXlsFile2/source/VbaFormat/VbaReader.h"
namespace OOX
{
@ -92,17 +93,25 @@ namespace OOX
void VbaProject::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, m_filename.GetFilename());
pWriter->WriteString1(0, m_filename.GetFilename());
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
copy_to(pWriter->m_pCommon->m_pMediaManager->m_strDstMedia);
CVbaReader vbaReader(m_filename.GetPath(), L"");
std::wstring sXml = vbaReader.convert();
if (false == sXml.empty())
{
pWriter->StartRecord(0);
pWriter->WriteStringW2(sXml);
pWriter->EndRecord();
}
}
void VbaProject::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _rec_size = pReader->GetRecordSize();
LONG _end_rec = pReader->GetPos() + _rec_size + 4;
LONG _end_rec = pReader->GetPos() + _rec_size;
pReader->Skip(1); // start attributes
while (true)
@ -130,6 +139,24 @@ namespace OOX
break;
}
}
std::wstring sXml;
while (pReader->GetPos() < _end_rec)
{
BYTE rec = pReader->GetUChar();
switch (rec)
{
case 0:
{
_INT32 _len = pReader->GetRecordSize();
sXml = pReader->GetString2();
}break;
default:
{
pReader->SkipRecord();
}
}
}
pReader->Seek(_end_rec);
}
} // namespace OOX

View File

@ -1294,6 +1294,8 @@ namespace OOX
et_x_SheetView,
et_x_ProtectedRanges,
et_x_ProtectedRange,
et_x_CellWatches,
et_x_CellWatch,
et_x_GraphicFrame,
et_x_Graphic,
et_x_GraphicData,

View File

@ -4647,17 +4647,17 @@ namespace SimpleTypes
};
enum EObjectType
{
objectButton = 0,
objectCheckBox = 1,
objectDrop = 2,
objectGBox = 3,
objectLabel = 4,
objectList = 5,
objectRadio = 6,
objectScroll = 7,
objectSpin = 8,
objectEditBox = 9,
objectDialog = 10
objectButton = 0,
objectCheckBox = 1,
objectDrop = 2,
objectGBox = 3,
objectLabel = 4,
objectList = 5,
objectRadio = 6,
objectScroll = 7,
objectSpin = 8,
objectEditBox = 9,
objectDialog = 10
};
template<EObjectType eDefValue = objectButton>
class CObjectType : public CSimpleType<EObjectType, eDefValue>
@ -4757,10 +4757,10 @@ namespace SimpleTypes
virtual EDropStyle FromString(std::wstring &sValue)
{
if ( L"combo" == sValue ) this->m_eValue = valCombo;
if ( L"combo" == sValue ) this->m_eValue = valCombo;
else if ( L"comboedit" == sValue ) this->m_eValue = valComboedit;
else if ( L"simple" == sValue ) this->m_eValue = valSimple;
else this->m_eValue = eDefValue;
else this->m_eValue = eDefValue;
return this->m_eValue;
}

File diff suppressed because it is too large Load Diff

View File

@ -371,6 +371,8 @@ namespace OOX
m_oDataConsolidate = oReader;
else if (_T("sortState") == sName)
m_oSortState = oReader;
else if (_T("cellWatches") == sName)
m_oCellWatches = oReader;
else if (L"DataValidation" == sName)
{
if (false == m_oDataValidations.IsInit())
@ -781,6 +783,8 @@ namespace OOX
m_oRowBreaks->toXML(writer);
if(m_oColBreaks.IsInit())
m_oColBreaks->toXML(writer);
if (m_oCellWatches.IsInit())
m_oCellWatches->toXML(writer);
if(m_oDrawing.IsInit())
m_oDrawing->toXML(writer);
if(m_oLegacyDrawing.IsInit())
@ -814,7 +818,7 @@ namespace OOX
toXMLEnd(sXml);
//NSFile::CFileBinary::SaveToFile(oPath.GetPath(), sXml.GetData());
//for memory optimization fro large files
//for memory optimization for large files
wchar_t* pXmlData = sXml.GetBuffer();
LONG lwcharLen = (LONG)sXml.GetCurSize();

View File

@ -59,7 +59,6 @@ namespace OOX
class CThreadedComments;
class CPersonList;
//необработанные child:
//<cellWatches>
//<customProperties>
//<extLst>
//<phoneticPr>
@ -162,6 +161,7 @@ namespace OOX
nullable<OOX::Spreadsheet::CDataConsolidate> m_oDataConsolidate;
nullable<OOX::Spreadsheet::CSortState> m_oSortState;
nullable<OOX::Spreadsheet::CProtectedRanges> m_oProtectedRanges;
nullable<OOX::Spreadsheet::CCellWatches> m_oCellWatches;
nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;

View File

@ -258,6 +258,114 @@ namespace OOX
return et_x_ProtectedRanges;
}
};
class CCellWatch : public WritingElement
{
public:
WritingElement_AdditionConstructors(CCellWatch)
WritingElement_XlsbConstructors(CCellWatch)
CCellWatch()
{
}
virtual ~CCellWatch()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<cellWatch");
WritingStringNullableAttrString(L"r", m_oR, m_oR.get());
writer.WriteString(L"/>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes(oReader);
if (oReader.IsEmptyNode())
return;
}
void fromBin(XLS::BaseObjectPtr& obj)
{
ReadAttributes(obj);
}
virtual EElementType getType() const
{
return et_x_CellWatch;
}
void ReadAttributes(XLS::BaseObjectPtr& obj)
{
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start(oReader)
WritingElement_ReadAttributes_Read_if(oReader, (L"r"), m_oR)
WritingElement_ReadAttributes_End(oReader)
}
nullable_string m_oR;
};
class CCellWatches : public WritingElementWithChilds<CCellWatch>
{
public:
WritingElement_AdditionConstructors(CCellWatches)
WritingElement_XlsbVectorConstructors(CCellWatches)
CCellWatches()
{
}
virtual ~CCellWatches()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return (L"");
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
if (m_arrItems.empty()) return;
writer.WriteString((L"<cellWatches>"));
for (size_t i = 0; i < m_arrItems.size(); ++i)
{
if (m_arrItems[i])
{
m_arrItems[i]->toXML(writer);
}
}
writer.WriteString((L"</cellWatches>"));
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
if (oReader.IsEmptyNode())
return;
int nCurDepth = oReader.GetDepth();
while (oReader.ReadNextSiblingNode(nCurDepth))
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if (L"cellWatch" == sName)
m_arrItems.push_back(new CCellWatch(oReader));
}
}
void fromBin(std::vector<XLS::BaseObjectPtr>& obj)
{
}
virtual EElementType getType() const
{
return et_x_CellWatches;
}
};
class CPageMargins : public WritingElement
{
public:

View File

@ -97,7 +97,7 @@ JSSmart<CJSValue> CBuilderEmbed::builder_OpenTmpFile(JSSmart<CJSValue> path, JSS
p->m_internal->m_pBuilder = m_pBuilder;
p->m_internal->OpenFile(sPath, sParams);
CJSValueJSC* pRet = new CJSValueJSC();
pRet->context = _getCurrentContext();
pRet->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
pRet->value = [JSValue valueWithObject:(id)p inContext:pRet->context];
return pRet;
}

View File

@ -44,7 +44,7 @@
JSSmart<CJSValue> CPointerEmbedObject::createObject()
{
CJSValueJSC* pRet = new CJSValueJSC();
pRet->context = _getCurrentContext();
pRet->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
pRet->value = [JSValue valueWithObject:(id)[[CJSCPointer alloc] initWithPointer:this] inContext:pRet->context];
return pRet;
}

View File

@ -244,7 +244,8 @@ namespace NSJSBase
CJSLocalScope* CreateLocalScope();
JSSmart<CJSValue> runScript(const std::string& script, JSSmart<CJSTryCatch> exception = NULL, const std::wstring& scriptPath = std::wstring(L""));
CJSValue* JSON_Parse(const char* json_content);
CJSValue* JSON_Parse(const char* json_content);
void MoveToThread();
public:
static CJSValue* createUndefined();

View File

@ -9,6 +9,8 @@
#include <JavaScriptCore/JSValueRef.h>
#import "../../../../DesktopEditor/common/Mac/NSString+StringUtils.h"
#include <vector>
#include "../../../../DesktopEditor/graphics/BaseThread.h"
@protocol JSEmbedObjectProtocol
- (void*) getNative;
@ -20,9 +22,12 @@ namespace NSJSBase
{
public:
JSContext* context;
std::vector<ASC_THREAD_ID> m_arThreads;
static bool g_oldVersion;
static JSContext* g_lockedContext;
// считаем, что vector будет небольшим, поэтому он будет быстрее, чем map
static std::vector<std::pair<ASC_THREAD_ID, JSContext*>> g_contexts;
public:
CJSContextPrivate()
@ -33,14 +38,55 @@ namespace NSJSBase
{
context = nil;
}
};
}
static JSContext* _getCurrentContext()
{
if (nil != NSJSBase::CJSContextPrivate::g_lockedContext)
return NSJSBase::CJSContextPrivate::g_lockedContext;
return [JSContext currentContext];
static JSContext* GetCurrentContext()
{
ASC_THREAD_ID nCurrentThread = NSThreads::GetCurrentThreadId();
for (std::vector<std::pair<ASC_THREAD_ID, JSContext*>>::const_iterator i = g_contexts.begin(); i != g_contexts.end(); i++)
{
if (i->first == nCurrentThread)
{
return i->second;
}
}
return [JSContext currentContext];
}
private:
static bool RegisterContext(JSContext* ctx)
{
ASC_THREAD_ID nCurrentThread = NSThreads::GetCurrentThreadId();
for (std::vector<std::pair<ASC_THREAD_ID, JSContext*>>::const_iterator i = g_contexts.begin(); i != g_contexts.end(); i++)
{
if (i->first == nCurrentThread)
{
return false;
}
}
g_contexts.push_back(std::pair<ASC_THREAD_ID, JSContext*>(nCurrentThread, ctx));
return true;
}
static void UnregisterContextForId(ASC_THREAD_ID nCurrentThread)
{
for (std::vector<std::pair<ASC_THREAD_ID, JSContext*>>::const_iterator i = g_contexts.begin(); i != g_contexts.end(); i++)
{
if (i->first == nCurrentThread)
{
g_contexts.erase(i);
return;
}
}
}
static void UnregisterContext()
{
UnregisterContextForId(NSThreads::GetCurrentThreadId());
}
friend class CJSContext;
};
}
namespace NSJSBase
@ -60,13 +106,13 @@ namespace NSJSBase
CJSValueJSCTemplate(JSValue* _value)
{
value = _value;
context = _getCurrentContext();
context = NSJSBase::CJSContextPrivate::GetCurrentContext();
if (context == nil) {
context = _value.context;
}
}
public:
virtual ~CJSValueJSCTemplate()
@ -305,7 +351,7 @@ namespace NSJSBase
kJSTypedArrayTypeUint8Array,
(void*)data, (size_t)count,
isExternalize ? data_no_destroy_memory : data_destroy_memory,
nullptr, nullptr);
nullptr, nullptr);
if (object)
{
value = [JSValue valueWithJSValueRef:object inContext:context];
@ -332,8 +378,8 @@ namespace NSJSBase
{
NSJSBase::NSAllocator::Free((unsigned char*)bytes, 0);
}
static void data_no_destroy_memory(void* bytes, void* deallocatorContext)
{
static void data_no_destroy_memory(void* bytes, void* deallocatorContext)
{
}
virtual int getCount()
@ -353,13 +399,13 @@ namespace NSJSBase
virtual CJSDataBuffer getData()
{
CJSDataBuffer buffer;
CJSDataBuffer buffer;
if (!CJSContextPrivate::g_oldVersion)
{
JSObjectRef obj = JSValueToObject(context.JSGlobalContextRef, value.JSValueRef, NULL);
buffer.IsExternalize = false;
buffer.Data = (BYTE*)JSObjectGetTypedArrayBytesPtr(context.JSGlobalContextRef, obj, NULL);
buffer.Len = (size_t)JSObjectGetTypedArrayByteLength(context.JSGlobalContextRef, obj, NULL);
buffer.IsExternalize = false;
buffer.Data = (BYTE*)JSObjectGetTypedArrayBytesPtr(context.JSGlobalContextRef, obj, NULL);
buffer.Len = (size_t)JSObjectGetTypedArrayByteLength(context.JSGlobalContextRef, obj, NULL);
return buffer;
}
@ -402,7 +448,7 @@ namespace NSJSBase
value = nil;
context = nil;
}
virtual CJSValue* Call(CJSValue* recv, int argc, JSSmart<CJSValue> argv[])
{
NSMutableArray* arr = [[NSMutableArray alloc] init];

View File

@ -3,7 +3,8 @@
using namespace NSJSBase;
JSContext* NSJSBase::CJSContextPrivate::g_lockedContext = nil;
std::vector<std::pair<ASC_THREAD_ID, JSContext*>> NSJSBase::CJSContextPrivate::g_contexts;
bool NSJSBase::CJSContextPrivate::g_oldVersion = false;
template<typename T>
@ -117,6 +118,7 @@ namespace NSJSBase
void CJSContext::Initialize()
{
m_internal->context = [[JSContext alloc] init];
CJSContextPrivate::RegisterContext(m_internal->context);
#ifndef _IOS
if (@available(macOS 10.12, *))
@ -133,8 +135,12 @@ namespace NSJSBase
void CJSContext::Dispose()
{
m_internal->context = nil;
m_internal->g_lockedContext = nil;
NSJSBase::CJSContextPrivate::g_lockedContext = nil;
CJSContextPrivate::UnregisterContext();
for (std::vector<ASC_THREAD_ID>::const_iterator i = m_internal->m_arThreads.begin(); i != m_internal->m_arThreads.end(); i++)
{
CJSContextPrivate::UnregisterContextForId(*i);
}
}
void CJSContext::CreateContext()
@ -163,17 +169,16 @@ namespace NSJSBase
NSLog(@"%@", value);
}];
#endif
m_internal->g_lockedContext = m_internal->context;
return new CJSIsolateScope();
}
CJSContextScope* CJSContext::CreateContextScope()
{
CJSContextScope* pScope = new CJSContextScope();
JSValue* global_js = [m_internal->context globalObject];
JSValue* global_js = [m_internal->context globalObject];
[global_js setValue:global_js forProperty:[[NSString alloc] initWithUTF8String:"window"]];
return pScope;
return pScope;
}
CJSLocalScope* CJSContext::CreateLocalScope()
@ -184,7 +189,7 @@ namespace NSJSBase
CJSValue* CJSContext::createUndefined()
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->doUndefined();
return _value;
}
@ -192,7 +197,7 @@ namespace NSJSBase
CJSValue* CJSContext::createNull()
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->doNull();
return _value;
}
@ -200,7 +205,7 @@ namespace NSJSBase
CJSValue* CJSContext::createBool(const bool& value)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [JSValue valueWithBool:(value ? YES : NO) inContext:_value->context];
return _value;
}
@ -208,7 +213,7 @@ namespace NSJSBase
CJSValue* CJSContext::createInt(const int& value)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [JSValue valueWithInt32:((int32_t) value) inContext:_value->context];
return _value;
}
@ -216,7 +221,7 @@ namespace NSJSBase
CJSValue* CJSContext::createUInt(const unsigned int& value)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [JSValue valueWithUInt32:((uint32_t) value) inContext:_value->context];
return _value;
}
@ -224,7 +229,7 @@ namespace NSJSBase
CJSValue* CJSContext::createDouble(const double& value)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [JSValue valueWithDouble:value inContext:_value->context];
return _value;
}
@ -232,7 +237,7 @@ namespace NSJSBase
CJSValue* CJSContext::createString(const char* value, const int& len)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [NSString stringWithUtf8Buffer:value length:(size_t)((len == -1) ? strlen(value) : len)];
return _value;
}
@ -240,7 +245,7 @@ namespace NSJSBase
CJSValue* CJSContext::createString(const std::string& value)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [NSString stringWithAString:value];
return _value;
}
@ -248,7 +253,7 @@ namespace NSJSBase
CJSValue* CJSContext::createString(const std::wstring& value)
{
CJSValueJSC* _value = new CJSValueJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [NSString stringWithWString:value];
return _value;
}
@ -256,7 +261,7 @@ namespace NSJSBase
CJSObject* CJSContext::createObject()
{
CJSObjectJSC* _value = new CJSObjectJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [JSValue valueWithNewObjectInContext:_value->context];
return _value;
}
@ -264,14 +269,14 @@ namespace NSJSBase
CJSArray* CJSContext::createArray(const int& count)
{
CJSArrayJSC* _value = new CJSArrayJSC();
_value->context = _getCurrentContext();
_value->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
_value->value = [JSValue valueWithNewArrayInContext:_value->context];
return _value;
}
CJSTypedArray* CJSContext::createUint8Array(BYTE* data, int count, const bool& isExternalize)
{
JSContext* _current = _getCurrentContext();
JSContext* _current = NSJSBase::CJSContextPrivate::GetCurrentContext();
CJSTypedArrayJSC* _value = new CJSTypedArrayJSC(_current, data, count, isExternalize);
return _value;
}
@ -283,20 +288,20 @@ namespace NSJSBase
_value->context = m_internal->context;
return _value;
}
unsigned char* NSAllocator::Alloc(const size_t& size)
{
return (unsigned char*)malloc(size);
}
unsigned char* NSAllocator::Alloc(const size_t& size)
{
return (unsigned char*)malloc(size);
}
void NSAllocator::Free(unsigned char* data, const size_t& size)
{
free(data);
}
{
free(data);
}
CJSContext* CJSContext::GetCurrent()
{
CJSContext* ret = new CJSContext();
ret->m_internal->context = _getCurrentContext();
ret->m_internal->context = NSJSBase::CJSContextPrivate::GetCurrentContext();
return ret;
}
@ -325,6 +330,14 @@ namespace NSJSBase
_value->context = m_internal->context;
return _value;
}
void CJSContext::MoveToThread()
{
if (CJSContextPrivate::RegisterContext(m_internal->context))
{
m_internal->m_arThreads.push_back(NSThreads::GetCurrentThreadId());
}
}
}
namespace NSJSBase
@ -334,7 +347,7 @@ namespace NSJSBase
JSValue* exc = [context exception];
if (exc == nil || [exc isNull] || [exc isUndefined])
return false;
NSString* pExсeption = [[context exception] toString];
std::cerr << [pExсeption stdstring] << std::endl;
NSLog(@"%@", pExсeption);

View File

@ -350,6 +350,11 @@ namespace NSJSBase
return _value;
}
void CJSContext::MoveToThread()
{
// none
}
void CJSContext::ExternalInitialize()
{
CV8Worker::SetUseExetralInitialize();

View File

@ -110,6 +110,4 @@ include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
ADD_DEPENDENCY(kernel, graphics, UnicodeConverter)
SOURCES += ../../../../fontengine/ApplicationFontsWorker.cpp
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX

View File

@ -119,7 +119,7 @@ namespace NSUnicodeConverter
{ 50, 12000, "UTF-32LE", "Unicode (UTF-32)" },
{ 51, 12001, "UTF-32BE", "Unicode (UTF-32 Big Endian)" },
{ 52, 950, "EUC-JP", "Japanese (EUC-JP)" }
{ 52, 20932, "EUC-JP", "Japanese (EUC-JP)" }
};
@ -163,7 +163,7 @@ namespace NSUnicodeConverter
m[1255] = "windows-1255";
m[932] = "Shift_JIS";
m[950] = "EUC-JP";
m[950] = "Big5"; //CN
m[949] = "KS_C_5601-1987";
m[51949] = "EUC-KR";
@ -199,6 +199,7 @@ namespace NSUnicodeConverter
m[12001] = "UTF-32BE";
m[10000] = "macintosh";
m[20932] = "EUC-JP";
return m;
}
static const std::map<int, std::string> mapEncodingsICU = create_mapEncodingsICU();

View File

@ -321,7 +321,7 @@ namespace NExtractTools
{
_UINT32 nRes = S_OK;
std::wstring sToDir = NSDirectory::GetFolderPath(sTo);
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX))
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX) && !sDocxFile.empty())
{
CopyOOXOrigin(sToDir, sFrom, L"origin.docx", sDocxFile);
}
@ -794,7 +794,7 @@ namespace NExtractTools
{
_UINT32 nRes = S_OK;
std::wstring sToDir = NSDirectory::GetFolderPath(sTo);
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX))
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX) && !sXlsxFile.empty())
{
CopyOOXOrigin(sToDir, sXlsxDir, L"origin.xlsx", sXlsxFile);
}
@ -1255,7 +1255,7 @@ namespace NExtractTools
{
_UINT32 nRes = 0;
std::wstring sToDir = NSDirectory::GetFolderPath(sTo);
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX))
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX) && !sPptxFile.empty())
{
CopyOOXOrigin(sToDir, sFrom, L"origin.pptx", sPptxFile);
}
@ -2878,12 +2878,45 @@ namespace NExtractTools
nRes = processEncryptionError(nRes, sFrom, params);
if (SUCCEEDED_X2T(nRes))
{
//???? todooo - xlsx, pptx
BinDocxRW::CDocxSerializer m_oCDocxSerializer;
COfficeFileFormatChecker OfficeFileFormatChecker;
m_oCDocxSerializer.setFontDir(params.getFontPath());
nRes = m_oCDocxSerializer.saveToFile(sTo, sTempUnpackedOox, params.getXmlOptions(), sTemp) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
if (OfficeFileFormatChecker.isOOXFormatFile(sTempUnpackedOox, true))
{
switch (OfficeFileFormatChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF:
{
return docx_dir2doct_bin(sTempUnpackedOox, sTo, sTemp, params, L"");
}break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLTM:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSB:
{
const std::wstring & sXmlOptions = params.getXmlOptions();
return xlsx_dir2xlst_bin(sTempUnpackedOox, sTo, params, false, L"");
}break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_POTM:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPSM:
{
return pptx_dir2pptt_bin(sTempUnpackedOox, sTo, sTemp, params, L"");
}break;
default:
{
nRes = AVS_FILEUTILS_ERROR_CONVERT;
}break;
}
}
}
}
else
@ -3828,15 +3861,54 @@ namespace NExtractTools
}
else if (bIsNeedDoct)
{
std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
NSDirectory::CreateDirectory(sDoctDir);
std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = docx_dir2doct_bin(sFromWithChanges, sTFile, sTemp, params, sDocxFile);
if(SUCCEEDED_X2T(nRes))
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX))
{
nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bPaid, params);
std::wstring sToRender = sDocxFile;
if (sToRender.empty())
{
sToRender = sTemp + FILE_SEPARATOR_STR + _T("toRender.docx");
nRes = dir2zip(sFromWithChanges, sToRender);
}
NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::DOCT;
if(AVS_OFFICESTUDIO_FILE_DOCUMENT_EPUB == nFormatTo)
{
nRes = doct_bin2epub(eFromType, sToRender, sTo, sTemp, sThemeDir, params);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_FB2 == nFormatTo)
{
nRes = doct_bin2fb(eFromType, sToRender, sTo, sTemp, sThemeDir, params);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML == nFormatTo)
{
nRes = doct_bin2html(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else if(AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER == nFormatTo)
{
nRes = doct_bin2html_zip(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
nRes = doct_bin2pdf(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else if(0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo))
{
nRes = doct_bin2image(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS;
}
else
{
std::wstring sDoctDir = sTemp + FILE_SEPARATOR_STR + _T("doct_unpacked");
NSDirectory::CreateDirectory(sDoctDir);
std::wstring sTFile = sDoctDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = docx_dir2doct_bin(sFromWithChanges, sTFile, sTemp, params, sDocxFile);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromDoctBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bPaid, params);
}
}
}
else
@ -4073,16 +4145,40 @@ namespace NExtractTools
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo ||
AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
{
std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
NSDirectory::CreateDirectory(sXlstDir);
std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
nRes = xlsx_dir2xlst_bin(sFrom, sTFile, params, false, sXlsxFile);
else
nRes = xlsx_dir2xlst_bin(sFrom, sTFile, params, true, sXlsxFile);
if(SUCCEEDED_X2T(nRes))
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX) &&
((0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo)) || AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo))
{
nRes = fromXlstBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bPaid, params);
std::wstring sToRender = sXlsxFile;
if (sToRender.empty())
{
sToRender = sTemp + FILE_SEPARATOR_STR + _T("toRender.xlsx");
nRes = dir2zip(sFrom, sToRender);
}
NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::XLST;
if(AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
nRes = doct_bin2pdf(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else if(0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo))
{
nRes = doct_bin2image(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS;
}
else
{
std::wstring sXlstDir = sTemp + FILE_SEPARATOR_STR + _T("xlst_unpacked");
NSDirectory::CreateDirectory(sXlstDir);
std::wstring sTFile = sXlstDir + FILE_SEPARATOR_STR + _T("Editor.bin");
if(AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV == nFormatTo)
nRes = xlsx_dir2xlst_bin(sFrom, sTFile, params, false, sXlsxFile);
else
nRes = xlsx_dir2xlst_bin(sFrom, sTFile, params, true, sXlsxFile);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromXlstBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bPaid, params);
}
}
}
else
@ -4392,14 +4488,37 @@ namespace NExtractTools
else if ( (0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo)) ||
AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
std::wstring sPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked");
NSDirectory::CreateDirectory(sPpttDir);
std::wstring sTFile = sPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = pptx_dir2pptt_bin(sFrom, sTFile, sTemp, params, sPptxFile);
if(SUCCEEDED_X2T(nRes))
if (params.needConvertToOrigin(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX))
{
nRes = fromPpttBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bPaid, params);
std::wstring sToRender = sPptxFile;
if (sToRender.empty())
{
sToRender = sTemp + FILE_SEPARATOR_STR + _T("toRender.pptx");
nRes = dir2zip(sFrom, sToRender);
}
NSDoctRenderer::DoctRendererFormat::FormatFile eFromType = NSDoctRenderer::DoctRendererFormat::FormatFile::PPTT;
if (AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF == nFormatTo)
{
nRes = doct_bin2pdf(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else if(0 != (AVS_OFFICESTUDIO_FILE_IMAGE & nFormatTo))
{
nRes = doct_bin2image(eFromType, sToRender, sTo, sTemp, bPaid, sThemeDir, params);
}
else
nRes = AVS_FILEUTILS_ERROR_CONVERT_PARAMS;
}
else
{
std::wstring sPpttDir = sTemp + FILE_SEPARATOR_STR + _T("pptt_unpacked");
NSDirectory::CreateDirectory(sPpttDir);
std::wstring sTFile = sPpttDir + FILE_SEPARATOR_STR + _T("Editor.bin");
nRes = pptx_dir2pptt_bin(sFrom, sTFile, sTemp, params, sPptxFile);
if(SUCCEEDED_X2T(nRes))
{
nRes = fromPpttBin(sTFile, sTo, nFormatTo, sTemp, sThemeDir, bPaid, params);
}
}
}
else

View File

@ -264,7 +264,11 @@ namespace BinXlsxRW
Comma = 12,
Semicolon = 13,
Consecutive = 14,
TextFields = 15
TextFields = 15,
CodePage = 16,
TextField = 17,
TextFieldType = 18,
TextFieldPosition = 19
};}
namespace c_oSerOlapPrTypes{enum c_oSerOlapPrTypes
{
@ -325,7 +329,8 @@ namespace BinXlsxRW
TextPr = 23,
WebPr = 24,
RangePr = 25,
IdExt = 26
IdExt = 26,
UId = 27
};}
namespace c_oSerWorkbookVbaProjectTypes{enum c_oSerWorkbookVbaProjectTypes
{
@ -411,7 +416,10 @@ namespace BinXlsxRW
NamedSheetView = 40,
Protection = 41,
ProtectedRanges = 42,
ProtectedRange = 43
ProtectedRange = 43,
CellWatches = 44,
CellWatch = 45,
CellWatchR = 46
};}
namespace c_oSerWorksheetProtection {enum c_oSerWorksheetPropTypes
{

View File

@ -43,8 +43,6 @@
#include "../../ASCOfficePPTXFile/PPTXFormat/Core.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/Logic/HeadingVariant.h"
#include "../../ASCOfficeXlsFile2/source/VbaFormat/VbaReader.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/XlsxFlat.h"
@ -2115,16 +2113,6 @@ void BinaryWorkbookTableWriter::WriteWorkbook(OOX::Spreadsheet::CWorkbook& workb
m_pXlsx->m_pVbaProject->toPPTY(&m_oBcw.m_oStream);
m_oBcw.m_oStream.EndRecord();
CVbaReader vbaReader(m_pXlsx->m_pVbaProject->filename().GetPath(), L"");
std::wstring sXml = vbaReader.convert();
if (false == sXml.empty())
{
m_oBcw.m_oStream.StartRecord(1);
m_oBcw.m_oStream.WriteStringW(sXml);
m_oBcw.m_oStream.EndRecord();
}
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//Write JsaProject
@ -2159,7 +2147,6 @@ void BinaryWorkbookTableWriter::WriteWorkbook(OOX::Spreadsheet::CWorkbook& workb
WriteConnections(pConnectionFile->m_oConnections.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (workbook.m_oAppName.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::AppName);
@ -2247,12 +2234,39 @@ void BinaryWorkbookTableWriter::WriteWorkbookPr(const OOX::Spreadsheet::CWorkboo
m_oBcw.m_oStream.WriteBOOL(workbookPr.m_oShowPivotChartFilter->ToBool());
}
}
void BinaryWorkbookTableWriter::WriteConnectionTextFields(const OOX::Spreadsheet::CTextFields& textFields)
{
for (size_t i = 0; i < textFields.m_arrItems.size(); ++i)
{
OOX::Spreadsheet::CTextField* pTextField = static_cast<OOX::Spreadsheet::CTextField*>(textFields.m_arrItems[i]);
int nCurPos = m_oBcw.WriteItemStart(c_oSerTextPrTypes::TextField);
WriteConnectionTextField(*pTextField);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void BinaryWorkbookTableWriter::WriteConnectionTextField(const OOX::Spreadsheet::CTextField& textField)
{
int nCurPos;
if (textField.m_oType.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerTextPrTypes::TextFieldType);
m_oBcw.m_oStream.WriteLONG(textField.m_oType->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (textField.m_oPosition.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerTextPrTypes::TextFieldPosition);
m_oBcw.m_oStream.WriteLONG(*textField.m_oPosition);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void BinaryWorkbookTableWriter::WriteBookViews(const OOX::Spreadsheet::CBookViews& bookViews)
{
int nCurPos;
if(bookViews.m_arrItems.size() > 0)
if (false == bookViews.m_arrItems.empty())
{
//WorkbookView
OOX::Spreadsheet::CWorkbookView* pWorkbookView = static_cast<OOX::Spreadsheet::CWorkbookView*>(bookViews.m_arrItems[0]);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorkbookTypes::WorkbookView);
WriteWorkbookView(*pWorkbookView);
@ -2392,6 +2406,11 @@ void BinaryWorkbookTableWriter::WriteConnection(const OOX::Spreadsheet::CConnect
m_oBcw.m_oStream.WriteULONG(connection.m_oId->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (connection.m_oUId.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerConnectionsTypes::UId);
m_oBcw.m_oStream.WriteStringW(*connection.m_oUId);
}
if(connection.m_oCredentials.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerConnectionsTypes::Credentials);
@ -2704,7 +2723,18 @@ void BinaryWorkbookTableWriter::WriteConnectionTextPr(const OOX::Spreadsheet::CT
m_oBcw.m_oStream.WriteBYTE(*textPr.m_oConsecutive ? 1 : 0);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
//m_oTextFields;
if (textPr.m_oCodePage.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerTextPrTypes::CodePage);
m_oBcw.m_oStream.WriteLONG(*textPr.m_oCodePage);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (textPr.m_oTextFields.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerTextPrTypes::TextFields);
WriteConnectionTextFields(textPr.m_oTextFields.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void BinaryWorkbookTableWriter::WriteConnectionRangePr(const OOX::Spreadsheet::CRangePr& rangePr)
{
@ -3482,6 +3512,12 @@ void BinaryWorksheetTableWriter::WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet
WritemRowColBreaks(oWorksheet.m_oColBreaks.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oWorksheet.m_oCellWatches.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::CellWatches);
WriteCellWatches(oWorksheet.m_oCellWatches.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if (oWorksheet.m_oPicture.IsInit() && oWorksheet.m_oPicture->m_oId.IsInit())
{
smart_ptr<OOX::File> pFile = oWorksheet.Find(oWorksheet.m_oPicture->m_oId->GetValue());
@ -3555,12 +3591,29 @@ void BinaryWorksheetTableWriter::WriteWorksheetProp(OOX::Spreadsheet::CSheet& oS
m_oBcw.m_oStream.WriteBYTE(oSheet.m_oState->GetValue());
}
}
void BinaryWorksheetTableWriter::WriteCellWatches(const OOX::Spreadsheet::CCellWatches& cellWatches)
{
for (size_t nIndex = 0, nLength = cellWatches.m_arrItems.size(); nIndex < nLength; ++nIndex)
{
int nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::CellWatch);
WriteCellWatch(*cellWatches.m_arrItems[nIndex]);
m_oBcw.WriteItemEnd(nCurPos);
}
}
void BinaryWorksheetTableWriter::WriteCellWatch(const OOX::Spreadsheet::CCellWatch& cellWatch)
{
if (cellWatch.m_oR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWorksheetsTypes::CellWatchR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
m_oBcw.m_oStream.WriteStringW(*cellWatch.m_oR);
}
}
void BinaryWorksheetTableWriter::WriteProtectedRanges(const OOX::Spreadsheet::CProtectedRanges& protectedRanges)
{
int nCurPos = 0;
for (size_t nIndex = 0, nLength = protectedRanges.m_arrItems.size(); nIndex < nLength; ++nIndex)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::ProtectedRange);
int nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::ProtectedRange);
WriteProtectedRange(*protectedRanges.m_arrItems[nIndex]);
m_oBcw.WriteItemEnd(nCurPos);
}

View File

@ -170,6 +170,8 @@ namespace BinXlsxRW
void WriteConnectionDbPr(const OOX::Spreadsheet::CDbPr& dbPr);
void WriteConnectionOlapPr(const OOX::Spreadsheet::COlapPr& olapPr);
void WriteConnectionTextPr(const OOX::Spreadsheet::CTextPr& textPr);
void WriteConnectionTextFields(const OOX::Spreadsheet::CTextFields& textFields);
void WriteConnectionTextField(const OOX::Spreadsheet::CTextField& textField);
void WriteConnectionWebPr(const OOX::Spreadsheet::CWebPr& webPr);
void WriteConnectionRangePr(const OOX::Spreadsheet::CRangePr& rangePr);
void WriteExternalReferences(const OOX::Spreadsheet::CExternalReferences& externalReferences, OOX::Spreadsheet::CWorkbook& workbook);
@ -217,6 +219,8 @@ namespace BinXlsxRW
void WriteWorksheet(OOX::Spreadsheet::CSheet* pSheet, OOX::Spreadsheet::CWorksheet& oWorksheet);
void WriteCellWatches(const OOX::Spreadsheet::CCellWatches& cellWatches);
void WriteCellWatch(const OOX::Spreadsheet::CCellWatch& cellWatch);
void WriteWorksheetProp(OOX::Spreadsheet::CSheet& oSheet);
void WriteProtection(const OOX::Spreadsheet::CSheetProtection& protection);
void WriteProtectedRanges(const OOX::Spreadsheet::CProtectedRanges& protectedRanges);

View File

@ -2114,6 +2114,10 @@ int BinaryWorkbookTableReader::ReadWorkbookTableContent(BYTE type, long length,
READ1_DEF(length, res, this->ReadPivotCaches, poResult);
m_oWorkbook.m_oPivotCachesXml->append(L"</pivotCaches>");
}
else if (c_oSerWorkbookTypes::AppName == type)
{
m_oWorkbook.m_oAppName = m_oBufferedStream.GetString4(length);
}
else if (c_oSerWorkbookTypes::OleSize == type)
{
m_oWorkbook.m_oOleSize = m_oBufferedStream.GetString4(length);
@ -2244,6 +2248,10 @@ int BinaryWorkbookTableReader::ReadConnection(BYTE type, long length, void* poRe
pConnection->m_oId.Init();
pConnection->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if (c_oSerConnectionsTypes::UId == type)
{
pConnection->m_oUId = m_oBufferedStream.GetString4(length);
}
else if(c_oSerConnectionsTypes::Credentials == type)
{
pConnection->m_oCredentials.Init();
@ -2452,6 +2460,10 @@ int BinaryWorkbookTableReader::ReadConnectionTextPr(BYTE type, long length, void
{
pTextPr->m_oFirstRow = m_oBufferedStream.GetLong();
}
else if (c_oSerTextPrTypes::CodePage == type)
{
pTextPr->m_oCodePage = m_oBufferedStream.GetLong();
}
else if(c_oSerTextPrTypes::Qualifier == type)
{
pTextPr->m_oQualifier.Init();
@ -2490,6 +2502,45 @@ int BinaryWorkbookTableReader::ReadConnectionTextPr(BYTE type, long length, void
{
pTextPr->m_oConsecutive = m_oBufferedStream.GetBool();
}
else if (c_oSerTextPrTypes::TextFields == type)
{
pTextPr->m_oTextFields.Init();
READ1_DEF(length, res, this->ReadConnectionTextFields, pTextPr->m_oTextFields.GetPointer());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int BinaryWorkbookTableReader::ReadConnectionTextFields(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CTextFields* pTextFields = static_cast<OOX::Spreadsheet::CTextFields*>(poResult);
int res = c_oSerConstants::ReadOk;
if (c_oSerTextPrTypes::TextField == type)
{
pTextFields->m_arrItems.push_back(new OOX::Spreadsheet::CTextField());
READ1_DEF(length, res, this->ReadConnectionTextField, pTextFields->m_arrItems.back());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int BinaryWorkbookTableReader::ReadConnectionTextField(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CTextField* pTextField = static_cast<OOX::Spreadsheet::CTextField*>(poResult);
int res = c_oSerConstants::ReadOk;
if (c_oSerTextPrTypes::TextFieldType == type)
{
pTextField->m_oType.Init();
pTextField->m_oType->SetValue((SimpleTypes::Spreadsheet::EExternalConnectionType)m_oBufferedStream.GetLong());
}
else if (c_oSerTextPrTypes::TextFieldPosition == type)
{
pTextField->m_oPosition = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3904,6 +3955,12 @@ int BinaryWorksheetsTableReader::ReadWorksheet(boost::unordered_map<BYTE, std::v
READ1_DEF(length, res, this->ReadRowColBreaks, &oColBreaks);
oColBreaks.toXML2(oStreamWriter, L"colBreaks");
SEEK_TO_POS_END2();
//-------------------------------------------------------------------------------------------------------------
SEEK_TO_POS_START(c_oSerWorksheetsTypes::CellWatches);
OOX::Spreadsheet::CCellWatches oCellWatches;
READ1_DEF(length, res, this->ReadCellWatches, &oCellWatches);
oCellWatches.toXML(oStreamWriter);
SEEK_TO_POS_END2();
//-------------------------------------------------------------------------------------------------------------
//important before Drawings
SEEK_TO_POS_START(c_oSerWorksheetsTypes::Comments);
@ -5010,6 +5067,31 @@ int BinaryWorksheetsTableReader::ReadHeaderFooter(BYTE type, long length, void*
res = c_oSerConstants::ReadUnknown;
return res;
}
int BinaryWorksheetsTableReader::ReadCellWatches(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Spreadsheet::CCellWatches* pCellWatches = static_cast<OOX::Spreadsheet::CCellWatches*>(poResult);
if (c_oSerWorksheetsTypes::CellWatch == type)
{
pCellWatches->m_arrItems.push_back(new OOX::Spreadsheet::CCellWatch());
READ2_DEF_SPREADSHEET(length, res, this->ReadCellWatch, pCellWatches->m_arrItems.back());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int BinaryWorksheetsTableReader::ReadCellWatch(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Spreadsheet::CCellWatch* pCellWatch = static_cast<OOX::Spreadsheet::CCellWatch*>(poResult);
if (c_oSerWorksheetsTypes::CellWatchR == type)
{
pCellWatch->m_oR = m_oBufferedStream.GetString4(length);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int BinaryWorksheetsTableReader::ReadRowColBreaks(BYTE type, long length, void* poResult)
{
OOX::Spreadsheet::CRowColBreaks* pRowColBreaks = static_cast<OOX::Spreadsheet::CRowColBreaks*>(poResult);

View File

@ -235,6 +235,8 @@ namespace BinXlsxRW
int ReadConnectionTextPr(BYTE type, long length, void* poResult);
int ReadConnectionWebPr(BYTE type, long length, void* poResult);
int ReadConnectionRangePr(BYTE type, long length, void* poResult);
int ReadConnectionTextFields(BYTE type, long length, void* poResult);
int ReadConnectionTextField(BYTE type, long length, void* poResult);
int ReadSlicerCaches(BYTE type, long length, void* poResult);
};
class BinaryCommentReader : public Binary_CommonReader
@ -314,6 +316,8 @@ namespace BinXlsxRW
int ReadProtection(BYTE type, long length, void* poResult);
int ReadRowColBreaks(BYTE type, long length, void* poResult);
int ReadBreak(BYTE type, long length, void* poResult);
int ReadCellWatches(BYTE type, long length, void* poResult);
int ReadCellWatch(BYTE type, long length, void* poResult);
int ReadPrintOptions(BYTE type, long length, void* poResult);
int ReadHyperlinks(BYTE type, long length, void* poResult);
int ReadHyperlink(BYTE type, long length, void* poResult);