Commit 9dd115ec authored by Alexey Golubev's avatar Alexey Golubev

v5.0.1

parents 34083d99 244d549c
......@@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
base_font_size_(12), fonts_container_(fonts)
base_font_size_(12), fonts_container_(fonts), is_need_e_(false)
{
graphRPR_ = graphic;
......
......@@ -106,6 +106,8 @@ namespace oox {
std::wstring nsRPr_;
bool graphRPR_;
bool is_need_e_;
private:
std::wstringstream math_stream_;
std::wstringstream math_style_stream_;
......
......@@ -753,10 +753,10 @@ void pptx_slide_context::serialize_animations(std::wostream & strm)
{
CP_XML_ATTR(L"spd",impl_->transition_.Speed.get());
}
if (impl_->transition_.Time)
/* if (impl_->transition_.Time)
{
CP_XML_ATTR(L"p14:dur", impl_->transition_.Time.get());
}
}*/
if (impl_->transition_.PageTime)
{
CP_XML_ATTR(L"advTm", impl_->transition_.PageTime.get());
......
......@@ -96,6 +96,7 @@ void math_mrow::oox_convert(oox::math_context & Context)
bDPr = true;
}
bool need_e_old = Context.is_need_e_, need_e = false;
if (bDPr)
{
Context.output_stream() << L"<m:d>";
......@@ -115,20 +116,31 @@ void math_mrow::oox_convert(oox::math_context & Context)
}
Context.output_stream() << Context.math_style_stream().str();
Context.output_stream() << L"</m:dPr>";
Context.output_stream() << L"<m:e>";
need_e = true;
}
else need_e = Context.is_need_e_;
Context.is_need_e_ = false;
if (need_e)
{
Context.output_stream() << L"<m:e>";
}
for (int i = i_start; i < i_end ; i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
}
if (need_e)
{
Context.output_stream() << L"</m:e>";
}
if (bDPr)
{
Context.output_stream() << L"</m:e>";
Context.output_stream() << L"</m:d>";
}
Context.is_need_e_ = need_e_old;
}
//---------------------------------------------------------------
const wchar_t * math_mfrac::ns = L"math";
......@@ -150,13 +162,23 @@ void math_mfrac::oox_convert(oox::math_context & Context)
{
return;
}
bool need_e = Context.is_need_e_;
if (need_e)
{
Context.output_stream() << L"<m:e>";
}
Context.is_need_e_ = false;
office_math_element* math_element = NULL;
Context.output_stream() << L"<m:f>";
Context.output_stream() << L"<m:num>";
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
Context.output_stream() << L"</m:num>";
Context.is_need_e_ = false;
Context.output_stream() << L"<m:den>";
math_element = dynamic_cast<office_math_element*>(content_[1].get());
......@@ -164,6 +186,12 @@ void math_mfrac::oox_convert(oox::math_context & Context)
Context.output_stream() << L"</m:den>";
Context.output_stream() << L"</m:f>";
if (need_e)
{
Context.output_stream() << L"</m:e>";
}
Context.is_need_e_ = need_e;
}
//---------------------------------------------------------------
const wchar_t * math_msqrt::ns = L"math";
......@@ -192,6 +220,8 @@ void math_msqrt::oox_convert(oox::math_context & Context)
strm << L"<m:deg/>";
strm << L"<m:e>";
Context.is_need_e_ = false;
for (size_t i = 0 ; i < content_.size(); i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
......@@ -230,6 +260,9 @@ void math_mroot::oox_convert(oox::math_context & Context)
math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:deg>";
Context.is_need_e_ = false;
strm << L"<m:e>";
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
......@@ -295,21 +328,23 @@ void math_mstyle::oox_convert(oox::math_context & Context)
}
}
}
bool need_e_old = Context.is_need_e_;
Context.is_need_e_ = content_.size() > 1 ? true : need_e_old;
for (size_t i = 0; i < content_.size(); i++)
{
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
//math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
//math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
//math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
if (row_test || munder_test || frac_test)
Context.output_stream() << L"<m:e>";
//if (row_test || munder_test || frac_test)
// Context.output_stream() << L"<m:e>";
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
if (row_test || munder_test || frac_test)
Context.output_stream() << L"</m:e>";
//if (row_test || munder_test || frac_test)
// Context.output_stream() << L"</m:e>";
//office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
//math_element->oox_convert(Context);
......@@ -320,6 +355,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
Context.text_properties_->content().style_font_name_ = L"Cambria Math";
Context.text_properties_->content().fo_font_size_ = odf_types::length(Context.base_font_size_, odf_types::length::pt);
Context.is_need_e_ = need_e_old;
{
std::wstringstream & strm = Context.math_style_stream();
strm.str( std::wstring() );
......
......@@ -71,11 +71,15 @@ void math_msub::oox_convert(oox::math_context & Context)
strm << L"<m:sSub>";
strm << L"<m:e>";
Context.is_need_e_ = false;
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
strm << L"<m:sub>";
Context.is_need_e_ = false; //??
math_element = dynamic_cast<office_math_element*>(content_[1].get());
math_element->oox_convert(Context);
strm << L"</m:sub>";
......@@ -109,6 +113,8 @@ void math_msup::oox_convert(oox::math_context & Context)
strm << L"<m:sSup>";
strm << L"<m:e>";
Context.is_need_e_ = false;
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
......@@ -142,6 +148,8 @@ void math_msubsup::oox_convert(oox::math_context & Context)
office_math_element* math_element = NULL;
strm << L"<m:sSubSup>";
Context.is_need_e_ = false;
strm << L"<m:e>";
math_element = dynamic_cast<office_math_element*>(content_[0].get());
......@@ -328,6 +336,9 @@ void math_mover::oox_convert(oox::math_context & Context)
strm << L"<m:limUpp>";
strm << L"<m:limUppPr/>";
strm << L"<m:e>";
Context.is_need_e_ = false;
math_element = dynamic_cast<office_math_element*>(content_[0].get());
math_element->oox_convert(Context);
strm << L"</m:e>";
......@@ -355,6 +366,13 @@ void math_munder::oox_convert(oox::math_context & Context)
{//2 elements
std::wostream & strm = Context.output_stream();
bool need_e = Context.is_need_e_;
if (need_e)
{
Context.output_stream() << L"<m:e>";
}
Context.is_need_e_ = false;
office_math_element* math_element = NULL;
strm << L"<m:limLow>";
strm << L"<m:limLowPr/>";
......@@ -367,6 +385,12 @@ void math_munder::oox_convert(oox::math_context & Context)
math_element->oox_convert(Context);
strm << L"</m:lim>";
strm << L"</m:limLow>";
if (need_e)
{
Context.output_stream() << L"</m:e>";
}
Context.is_need_e_ = need_e;
}
}
}
......@@ -92,23 +92,30 @@ void math_mtr::oox_convert(oox::math_context & Context)
std::wostream & strm = Context.output_stream();
strm << L"<m:mr>";
for (size_t i = 0; i < content_.size(); i++)
{
math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
if (row_test || munder_test || frac_test)
Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
if (row_test || munder_test || frac_test)
strm << L"</m:e>";
}
bool need_e_old = Context.is_need_e_;
for (size_t i = 0; i < content_.size(); i++)
{
//Context.is_need_e_ = content_.size() > 1 ? true : false;
Context.is_need_e_ = true;
//math_mrow* row_test = dynamic_cast<math_mrow*>(content_[i].get());
//math_munder* munder_test = dynamic_cast<math_munder*>(content_[i].get());
//math_mfrac* frac_test = dynamic_cast<math_mfrac*>(content_[i].get());
//
//if (row_test || munder_test || frac_test)
// Context.output_stream() << L"<m:e>";// EqArray записался в числитель вместо знаменателя.docx - дублирование
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
//if (row_test || munder_test || frac_test)
// strm << L"</m:e>";
}
strm << L"</m:mr>";
Context.is_need_e_ = need_e_old;
}
//----------------------------------------------------------------------------------------------------
......@@ -151,6 +158,7 @@ void math_mtd::oox_convert(oox::math_context & Context)
std::wostream & strm = Context.output_stream();
strm << L"<m:e>";
Context.is_need_e_ = false;
for (size_t i = 0; i < content_.size(); i++)
{
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
......
......@@ -286,7 +286,7 @@ void math_mtext::oox_convert(oox::math_context & Context)
if (text_)
{
Context.output_stream() << L"<m:r><m:rPr><m:nor/></m:rPr><m:t>";
Context.output_stream() << *text_;
Context.output_stream() << XmlUtils::EncodeXmlString(*text_);
Context.output_stream() << L"</m:t></m:r>";
}
}
......
......@@ -407,7 +407,7 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
switch (style_text_underline_style_->get_type())
{
case line_style::Solid:
if (underlineBold) underline = L"thick";
if (underlineBold) underline = L"heavy";
else underline = L"sng";
break;
case line_style::Dotted:
......
......@@ -44,17 +44,67 @@ HRESULT ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name)
Ole1FormatReader ole1Reader(pData, nSize);
NSFile::CFileBinary file;
file.CreateFileW(sOle2Name);
if (ole1Reader.NativeDataSize > 0)//conv_NI38P7GBIpw1aD84H3k.rtf
{
file.WriteFile(ole1Reader.NativeData, ole1Reader.NativeDataSize);
}
else
{
if (ole1Reader.NativeDataSize > 0)
{
POLE::Storage * storageOut = new POLE::Storage(sOle2Name.c_str());
if ( (storageOut) && (storageOut->open(true, true)))
{
_UINT32 tmp = 0;
std::string name = ole1Reader.Header.ClassName.val;
_UINT32 name_size = name.length() + 1;
//Ole
BYTE dataOleInfo[] = {0x01,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
POLE::Stream oStream3(storageOut, "\001Ole", true, 20);
oStream3.write(dataOleInfo, 20);
oStream3.flush();
//CompObj
BYTE dataCompObjHeader[28] = {0x01,0x00,0xfe,0xff,0x03,0x0a,0x00,0x00,0xff,0xff,0xff,0xff,0x0a,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
POLE::Stream oStream1(storageOut, "\001CompObj", true, 28 + (name_size + 5) + 2 * (ole1Reader.Header.ClassName.size + 4) + 4 * 4);
oStream1.write(dataCompObjHeader, 28);
oStream1.write((BYTE*)&name_size, 4);
oStream1.write((BYTE*)name.c_str(), name_size);
//oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
//oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
oStream1.write((BYTE*)&ole1Reader.Header.ClassName.size, 4);
oStream1.write((BYTE*)ole1Reader.Header.ClassName.val.c_str(), ole1Reader.Header.ClassName.size);
tmp = 0x71B239F4;
oStream1.write((BYTE*)&tmp, 4); // UnicodeMarker
tmp = 0;
oStream1.write((BYTE*)&tmp, 4); // UnicodeUserType
oStream1.write((BYTE*)&tmp, 4); // UnicodeClipboardFormat
oStream1.write((BYTE*)&tmp, 4); //
oStream1.flush();
//ObjInfo
BYTE dataObjInfo[] = {0x00,0x00,0x03,0x00,0x04,0x00};
POLE::Stream oStream2(storageOut, "\003ObjInfo", true, 6);
oStream2.write(dataObjInfo, 6);
oStream2.flush();
//Ole10Native
POLE::Stream streamData(storageOut, "\001Ole10Native", true, ole1Reader.NativeDataSize + 4);
streamData.write((BYTE*)&ole1Reader.NativeDataSize, 4);
streamData.write(ole1Reader.NativeData, ole1Reader.NativeDataSize);
streamData.flush();
storageOut->close();
delete storageOut;
}
}
else //conv_NI38P7GBIpw1aD84H3k.rtf
{
NSFile::CFileBinary file;
file.CreateFileW(sOle2Name);
file.WriteFile(pData, nSize);
file.CloseFile();
}
file.CloseFile();
return S_FALSE;
}
//-----------------------------------------------------------------------------------------
......@@ -1679,20 +1729,35 @@ void RtfOleBinReader::ExecuteText(RtfDocument& oDocument, RtfReader& oReader, st
void RtfOleBinReader::GetData( BYTE** ppData, long& nSize)
{
nSize = 0;
for (size_t i = 0; i < m_arData.size(); i++)
size_t pos = 0, start = 0, nSizeRead = 0;
if (m_arData.size() > 1)
{
nSizeRead = *((short*)m_arData[0].c_str());
start = 1; // first content all size
}
for (size_t i = start; i < m_arData.size(); i++)
{
nSize += m_arData[i].length();
}
(*ppData) = new BYTE[ nSize];
int pos = 0;
for (size_t i = 0; i < m_arData.size(); i++)
for (size_t i = start; i < m_arData.size(); i++)
{
memcpy((*ppData) + pos, m_arData[i].c_str(), m_arData[i].length());
BYTE *buf = (BYTE*)m_arData[i].c_str();
pos += m_arData[i].length();
for (size_t j = 0; j < m_arData[i].length(); j += 2)
{
BYTE nByte = 0;
nByte = RtfUtility::ToByte(buf[ j ]) << 4;
nByte |= RtfUtility::ToByte(buf[ j + 1]);
(*ppData)[pos++] = nByte;
}
}
nSize = pos;
}
bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
{
......@@ -1725,7 +1790,7 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
HRESULT hRes = S_FALSE;
//конвертация Ole1 в Ole2
#if 0 //defined(_WIN32) || defined(_WIN64)
#if 0//defined(_WIN32) || defined(_WIN64)
RtfOle1ToOle2Stream oStream;
oStream.lpstbl = new OLESTREAMVTBL();
......
......@@ -307,20 +307,23 @@ public:
stream >> Header.OLEVersion >> Header.FormatID;
if (Header.OLEVersion & 0x00000500)
if (Header.FormatID == 2)
{
stream >> Header.ClassName;
}
stream >> Header.Width >> Header.Height;
stream >> NativeDataSize;
if (Header.OLEVersion & 0x00000500)
{
stream >> Header.ClassName;
}
stream >> Header.Width >> Header.Height;
NativeData = stream.GetCurPtr();
stream.Skip(NativeDataSize);
stream >> NativeDataSize;
NativeData = stream.GetCurPtr();
stream.Skip(NativeDataSize);
int sz = stream.CanRead();
int sz = stream.CanRead();
/// далее графическое представление
/// далее графическое представление
}
}
ObjectHeader Header;
......
......@@ -56,6 +56,10 @@
#include <stdio.h>
#endif
#ifdef BUIDLER_OPEN_DOWNLOAD_ENABLED
#include "../../Common/FileDownloader/FileDownloader.h"
#endif
template <typename T>
class CScopeWrapper
{
......@@ -558,6 +562,8 @@ namespace NSDoctRenderer
bool m_bIsCacheScript;
std::wstring m_sFolderForSaveOnlyUseNames;
std::string m_sGlobalVariable;
bool m_bIsGlobalVariableUse;
public:
......@@ -851,6 +857,64 @@ namespace NSDoctRenderer
#endif
}
void MoveFileOpen(const std::wstring& from, const std::wstring& to)
{
#ifdef BUIDLER_OPEN_DOWNLOAD_ENABLED
int n1 = (int)from.find (L"www");
int n2 = (int)from.find (L"http");
int n3 = (int)from.find (L"ftp");
int n4 = (int)from.find (L"https");
//если nI сранивать не с 0, то будут проблемы
//потому что в инсталяции мы кладем файлы в /var/www...
if (0 == n1 || 0 == n2 || 0 == n3 || 0 == n4)
{
CFileDownloader oDownloader(from, false);
oDownloader.SetFilePath(to);
if (oDownloader.DownloadSync())
return;
}
#endif
#ifdef BUIDLER_OPEN_BASE64_ENABLED
if (0 == from.find(L"data:"))
{
std::wstring::size_type findBase64 = from.find(L"base64,");
if (std::wstring::npos != findBase64)
{
int nStartBase64 = (int)findBase64;
if (50 > nStartBase64)
{
nStartBase64 += 7;
const wchar_t* pStart = from.c_str() + nStartBase64;
int nDataLen = (int)from.length() - nStartBase64;
std::string sBase64 = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(pStart, (LONG)nDataLen, false);
BYTE* pDataDst = NULL;
int nDataDstLen = 0;
if (NSFile::CBase64Converter::Decode(sBase64.c_str(), (int)sBase64.length(), pDataDst, nDataLen))
{
NSFile::CFileBinary oFileDst;
if (oFileDst.CreateFileW(to))
{
oFileDst.WriteFile(pDataDst, (DWORD)nDataDstLen);
oFileDst.CloseFile();
RELEASEARRAYOBJECTS(pDataDst);
return;
}
RELEASEARRAYOBJECTS(pDataDst);
}
}
}
}
#endif
NSFile::CFileBinary::Copy(from, to);
}
int OpenFile(const std::wstring& path, const std::wstring& params)
{
Init();
......@@ -861,7 +925,7 @@ namespace NSDoctRenderer
NSDirectory::CreateDirectory(m_sFileDir + L"/changes");
std::wstring sFileCopy = m_sFileDir + L"/origin." + NSCommon::GetFileExtention(path);
NSFile::CFileBinary::Copy(path, sFileCopy);
MoveFileOpen(path, sFileCopy);
COfficeFileFormatChecker oChecker;
if (!oChecker.isOfficeFile(path))
......@@ -1054,7 +1118,16 @@ namespace NSDoctRenderer
NSStringUtils::CStringBuilder oBuilder;
std::wstring _path = path;
std::wstring sDstFileDir = NSCommon::GetDirectoryName(_path);
if (!m_sFolderForSaveOnlyUseNames.empty())
{
_path = m_sFolderForSaveOnlyUseNames;
wchar_t last = m_sFolderForSaveOnlyUseNames.c_str()[m_sFolderForSaveOnlyUseNames.length() - 1];
if (last != '/' && last != '\\')
_path += L"/";
_path += NSCommon::GetFileName(path);
}
std::wstring sDstFileDir = NSCommon::GetDirectoryName(_path);
if ((sDstFileDir != _path) && !NSDirectory::Exists(sDstFileDir))
NSDirectory::CreateDirectories(sDstFileDir);
......@@ -1642,6 +1715,8 @@ namespace NSDoctRenderer
m_pInternal->m_oParams.m_sWorkDir = std::wstring(value);
else if (sParam == "--cache-scripts")
m_pInternal->m_bIsCacheScript = (std::wstring(value) == L"true");
else if (sParam == "--save-use-only-names")
m_pInternal->m_sFolderForSaveOnlyUseNames = std::wstring(value);
else if (sParam == "--argument")
{
std::wstring sArg(value);
......
......@@ -44,3 +44,27 @@ unix {
target.path = /usr/lib
INSTALLS += target
}
# downloader
DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED
DEFINES += BUIDLER_OPEN_BASE64_ENABLED
HEADERS += ../../Common/FileDownloader/FileDownloader.h
core_windows {
SOURCES += \
../../Common/FileDownloader/FileDownloader_win.cpp
LIBS += -lurlmon
}
core_linux {
SOURCES += \
../../Common/FileDownloader/FileDownloader_curl.cpp
LIBS += -lcurl
}
core_mac {
OBJECTIVE_SOURCES += \
../../Common/FileDownloader/FileDownloader_mac.mm
LIBS += -framework AppKit
}
......@@ -217,6 +217,11 @@ namespace MetaFile
double dX, dY, dW, dH;
GetBounds(&dX, &dY, &dW, &dH);
if (dW < 0)
dW = -dW;
if (dH < 0)
dH = -dH;
if (nWidth < 0) nWidth = dW;
nHeight = (int)((double)nWidth * dH / dW);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment