Compare commits

...

51 Commits

Author SHA1 Message Date
22f986295f . 2017-10-12 18:17:16 +03:00
86d2bde83b x2t version up 2017-10-12 12:01:44 +03:00
07041d60f6 . 2017-10-12 11:54:47 +03:00
a5466ab740 XlsFormatReader - external data (dde, workbook, ..) 2017-10-12 11:41:21 +03:00
dfd54ff53f _MSC_VER >= 1900 build 2017-10-11 16:30:37 +03:00
6ec7d77e19 speed logger 2017-10-09 15:21:16 +03:00
356ccba104 fixed bug#35998 2017-10-06 14:09:56 +03:00
3044d1122a OdfFormatReader - fix pilot tables (groups & references) 2017-10-06 11:36:00 +03:00
fb00ba7ecb fix users file 2017-10-06 11:35:03 +03:00
9dd115ec56 v5.0.1 2017-10-05 14:48:07 +03:00
34083d996b preload cef library 2017-10-03 16:10:20 +03:00
244d549cf8 --save-use-only-names mode 2017-10-03 11:07:01 +03:00
ef96571879 outlineLvl 2017-10-02 17:18:50 +03:00
7a27150de6 OdfFormatReader - fix math after testing 2017-10-02 17:11:12 +03:00
2197fddb7b RtfFormatReader - fix ole 2017-09-29 19:29:05 +03:00
d31344d7d3 correct metafile bounds 2017-09-29 17:29:21 +03:00
f7617b42cb Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-29 15:57:28 +03:00
8312cce2c3 . 2017-09-29 15:56:39 +03:00
dc89e1d484 Merge branch 'hotfix/v5.0.1' of https://github.com/ONLYOFFICE/core into hotfix/v5.0.1 2017-09-29 15:33:18 +03:00
17f4903347 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-29 15:31:52 +03:00
ebdfb2f785 OOxmlFormat - fix users files 2017-09-29 15:28:46 +03:00
ec2901bf48 RtfFormat - fix users file 2017-09-29 14:24:57 +03:00
f9e87624c0 . 2017-09-29 13:31:08 +03:00
5f0e6349cc . 2017-09-29 11:06:48 +03:00
3bdf44b8c7 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-29 10:56:48 +03:00
d586698025 x2t version up 2017-09-29 10:54:08 +03:00
eb6fb03ca5 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-28 19:27:08 +03:00
ad40f51dee OdsFormatReader - fix after testing 2017-09-28 19:26:35 +03:00
5e60456fc1 fix for crash sample.docx file 2017-09-28 17:30:13 +03:00
1f9e3f4fd8 OdpFormatReader - fix after testing 2017-09-27 19:49:10 +03:00
334620cd5a hidePivotFieldList in Editor.bin 2017-09-26 17:19:58 +03:00
4a5fca5ccf hidePivotFieldList in Editor.bin 2017-09-26 17:18:05 +03:00
828df16fe5 OdfFormat - fix transactions 2017-09-26 16:41:43 +03:00
66dae03919 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  fix bug #35895
  x2t version up
  OdfFormatReader - fix after testing
2017-09-26 16:37:52 +03:00
114a01f364 event for drag&drop content in ios11 2017-09-26 16:37:43 +03:00
2ddaf33156 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2017-09-25 19:07:39 +03:00
1af37af850 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-25 19:06:43 +03:00
b58026ea66 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatReader - fix after testing
  .
  PptFormat - support vba macros
  DocFormat - vba macros
2017-09-25 18:54:39 +03:00
09a8a6794a log for errors 2017-09-25 18:54:31 +03:00
941cbe4f9b fix bug #35895 2017-09-25 17:10:50 +03:00
668d0c2abf x2t version up 2017-09-25 16:53:39 +03:00
66db5b09e6 Merge remote-tracking branch 'origin/hotfix/v5.0.1' into develop 2017-09-25 16:49:31 +03:00
e7dae4b381 OdfFormatReader - fix after testing 2017-09-25 16:46:32 +03:00
7dbbacf336 OdfFormatReader - fix after testing 2017-09-22 20:00:21 +03:00
f43a0bbfe2 . 2017-09-21 17:06:44 +03:00
746c228261 PptFormat - support vba macros 2017-09-21 16:59:38 +03:00
d8c7d41462 DocFormat - vba macros 2017-09-20 17:58:41 +03:00
4a9abce180 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  .
  x2t version up
2017-09-20 14:21:11 +03:00
a78711a19c fix build for ios11 2017-09-20 14:21:04 +03:00
57465b60bf Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatReader - support pilot(pivot) tables add flat open office formats ...
2017-09-19 19:33:48 +03:00
24d58fe189 fix for build 2017-09-19 19:33:41 +03:00
228 changed files with 5278 additions and 2149 deletions

View File

@ -501,7 +501,7 @@ namespace DocFileFormat
facet.widen((char*)bytes, (char*)bytes + size, &result[0]);
for (long i=0; i < result.length(); i++)
for (size_t i=0; i < result.length(); i++)
{
STLCollection->push_back(result[i]);
}
@ -536,7 +536,7 @@ namespace DocFileFormat
delete [] pStrUtf16;
return GetSTLCollectionFromLocale(STLCollection, bytes,size);
}
for (long i=0; i < nLength; i++)
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf16[i]);
}
@ -566,7 +566,7 @@ namespace DocFileFormat
delete [] pStrUtf32;
return GetSTLCollectionFromLocale(STLCollection, bytes, size);
}
for (long i=0; i < nLength; i++)
for (unsigned int i = 0; i < nLength; i++)
{
STLCollection->push_back(pStrUtf32[i]);
}
@ -652,7 +652,7 @@ namespace DocFileFormat
NSUnicodeConverter::CUnicodeConverter oConverter;
std::wstring unicode_string = oConverter.toUnicode((char*)bytes, size, sCodePage.c_str());
for (long i=0; i < unicode_string.size(); i++)
for (size_t i = 0; i < unicode_string.size(); i++)
{
STLCollection->push_back(unicode_string[i]);
}

View File

@ -157,6 +157,7 @@ namespace OpenXmlRelationshipTypes
static const wchar_t* OleObject = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
static const wchar_t* GlossaryDocument = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument";
static const wchar_t* Package = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
static const wchar_t* VbaProject = L"http://schemas.microsoft.com/office/2006/relationships/vbaProject";
}
namespace MicrosoftWordRelationshipTypes

View File

@ -65,7 +65,7 @@ namespace DocFileFormat
{
ConversionContext context( doc, docx );
//Write styles.xml
//Write styles.xml
if (doc->Styles)
{
StyleSheetMapping styleSheetMapping( &context );
@ -88,9 +88,7 @@ namespace DocFileFormat
return S_FALSE;
}
}
//Write numbering.xml
//Write numbering.xml
if (doc->listTable)
{
NumberingMapping numberingMapping( &context );
@ -110,7 +108,7 @@ namespace DocFileFormat
}
}
//Write fontTable.xml
//Write fontTable.xml
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
@ -130,7 +128,7 @@ namespace DocFileFormat
}
}
//write the footnotes
//write the footnotes
FootnotesMapping footnotesMapping( &context );
doc->Convert( &footnotesMapping );
@ -147,7 +145,7 @@ namespace DocFileFormat
}
}
//write the endnotes
//write the endnotes
EndnotesMapping endnotesMapping( &context );
doc->Convert( &endnotesMapping );
@ -164,7 +162,7 @@ namespace DocFileFormat
}
}
//write the comments
//write the comments
CommentsMapping commentsMapping( &context );
doc->Convert( &commentsMapping );
@ -181,13 +179,13 @@ namespace DocFileFormat
}
}
//write settings.xml at last because of the rsid list
//write settings.xml at last because of the rsid list
if (doc->DocProperties)
{
SettingsMapping settingsMapping( &context );
doc->DocProperties->Convert( &settingsMapping );
}
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 975000 );
@ -204,7 +202,7 @@ namespace DocFileFormat
return S_OK;
}
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress)
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
{
long result = S_FALSE;
@ -219,7 +217,7 @@ namespace DocFileFormat
if (result == S_OK)
{
docx.SaveDocument();
docx.SaveDocument(bMacros);
if (progress)progress->OnProgress(progress->caller, DOC_ONPROGRESSEVENT_ID, 1000000);

View File

@ -48,7 +48,7 @@ namespace DocFileFormat
std::wstring m_sTempFolder;
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress);
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros);
private:
long Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);

View File

@ -50,8 +50,7 @@ namespace DocFileFormat
void MainDocumentMapping::Apply(IVisitable* visited)
{
m_document = static_cast<WordDocument*>(visited);
m_context->_docx->RegisterDocument();
// Header
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );

View File

@ -73,7 +73,6 @@ namespace DocFileFormat
NSDirectory::CreateDirectory( m_strOutputPath + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"_rels" );
WriteRelsFile( DocumentRelationshipsFile );
WriteRelsFile( FootnotesRelationshipsFile );
@ -199,7 +198,14 @@ namespace DocFileFormat
{
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocument, L"");
}
int OpenXmlPackage::RegisterDocumentMacros()
{
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocumentMacro, L"");
}
int OpenXmlPackage::RegisterVbaProject()
{
return AddPart( L"word", L"vbaProject.bin", MicrosoftWordContentTypes::VbaProject, OpenXmlRelationshipTypes::VbaProject );
}
int OpenXmlPackage::RegisterFontTable()
{
return AddPart( L"word", L"fontTable.xml", WordprocessingMLContentTypes::FontTable, OpenXmlRelationshipTypes::FontTable );

View File

@ -118,6 +118,8 @@ namespace DocFileFormat
class OpenXmlPackage
{
public:
const WordDocument* docFile;
private:
ContentTypesFile DocumentContentTypesFile;
RelationshipsFile MainRelationshipsFile;
@ -137,8 +139,6 @@ namespace DocFileFormat
int _footerCounter;
int _oleCounter;
const WordDocument* docFile;
int AddHeaderPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
int AddFooterPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
int AddFootnotesPart( const std::wstring& fileName, const std::wstring& relationshipType = L"", const std::wstring& targetMode = L"" );
@ -166,6 +166,7 @@ namespace DocFileFormat
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
int RegisterDocument();
int RegisterDocumentMacros();
int RegisterFontTable();
int RegisterNumbering();
int RegisterSettings();
@ -179,5 +180,6 @@ namespace DocFileFormat
int RegisterOLEObject ( const IMapping* mapping, const std::wstring& objectType );
int RegisterPackage ( const IMapping* mapping, const std::wstring& objectType);
int RegisterExternalOLEObject( const IMapping* mapping, const std::wstring& objectType, const std::wstring& uri );
int RegisterVbaProject();
};
}

View File

@ -42,7 +42,6 @@ namespace DocFileFormat
{
}
~StructuredStorageReader()
{
if(m_pStorage)
@ -62,6 +61,12 @@ namespace DocFileFormat
}
return false;
}
bool isDirectory( const std::string& name )
{
if (!m_pStorage) return false;
return m_pStorage->isDirectory(name);
}
bool GetStream (const char *path, POLE::Stream** ppStream)
{
@ -79,8 +84,78 @@ namespace DocFileFormat
{
return m_pStorage;
}
void copy( int indent, std::string path, POLE::Storage * storageOut, bool withRoot = true)
{
std::list<std::string> entries, entries_sort;
entries = m_pStorage->entries( path );
for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
{
std::string name = *it;
std::string fullname = path + name;
if( m_pStorage->isDirectory( fullname ) )
{
entries_sort.push_back(name);
}
else
{
entries_sort.push_front(name);
}
}
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::string>::iterator it = entries_sort.begin(); it != entries_sort.end(); it++ )
{
std::string name = *it;
std::string fullname = path + name;
if( m_pStorage->isDirectory( fullname ) )
{
copy( indent + 1, fullname + "/", storageOut, withRoot );
}
else
{
copy_stream(fullname, storageOut, withRoot);
}
}
}
private:
void copy_stream(std::string streamName, POLE::Storage * storageOut, bool withRoot = true)
{
POLE::Stream *stream = new POLE::Stream(m_pStorage, streamName);
if (!stream) return;
stream->seek(0);
int size_stream = stream->size();
if (withRoot == false)
{
int pos = streamName.find("/");
if (pos >= 0)
streamName = streamName.substr(pos + 1);
}
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, size_stream);
if (!streamNew) return;
unsigned char* data_stream = new unsigned char[size_stream];
if (data_stream)
{
stream->read(data_stream, size_stream);
streamNew->write(data_stream, size_stream);
delete []data_stream;
data_stream = NULL;
}
streamNew->flush();
delete streamNew;
delete stream;
}
POLE::Storage* m_pStorage;
};

View File

@ -1905,13 +1905,13 @@ namespace DocFileFormat
switch (pSpa->wr)
{
case 0:
case 2: wrapType = L"square";
case 1: wrapType = L"topAndBottom";
case 3: wrapType = L"through";
case 2: wrapType = L"square"; break;
case 1: wrapType = L"topAndBottom"; break;
case 3: wrapType = L"through"; break;
case 4:
case 5: wrapType = L"tight";
case 5: wrapType = L"tight"; break;
default:
wrapType = L"none";
wrapType = L"none"; break;
}
}

View File

@ -528,11 +528,24 @@ namespace DocFileFormat
}
void WordDocument::DecryptStream( int level, std::string path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
{
std::list<std::string> entries;
std::list<std::string> entries, entries_sort;
entries = storageIn->entries( path );
std::list<std::string>::iterator it;
for( it = entries.begin(); it != entries.end(); ++it )
for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
{
std::string name = *it;
std::string fullname = path + name;
if( storageIn->isDirectory( fullname ) )
{
entries_sort.push_back(name);
}
else
{
entries_sort.push_front(name);
}
}
for( std::list<std::string>::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it )
{
std::string name = *it;
std::string fullname = path + name;

View File

@ -99,18 +99,17 @@ namespace DocFileFormat
bool bOlderVersion;
int document_code_page;
inline StructuredStorageReader* GetStorage() const
{
return m_pStorage;
}
private:
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
void DecryptStream (int level, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
inline StructuredStorageReader* GetStorage() const
{
return m_pStorage;
}
inline OfficeArtContent* GetOfficeArt ()
{
return officeArtContent;

View File

@ -180,10 +180,37 @@ namespace DocFileFormat
{
}
void WordprocessingDocument::SaveDocument()
void WordprocessingDocument::SaveDocument(bool &bMacros)
{
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
NSDirectory::CreateDirectory( pathWord );
std::wstring pathWord = m_strOutputPath + FILE_SEPARATOR_STR + L"word" ;
NSDirectory::CreateDirectory( pathWord );
if (bMacros && docFile->GetStorage()->isDirectory("Macros"))
{
std::wstring sVbaProjectFile = pathWord + FILE_SEPARATOR_STR + L"vbaProject.bin";
POLE::Storage *storageVbaProject = new POLE::Storage(sVbaProjectFile.c_str());
if ((storageVbaProject) && (storageVbaProject->open(true, true)))
{
docFile->GetStorage()->copy(0, "Macros/", storageVbaProject, false);
storageVbaProject->close();
delete storageVbaProject;
RegisterDocumentMacros();
RegisterVbaProject();
//output_document->get_xl_files().add_vba_project();
}
else bMacros = false;
}
else
bMacros = false;
if (!bMacros)
{
RegisterDocument();
}
WritePackage();

View File

@ -76,6 +76,7 @@ namespace DocFileFormat
public:
WordprocessingDocument(const std::wstring & _docxDirectory, const WordDocument* _docFile);
virtual ~WordprocessingDocument();
void SaveDocument();
void SaveDocument(bool &bMacros);
};
}

View File

@ -34,14 +34,14 @@
#include "../DocDocxConverter/Converter.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, ProgressCallback *ffCallBack )
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
{
HRESULT hr = S_FALSE;
DocFileFormat::Converter docToDocx;
docToDocx.m_sTempFolder = m_sTempFolder;
hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack);
hr= docToDocx.LoadAndConvert(docFile, docxDirectory, password, ffCallBack, bMacros);
return hr;
}

View File

@ -53,7 +53,7 @@ public:
std::wstring m_sTempFolder;
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, ProgressCallback *ffCallBack = NULL);
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack = NULL);
HRESULT SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL);
};

View File

@ -54,17 +54,27 @@ int _tmain(int argc, _TCHAR* argv[])
if (argc < 2) return 1;
std::wstring sSrcDoc = argv[1];
std::wstring sDstDocx = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx";
std::wstring sDstDocx;
std::wstring outputDir = NSDirectory::GetFolderPath(sDstDocx);
std::wstring outputDir = NSDirectory::GetFolderPath(sSrcDoc);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
COfficeDocFile docFile;
docFile.m_sTempFolder = outputDir;
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", NULL);
bool bMacros = true;
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", bMacros, NULL);
if (bMacros)
{
sDstDocx = sSrcDoc + L"-my.docm";
}
else
{
sDstDocx = sSrcDoc + L"-my.docx";
}
if (hRes == S_OK)
{
COfficeUtils oCOfficeUtils(NULL);

View File

@ -885,6 +885,11 @@ public:
pCStringWriter->WriteString(oSectPr.Write());
pCStringWriter->WriteString(std::wstring(_T("</w:sectPr>")));
}break;
case c_oSerProp_pPrType::outlineLvl:
{
long outlineLvl = m_oBufferedStream.GetLong();
pCStringWriter->WriteString(L"<w:outlineLvl w:val=\"" + std::to_wstring(outlineLvl) + L"\"/>");
}break;
default:
res = c_oSerConstants::ReadUnknown;
break;

View File

@ -344,7 +344,8 @@ extern int g_nCurFormatVersion;
FramePr = 30,
SectPr = 31,
numPr_Ins = 32,
pPrChange = 33
pPrChange = 33,
outlineLvl = 34
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{

View File

@ -1024,6 +1024,12 @@ namespace BinDocxRW
WritePPrChange(pPr.m_oPPrChange.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(pPr.m_oOutlineLvl.IsInit() && pPr.m_oOutlineLvl->m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::outlineLvl);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pPr.m_oOutlineLvl->m_oVal->GetValue());
}
//SectPr
if(NULL != m_oBinaryHeaderFooterTableWriter && pPr.m_oSectPr.IsInit())
{

View File

@ -314,7 +314,7 @@
17E17ED41AC453F800BEA2EA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Ascensio System SIA";
};
buildConfigurationList = 17E17ED71AC453F800BEA2EA /* Build configuration list for PBXProject "ASCOfficeDocxFile2Lib" */;
@ -402,6 +402,7 @@
EXECUTABLE_PREFIX = lib;
GCC_ENABLE_CPP_EXCEPTIONS = YES;
GCC_ENABLE_CPP_RTTI = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
@ -441,14 +442,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -470,7 +477,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
@ -486,14 +493,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -509,7 +522,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;

View File

@ -454,7 +454,7 @@ namespace formulasconvert {
// boost::match_default | boost::format_all);
bool isFormula = check_formula(workstr);
boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
@ -477,6 +477,12 @@ namespace formulasconvert {
}
//todooo INDEX((A1:C6~A8:C11),2,2,2) - ???? - INDEX_emb.ods
}
else
{
size_t sz_workstr = workstr.length();
if (workstr.substr(0, (std::min)((size_t)3, sz_workstr)) == L"of:")//sample_02neu_crashes.ods
workstr = workstr.substr(3);
}
//-----------------------------------------------------------

View File

@ -154,7 +154,7 @@ namespace cpdoccore
if (val)
{
std::wstring tmp = *val;
XmlUtils::GetLower(tmp);
tmp = XmlUtils::GetLower(tmp);
return optional<bool>::Type((tmp == xml_char_value_type::trueVal));
}
else

View File

@ -96,7 +96,7 @@ void text_tracked_context::start_change (std::wstring id)
{
current_state_.clear();
current_state_.id = id;
current_state_.id = id;
}
void text_tracked_context::end_change ()
{
@ -378,7 +378,8 @@ void docx_conversion_context::start_document()
output_stream() << L"xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" ";
output_stream() << L"xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ";
output_stream() << L"xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" ";
output_stream() << L"xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ";
output_stream() << L"xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ";
output_stream() << L"xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" ";
output_stream() << L"mc:Ignorable=\"w14 wp14\">";
@ -406,14 +407,12 @@ void docx_conversion_context::end_document()
output_document_->get_word_files().set_notes(notes_context_);
////////////////////////
int count = 0;
BOOST_FOREACH(const oox_chart_context_ptr& chart, charts_)
for (size_t i = 0; i < charts_.size(); i++)
{
count++;
package::chart_content_ptr content = package::chart_content::create();
chart->serialize(content->content());
chart->dump_rels(content->get_rel_file()->get_rels());
charts_[i]->serialize(content->content());
charts_[i]->dump_rels(content->get_rel_file()->get_rels());
output_document_->get_word_files().add_charts(content);
@ -580,10 +579,10 @@ mc:Ignorable=\"w14 wp14\">";
strm << L"</w:abstractNum>";
}
BOOST_FOREACH(int numId, numIds)
for (size_t i = 0; i < numIds.size(); i++)
{
strm << L"<w:num w:numId=\"" << numId << L"\" >";
strm << L"<w:abstractNumId w:val=\"" << numId << "\" />";
strm << L"<w:num w:numId=\"" << numIds[i] << L"\" >";
strm << L"<w:abstractNumId w:val=\"" << numIds[i] << "\" />";
strm << L"</w:num>";
}
@ -801,7 +800,7 @@ bool docx_conversion_context::process_page_properties(std::wostream & strm)
if (page_layout_instance_)
{
page_layout_instance_->docx_convert_serialize(strm, *this);
page_layout_instance_->docx_serialize(strm, *this);
}
else
{
@ -1286,7 +1285,8 @@ void docx_conversion_context::start_text_changes (std::wstring id)
L" w:author=\"" + state.author + L"\"" ;
finish_run();
state.active = true;
state.active = true;
state.in_drawing = get_drawing_state_content();
if (state.type == 1)
{
@ -1420,6 +1420,9 @@ void docx_conversion_context::end_changes()
if (state.type == 0) continue; //unknown change ... libra format change skip
if (state.type == 3) continue;
if (!state.active) continue;
if (state.in_drawing != get_drawing_state_content())
continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";

View File

@ -492,10 +492,11 @@ public:
std::wstring id;
std::wstring author;
std::wstring date;
int type;
int type = 0;
std::wstring style_name;
std::vector<std::wstring> content; //delete elements
bool active;
bool active = false;
bool in_drawing = false;
void clear()
{
@ -505,6 +506,7 @@ public:
date.clear();
content.clear();
active = false;
in_drawing = false;
}
};
std::wstring dumpPPr_;

View File

@ -392,8 +392,11 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
{
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
if (val.cx > 0 || val.cy > 0)
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
serialize_null_extent(CP_XML_STREAM());
}
@ -463,10 +466,13 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
}
}
}
CP_XML_NODE(L"wp:extent")
if (val.cx > 0 || val.cy > 0)
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
}
serialize_wrap(CP_XML_STREAM(), val);

View File

@ -319,6 +319,7 @@ namespace
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" >";
//mc:Ignorable=\"w14 wp14\"

View File

@ -181,7 +181,11 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
sub_path = L"embeddings/";
}
else
{
isMediaInternal = is_internal(href, odf_packet_);
if (href.empty() && type == typeImage)
return L"";
}
int number=0;
@ -205,9 +209,9 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id;
for (int i = 0 ; i < items_.size(); i++)
for (size_t i = 0 ; i < items_.size(); i++)
{
if (items_[i].href == inputPath)
if ((items_[i].href == inputPath && !inputPath.empty()) || (items_[i].type == type && inputPath.empty()))
{
id = items_[i].Id;
outputPath = items_[i].outputName;

View File

@ -57,6 +57,7 @@ oox_chart_series::oox_chart_series()
iSymbolMarkerType_ = 0;
bLocalTable_ = false;
labelPosEnabled_ = true;
}
void oox_chart_series::setName(std::wstring &value)
{
@ -69,8 +70,7 @@ void oox_chart_series::setFormula(int ind, std::wstring &value, std::wstring & f
if (ind == 0)
{
long res = value.find(L"local-table");
if (res >=0) return;
if (std::wstring::npos != value.find(L"local-table")) return;
values_[ind].strRef_.formula = converter.convert_chart_distance(value);
values_[ind].strRef_.present = true;
@ -78,8 +78,8 @@ void oox_chart_series::setFormula(int ind, std::wstring &value, std::wstring & f
}
else
{
long res = value.find(L"local-table");
if (res >=0 && !bLocalTable_ ) return; //в xlsx низя .... нужно сделать тогда отдельную table.xml
if (std::wstring::npos != value.find(L"local-table") && !bLocalTable_ ) return;
//в xlsx низя .... нужно сделать тогда отдельную table.xml
values_[ind].numRef_.formula = converter.convert_chart_distance(value);
values_[ind].numRef_.present = true;
@ -135,7 +135,7 @@ void oox_chart_series::parse_properties()
if (*intVal == 2) data_labels_->set_showPercent(true);
}
odf_reader::GetProperty(content_.properties_, L"label-position", intVal);
if (intVal)
if (intVal && labelPosEnabled_)
{
if (!data_labels_) data_labels_ = oox_data_labels();
@ -220,12 +220,24 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
shape.set(content_.graphic_properties_, content_.fill_);
shape.oox_serialize(_Wostream);
for (int i=0; i < 5; i++)
for (int i = 0; i < 5; i++)
{
if (values_[i].present)
{
if (bLocalTable_)
{
if (values_[i].numRef_.present && values_[i].numRef_.num_cache_count == 0)
{
continue;
}
if (values_[i].strRef_.present && values_[i].strRef_.str_cache_count == 0 )
{
continue;
}
}
CP_XML_NODE(values_[i].type)
{
if (values_[i].numRef_.present && !bLocalTable_)
{
CP_XML_NODE(L"c:numRef")

View File

@ -55,6 +55,7 @@ public:
virtual void oox_serialize(std::wostream & _Wostream) = 0;
bool labelPosEnabled_;
_oox_chart_values values_[5]; //cat(labels), common, x, y, bubble,
int id_;
std::wstring name_; //tx (Series Text) §21.2.2.215

View File

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

View File

@ -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_;

View File

@ -117,15 +117,15 @@ void oox_data_labels::oox_serialize(std::wostream & _Wostream)
case 1: CP_XML_ATTR(L"val", L"b"); break;
case 2: CP_XML_ATTR(L"val", L"b"); break;
case 3: CP_XML_ATTR(L"val", L"b"); break;
case 4: CP_XML_ATTR(L"val", L"ctr"); break;
case 5: CP_XML_ATTR(L"val", L"inEnd"); break;
case 6: CP_XML_ATTR(L"val", L"l"); break;
case 7: CP_XML_ATTR(L"val", L"inBase"); break;
case 8: CP_XML_ATTR(L"val", L"outEnd"); break;
case 9: CP_XML_ATTR(L"val", L"r"); break;
case 10: CP_XML_ATTR(L"val", L"t"); break;
case 11: CP_XML_ATTR(L"val", L"t"); break;
case 12: CP_XML_ATTR(L"val", L"t"); break;
case 5: //CP_XML_ATTR(L"val", L"inEnd"); break;
case 8: //CP_XML_ATTR(L"val", L"outEnd"); break;
case 4: CP_XML_ATTR(L"val", L"ctr"); break;
}
}

View File

@ -171,7 +171,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
if ( color.empty() )
{
if (always_draw) color = L"000000";
else color = L"FFFFFFFF";
else color = L"FFFFFF";
}
CP_XML_NODE(L"a:srgbClr")
@ -210,16 +210,15 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
}
}
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:avLst")
{
_CP_OPT(bool) bModifiers;
_CP_OPT(std::wstring) strModifiers;
odf_reader::GetProperty(prop, L"bModifiers", bModifiers);
odf_reader::GetProperty(prop, L"oox-draw-modifiers", strModifiers);
if (strModifiers)
{
std::vector< std::wstring > values;
@ -227,17 +226,61 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
if (!values.empty() && values.back().empty()) values.pop_back();
std::vector<std::wstring> names;
if (std::wstring::npos != shapeGeomPreset.find(L"math") ||
std::wstring::npos != shapeGeomPreset.find(L"bentConnector") ||
std::wstring::npos != shapeGeomPreset.find(L"curvedConnector")||
std::wstring::npos != shapeGeomPreset.find(L"frame"))
{
names.push_back(L"adj1");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
{
names.push_back(L"hf");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"hexagon"))
{
names.push_back(L"adj");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"star5")||
std::wstring::npos != shapeGeomPreset.find(L"star7"))
{
names.push_back(L"adj");
names.push_back(L"hf");
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"star6") ||
std::wstring::npos != shapeGeomPreset.find(L"star10"))
{
names.push_back(L"adj");
names.push_back(L"hf");
}
for (size_t i = 0; i < values.size(); i++)
{
if (values[i].empty()) continue;
CP_XML_NODE(L"a:gd")
{
//if (values.size() > 1 || bModifiers)
//весьма странное .. для некоторых модификаторов (напр math...) нужно указывать множественность их
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i+1));
//else
// CP_XML_ATTR(L"name", L"adj");
if (names.size() > i)
{
CP_XML_ATTR(L"name", names[i]);
}
else
{
if (values.size() > 1)
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i + 1));
else
CP_XML_ATTR(L"name", L"adj");
}
CP_XML_ATTR(L"fmla", L"val " + values[i]);
}
}
@ -321,7 +364,8 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
CP_XML_NODE(L"a:prstTxWarp")
{
CP_XML_ATTR(L"prst", shapeType);
oox_serialize_aLst(CP_XML_STREAM(), prop);
oox_serialize_aLst(CP_XML_STREAM(), prop, shapeType);
}
}
}
@ -370,7 +414,8 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
{
CP_XML_NODE(L"a:custGeom")
{
oox_serialize_aLst(CP_XML_STREAM(), additional);
std::vector<std::wstring> names;
oox_serialize_aLst(CP_XML_STREAM(), additional, L"");
CP_XML_NODE(L"a:ahLst");
CP_XML_NODE(L"a:gdLst");
@ -391,8 +436,14 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
int path_w = w ? *w : cx;
int path_h = h ? *h : cy;
if (path_w < 1) path_w = 1024;
if (path_h < 1) path_h = 1024;
CP_XML_ATTR(L"w", path_w);
CP_XML_ATTR(L"h", path_h);
if (sCustomPath)
{
@ -414,11 +465,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
CP_XML_ATTR(L"prst", shapeGeomPreset);
if (!bWordArt)
{
if (std::wstring::npos != shapeGeomPreset.find(L"mathPlus"))
{
additional.push_back(odf_reader::_property(L"bModifiers", true));
}
oox_serialize_aLst(CP_XML_STREAM(), additional);
oox_serialize_aLst(CP_XML_STREAM(), additional, shapeGeomPreset);
}
}
}
@ -508,10 +555,13 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
CP_XML_ATTR(L"x", 0);
CP_XML_ATTR(L"y", 0);
}
CP_XML_NODE(L"a:chExt")
if (cx > 0 || cy > 0)
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
CP_XML_NODE(L"a:chExt")
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
}
}
}
@ -525,9 +575,6 @@ void oox_serialize_action(std::wostream & strm, _action_desc const & val)
{
CP_XML_NODE(L"a:hlinkClick")
{
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
if (!val.action.empty())
CP_XML_ATTR(L"action", val.action);
@ -544,6 +591,8 @@ void oox_serialize_action(std::wostream & strm, _action_desc const & val)
CP_XML_ATTR(L"name", L"sound");
}
}
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
}
}
}

View File

@ -83,7 +83,7 @@ namespace oox {
class _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object")
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object"), extExternal(false)
{
}
RelsType type;
@ -103,6 +103,7 @@ namespace oox {
std::wstring objectProgId;
std::wstring extId;
bool extExternal;
_action_desc action;
std::vector<_hlink_desc> hlinks;
@ -118,7 +119,7 @@ namespace oox {
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset);
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
}

View File

@ -37,7 +37,7 @@
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false),bTile(false),isInternal(true)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
{
memset(cropRect,0,sizeof(double)*4);
}
@ -168,7 +168,7 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
if (val.bitmap->isInternal)
{
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:embed", val.bitmap->rId );
}
else
@ -186,10 +186,10 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
{
CP_XML_NODE(L"a:srcRect")
{
CP_XML_ATTR(L"l", static_cast<size_t>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<size_t>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<size_t>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<size_t>(val.bitmap->cropRect[3]*1000));
CP_XML_ATTR(L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)

View File

@ -147,6 +147,6 @@ namespace oox {
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val);
}
}

View File

@ -70,13 +70,14 @@ static std::wstring get_mime_type(const std::wstring & extension)
else if (L"tif" == extension) return L"image/x-tiff";
else if (L"tiff" == extension) return L"image/x-tiff";
else if (L"pdf" == extension) return L"application/pdf";
else if (L"bmp" == extension) return L"image/bmp";
else if (L"wav" == extension) return L"audio/wav";
else if (L"mp3" == extension) return L"audio/mpeg";
else if (L"wma" == extension) return L"audio/x-ms-wma";
else if (L"m4a" == extension) return L"audio/unknown";
else if (L"avi" == extension) return L"video/avi";
else if (L"avi" == extension) return L"video/x-msvideo";
else if (L"wmv" == extension) return L"video/x-ms-wmv";
else if (L"mov" == extension) return L"video/unknown";
else if (L"mp4" == extension) return L"video/unknown";

View File

@ -102,6 +102,10 @@ void oox_chart::oox_serialize_common(std::wostream & _Wostream)
}
for (size_t i = 0; i < series_.size(); i++)
{
if (is3D_ || type_ == CHART_TYPE_AREA || type_ == CHART_TYPE_DOUGHNUT || type_ == CHART_TYPE_RADAR)
{
series_[i]->labelPosEnabled_ = false;
}
series_[i]->oox_serialize(_Wostream);
}
for (size_t i = 0; i < axisId_.size(); i++)
@ -469,7 +473,7 @@ void oox_stock_chart::oox_serialize(std::wostream & _Wostream)
//{
// //shape.oox_serialize(CP_XML_STREAM());
//}
CP_XML_NODE(L"upDownBars")
CP_XML_NODE(L"c:upDownBars")
{
CP_XML_NODE(L"c:gapWidth")
{

View File

@ -150,15 +150,30 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p14:media")
{
CP_XML_ATTR(L"xmlns:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"r:embed", val.extId);
if (val.extExternal)
{
CP_XML_ATTR(L"r:link", val.extId);
}
else
{
CP_XML_ATTR(L"r:embed", val.extId);
}
}
}
}
}
}
if (val.fill.bitmap)
{
val.fill.bitmap->name_space = L"p";
oox_serialize_fill(CP_XML_STREAM(), val.fill);
oox_serialize_bitmap_fill(strm, val.fill);
val.fill.bitmap.reset();
}
else
{
CP_XML_NODE(L"p:blipFill");
}
CP_XML_NODE(L"p:spPr")
{
@ -169,7 +184,8 @@ void pptx_serialize_media(std::wostream & strm, _pptx_drawing & val)
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(), val.additional);
oox_serialize_fill (CP_XML_STREAM(), val.fill);
oox_serialize_ln (CP_XML_STREAM(), val.additional);
}
//_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent);

View File

@ -472,6 +472,13 @@ void pptx_slide_context::set_media_param(std::wstring name, std::wstring value)
void pptx_slide_context::set_image(const std::wstring & path)
{
int pos_replaicement = path.find(L"ObjectReplacements");
if (pos_replaicement >= 0)
{
if (path.length() - (pos_replaicement + 18) < 2)
return; //object without image
}
if (impl_->object_description_.type_ == typeUnknown)
{
impl_->object_description_.type_ = typeImage;
@ -547,8 +554,9 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
drawing.fill.bitmap->isInternal = isMediaInternal;
if (drawing.type == typeShape)
{
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
@ -640,11 +648,12 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
drawing.extId = L"ext" + drawing.objectId;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
drawing.extId = L"ext" + drawing.objectId;
drawing.extExternal = !isMediaInternal;
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
add_additional_rels( true, drawing.extId, ref, typeMedia);
add_additional_rels( isMediaInternal, drawing.extId, ref, typeMedia);
if (drawing.fill.bitmap)
{
@ -744,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());

View File

@ -332,21 +332,34 @@ void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::styl
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_)
{
CP_XML_ATTR(L"marT", *style_cell_attlist.common_padding_attlist_.fo_padding_);
CP_XML_ATTR(L"marB", *style_cell_attlist.common_padding_attlist_.fo_padding_);
CP_XML_ATTR(L"marL", *style_cell_attlist.common_padding_attlist_.fo_padding_);
CP_XML_ATTR(L"marR", *style_cell_attlist.common_padding_attlist_.fo_padding_);
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marT", (long)padding);
CP_XML_ATTR(L"marB", (long)padding);
CP_XML_ATTR(L"marL", (long)padding);
CP_XML_ATTR(L"marR", (long)padding);
}
else
{
if (style_cell_attlist.common_padding_attlist_.fo_padding_top_)
CP_XML_ATTR(L"marT", *style_cell_attlist.common_padding_attlist_.fo_padding_top_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_top_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marT", (long)padding);
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_bottom_)
CP_XML_ATTR(L"marB", *style_cell_attlist.common_padding_attlist_.fo_padding_bottom_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_bottom_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marB", (long)padding);
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_left_)
CP_XML_ATTR(L"marL", *style_cell_attlist.common_padding_attlist_.fo_padding_left_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_left_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marL", (long)padding);
}
if (style_cell_attlist.common_padding_attlist_.fo_padding_right_)
CP_XML_ATTR(L"marR", *style_cell_attlist.common_padding_attlist_.fo_padding_right_);
{
double padding = style_cell_attlist.common_padding_attlist_.fo_padding_right_->get_value_unit(odf_types::length::emu);
CP_XML_ATTR(L"marR", (long)padding);
}
}
//vert //
//style_cell_attlist.pptx_serialize(Context, CP_XML_STREAM()); //nodes

View File

@ -55,8 +55,8 @@ public:
void add_format(std::wstring const & condition, std::wstring const & format)
{
std::wstring c = condition;
XmlUtils::GetLower(c);
std::wstring c = XmlUtils::GetLower(condition);
XmlUtils::replace_all( c, L" ", L"");
XmlUtils::replace_all( c, L"\t", L"");

View File

@ -281,6 +281,11 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(val);
}
else if (0 <= (pos = f.find(L"is-error")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsErrors";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else if (0 <= (pos = f.find(L"duplicate")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";

View File

@ -299,6 +299,13 @@ void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::w
}
void xlsx_drawing_context::set_image(const std::wstring & path)
{
int pos_replaicement = path.find(L"ObjectReplacements");
if (pos_replaicement >= 0)
{
if (path.length() - (pos_replaicement + 18) < 2)
return; //object without image
}
if (impl_->object_description_.type_ == typeUnknown)
{
impl_->object_description_.type_ = typeImage;

View File

@ -38,6 +38,8 @@
#include <cpdoccore/xml/simple_xml_writer.h>
#include"../../Common/DocxFormat/Source/XML/Utils.h"
#include"../../Common/DocxFormat/Source/Base/Types_32.h"
#include <map>
namespace cpdoccore {
@ -68,9 +70,22 @@ public:
std::wstring sVal;
std::wstring sNode;
};
struct _reference
{
std::wstring name;
int type = -1;
std::wstring member_name;
int member_type = -1;
};
struct _group
{
std::wstring name;
std::vector<_field_value> caches;
};
struct _field
{
std::wstring name;
std::wstring display_name;
int type = -1;
int hierarchy = -1;
int function = -1;
@ -78,12 +93,20 @@ public:
bool data_layout = false;
bool show_empty = false;
bool repeat_item_labels = true;
int type_groups = 0;
int sort = 0;
std::vector<int> subtotals;
std::vector<_field_value> caches;
std::vector<_reference> references;
int references_field = -1;
bool used_in_referenes = false;
int type_groups = 0;
int base_group = -1;
std::wstring source_groups;
std::vector<_group> groups;
std::vector<int> groups_discrete;
bool bDataFieldEnabled = false;
bool bString = false;
@ -139,13 +162,19 @@ public:
bool identify_categories = false;
bool drill_enabled = true;
bool ignore_empty_rows = false;
bool data_on_row = false;
bool in_group = false;
}current_;
void sort_fields();
void serialize_view(std::wostream & strm);
void serialize_cache(std::wostream & strm);
void serialize_type_field(CP_ATTR_NODE, _field & field);
private:
bool clear_header_map(std::map<size_t, size_t> & map)
{//отсев по секонд - нужны тока повторы
@ -243,12 +272,172 @@ private:
}
connections_ += strm.str();
}
};
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
{
}
void xlsx_pivots_context::Impl::sort_fields()
{
size_t count_skip = 0;
for (size_t i = 0; i < current_.fields.size() - count_skip; i++)
{
if (!current_.fields[i].source_groups.empty() && i != current_.fields.size() - count_skip)
{
current_.fields.push_back(current_.fields[i]);
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
i--;
count_skip++;
}
}
count_skip = 0;
for (size_t i = 0; i < current_.fields.size() - count_skip; i++)
{
if (current_.fields[i].name.empty() && i != current_.fields.size() - count_skip)
{
current_.fields.push_back(current_.fields[i]);
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
i--;
count_skip++;
}
}
bool bEmptyRowCache = false, bAddRepeateCol = false;
bool bEmptyColCache = false, bAddRepeateRow = false;
int index_current = 0;
for (size_t i = 0; i < current_.fields.size(); i++, index_current++)
{
if ( current_.fields[i].type_groups > 0 )
{
current_.fields[i].base_group = 0;
int index_group = 0;
for (size_t k = 0; k < current_.fields.size(); k++)
{
if (current_.fields[k].type == 7) continue;
if (current_.fields[k].name == current_.fields[i].source_groups && !current_.fields[i].source_groups.empty())
{
if (current_.fields[k].type_groups == 0)
current_.fields[k].base_group = index_current; //опорный (если он и базовый - не писать)
current_.fields[i].base_group = index_group;
for (size_t c = 0; !current_.fields[i].groups.empty() && c < current_.fields[k].caches.size(); c++)
{
for (size_t g = 0; g < current_.fields[i].groups.size(); g++)
{
for (size_t h = 0; h < current_.fields[i].groups[g].caches.size(); h++)
{
if (current_.fields[i].groups[g].caches[h].sVal == current_.fields[k].caches[c].sVal)
current_.fields[i].groups_discrete.push_back(g);
}
}
}
break;
}
index_group++;
}
}
if ( current_.fields[i].name.empty() &&
!current_.fields[i].data_layout)
continue;
switch(current_.fields[i].type)
{
case 0: // column
{
if (!current_.fields[i].name.empty())
current_.col_fields.push_back(i);
if (current_.fields[i].data_layout)
{
if ((current_.fields[i].name.empty() && (!current_.identify_categories || current_.fields[i].hierarchy >= 0)) ||
current_.fields[i].used_in_referenes )
{
if ((current_.col_fields.empty()) || (current_.col_fields.back() != -2))
{
bAddRepeateCol = true;
}
}
}
if (current_.fields[i].caches.empty())
bEmptyColCache = true;
}break;
case 1: // data
{
int index_field = -1;
for (size_t j = 0; j < i/*current_.fields.size()*/; j++)
{
if ( current_.fields[j].name == current_.fields[i].name )
{
current_.fields[j].bDataFieldEnabled = true;
index_field = j;
break;
}
}
if (index_field >= 0)
{
if (current_.fields[i].caches.empty())
{
current_.fields[i].type = 7; //skip
current_.fields_count--;
index_current--;
}
current_.fields[i].references_field = index_field;
}
index_field = i;
current_.fields[i].bDataFieldEnabled = true;
current_.data_fields.push_back(index_field);
}break;
case 2: // hidden
{
}break;
case 3: // page
{
current_.page_fields.push_back(i);
}break;
case 4: // row
{
if (!current_.fields[i].name.empty())
current_.row_fields.push_back(i);
if (current_.fields[i].data_layout)
{
current_.data_on_row = true;
if ((current_.fields[i].name.empty() && (!current_.identify_categories || current_.fields[i].hierarchy >= 0)) ||
current_.fields[i].used_in_referenes )
{
bAddRepeateRow = true;
}
}
if (current_.fields[i].caches.empty())
bEmptyRowCache = true;
}break;
}
if (current_.fields[i].name.empty())
{
current_.fields.erase(current_.fields.begin() + i, current_.fields.begin() + i + 1);
current_.fields_count--;
i--;
}
}
if (bAddRepeateCol || bEmptyColCache)
current_.col_fields.push_back(-2);
if (bAddRepeateRow)
current_.row_fields.push_back(-2);
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{
if (current_.headers.empty()) return;
@ -403,6 +592,7 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
CP_XML_ATTR(L"colPageCount", 1);
}
}
std::map<std::wstring, bool> used_field_name;
CP_XML_NODE(L"pivotFields")
{
CP_XML_ATTR(L"count", current_.fields_count);
@ -411,6 +601,11 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
if (current_.fields[i].type == 7)
continue;
if (used_field_name.end() != used_field_name.find(current_.fields[i].name))
continue;
used_field_name.insert(std::make_pair(current_.fields[i].name, true));
CP_XML_NODE(L"pivotField")
{
switch(current_.fields[i].type)
@ -440,22 +635,38 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
}
CP_XML_ATTR(L"defaultSubtotal", 0);
if (!current_.fields[i].caches.empty() && current_.fields[i].type != 2)
if (current_.fields[i].type != 2)
{
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
if (!current_.fields[i].groups.empty())
{
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].groups.size());
for (size_t j = 0; j < current_.fields[i].groups.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
}
}
}
}
else if (!current_.fields[i].caches.empty())
{
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
}
}
}
}
}
}
//CP_XML_STREAM() << fields_[i].view_;
}
}
if (!current_.row_fields.empty())
@ -509,35 +720,85 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
CP_XML_ATTR(L"count", current_.data_fields.size());
for (size_t i = 0; i < current_.data_fields.size(); i++)
{
CP_XML_NODE(L"dataField")
{
CP_XML_ATTR(L"fld", current_.data_fields[i]);
CP_XML_ATTR(L"baseField", current_.data_fields[i]);
//CP_XML_ATTR(L"baseItem", -1);
//CP_XML_ATTR(L"name", L"");
int ind_field_dirty = current_.data_fields[i];
int ind_field = current_.data_fields[i];
if (ind_field >= 0 && ind_field < current_.fields.size())
CP_XML_NODE(L"dataField")
{
int fld = 0, ind_fld = current_.fields[ind_field_dirty].references_field < 0 ? ind_field_dirty :
current_.fields[ind_field_dirty].references_field;
for (size_t k = 0; k < ind_fld; k++)
{
switch(current_.fields[ind_field].function)
if (current_.fields[k].type != 7 ) fld++;
}
CP_XML_ATTR(L"fld", fld);
if (current_.fields[ind_field_dirty].references.empty())
{
CP_XML_ATTR(L"baseField", fld);
}
else
{
size_t base_field = 0, base_item = 0;
for (size_t k = 0; k < current_.fields.size(); k++)
{
case 1: CP_XML_ATTR(L"subtotal", L"average"); break;
case 2: CP_XML_ATTR(L"subtotal", L"count"); break;
case 3: CP_XML_ATTR(L"subtotal", L"countNums"); break;
case 4: CP_XML_ATTR(L"subtotal", L"max"); break;
case 5: CP_XML_ATTR(L"subtotal", L"min"); break;
case 6: CP_XML_ATTR(L"subtotal", L"product"); break;
case 7: CP_XML_ATTR(L"subtotal", L"stdDev"); break;
case 8: CP_XML_ATTR(L"subtotal", L"stdDevp"); break;
case 9: CP_XML_ATTR(L"subtotal", L"sum"); break;
case 10: CP_XML_ATTR(L"subtotal", L"var"); break;
case 11: CP_XML_ATTR(L"subtotal", L"varp"); break;
if (current_.fields[k].type == 7 ) continue;
if (current_.fields[k].name == current_.fields[ind_field_dirty].references[0].name)
{
for (size_t j = 0; j < current_.fields[k].caches.size(); j++)
{
if (current_.fields[k].caches[j].sVal == current_.fields[ind_field_dirty].references[0].member_name)
{
base_item = j;
break;
}
}
break;
}
base_field++;
}
CP_XML_ATTR(L"baseField", base_field);
CP_XML_ATTR(L"baseItem", base_item);
switch(current_.fields[ind_field_dirty].references[0].type)
{
case 1: CP_XML_ATTR(L"showDataAs", L"difference"); break;
case 2: CP_XML_ATTR(L"showDataAs", L"percent"); break;
case 3: CP_XML_ATTR(L"showDataAs", L"percentDiff"); break;
}
}
std::wstring name;
if (ind_field_dirty >= 0 && ind_field_dirty < current_.fields.size())
{
switch(current_.fields[ind_field_dirty].function)
{
case 1: CP_XML_ATTR(L"subtotal", L"average"); name = L"average "; break;
case 2: CP_XML_ATTR(L"subtotal", L"count"); name = L"count "; break;
case 3: CP_XML_ATTR(L"subtotal", L"countNums"); name = L"countNums "; break;
case 4: CP_XML_ATTR(L"subtotal", L"max"); name = L"max "; break;
case 5: CP_XML_ATTR(L"subtotal", L"min"); name = L"min "; break;
case 6: CP_XML_ATTR(L"subtotal", L"product"); name = L"product "; break;
case 7: CP_XML_ATTR(L"subtotal", L"stdDev"); name = L"stdDev Dev "; break;
case 8: CP_XML_ATTR(L"subtotal", L"stdDevp"); name = L"stdDevp "; break;
case 9: CP_XML_ATTR(L"subtotal", L"sum"); name = L"sum by "; break;
case 10: CP_XML_ATTR(L"subtotal", L"var"); name = L"var "; break;
case 11: CP_XML_ATTR(L"subtotal", L"varp"); name = L"varp "; break;
case 12:
{
CP_XML_ATTR(L"subtotal", current_.fields[current_.data_fields[i]].user_function);
}break;
default: break;
}
if (current_.fields[ind_field_dirty].display_name.empty())
{
name += current_.fields[ind_field_dirty].name;
}
else
{
name = current_.fields[ind_field_dirty].display_name;
}
CP_XML_ATTR(L"name", name);
}
}
}
@ -554,9 +815,90 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
}
}
}
void xlsx_pivots_context::Impl::serialize_type_field(CP_ATTR_NODE, _field & field)
{
_CP_OPT(bool) containsSemiMixedTypes;
_CP_OPT(bool) containsMixedTypes;
_CP_OPT(bool) containsNonDate;
_CP_OPT(bool) containsDate;
_CP_OPT(bool) containsString;
_CP_OPT(bool) containsBlank;
_CP_OPT(bool) containsNumber;
_CP_OPT(bool) containsInteger;
if (field.bDate & field.bNumber/* ||
field.bNumber & field.bString*/)
{
containsSemiMixedTypes = true;
}
else if (field.bDate & field.bString ||
field.bNumber & field.bString ||
field.bInteger & field.bString)
{
containsMixedTypes = true;
if (field.bInteger)
{
if (field.bNumber) field.bInteger = false;
field.bNumber = true;
}
}
else if (!field.bEmpty && !field.bString && !field.bBool)
{
containsSemiMixedTypes = false;
}
if (field.bDate &&
!(field.bNumber || field.bInteger || field.bString || field.bEmpty ))
{
containsNonDate = false;
}
if (field.bDate)
{
containsDate = true;
}
if (!field.bString &&
(field.bInteger || field.bDate || field.bNumber || field.bEmpty))
{
containsString = false;
if (field.bInteger)
{
if (field.bNumber) field.bInteger = false;
field.bNumber = true;
}
if (/*!field.bDate && */field.bEmpty)
containsNonDate = false;
}
if (field.bEmpty)
{
containsBlank = true;
}
if (field.bNumber)
{
containsNumber = true;
}
if (field.bInteger && !field.bDate)
{
if (containsMixedTypes)
{
containsNumber = true;
containsInteger = true;
}
else
containsInteger = true;
}
if (containsNonDate) CP_XML_ATTR(L"containsNonDate", *containsNonDate);
if (containsSemiMixedTypes) CP_XML_ATTR(L"containsSemiMixedTypes", *containsSemiMixedTypes);
if (containsString) CP_XML_ATTR(L"containsString", *containsString);
if (containsBlank) CP_XML_ATTR(L"containsBlank", *containsBlank);
if (containsMixedTypes) CP_XML_ATTR(L"containsMixedTypes", *containsMixedTypes);
if (containsDate) CP_XML_ATTR(L"containsDate", *containsDate);
if (containsNumber) CP_XML_ATTR(L"containsNumber", *containsNumber);
if (containsInteger) CP_XML_ATTR(L"containsInteger", *containsInteger);
}
void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
{
std::map<std::wstring, bool> used_field_name;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheDefinition")
@ -599,6 +941,7 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
}
}
}
int index_current = 0;
if (current_.fields.empty() == false)
{
@ -611,67 +954,38 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
if (current_.fields[i].type == 7)
continue;
if (used_field_name.end() != used_field_name.find(current_.fields[i].name))
continue;
used_field_name.insert(std::make_pair(current_.fields[i].name, true));
CP_XML_NODE(L"cacheField")
{
CP_XML_ATTR(L"name", current_.fields[i].name);
CP_XML_ATTR(L"numFmtId", 0);
if (!current_.fields[i].source_groups.empty())
{
CP_XML_ATTR(L"databaseField", 0);
}
CP_XML_NODE(L"sharedItems")
{
if (current_.fields[i].caches.empty() == false/* &&
current_.fields[i].type != 2*/)
{
{
if (current_.fields[i].type_groups == 0)
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
}
else
{
else if (current_.fields[i].type_groups < 8)
{//group by date
current_.fields[i].bDate = true;
current_.fields[i].bString = false;
}
if ((current_.fields[i].bDate & current_.fields[i].bNumber) ||
(current_.fields[i].bNumber & current_.fields[i].bString))
{
CP_XML_ATTR(L"containsSemiMixedTypes", 1);
}
else if (current_.fields[i].bDate & current_.fields[i].bString)
{
CP_XML_ATTR(L"containsMixedTypes", 1);
}
else if (!current_.fields[i].bEmpty && !current_.fields[i].bString && !current_.fields[i].bBool)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 0);
}
if (current_.fields[i].bDate &&
!(current_.fields[i].bNumber || current_.fields[i].bInteger || current_.fields[i].bString || current_.fields[i].bEmpty ))
{
CP_XML_ATTR(L"containsNonDate", 0);
}
if (current_.fields[i].bDate) CP_XML_ATTR(L"containsDate", 1);
if (!current_.fields[i].bString &&
(current_.fields[i].bInteger || current_.fields[i].bDate || current_.fields[i].bNumber || current_.fields[i].bEmpty))
{
CP_XML_ATTR(L"containsString", 0);
}
if (current_.fields[i].bEmpty) CP_XML_ATTR(L"containsBlank", 1);
if (current_.fields[i].bNumber) CP_XML_ATTR(L"containsNumber", 1);
if (current_.fields[i].bInteger && !current_.fields[i].bDate)
{
if (current_.fields[i].bString)
{
CP_XML_ATTR(L"containsInteger", 1);
}
else if (!current_.fields[i].bNumber)
{
CP_XML_ATTR(L"containsNumber", 1);
CP_XML_ATTR(L"containsInteger", 1);
}
}
//else group by fields
serialize_type_field(CP_GET_XML_NODE(), current_.fields[i]);
if ( current_.fields[i].type_groups == 0 )
{
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
@ -687,37 +1001,78 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
}
}
}
if ( current_.fields[i].type_groups != 0 )
if (current_.fields[i].base_group >= 0)
{
CP_XML_NODE(L"fieldGroup")
{
CP_XML_ATTR(L"base", i);
CP_XML_NODE(L"rangePr")
{
if ( current_.fields[i].type_groups > 0)
{
switch(current_.fields[i].type_groups)
{
case 1: CP_XML_ATTR(L"groupBy", L"seconds"); break;
case 2: CP_XML_ATTR(L"groupBy", L"minutes"); break;
case 3: CP_XML_ATTR(L"groupBy", L"hours"); break;
case 4: CP_XML_ATTR(L"groupBy", L"days"); break;
case 5: CP_XML_ATTR(L"groupBy", L"months"); break;
case 6: CP_XML_ATTR(L"groupBy", L"quarters"); break;
case 7: CP_XML_ATTR(L"groupBy", L"years"); break;
}
CP_XML_ATTR(L"startDate", L"1899-12-31T00:00:00");
CP_XML_ATTR(L"endDate", L"1899-12-31T00:00:00");
CP_XML_ATTR(L"base", current_.fields[i].base_group);
}
CP_XML_NODE(L"groupItems")
else
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
CP_XML_ATTR(L"par", current_.fields[i].base_group);
}
if (current_.fields[i].type_groups > 0)
{
if (current_.fields[i].type_groups < 8)
{
CP_XML_NODE(current_.fields[i].caches[j].sNode)
CP_XML_NODE(L"rangePr")
{
if (current_.fields[i].caches[j].sVal.empty() == false)
switch(current_.fields[i].type_groups)
{
CP_XML_ATTR(L"v", current_.fields[i].caches[j].sVal);
case 1: CP_XML_ATTR(L"groupBy", L"seconds"); break;
case 2: CP_XML_ATTR(L"groupBy", L"minutes"); break;
case 3: CP_XML_ATTR(L"groupBy", L"hours"); break;
case 4: CP_XML_ATTR(L"groupBy", L"days"); break;
case 5: CP_XML_ATTR(L"groupBy", L"months"); break;
case 6: CP_XML_ATTR(L"groupBy", L"quarters"); break;
case 7: CP_XML_ATTR(L"groupBy", L"years"); break;
}
CP_XML_ATTR(L"startDate", L"1899-12-31T00:00:00");
CP_XML_ATTR(L"endDate", L"1899-12-31T00:00:00");
}
}
if (!current_.fields[i].groups_discrete.empty())
{
CP_XML_NODE(L"discretePr")
{
CP_XML_ATTR(L"count", current_.fields[i].groups_discrete.size());
for (size_t j = 0; j < current_.fields[i].groups_discrete.size(); j++)
{
CP_XML_NODE(L"x")
{
CP_XML_ATTR(L"v", current_.fields[i].groups_discrete[j]);
}
}
}
}
CP_XML_NODE(L"groupItems")
{
if (!current_.fields[i].groups.empty())
{
CP_XML_ATTR(L"count", current_.fields[i].groups.size());
for (size_t j = 0; j < current_.fields[i].groups.size(); j++)
{
CP_XML_NODE(L"s")
{
CP_XML_ATTR(L"v", current_.fields[i].groups[j].name);
}
}
}
else
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(current_.fields[i].caches[j].sNode)
{
if (current_.fields[i].caches[j].sVal.empty() == false)
{
CP_XML_ATTR(L"v", current_.fields[i].caches[j].sVal);
}
}
}
}
}
@ -725,6 +1080,8 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
}
}
}
index_current++;
}
}
}
@ -823,6 +1180,8 @@ int xlsx_pivots_context::end_table()
std::wstringstream view_strm;
std::wstringstream cache_strm;
std::wstringstream rec_strm;
impl_->sort_fields();
impl_->serialize_view(view_strm);
impl_->serialize_cache(cache_strm);
@ -859,6 +1218,10 @@ void xlsx_pivots_context::set_identify_categories(bool val)
{
impl_->current_.identify_categories = val;
}
void xlsx_pivots_context::set_ignore_empty_rows(bool val)
{
impl_->current_.ignore_empty_rows = val;
}
void xlsx_pivots_context::set_drill(bool val)
{
impl_->current_.drill_enabled = val;
@ -874,75 +1237,86 @@ void xlsx_pivots_context::set_field_name(std::wstring name)
{
impl_->current_.fields.back().name = name;
}
void xlsx_pivots_context::set_field_display(std::wstring name)
{
impl_->current_.fields.back().display_name = name;
}
void xlsx_pivots_context::set_field_type(int type, int hierarchy)
{
impl_->current_.fields.back().type = type;
impl_->current_.fields.back().hierarchy = hierarchy;
if ( impl_->current_.fields.back().name.empty() &&
!impl_->current_.fields.back().data_layout)
return;
//if ( impl_->current_.fields.back().name.empty() &&
// !impl_->current_.fields.back().data_layout)
// return;
switch(type)
{
case 0: // column
{
if (impl_->current_.fields.back().data_layout)
{
if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
//impl_->current_.fields.back().repeat_item_labels )) //????
impl_->current_.col_fields.push_back(-2);
}
else
impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1);
}break;
case 1: // data
{
int index_field = -1;
for (size_t i = 0; i < impl_->current_.fields.size(); i++)
{
if (impl_->current_.fields[i].name == impl_->current_.fields.back().name &&
impl_->current_.fields[i].type != 1)
{
impl_->current_.fields[i].bDataFieldEnabled = true;
index_field = i;
break;
}
}
if (index_field >= 0)
{
impl_->current_.fields.back().type = 7;
impl_->current_.fields_count--;
impl_->current_.data_fields.push_back(index_field);
}
else
{
index_field = impl_->current_.fields.size() - 1;
impl_->current_.fields.back().bDataFieldEnabled = true;
impl_->current_.data_fields.push_back(index_field);
}
}break;
case 2: // hidden
break;
case 3: // page
impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1);
break;
case 4: // row
if (impl_->current_.fields.back().data_layout)
{
impl_->current_.data_on_row = true;
//switch(type)
//{
// case 0: // column
// {
// if (impl_->current_.fields.back().data_layout)
// {
// if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
// //impl_->current_.fields.back().repeat_item_labels )) //????
// impl_->current_.col_fields.push_back(-2);
// }
// else
// impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1);
// }break;
// case 1: // data
// {
// int index_field = -1;
//
// for (size_t i = 0; i < impl_->current_.fields.size() - 1; i++)
// {
// if (impl_->current_.fields[i].name == impl_->current_.fields.back().name &&
// (impl_->current_.fields[i].type != 1 || !impl_->current_.fields.back().references.empty()))
// {
// impl_->current_.fields[i].bDataFieldEnabled = true;
// index_field = i;
// break;
// }
// }
// if (index_field >= 0)
// {
// impl_->current_.fields.back().type = 7; //skip
// impl_->current_.fields_count--;
//
// if (!impl_->current_.fields.back().references.empty())
// {
// impl_->current_.fields.back().references_field = index_field;
// impl_->current_.fields.back().bDataFieldEnabled = true;
//
// index_field = impl_->current_.fields.size() - 1;
// }
// }
// else
// {
// index_field = impl_->current_.fields.size() - 1;
// impl_->current_.fields.back().bDataFieldEnabled = true;
// }
// impl_->current_.data_fields.push_back(index_field);
// }break;
// case 2: // hidden
// break;
// case 3: // page
// impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1);
// break;
// case 4: // row
// if (impl_->current_.fields.back().data_layout)
// {
// impl_->current_.data_on_row = true;
if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
//(impl_->current_.fields.back().repeat_item_labels ||
// !impl_->current_.identify_categories ))
impl_->current_.row_fields.push_back(-2);
// if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
// //(impl_->current_.fields.back().repeat_item_labels ||
// // !impl_->current_.identify_categories ))
// impl_->current_.row_fields.push_back(-2);
}
else
impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1);
break;
}
// }
// else
// impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1);
// break;
//}
}
void xlsx_pivots_context::set_field_function(int type)
{
@ -973,10 +1347,60 @@ void xlsx_pivots_context::set_field_groups(int type)
{
impl_->current_.fields.back().type_groups = type + 1;
}
void xlsx_pivots_context::set_field_groups_source(std::wstring name)
{
impl_->current_.fields.back().source_groups = name;
}
void xlsx_pivots_context::start_field_group()
{
impl_->current_.in_group = true;
Impl::_group group;
impl_->current_.fields.back().groups.push_back(group);
}
void xlsx_pivots_context::set_field_group_name (std::wstring name)
{
impl_->current_.fields.back().groups.back().name = name;
}
void xlsx_pivots_context::end_field_group()
{
impl_->current_.in_group = false;
}
void xlsx_pivots_context::set_field_sort(int type)
{
impl_->current_.fields.back().sort = type + 1;
}
void xlsx_pivots_context::start_field_reference()
{
Impl::_reference ref;
impl_->current_.fields.back().references.push_back(ref);
}
void xlsx_pivots_context::end_field_reference()
{
}
void xlsx_pivots_context::set_field_ref_name(std::wstring name)
{
impl_->current_.fields.back().references.back().name = name;
for (size_t i = 0; i < impl_->current_.fields.size(); i++)
{
if (impl_->current_.fields[i].name == name)
{
impl_->current_.fields[i].used_in_referenes = true;
}
}
}
void xlsx_pivots_context::set_field_ref_type (int type)
{
impl_->current_.fields.back().references.back().type = type;
}
void xlsx_pivots_context::set_field_ref_member_name(std::wstring name)
{
impl_->current_.fields.back().references.back().member_name = name;
}
void xlsx_pivots_context::set_field_ref_member_type(int type)
{
impl_->current_.fields.back().references.back().member_type = type;
}
void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
{
if (index < 0)
@ -1002,15 +1426,16 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
_CP_OPT(double) dVal;
if (pos >= 0)//финановый .. todooo общее правило бы...
{
value = value.substr(pos + 1);
XmlUtils::replace_all(value, L",", L"");
XmlUtils::replace_all(value, L" ", L"");
XmlUtils::replace_all(value, L"\x00A0", L"");
//value = value.substr(pos + 1);
//XmlUtils::replace_all(value, L",", L"");
//XmlUtils::replace_all(value, L" ", L"");
//XmlUtils::replace_all(value, L"\x00A0", L"");
}
if (oox::IsNumber(value))
{
try
{
XmlUtils::replace_all(value, L",", L".");
dVal = boost::lexical_cast<double>(value);
}
catch(...)
@ -1021,7 +1446,7 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
{
node_name = L"n";
int iVal = *dVal;
_INT64 iVal = *dVal;
if (abs(iVal - *dVal) > 0.00001)
{
value = std::to_wstring(*dVal);
@ -1045,14 +1470,20 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
}
}
impl_->current_.fields.back().caches.push_back(Impl::_field_value(value, node_name));
if (impl_->current_.in_group)
{
impl_->current_.fields.back().groups.back().caches.push_back(impl_->current_.fields.back().caches.back());
}
}
void xlsx_pivots_context::end_field()
{
if (impl_->current_.fields.back().name.empty())
{
impl_->current_.fields_count--;
impl_->current_.fields.pop_back();
}
//if (impl_->current_.fields.back().name.empty())
//{
// impl_->current_.fields_count--;
// impl_->current_.fields.pop_back();
//}
}
void xlsx_pivots_context::set_source_range(std::wstring table_name, std::wstring ref)
{

View File

@ -51,6 +51,7 @@ public:
void start_field ();
void set_field_name (std::wstring name);
void set_field_display (std::wstring name);
void set_field_type (int type, int hierarchy);
void set_field_function (int type);
void set_field_user_function (std::wstring f);
@ -59,8 +60,22 @@ public:
void set_field_show_empty (bool val);
void set_field_data_layout (bool val);
void set_field_sort (int type);
void set_field_groups (int type);
void set_repeat_item_labels(bool val);
void set_field_groups (int type);
void set_field_groups_source(std::wstring name);
void start_field_group();
void set_field_group_name (std::wstring name);
void end_field_group();
void start_field_reference();
void set_field_ref_name(std::wstring name);
void set_field_ref_type (int type);
void set_field_ref_member_name(std::wstring name);
void set_field_ref_member_type(int type);
void end_field_reference();
void end_field();
int get_count();
@ -72,6 +87,7 @@ public:
void add_button_header(std::wstring ref);
void set_identify_categories(bool val);
void set_ignore_empty_rows(bool val);
void set_drill(bool val);
void set_source_range(std::wstring table_name, std::wstring ref);
@ -97,7 +113,6 @@ public:
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}

View File

@ -358,7 +358,18 @@ void xlsx_table_state::serialize_page_properties (std::wostream & strm)
page_layout->xlsx_serialize(strm, *context_);
}
void xlsx_table_state::serialize_background (std::wostream & strm)
{
if (tableBackground_.empty()) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"picture")
{
CP_XML_ATTR(L"r:id", tableBackground_);
}
}
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();

View File

@ -120,10 +120,12 @@ public:
xlsx_conditionalFormatting_context & get_conditionalFormatting_context() {return xlsx_conditionalFormatting_context_;}
void table_column_last_width(double w) { table_column_last_width_ = w; }
double table_column_last_width() const { return table_column_last_width_; };
double table_column_last_width() const { return table_column_last_width_; };
void start_hyperlink ();
std::wstring end_hyperlink (std::wstring const & ref, std::wstring const & href, std::wstring const & display);
std::wstring end_hyperlink (std::wstring const & ref, std::wstring const & href, std::wstring const & display);
void set_background (std::wstring rId) { tableBackground_ = rId; }
void serialize_conditionalFormatting (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream);
@ -131,6 +133,7 @@ public:
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
@ -154,6 +157,7 @@ private:
std::wstring tableName_;
int tableId_;
std::wstring tableBackground_;
std::wstring table_style_;
std::wstring table_row_style_;

View File

@ -320,6 +320,10 @@ void xlsx_table_context::serialize_page_properties(std::wostream & _Wostream)
{
return state()->serialize_page_properties(_Wostream);
}
void xlsx_table_context::serialize_background(std::wostream & _Wostream)
{
return state()->serialize_background(_Wostream);
}
void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
{
return state()->serialize_hyperlinks(_Wostream);

View File

@ -90,6 +90,7 @@ public:
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();

View File

@ -47,7 +47,7 @@ namespace oox {
bool IsNumber(const std::wstring &value)
{
boost::wregex rule(L"\\-?^[0-9]*[.,]?[0-9]*$");
boost::wregex rule(L"^\\-{0,1}[0-9]*[.,]{0,1}[0-9]*$");
boost::match_results<std::wstring::const_iterator> results;
return boost::regex_search(value/*.begin(), value.end(), results*/, rule);

View File

@ -475,9 +475,10 @@ void xlsx_conversion_context::end_table()
{
CP_XML_ATTR(L"r:id", drawingName.second);
}
}
}
}
get_table_context().serialize_background (current_sheet().drawing());
}
if (!get_comments_context().empty())
{
std::wstringstream strm;
@ -495,7 +496,6 @@ void xlsx_conversion_context::end_table()
current_sheet().set_comments_link(commentsName.first, commentsName.second);
current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
}
//background picture
get_table_context().end_table();
}
@ -547,7 +547,10 @@ int xlsx_conversion_context::current_table_row()
std::wstring xlsx_conversion_context::current_cell_address()
{
return oox::getCellAddress(current_table_column(), current_table_row());
int col = current_table_column();
int row = current_table_row();
return oox::getCellAddress(col < 0 ? 0 : col, row < 0 ? 0 : row); //under covered cell
}
void xlsx_conversion_context::start_office_spreadsheet(const odf_reader::office_element * elm)

View File

@ -46,8 +46,7 @@ std::wostream & operator << (std::wostream & _Wostream, const Bool & _Val)
}
Bool Bool::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
XmlUtils::GetLower(tmp);
std::wstring tmp = XmlUtils::GetLower(Str);
if (tmp == L"0" || tmp == L"false") return Bool(false);
else return Bool(true);

View File

@ -108,7 +108,6 @@ font_weight font_weight::parse(const std::wstring & Str)
return font_weight( W900 );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return WNormal;
}
}

View File

@ -91,47 +91,47 @@ smil_transition_type smil_transition_type::parse(const std::wstring & Str)
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if(tmp == L"barWipe") return smil_transition_type( barWipe );
else if(tmp == L"boxWipe") return smil_transition_type( boxWipe );
else if(tmp == L"fourboxWipe") return smil_transition_type( fourBoxWipe );
else if(tmp == L"barndoorWipe") return smil_transition_type( barnDoorWipe );
else if(tmp == L"diagonalWipe") return smil_transition_type( diagonalWipe );
else if(tmp == L"bowtieWipe") return smil_transition_type( bowTieWipe );
else if(tmp == L"miscdiagonalWipe") return smil_transition_type( miscDiagonalWipe );
else if(tmp == L"veeWipe") return smil_transition_type( veeWipe );
else if(tmp == L"barnveeWipe") return smil_transition_type( barnVeeWipe );
else if(tmp == L"zigzagWipe") return smil_transition_type( zigZagWipe );
else if(tmp == L"barnzigzagWipe") return smil_transition_type( barnZigZagWipe );
else if(tmp == L"irisWipe") return smil_transition_type( irisWipe);
else if(tmp == L"triangleWipe") return smil_transition_type( triangleWipe);
else if(tmp == L"arrowheadWipe") return smil_transition_type( arrowHeadWipe );
else if(tmp == L"pentagonWipe") return smil_transition_type( pentagonWipe );
else if(tmp == L"hexagonWipe") return smil_transition_type( hexagonWipe );
else if(tmp == L"ellipseWipe") return smil_transition_type( ellipseWipe );
else if(tmp == L"eyeWipe") return smil_transition_type( eyeWipe );
else if(tmp == L"roundrectWipe") return smil_transition_type( roundRectWipe );
else if(tmp == L"starWipe") return smil_transition_type( starWipe );
else if(tmp == L"miscshapeWipe") return smil_transition_type( miscShapeWipe );
else if(tmp == L"clockWipe") return smil_transition_type( clockWipe );
else if(tmp == L"pinwheelWipe") return smil_transition_type( pinWheelWipe );
else if(tmp == L"singlesweepWipe") return smil_transition_type( singleSweepWipe);
else if(tmp == L"fanWipe") return smil_transition_type( fanWipe );
else if(tmp == L"doublefanWipe") return smil_transition_type( doubleFanWipe );
else if(tmp == L"doublesweepWipe") return smil_transition_type( doubleSweepWipe );
else if(tmp == L"saloondoorWipe") return smil_transition_type( saloonDoorWipe );
else if(tmp == L"windshieldWipe") return smil_transition_type( windshieldWipe );
else if(tmp == L"snakeWipe") return smil_transition_type( snakeWipe );
else if(tmp == L"spiralWipe") return smil_transition_type( spiralWipe );
else if(tmp == L"parallelsnakesWipe")return smil_transition_type( parallelSnakesWipe );
else if(tmp == L"boxsnakesWipe") return smil_transition_type( boxSnakesWipe );
else if(tmp == L"waterfallWipe") return smil_transition_type( waterfallWipe );
else if(tmp == L"pushWipe") return smil_transition_type( pushWipe );
else if(tmp == L"slideWipe") return smil_transition_type( slideWipe );
if(tmp == L"barwipe") return smil_transition_type( barWipe );
else if(tmp == L"boxwipe") return smil_transition_type( boxWipe );
else if(tmp == L"fourboxwipe") return smil_transition_type( fourBoxWipe );
else if(tmp == L"barndoorwipe") return smil_transition_type( barnDoorWipe );
else if(tmp == L"diagonalwipe") return smil_transition_type( diagonalWipe );
else if(tmp == L"bowtiewipe") return smil_transition_type( bowTieWipe );
else if(tmp == L"miscdiagonalwipe") return smil_transition_type( miscDiagonalWipe );
else if(tmp == L"veewipe") return smil_transition_type( veeWipe );
else if(tmp == L"barnveewipe") return smil_transition_type( barnVeeWipe );
else if(tmp == L"zigzagwipe") return smil_transition_type( zigZagWipe );
else if(tmp == L"barnzigzagwipe") return smil_transition_type( barnZigZagWipe );
else if(tmp == L"iriswipe") return smil_transition_type( irisWipe);
else if(tmp == L"trianglewipe") return smil_transition_type( triangleWipe);
else if(tmp == L"arrowheadwipe") return smil_transition_type( arrowHeadWipe );
else if(tmp == L"pentagonwipe") return smil_transition_type( pentagonWipe );
else if(tmp == L"hexagonwipe") return smil_transition_type( hexagonWipe );
else if(tmp == L"ellipsewipe") return smil_transition_type( ellipseWipe );
else if(tmp == L"eyewipe") return smil_transition_type( eyeWipe );
else if(tmp == L"roundrectwipe") return smil_transition_type( roundRectWipe );
else if(tmp == L"starwipe") return smil_transition_type( starWipe );
else if(tmp == L"miscshapewipe") return smil_transition_type( miscShapeWipe );
else if(tmp == L"clockwipe") return smil_transition_type( clockWipe );
else if(tmp == L"pinwheelwipe") return smil_transition_type( pinWheelWipe );
else if(tmp == L"singlesweepwipe") return smil_transition_type( singleSweepWipe);
else if(tmp == L"fanwipe") return smil_transition_type( fanWipe );
else if(tmp == L"doublefanwipe") return smil_transition_type( doubleFanWipe );
else if(tmp == L"doublesweepwipe") return smil_transition_type( doubleSweepWipe );
else if(tmp == L"saloondoorwipe") return smil_transition_type( saloonDoorWipe );
else if(tmp == L"windshieldwipe") return smil_transition_type( windshieldWipe );
else if(tmp == L"snakewipe") return smil_transition_type( snakeWipe );
else if(tmp == L"spiralwipe") return smil_transition_type( spiralWipe );
else if(tmp == L"parallelsnakeswipe")return smil_transition_type( parallelSnakesWipe );
else if(tmp == L"boxsnakeswipe") return smil_transition_type( boxSnakesWipe );
else if(tmp == L"waterfallwipe") return smil_transition_type( waterfallWipe );
else if(tmp == L"pushwipe") return smil_transition_type( pushWipe );
else if(tmp == L"slidewipe") return smil_transition_type( slideWipe );
else if(tmp == L"fade") return smil_transition_type( fade );
else if(tmp == L"checkerboardWipe") return smil_transition_type( checkerBoardWipe);
else if(tmp == L"blindsWipe") return smil_transition_type( blindsWipe);
else if(tmp == L"checkerboardwipe") return smil_transition_type( checkerBoardWipe);
else if(tmp == L"blindswipe") return smil_transition_type( blindsWipe);
else if(tmp == L"dissolve") return smil_transition_type( dissolve);
else if(tmp == L"randombarWipe") return smil_transition_type( randomBarWipe);
else if(tmp == L"randombarwipe") return smil_transition_type( randomBarWipe);
else
{
return smil_transition_type( barWipe );

View File

@ -84,7 +84,6 @@ vertical_align vertical_align::parse(const std::wstring & Str)
return vertical_align( Justify );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return vertical_align( Baseline );
}
}

View File

@ -754,7 +754,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
}
void common_draw_docx_convert(oox::docx_conversion_context & Context, const union_common_draw_attlists & attlists_, oox::_docx_drawing *drawing)
void common_draw_docx_convert(oox::docx_conversion_context & Context, union_common_draw_attlists & attlists_, oox::_docx_drawing *drawing)
{
const std::wstring styleName = attlists_.shape_with_text_and_styles_.
common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
@ -899,7 +899,16 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
}
}
///////////////////////////
if (attlists_.rel_size_.common_draw_size_attlist_.svg_width_)
{
double w_shape = attlists_.rel_size_.common_draw_size_attlist_.svg_width_->get_value_unit(length::pt);
if (w_shape < 1) attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(1, length::pt);
}
if (attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
{
double h_shape = attlists_.rel_size_.common_draw_size_attlist_.svg_height_->get_value_unit(length::pt);
if (h_shape < 1) attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(1, length::pt);
}
drawing->x = get_value_emu(attlists_.position_.svg_x_);
drawing->y = get_value_emu(attlists_.position_.svg_y_);
@ -1040,23 +1049,44 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
std::wostream & strm = Context.output_stream();
bool pState = Context.get_paragraph_state();
Context.set_paragraph_state(false);
bool runState = Context.get_run_state();
bool paraState = Context.get_paragraph_state();
bool keepState = Context.get_paragraph_keep();
//Context.set_run_state (false);
Context.set_paragraph_state (false);
bool new_run = false;
bool new_run = true;
if ((pState == false && Context.get_drawing_context().get_current_level() == 1) || (Context.get_drawing_context().in_group()))
if ((paraState == false && Context.get_drawing_context().get_current_level() == 1) || (Context.get_drawing_context().in_group()))
{
new_run = false;
}
else
Context.add_new_run(_T(""));
{
if (!Context.get_drawing_context().in_group() && !runState)
{
if (!paraState)
{
Context.start_paragraph();
}
Context.add_new_run(L"");
new_run = true;
}
}
drawing.serialize(strm/*, Context.get_drawing_state_content()*/);
if (new_run) Context.finish_run();
if (new_run)
{
Context.finish_run();
if (!paraState)
{
Context.finish_paragraph();
}
}
Context.set_paragraph_state(pState);
Context.set_paragraph_state(paraState);
Context.get_drawing_context().stop_shape();
}
@ -1067,7 +1097,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
return;
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
int pos_replaicement= href.find(L"ObjectReplacements");
int pos_replaicement = href.find(L"ObjectReplacements");
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
if (!frame)
@ -1076,9 +1106,12 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
if (pos_replaicement >= 0 && !Context.get_drawing_context().get_use_image_replace())
if (pos_replaicement >= 0)
{
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
if (!Context.get_drawing_context().get_use_image_replace())
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
if (href.length() - (pos_replaicement + 18) < 2)
return; //href="./ObjectReplacements/"
}
if (drawing->type == oox::typeUnknown)
@ -1122,7 +1155,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
drawing->fill.bitmap = oox::oox_bitmap_fill::create();
drawing->fill.type = 2;
drawing->fill.bitmap->isInternal = false;
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal,href);
drawing->fill.bitmap->rId = Context.add_mediaitem(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
drawing->fill.bitmap->bStretch = true;
const std::wstring styleName = frame->common_draw_attlists_.shape_with_text_and_styles_.
@ -1381,22 +1414,34 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context)
//-----------------------------------------------------------------------------------------------------
bool runState = Context.get_run_state();
bool pState = Context.get_paragraph_state();
bool paraState = Context.get_paragraph_state();
bool keepState = Context.get_paragraph_keep();
Context.set_run_state (false);
Context.set_paragraph_state (false);
if (!Context.get_drawing_context().in_group() && !runState)
Context.add_new_run(_T(""));
{
if (!paraState)//0115GS3-KeyboardShortcuts.odt
{
Context.start_paragraph();
}
Context.add_new_run(L"");
}
drawing->serialize(Context.output_stream()/*, Context.get_drawing_state_content()*/);
if (!Context.get_drawing_context().in_group() && !runState)
{
Context.finish_run();
if (!paraState)//0115GS3-KeyboardShortcuts.odt
{
Context.finish_paragraph();
}
}
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_paragraph_state (paraState);
Context.set_paragraph_keep (keepState);
Context.get_drawing_context().stop_frame();
@ -1406,9 +1451,9 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
{
try
{
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
if (!odf_document_)
if (!odf_document_ && !href.empty())
{
std::wstring folderPath = Context.root()->get_folder();
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;

View File

@ -257,9 +257,9 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
{
try
{
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
if (!odf_document_)
if (!odf_document_ && !href.empty())
{
std::wstring folderPath = Context.root()->get_folder();
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;

View File

@ -265,7 +265,8 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
try
{
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
if (!odf_document_)
if (!odf_document_ && !href.empty())
{
std::wstring folderPath = Context.root()->get_folder();
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;

View File

@ -607,9 +607,8 @@ void draw_caption::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_connector_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"svg:d", svg_d_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
CP_APPLY_ATTR(L"draw:type", draw_type_);
}
// draw:connector
const wchar_t * draw_connector::ns = L"draw";
@ -669,5 +668,42 @@ void draw_connector::reset_svg_path()
}
///////////////////////////////////////
// dr3d:scene
const wchar_t * dr3d_scene::ns = L"dr3d";
const wchar_t * dr3d_scene::name = L"scene";
void dr3d_scene::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_shape::add_attributes(Attributes);
sub_type_ = 10;
}
// dr3d:extrude
const wchar_t * dr3d_extrude::ns = L"dr3d";
const wchar_t * dr3d_extrude::name = L"extrude";
void dr3d_extrude::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"svg:d", svg_d_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
void dr3d_extrude::reset_svg_path()
{
if (!svg_d_) return;
}
// dr3d:light
const wchar_t * dr3d_light::ns = L"dr3d";
const wchar_t * dr3d_light::name = L"light";
void dr3d_light::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"dr3d:diffuse_color", dr3d_diffuse_color_);
CP_APPLY_ATTR(L"dr3d:direction", dr3d_direction_);
CP_APPLY_ATTR(L"dr3d:specular", dr3d_specular_);
CP_APPLY_ATTR(L"dr3d:enabled", dr3d_enabled_);
}
}
}

View File

@ -543,8 +543,8 @@ public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
draw_connector_attlist draw_connector_attlist_;
draw_line_attlist draw_line_attlist_;
draw_connector_attlist draw_connector_attlist_;
draw_line_attlist draw_line_attlist_;
void reset_svg_path();
void reset_svg_attributes();
@ -552,5 +552,75 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(draw_connector);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class dr3d_scene : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dScene;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_scene);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class dr3d_extrude : public office_element_impl<dr3d_extrude>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dExtrude;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) svg_d_;
_CP_OPT(std::wstring) svg_viewbox_;
void reset_svg_path();
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_extrude);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class dr3d_light : public office_element_impl<dr3d_light>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dLight;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_diffuse_color_;
_CP_OPT(std::wstring) dr3d_direction_;
_CP_OPT(std::wstring) dr3d_specular_;
_CP_OPT(odf_types::Bool)dr3d_enabled_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_light);
}
}

View File

@ -298,6 +298,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape->additional_.push_back(odf_reader::_property(L"custom_path", output_.str()));
set_shape = true;
int w = 0;
int h = 0;
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
@ -306,8 +308,8 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
if (splitted.size() == 2)
{
int w = boost::lexical_cast<int>(splitted[0]);
int h = boost::lexical_cast<int>(splitted[1]);
w = boost::lexical_cast<int>(splitted[0]);
h = boost::lexical_cast<int>(splitted[1]);
shape->additional_.push_back(odf_reader::_property(L"custom_path_w", w));
shape->additional_.push_back(odf_reader::_property(L"custom_path_h", h));
@ -320,6 +322,17 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
int b = boost::lexical_cast<int>(splitted[3]);
}
//if (shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_)
//{
// int w_shape = shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_->get_value();
// if (w_shape < 1) shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(1, length::pt);
//}
//if (shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
//{
// int h_shape = shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_->get_value();
// if (h_shape < 1) shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(1, length::pt);
//}
}
}
}
@ -338,5 +351,28 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
shape->bad_shape_ = true;
}
}
void dr3d_scene::docx_convert(oox::docx_conversion_context & Context)
{
//if (Context.get_drawing_context().get_current_level() >0 )return;
if (Context.get_drawing_context().get_current_level() > 0 && !Context.get_drawing_context().in_group() )
{
if(Context.delayed_converting_ == false)
Context.add_delayed_element(this);
return;
}
common_docx_convert(Context);
//...
draw_shape::docx_convert(Context);
}
void dr3d_extrude::docx_convert(oox::docx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::docx_convert(oox::docx_conversion_context & Context)
{
}
}
}

View File

@ -401,6 +401,24 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
{
Context.get_slide_context().start_shape(1); //restart type shape
}
}
void dr3d_scene::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_);
common_pptx_convert(Context);
Context.get_slide_context().end_shape();
}
void dr3d_extrude::pptx_convert(oox::pptx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::pptx_convert(oox::pptx_conversion_context & Context)
{
}
}
}

View File

@ -334,6 +334,26 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
{
}
}
}
void dr3d_scene::xlsx_convert(oox::xlsx_conversion_context & Context)
{
//const std::wstring style = common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
Context.get_drawing_context().start_shape(1);//rect с наваротами-атрибутами .. а-ля TextBox
common_xlsx_convert(Context);
Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
}
void dr3d_extrude::xlsx_convert(oox::xlsx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
}
}

View File

@ -33,6 +33,7 @@
#include "math_layout_elements.h"
#include "math_token_elements.h"
#include "style_text_properties.h"
#include "math_limit_elements.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
@ -95,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>";
@ -114,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);
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";
@ -149,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());
@ -163,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";
@ -191,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());
@ -229,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);
@ -294,11 +328,26 @@ 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());
//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);
math_element->oox_convert(Context);
//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);
}
//reset to default math text props
Context.text_properties_ = odf_reader::style_text_properties_ptr(new odf_reader::style_text_properties());
@ -306,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() );

View File

@ -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;
}
}
}

View File

@ -31,6 +31,8 @@
*/
#include "math_table_elements.h"
#include "math_layout_elements.h"
#include "math_limit_elements.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
@ -90,14 +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++)
{
//strm << L"<m:e>"; // EqArray записался в числитель вместо знаменателя.docx - дублирование
office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
math_element->oox_convert(Context);
//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;
}
//----------------------------------------------------------------------------------------------------
@ -140,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());

View File

@ -283,7 +283,12 @@ void math_mtext::add_text(const std::wstring & Text)
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() << XmlUtils::EncodeXmlString(*text_);
Context.output_stream() << L"</m:t></m:r>";
}
}
//----------------------------------------------------------------------------------------------------
const wchar_t * math_mglyph::ns = L"math";

View File

@ -104,8 +104,7 @@ void styles_container::add_style( const std::wstring & Name,
map_[n] = pos;
// TODO: как правильно??
std::wstring lName = Name;
XmlUtils::GetLower(lName);
std::wstring lName = XmlUtils::GetLower(Name);
//if ( boost::algorithm::contains(lName, L"internet_20_link") )
if (lName == L"internet_20_link")///???????????????
hyperlink_style_pos_ = pos;
@ -331,7 +330,7 @@ void page_layout_instance::xlsx_serialize(std::wostream & strm, oox::xlsx_conver
props->xlsx_serialize(strm, Context);
}
void page_layout_instance::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
void page_layout_instance::docx_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{
const style_header_style * headerStyle = dynamic_cast<style_header_style *>(style_page_layout_->style_header_style_.get());
const style_footer_style * footerStyle = dynamic_cast<style_footer_style *>(style_page_layout_->style_footer_style_.get());
@ -357,7 +356,7 @@ void page_layout_instance::docx_convert_serialize(std::wostream & strm, oox::doc
style_page_layout_properties * props = properties();
if (props)
props->docx_convert_serialize(strm, Context);
props->docx_serialize(strm, Context);
}
void page_layout_instance::pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context)
{

View File

@ -193,9 +193,9 @@ public:
const std::wstring & name() const;
style_page_layout_properties * properties() const;
void docx_convert_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void xlsx_serialize (std::wostream & strm, oox::xlsx_conversion_context & Context);
void pptx_serialize (std::wostream & strm, oox::pptx_conversion_context & Context);
void docx_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_serialize (std::wostream & strm, oox::pptx_conversion_context & Context);
void xlsx_serialize (std::wostream & strm, oox::xlsx_conversion_context & Context);
const style_page_layout * style_page_layout_;

View File

@ -40,9 +40,10 @@
#include "serialize_elements.h"
#include <cpdoccore/odf/odf_document.h>
#include "../odf/odfcontext.h"
#include "odfcontext.h"
#include "../odf/calcs_styles.h"
#include "calcs_styles.h"
#include "../docx/xlsx_utils.h"
namespace cpdoccore {
@ -215,8 +216,12 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");
std::wstring ref = Context.current_cell_address();
Context.get_comments_context().end_comment(ref,Context.current_table_column(), Context.current_table_row());
int col = Context.current_table_column(); if (col < 0) col = 0;
int row = Context.current_table_row(); if (row < 0) row = 0;
std::wstring ref = oox::getCellAddress(col, row);
Context.get_comments_context().end_comment(ref, col, row);
}
// officeooo:annotation
//////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -152,7 +152,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
{
if (page_layout_instance * lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{
lastPageLayout->docx_convert_serialize(Context.output_stream(), Context);
lastPageLayout->docx_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();
}
}

View File

@ -346,6 +346,13 @@ enum ElementType
typeDrawHandle,
typeDrawEquation,
typeDr3dScene,
typeDr3dLight,
typeDr3dExtrude,
typeDr3dCube,
typeDr3dRotate,
typeDr3dSphere,
typeDrawPage,
typePresentationFooterDecl,
typePresentationDateTimeDecl,

View File

@ -86,19 +86,42 @@ void text::add_text(const std::wstring & Text)
void text::docx_convert(oox::docx_conversion_context & Context)
{
Context.add_element_to_run();
std::wostream & strm = Context.output_stream();
if (Context.get_process_note() != oox::docx_conversion_context::noNote &&
Context.get_delete_text_state())
return; //в ms нет рецензирования notes
bool add_del_run = false;
if (Context.get_drawing_state_content() && Context.get_delete_text_state())
{ //0503IG-AddingFormattingText.odt - удаленый текст в удаленом объекте
oox::text_tracked_context::_state &state = Context.get_text_tracked_context().get_tracked_change(L"");
if (state.type == 2)
{
add_del_run = true;
Context.output_stream() << L"<w:del>";
}
}
Context.add_element_to_run();
std::wstring textNode = L"w:t";
if (Context.get_delete_text_state()) textNode = L"w:delText";
strm << L"<" << textNode;
Context.output_stream() << L"<" << textNode;
if (preserve_ && !Context.get_delete_text_state())
strm << L" xml:space=\"preserve\"";
strm << L">";
Context.output_stream() << L" xml:space=\"preserve\"";
Context.output_stream() << L">";
Context.output_stream() << xml::utils::replace_text_to_xml( text_ );
Context.output_stream() << L"</" << textNode << L">";
if (add_del_run)
{
Context.finish_run();
Context.output_stream() << L"</w:del>";
}
strm << xml::utils::replace_text_to_xml( text_ );
strm << L"</" << textNode << L">";
}
void text::xlsx_convert(oox::xlsx_conversion_context & Context)

View File

@ -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:

View File

@ -1254,7 +1254,6 @@ bool style_page_layout_properties::docx_background_serialize(std::wostream & str
void style_page_layout_properties::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context)
{
CP_XML_WRITER(strm)
@ -1319,31 +1318,28 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
}
}
}
if (elements_.style_background_image_)
}
if (elements_.style_background_image_)
{
oox::_oox_fill fill;
Compute_GraphicFill(attlist_.common_draw_fill_attlist_, elements_.style_background_image_, Context.root()->odf_context().drawStyles(), fill);
if (fill.bitmap)
{
oox::_oox_fill fill;
Compute_GraphicFill(attlist_.common_draw_fill_attlist_, elements_.style_background_image_, Context.root()->odf_context().drawStyles(), fill);
if (fill.bitmap)
if ( fill.bitmap->rId.empty())
{
if ( fill.bitmap->rId.empty())
{
std::wstring href = fill.bitmap->xlink_href_;
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
std::wstring href = fill.bitmap->xlink_href_;
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true);
}
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true);
}
CP_XML_NODE(L"picture")
{
CP_XML_ATTR(L"r:id", fill.bitmap->rId );
}
}
}
Context.get_table_context().state()->set_background(fill.bitmap->rId);
}
}
}
void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
void style_page_layout_properties::docx_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{
style_columns * columns = dynamic_cast<style_columns *>( elements_.style_columns_.get());

View File

@ -975,11 +975,12 @@ public:
static const ElementType type = typeStylePageLayout;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_convert (oox::pptx_conversion_context & Context);
void xlsx_convert (oox::xlsx_conversion_context & Context);
bool docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id);
void docx_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context);
void pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context);

View File

@ -790,7 +790,7 @@ namespace svg_path
}
}
if ((aCurrPoly.points.size() > 0 || !bIsClosed) && !aCurrPoly.command.empty() && aCurrPoly.command != L"a:cubicBezTo")
if ((aCurrPoly.points.size() > 0/* || !bIsClosed*/) && !aCurrPoly.command.empty() && aCurrPoly.command != L"a:cubicBezTo")
{
// end-process last poly

View File

@ -123,6 +123,9 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
if (table_identify_categories_)
Context.get_pivots_context().set_identify_categories(table_identify_categories_->get());
if (table_ignore_empty_rows_)
Context.get_pivots_context().set_ignore_empty_rows(table_ignore_empty_rows_->get());
if (table_drill_down_ondouble_click_)
Context.get_pivots_context().set_drill(table_drill_down_ondouble_click_->get());
@ -155,6 +158,7 @@ void table_data_pilot_field::add_attributes( const xml::attributes_wc_ptr & Attr
CP_APPLY_ATTR(L"loext:ignore-selected-page" , loext_ignore_selected_page_);
CP_APPLY_ATTR(L"table:selected-page" , table_selected_page_);
CP_APPLY_ATTR(L"table:is-data-layout-field" , table_is_data_layout_field_);
CP_APPLY_ATTR(L"tableooo:display-name" , table_display_name_);
}
void table_data_pilot_field::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -175,6 +179,9 @@ void table_data_pilot_field::xlsx_convert(oox::xlsx_conversion_context & Context
Context.get_pivots_context().set_field_name(table_source_field_name_.get_value_or(L""));
if (table_display_name_)
Context.get_pivots_context().set_field_display(*table_display_name_);
if (table_is_data_layout_field_)
Context.get_pivots_context().set_field_data_layout(table_is_data_layout_field_->get());
@ -217,7 +224,24 @@ void table_data_pilot_field_reference::add_attributes( const xml::attributes_wc_
void table_data_pilot_field_reference::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_pivots_context().start_field_reference();
if (table_field_name_)
{
Context.get_pivots_context().set_field_ref_name(*table_field_name_);
}
if (table_type_)
{
Context.get_pivots_context().set_field_ref_type(table_type_->get_type());
}
if (table_member_name_)
{
Context.get_pivots_context().set_field_ref_member_name(*table_member_name_);
}
if (table_member_type_)
{
Context.get_pivots_context().set_field_ref_member_type(table_member_type_->get_type());
}
Context.get_pivots_context().end_field_reference();
}
//-------------------------------------------------------------------------------------------------
const wchar_t * table_database_source_table::ns = L"table";
@ -405,6 +429,12 @@ void table_data_pilot_groups::xlsx_convert(oox::xlsx_conversion_context & Contex
{
if (table_grouped_by_)
Context.get_pivots_context().set_field_groups(table_grouped_by_->get_type());
else
Context.get_pivots_context().set_field_groups(7);
if (table_source_field_name_)
Context.get_pivots_context().set_field_groups_source(*table_source_field_name_);
for (size_t i = 0; i < content_.size(); i++)
{
@ -425,10 +455,16 @@ void table_data_pilot_group::add_child_element( xml::sax * Reader, const std::ws
}
void table_data_pilot_group::xlsx_convert(oox::xlsx_conversion_context & Context)
{
for (size_t i = 0; i < content_.size(); i++)
Context.get_pivots_context().start_field_group();
if (table_name_)
Context.get_pivots_context().set_field_group_name (*table_name_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.get_pivots_context().end_field_group();
}
//-------------------------------------------------------------------------------------------------
const wchar_t * table_data_pilot_members::ns = L"table";
@ -466,12 +502,12 @@ const wchar_t * table_data_pilot_group_member::name = L"data-pilot-group-member"
void table_data_pilot_group_member::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"table:name", table_name_);
CP_APPLY_ATTR(L"table:name", table_name_);
}
void table_data_pilot_group_member::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_pivots_context().add_field_cache(-1, table_name_.get_value_or(L""));
}
//-------------------------------------------------------------------------------------------------
const wchar_t * table_data_pilot_subtotals::ns = L"table";

View File

@ -130,6 +130,7 @@ public:
_CP_OPT(odf_types::Bool) loext_ignore_selected_page_;
_CP_OPT(std::wstring) table_selected_page_;
_CP_OPT(odf_types::Bool) table_is_data_layout_field_;
_CP_OPT(std::wstring) table_display_name_;
office_element_ptr reference_;
office_element_ptr level_;

View File

@ -1248,7 +1248,7 @@ void text_changed_region::docx_convert(oox::docx_conversion_context & Context)
if (content_.empty() || !text_id_) return;
Context.get_text_tracked_context().start_change (*text_id_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);

View File

@ -52,7 +52,7 @@ COfficePPTFile::~COfficePPTFile()
CloseFile();
}
long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring & password)
long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring & password, bool &bMacros)
{
CloseFile();
@ -66,6 +66,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring
pptReader->m_oDocumentInfo.m_strTmpDirectory = m_strTempDirectory;
pptReader->m_oDocumentInfo.m_strPassword = password;
pptReader->m_oDocumentInfo.m_bMacros = bMacros;
if (pptReader->IsPowerPoint() == false)
{
@ -88,6 +89,7 @@ long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring
//pptReader->ReadDocumentSummary();
pptReader->ReadDocument();
bMacros = pptReader->m_oDocumentInfo.m_bMacros;
m_Status = READMODE;
return S_OK;
@ -101,14 +103,14 @@ bool COfficePPTFile::CloseFile()
return S_OK;
}
HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password)
HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros)
{
if (m_strTempDirectory.empty())
{
m_strTempDirectory = NSDirectory::GetTempPath();
}
long nResult = OpenFile(sSrcFileName, password);
long nResult = OpenFile(sSrcFileName, password, bMacros);
if (nResult != S_OK)
{
CloseFile();

View File

@ -66,7 +66,7 @@ public:
return m_strTempDirectory;
}
HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password);
HRESULT LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros);
private:
@ -76,7 +76,7 @@ private:
std::wstring m_strTempDirectory;
std::wstring m_sTempDecryptFileName;
long OpenFile(const std::wstring & fileName, const std::wstring & password);
long OpenFile(const std::wstring & fileName, const std::wstring & password, bool &bMacros);
bool CloseFile();
std::wstring GetDirectory(std::wstring strFileName);

View File

@ -186,7 +186,7 @@ void NSPresentationEditor::CPPTXWriter::CloseFile()
void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
{
std::wstring strContentTypes = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
std::wstring strContentTypes = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\
<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\
<Default Extension=\"bmp\" ContentType=\"image/bmp\" />\
<Default Extension=\"png\" ContentType=\"image/png\" />\
@ -208,14 +208,22 @@ void NSPresentationEditor::CPPTXWriter::WriteContentTypes()
<Default Extension=\"xls\" ContentType=\"application/vnd.ms-excel\"/>\
<Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>\
<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\" />\
<Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>");
<Default Extension=\"jpg\" ContentType=\"application/octet-stream\"/>";
strContentTypes += _T("<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\" />\
<Override PartName=\"/ppt/presProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presProps+xml\" />\
if (m_pDocument->m_bMacros)
{
strContentTypes += L"<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml\" />\
<Override PartName=\"/ppt/vbaProject.bin\" ContentType=\"application/vnd.ms-office.vbaProject\" />";
}
else
{
strContentTypes += L"<Override PartName=\"/ppt/presentation.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\" />";
}
strContentTypes += L"<Override PartName=\"/ppt/presProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.presProps+xml\" />\
<Override PartName=\"/ppt/viewProps.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml\" />\
<Override PartName=\"/ppt/tableStyles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml\"/>\
<Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\" />\
<Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\" />");
<Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\" />";
int nIndexLayout = 1, nIndexTheme = 1;
@ -411,6 +419,15 @@ void NSPresentationEditor::CPPTXWriter::WritePresInfo()
strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles\" Target=\"tableStyles.xml\"/>";
strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps\" Target=\"viewProps.xml\"/>";
if (m_pDocument->m_bMacros)
{
std::wstring strVbaProject = m_strTempDirectory + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("vbaProject.bin");
if (CDirectory::CopyFile(m_pDocument->m_sVbaProjectFile, strVbaProject))
{
strPresRels += L"<Relationship Id=\"rId" + std::to_wstring(nCurrentRels++) + L"\" Type=\"http://schemas.microsoft.com/office/2006/relationships/vbaProject\" Target=\"vbaProject.bin\"/>";
}
}
strPresRels = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"
+ strPresRels + L"</Relationships>";

View File

@ -41,8 +41,9 @@ public:
std::wstring m_strTmpDirectory;
std::map<int, std::wstring> m_mapStoreImageFile;
std::wstring m_strPassword;
bool m_bMacros;
CPPTDocumentInfo() : m_oCurrentUser(), m_arUsers()
CPPTDocumentInfo() : m_oCurrentUser(), m_bMacros(true)
{
}
@ -88,6 +89,7 @@ public:
pInfo->m_strTmpDirectory = m_strTmpDirectory;
pInfo->m_bEncrypt = m_oCurrentUser.m_bIsEncrypt;
pInfo->m_strPassword = m_strPassword;
pInfo->m_bMacros = m_bMacros;
bool bResult = pInfo->ReadFromStream(&oUserAtom, pStream);

View File

@ -52,6 +52,7 @@ CPPTUserInfo::CPPTUserInfo() : CDocument(),
m_pDecryptor(NULL),
m_arOffsetPictures()
{
m_VbaProjectStg = NULL;
m_pDocumentInfo = NULL;
m_lIndexThisUser = -1;
@ -83,6 +84,7 @@ void CPPTUserInfo::Clear()
RELEASEOBJECT(m_pDecryptor);
RELEASEOBJECT(m_pStorageDecrypt);
RELEASEOBJECT(m_VbaProjectStg);
for (std::map<DWORD, CRecordSlide*>::iterator pPair = m_mapSlides.begin(); pPair != m_mapSlides.end(); ++pPair)
{
@ -390,6 +392,47 @@ bool CPPTUserInfo::ReadDocumentPersists(POLE::Stream* pStream)
m_mapHandoutMasters.insert( std::pair<DWORD, CRecordSlide*>(0, pSlide ));
}
}
if (m_bMacros)
{
m_bMacros = false;
std::vector<CRecordVBAInfoAtom*> oArrayVba;
m_oDocument.GetRecordsByType(&oArrayVba, true, true);
if (!oArrayVba.empty())
{
if (oArrayVba[0]->m_nHasMacros)
{
nIndexPsrRef = m_mapOffsetInPIDs.find(oArrayVba[0]->m_nObjStgDataRef);
if (m_mapOffsetInPIDs.end() != nIndexPsrRef)
{
offset_stream = nIndexPsrRef->second;
StreamUtils::StreamSeek(offset_stream, pStream);
POLE::Stream *pStreamTmp = pStream;
if (m_pDecryptor)
{
DecryptStream(pStream, oArrayVba[0]->m_nObjStgDataRef);
pStreamTmp = m_arStreamDecrypt.back()->stream_;
}
oHeader.ReadFromStream(pStreamTmp);
m_VbaProjectStg = new CRecordVbaProjectStg(m_strTmpDirectory);
m_VbaProjectStg->ReadFromStream(oHeader, pStreamTmp);
if (m_VbaProjectStg->m_sFileName.empty())
{
RELEASEOBJECT(m_VbaProjectStg);
}
else
{
m_sVbaProjectFile = m_VbaProjectStg->m_sFileName;
m_bMacros = true;
}
}
}
}
}
return true;
}
//--------------------------------------------------------------------------------------------

View File

@ -95,6 +95,7 @@ public:
// чтобы загружать неизмененные элементы от других юзеров (предыдущих)
CPPTDocumentInfo* m_pDocumentInfo;
CRecordVbaProjectStg* m_VbaProjectStg;
int m_lIndexThisUser;
// Animations structures

View File

@ -181,7 +181,7 @@ IRecord* CreateByType(SRecordHeader oHeader)
//CREATE_BY_TYPE(RECORD_TYPE_VIEWINFO_ATOM , CRecordNoZoomViewInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_VIEWINFO_ATOM , CRecordViewInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_SLIDE_VIEWINFO_ATOM , CRecordSlideViewInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_VBAINFO_ATOM , CRecordVBAInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_VBAINFO_ATOM , CRecordVBAInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_SSDOCINFO_ATOM , CRecordSSDocInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_DOC_ROUTING_SLIP , CRecordDocRoutingSlipAtom)
CREATE_BY_TYPE(RECORD_TYPE_EXOBJLIST_ATOM , CRecordExObjListAtom)
@ -263,11 +263,10 @@ IRecord* CreateByType(SRecordHeader oHeader)
//CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordRecolorInfoAtom)
//CREATE_BY_TYPE(RECORD_TYPE_UNKNOWN , CRecordAnimationInfoAtom)
CREATE_BY_TYPE(RECORD_TYPE_EX_VIDEOCONTAINER , CRecordExVideoContainer)
CREATE_BY_TYPE(RECORD_TYPE_EX_OBJREF_ATOM , CRecordExObjRefAtom)
CREATE_BY_TYPE(RECORD_TYPE_EX_MEDIA_ATOM , CRecordExMediaAtom)
//CREATE_BY_TYPE(RECORD_TYPE_EXCONTROL_ATOM , CRecordExControlAtom)
CREATE_BY_TYPE(RECORD_TYPE_EXCONTROL_ATOM , CRecordExControlAtom)
CREATE_BY_TYPE(RECORD_TYPE_ESCHER_BSTORE_CONTAINER , CRecordBlipStoreContainer)
CREATE_BY_TYPE(RECORD_TYPE_ESCHER_BSE , CRecordBlipStoreEntry)

View File

@ -34,7 +34,7 @@
class CRecordExControlAtom : public CUnknownRecord
{
UINT m_nSlideID;
UINT m_nSlideIdRef;
public:
@ -49,6 +49,7 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
m_oHeader = oHeader;
m_nSlideID = StreamUtils::ReadDWORD(pStream);
m_nSlideIdRef = StreamUtils::ReadDWORD(pStream);
}
};

View File

@ -52,6 +52,78 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
return CUnknownRecord::ReadFromStream(oHeader, pStream);
m_oHeader = oHeader;
m_nDrawAspect = StreamUtils::ReadDWORD(pStream);
m_nType = StreamUtils::ReadDWORD(pStream);
m_nExObjID = StreamUtils::ReadDWORD(pStream);
m_nSubType = StreamUtils::ReadDWORD(pStream);
m_nPersistID = StreamUtils::ReadDWORD(pStream);
StreamUtils::StreamSkip ( 4, pStream ); //unused
}
};
};
class CRecordExOleObjStg : public CUnknownRecord
{
public:
std::wstring m_sFileName;
std::wstring m_strTmpDirectory;
CRecordExOleObjStg(std::wstring strTemp) : m_strTmpDirectory(strTemp)
{
}
~CRecordExOleObjStg()
{
}
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
m_oHeader = oHeader;
ULONG decompressedSize = m_oHeader.RecLen, compressedSize = m_oHeader.RecLen;
BYTE* pData = new BYTE[m_oHeader.RecLen];
if (!pData) return;
if (m_oHeader.RecInstance == 0x01)
{
decompressedSize = StreamUtils::ReadDWORD(pStream);
compressedSize = m_oHeader.RecLen - 4;
}
pStream->read(pData, compressedSize);
if (m_oHeader.RecInstance == 0x01)
{
BYTE* pDataUncompress = new BYTE[decompressedSize + 64];
if (NSZLib::Decompress(pData, compressedSize, pDataUncompress, decompressedSize))
{
RELEASEOBJECT(pData);
pData = pDataUncompress;
}
else
{
RELEASEOBJECT(pData);
}
}
//if (pDecryptor)
//{
// pDecryptor->Decrypt((char*)pData, oHeader.RecLen - lOffset, 0);
//}
if (pData)
{
m_sFileName = m_strTmpDirectory + FILE_SEPARATOR_STR + L"oleObject_xxx.bin";
NSFile::CFileBinary file;
if (file.CreateFileW(m_sFileName))
{
file.WriteFile(pData, decompressedSize);
file.CloseFile();
}
delete[] pData;
pData = NULL;
}
}
};

View File

@ -34,11 +34,11 @@
class CRecordVBAInfoAtom : public CUnknownRecord
{
public:
UINT m_nObjStgDataRef;
UINT m_nHasMacros;
UINT m_nVersion;
public:
CRecordVBAInfoAtom()
{
@ -50,7 +50,69 @@ public:
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
return CUnknownRecord::ReadFromStream(oHeader, pStream);
m_oHeader = oHeader;
m_nObjStgDataRef = StreamUtils::ReadDWORD(pStream);
m_nHasMacros = StreamUtils::ReadDWORD(pStream);
m_nVersion = StreamUtils::ReadDWORD(pStream);
}
};
};
class CRecordVbaProjectStg : public CUnknownRecord
{
public:
std::wstring m_sFileName;
std::wstring m_strTmpDirectory;
CRecordVbaProjectStg(std::wstring strTemp) : m_strTmpDirectory(strTemp)
{
}
~CRecordVbaProjectStg()
{
}
virtual void ReadFromStream(SRecordHeader & oHeader, POLE::Stream* pStream)
{
m_oHeader = oHeader;
ULONG decompressedSize = m_oHeader.RecLen, compressedSize = m_oHeader.RecLen;
BYTE* pData = new BYTE[compressedSize];
if (!pData) return;
if (m_oHeader.RecInstance == 0x01)
{
decompressedSize = StreamUtils::ReadDWORD(pStream) + 64;
compressedSize -= 4;
}
pStream->read(pData, compressedSize);
//if (pDecryptor)
//{
// pDecryptor->Decrypt((char*)pData, compressedSize, 0);
//}
if (m_oHeader.RecInstance == 0x01)
{
BYTE* pDataUncompress = new BYTE[decompressedSize];
NSZLib::Decompress(pData, compressedSize, pDataUncompress, decompressedSize);
RELEASEOBJECT(pData);
pData = pDataUncompress;
}
m_sFileName = m_strTmpDirectory + FILE_SEPARATOR_STR + L"vbaProject.bin";
NSFile::CFileBinary file;
if (file.CreateFileW(m_sFileName))
{
file.WriteFile(pData, decompressedSize);
file.CloseFile();
}
delete[] pData;
pData = NULL;
}
};

View File

@ -49,9 +49,9 @@ int _tmain(int argc, _TCHAR* argv[])
if (argc < 2) return 1;
std::wstring sSrcPpt = argv[1];
std::wstring sDstPptx = argc > 2 ? argv[2] : sSrcPpt + L"-my.pptx";
std::wstring sDstPptx;
std::wstring outputDir = NSDirectory::GetFolderPath(sDstPptx);
std::wstring outputDir = NSDirectory::GetFolderPath(sSrcPpt);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
std::wstring tempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
@ -60,8 +60,19 @@ int _tmain(int argc, _TCHAR* argv[])
pptFile.put_TempDirectory(tempPath);
HRESULT hRes = pptFile.LoadFromFile(sSrcPpt, dstTempPath, L"password");
bool bMacros = true;
HRESULT hRes = pptFile.LoadFromFile(sSrcPpt, dstTempPath, L"password", bMacros);
if (bMacros)
{
sDstPptx = sSrcPpt + L"-my.pptm";
}
else
{
sDstPptx = sSrcPpt + L"-my.pptx";
}
if (hRes == S_OK)
{
COfficeUtils oCOfficeUtils(NULL);

View File

@ -48,7 +48,10 @@ namespace NSPresentationEditor
CMetricInfo m_oInfo;
CDocument() : m_arThemes(), m_arSlides()
bool m_bMacros;
std::wstring m_sVbaProjectFile;
CDocument() : m_bMacros (false)
{
m_pHandoutMaster = NULL;
m_pNotesMaster = NULL;

View File

@ -174,7 +174,8 @@ namespace PPTX
NSBinPptxRW::CBinaryFileWriter* old_writer = oDrawingConverter.m_pBinaryWriter;
NSCommon::smart_ptr<OOX::IFileContainer> old_rels = *pWriter->m_pCurrentContainer;
BinDocxRW::CDocxSerializer* old_serial = pWriter->m_pMainDocument;
NSCommon::smart_ptr<PPTX::Theme> old_theme = *pWriter->m_pTheme;
oDrawingConverter.m_pBinaryWriter = pWriter;
oDocxSerializer.m_pParamsWriter = new BinDocxRW::ParamsWriter(pWriter, &oFontProcessor, &oDrawingConverter, NULL);
@ -189,6 +190,7 @@ namespace PPTX
oDrawingConverter.m_pBinaryWriter = old_writer;
*pWriter->m_pCurrentContainer = old_rels;
pWriter->m_pMainDocument = old_serial;
*pWriter->m_pTheme = old_theme;
}
else if (office_checker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX ||
office_checker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM)
@ -201,9 +203,10 @@ namespace PPTX
DocWrapper::FontProcessor fp;
NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileWriter* old_writer = oDrawingConverter.m_pBinaryWriter;
NSBinPptxRW::CBinaryFileWriter* old_writer = oDrawingConverter.m_pBinaryWriter;
NSCommon::smart_ptr<OOX::IFileContainer> old_rels = *pWriter->m_pCurrentContainer;
NSCommon::smart_ptr<PPTX::Theme> old_theme = *pWriter->m_pTheme;
oDrawingConverter.m_pBinaryWriter = pWriter;
BinXlsxRW::BinaryFileWriter xlsxBinaryWriter(fp);
@ -215,7 +218,8 @@ namespace PPTX
oDrawingConverter.m_pBinaryWriter = old_writer;
*pWriter->m_pCurrentContainer = old_rels;
}
*pWriter->m_pTheme = old_theme;
}
//else if (office_checker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX)
//{
//}

View File

@ -1922,7 +1922,7 @@
17063B5B1AC5708E0056A3F1 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Ascensio System SIA";
};
buildConfigurationList = 17063B5E1AC5708E0056A3F1 /* Build configuration list for PBXProject "PPTXFormatLib" */;
@ -2004,14 +2004,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -2033,7 +2039,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
@ -2049,14 +2055,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -2072,7 +2084,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;

View File

@ -394,7 +394,7 @@
6967B1211E27B44D00A129E2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = OnlyOffce;
TargetAttributes = {
6967B1281E27B44D00A129E2 = {
@ -468,7 +468,9 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
@ -476,7 +478,11 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -499,7 +505,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@ -515,7 +521,9 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
@ -523,7 +531,11 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -540,7 +552,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;

View File

@ -44,10 +44,67 @@ HRESULT ConvertOle1ToOle2(BYTE *pData, int nSize, std::wstring sOle2Name)
Ole1FormatReader ole1Reader(pData, nSize);
NSFile::CFileBinary file;
file.CreateFileW(sOle2Name);
file.WriteFile(ole1Reader.NativeData, ole1Reader.NativeDataSize);
file.CloseFile();
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();
}
return S_FALSE;
}
//-----------------------------------------------------------------------------------------
@ -817,8 +874,7 @@ bool RtfShadingRowCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRe
else
return false;
return true;
}
}
bool RtfCharPropsCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter, RtfCharProperty * charProps, bool bLookOnBorder)
{
if (!charProps) return false;
@ -1645,7 +1701,64 @@ bool RtfFieldInstReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead
return RtfParagraphPropDestination::ExecuteCommand( oDocument, oReader, (*this), sCommand, hasParameter, parameter );
}
}
bool RtfOleBinReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
{
if ( "objdata" == sCommand )
return true;
if ( "bin" == sCommand ) // from RtfOleReader - conv_NI38P7GBIpw1aD84H3k.rtf
{
int nDataSize = 0;
if ( hasParameter )
nDataSize = parameter;
BYTE *pData = NULL;
oReader.m_oLex.ReadBytes( parameter, &pData );
m_arData.push_back(std::string((char*)pData, nDataSize));
RELEASEOBJECT(pData);
}
return true;
}
void RtfOleBinReader::ExecuteText(RtfDocument& oDocument, RtfReader& oReader, std::wstring sText)
{
m_arData.push_back(std::string(sText.begin(), sText.end()));
}
void RtfOleBinReader::GetData( BYTE** ppData, long& nSize)
{
nSize = 0;
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];
for (size_t i = start; i < m_arData.size(); i++)
{
BYTE *buf = (BYTE*)m_arData[i].c_str();
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)
{
if ( "object" == sCommand )
@ -1663,13 +1776,15 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
}
else if ( "objdata" == sCommand )
{
std::wstring sOleData;
TextReader oTextReader( sOleData, false );
StartSubReader( oTextReader, oDocument, oReader );
RtfOleBinReader oBinReader;
StartSubReader( oBinReader, oDocument, oReader );
BYTE *pData = NULL;
long nSize = 0;
RtfUtility::WriteDataToBinary( sOleData, &pData, nSize );
oBinReader.GetData(&pData, nSize );
if ( 0 != nSize && pData)
{
HRESULT hRes = S_FALSE;
@ -1689,7 +1804,7 @@ bool RtfOleReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, st
std::wstring sOleStorageName = Utils::CreateTempFile( oReader.m_sTempFolder );
IStorage* piMSStorage = NULL;
if ( SUCCEEDED( StgCreateDocfile( sOleStorageName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED/* | STGM_DELETEONRELEASE*/, NULL, &piMSStorage) ) )
if ( SUCCEEDED( StgCreateDocfile( sOleStorageName.c_str(), STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED/* | STGM_DELETEONRELEASE*/, NULL, &piMSStorage) ) )
{
hRes = OleConvertOLESTREAMToIStorage( &oStream, piMSStorage, NULL );
piMSStorage->Commit( STGC_DEFAULT );

View File

@ -109,13 +109,13 @@ public:
}
};
//class RtfOldList;
class TextReader: public RtfAbstractReader
class TextReader : public RtfAbstractReader
{
private:
std::wstring& m_sName;
bool m_bErease;
bool m_bErease;
public:
TextReader( std::wstring& sName, bool bErease = true ):m_sName(sName),m_bErease(bErease)
TextReader( std::wstring& sName, bool bErease = true ) : m_sName(sName), m_bErease(bErease)
{
}
void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, std::wstring sText)
@ -782,6 +782,20 @@ public:
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter);
};
class RtfOleBinReader : public RtfAbstractReader
{
private:
std::vector<std::string>/*&*/ m_arData;
public:
RtfOleBinReader()
{
}
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter);
void ExecuteText(RtfDocument& oDocument, RtfReader& oReader, std::wstring sText);
void GetData( BYTE** ppData, long& nSize);
};
class RtfTrackerChangesReader: public RtfAbstractReader
{
private:

View File

@ -300,26 +300,30 @@ public:
Ole1FormatReader(BYTE *pData, int Size)
{
NativeDataSize = 0;
if (!pData || Size < 8) return;
CDataStream stream(pData, Size);
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;

View File

@ -93,10 +93,14 @@ std::wstring RtfOle::RenderToOOX(RenderParameter oRenderParameter)
RenderParameter oNewRenderParameter = oRenderParameter;
oNewRenderParameter.nType = RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2;
m_oResultPic->m_bIsOle = true;
sResult += m_oResultPic->RenderToOOX(oNewRenderParameter);
oNewRenderParameter.nValue = m_oResultPic->m_nID;
if (m_oResultPic)
{
m_oResultPic->m_bIsOle = true;
sResult += m_oResultPic->RenderToOOX(oNewRenderParameter);
oNewRenderParameter.nValue = m_oResultPic->m_nID;
}
sResult += RenderToOOXOnlyOle(oNewRenderParameter);
sResult += L"</w:object>";

Some files were not shown because too many files have changed in this diff Show More