Compare commits

..

24 Commits

Author SHA1 Message Date
98eab74e97 . 2018-01-15 17:51:30 +03:00
2a7e88ca76 v5.0.7 2018-01-15 15:19:37 +03:00
369596b860 OdfFormatWriter - fix dropCap, sections 2018-01-13 14:59:56 +03:00
15af8f561a OdfFormatWriter - fix picture size from placeholder 2018-01-12 17:02:33 +03:00
58f8d13d71 . 2018-01-12 13:57:26 +03:00
d6413057e2 x2t version 2.4.505
OOXML - add external audio, video; add sound effects for shapes; fix chart theme override, clrmap; convert canvas drawingML
RtfWriter - add image scaling from DrawingML
fix convert from google csv
2018-01-12 12:54:22 +03:00
008382213b Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
Conflicts:
	Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h
2018-01-12 12:13:38 +03:00
dd5b4a719b x2t version 2.4.504 2018-01-12 12:03:44 +03:00
3d198bc211 for xlsx comments: Tahoma 9, User name in comment body 2018-01-11 20:43:10 +03:00
05ff75eeb2 fix bug #36652 2018-01-11 17:41:37 +03:00
597414ea6b DocFormatFile - fix users file (1995) without codepage 2017-12-26 13:08:02 +03:00
7f06ce7064 . 2017-12-26 11:21:39 +03:00
adf39680b6 OdfFormatWriter - extendede condition conditional formatting (x14) 2017-12-25 20:06:22 +03:00
ce77d478e3 x2t version 2.4.498 2017-12-25 15:42:59 +03:00
e1e14ae243 . 2017-12-25 13:52:57 +03:00
4f6e364225 . 2017-12-25 13:48:50 +03:00
26c02c5766 . 2017-12-23 19:33:05 +03:00
0d8c668f95 OdfFormat, fix bug 36596 (only for onlyoffice editors) 2017-12-23 17:34:20 +03:00
310cff0dfe change non-defined temp directory to unique 2017-12-23 14:48:44 +03:00
7f6611ab21 .. 2017-12-23 14:35:52 +03:00
bb37e348f5 . 2017-12-23 13:26:11 +03:00
6b5e03df5e . 2017-12-23 12:29:40 +03:00
d0e0109560 . 2017-12-22 15:10:45 +03:00
5039cec847 diagramm save error 2017-12-19 15:09:10 +03:00
265 changed files with 4421 additions and 3557 deletions

View File

@ -47,30 +47,17 @@ namespace DocFileFormat
virtual ~ConversionContext()
{
}
// Adds a new RSID to the set
inline void AddRsid(const std::wstring& rsid)
{
if (AllRsids.find(rsid) == AllRsids.end())
AllRsids.insert(rsid);
}
inline WordDocument* GetDocument()
{
return _doc;
}
inline WordprocessingDocument* GetXmlDocument()
{
return _docx;
}
public:
WordprocessingDocument* _docx;
WordDocument* _doc;
/// A set thta contains all revision ids.
std::set<std::wstring> AllRsids;
};
}

View File

@ -63,8 +63,16 @@ namespace DocFileFormat
{
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
{
if (!doc || !docx) return S_FALSE;
ConversionContext context( doc, docx );
//Write fontTable.xml
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
}
//Write styles.xml
if (doc->Styles)
{
@ -107,14 +115,6 @@ namespace DocFileFormat
return S_FALSE;
}
}
//Write fontTable.xml
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
}
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000 );

View File

@ -48,7 +48,8 @@ namespace DocFileFormat
class FontFamilyName: public ByteStructure
{
friend class CharacterPropertiesMapping;
friend class WordDocument;
friend class CharacterPropertiesMapping;
friend class DocumentMapping;
friend class FontTableMapping;
friend class StyleSheetMapping;

View File

@ -34,32 +34,30 @@
namespace DocFileFormat
{
FontTableMapping::FontTableMapping( ConversionContext* ctx ): AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
FontTableMapping::FontTableMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
{
_ctx = ctx;
}
/*========================================================================================================*/
FontTableMapping::~FontTableMapping()
{
RELEASEOBJECT (m_pXmlWriter);
}
/*========================================================================================================*/
void FontTableMapping::Apply( IVisitable* visited )
{
StringTable<FontFamilyName>* table = static_cast<StringTable<FontFamilyName>*>( visited );
this->_ctx->_docx->RegisterFontTable();
_ctx->_docx->RegisterFontTable();
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_pXmlWriter->WriteNodeBegin( L"w:fonts", TRUE );
m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
int sz_fonts = table->Data.size();
int sz_fonts = table->Data.size();
int users_fonts = 0;
for ( std::vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
@ -140,6 +138,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"w:fonts");
this->_ctx->_docx->FontTableXML = std::wstring( m_pXmlWriter->GetXmlString() );
_ctx->_docx->FontTableXML = m_pXmlWriter->GetXmlString() ;
}
}

View File

@ -38,8 +38,8 @@ namespace DocFileFormat
{
if (m_context)
{
m_document = m_context->GetDocument();
m_xmldocument = m_context->GetXmlDocument();
m_document = m_context->_doc;
m_xmldocument = m_context->_docx;
}
}

View File

@ -164,7 +164,7 @@ namespace DocFileFormat
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
std::list<std::wstring> entries = storageInp->entries(path);
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++)
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it)
{
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + L"/"+ (*it));
if (stream_inp == NULL)continue;

View File

@ -41,6 +41,7 @@ namespace DocFileFormat
{
template<class T> class StringTable: public IVisitable
{
friend class WordDocument;
friend class CharacterPropertiesMapping;
friend class FontTableMapping;
friend class StyleSheetMapping;

View File

@ -90,7 +90,7 @@ namespace DocFileFormat
std::list<std::wstring> entries, entries_sort;
entries = m_pStorage->entries_with_prefix( path );
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
{
std::wstring name = *it;
std::wstring fullname = path + name;
@ -104,8 +104,8 @@ namespace DocFileFormat
entries_sort.push_front(name);
}
}
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); it++ )
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); ++it )
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it )
{
std::wstring name = *it;
std::wstring fullname = path + name;

View File

@ -159,13 +159,13 @@ namespace DocFileFormat
OOX::CDocument docEmbedded(path, path);
bool res = false;
for (std::list<OOX::WritingElement*>::iterator it = docEmbedded.m_arrItems.begin(); it != docEmbedded.m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = docEmbedded.m_arrItems.begin(); it != docEmbedded.m_arrItems.end(); ++it)
{
if ((*it)->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(*it);
for (std::list<OOX::WritingElement*>::iterator jt = paragraph->m_arrItems.begin();
for (std::vector<OOX::WritingElement*>::iterator jt = paragraph->m_arrItems.begin();
(paragraph) && (jt != paragraph->m_arrItems.end()); jt++)
{
if ((*jt)->getType() == OOX::et_m_oMath)
@ -178,7 +178,7 @@ namespace DocFileFormat
{
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(*jt);
for (std::list<OOX::WritingElement*>::iterator kt = mathPara->m_arrItems.begin();
for (std::vector<OOX::WritingElement*>::iterator kt = mathPara->m_arrItems.begin();
(mathPara) && (kt != mathPara->m_arrItems.end()); kt++)
{
if ((*kt)->getType() == OOX::et_m_oMath)

View File

@ -40,8 +40,45 @@
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Directory.h"
#include <unordered_map>
namespace DocFileFormat
{
static const int aCodePages[][2] = {
//charset codepage
0, 1252, //ANSI
1, 0,//Default
2, 42,//Symbol
77, 10000,//Mac Roman
78, 10001,//Mac Shift Jis
79, 10003,//Mac Hangul
80, 10008,//Mac GB2312
81, 10002,//Mac Big5
83, 10005,//Mac Hebrew
84, 10004,//Mac Arabic
85, 10006,//Mac Greek
86, 10081,//Mac Turkish
87, 10021,//Mac Thai
88, 10029,//Mac East Europe
89, 10007,//Mac Russian
128, 932,//Shift JIS
129, 949,//Hangul
130, 1361,//Johab
134, 936,//GB2312
136, 950,//Big5
238, 1250,//Greek
161, 1253,//Greek
162, 1254,//Turkish
163, 1258,//Vietnamese
177, 1255,//Hebrew
178, 1256, //Arabic
186, 1257,//Baltic
204, 1251,//Russian
222, 874,//Thai
238, 1250,//Eastern European
254, 437,//PC 437
255, 850//OEM
};
WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder ) :
m_PieceTable(NULL), WordDocumentStream(NULL), TableStream(NULL), DataStream(NULL), FIB(NULL),
Text(NULL), RevisionAuthorTable(NULL), FontTable(NULL), BookmarkNames(NULL), AutoTextNames(NULL),
@ -55,12 +92,15 @@ namespace DocFileFormat
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL),
AnnotStartPlex(NULL), AnnotEndPlex(NULL), encryptionHeader(NULL)
{
m_pCallFunc = pCallFunc;
m_sTempFolder = sTempFolder;
m_pCallFunc = pCallFunc;
m_sTempFolder = sTempFolder;
m_pStorage = NULL;
officeArtContent = NULL;
bOlderVersion = false;
m_pStorage = NULL;
officeArtContent = NULL;
bOlderVersion = false;
bDocumentCodePage = false;
nDocumentCodePage = ENCODING_WINDOWS_1250;
}
WordDocument::~WordDocument()
@ -178,8 +218,6 @@ namespace DocFileFormat
m_pStorage->GetStream (L"SummaryInformation", &Summary);
m_pStorage->GetStream (L"DocumentSummaryInformation", &DocSummary);
document_code_page = ENCODING_WINDOWS_1250;
if ((Summary) && (Summary->size() > 0))
{
@ -188,7 +226,10 @@ namespace DocFileFormat
int document_code_page1 = summary_info.GetCodePage(); //from software last open
if (document_code_page1 > 0)
document_code_page = document_code_page1;
{
nDocumentCodePage = document_code_page1;
bDocumentCodePage = true;
}
}
if ((DocSummary) && (DocSummary->size() > 0))
{
@ -197,12 +238,18 @@ namespace DocFileFormat
int document_code_page2 = doc_summary_info.GetCodePage();
if (document_code_page2 > 0)
document_code_page = document_code_page2;
{
nDocumentCodePage = document_code_page2;
bDocumentCodePage = true;
}
}
if (!bOlderVersion)
document_code_page = ENCODING_UTF16;
{
nDocumentCodePage = ENCODING_UTF16;
bDocumentCodePage = true;
}
FIB->m_CodePage = document_code_page;
FIB->m_CodePage = nDocumentCodePage;
//-------------------------------------------------------------------------------------------------
try
{
@ -353,6 +400,31 @@ namespace DocFileFormat
return AVS_ERROR_FILEFORMAT;
}
}
if (!bDocumentCodePage && FontTable)
{
std::unordered_map<int, int> fonts_charsets;
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin();!bDocumentCodePage && iter != FontTable->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
if (!font) continue;
if (fonts_charsets.find(font->chs) == fonts_charsets.end())
{
fonts_charsets.insert(std::make_pair(font->chs, font->ff));
for (int i = 0 ; i < sizeof(aCodePages) / 2; i++)
{
if (aCodePages[i][0] == font->chs && font->chs != 0)
{
nDocumentCodePage = aCodePages[i][1];
bDocumentCodePage = true;
break;
}
}
}
}
}
if (FIB->m_FibWord97.lcbClx > 0)
{
@ -371,7 +443,7 @@ namespace DocFileFormat
WordDocumentStream->read (bytes, cb);
Text = new std::vector<wchar_t>();
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, document_code_page);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, nDocumentCodePage);
RELEASEARRAYOBJECTS(bytes);
}
@ -487,7 +559,7 @@ namespace DocFileFormat
//std::list<std::string> listStream = storageIn->entries();
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); ++it)
//{
// if (storageIn->isDirectory(*it))
// {
@ -531,7 +603,7 @@ namespace DocFileFormat
std::list<std::wstring> entries, entries_files, entries_dir;
entries = storageIn->entries_with_prefix( path );
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
{
std::wstring name = *it;
std::wstring fullname = path + name;

View File

@ -69,7 +69,6 @@ namespace DocFileFormat
{
class WordDocument: public IVisitable
{
/*Mapping classes with direct access to the Word Document.*/
friend class FootnotesMapping;
friend class EndnotesMapping;
friend class CommentsMapping;
@ -98,7 +97,8 @@ namespace DocFileFormat
long LoadDocument (const std::wstring & fileName, const std::wstring & password);
bool bOlderVersion;
int document_code_page;
int nDocumentCodePage;
bool bDocumentCodePage;
inline StructuredStorageReader* GetStorage() const
{

View File

@ -67,7 +67,7 @@
Name="VCLinkerTool"
AdditionalDependencies="Urlmon.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMT.lib"
IgnoreDefaultLibraryNames=""
IgnoreEmbeddedIDL="true"
GenerateDebugInformation="true"
SubSystem="1"

View File

@ -372,7 +372,7 @@ public:
class rPr
{
private:
std::map<std::wstring, int>& m_mapFonts;
boost::unordered_map<std::wstring, int>& m_mapFonts;
public:
bool Bold;
bool Italic;
@ -445,7 +445,7 @@ public:
bool bDoNotWriteNullProp;
public:
rPr(std::map<std::wstring, int>& mapFonts) : m_mapFonts(mapFonts)
rPr(boost::unordered_map<std::wstring, int>& mapFonts) : m_mapFonts(mapFonts)
{
Reset();
@ -1787,8 +1787,8 @@ w15:paraIdParent=\"" + pComment->m_sParaIdParent + L"\" w15:done=\"" + sDone + L
};
class CComments
{
std::map<int, CComment*> m_mapComments;
std::map<std::wstring, CComment*> m_mapAuthors;
boost::unordered_map<int, CComment*> m_mapComments;
boost::unordered_map<std::wstring, CComment*> m_mapAuthors;
public:
IdCounter m_oFormatIdCounter;
IdCounter m_oParaIdCounter;
@ -1798,7 +1798,7 @@ public:
}
~CComments()
{
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
delete it->second;
}
@ -1822,7 +1822,7 @@ public:
CComment* get(int nInd)
{
CComment* pRes = NULL;
std::map<int, CComment*>::const_iterator pair = m_mapComments.find(nInd);
boost::unordered_map<int, CComment*>::const_iterator pair = m_mapComments.find(nInd);
if(m_mapComments.end() != pair)
pRes = pair->second;
return pRes;
@ -1834,7 +1834,7 @@ public:
std::wstring writeContent()
{
std::wstring sRes;
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
sRes += (it->second->writeTemplates(CComment::writeContent));
}
@ -1843,7 +1843,7 @@ public:
std::wstring writeContentExt()
{
std::wstring sRes;
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
sRes += (it->second->writeTemplates(CComment::writeContentExt));
}
@ -1852,7 +1852,7 @@ public:
std::wstring writePeople()
{
std::wstring sRes;
for (std::map<std::wstring, CComment*>::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it)
for (boost::unordered_map<std::wstring, CComment*>::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it)
{
sRes += (it->second->writePeople(it->second));
}

View File

@ -35,6 +35,7 @@
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include <boost/unordered_map.hpp>
namespace Writers
{
@ -48,7 +49,7 @@ namespace Writers
CApplicationFonts m_oApplicationFonts;
CFontManager* m_pFontManager;
public:
std::map<std::wstring, int> m_mapFonts;
boost::unordered_map<std::wstring, int> m_mapFonts;
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
{
@ -81,7 +82,7 @@ namespace Writers
bool bCalibri = false;
bool bTimes = false;
bool bCambria = false;
for (std::map<std::wstring, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
for (boost::unordered_map<std::wstring, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
{
const std::wstring& sFontName = it->first;
if(_T("Calibri") == sFontName)

View File

@ -3024,18 +3024,18 @@ namespace BinDocxRW
m_oBcw.m_oStream.EndRecord();
}
void Write(std::list<OOX::WritingElement*> & aElems)
void Write(std::vector<OOX::WritingElement*> & aElems)
{
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteDocumentContent(aElems);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteDocumentContent(const std::list<OOX::WritingElement*> & aElems)
void WriteDocumentContent(const std::vector<OOX::WritingElement*> & aElems)
{
int nCurPos = 0;
for ( std::list<OOX::WritingElement*>::const_iterator it = aElems.begin(); it != aElems.end(); it++)
for ( size_t i = 0; i < aElems.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = aElems[i];
switch(item->getType())
{
@ -3184,12 +3184,13 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteParagraphContent(const std::list<OOX::WritingElement*> & content, bool bHyperlink = false)
void WriteParagraphContent(const std::vector<OOX::WritingElement*> & content, bool bHyperlink = false)
{
int nCurPos = 0;
for(std::list<OOX::WritingElement*>::const_iterator it = content.begin(); it != content.end(); it++)
{
OOX::WritingElement* item = *it;
for ( size_t i = 0; i < content.size(); ++i)
{
OOX::WritingElement* item = content[i];
switch (item->getType())
{
case OOX::et_w_fldSimple:
@ -3836,8 +3837,8 @@ namespace BinDocxRW
bool bWasText = false;
int nRecordType = 0;
std::list<OOX::WritingElement*>::iterator nIndexStart = pRun->m_arrItems.begin();
std::list<OOX::WritingElement*>::iterator nIndexEnd = pRun->m_arrItems.end();
std::vector<OOX::WritingElement*>::iterator nIndexStart = pRun->m_arrItems.begin();
std::vector<OOX::WritingElement*>::iterator nIndexEnd = pRun->m_arrItems.end();
if (bMathRun)
nRecordType = c_oSer_OMathContentType::Run;
@ -3845,9 +3846,9 @@ namespace BinDocxRW
nRecordType = c_oSerParType::Run;
//Разбиваем массив по знаку et_w_sym
for (std::list<OOX::WritingElement*>::iterator it = pRun->m_arrItems.begin(); it != nIndexEnd; it++)
for (std::vector<OOX::WritingElement*>::iterator it = nIndexStart; it != nIndexEnd; ++it)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = (*it);
if(OOX::et_w_sym == item->getType())
{
@ -3859,7 +3860,7 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
nCurPos = m_oBcw.WriteItemStart(nRecordType);
std::list<OOX::WritingElement*>::iterator it_next = it; it_next++;
std::vector<OOX::WritingElement*>::iterator it_next = it; it_next++;
WritePreparedRun( pRun, bHyperlink, it, it_next);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
nIndexStart = it; nIndexStart++;
@ -3874,11 +3875,11 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteMathArgNodes(const std::list<OOX::WritingElement*>& m_arrItems)
void WriteMathArgNodes(const std::vector<OOX::WritingElement*>& arrItems)
{
for(std::list<OOX::WritingElement*>::const_iterator it = m_arrItems.begin(); it != m_arrItems.end(); it++)
{
OOX::WritingElement* item = *it;
for (size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos = 0;
@ -4046,7 +4047,7 @@ namespace BinDocxRW
LONG lCol = 0;
//TODO убрать, тк при отсутствии m:mcs, к-во столбцов должно разруливаться динамически в скрипте
for (std::list<OOX::WritingElement*>::iterator jt = pMatrix->m_arrItems.begin(); jt != pMatrix->m_arrItems.end(); jt++)
for (std::vector<OOX::WritingElement*>::iterator jt = pMatrix->m_arrItems.begin(); jt != pMatrix->m_arrItems.end(); jt++)
{
OOX::WritingElement* item = *jt;
if (item->getType() == OOX::et_m_mr)
@ -4496,11 +4497,11 @@ namespace BinDocxRW
}
m_oBcw.WriteItemEnd(nCurPos);
}
void WriteMathDelimiter(const std::list<OOX::WritingElement*> & arrItems, LONG &lColumn)
void WriteMathDelimiter(const std::vector<OOX::WritingElement*> & arrItems, LONG &lColumn)
{
for(std::list<OOX::WritingElement*>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos = 0;
@ -4616,11 +4617,12 @@ namespace BinDocxRW
}
m_oBcw.WriteItemEnd(nCurPos);
}
void WriteMathEqArr(const std::list<OOX::WritingElement*> & arrItems, LONG& lRow)
void WriteMathEqArr(const std::vector<OOX::WritingElement*> & arrItems, LONG& lRow)
{
for(std::list<OOX::WritingElement*>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
{
OOX::WritingElement* item = *it;
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos = 0;
switch(eType)
@ -4844,12 +4846,13 @@ namespace BinDocxRW
}
m_oBcw.WriteItemEnd(nCurPos);
}
void WriteMathMatrix(const std::list<OOX::WritingElement*> & arrItems, LONG &lRow, LONG &lCol)
void WriteMathMatrix(const std::vector<OOX::WritingElement*> & arrItems, LONG &lRow, LONG &lCol)
{
bool bColumn = false;
for(std::list<OOX::WritingElement*>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
{
OOX::WritingElement* item = *it;
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos = 0;
switch(eType)
@ -4946,9 +4949,9 @@ namespace BinDocxRW
{
int nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathBottomNodesType::Mcs);
for(std::list<OOX::WritingElement*>::const_iterator it = pMcs.m_arrItems.begin(); it != pMcs.m_arrItems.end(); it++)
for(size_t i = 0; i < pMcs.m_arrItems.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = pMcs.m_arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos1 = 0;
@ -5007,11 +5010,12 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
void WriteMathMr(const std::list<OOX::WritingElement*> & arrItems)
void WriteMathMr(const std::vector<OOX::WritingElement*> & arrItems)
{
for(std::list<OOX::WritingElement*>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
{
OOX::WritingElement* item = *it;
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos = 0;
if (eType == OOX::et_m_e)
@ -5089,11 +5093,12 @@ namespace BinDocxRW
WriteMathArgNodes(pOMath.m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
}
void WriteMathOMathPara(const std::list<OOX::WritingElement*> & arrItems)
void WriteMathOMathPara(const std::vector<OOX::WritingElement*> & arrItems)
{
for(std::list<OOX::WritingElement*>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
{
OOX::WritingElement* item = *it;
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = arrItems[i];
OOX::EElementType eType = item->getType();
int nCurPos = 0;
if (eType == OOX::et_m_oMath)
@ -5505,7 +5510,7 @@ namespace BinDocxRW
}
m_oBcw.WriteItemEnd(nCurPos);
}
void WritePreparedRun(OOX::Logic::CRun *pRun, bool bHyperlink, std::list<OOX::WritingElement*>::iterator &start, std::list<OOX::WritingElement*>::iterator &end)
void WritePreparedRun(OOX::Logic::CRun *pRun, bool bHyperlink, std::vector<OOX::WritingElement*>::iterator &start, std::vector<OOX::WritingElement*>::iterator &end)
{
if (!pRun) return;
@ -5543,12 +5548,12 @@ namespace BinDocxRW
//Content пишется начиная от индекса nIndexStart и заканчивая предшествующим элементом для nIndexStop
nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::Content);
WriteRunContent(pRun->m_arrItems, start, end, bHyperlink);
WriteRunContent( start, end, bHyperlink);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
void WriteRunContent(std::list<OOX::WritingElement*>& m_arrItems, std::list<OOX::WritingElement*>::iterator &start, std::list<OOX::WritingElement*>::iterator &end, bool bHyperlink = false)
void WriteRunContent(std::vector<OOX::WritingElement*>::iterator &start, std::vector<OOX::WritingElement*>::iterator &end, bool bHyperlink = false)
{
for ( std::list<OOX::WritingElement*>::iterator it = start; it != end; it++ )
for ( std::vector<OOX::WritingElement*>::iterator it = start; it != end; ++it )
{
OOX::WritingElement* item = *it;
switch (item->getType())
@ -6533,13 +6538,15 @@ namespace BinDocxRW
RELEASEOBJECT(pTblPr);
}
bool ValidateRow(const std::list<OOX::WritingElement *> & arrItems)
bool ValidateRow(const std::vector<OOX::WritingElement *> & arrItems)
{
//Проверяем чтобы не все ячейки в ряду были вертикально замержены
bool bRes = true;
for(std::list<OOX::WritingElement*>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
{
OOX::WritingElement* item = *it;
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = arrItems[i];
if(OOX::et_w_tc == item->getType())
{
OOX::Logic::CTc* tc = static_cast<OOX::Logic::CTc*>(item);
@ -6581,11 +6588,12 @@ namespace BinDocxRW
}
return false;
}
void GetTableSize(std::list<OOX::WritingElement *> & rows, int& nRows, int& nCols, OOX::Logic::CTableProperty** ppTblPr)
void GetTableSize(std::vector<OOX::WritingElement *> & rows, int& nRows, int& nCols, OOX::Logic::CTableProperty** ppTblPr)
{
for(std::list<OOX::WritingElement*>::iterator it = rows.begin(); it != rows.end(); it++)
for(size_t i = 0; i < rows.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = rows[i];
if(OOX::et_w_tblPr == item->getType())
{
*ppTblPr = new OOX::Logic::CTableProperty();
@ -6605,8 +6613,7 @@ namespace BinDocxRW
}
else
{
//
rows.erase(it);
rows.erase(rows.begin() + i);
}
}
else if(OOX::et_w_sdt == item->getType())
@ -6632,18 +6639,20 @@ namespace BinDocxRW
}
}
}
int GetColsCount(const std::list<OOX::WritingElement *>& arrItems)
int GetColsCount(const std::vector<OOX::WritingElement *>& arrItems)
{
int nColCount = 0;
for(std::list<OOX::WritingElement *>::const_iterator it = arrItems.begin(); it != arrItems.end(); it++)
for(size_t i = 0; i < arrItems.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = arrItems[i];
if(OOX::et_w_tc == item->getType())
{
nColCount++;
OOX::Logic::CTc* tc = static_cast<OOX::Logic::CTc*>(item);
for(std::list<OOX::WritingElement *>::iterator jt = tc->m_arrItems.begin(); jt != tc->m_arrItems.end(); jt++)
for(std::vector<OOX::WritingElement *>::iterator jt = tc->m_arrItems.begin(); jt != tc->m_arrItems.end(); jt++)
{
OOX::WritingElement* item2 = *jt;
@ -6723,14 +6732,15 @@ namespace BinDocxRW
}
}
void WriteTableContent(std::list<OOX::WritingElement *>& content, OOX::Logic::CTableProperty* pTblPr, int nRows, int nCols)
void WriteTableContent(std::vector<OOX::WritingElement *>& content, OOX::Logic::CTableProperty* pTblPr, int nRows, int nCols)
{
int nCurPos = 0;
int nCurRowIndex = 0;
for(std::list<OOX::WritingElement*>::iterator it = content.begin(); it != content.end(); it++)
for(size_t i = 0; i < content.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = content[i];
if(OOX::et_w_tr == item->getType())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerDocTableType::Row);
@ -6793,14 +6803,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
void WriteRowContent(const std::list<OOX::WritingElement *> & content, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nRows, int nCols)
void WriteRowContent(const std::vector<OOX::WritingElement *> & content, OOX::Logic::CTableProperty* pTblPr, int nCurRowIndex, int nRows, int nCols)
{
int nCurPos = 0;
int nCurColIndex = 0;
for(std::list<OOX::WritingElement*>::const_iterator it = content.begin(); it != content.end(); it++)
{
OOX::WritingElement* item = *it;
for(size_t i = 0; i < content.size(); ++i)
{
OOX::WritingElement* item = content[i];
if(OOX::et_w_tc == item->getType())
{
@ -7200,7 +7210,7 @@ namespace BinDocxRW
if(mapAuthorToUserId.end() != pPair)
pNewCommentWriteTemp->sUserId = pPair->second;
}
for(std::list<OOX::WritingElement*>::iterator jt = pComment->m_arrItems.begin(); jt != pComment->m_arrItems.end(); jt++)
for(std::vector<OOX::WritingElement*>::iterator jt = pComment->m_arrItems.begin(); jt != pComment->m_arrItems.end(); jt++)
{
OOX::WritingElement* pWe = *jt;
@ -7384,9 +7394,10 @@ namespace BinDocxRW
};
void WriteMathPr(const OOX::Logic::CMathPr &pMathPr)
{
for(std::list<OOX::WritingElement*>::const_iterator it = pMathPr.m_arrItems.begin(); it != pMathPr.m_arrItems.end(); it++)
for(size_t i = 0; i < pMathPr.m_arrItems.size(); ++i)
{
OOX::WritingElement* item = *it;
OOX::WritingElement* item = pMathPr.m_arrItems[i];
OOX::EElementType eType = item->getType();
switch(eType)
{
@ -7960,9 +7971,11 @@ namespace BinDocxRW
if(NULL != pParagraph)
{
OOX::Logic::CParagraphProperty* pPr = NULL;
for(std::list<OOX::WritingElement*>::iterator it = pParagraph->m_arrItems.begin(); it != pParagraph->m_arrItems.end(); it++)
for(size_t i = 0; i < pParagraph->m_arrItems.size(); ++i)
{
OOX::WritingElement* we = *it;
OOX::WritingElement* we = pParagraph->m_arrItems[i];
if(OOX::et_w_pPr == we->getType())
{
pPr = static_cast<OOX::Logic::CParagraphProperty*>(we);

View File

@ -127,10 +127,11 @@ namespace BinXlsxRW{
}
ChartWriter::~ChartWriter()
{
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); it++)
for (boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
{
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
for(boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
{
delete itRow->second;
}
@ -143,10 +144,12 @@ namespace BinXlsxRW{
//Sheet
OOX::Spreadsheet::CWorkbook* pWorkbook = oXlsx.CreateWorkbook();
pWorkbook->m_oSheets.Init();
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets = oXlsx.GetWorksheets();
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets = oXlsx.GetWorksheets();
int nSheetId = 1;
OOX::Spreadsheet::CWorksheet* pFirstWorksheet = NULL;
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); it++)
for (boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
{
const std::wstring& sSheetName = it->first;
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(mapWorksheets, sSheetName);
@ -196,7 +199,8 @@ namespace BinXlsxRW{
pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
}
pStyles->m_oNumFmts.Init();
for (std::map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); it++)
for (boost::unordered_map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); ++it)
{
OOX::Spreadsheet::CNumFmt* pNumFmt = new OOX::Spreadsheet::CNumFmt();
pNumFmt->m_oFormatCode.Init();
@ -458,18 +462,22 @@ namespace BinXlsxRW{
//проверяем можем ли создать таблицу
if(m_mapSheets.size() > 0 && m_nRow1 > 0 && m_nRow2 > 0 && m_nCol1 > 0 && m_nCol2 > 0 && m_nRow1 < m_nRow2)
{
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
if(itRows != rows->end())
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
if(itRows != rows->end())
{
std::map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
boost::unordered_map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
std::vector<int> aIndexesCell;
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); it++)
for(boost::unordered_map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); ++it)
{
aIndexesCell.push_back(it->first);
}
std::sort(aIndexesCell.begin(), aIndexesCell.end());
if(m_nCol2 - m_nCol1 + 1 == aIndexesCell.size() && m_nCol1 == aIndexesCell[0] && m_nCol2 == aIndexesCell[aIndexesCell.size() - 1])
std::sort(aIndexesCell.begin(), aIndexesCell.end());
if(m_nCol2 - m_nCol1 + 1 == aIndexesCell.size() && m_nCol1 == aIndexesCell[0] && m_nCol2 == aIndexesCell[aIndexesCell.size() - 1])
{
for(size_t j = 0; j < aIndexesCell.size(); ++j)
{
@ -482,11 +490,12 @@ namespace BinXlsxRW{
}
}
}
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
{
OOX::Spreadsheet::CWorksheet* pWorksheet = NULL;
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator it = mapWorksheets.find(sName);
if (it == mapWorksheets.end())
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator it = mapWorksheets.find(sName);
if (it == mapWorksheets.end())
{
pWorksheet = new OOX::Spreadsheet::CWorksheet();
pWorksheet->m_oSheetFormatPr.Init();
@ -515,32 +524,40 @@ namespace BinXlsxRW{
}
return pWorksheet;
}
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
{
pWorksheet->m_oSheetData.Init();
std::vector<int> aIndexesRow;
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); it++)
for(boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); ++it)
{
aIndexesRow.push_back(it->first);
}
std::sort(aIndexesRow.begin(), aIndexesRow.end());
for(size_t i = 0; i < aIndexesRow.size(); ++i)
std::sort(aIndexesRow.begin(), aIndexesRow.end());
for(size_t i = 0; i < aIndexesRow.size(); ++i)
{
int nIndexRow = aIndexesRow[i];
OOX::Spreadsheet::CRow* pRow = new OOX::Spreadsheet::CRow();
OOX::Spreadsheet::CRow* pRow = new OOX::Spreadsheet::CRow();
pRow->m_oR.Init();
pRow->m_oR->SetValue(nIndexRow);
const std::map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
const boost::unordered_map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
std::vector<int> aIndexesCell;
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); it++)
for(boost::unordered_map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); ++it)
{
aIndexesCell.push_back(it->first);
}
std::sort(aIndexesCell.begin(), aIndexesCell.end());
for(size_t j = 0; j < aIndexesCell.size(); ++j)
for(size_t j = 0; j < aIndexesCell.size(); ++j)
{
int nIndexCell = aIndexesCell[j];
OOX::Spreadsheet::CCell* pCell = cells.at(nIndexCell);
OOX::Spreadsheet::CCell* pCell = cells.at(nIndexCell);
//SharedStrings
if(pCell->m_oValue.IsInit())
{
@ -588,22 +605,24 @@ namespace BinXlsxRW{
}
void ChartWriter::parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format = NULL)
{
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
if(itSheets == m_mapSheets.end())
boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
if(itSheets == m_mapSheets.end())
{
rows = new std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>();
rows = new boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>();
m_mapSheets.insert(std::make_pair(sheet, rows));
}
else
{
rows = itSheets->second;
}
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
std::map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
if(itRows == rows->end())
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
boost::unordered_map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
if(itRows == rows->end())
{
cells = new std::map<int, OOX::Spreadsheet::CCell*>();
cells = new boost::unordered_map<int, OOX::Spreadsheet::CCell*>();
rows->insert(std::make_pair(nRow, cells));
}
else
@ -622,10 +641,12 @@ namespace BinXlsxRW{
//пока добавляем как есть, shared string после записи таблицы
pNewCell->m_oValue.Init();
pNewCell->m_oValue->m_sText = val;
if(NULL != format)
if(NULL != format)
{
int nXfsIndex = m_aXfs.size();
std::map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
boost::unordered_map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
if(itFormat == m_mapFormats.end())
{
m_mapFormats[*format] = nXfsIndex;

View File

@ -33,8 +33,8 @@
#define CHART_WRITER
#include <string>
#include <map>
#include <vector>
#include <boost/unordered_map.hpp>
namespace OOX
{
@ -59,22 +59,25 @@ namespace BinXlsxRW {
class ChartWriter
{
public:
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*> m_mapSheets;
std::map<std::wstring, int> m_mapFormats;
std::vector<OOX::Spreadsheet::CXfs*> m_aXfs;
std::vector<std::wstring> m_aTableNames;
int m_nRow1;
boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*> m_mapSheets;
boost::unordered_map<std::wstring, int> m_mapFormats;
std::vector<OOX::Spreadsheet::CXfs*> m_aXfs;
std::vector<std::wstring> m_aTableNames;
int m_nRow1;
int m_nCol1;
int m_nRow2;
int m_nCol2;
public:
ChartWriter();
ChartWriter();
~ChartWriter();
void toXlsx(OOX::Spreadsheet::CXlsx& oXlsx);
void parseChart(const OOX::Spreadsheet::CT_Chart* pChart);
private:
OOX::Spreadsheet::CWorksheet* toXlsxGetSheet(std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName);
void toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings);
private:
OOX::Spreadsheet::CWorksheet* toXlsxGetSheet(boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName);
void toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings);
void parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format);
OOX::Spreadsheet::CCell* parseCreateCell(const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format);
void parseStrRef(const OOX::Spreadsheet::CT_StrRef* pStrRef, bool bUpdateRange, const wchar_t* cRangeName);

View File

@ -68,6 +68,7 @@
ShowProgress="0"
Version=""
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"

View File

@ -407,11 +407,11 @@ namespace formulasconvert {
std::wstring is_forbidden(const std::wstring & formula)
{
std::wstring result = formula;
std::map<std::wstring, std::wstring> forbidden_formulas;
std::map<std::wstring, std::wstring> forbidden_formulas;
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); it++)
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
{
if (boost::algorithm::contains(formula, it->first))
{

View File

@ -335,8 +335,8 @@ namespace internal
inline bool starts_with_bom (octet_iterator it, octet_iterator end)
{
return (
((it != end) && (internal::mask8(*it++)) == bom[0]) &&
((it != end) && (internal::mask8(*it++)) == bom[1]) &&
((it != end) && (internal::mask8(*++it)) == bom[0]) &&
((it != end) && (internal::mask8(*++it)) == bom[1]) &&
((it != end) && (internal::mask8(*it)) == bom[2])
);
}
@ -346,8 +346,8 @@ namespace internal
inline bool is_bom (octet_iterator it)
{
return (
(internal::mask8(*it++)) == bom[0] &&
(internal::mask8(*it++)) == bom[1] &&
(internal::mask8(*++it)) == bom[0] &&
(internal::mask8(*++it)) == bom[1] &&
(internal::mask8(*it)) == bom[2]
);
}

View File

@ -66,7 +66,7 @@ namespace utf8
case 1:
break;
case 2:
it++;
++it;
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break;
case 3:

View File

@ -1320,7 +1320,7 @@ void docx_conversion_context::start_changes()
text_tracked_context_.dumpTcPr_.clear();
text_tracked_context_.dumpTblPr_.clear();
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); ++it)
{
text_tracked_context::_state &state = it->second;
@ -1413,7 +1413,7 @@ void docx_conversion_context::end_changes()
{
if (process_comment_) return;
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); ++it)
{
text_tracked_context::_state &state = it->second;

View File

@ -103,7 +103,7 @@ public:
reset_fill(l.fill_);
//floor_.content_= l;
}
void set_legend(odf_reader::chart::simple & l)
void set_legend(odf_reader::chart::legend & l)
{
reset_fill(l.fill_);
legend_.content_= l;

View File

@ -52,10 +52,9 @@ void oox_chart_legend::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:legend")
{
CP_XML_NODE(L"c:legendPos")
{
CP_XML_ATTR(L"val", "r");// "b" | "l" | "r" | "t"// == bottom left right top
CP_XML_ATTR(L"val", content_.position);
}
layout_.oox_serialize(CP_XML_STREAM());

View File

@ -48,7 +48,7 @@ public:
void oox_serialize(std::wostream & _Wostream);
odf_reader::chart::simple content_;
odf_reader::chart::legend content_;
private:
cpdoccore::oox::oox_layout layout_; //layout (Layout) §21.2.2.88

View File

@ -71,7 +71,7 @@ void oox_data_labels::oox_serialize(std::wostream & _Wostream)
{
oox_serialize_default_text(CP_XML_STREAM(), textPr_);
for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); it++)
for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); ++it)
{
CP_XML_NODE(L"c:dLbl")
{

View File

@ -194,7 +194,7 @@ private:
std::map<size_t, size_t> count;
size_t max_size = 0;
for (std::map<size_t, size_t>::iterator it = map.begin(); it != map.end(); it++)
for (std::map<size_t, size_t>::iterator it = map.begin(); it != map.end(); ++it)
{
std::map<size_t, size_t>::iterator pFind = count.find(it->second);
if (pFind != count.end())
@ -215,7 +215,7 @@ private:
size_t found = 0;
for (std::map<size_t, size_t>::iterator it = count.begin() ; it != count.end(); it++)
for (std::map<size_t, size_t>::iterator it = count.begin() ; it != count.end(); ++it)
{
if (it->second == max_size)
{
@ -229,16 +229,16 @@ private:
{
if (it->second != found)
{
std::map<size_t, size_t>::iterator del = it; it++;
std::map<size_t, size_t>::iterator del = it; ++it;
map.erase(del);
}
else it++;
else ++it;
}
return true;
}
void clear_header_map2(std::map<size_t, size_t> & map, std::map<size_t, size_t> & map_by)
{//отсев тех кто во втором
for (std::map<size_t, size_t>::iterator it = map_by.begin() ; it != map_by.end(); it++)
for (std::map<size_t, size_t>::iterator it = map_by.begin() ; it != map_by.end(); ++it)
{
std::map<size_t, size_t>::iterator pFind = map.find(it->second);
if (pFind != map.end())

View File

@ -253,7 +253,7 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; it++)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
}
@ -271,7 +271,7 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; it++)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->filter)
{

View File

@ -762,6 +762,28 @@ void process_build_object::visit(const chart_footer& val)
void process_build_object::visit(const chart_legend& val)
{
object_odf_context_.legend_.bEnabled = true;
object_odf_context_.legend_.position = L"r";
if (val.attlist_.chart_legend_position_)
{
std::wstring pos = val.attlist_.chart_legend_position_.get();
if ( pos == L"bottom") object_odf_context_.legend_.position = L"b";
if ( pos == L"start") object_odf_context_.legend_.position = L"l";
if ( pos == L"top") object_odf_context_.legend_.position = L"t";
if ( pos == L"top-end") object_odf_context_.legend_.position = L"tr";
if ( pos == L"top-start") object_odf_context_.legend_.position = L"tl";
if ( pos == L"bottom-start") object_odf_context_.legend_.position = L"bl";
if ( pos == L"bottom-end") object_odf_context_.legend_.position = L"br";
}
if (val.attlist_.chart_legend_align_)
{
std::wstring align = val.attlist_.chart_legend_align_.get();
//if ( pos == L"start") object_odf_context_.legend_.align = L"b";
//if ( pos == L"center") object_odf_context_.legend_.align = L"l";
//if ( pos == L"end") object_odf_context_.legend_.align = L"t";
}
ApplyChartProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.properties_);
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.graphic_properties_,object_odf_context_.legend_.fill_);

View File

@ -188,7 +188,7 @@ public:
office_element_ptr_array title_odf_context_;
chart::title sub_title_;
chart::simple legend_;
chart::legend legend_;
chart::plot_area plot_area_;
chart::simple wall_;

View File

@ -76,6 +76,7 @@ namespace chart {
struct simple
{
simple() : bEnabled(false) {}
bool bEnabled;
std::vector<_property> properties_;
std::vector<_property> text_properties_;
@ -92,6 +93,11 @@ namespace chart {
treadline(){bEquation = false; bREquation = false;}
};
struct legend : public simple
{
std::wstring position;
std::wstring align;
};
struct plot_area : public simple
{
std::wstring cell_range_address_;

View File

@ -58,6 +58,9 @@ std::wostream & operator << (std::wostream & _Wostream, const calcext_type & _Va
break;
case calcext_type::Minimum:
_Wostream << L"minimum";
break;
case calcext_type::Percentile:
_Wostream << L"percentile";
break;
default:
break;
@ -84,6 +87,8 @@ calcext_type calcext_type::parse(const std::wstring & Str)
return calcext_type( Minimum );
else if (tmp == L"formula")
return calcext_type( Formula );
else if (tmp == L"percentile")
return calcext_type( Percentile );
else
{
return calcext_type( Number );

View File

@ -49,7 +49,8 @@ public:
Minimum,
AutoMaximum,
AutoMinimum,
Formula
Formula,
Percentile
};
calcext_type() {}

View File

@ -72,7 +72,6 @@ class common_chart_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(std::wstring) chart_style_name_;
};
@ -117,7 +116,6 @@ class chart_title_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(std::wstring) table_cell_range_;
odf_types::common_draw_position_attlist common_draw_position_attlist_;
common_chart_attlist common_attlist_;
@ -194,13 +192,13 @@ class chart_legend_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(std::wstring) chart_legend_position_;
_CP_OPT(std::wstring) chart_legend_align_;
odf_types::common_draw_position_attlist common_draw_position_attlist_;
_CP_OPT(std::wstring) style_legend_expansion_;
_CP_OPT(double) style_legend_expansion_aspect_ratio_;
common_chart_attlist common_attlist_;
odf_types::common_draw_position_attlist common_draw_position_attlist_;
common_chart_attlist common_attlist_;
};

View File

@ -67,10 +67,11 @@ void table_format_properties::add_attributes( const xml::attributes_wc_ptr & Att
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"style:may-break-between-rows", style_may_break_between_rows_);
CP_APPLY_ATTR(L"table:align", table_align_);
CP_APPLY_ATTR(L"table:border-model", table_border_model_);
CP_APPLY_ATTR(L"table:display", table_display_);
CP_APPLY_ATTR(L"tableooo:tab-color", tableooo_tab_color_);
CP_APPLY_ATTR(L"table:align", table_align_);
CP_APPLY_ATTR(L"table:border-model", table_border_model_);
CP_APPLY_ATTR(L"table:display", table_display_);
CP_APPLY_ATTR(L"tableooo:tab-color", tableooo_tab_color_);
CP_APPLY_ATTR(L"style:use-optimal-column-width",style_use_optimal_column_width_);
}
bool table_format_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
@ -94,17 +95,22 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (style_rel_width_)
{
int w_w = (int)(0.5 + 50.0 * style_rel_width_->get_value());
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"" << w_w << "\" />";
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"" << w_w << "\"/>";
}
else if (style_width_)
else if (style_use_optimal_column_width_)
{
_tblPr << L"<w:tblW w:type=\"auto\" w:w=\"0\"/>";
}
else if (style_width_)
{
int w_w = (int)(0.5 + 20.0 * style_width_->get_value_unit(length::pt));
if (w_w > 31680)w_w = 31680;
_tblPr << L"<w:tblW w:type=\"dxa\" w:w=\"" << w_w << "\" />";
_tblPr << L"<w:tblW w:type=\"dxa\" w:w=\"" << w_w << "\"/>";
}
else
{
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"5000\" />";
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"5000\"/>";
}
if (common_break_attlist_.fo_break_before_)
@ -127,23 +133,26 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
{
odf_types::length indent = common_horizontal_margin_attlist_.fo_margin_left_->get_length();
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\" />";
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\"/>";
}
}
else //if (table_align_->get_type() == table_align::Center)
w_val = boost::lexical_cast<std::wstring>(*table_align_);
_tblPr << L"<w:jc w:val=\"" << w_val << "\" />";
_tblPr << L"<w:jc w:val=\"" << w_val << "\"/>";
}
_tblPr << "<w:tblLayout w:type=\"fixed\" />";
if (!style_use_optimal_column_width_)
{
_tblPr << "<w:tblLayout w:type=\"fixed\"/>";
}
if (common_background_color_attlist_.fo_background_color_)
{
const std::wstring w_fill = (common_background_color_attlist_.fo_background_color_->get_type() == background_color::Enabled
? common_background_color_attlist_.fo_background_color_->get_color().get_hex_value() : L"auto");
_tblPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\" />";
_tblPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\"/>";
}
}

View File

@ -79,7 +79,6 @@ public:
_CP_OPT(odf_types::length) style_width_;
_CP_OPT(odf_types::percent) style_rel_width_;
office_element_ptr style_background_image_;
_CP_OPT(bool) style_may_break_between_rows_;
_CP_OPT(odf_types::border_model) table_border_model_;
@ -87,6 +86,8 @@ public:
_CP_OPT(bool) table_display_;
_CP_OPT(odf_types::color) tableooo_tab_color_;
_CP_OPT(odf_types::Bool) style_use_optimal_column_width_; //not specification
office_element_ptr style_background_image_;
};
class style_table_properties : public office_element_impl<style_table_properties>

View File

@ -337,23 +337,6 @@ void table_columns_and_groups::add_child_element( xml::sax * Reader, const std::
}
else
not_applicable_element(L"table-columns-and-groups", Reader, Ns, Name);
/*
if (CP_CHECK_NAME(L"table", L"table-column-group") && type_ != 1)
{
type_ = 0;
CP_CREATE_ELEMENT_SIMPLE(table_table_column_group_);
}
else if (( CP_CHECK_NAME(L"table", L"table-columns") ||
CP_CHECK_NAME(L"table", L"table-column") ||
CP_CHECK_NAME(L"table", L"table-header-columns") )
&& type_ != 0)
{
type_ = 1;
table_columns_no_group_.add_child_element(Reader, Ns, Name, Context);
}
else
not_applicable_element(L"table-columns-and-groups", Reader, Ns, Name);
*/
}
//////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -164,7 +164,6 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
if (inst && inst->content())
inst->content()->docx_convert(Context);
Context.get_styles_context().docx_serialize_table_style(_Wostream, Context.get_text_tracked_context().dumpTblPr_);
_Wostream << L"<w:tblGrid>";

View File

@ -32,17 +32,14 @@
// ASCOfficeOdfFileWTest.cpp : Defines the entry point for the console application.
//
#include "../../Common/OfficeFileFormatChecker.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
#include <string>
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/common/File.h"
#include "../source/Oox2OdfConverter/Oox2OdfConverter.h"
@ -52,81 +49,31 @@
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
std::wstring DetectTypeDocument(const std::wstring & pathOOX)
HRESULT convert_single(std::wstring srcFileName)
{
std::wstring sRes;
COfficeFileFormatChecker fileChecker(srcFileName);
NSFile::CFileBinary file;
std::wstring dstPath = srcFileName;// + ....
std::wstring fileContentType = pathOOX + FILE_SEPARATOR_STR + L"[Content_Types].xml";
if (file.OpenFile(fileContentType) ==false) return sRes;
DWORD nBufferSize = min (file.GetFileSize(), 10000);
BYTE *pBuffer = new BYTE[nBufferSize];
file.ReadFile(pBuffer, nBufferSize, nBufferSize);
file.CloseFile();
if (pBuffer != NULL)
std::wstring type;
switch(fileChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"text"; break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: dstPath += L"-my.ods"; type = L"spreadsheet"; break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTM: dstPath += L"-my.odp"; type = L"presentation"; break;
const char *docxFormatLine = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
const char *dotxFormatLine = "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml";
const char *docmFormatLine = "application/vnd.ms-word.document.macroEnabled.main+xml";
const char *dotmFormatLine = "application/vnd.ms-word.template.macroEnabledTemplate.main+xml";
const char *xlsxFormatLine = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
const char *xltxFormatLine = "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml";
const char *xlsmFormatLine = "application/vnd.ms-excel.sheet.macroEnabled.main+xml";
const char *xltmFormatLine = "application/vnd.ms-excel.template.macroEnabled.main+xml";
const char *pptxFormatLine = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
const char *ppsxFormatLine = "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml";
const char *potxFormatLine = "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml";
const char *pptmFormatLine = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml";
const char *ppsmFormatLine = "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml";
const char *potmFormatLine = "application/vnd.ms-powerpoint.template.macroEnabled.main+xml";
std::string strContentTypes((char*)pBuffer, nBufferSize);
int res = 0;
if ( (res = strContentTypes.find(docxFormatLine))>0 || (res = strContentTypes.find(dotxFormatLine))>0 ||
(res = strContentTypes.find(docmFormatLine))>0 || (res = strContentTypes.find(dotmFormatLine))>0)
{
sRes = L"text";
}
else if ((res = strContentTypes.find(xlsxFormatLine))>0 || (res = strContentTypes.find(xltxFormatLine))>0 ||
(res = strContentTypes.find(xlsmFormatLine))>0 || (res = strContentTypes.find(xltmFormatLine))>0)
{
sRes = L"spreadsheet";
}
else if ((res = strContentTypes.find(pptxFormatLine) > 0) || /*(res = strContentTypes.find(ppsxFormatLine))>0 ||*/
(res = strContentTypes.find(potxFormatLine))>0 || (res = strContentTypes.find(pptmFormatLine))>0 ||
(res = strContentTypes.find(ppsmFormatLine))>0 || (res = strContentTypes.find(potmFormatLine))>0 ||
(res = strContentTypes.find(ppsxFormatLine)) >0 )
{
sRes = L"presentation";
}
delete []pBuffer;
pBuffer = NULL;
default:
return S_FALSE;
}
return sRes;
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3) return 0;
//------------------------------------------------------------------------------------------
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argv[2];
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
std::wstring srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
@ -137,8 +84,6 @@ int _tmain(int argc, _TCHAR* argv[])
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
return S_FALSE;
std::wstring type = DetectTypeDocument(srcTempPath);
Oox2Odf::Converter converter(srcTempPath, type, L"C:\\Windows\\Fonts", NULL);
converter.convert();
@ -155,3 +100,32 @@ int _tmain(int argc, _TCHAR* argv[])
return 0;
}
HRESULT convert_directory(std::wstring pathName)
{
HRESULT hr = S_OK;
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
for (size_t i = 0; i < arFiles.size(); i++)
{
convert_single(arFiles[i]);
}
return S_OK;
}
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = -1;
if (NSFile::CFileBinary::Exists(argv[1]))
{
hr = convert_single(argv[1]);
}
else if (NSDirectory::Exists(argv[1]))
{
hr = convert_directory(argv[1]);
}
return hr;
}

View File

@ -49,6 +49,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
ProgramDataBaseFileName="$(IntDir)\OdfFileWriterTest.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
@ -66,7 +67,7 @@
Name="VCLinkerTool"
AdditionalDependencies="&#x0D;&#x0A;Rpcrt4.lib"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
@ -450,6 +451,14 @@
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/bigobj"
/>
</FileConfiguration>
</File>
</Filter>
</Filter>

View File

@ -140,7 +140,7 @@ void calcext_data_bar::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
calcext_data_bar_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < content_.size(); i++)
{
@ -170,6 +170,7 @@ void calcext_color_scale::serialize(std::wostream & _Wostream)
{
for (size_t i = 0; i < content_.size(); i++)
{
if (!content_[i]) continue;
content_[i]->serialize(CP_XML_STREAM());
}
}
@ -194,7 +195,7 @@ void calcext_icon_set::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
calcext_icon_set_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < content_.size(); i++)
{
@ -206,8 +207,8 @@ void calcext_icon_set::serialize(std::wostream & _Wostream)
// calcext_formatting_entry
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * calcext_formatting_entry::ns = L"calcext";
const wchar_t * calcext_formatting_entry::name = L"formatting-entry";
const wchar_t * calcext_formatting_entry::ns = L"calcext";
const wchar_t * calcext_formatting_entry::name = L"formatting-entry";
void calcext_formatting_entry::serialize(std::wostream & _Wostream)
{
@ -223,8 +224,8 @@ void calcext_formatting_entry::serialize(std::wostream & _Wostream)
// calcext_color_scale_entry
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * calcext_color_scale_entry::ns = L"calcext";
const wchar_t * calcext_color_scale_entry::name = L"color_scale_entry";
const wchar_t * calcext_color_scale_entry::ns = L"calcext";
const wchar_t * calcext_color_scale_entry::name = L"color-scale-entry";
void calcext_color_scale_entry::serialize(std::wostream & _Wostream)
{
@ -240,7 +241,7 @@ void calcext_color_scale_entry::serialize(std::wostream & _Wostream)
}
// calcext_condition
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * calcext_condition::ns = L"calcext";
const wchar_t * calcext_condition::ns = L"calcext";
const wchar_t * calcext_condition::name = L"condition";
void calcext_condition::serialize(std::wostream & _Wostream)
@ -249,7 +250,7 @@ void calcext_condition::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
calcext_condition_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
}
}
}
@ -264,7 +265,7 @@ void calcext_date_is::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
calcext_date_is_attr_.serialize(CP_GET_XML_NODE());
attr_.serialize(CP_GET_XML_NODE());
}
}
}

View File

@ -88,7 +88,7 @@ public:
};
//////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief calcext:color-scale-entry
/// calcext:color-scale-entry
class calcext_color_scale_entry : public office_element_impl<calcext_color_scale_entry>
{
public:
@ -104,13 +104,13 @@ public:
virtual void serialize(std::wostream & _Wostream);
_CP_OPT(odf_types::color) calcext_color_;
_CP_OPT(std::wstring) calcext_value_;
_CP_OPT(std::wstring) calcext_value_;
_CP_OPT(odf_types::calcext_type) calcext_type_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_color_scale_entry);
/// \brief calcext:formatting-entry
/// calcext:formatting-entry
class calcext_formatting_entry : public office_element_impl<calcext_formatting_entry>
{
public:
@ -125,13 +125,13 @@ public:
virtual void serialize(std::wostream & _Wostream);
_CP_OPT(std::wstring) calcext_value_;
_CP_OPT(odf_types::calcext_type) calcext_type_;
_CP_OPT(std::wstring) calcext_value_;
_CP_OPT(odf_types::calcext_type) calcext_type_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_formatting_entry);
/// \brief calcext:icon-set
/// calcext:icon-set
class calcext_icon_set : public office_element_impl<calcext_icon_set>
{
public:
@ -146,15 +146,13 @@ public:
virtual void serialize(std::wostream & _Wostream);
calcext_icon_set_attr calcext_icon_set_attr_;
private:
office_element_ptr_array content_;//entries
calcext_icon_set_attr attr_;
office_element_ptr_array content_;//entries
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_icon_set);
/// \brief calcext:data-bar
/// calcext:data-bar
class calcext_data_bar: public office_element_impl<calcext_data_bar>
{
public:
@ -169,14 +167,12 @@ public:
virtual void serialize(std::wostream & _Wostream);
calcext_data_bar_attr calcext_data_bar_attr_;
private:
office_element_ptr_array content_;//entries
calcext_data_bar_attr attr_;
office_element_ptr_array content_;//entries
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_data_bar)
/// \brief calcext:color-scale
/// calcext:color-scale
class calcext_color_scale: public office_element_impl<calcext_color_scale>
{
public:
@ -191,12 +187,11 @@ public:
virtual void serialize(std::wostream & _Wostream);
private:
office_element_ptr_array content_;//color_scale_entries
office_element_ptr_array content_; //color_scale_entries
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_color_scale)
/// \brief calcext:date-is
/// calcext:date-is
class calcext_date_is: public office_element_impl<calcext_date_is>
{
public:
@ -211,11 +206,11 @@ public:
virtual void serialize(std::wostream & _Wostream);
calcext_date_is_attr calcext_date_is_attr_;
calcext_date_is_attr attr_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_date_is)
/// \brief calcext:condition
/// calcext:condition
class calcext_condition: public office_element_impl<calcext_condition>
{
public:
@ -230,11 +225,11 @@ public:
virtual void serialize(std::wostream & _Wostream);
calcext_condition_attr calcext_condition_attr_;
calcext_condition_attr attr_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_condition)
/// \brief calcext:conditional-format
/// calcext:conditional-format
class calcext_conditional_format: public office_element_impl<calcext_conditional_format>
{
public:
@ -257,7 +252,7 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_conditional_format)
/// \brief calcext:conditional-formats
/// calcext:conditional-formats
class calcext_conditional_formats: public office_element_impl<calcext_conditional_formats>
{
public:

View File

@ -86,7 +86,7 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
std::wstring input_path = oox_ref;
#if defined (_WIN32) || defined(_WIN64) // + mac???
#if defined (_WIN32) || defined(_WIN64)
boost::to_lower(input_path);
#endif
@ -100,7 +100,7 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
break;
}
}
if (output_path.length() < 1)
if (output_path.empty())
{
output_path = ( output_sub_path + output_fileName) ;
if ( type == typeImage)

View File

@ -68,8 +68,8 @@ std::wstring create_file_name(const std::wstring & uri, _mediaitems::Type type,
{
std::wstring sExt;
if (type == _mediaitems::typeOleObject &&
type == _mediaitems::typeObjectReplacement)
//if (type == _mediaitems::typeOleObject &&
// type == _mediaitems::typeObjectReplacement)
{
int n = uri.rfind(L".");
if (n >= 0) sExt = uri.substr(n);

View File

@ -39,7 +39,7 @@
#include "../../../DesktopEditor/common/File.h"
#include "../../../DesktopEditor/common/Directory.h"
#include "../../../Common/DocxFormat/Source/Base/Base.h"
#include "../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
namespace cpdoccore
{
@ -180,8 +180,8 @@ namespace odf_writer
void media::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + (folder_.empty() ? L"" : FILE_SEPARATOR_STR) + folder_;
NSDirectory::CreateDirectory(path);
OOX::CPath path (RootPath + (folder_.empty() ? L"" : FILE_SEPARATOR_STR) + folder_);
NSDirectory::CreateDirectory(path.GetPath());
std::vector< _mediaitems::item > & items = mediaitems_.items();
@ -189,9 +189,10 @@ namespace odf_writer
{
if (items[i].type == type_)
{
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].odf_ref;
OOX::CPath file_name_inp ( items[i].oox_ref);
OOX::CPath file_name_out ( RootPath + FILE_SEPARATOR_STR + items[i].odf_ref); //ref содержит уже folder_
NSFile::CFileBinary::Copy(items[i].oox_ref, file_name_out);
NSFile::CFileBinary::Copy(file_name_inp.GetPath(), file_name_out.GetPath());
}
}
@ -206,7 +207,7 @@ namespace odf_writer
{
if (mediaitems.count_image > 0)
{
pictures_ = element_ptr( new media(mediaitems, L"Picture", 1) );
pictures_ = element_ptr( new media(mediaitems, L"Pictures", 1) );
}
if (mediaitems.count_media > 0)
{

View File

@ -125,7 +125,7 @@ namespace odf_writer
class odf_chart_context::Impl
{
public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)
Impl(odf_conversion_context *odf_context) : odf_context_(odf_context)
{
styles_context_ = NULL;
current_series_count_ = 0;
@ -151,6 +151,9 @@ public:
std::vector<office_element_ptr> group_series_;
std::vector<unsigned int> axis_group_series_;
_CP_OPT(int) bar_overlap;
_CP_OPT(int) bar_gap_width;
struct _range
{
_range(std::wstring &r, bool l, chart_series *s) : label(l), index_cash(-1), series(s), ref(r) {}
@ -277,6 +280,9 @@ void odf_chart_context::Impl::clear_current()
group_series_.clear();
data_cell_ranges_.clear();
cash_.clear();
bar_gap_width = boost::none;
bar_overlap = boost::none;
current_series_count_ = 0;
local_table_reset_ref_ = false;
@ -335,7 +341,7 @@ void odf_chart_context::start_chart(office_element_ptr & root)
root->add_child_element(chart_elm);
//////////
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
impl_->styles_context_->create_style(L"", style_family::Chart, true, false, -1);
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
@ -427,8 +433,6 @@ void odf_chart_context::set_chart_bar_direction(int type)
}
void odf_chart_context::set_chart_bar_gap_width(std::wstring val)
{
if (!impl_->current_level_.back().chart_properties_) return;
int res = val.find(L"%");
bool percent=false;
@ -438,21 +442,22 @@ void odf_chart_context::set_chart_bar_gap_width(std::wstring val)
percent=true;
}
double dVal = boost::lexical_cast<double>(val);
impl_->current_level_.back().chart_properties_->content_.chart_gap_width_ = (int)dVal;
impl_->bar_gap_width = (int)dVal;
}
void odf_chart_context::set_chart_bar_overlap(std::wstring val)
{
if (!impl_->current_level_.back().chart_properties_) return;
int res = val.find(L"%");
bool percent=false;
bool percent = false;
if (res > 0)
{
val = val.substr(0,res);
percent=true;
percent = true;
}
double dVal = boost::lexical_cast<double>(val);
impl_->current_level_.back().chart_properties_->content_.chart_overlap_ = (int)dVal;
impl_->bar_overlap = (int)dVal;
}
void odf_chart_context::set_chart_stock_candle_stick(bool val)
@ -702,15 +707,17 @@ void odf_chart_context::end_group_series()
std::wstring axis_name;
bool presentZ = false;
long countX = 0;
long countY = 0;
long countZ = 0;
for (size_t j = 0; j < impl_->axis_.size(); j++)
{
if (impl_->axis_[j].dimension ==1) countX++;
else if (impl_->axis_[j].dimension ==3) presentZ = true;
else countY++;
if (impl_->axis_[j].dimension == 1) countX++;
else if (impl_->axis_[j].dimension == 2) countY++;
else if (impl_->axis_[j].dimension == 3) countZ++;
}
if (countX < 1 && countY > 1)
{
impl_->axis_[0].dimension == 1;
@ -718,15 +725,15 @@ void odf_chart_context::end_group_series()
axis->chart_axis_attlist_.chart_dimension_ = L"x";
countY--;
}
if (presentZ == false && impl_->axis_group_series_.size() == 3 && (countY > 1 || countX > 1))
{
impl_->axis_.back().dimension == 3;
chart_axis *axis = dynamic_cast<chart_axis*>(impl_->axis_.back().elm.get());
axis->chart_axis_attlist_.chart_dimension_ = L"z";
countY--;
}
//if (countZ > 0 && impl_->axis_group_series_.size() == 3 && (countY > 1 || countX > 1))
//{
// impl_->axis_.back().dimension == 3;
// chart_axis *axis = dynamic_cast<chart_axis*>(impl_->axis_.back().elm.get());
// axis->chart_axis_attlist_.chart_dimension_ = L"z";
// countY--;
//}
for (size_t i=0; i < impl_->axis_group_series_.size(); i++)
for (size_t i = 0; i < impl_->axis_group_series_.size(); i++)
{
for (size_t j = 0; j < impl_->axis_.size(); j++)
{
@ -740,7 +747,7 @@ void odf_chart_context::end_group_series()
}
for (size_t i =0; i < impl_->group_series_.size() && axis_name.length() > 0; i++)
for (size_t i = 0; i < impl_->group_series_.size() && axis_name.length() > 0; i++)
{
chart_series *series= dynamic_cast<chart_series*>(impl_->group_series_[i].get());
if (series)
@ -796,7 +803,7 @@ void odf_chart_context::start_axis()
chart_axis *axis = dynamic_cast<chart_axis*>(elm.get());
if (axis == NULL)return;
//////////
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
impl_->styles_context_->create_style(L"", style_family::Chart, true, false, -1);
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
@ -810,10 +817,19 @@ void odf_chart_context::start_axis()
}
start_element(elm, style_elm, style_name);
odf_axis_state axis_state={0,0,L"",elm};
odf_axis_state axis_state={0, 0, L"", elm};
impl_->axis_.push_back(axis_state);
/////////////////////defaults
impl_->current_level_.back().chart_properties_->content_.chart_reverse_direction_ = false;
if (impl_->bar_overlap)
{
impl_->current_level_.back().chart_properties_->content_.chart_overlap_ = impl_->bar_overlap.get();
}
if (impl_->bar_gap_width)
{
impl_->current_level_.back().chart_properties_->content_.chart_gap_width_ = impl_->bar_gap_width.get();
}
}
void odf_chart_context::start_grid(int type)
{
@ -826,7 +842,7 @@ void odf_chart_context::start_grid(int type)
if (type == 1) grid->chart_grid_attlist_.chart_class_ = L"major";
if (type == 2) grid->chart_grid_attlist_.chart_class_ = L"minor";
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
impl_->styles_context_->create_style(L"", style_family::Chart, true, false, -1);
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
@ -850,7 +866,7 @@ void odf_chart_context::start_title()
chart_title *title = dynamic_cast<chart_title*>(chart_elm.get());
if (title == NULL)return;
//////////
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
impl_->styles_context_->create_style(L"", style_family::Chart, true, false, -1);
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
@ -874,7 +890,7 @@ void odf_chart_context::start_plot_area()
plot_area->chart_plot_area_attlist_.chart_data_source_has_labels_ = L"both";
//////////
impl_->styles_context_->create_style(L"",style_family::Chart, true, false, -1);
impl_->styles_context_->create_style(L"", style_family::Chart, true, false, -1);
office_element_ptr & style_elm = impl_->styles_context_->last_state()->get_office_element();
@ -911,23 +927,22 @@ void odf_chart_context::start_text()
impl_->odf_context_->start_text_context();
impl_->odf_context_->text_context()->set_styles_context(impl_->styles_context_);
style_text_properties *text_props = NULL;
style *style_ = dynamic_cast<style*>(impl_->current_chart_state_.elements_.back().style_elm.get());
if (style_)
{
impl_->current_level_.back().paragraph_properties_ = style_->content_.get_style_paragraph_properties();
impl_->current_level_.back().text_properties_ = style_->content_.get_style_text_properties();
impl_->current_level_.back().paragraph_properties_ = style_->content_.get_style_paragraph_properties();
impl_->current_level_.back().text_properties_ = style_->content_.get_style_text_properties();
}
impl_->odf_context_->text_context()->set_single_object(true,impl_->current_level_.back().paragraph_properties_,impl_->current_level_.back().text_properties_);
impl_->odf_context_->text_context()->set_single_object(true, impl_->current_level_.back().paragraph_properties_, impl_->current_level_.back().text_properties_);
}
void odf_chart_context::end_text()
{
odf_text_context * text_context_ = text_context();
if (text_context_ == NULL || impl_->current_level_.size() <1 )return;
odf_text_context *text_context_ = text_context();
if (text_context_ == NULL || impl_->current_level_.size() < 1 )return;
for (size_t i=0; i< text_context_->text_elements_list_.size(); i++)
for (size_t i = 0; i < text_context_->text_elements_list_.size(); i++)
{
if (text_context_->text_elements_list_[i].level ==0)
{
@ -945,6 +960,45 @@ void odf_chart_context::end_text()
impl_->odf_context_->end_text_context();
}
void odf_chart_context::set_textarea_vertical_align(int align)
{
if (!impl_->current_level_.back().chart_properties_)return;
//switch(align)
//{
//case 0://SimpleTypes::textanchoringtypeB:
// impl_->current_graphic_properties->draw_textarea_vertical_align_ = odf_types::vertical_align(odf_types::vertical_align::Bottom); break;
//case 1://SimpleTypes::textanchoringtypeCtr:
// impl_->current_graphic_properties->draw_textarea_vertical_align_ = odf_types::vertical_align(odf_types::vertical_align::Middle); break;
//case 2://SimpleTypes::textanchoringtypeDist:
// impl_->current_graphic_properties->draw_textarea_vertical_align_ = odf_types::vertical_align(odf_types::vertical_align::Baseline);break;
//case 3://SimpleTypes::textanchoringtypeJust:
// impl_->current_graphic_properties->draw_textarea_vertical_align_ = odf_types::vertical_align(odf_types::vertical_align::Justify); break;
//case 4://SimpleTypes::textanchoringtypeT:
// impl_->current_graphic_properties->draw_textarea_vertical_align_ = odf_types::vertical_align(odf_types::vertical_align::Top); break;
//}
}
void odf_chart_context::set_textarea_rotation(double val)
{
if (!impl_->current_level_.back().chart_properties_)return;
if (val < 0.001 && val > -0.001) return;
if (val < -360 || val > 360) return;
if (val < 0) val += 360;
val = 360 - val;
impl_->current_level_.back().chart_properties_->content_.common_rotation_angle_attlist_.style_rotation_angle_ = (unsigned int)val;
}
void odf_chart_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(double) & top, _CP_OPT(double) & right, _CP_OPT(double) & bottom)//in pt
{
if (!impl_->current_level_.back().chart_properties_)return;
//if (left) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_left_ = length(*left, length::pt);
//if (top) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_top_ = length(*top, length::pt);
//if (right) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_right_ = length(*right,length::pt);
//if (bottom) impl_->current_graphic_properties->common_padding_attlist_.fo_padding_bottom_ = length(*bottom,length::pt);
}
void odf_chart_context::start_floor()
{
office_element_ptr elm;
@ -1478,6 +1532,13 @@ void odf_chart_context::set_series_pie_explosion(int val)//или точка с
impl_->current_level_.back().chart_properties_->content_.chart_pie_offset_ = val;
}
void odf_chart_context::set_series_pie_bubble(bool val)
{
if (!impl_->current_level_.back().chart_properties_)return;
impl_->current_level_.back().chart_properties_->content_.chart_pie_bubble_ = val;
}
//void odf_chart_context::set_cash(std::wstring format, std::vector<double> &data_double)
//{
// if (data_double.size() <1 || impl_->data_cell_ranges_.size() < 1) return;

View File

@ -89,6 +89,7 @@ public:
long get_count_data_points_series();
void set_series_pie_explosion(int val);
void set_series_pie_bubble(bool val);
void end_series();
void end_group_series();
@ -136,6 +137,10 @@ public:
void start_text();
void end_text();
void set_textarea_vertical_align(int align);
void set_textarea_padding (_CP_OPT(double) & left, _CP_OPT(double) & top, _CP_OPT(double) & right, _CP_OPT(double) & bottom);//in pt
void set_textarea_rotation (double val);
void add_domain(std::wstring formula);
void add_categories(std::wstring formula, office_element_ptr & axis);

View File

@ -177,7 +177,7 @@ void odf_conversion_context::start_chart()
create_object();
create_element(L"office", L"chart", objects_.back().content, this, true);
chart_context_.set_styles_context(styles_context());
chart_context_.set_styles_context(odf_conversion_context::styles_context());
chart_context_.start_chart(get_current_object_element());
}
void odf_conversion_context::start_spreadsheet()

View File

@ -2101,6 +2101,36 @@ void odf_drawing_context::set_line_dash_preset(int style)
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::Solid); break;
}
}
void odf_drawing_context::set_paragraph_properties(style_paragraph_properties *paragraph_properties)
{
if (impl_->current_drawing_state_.elements_.empty()) return;
if (!impl_->current_paragraph_properties)
{
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (draw)
{
if(!draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
{
impl_->styles_context_->create_style(L"", style_family::Paragraph, true, false, -1);
office_element_ptr & style_shape_elm = impl_->styles_context_->last_state()->get_office_element();
style* style_ = dynamic_cast<style*>(style_shape_elm.get());
if (style_)
{
impl_->current_paragraph_properties = style_->content_.get_style_paragraph_properties();
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_ = style_->style_name_;
}
}
else
{
//??? find by name
}
}
}
if (impl_->current_paragraph_properties)
impl_->current_paragraph_properties ->apply_from(paragraph_properties);
}
void odf_drawing_context::set_textarea_vertical_align(int align)
{
@ -2136,6 +2166,18 @@ void odf_drawing_context::set_textarea_fit_to_size(bool val)
impl_->current_graphic_properties->draw_fit_to_size_ = val;
}
void odf_drawing_context::set_textarea_rotation(double val)
{
odf_style_state_ptr style_state = impl_->styles_context_->last_state(style_family::Paragraph);
if (style_state)
{
impl_->current_text_properties = style_state->get_text_properties();
}
if (!impl_->current_text_properties) return;
impl_->current_text_properties->content_.style_text_rotation_angle_ = (int)val;
}
void odf_drawing_context::set_textarea_font(std::wstring & latin, std::wstring & cs, std::wstring & ea)
{
@ -2249,36 +2291,6 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
}
}
}
void odf_drawing_context::set_paragraph_properties(style_paragraph_properties *paragraph_properties)
{
if (impl_->current_drawing_state_.elements_.empty()) return;
if (!impl_->current_paragraph_properties)
{
draw_base* draw = dynamic_cast<draw_base*>(impl_->current_drawing_state_.elements_[0].elm.get());
if (draw)
{
if(!draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
{
impl_->styles_context_->create_style(L"", style_family::Paragraph, true, false, -1);
office_element_ptr & style_shape_elm = impl_->styles_context_->last_state()->get_office_element();
style* style_ = dynamic_cast<style*>(style_shape_elm.get());
if (style_)
{
impl_->current_paragraph_properties = style_->content_.get_style_paragraph_properties();
draw->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_ = style_->style_name_;
}
}
else
{
//??? find by name
}
}
}
if (impl_->current_paragraph_properties)
impl_->current_paragraph_properties ->apply_from(paragraph_properties);
}
void odf_drawing_context::set_textarea_padding(_CP_OPT(double) & left, _CP_OPT(double) & top, _CP_OPT(double) & right, _CP_OPT(double) & bottom)//in pt
{
if (!impl_->current_graphic_properties)return;

View File

@ -231,6 +231,7 @@ public:
void set_textarea_fontcolor (std::wstring hexColor);
void set_textarea_font (std::wstring & latin, std::wstring & cs, std::wstring & ea);
void set_textarea_fit_to_size (bool val);
void set_textarea_rotation (double val);
void set_placeholder_id (std::wstring val);
void set_placeholder_type (int val);

View File

@ -199,7 +199,7 @@ std::wstring odf_style_context::find_odf_style_name(int oox_id_style, style_fami
}
//office_element_ptr odf_style_context::find_odf_style(int oox_id_style, style_family::type family, bool root, _CP_OPT(bool) automatic)
//{
// //for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); it++)
// //for (std::list<odf_style_state>::iterator it = style_state_list_.begin(); it != style_state_list_.end(); ++it)
// for (size_t i=0;i<style_state_list_.size(); i++)
// {
// if (style_state_list_[i]->odf_style_)

View File

@ -100,6 +100,7 @@ public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)
{
default_column_width = -1;
optimal_column_width = false;
}
odf_table_state & current_table() {return tables_.back();}
@ -107,13 +108,21 @@ public:
void start_table(odf_table_state & state) {tables_.push_back(state);}
void end_table() {if (tables_.size() > 0) tables_.pop_back(); default_column_width = -1; default_cell_properties = L"";}
void end_table()
{
if (tables_.size() > 0) tables_.pop_back();
default_column_width = -1; // todo .. in level ???
default_cell_properties = L"";
optimal_column_width = false;
}
odf_style_context * styles_context() {return odf_context_->styles_context();}
odf_conversion_context *odf_context_;
double default_column_width;
double default_column_width;
bool optimal_column_width;
std::wstring default_cell_properties; // для предустановки ..
private:
@ -307,6 +316,10 @@ void odf_table_context::set_default_column_width(double width)
{
impl_->default_column_width = width;
}
void odf_table_context::set_optimal_column_width(bool val)
{
impl_->optimal_column_width = val;
}
void odf_table_context::set_column_optimal(bool val)
{
if (impl_->empty()) return;
@ -362,7 +375,11 @@ void odf_table_context::set_column_width(double width)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = false;
if (impl_->optimal_column_width)
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
}
impl_->current_table().table_width += width;
}
@ -370,7 +387,7 @@ void odf_table_context::set_column_width(double width)
{
properties->style_table_column_properties_attlist_.style_use_optimal_column_width_ = true;
if (impl_->default_column_width >=0)
if (impl_->default_column_width >= 0)
{
properties->style_table_column_properties_attlist_.style_column_width_ = length(length(impl_->default_column_width,length::pt).get_value_unit(length::cm),length::cm);
//properties->style_table_column_properties_attlist_.style_rel_column_width_ = length(length(impl_->current_table().table_width,length::pt).get_value_unit(length::cm),length::cm);

View File

@ -66,6 +66,7 @@ public:
void start_table(office_element_ptr &elm, bool styled = false);
void set_default_column_width(double width);
void set_optimal_column_width(bool val);
void change_current_column_width(double width);
void end_table();

View File

@ -54,10 +54,10 @@ namespace cpdoccore {
namespace odf_writer
{
odf_text_context::odf_text_context(odf_conversion_context *odf_context)
odf_text_context::odf_text_context(odf_conversion_context *odf_context, odf_style_context *styles_context)
{
odf_context_ = odf_context;
styles_context_ = odf_context->styles_context();
styles_context_ = styles_context;
single_paragraph_ = false;
paragraph_properties_ = NULL;

View File

@ -53,7 +53,7 @@ class style_text_properties;
class odf_text_context: boost::noncopyable
{
public:
odf_text_context (odf_conversion_context *odf_context);
odf_text_context (odf_conversion_context *odf_context, odf_style_context *styles_context);
~odf_text_context ();
public:
odf_style_context* get_styles_context();//для embedded

View File

@ -132,8 +132,7 @@ void odp_conversion_context::end_layout_slide()
}
void odp_conversion_context::start_text_context()
{
text_context_ = new odf_text_context(this);
text_context_->set_styles_context(slide_context_.get_styles_context());
text_context_ = new odf_text_context(this, slide_context_.get_styles_context());
}
void odp_conversion_context::end_text_context()
{

View File

@ -472,8 +472,7 @@ void ods_conversion_context::add_column(int start_column, int repeated, int leve
}
void ods_conversion_context::start_text_context()
{
current_text_context_ = new odf_text_context(this);
current_text_context_ = new odf_text_context(this, styles_context());
}
void ods_conversion_context::end_text_context()
{

View File

@ -1137,20 +1137,20 @@ void ods_table_state::start_conditional_rule(int rule_type)
boost::algorithm::split(splitted, test, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
cell = splitted[0];
condition->calcext_condition_attr_.calcext_base_cell_address_ = table + cell;
condition->attr_.calcext_base_cell_address_ = table + cell;
}
switch(rule_type)
{
case 4: condition->calcext_condition_attr_.calcext_value_ = L"contains-text( )"; break;
case 5: condition->calcext_condition_attr_.calcext_value_ = L"is-error"; break;
case 6: condition->calcext_condition_attr_.calcext_value_ = L"contains-text()"; break;
case 8: condition->calcext_condition_attr_.calcext_value_ = L"duplicate"; break;
case 9: condition->calcext_condition_attr_.calcext_value_ = L"formula-is()"; break;
case 11: condition->calcext_condition_attr_.calcext_value_ = L"not-contains-text( )"; break;
case 12: condition->calcext_condition_attr_.calcext_value_ = L"is-no-error"; break;
case 13: condition->calcext_condition_attr_.calcext_value_ = L"not-contains-text()"; break;
case 15: condition->calcext_condition_attr_.calcext_value_ = L"top-elements()"; break;//bottom-elements ???
case 16: condition->calcext_condition_attr_.calcext_value_ = L"unique"; break;
case 4: condition->attr_.calcext_value_ = L"contains-text( )"; break;
case 5: condition->attr_.calcext_value_ = L"is-error"; break;
case 6: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 8: condition->attr_.calcext_value_ = L"duplicate"; break;
case 9: condition->attr_.calcext_value_ = L"formula-is()"; break;
case 11: condition->attr_.calcext_value_ = L"not-contains-text( )"; break;
case 12: condition->attr_.calcext_value_ = L"is-no-error"; break;
case 13: condition->attr_.calcext_value_ = L"not-contains-text()"; break;
case 15: condition->attr_.calcext_value_ = L"top-elements()"; break;//bottom-elements ???
case 16: condition->attr_.calcext_value_ = L"unique"; break;
case 0: /*aboveAverage*/
case 1: /*beginsWith*/
case 2: /*cellIs*/
@ -1178,9 +1178,9 @@ void ods_table_state::set_conditional_formula(std::wstring formula)
std::wstring operator_;
bool s = false;
if (condition->calcext_condition_attr_.calcext_value_)//есть опреатор
if (condition->attr_.calcext_value_)//есть опреатор
{
operator_ = *condition->calcext_condition_attr_.calcext_value_;
operator_ = *condition->attr_.calcext_value_;
int f = operator_.find(L"(");
if (f > 0)
{
@ -1188,7 +1188,7 @@ void ods_table_state::set_conditional_formula(std::wstring formula)
operator_ = operator_.substr(0,operator_.length() - 2);
}
}
condition->calcext_condition_attr_.calcext_value_= operator_ + (s ? L"(": L"") + odfFormula + (s ? L")": L"");
condition->attr_.calcext_value_= operator_ + (s ? L"(": L"") + odfFormula + (s ? L")": L"");
}
}
void ods_table_state::set_conditional_style_name(std::wstring style_name)
@ -1196,8 +1196,8 @@ void ods_table_state::set_conditional_style_name(std::wstring style_name)
calcext_condition* condition = dynamic_cast<calcext_condition*> (current_level_.back().get());
calcext_date_is* date_is = dynamic_cast<calcext_date_is*> (current_level_.back().get());
if (condition) condition->calcext_condition_attr_.calcext_apply_style_name_= style_name;
if (date_is) date_is->calcext_date_is_attr_.calcext_style_ = style_name;
if (condition) condition->attr_.calcext_apply_style_name_ = style_name;
if (date_is) date_is->attr_.calcext_style_ = style_name;
}
void ods_table_state::set_conditional_operator(int _operator)
{
@ -1206,18 +1206,18 @@ void ods_table_state::set_conditional_operator(int _operator)
{
switch(_operator)
{
case 0: condition->calcext_condition_attr_.calcext_value_ = L"begins-with()"; break;
case 1: condition->calcext_condition_attr_.calcext_value_ = L"between()"; break;
case 2: condition->calcext_condition_attr_.calcext_value_ = L"contains-text()"; break;
case 3: condition->calcext_condition_attr_.calcext_value_ = L"ends-with()"; break;
case 4: condition->calcext_condition_attr_.calcext_value_ = L"="; break;
case 5: condition->calcext_condition_attr_.calcext_value_ = L">"; break;
case 6: condition->calcext_condition_attr_.calcext_value_ = L">="; break;
case 7: condition->calcext_condition_attr_.calcext_value_ = L"<"; break;
case 8: condition->calcext_condition_attr_.calcext_value_ = L"<="; break;
case 9: condition->calcext_condition_attr_.calcext_value_ = L"not-between()"; break;
case 10:condition->calcext_condition_attr_.calcext_value_ = L"not-contains-text()"; break;
case 11:condition->calcext_condition_attr_.calcext_value_ = L"!="; break;
case 0: condition->attr_.calcext_value_ = L"begins-with()"; break;
case 1: condition->attr_.calcext_value_ = L"between()"; break;
case 2: condition->attr_.calcext_value_ = L"contains-text()"; break;
case 3: condition->attr_.calcext_value_ = L"ends-with()"; break;
case 4: condition->attr_.calcext_value_ = L"="; break;
case 5: condition->attr_.calcext_value_ = L">"; break;
case 6: condition->attr_.calcext_value_ = L">="; break;
case 7: condition->attr_.calcext_value_ = L"<"; break;
case 8: condition->attr_.calcext_value_ = L"<="; break;
case 9: condition->attr_.calcext_value_ = L"not-between()"; break;
case 10:condition->attr_.calcext_value_ = L"not-contains-text()"; break;
case 11:condition->attr_.calcext_value_ = L"!="; break;
}
}
}
@ -1229,8 +1229,8 @@ void ods_table_state::set_conditional_value(int type, std::wstring value )
if (icon_set || data_bar)
{
office_element_ptr elm;
create_element(L"calcext", L"formatting-entry",elm, context_);
office_element_ptr elm;
create_element(L"calcext", L"formatting-entry", elm, context_);
current_level_.back()->add_child_element(elm);
@ -1247,13 +1247,14 @@ void ods_table_state::set_conditional_value(int type, std::wstring value )
case 3: //Number
default: entry->calcext_type_ = calcext_type(calcext_type::Number);
}
entry->calcext_value_ = value;
}
}
if (color_scale)
{
office_element_ptr elm;
create_element(L"calcext", L"color-scale-entry",elm, context_);
office_element_ptr elm;
create_element(L"calcext", L"color-scale-entry", elm, context_);
current_level_.back()->add_child_element(elm);
@ -1263,13 +1264,14 @@ void ods_table_state::set_conditional_value(int type, std::wstring value )
switch(type)
{
case 0: //Formula
case 1: entry->calcext_type_ = calcext_type(calcext_type::Maximum); break;
case 2: entry->calcext_type_ = calcext_type(calcext_type::Minimum); break;
case 4: entry->calcext_type_ = calcext_type(calcext_type::Percent); break;
case 5: //Percentile
case 1: entry->calcext_type_ = calcext_type(calcext_type::Maximum); break;
case 2: entry->calcext_type_ = calcext_type(calcext_type::Minimum); break;
case 4: entry->calcext_type_ = calcext_type(calcext_type::Percent); break;
case 5: entry->calcext_type_ = calcext_type(calcext_type::Percentile); break;
case 3: //Number
default: entry->calcext_type_ = calcext_type(calcext_type::Number);
}
entry->calcext_value_ = value;
}
///color???? - прихоодят выше уровнем !!
}
@ -1281,11 +1283,22 @@ void ods_table_state::set_conditional_iconset(int type_iconset)
if (cond_format)
{
cond_format->calcext_icon_set_attr_.calcext_icon_set_type_ = iconset_type((iconset_type::type)type_iconset);
cond_format->attr_.calcext_icon_set_type_ = iconset_type((iconset_type::type)type_iconset);
}
}
void ods_table_state::add_conditional_colorscale(_CP_OPT(color) color)
void ods_table_state::add_conditional_colorscale(int index, _CP_OPT(color) color)
{
calcext_color_scale *scale = dynamic_cast<calcext_color_scale*>(current_level_.back().get());
if (!scale) return;
if (index >= scale->content_.size() || index < 0) return;
calcext_color_scale_entry* color_scale_entry = dynamic_cast<calcext_color_scale_entry*>(scale->content_[index].get());
if (color_scale_entry)
{
color_scale_entry->calcext_color_ = color;
}
}
void ods_table_state::set_conditional_databar_color(_CP_OPT(color) color)
{
@ -1293,7 +1306,7 @@ void ods_table_state::set_conditional_databar_color(_CP_OPT(color) color)
if (cond_format)
{
cond_format->calcext_data_bar_attr_.calcext_positive_color_ = color;
cond_format->attr_.calcext_positive_color_ = color;
}
}

View File

@ -274,7 +274,7 @@ public:
void set_conditional_formula(std::wstring formula);
void set_conditional_value(int type, std::wstring value );
void set_conditional_iconset(int type_iconset);
void add_conditional_colorscale(_CP_OPT(odf_types::color) color);
void add_conditional_colorscale(int index, _CP_OPT(odf_types::color) color);
void set_conditional_databar_color(_CP_OPT(odf_types::color) color);
void set_conditional_style_name(std::wstring style_name);

View File

@ -105,7 +105,8 @@ void odt_conversion_context::start_document()
root_document_ = get_current_object_element();
root_text_ = dynamic_cast<office_text*>(root_document_.get());
main_text_context_ = new odf_text_context(this);
main_text_context_ = new odf_text_context(this, styles_context());
page_layout_context()->set_styles_context(styles_context());
@ -117,7 +118,7 @@ void odt_conversion_context::start_document()
void odt_conversion_context::end_document()
{
//add sections to root
for (size_t i = 0; i< sections_.size(); i++)
for (size_t i = 0; i < sections_.size(); i++)
{
root_document_->add_child_element(sections_[i].elm);
}
@ -182,7 +183,8 @@ odf_text_context* odt_conversion_context::text_context()
}
void odt_conversion_context::start_text_context()
{
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this));
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, /*odf_conversion_context::*/styles_context()));
//объекты с текстом в колонтитулах
if (!new_text_context_)return;
text_context_.push_back(new_text_context_);
@ -198,17 +200,18 @@ void odt_conversion_context::add_text_content(const std::wstring & text)
{
if (drop_cap_state_.enabled)
{
int count = text.size();
int count = text.length();
drop_cap_state_.characters += count;
if (drop_cap_state_.inline_style == false)
style_text_properties * props = text_context()->get_text_properties();
if (props)
{
style_text_properties * props = text_context()->get_text_properties();
if (props)
if (drop_cap_state_.inline_style == false)
{
std::wstring f_name = props->content_.fo_font_family_.get_value_or(L"Arial");
double f_size = props->content_.fo_font_size_.get_value_or(font_size(length(12,length::pt))).get_length().get_value_unit(length::pt);
drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size, applicationFonts_);
double f_size = props->content_.fo_font_size_.get_value_or(font_size(length(12, length::pt))).get_length().get_value_unit(length::pt);
drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size, applicationFonts_);
}
}
}
@ -478,6 +481,14 @@ int odt_conversion_context::get_current_section_columns()
}
void odt_conversion_context::add_section(bool continuous)
{
//--dump first elements to root------------------------------------------------
for (size_t i = 0; i< current_root_elements_.size(); i++)
{
root_document_->add_child_element(current_root_elements_[i].elm);
}
current_root_elements_.clear();
//----------------------------------------------------------------------------
odt_section_state state;
state.empty = true;
@ -661,9 +672,9 @@ void odt_conversion_context::set_no_list()
}
void odt_conversion_context::flush_section()
{
if (sections_.size() > 0 && sections_.back().empty)
if (!sections_.empty() && sections_.back().empty)
{
for (size_t i=0; i< current_root_elements_.size(); i++)
for (size_t i = 0; i < current_root_elements_.size(); i++)
{
if ((sections_.back().continuous && i < 2) || !sections_.back().continuous)
// при вставлении параграфа возможен искусственный разрыв в параграфах - см add_page_break
@ -696,7 +707,7 @@ void odt_conversion_context::start_run(bool styled)
if (is_hyperlink_ && text_context_.size() > 0) return;
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && !current_field_.in_span)
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && !current_field_.in_span)
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
@ -704,7 +715,14 @@ void odt_conversion_context::start_run(bool styled)
text_context()->start_span(styled);
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
if (drop_cap_state_.enabled)
{
style_text_properties *props = text_context()->get_text_properties();
if (props)
props->apply_from(dynamic_cast<style_text_properties*>(drop_cap_state_.text_properties.get()));
}
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
@ -944,7 +962,14 @@ void odt_conversion_context::end_change (int id, int type)
// return (text_changes_state_.current_types.back() == 2);
//}
//--------------------------------------------------------------------------------------------------------
style_text_properties* odt_conversion_context::get_drop_cap_properties()
{
if (!drop_cap_state_.text_properties)
{
create_element(L"style", L"text-properties", drop_cap_state_.text_properties, this);
}
return dynamic_cast<style_text_properties *>(drop_cap_state_.text_properties.get());
}
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
{
if (drop_cap_state_.enabled)
@ -966,6 +991,8 @@ void odt_conversion_context::set_drop_cap_lines(int lines)
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get());
if (drop_cap)drop_cap->style_lines_ = lines;
drop_cap_state_.lines = lines;
}
void odt_conversion_context::set_drop_cap_margin(bool val)
{
@ -976,7 +1003,7 @@ void odt_conversion_context::end_drop_cap()
{
if (!drop_cap_state_.enabled) return;
if (drop_cap_state_.characters >0 && drop_cap_state_.paragraph_properties)
if (drop_cap_state_.characters > 0 && drop_cap_state_.paragraph_properties)
{
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get());
if (drop_cap)

View File

@ -113,6 +113,8 @@ public:
void set_drop_cap_lines (int lines);
void set_drop_cap_margin(bool val);
void end_drop_cap ();
bool in_drop_cap () {return drop_cap_state_.enabled;}
style_text_properties* get_drop_cap_properties();
bool start_comment (int oox_comment_id);
void end_comment (int oox_comment_id);
@ -203,14 +205,25 @@ private:
struct _drop_cap_state
{
void clear(){enabled = false; paragraph_properties = NULL; characters = 0; inline_style = true; characters_size_pt =0;}
void clear()
{
enabled = false;
paragraph_properties = NULL;
characters = 0;
inline_style = true;
characters_size_pt = 0;
lines = 0;
text_properties = office_element_ptr();
}
bool enabled;
style_paragraph_properties *paragraph_properties;
bool enabled = false;
style_paragraph_properties *paragraph_properties = NULL;
office_element_ptr text_properties;
int characters;
bool inline_style;
double characters_size_pt;
int lines = 0;
int characters = 0;
bool inline_style = false;
double characters_size_pt = 0;
}drop_cap_state_;
};

View File

@ -43,7 +43,7 @@
namespace cpdoccore {
namespace odf_writer {
/// \brief office:chart
/// office:chart
class office_chart : public office_element_impl<office_chart>
{
public:
@ -86,7 +86,7 @@ public:
_CP_OPT(std::wstring) chart_row_mapping_;
};
/// \brief chart:chart
/// chart:chart
class chart_chart : public office_element_impl<chart_chart>
{
public:
@ -118,7 +118,7 @@ public:
common_chart_attlist common_attlist_;
};
/// \brief chart:title
/// chart:title
class chart_title : public office_element_impl<chart_title>
{
public:
@ -139,7 +139,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_title);
/// \brief chart:subtitle
/// chart:subtitle
class chart_subtitle : public office_element_impl<chart_subtitle>
{
public:
@ -161,7 +161,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_subtitle);
/// \brief chart:footer
/// chart:footer
class chart_footer : public office_element_impl<chart_footer>
{
public:
@ -200,7 +200,7 @@ public:
_CP_OPT(odf_types::length) chartooo_width_;
};
/// \brief chart:legend
/// chart:legend
class chart_legend : public office_element_impl<chart_legend>
{
public:
@ -239,7 +239,7 @@ public:
// common-dr3d-transform-attlist
};
/// \brief chart:plot-area
/// chart:plot-area
class chart_plot_area : public office_element_impl<chart_plot_area>
{
public:
@ -291,7 +291,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_wall);
/// \brief chart:floor
/// chart:floor
class chart_floor : public office_element_impl<chart_floor>
{
public:
@ -322,7 +322,7 @@ public:
common_chart_attlist common_attlist_;
};
/// \brief chart:axis
/// chart:axis
class chart_axis : public office_element_impl<chart_axis>
{
public:
@ -354,7 +354,7 @@ public:
};
/// \brief chart:grid
/// chart:grid
class chart_grid : public office_element_impl<chart_grid>
{
public:
@ -375,7 +375,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_grid);
/// \brief chart:categories
/// chart:categories
class chart_categories : public office_element_impl<chart_categories>
{
public:
@ -409,7 +409,7 @@ public:
};
/// \brief chart:series
/// chart:series
class chart_series : public office_element_impl<chart_series>
{
public:
@ -431,7 +431,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_series);
/// \brief chart:domain
/// chart:domain
class chart_domain : public office_element_impl<chart_domain>
{
public:
@ -461,7 +461,7 @@ public:
common_chart_attlist common_attlist_;
};
/// \brief chart:data-point
/// chart:data-point
class chart_data_point : public office_element_impl<chart_data_point>
{
public:
@ -482,7 +482,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_data_point);
/// \brief chart:mean-value
/// chart:mean-value
class chart_mean_value : public office_element_impl<chart_mean_value>
{
public:
@ -503,7 +503,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_mean_value);
/// \brief chart:error-indicator
/// chart:error-indicator
class chart_error_indicator : public office_element_impl<chart_error_indicator>
{
public:
@ -566,7 +566,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_regression_curve);
/// \brief chart:stock-gain-marker
/// chart:stock-gain-marker
class chart_stock_gain_marker : public office_element_impl<chart_stock_gain_marker>
{
public:
@ -587,7 +587,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_stock_gain_marker);
/// \brief chart:stock-loss-marker
/// chart:stock-loss-marker
class chart_stock_loss_marker : public office_element_impl<chart_stock_loss_marker>
{
public:
@ -608,7 +608,7 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(chart_stock_loss_marker);
/// \brief chart:stock-range-line
/// chart:stock-range-line
class chart_stock_range_line : public office_element_impl<chart_stock_range_line>
{
public:

View File

@ -95,6 +95,7 @@ public:
_CP_OPT(int) chart_spline_order_;
_CP_OPT(int) chart_spline_resolution_;
_CP_OPT(int) chart_pie_offset_;
_CP_OPT(bool) chart_pie_bubble_;
_CP_OPT(int) chart_interval_minor_divisor_;
_CP_OPT(double) chart_maximum_;
@ -105,15 +106,15 @@ public:
_CP_OPT(double) chart_error_margin_;
_CP_OPT(double) chart_error_upper_limit_;
_CP_OPT(odf_types::chart_interpolation) chart_interpolation_;
_CP_OPT(odf_types::chart_interpolation) chart_interpolation_;
_CP_OPT(odf_types::chart_solid_type) chart_solid_type_;
_CP_OPT(odf_types::chart_label_arrangement) chart_label_arrangement_;
_CP_OPT(odf_types::chart_label_arrangement) chart_label_arrangement_;
_CP_OPT(odf_types::direction) style_direction_;
_CP_OPT(odf_types::chart_series_source) chart_series_source_;
_CP_OPT(odf_types::chart_series_source) chart_series_source_;
_CP_OPT(odf_types::length) chart_symbol_width_;
_CP_OPT(odf_types::length) chart_symbol_height_;
_CP_OPT(odf_types::chart_regression_type) chart_regression_type_;
_CP_OPT(odf_types::chart_data_label_number) chart_data_label_number_;
_CP_OPT(odf_types::chart_data_label_number) chart_data_label_number_;
_CP_OPT(odf_types::chart_error_category) chart_error_category_;
_CP_OPT(std::wstring) chart_axis_label_position_;

View File

@ -269,8 +269,15 @@ void style_paragraph_properties::apply_from(style_paragraph_properties * Other)
content_.apply_from(Other->content_);
}
void paragraph_format_properties::clear()
void paragraph_format_properties::clear(bool bEraseDropCap)
{
if (bEraseDropCap)
{
style_drop_cap_ = office_element_ptr();
fo_text_indent_ = boost::none;
}
style_tab_stops_ = office_element_ptr();
style_background_image_ = office_element_ptr();
fo_line_height_ = boost::none;
style_line_height_at_least_ = boost::none;
style_line_spacing_ = boost::none;
@ -287,7 +294,6 @@ void paragraph_format_properties::clear()
style_register_true_ = boost::none;
fo_margin_left_ = boost::none;
fo_margin_right_ = boost::none;
//fo_text_indent_ = boost::none;//заточено под буквицу
style_auto_text_indent_ = boost::none;
fo_margin_top_ = boost::none;
fo_margin_bottom_ = boost::none;
@ -318,7 +324,11 @@ void paragraph_format_properties::clear()
text_number_lines_ = boost::none;
style_shadow_ = boost::none;
//todooo borders
common_border_attlist_.fo_border_ = boost::none;
common_border_attlist_.fo_border_top_ = boost::none;
common_border_attlist_.fo_border_bottom_= boost::none;
common_border_attlist_.fo_border_left_ = boost::none;
common_border_attlist_.fo_border_right_ = boost::none;
}
void paragraph_format_properties::apply_from(paragraph_format_properties & Other)

View File

@ -192,9 +192,8 @@ public:
void apply_from( paragraph_format_properties & Other);
void clear();
void clear(bool bEraseDropCap = true);
public:
_CP_OPT(odf_types::length) style_line_height_at_least_;
_CP_OPT(odf_types::length_or_percent) style_line_spacing_;
_CP_OPT(odf_types::Bool) style_font_independent_line_spacing_;
@ -277,7 +276,7 @@ public:
virtual void serialize(std::wostream & strm);
paragraph_format_properties content_;
paragraph_format_properties content_;
};

View File

@ -83,8 +83,13 @@ void table_format_properties::serialize(std::wostream & _Wostream,const wchar_t
common_keep_with_next_attlist_.serialize(CP_GET_XML_NODE());
common_border_attlist_.serialize(CP_GET_XML_NODE());
if (style_background_image_) style_background_image_->serialize(_Wostream);
CP_XML_ATTR_OPT(L"table:align", table_align_);
//not from specification !!
CP_XML_ATTR_OPT(L"style:use-optimal-column-width", style_use_optimal_column_width_);
//not from specification !!
if (style_background_image_) style_background_image_->serialize(_Wostream);
}
}
}
@ -109,7 +114,8 @@ void table_format_properties::apply_from(const table_format_properties & Other)
common_keep_with_next_attlist_.apply_from(Other.common_keep_with_next_attlist_);
common_border_attlist_.apply_from(Other.common_border_attlist_);
style_background_image_ = Other.style_background_image_;
style_background_image_ = Other.style_background_image_;
style_use_optimal_column_width_ = Other.style_use_optimal_column_width_;
}
// style:table-properties
@ -145,9 +151,10 @@ void style_table_column_properties_attlist::serialize(std::wostream & _Wostream,
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"style:column-width", style_column_width_);
CP_XML_ATTR_OPT(L"style:rel-column-width", style_rel_column_width_);
CP_XML_ATTR_OPT(L"style:use-optimal-column-width", style_use_optimal_column_width_);
CP_XML_ATTR_OPT(L"style:column-width", style_column_width_);
CP_XML_ATTR_OPT(L"style:rel-column-width", style_rel_column_width_);
CP_XML_ATTR_OPT(L"style:use-optimal-column-width", style_use_optimal_column_width_);
common_break_attlist_.serialize(CP_GET_XML_NODE());
}
}

View File

@ -84,8 +84,8 @@ public:
odf_types::common_border_attlist common_border_attlist_;
office_element_ptr style_background_image_;
office_element_ptr style_background_image_;
_CP_OPT(odf_types::Bool) style_use_optimal_column_width_;
};

View File

@ -29,6 +29,7 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "XlsxConverter.h"
#include "PptxConverter.h"
#include "DocxConverter.h"
@ -565,7 +566,7 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
//docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
for (std::list<OOX::WritingElement*>::iterator it = oox_shape->oTextBoxShape->m_arrItems.begin(); it != oox_shape->oTextBoxShape->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_shape->oTextBoxShape->m_arrItems.begin(); it != oox_shape->oTextBoxShape->m_arrItems.end(); ++it)
{
docx_converter->convert(*it);
@ -664,6 +665,8 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
if (effectLst) convert(effectLst);
else if (oox_sp_style) convert(&oox_sp_style->effectRef, 3);
//convert(oox_spPr->ExtLst.GetPointer());
//nullable<OOX::Drawing::CEffectContainer> EffectDag;
//nullable<OOX::Drawing::COfficeArtExtensionList> ExtLst;
@ -672,6 +675,40 @@ void OoxConverter::convert(PPTX::Logic::SpPr *oox_spPr, PPTX::Logic::ShapeStyle*
//-----------------------------------------------------------------------------------------------------------------------------
}
void OoxConverter::convert(OOX::Drawing::COfficeArtExtensionList *ext_list)
{
if (ext_list == NULL)return;
for (size_t i = 0; i < ext_list->m_arrExt.size(); i++)
{
convert(ext_list->m_arrExt[i]);
}
}
void OoxConverter::convert(OOX::Drawing::COfficeArtExtension *art_ext)
{
if (art_ext == NULL)return;
if (art_ext->m_oSparklineGroups.IsInit() || art_ext->m_oAltTextTable.IsInit() || !art_ext->m_arrConditionalFormatting.empty())
{
XlsxConverter *xlsx_converter = dynamic_cast<XlsxConverter*>(this);
if (xlsx_converter)
{
xlsx_converter->convert(art_ext->m_oSparklineGroups.GetPointer());
xlsx_converter->convert(art_ext->m_oAltTextTable.GetPointer());
for (size_t i = 0; i < art_ext->m_arrConditionalFormatting.size(); i++)
{
xlsx_converter->convert(art_ext->m_arrConditionalFormatting[i]);
}
}
}
//convert(art_ext->m_oCompatExt.GetPointer());
//convert(art_ext->m_oDataModelExt.GetPointer());
}
void OoxConverter::convert(PPTX::Logic::UniFill *oox_fill, DWORD nARGB)
{
if (oox_fill == NULL) return;
@ -1165,6 +1202,10 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
//+ style section
//+element text:section в котором параграфы
}
if (oox_bodyPr->rot.IsInit())
{
odf_context()->drawing_context()->set_textarea_rotation(oox_bodyPr->rot.get() / 60000);
}
switch(oox_bodyPr->Fit.type)
{
@ -1505,7 +1546,7 @@ void OoxConverter::convert(PPTX::Logic::Paragraph *oox_paragraph, PPTX::Logic::T
}
//свойства могут быть приписаны не только к параграфу, но и к самому объекту
odf_writer::style_paragraph_properties* paragraph_properties = odf_context()->text_context()->get_paragraph_properties();
odf_writer::style_text_properties* text_properties = NULL;
odf_writer::style_text_properties* text_properties = odf_context()->text_context()->get_text_properties();
if (!paragraph_properties)
{

View File

@ -70,7 +70,7 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
}
//m_oPreferRelative//типо можно менять размер
for (std::list<OOX::WritingElement*>::iterator it = vml_shape_type->m_arrItems.begin(); it != vml_shape_type->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = vml_shape_type->m_arrItems.begin(); it != vml_shape_type->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -90,7 +90,7 @@ void OoxConverter::convert(OOX::Vml::CFormulas *vml_formulas)
{
if (vml_formulas == NULL) return;
for (std::list<OOX::Vml::CF*>::iterator it = vml_formulas->m_arrItems.begin(); it != vml_formulas->m_arrItems.end(); it++)
for (std::vector<OOX::Vml::CF*>::iterator it = vml_formulas->m_arrItems.begin(); it != vml_formulas->m_arrItems.end(); ++it)
{
OOX::Vml::CF *cf = dynamic_cast<OOX::Vml::CF *>(*it);
if (cf == NULL) continue;
@ -717,7 +717,7 @@ void OoxConverter::convert(OOX::Vml::CTextbox *vml_textbox)
{
odf_context()->start_text_context();
{
for (std::list<OOX::WritingElement*>::iterator it = vml_textbox->m_oTxtbxContent->m_arrItems.begin(); it != vml_textbox->m_oTxtbxContent->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = vml_textbox->m_oTxtbxContent->m_arrItems.begin(); it != vml_textbox->m_oTxtbxContent->m_arrItems.end(); ++it)
{
docx_converter->convert(*it);
}
@ -890,7 +890,7 @@ void OoxConverter::convert(OOX::Vml::CVmlCommonElements *vml_common)
delete oRgbColor;
}
}
for (std::list<OOX::WritingElement*>::iterator it = vml_common->m_arrItems.begin(); it != vml_common->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = vml_common->m_arrItems.begin(); it != vml_common->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -920,7 +920,7 @@ void OoxConverter::convert(OOX::Vml::CGroup *vml_group)
odf_context()->drawing_context()->set_group_shift(vml_group->m_oCoordOrigin->GetX(), vml_group->m_oCoordOrigin->GetY());
}
for (std::list<OOX::WritingElement*>::iterator it = vml_group->m_arrItems.begin(); it != vml_group->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = vml_group->m_arrItems.begin(); it != vml_group->m_arrItems.end(); ++it)
{
if (*it == NULL) continue;

View File

@ -58,6 +58,8 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h"
#define PROGRESSEVENT_ID 0
namespace Oox2Odf
@ -285,6 +287,14 @@ void OoxConverter::convert(OOX::WritingElement *oox_unknown)
{
convert(dynamic_cast<OOX::VmlWord::CWrap*>(oox_unknown));
}break;
case OOX::et_a_extLst:
{
convert(dynamic_cast<OOX::Drawing::COfficeArtExtensionList*>(oox_unknown));
}break;
case OOX::et_a_ext:
{
convert(dynamic_cast<OOX::Drawing::COfficeArtExtension*>(oox_unknown));
}break;
// "ненужные" элементы
case OOX::et_w_softHyphen:
case OOX::et_w_proofErr:

View File

@ -78,6 +78,8 @@ namespace OOX
//class CPresetTextShape;
class CInline;
class CAnchor;
class COfficeArtExtensionList;
class COfficeArtExtension;
}
namespace Spreadsheet
{
@ -395,7 +397,6 @@ public:
void convert(PPTX::Logic::StyleRef *oox_styleRef, int type);
void convert(PPTX::Logic::Path2D *oox_path2D);
void convert(PPTX::Logic::PathBase *oox_path);
void convert(PPTX::Logic::BodyPr *oox_bodyPr);
void convert(PPTX::Logic::UniFill *oox_fill, DWORD ARGB = 0);
void convert(PPTX::Logic::UniColor *color, DWORD & nARGB);
void convert(PPTX::Logic::UniColor *color, std::wstring & hexString, _CP_OPT(double) & opacity, DWORD ARGB = 0);
@ -420,7 +421,12 @@ public:
void convert(PPTX::Logic::Run *oox_run);
void convert(PPTX::Logic::Fld *oox_fld);
void convert(PPTX::Logic::Br *oox_br);
void convert(PPTX::Logic::TxBody *oox_txBody, PPTX::Logic::ShapeStyle* oox_style = NULL);
void convert_chart_text(PPTX::Logic::TxBody *oox_txBody);
void convert(PPTX::Logic::BodyPr *oox_bodyPr);
void convert_chart_text(PPTX::Logic::BodyPr *oox_bodyPr);
void convert(PPTX::Logic::MathParaWrapper *oox_math);
void convert(PPTX::Logic::NvGraphicFramePr *oox_framePr);
void convert(PPTX::Logic::ChartRec *oox_chart);
@ -453,7 +459,9 @@ public:
void convert(OOX::Spreadsheet::CT_Area3DChart *chart);
void convert(OOX::Spreadsheet::CT_AreaChart *chart);
void convert(OOX::Spreadsheet::CT_Bar3DChart *chart);
void convert_before(OOX::Spreadsheet::CT_Bar3DChart *chart);
void convert(OOX::Spreadsheet::CT_BarChart *chart);
void convert_before(OOX::Spreadsheet::CT_BarChart *chart);
void convert(OOX::Spreadsheet::CT_Line3DChart *chart);
void convert(OOX::Spreadsheet::CT_LineChart *chart);
void convert(OOX::Spreadsheet::CT_Pie3DChart *chart);
@ -514,6 +522,9 @@ public:
void convert(OOX::Vml::CGroup *vml_group);
void convert(OOX::Vml::CVmlCommonElements *vml_attr);
void convert(OOX::Vml::CFormulas *vml_formulas);
void convert(OOX::Drawing::COfficeArtExtensionList *ext_list);
void convert(OOX::Drawing::COfficeArtExtension *art_ext);
};
} // namespace Oox2Odf

View File

@ -49,6 +49,61 @@
namespace Oox2Odf
{
void OoxConverter::convert_chart_text(PPTX::Logic::TxBody *oox_txBody)
{
if (!oox_txBody) return;
if (oox_txBody->Paragrs.empty()) return;
odf_context()->chart_context()->start_text();
convert(oox_txBody->lstStyle.GetPointer());
for (size_t i = 0; i < oox_txBody->Paragrs.size(); i++)
{
convert(&oox_txBody->Paragrs[i], oox_txBody->lstStyle.GetPointer());
//внешние настройки для текста
convert_chart_text(oox_txBody->bodyPr.GetPointer());
}
odf_context()->chart_context()->end_text();
}
void OoxConverter::convert_chart_text(PPTX::Logic::BodyPr *oox_bodyPr)
{
if (!oox_bodyPr) return;
if (oox_bodyPr->vert.IsInit())
{
//odf_context()->chart_context()->set_textarea_writing_mode (oox_bodyPr->vert->GetBYTECode());
}
if (oox_bodyPr->anchor.IsInit())
{
//odf_context()->chart_context()->set_textarea_vertical_align (oox_bodyPr->anchor->GetBYTECode());
}
_CP_OPT(double) lIns, tIns, rIns, bIns;
if (oox_bodyPr->lIns.IsInit()) lIns = oox_bodyPr->lIns.get() / 12700.; //pt
if (oox_bodyPr->tIns.IsInit()) tIns = oox_bodyPr->tIns.get() / 12700.;
if (oox_bodyPr->rIns.IsInit()) rIns = oox_bodyPr->rIns.get() / 12700.;
if (oox_bodyPr->bIns.IsInit()) bIns = oox_bodyPr->bIns.get() / 12700.;
//odf_context()->chart_context()->set_textarea_padding (lIns, tIns, rIns, bIns);
//if (oox_bodyPr->wrap.IsInit())
// odf_context()->chart_context()->set_textarea_wrap(oox_bodyPr->wrap->GetBYTECode());
if ((oox_bodyPr->numCol.IsInit()) && (oox_bodyPr->numCol.get() > 1))
{
//+ style section
//+element text:section в котором параграфы
}
if (oox_bodyPr->rot.IsInit())
{
odf_context()->chart_context()->set_textarea_rotation(oox_bodyPr->rot.get() / 60000);
}
}
void OoxConverter::convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart)
{
if (!oox_chart)return;
@ -56,7 +111,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ChartSpace *oox_chart)
convert(oox_chart->m_externalData);
convert(oox_chart->m_oSpPr.GetPointer());
convert(oox_chart->m_oTxPr.GetPointer());
convert_chart_text(oox_chart->m_oTxPr.GetPointer());
convert(oox_chart->m_chart->m_title);
convert(oox_chart->m_chart->m_legend);
@ -103,7 +158,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Tx* ct_tx)
{
if (ct_tx == NULL)return;
convert(ct_tx->m_oRich.GetPointer());
convert_chart_text(ct_tx->m_oRich.GetPointer());
}
void OoxConverter::convert(OOX::Spreadsheet::CT_Layout* ct_layout)
{
@ -130,7 +185,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Title* ct_title)
odf_context()->chart_context()->start_title();
convert(ct_title->m_oSpPr.GetPointer());
convert(ct_title->m_layout);
convert(ct_title->m_oTxPr.GetPointer());
convert_chart_text(ct_title->m_oTxPr.GetPointer());
///////////////////////////////
convert(ct_title->m_tx);
odf_context()->chart_context()->end_element();
@ -145,7 +200,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Legend* ct_legend)
if ((ct_legend->m_legendPos) && (ct_legend->m_legendPos->m_val))
odf_context()->chart_context()->set_legend_position(*ct_legend->m_legendPos->m_val);
convert(ct_legend->m_oTxPr.GetPointer());
convert_chart_text(ct_legend->m_oTxPr.GetPointer());
if (ct_legend->m_legendEntry.size() > 0)
{
convert(ct_legend->m_legendEntry[0]); // в odf_writer нет в легенде множественности стилей
@ -157,7 +212,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_LegendEntry* ct_legend)
{
if (ct_legend == NULL)return;
convert(ct_legend->m_oTxPr.GetPointer());
convert_chart_text(ct_legend->m_oTxPr.GetPointer());
}
void OoxConverter::convert(OOX::Spreadsheet::CT_PlotArea* ct_plotArea)
{
@ -167,6 +222,17 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_PlotArea* ct_plotArea)
convert(ct_plotArea->m_layout);
///////////////////////
for (size_t i=0; i< ct_plotArea->m_Items.size(); i++)//
{
if (!ct_plotArea->m_ItemsElementName0[i]) continue;
switch(*ct_plotArea->m_ItemsElementName0[i])
{
case OOX::Spreadsheet::itemschoicetype5BAR3DCHART: convert_before((OOX::Spreadsheet::CT_Bar3DChart*) ct_plotArea->m_Items[i]); break;
case OOX::Spreadsheet::itemschoicetype5BARCHART: convert_before((OOX::Spreadsheet::CT_BarChart*) ct_plotArea->m_Items[i]); break;
}
}
for (size_t i = 0; i < ct_plotArea->m_Items1.size(); i++)
{
if (!ct_plotArea->m_ItemsElementName1[i]) continue;
@ -222,7 +288,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_CatAx* axis)
odf_context()->chart_context()->set_axis_dimension(1);
if (axis->m_axId && axis->m_axId->m_val)
odf_context()->chart_context()->set_axis_id(*axis->m_axId->m_val);
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -249,7 +317,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_CatAx* axis)
odf_context()->chart_context()->set_axis_label_position(*axis->m_tickLblPos->m_val);
///////////////////
convert(axis->m_oTxPr.GetPointer());
convert_chart_text(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
@ -263,7 +331,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_DateAx* axis)
odf_context()->chart_context()->set_axis_dimension(1);
if (axis->m_axId && axis->m_axId->m_val)
odf_context()->chart_context()->set_axis_id(*axis->m_axId->m_val);
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -288,7 +358,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_DateAx* axis)
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
//////////////////
convert(axis->m_oTxPr.GetPointer());
convert_chart_text(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
@ -302,7 +372,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SerAx* axis)
odf_context()->chart_context()->set_axis_dimension(1);
if (axis->m_axId && axis->m_axId->m_val)
odf_context()->chart_context()->set_axis_id(*axis->m_axId->m_val);
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -327,7 +399,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_SerAx* axis)
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
///////////////////////////
convert(axis->m_oTxPr.GetPointer());
convert_chart_text(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
@ -341,7 +413,9 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ValAx* axis)
odf_context()->chart_context()->set_axis_dimension(2);
if (axis->m_axId && axis->m_axId->m_val)
odf_context()->chart_context()->set_axis_id(*axis->m_axId->m_val);
convert(axis->m_oSpPr.GetPointer());
if (axis->m_scaling)
{
if (axis->m_scaling->m_logBase)
@ -365,7 +439,7 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_ValAx* axis)
if (axis->m_axPos && axis->m_axPos->m_val)
odf_context()->chart_context()->set_axis_position(*axis->m_axPos->m_val);
/////////////////////////////
convert(axis->m_oTxPr.GetPointer());
convert_chart_text(axis->m_oTxPr.GetPointer());
convert(axis->m_title);
convert(axis->m_majorGridlines, 1);
convert(axis->m_minorGridlines, 2);
@ -451,12 +525,6 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Bar3DChart *chart)
if (chart->m_barDir && chart->m_barDir->m_val)
odf_context()->chart_context()->set_chart_bar_direction(*chart->m_barDir->m_val);
if (chart->m_gapWidth && chart->m_gapWidth->m_val)
odf_context()->chart_context()->set_chart_bar_gap_width(*chart->m_gapWidth->m_val);
//if (chart->m_overlap && chart->m_overlap->m_val)
// odf_context()->chart_context()->set_chart_bar_overlap(*chart->m_overlap->m_val);
odf_context()->chart_context()->start_group_series();
convert(chart->m_dLbls);
@ -470,6 +538,34 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Bar3DChart *chart)
}
odf_context()->chart_context()->end_group_series();
}
void OoxConverter::convert_before(OOX::Spreadsheet::CT_Bar3DChart *chart)
{
if (chart == NULL)return;
if (chart->m_gapWidth && chart->m_gapWidth->m_val)
odf_context()->chart_context()->set_chart_bar_gap_width(*chart->m_gapWidth->m_val);
//if (chart->m_overlap && chart->m_overlap->m_val)
// odf_context()->chart_context()->set_chart_bar_overlap(*chart->m_overlap->m_val);
//else
// odf_context()->chart_context()->set_chart_bar_overlap(L"0");
}
void OoxConverter::convert_before(OOX::Spreadsheet::CT_BarChart *chart)
{
if (chart == NULL)return;
if (chart->m_gapWidth && chart->m_gapWidth->m_val)
odf_context()->chart_context()->set_chart_bar_gap_width(*chart->m_gapWidth->m_val);
else
odf_context()->chart_context()->set_chart_bar_overlap(L"100");
if (chart->m_overlap && chart->m_overlap->m_val)
odf_context()->chart_context()->set_chart_bar_overlap(*chart->m_overlap->m_val);
else
odf_context()->chart_context()->set_chart_bar_overlap(L"0");
}
void OoxConverter::convert(OOX::Spreadsheet::CT_BarChart *chart)
{
if (chart == NULL)return;
@ -482,12 +578,6 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_BarChart *chart)
if (chart->m_barDir && chart->m_barDir->m_val)
odf_context()->chart_context()->set_chart_bar_direction(*chart->m_barDir->m_val);
if (chart->m_gapWidth && chart->m_gapWidth->m_val)
odf_context()->chart_context()->set_chart_bar_gap_width(*chart->m_gapWidth->m_val);
if (chart->m_overlap && chart->m_overlap->m_val)
odf_context()->chart_context()->set_chart_bar_overlap(*chart->m_overlap->m_val);
odf_context()->chart_context()->start_group_series();
convert(chart->m_dLbls);
@ -971,6 +1061,8 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_Marker* marker, std::vector<OOX:
convert(dPt[i]->m_marker);
if (dPt[i]->m_explosion && dPt[i]->m_explosion->m_val)
odf_context()->chart_context()->set_series_pie_explosion(*dPt[i]->m_explosion->m_val);
if (dPt[i]->m_bubble3D && dPt[i]->m_bubble3D->m_val)
odf_context()->chart_context()->set_series_pie_bubble(*dPt[i]->m_bubble3D->m_val);
odf_context()->chart_context()->end_element();
current_point = set_point+1;
@ -1000,6 +1092,27 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_DLbls* ser_lbls)
{
bool boolVal = false;
bool bIsFound = false;
switch(*ser_lbls->m_ItemsElementName0[i])
{
case OOX::Spreadsheet::itemschoicetype3DELETE :
case OOX::Spreadsheet::itemschoicetype3SHOWBUBBLESIZE:
case OOX::Spreadsheet::itemschoicetype3SHOWCATNAME:
case OOX::Spreadsheet::itemschoicetype3SHOWLEADERLINES:
case OOX::Spreadsheet::itemschoicetype3SHOWLEGENDKEY:
case OOX::Spreadsheet::itemschoicetype3SHOWPERCENT:
case OOX::Spreadsheet::itemschoicetype3SHOWSERNAME:
case OOX::Spreadsheet::itemschoicetype3SHOWVAL:
bIsFound = true;
break;
default:
break;
}
if (!bIsFound)
continue;
OOX::Spreadsheet::CT_Boolean * ct_boolean = (OOX::Spreadsheet::CT_Boolean*)ser_lbls->m_Items[i];
if (ct_boolean && ct_boolean->m_val) boolVal = * ct_boolean->m_val;

View File

@ -58,6 +58,37 @@ using namespace cpdoccore;
namespace Oox2Odf
{
bool compare (OOX::Logic::CSectionProperty* props1, OOX::Logic::CSectionProperty* props2)
{
size_t cols_1 = 1, cols_2 = 1;
if (props1 && props1->m_oCols.IsInit())
{
cols_1 = props1->m_oCols->m_oNum.IsInit() ? props1->m_oCols->m_oNum->GetValue() : 1;
if (!props1->m_oCols->m_arrColumns.empty())
cols_1 = std::min(cols_1, props1->m_oCols->m_arrColumns.size());
}
if (props2)
{
if (props2->m_oCols.IsInit())
{
cols_2 = props2->m_oCols->m_oNum.IsInit() ? props2->m_oCols->m_oNum->GetValue() : 1;
if (!props2->m_oCols->m_arrColumns.empty())
cols_2 = std::min(cols_2, props2->m_oCols->m_arrColumns.size());
}
else
{
if (props2->m_oType.IsInit() && props2->m_oType->m_oVal.IsInit())
{
if (props2->m_oType->m_oVal->GetValue() == SimpleTypes::sectionmarkContinious)
cols_2 = cols_1;
}
}
}
return cols_1 == cols_2;
}
DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{
const OOX::CPath oox_path(std::wstring(path.c_str()));
@ -181,16 +212,18 @@ void DocxConverter::convert_document()
std::vector<_section> sections;
//----------------------------------------------------------------------------------------------------------
std::list<OOX::WritingElement*>::const_iterator last_section_start = document->m_arrItems.begin();
//считаем количесво секций и запоминаем их свойства ..
for (std::list<OOX::WritingElement*>::const_iterator it = document->m_arrItems.begin(); it != document->m_arrItems.end(); it++)
{
if ((*it) == NULL) continue;
size_t last_section_start = 0;
if ((*it)->getType() == OOX::et_w_p)
OOX::Logic::CSectionProperty* prev = NULL;
for (size_t i = 0; i < document->m_arrItems.size(); ++i)
{
if ((document->m_arrItems[i]) == NULL) continue;
if (document->m_arrItems[i]->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(*it);
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(document->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
{
@ -200,11 +233,13 @@ void DocxConverter::convert_document()
section.props = para->m_oParagraphProperty->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = it; section.end_para++;
section.end_para = i + 1;
section.bContinue = compare (prev, section.props);
sections.push_back(section);
last_section_start = it; last_section_start++;
last_section_start = i + 1;
prev = section.props;
}
}
}
@ -213,7 +248,10 @@ void DocxConverter::convert_document()
section.props = document->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = document->m_arrItems.end();
section.end_para = document->m_arrItems.size();
section.bContinue = compare (prev, section.props);
sections.push_back(section);
//----------------------------------------------------------------------------------------------------------
@ -223,9 +261,9 @@ void DocxConverter::convert_document()
{
current_section_properties = &sections[sect];
for (std::list<OOX::WritingElement*>::const_iterator it = sections[sect].start_para; it != sections[sect].end_para; it++)
for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
{
convert(*it);
convert(document->m_arrItems[i]);
}
}
}
@ -373,7 +411,7 @@ void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
{
if (oox_sdt == NULL) return;
for (std::list<OOX::WritingElement*>::iterator it = oox_sdt->m_arrItems.begin(); it != oox_sdt->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_sdt->m_arrItems.begin(); it != oox_sdt->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -381,7 +419,7 @@ void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
{
if (oox_paragraph == NULL) return;
//---------------------------------------------------------------------------------------------------------------------
if (current_section_properties)
{
@ -478,20 +516,29 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if (odt_context->text_context()->get_KeepNextParagraph())
{
odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
if (state)
{
paragraph_properties = state->get_paragraph_properties();
paragraph_properties = state->get_paragraph_properties();
if (bRunPara)
text_properties = state->get_text_properties();
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit())
if (bRunPara)
text_properties = state->get_text_properties();
if (odt_context->in_drop_cap()) //после буквицы (Nadpis.docx) - нужно накатить свойства параграфа нормального
{
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами
paragraph_properties->content_.clear();
if (text_properties)
text_properties->content_.clear();
//очистить все кроме drop_cap
paragraph_properties->content_.clear(false);
}
else
{
// ????
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit())
{
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами
paragraph_properties->content_.clear(true);
if (text_properties)
text_properties->content_.clear();
}
}
}
}
@ -509,10 +556,25 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
odt_context->styles_context()->last_state()->set_list_style_name(list_style_name);
}
}
if (odt_context->in_drop_cap())
{
odt_context->end_drop_cap();
}
convert(oox_paragraph->m_oParagraphProperty, paragraph_properties);
if (text_properties && oox_paragraph->m_oParagraphProperty)
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
{
if (odt_context->in_drop_cap())
{
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), odt_context->get_drop_cap_properties());
//вообще то свойства правильные параграфа идут в следующем после буквицы параграфе
}
else
{
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
}
}
}
else
{
@ -531,7 +593,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
{//rapcomnat12.docx - стр 185
bool empty_para = true;
for (std::list<OOX::WritingElement*>::iterator it = oox_paragraph->m_arrItems.begin(); it != oox_paragraph->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_paragraph->m_arrItems.begin(); it != oox_paragraph->m_arrItems.end(); ++it)
{
switch((*it)->getType())
{
@ -555,7 +617,7 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
//---------------------------------------------------------------------------------------------------------------------
for (std::list<OOX::WritingElement*>::iterator it = oox_paragraph->m_arrItems.begin(); it != oox_paragraph->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_paragraph->m_arrItems.begin(); it != oox_paragraph->m_arrItems.end(); ++it)
{
//те элементы которые тока для Paragraph - здесь - остальные в общей куче
switch((*it)->getType())
@ -571,8 +633,6 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
//---------------------------------------------------------------------------------------------------------------------
if (odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_drop_cap();
if (!odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_paragraph();
if(list_present && !odt_context->text_context()->get_KeepNextParagraph())
@ -617,7 +677,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
odt_context->start_run(styled);
for (std::list<OOX::WritingElement*>::iterator it = oox_run->m_arrItems.begin(); it != oox_run->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_run->m_arrItems.begin(); it != oox_run->m_arrItems.end(); ++it)
{
//те элементы которые тока для Run - здесь - остальные в общей куче
switch((*it)->getType())
@ -787,7 +847,7 @@ void DocxConverter::convert(OOX::Logic::CFldSimple *oox_fld)
if (oox_fld->m_sInstr.IsInit())
odt_context->set_field_instr(oox_fld->m_sInstr.get2());
for (std::list<OOX::WritingElement*>::iterator it = oox_fld->m_arrItems.begin(); it != oox_fld->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_fld->m_arrItems.begin(); it != oox_fld->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -824,7 +884,7 @@ void DocxConverter::convert(OOX::Logic::CIns *oox_ins)
bool start_change = odt_context->start_change(id, 1, author, userId, date);
for (std::list<OOX::WritingElement*>::iterator it = oox_ins->m_arrItems.begin(); it != oox_ins->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_ins->m_arrItems.begin(); it != oox_ins->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -1029,7 +1089,7 @@ void DocxConverter::convert(OOX::Logic::CDel *oox_del)
bool res_change = odt_context->start_change(id, 2, author, userId, date);
for (std::list<OOX::WritingElement*>::iterator it = oox_del->m_arrItems.begin(); it != oox_del->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_del->m_arrItems.begin(); it != oox_del->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -1040,7 +1100,7 @@ void DocxConverter::convert(OOX::Logic::CSmartTag *oox_tag)
{
if (oox_tag == NULL) return;
for (std::list<OOX::WritingElement*>::iterator it = oox_tag->m_arrItems.begin(); it != oox_tag->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_tag->m_arrItems.begin(); it != oox_tag->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -1054,7 +1114,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
{
if (current_section_properties)
{
convert(current_section_properties->props, current_section_properties->root);
convert(current_section_properties->props, !current_section_properties->bContinue);
}
return;
}
@ -1231,7 +1291,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
{
paragraph_properties->content_.style_page_number_ = current_section_properties->props->m_oPgNumType->m_oStart->GetValue();
}
convert(current_section_properties->props, current_section_properties->root);
convert(current_section_properties->props, !current_section_properties->bContinue);
//odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
//if (odt_context->is_paragraph_in_current_section_ && state)
@ -1327,7 +1387,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi
}
}
}
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root)
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection)
{
if (oox_section_pr == NULL) return;
current_section_properties = NULL;
@ -1352,18 +1412,18 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!last_section_properties && (root || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
if (!last_section_properties && (!bSection || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
{
last_section_properties = oox_section_pr;
}
else if (root || continuous == false)
else if (!bSection || continuous == false)
{
apply_HF_from(last_section_properties, oox_section_pr);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (root || continuous == false)
if (!bSection || continuous == false)
{
odt_context->page_layout_context()->add_master_page(root ? L"Standard" : L"");
odt_context->page_layout_context()->add_master_page(bSection ? L"" : L"Standard");
}
bool present_header = false;
@ -1498,7 +1558,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle;
}
if (continuous == false || root || oox_section_pr->m_oTitlePg.IsInit())
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit())
{
OOX::Logic::CSectionProperty* s = last_section_properties;
@ -1589,53 +1649,46 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<ComplexTypes::Word::CRel > m_oPrinterSettings;
//nullable<OOX::Logic::CSectPrChange > m_oSectPrChange;
//--------------------------------------------------------------------------------------------------------------------------------------------
int num_columns = 1;
if (oox_section_pr->m_oCols.IsInit())
if (bSection)
{
num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1;
odt_context->add_section(continuous);
}
if (bSection && oox_section_pr->m_oCols.IsInit())
{
int num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1;
if (num_columns > 1 && oox_section_pr->m_oCols->m_arrColumns.size() > 0)
num_columns = /*(std::max)*/( /*num_columns,*/ (int)oox_section_pr->m_oCols->m_arrColumns.size()) ;
}
if (/*num_columns != odt_context->get_current_section_columns() || */num_columns >= 1) //колонки
{
if (!root || num_columns > 1)
odt_context->add_section(continuous);
double default_space_pt = -1;
if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints();
if (oox_section_pr->m_oCols.IsInit())
{
double default_space_pt = -1;
if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints();
bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
std::vector<std::pair<double,double>> width_space;
std::vector<std::pair<double,double>> width_space;
for (size_t i =0; i< oox_section_pr->m_oCols->m_arrColumns.size(); i++)
{
if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue;
double space = default_space_pt;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit())
space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints();
double w = -1;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oW.IsInit())
w = oox_section_pr->m_oCols->m_arrColumns[i]->m_oW->ToPoints();
for (size_t i =0; i< oox_section_pr->m_oCols->m_arrColumns.size(); i++)
{
if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue;
double space = default_space_pt;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit())
space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints();
double w = -1;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oW.IsInit())
w = oox_section_pr->m_oCols->m_arrColumns[i]->m_oW->ToPoints();
width_space.push_back(std::pair<double,double>(w, space));
}
//for (size_t i= oox_section_pr->m_oCols->m_arrColumns.size(); i< num_columns; i ++)
//{
// width_space.push_back(std::pair<double,double>(-1, default_space_pt));
//}
odt_context->add_section_column(width_space);
width_space.push_back(std::pair<double,double>(w, space));
}
//for (size_t i= oox_section_pr->m_oCols->m_arrColumns.size(); i< num_columns; i ++)
//{
// width_space.push_back(std::pair<double,double>(-1, default_space_pt));
//}
odt_context->add_section_column(width_space);
}
}
void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type)
@ -2414,8 +2467,8 @@ void DocxConverter::convert(OOX::Logic::CPicture* oox_pic)
odf_context()->drawing_context()->set_name(std::wstring (L"Custom") + std::to_wstring(sptType));
odf_context()->drawing_context()->start_shape(OOX::VmlShapeType2PrstShape(sptType));
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
OoxConverter::convert(oox_pic->m_oShapeType.GetPointer());
OoxConverter::convert(oox_pic->m_oShape.GetPointer());
odf_context()->drawing_context()->end_shape();
}
@ -2913,7 +2966,7 @@ void DocxConverter::convert(OOX::Logic::CHyperlink *oox_hyperlink)
odt_context->start_hyperlink(ref);
for (std::list<OOX::WritingElement*>::iterator it = oox_hyperlink->m_arrItems.begin(); it != oox_hyperlink->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_hyperlink->m_arrItems.begin(); it != oox_hyperlink->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -2922,7 +2975,7 @@ void DocxConverter::convert(OOX::Logic::CHyperlink *oox_hyperlink)
else
{//ссылка внутри дока
//anchor todooo
for (std::list<OOX::WritingElement*>::iterator it = oox_hyperlink->m_arrItems.begin(); it != oox_hyperlink->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_hyperlink->m_arrItems.begin(); it != oox_hyperlink->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -3477,7 +3530,7 @@ void DocxConverter::convert_comment(int oox_comm_id)
if (oox_comment->m_oDate.IsInit()) odt_context->comment_context()->set_date (oox_comment->m_oDate->GetValue());
if (oox_comment->m_oInitials.IsInit()) {}
for (std::list<OOX::WritingElement*>::iterator it = oox_comment->m_arrItems.begin(); it != oox_comment->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_comment->m_arrItems.begin(); it != oox_comment->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -3504,7 +3557,7 @@ void DocxConverter::convert_footnote(int oox_ref_id)
{
odt_context->start_note_content();
{
for (std::list<OOX::WritingElement*>::iterator it = oox_note->m_arrItems.begin(); it != oox_note->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_note->m_arrItems.begin(); it != oox_note->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -3532,7 +3585,7 @@ void DocxConverter::convert_endnote(int oox_ref_id)
{
odt_context->start_note_content();
{
for (std::list<OOX::WritingElement*>::iterator it = oox_note->m_arrItems.begin(); it != oox_note->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_note->m_arrItems.begin(); it != oox_note->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -3549,7 +3602,7 @@ void DocxConverter::convert_hdr_ftr (std::wstring sId)
oox_current_child_document = dynamic_cast<OOX::IFileContainer*>(oox_hdr_ftr);
for (std::list<OOX::WritingElement*>::iterator it = oox_hdr_ftr->m_arrItems.begin(); it != oox_hdr_ftr->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_hdr_ftr->m_arrItems.begin(); it != oox_hdr_ftr->m_arrItems.end(); ++it)
{
convert(*it);
}
@ -3611,7 +3664,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
if (in_frame)
{
if (current_section_properties)
convert(current_section_properties->props, current_section_properties->root);
convert(current_section_properties->props, !current_section_properties->bContinue);
odt_context->start_paragraph();
@ -3728,7 +3781,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
convert(oox_table->m_oTblGrid.GetPointer());
//------ строки
for (std::list<OOX::WritingElement*>::iterator it = oox_table->m_arrItems.begin(); it != oox_table->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_table->m_arrItems.begin(); it != oox_table->m_arrItems.end(); ++it)
{
switch((*it)->getType())
{
@ -3844,7 +3897,7 @@ void DocxConverter::convert(OOX::Logic::CTr *oox_table_row)
convert(oox_table_row->m_pTableRowProperties);
for (std::list<OOX::WritingElement*>::iterator it = oox_table_row->m_arrItems.begin(); it != oox_table_row->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_table_row->m_arrItems.begin(); it != oox_table_row->m_arrItems.end(); ++it)
{
switch((*it)->getType())
{
@ -3904,7 +3957,7 @@ void DocxConverter::convert(OOX::Logic::CTc *oox_table_cell)
odt_context->table_context()->set_cell_column_span(oox_table_cell->m_pTableCellProperties->m_oGridSpan->m_oVal->GetValue());
}
for (std::list<OOX::WritingElement*>::iterator it = oox_table_cell->m_arrItems.begin(); it != oox_table_cell->m_arrItems.end(); it++)
for (std::vector<OOX::WritingElement*>::iterator it = oox_table_cell->m_arrItems.begin(); it != oox_table_cell->m_arrItems.end(); ++it)
{
switch((*it)->getType())
{
@ -3926,13 +3979,23 @@ bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, odf_writer
if (oox_table_pr == NULL) return false;
if (table_properties == NULL) return false;
if (oox_table_pr->m_oTblW.IsInit())
if (oox_table_pr->m_oTblW.IsInit() && oox_table_pr->m_oTblW->m_oW.IsInit())
{
if ((oox_table_pr->m_oTblW->m_oType.IsInit() && oox_table_pr->m_oTblW->m_oType->GetValue() == SimpleTypes::tblwidthDxa) &&
(oox_table_pr->m_oTblW->m_oW.IsInit() && oox_table_pr->m_oTblW->m_oW->GetValue() >0))
if (oox_table_pr->m_oTblW->m_oType.IsInit() && oox_table_pr->m_oTblW->m_oW.IsInit())
{
if (oox_table_pr->m_oTblW->m_oW->IsPercent() == false)
odt_context->table_context()->set_default_column_width(oox_table_pr->m_oTblW->m_oW->GetValue()/20.);
if ( oox_table_pr->m_oTblW->m_oType->GetValue() == SimpleTypes::tblwidthDxa &&
oox_table_pr->m_oTblW->m_oW->GetValue() > 0 )
{
if ( oox_table_pr->m_oTblW->m_oW->IsPercent() == false)
odt_context->table_context()->set_default_column_width(oox_table_pr->m_oTblW->m_oW->GetValue() / 20.);
}
else if ( oox_table_pr->m_oTblW->m_oType->GetValue() == SimpleTypes::tblwidthAuto &&
oox_table_pr->m_oTblW->m_oW->GetValue() == 0 )
{
//динамическое расширение - автоподбор по содержимому.
odt_context->table_context()->set_optimal_column_width(true);
table_properties->table_format_properties_.style_use_optimal_column_width_ = true;
}
}
}
@ -4033,7 +4096,7 @@ bool DocxConverter::convert(OOX::Logic::CTableProperty *oox_table_pr, bool base_
{//напрямую задать cell_prop на саму таблицу низя - тока как default-cell-style-name на columns & row
//общие свойства ячеек
odt_context->styles_context()->create_style(L"",odf_types::style_family::TableCell, true, false, -1); //ради нормального задания дефолтовых свойств на cells
odt_context->styles_context()->create_style(L"", odf_types::style_family::TableCell, true, false, -1); //ради нормального задания дефолтовых свойств на cells
odt_context->styles_context()->last_state()->set_dont_write(true);
odf_writer::style_table_cell_properties * table_cell_properties = odt_context->styles_context()->last_state()->get_table_cell_properties();

View File

@ -158,11 +158,11 @@ namespace Oox2Odf
private:
struct _section
{
OOX::Logic::CSectionProperty *props;
std::list<OOX::WritingElement*>::const_iterator start_para;
std::list<OOX::WritingElement*>::const_iterator end_para;
OOX::Logic::CSectionProperty *props;
size_t start_para;
size_t end_para;
bool root;
bool bContinue = false;
} *current_section_properties;
OOX::CDocx *docx_document;
cpdoccore::odf_writer::package::odf_document *output_document;
@ -184,7 +184,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CBackground *oox_background, int type);
void convert(OOX::Logic::CSdt *oox_sdt);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root = false);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection);
void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run);
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);

View File

@ -42,6 +42,8 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CTn.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EmptyTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/OrientationTransition.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Transitions/EightDirectionTransition.h"
@ -1338,51 +1340,66 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
for (size_t i = 0 ; i < oox_slide->spTree.SpTreeElems.size(); i++)
{
smart_ptr<PPTX::WrapperWritingElement> pElem = oox_slide->spTree.SpTreeElems[i].GetElem();
smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
smart_ptr<PPTX::Logic::Shape> pShape = pElem.smart_dynamic_cast<PPTX::Logic::Shape>();
smart_ptr<PPTX::Logic::Pic> pPic = pElem.smart_dynamic_cast<PPTX::Logic::Pic>();
odf_context()->drawing_context()->start_drawing();
PPTX::Logic::NvPr *pNvPr = NULL;
if (pShape.IsInit())
if (pShape.IsInit()) pNvPr = &pShape->nvSpPr.nvPr;
if (pPic.IsInit()) pNvPr = &pPic->nvPicPr.nvPr;
bool bConvert = false;
if ((pNvPr) && (pNvPr->ph.is_init()))
{
if (pShape->nvSpPr.nvPr.ph.is_init())
if (type == Notes || type == NotesMaster)
{
if (type == Notes || type == NotesMaster)
{
pShape->nvSpPr.nvPr.ph->idx.reset();
}
if (bFillUp)
pShape->FillLevelUp();
if (pShape->nvSpPr.nvPr.ph->type.IsInit())
{
int ph_type = pShape->nvSpPr.nvPr.ph->type->GetBYTECode();
if (pShape.IsInit()) pShape->nvSpPr.nvPr.ph->idx.reset();
if (pPic.IsInit()) pPic->nvPicPr.nvPr.ph->idx.reset();
}
if (bFillUp)
{
if (pShape.IsInit()) pShape->FillLevelUp();
if (pPic.IsInit()) pPic->FillLevelUp();
}
if (pNvPr->ph->type.IsInit())
{
int ph_type = pNvPr->ph->type->GetBYTECode();
if (type == Layout && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
continue;
odf_context()->drawing_context()->set_placeholder_type(ph_type);
}
else
odf_context()->drawing_context()->set_placeholder_type(0);
if (pShape->nvSpPr.nvPr.ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(pShape->nvSpPr.nvPr.ph->idx.get());
if (!bPlaceholders)
if (type == Layout && (ph_type == 5 || ph_type == 6 || ph_type == 7 || ph_type == 12))
continue;
PPTX::Logic::TextListStyle * listMasterStyle = NULL;
odf_context()->drawing_context()->set_placeholder_type(ph_type);
}
else
odf_context()->drawing_context()->set_placeholder_type(0);
if (pNvPr->ph->idx.IsInit())
odf_context()->drawing_context()->set_placeholder_id(pNvPr->ph->idx.get());
if (!bPlaceholders)
continue;
PPTX::Logic::TextListStyle * listMasterStyle = NULL;
if (txStyles)
{
std::wstring type = pNvPr->ph->type.get_value_or(_T("body"));
if (txStyles)
{
std::wstring type = pShape->nvSpPr.nvPr.ph->type.get_value_or(_T("body"));
if ((type == L"title") || (type == L"ctrTitle"))
listMasterStyle = txStyles->titleStyle.GetPointer();
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
listMasterStyle = txStyles->bodyStyle.GetPointer();
else if (type != L"")
listMasterStyle = txStyles->otherStyle.GetPointer();
}
if ((type == L"title") || (type == L"ctrTitle"))
listMasterStyle = txStyles->titleStyle.GetPointer();
else if ((type == L"body") || (type == L"subTitle") || (type == L"obj"))
listMasterStyle = txStyles->bodyStyle.GetPointer();
else if (type != L"")
listMasterStyle = txStyles->otherStyle.GetPointer();
}
if (pShape.IsInit())
{
PPTX::Logic::Shape update_shape;
if (listMasterStyle)
@ -1401,24 +1418,36 @@ void PptxConverter::convert_slide(PPTX::Logic::CSld *oox_slide, PPTX::Logic::TxS
pShape->Merge(update_shape);
OoxConverter::convert(&update_shape);
}
else if (pShape->txBody.IsInit() && presentation->defaultTextStyle.IsInit())
{//default text style with master clrScheme
PPTX::Logic::Shape update_shape;
if (pPic.IsInit())
{
PPTX::Logic::Pic update_shape;
update_shape.txBody = new PPTX::Logic::TxBody();
presentation->defaultTextStyle->Merge(update_shape.txBody->lstStyle);
pShape->Merge(update_shape);
pPic->Merge(update_shape);
OoxConverter::convert(&update_shape);
}
else
OoxConverter::convert(pShape.operator->());
bConvert = true;
}
else
if (!bConvert && (pShape.IsInit()) && (pShape->txBody.IsInit() && presentation->defaultTextStyle.IsInit()))
{//default text style with master clrScheme
PPTX::Logic::Shape update_shape;
update_shape.txBody = new PPTX::Logic::TxBody();
presentation->defaultTextStyle->Merge(update_shape.txBody->lstStyle);
pShape->Merge(update_shape);
OoxConverter::convert(&update_shape);
bConvert = true;
}
if (!bConvert)
{
OoxConverter::convert(pElem.operator->());
}
odf_context()->drawing_context()->end_drawing();
}
convert(oox_slide->controls.GetPointer());

View File

@ -162,27 +162,25 @@ void XlsxConverter::convert_sheets()
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->GetWorkbook();
if (!Workbook) return;
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*> &arrWorksheets = xlsx_document->GetWorksheets();
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*> &arrWorksheets = xlsx_document->GetWorksheets();
if(Workbook->m_oBookViews.IsInit())
{
for (std::list<OOX::Spreadsheet::CWorkbookView*>::iterator it = Workbook->m_oBookViews->m_arrItems.begin();
it != Workbook->m_oBookViews->m_arrItems.end(); it++)
for (size_t i = 0; i < Workbook->m_oBookViews->m_arrItems.size(); i++)
{
convert(*it);
convert(Workbook->m_oBookViews->m_arrItems[i]);
}
}
if(Workbook->m_oSheets.IsInit())
{
for (std::list<OOX::Spreadsheet::CSheet*>::iterator it = Workbook->m_oSheets->m_arrItems.begin();
it != Workbook->m_oSheets->m_arrItems.end(); it++)
for(size_t i = 0, length = Workbook->m_oSheets->m_arrItems.size(); i < length; ++i)
{
OOX::Spreadsheet::CSheet* pSheet = *it;
OOX::Spreadsheet::CSheet* pSheet = Workbook->m_oSheets->m_arrItems[i];
if(pSheet->m_oRid.IsInit())
{
std::wstring sSheetRId = pSheet->m_oRid.get2().ToString();
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::iterator pItWorksheet = arrWorksheets.find(sSheetRId);
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>::iterator pItWorksheet = arrWorksheets.find(sSheetRId);
if (pItWorksheet->second)
{
@ -200,10 +198,9 @@ void XlsxConverter::convert_sheets()
}
if (Workbook->m_oDefinedNames.IsInit())
{
for (std::list<OOX::Spreadsheet::CDefinedName*>::iterator it = Workbook->m_oDefinedNames->m_arrItems.begin();
it != Workbook->m_oDefinedNames->m_arrItems.end(); it++)
for (size_t i = 0; i < Workbook->m_oDefinedNames->m_arrItems.size(); i++)
{
convert(*it);
convert(Workbook->m_oDefinedNames->m_arrItems[i]);
}
}
}
@ -247,13 +244,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(oox_sheet->m_oSheetPr.GetPointer());
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Предобработка
for (std::list<OOX::Spreadsheet::CHyperlink*>::iterator it = oox_sheet->m_oHyperlinks->m_arrItems.begin();
it != oox_sheet->m_oHyperlinks->m_arrItems.end(); it++)
//гиперлинки
for (size_t hyp = 0; oox_sheet->m_oHyperlinks.IsInit() && hyp < oox_sheet->m_oHyperlinks->m_arrItems.size(); hyp++)
{
convert(*it, oox_sheet);
}
convert(oox_sheet->m_oHyperlinks->m_arrItems[hyp],oox_sheet);
}
//комментарии
std::map<std::wstring, OOX::Spreadsheet::CCommentItem*>::iterator pos = oox_sheet->m_mapComments.begin();
boost::unordered_map<std::wstring, OOX::Spreadsheet::CCommentItem*>::iterator pos = oox_sheet->m_mapComments.begin();
while ( oox_sheet->m_mapComments.end() != pos )
{
convert(pos->second);
@ -262,39 +259,35 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
//todooo для оптимизации - перенести мержи в начало
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//колонки
ods_context->start_columns();
for (std::list<OOX::Spreadsheet::CCol*>::iterator it = oox_sheet->m_oCols->m_arrItems.begin();
it != oox_sheet->m_oCols->m_arrItems.end(); it++)
{
convert(*it);
}
ods_context->end_columns();
ods_context->start_columns();
for (size_t col = 0 ; oox_sheet->m_oCols.IsInit() && col < oox_sheet->m_oCols->m_arrItems.size(); col++)
{
convert(oox_sheet->m_oCols->m_arrItems[col]);
}
ods_context->end_columns();
//строки
if (oox_sheet->m_oSheetData.IsInit() )
{
ods_context->start_rows();
for (size_t row = 0 ; row < oox_sheet->m_oSheetData->m_arrItems.size(); row++)
for (std::list<OOX::Spreadsheet::CRow*>::iterator it = oox_sheet->m_oSheetData->m_arrItems.begin();
it != oox_sheet->m_oSheetData->m_arrItems.end(); it++)
{
convert(*it);
convert(oox_sheet->m_oSheetData->m_arrItems[row]);
//оптимизация памяти - удаляем уже не нужное
if ( *it ) delete *it;
*it = NULL;
if ( oox_sheet->m_oSheetData->m_arrItems[row] )
delete oox_sheet->m_oSheetData->m_arrItems[row];
oox_sheet->m_oSheetData->m_arrItems[row] = NULL;
}
ods_context->end_rows();
oox_sheet->m_oSheetData.reset();
}
for (std::list<OOX::Spreadsheet::CMergeCell*>::iterator it = oox_sheet->m_oMergeCells->m_arrItems.begin();
it != oox_sheet->m_oMergeCells->m_arrItems.end(); it++)
//мержи
for (size_t mrg = 0 ; oox_sheet->m_oMergeCells.IsInit() && mrg < oox_sheet->m_oMergeCells->m_arrItems.size(); mrg++)
{
if ((*it) && ((*it)->m_oRef.IsInit()))
{
ods_context->add_merge_cells((*it)->m_oRef.get());
if (oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.IsInit())
ods_context->add_merge_cells(oox_sheet->m_oMergeCells->m_arrItems[mrg]->m_oRef.get());
}
}
if (oox_sheet->m_oDrawing.IsInit() && oox_sheet->m_oDrawing->m_oId.IsInit())
{
smart_ptr<OOX::File> oFile = oox_sheet->Find(oox_sheet->m_oDrawing->m_oId->GetValue());
@ -327,10 +320,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
//выносные части таблицы
if (oox_sheet->m_oTableParts.IsInit())
{
for (std::list<OOX::Spreadsheet::CTablePart*>::iterator it = oox_sheet->m_oTableParts->m_arrItems.begin();
it != oox_sheet->m_oTableParts->m_arrItems.end(); it++)
for (size_t i=0 ; i < oox_sheet->m_oTableParts->m_arrItems.size(); i++)
{
OOX::Spreadsheet::CTablePart *oox_table_part = *it;
OOX::Spreadsheet::CTablePart *oox_table_part = oox_sheet->m_oTableParts->m_arrItems[i];
if (!oox_table_part)continue;
if (!oox_table_part->m_oRId.IsInit())continue;
@ -354,6 +346,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
convert(oox_sheet->m_oPageSetup.GetPointer());
convert(oox_sheet->m_oPageMargins.GetPointer());
convert(oox_sheet->m_oPicture.GetPointer());
OoxConverter::convert(oox_sheet->m_oExtLst.GetPointer());
xlsx_current_container = old_container;
}
@ -413,8 +407,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CTable *oox_table_part)
if (oox_table_part->m_oAutoFilter.IsInit())
ods_context->set_table_part_autofilter(true);
OoxConverter::convert(oox_table_part->m_oExtLst.GetPointer());
ods_context->end_table_part();
}
void XlsxConverter::convert(OOX::Spreadsheet::CCommentItem * oox_comment)
@ -434,10 +429,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CCommentItem * oox_comment)
if (oox_comment->m_oText.IsInit())
{
for (std::list<OOX::Spreadsheet::WritingElement*>::iterator it = oox_comment->m_oText->m_arrItems.begin();
it != oox_comment->m_oText->m_arrItems.end(); it++)
for(size_t i = 0; i < oox_comment->m_oText->m_arrItems.size(); ++i)
{
convert(*it);
convert(oox_comment->m_oText->m_arrItems[i]);
}
}
ods_context->end_comment();
@ -515,9 +509,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row)
}else
ods_context->current_table().set_row_optimal_height(true);
for (std::list<OOX::Spreadsheet::CCell*>::iterator it = oox_row->m_arrItems.begin(); it != oox_row->m_arrItems.end(); it++)
for (size_t cell = 0 ; cell < oox_row->m_arrItems.size();cell++)
{
convert(*it);
convert(oox_row->m_arrItems[cell]);
}
ods_context->end_row();
}
@ -576,12 +570,9 @@ void XlsxConverter::convert_sharing_string(int number)
const OOX::Spreadsheet::CSharedStrings *SharedStrings= xlsx_document->GetSharedStrings();
if (!SharedStrings) return;
std::unordered_map<int, OOX::Spreadsheet::CSi*>::const_iterator pFind = SharedStrings->m_mapItems.find(number);
if (number >=0 && number < SharedStrings->m_arrItems.size())
if (pFind != SharedStrings->m_mapItems.end())
{
convert(pFind->second);
}
convert(SharedStrings->m_arrItems[number]);
}
void XlsxConverter::convert(OOX::Spreadsheet::CSi* oox_rtf_text)
@ -590,9 +581,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSi* oox_rtf_text)
ods_context->start_cell_text();
for (std::list<OOX::Spreadsheet::WritingElement*>::iterator it = oox_rtf_text->m_arrItems.begin(); it != oox_rtf_text->m_arrItems.end(); it++)
for(size_t i = 0; i < oox_rtf_text->m_arrItems.size(); ++i)
{
convert(*it);
convert(oox_rtf_text->m_arrItems[i]);
}
ods_context->end_cell_text();
@ -624,14 +615,24 @@ void XlsxConverter::convert(OOX::Spreadsheet::WritingElement *oox_unknown)
OOX::Spreadsheet::CDataBar *pB = dynamic_cast<OOX::Spreadsheet::CDataBar*>(oox_unknown);
convert(pB);
}break;
case OOX::et_x_ColorScale:
{
OOX::Spreadsheet::CColorScale *pB = dynamic_cast<OOX::Spreadsheet::CColorScale*>(oox_unknown);
convert(pB);
}break;
case OOX::et_x_FormulaCF:
{
OOX::Spreadsheet::CFormulaCF *pF = dynamic_cast<OOX::Spreadsheet::CFormulaCF*>(oox_unknown);
convert(pF);
}break;
case OOX::et_x_ConditionalFormatValueObject:
{
OOX::Spreadsheet::CConditionalFormatValueObject *pF = dynamic_cast<OOX::Spreadsheet::CConditionalFormatValueObject*>(oox_unknown);
convert(pF);
}break;
default:
{
_CP_LOG << L"[warning] : no convert element(" << oox_unknown->getType() << L")\n";
OoxConverter::convert(oox_unknown);
}
}
}
@ -643,9 +644,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRun *oox_text_run)
convert(oox_text_run->m_oRPr.GetPointer());
ods_context->text_context()->start_span(oox_text_run->m_oRPr.GetPointer() ? true : false);
for (std::list<OOX::Spreadsheet::CText*>::iterator it = oox_text_run->m_arrItems.begin(); it != oox_text_run->m_arrItems.end(); it++)
for(size_t i = 0; i < oox_text_run->m_arrItems.size(); ++i)
{
convert(*it);
convert(oox_text_run->m_arrItems[i]);
}
ods_context->text_context()->end_span();
}
@ -924,9 +925,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
{
if (!oox_sheet_views)return;
for (std::list<OOX::Spreadsheet::CSheetView*>::iterator it = oox_sheet_views->m_arrItems.begin(); it != oox_sheet_views->m_arrItems.end(); it++)
for (unsigned long i =0; i < oox_sheet_views->m_arrItems.size(); i++)
{
OOX::Spreadsheet::CSheetView *sheet_view = *it;
OOX::Spreadsheet::CSheetView *sheet_view = oox_sheet_views->m_arrItems[i];
if (!sheet_view) continue;
int view_id = sheet_view->m_oWorkbookViewId->GetValue();
@ -968,10 +969,9 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetViews *oox_sheet_views)
bool bPaneY = false;
int ActiveCellX = -1, ActiveCellY = -1;
for (std::list<OOX::Spreadsheet::CSelection*>::iterator it = sheet_view->m_arrItems.begin();
it != sheet_view->m_arrItems.end(); it++)
for (size_t j = 0; j < sheet_view->m_arrItems.size(); j++)
{
OOX::Spreadsheet::CSelection *selection = *it;
OOX::Spreadsheet::CSelection *selection = sheet_view->m_arrItems[j];
if (selection->m_oActiveCell.IsInit())
{
@ -1211,42 +1211,35 @@ void XlsxConverter::convert_styles()
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
if (!xlsx_styles)return;
int i = 0;
//todooo ?? стоит ли обращать на параметр Count ??
////////////форматы данных
for (std::list<OOX::Spreadsheet::CNumFmt*>::iterator it = xlsx_styles->m_oNumFmts->m_arrItems.begin();
xlsx_styles->m_oNumFmts.IsInit() && it != xlsx_styles->m_oNumFmts->m_arrItems.end(); it++)
for (size_t i = 0; xlsx_styles->m_oNumFmts.IsInit() && i < xlsx_styles->m_oNumFmts->m_arrItems.size(); i++)
{
convert(*it);
convert(xlsx_styles->m_oNumFmts->m_arrItems[i]);
}
/////////////стили ячеек
for (std::list<OOX::Spreadsheet::CXfs*>::iterator it = xlsx_styles->m_oCellStyleXfs->m_arrItems.begin();
xlsx_styles->m_oCellStyleXfs.IsInit() && it != xlsx_styles->m_oCellStyleXfs->m_arrItems.end(); it++)
for (size_t i = 0; xlsx_styles->m_oCellStyleXfs.IsInit() && i < xlsx_styles->m_oCellStyleXfs->m_arrItems.size(); i++)
{
//automatical, root - noname - они тока для named
convert(*it , i++, true, true);
convert(xlsx_styles->m_oCellStyleXfs->m_arrItems[i] , i, true, true);
}
for (std::list<OOX::Spreadsheet::CCellStyle*>::iterator it = xlsx_styles->m_oCellStyles->m_arrItems.begin();
xlsx_styles->m_oCellStyles.IsInit() && it != xlsx_styles->m_oCellStyles->m_arrItems.end(); it++)
for (size_t i = 0; xlsx_styles->m_oCellStyles.IsInit() && i < xlsx_styles->m_oCellStyles->m_arrItems.size(); i++)//styles.xml
{
//non automatical, root - named
convert(*it);
convert(xlsx_styles->m_oCellStyles->m_arrItems[i]);
}
i = 0;
//кастомные стили ячеек
for (std::list<OOX::Spreadsheet::CXfs*>::iterator it = xlsx_styles->m_oCellXfs->m_arrItems.begin();
xlsx_styles->m_oCellXfs.IsInit() && it != xlsx_styles->m_oCellXfs->m_arrItems.end(); it++)
for (size_t i = 0; xlsx_styles->m_oCellXfs.IsInit() && i < xlsx_styles->m_oCellXfs->m_arrItems.size(); i++)
{
//automatical, non root
convert(*it, i++, true, false);
convert(xlsx_styles->m_oCellXfs->m_arrItems[i], i, true, false);
}
////////////стили условного форматирования
for (std::list<OOX::Spreadsheet::CDxf*>::iterator it = xlsx_styles->m_oDxfs->m_arrItems.begin();
xlsx_styles->m_oDxfs.IsInit() && it != xlsx_styles->m_oDxfs->m_arrItems.end(); it++)
for (size_t i=0; xlsx_styles->m_oDxfs.IsInit() && i < xlsx_styles->m_oDxfs->m_arrItems.size(); i++)
{
convert(*it, i);
convert(xlsx_styles->m_oDxfs->m_arrItems[i], i);
}
}
@ -1905,7 +1898,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDrawing *oox_drawing, OOX::Spread
if (oox_sheet->m_oOleObjects.IsInit() && oox_anchor->m_nId.IsInit())
{
std::map<int, OOX::Spreadsheet::COleObject*>::const_iterator pFind = oox_sheet->m_oOleObjects->m_mapOleObjects.find(oox_anchor->m_nId.get());
boost::unordered_map<int, OOX::Spreadsheet::COleObject*>::const_iterator pFind = oox_sheet->m_oOleObjects->m_mapOleObjects.find(oox_anchor->m_nId.get());
if (pFind != oox_sheet->m_oOleObjects->m_mapOleObjects.end())
{
//??? перенести даные привязки
@ -1925,7 +1918,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::COleObjects *oox_objects, OOX::Spr
{
if (!oox_objects) return;
for (std::map<int, OOX::Spreadsheet::COleObject*>::const_iterator it = oox_objects->m_mapOleObjects.begin(); it != oox_objects->m_mapOleObjects.end(); ++it)
for (boost::unordered_map<int, OOX::Spreadsheet::COleObject*>::const_iterator it = oox_objects->m_mapOleObjects.begin(); it != oox_objects->m_mapOleObjects.end(); ++it)
{
OOX::Spreadsheet::COleObject* object = it->second;
ods_context->start_drawings();
@ -2003,6 +1996,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFromTo* oox_from_to, oox_table_po
if (oox_from_to->m_oColOff.IsInit()) pos->col_off = oox_from_to->m_oColOff->GetValue();//pt
}
void XlsxConverter::convert(OOX::Spreadsheet::CSparklineGroups *sparkline)
{
if (!sparkline)return;
}
void XlsxConverter::convert(OOX::Spreadsheet::CAltTextTable *alt_text)
{
if (!alt_text)return;
}
void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt)
{
if (!oox_cond_fmt)return;
@ -2011,11 +2013,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_f
{
ods_context->current_table().start_conditional_format(oox_cond_fmt->m_oSqRef.get());
for (std::list<OOX::Spreadsheet::CConditionalFormattingRule*>::iterator it = oox_cond_fmt->m_arrItems.begin();
it != oox_cond_fmt->m_arrItems.end(); it++)
{
convert(*it);//rule
}
for (size_t i=0; i< oox_cond_fmt->m_arrItems.size(); i++)
convert(oox_cond_fmt->m_arrItems[i]);//rule
ods_context->current_table().end_conditional_format();
}
@ -2037,11 +2036,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_co
if (oox_cond_rule->m_oOperator.IsInit())
ods_context->current_table().set_conditional_operator(oox_cond_rule->m_oOperator->GetValue());
for (std::list<OOX::Spreadsheet::WritingElement*>::iterator it = oox_cond_rule->m_arrItems.begin();
it != oox_cond_rule->m_arrItems.end(); it++)
{
convert(*it);
}
for (size_t i=0; i< oox_cond_rule->m_arrItems.size(); i++)
convert(oox_cond_rule->m_arrItems[i]);
}
ods_context->current_table().end_conditional_rule();
}
@ -2057,18 +2053,17 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDataBar *oox_cond_databar)
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMaxLength;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMinLength;
//nullable<SimpleTypes::COnOff<>> m_oShowValue;
for (std::list<OOX::Spreadsheet::CConditionalFormatValueObject*>::iterator it = oox_cond_databar->m_arrItems.begin();
it != oox_cond_databar->m_arrItems.end(); it++)
{
convert(*it);
}
for (size_t i=0; i< oox_cond_databar->m_arrItems.size(); i++)
convert(oox_cond_databar->m_arrItems[i]);
}
void XlsxConverter::convert(OOX::Spreadsheet::CColorScale *oox_cond_colorscale)
{
if (!oox_cond_colorscale)return;
int index = 0;
for (std::list<OOX::Spreadsheet::WritingElement*>::iterator it = oox_cond_colorscale->m_arrItems.begin();
it != oox_cond_colorscale->m_arrItems.end(); it++)
for (std::vector<OOX::Spreadsheet::WritingElement*>::iterator it = oox_cond_colorscale->m_arrItems.begin();
it != oox_cond_colorscale->m_arrItems.end(); ++it)
{
if (*it == NULL )continue;
@ -2082,7 +2077,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColorScale *oox_cond_colorscale)
_CP_OPT(odf_types::color) color;
convert(dynamic_cast<OOX::Spreadsheet::CColor*>(*it), color);
ods_context->current_table().add_conditional_colorscale( color );
ods_context->current_table().add_conditional_colorscale( index++, color );
}
}
}
@ -2095,11 +2090,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CIconSet *oox_cond_iconset)
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMaxLength;
//nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oMinLength;
//nullable<SimpleTypes::COnOff<>> m_oShowValue;
for (std::list<OOX::Spreadsheet::CConditionalFormatValueObject*>::iterator it = oox_cond_iconset->m_arrItems.begin();
it != oox_cond_iconset->m_arrItems.end(); it++)
{
convert(*it);
}
for (size_t i=0; i< oox_cond_iconset->m_arrItems.size(); i++)
convert(oox_cond_iconset->m_arrItems[i]);
}
void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox_cond_value)
{
@ -2107,12 +2099,14 @@ void XlsxConverter::convert(OOX::Spreadsheet::CConditionalFormatValueObject *oox
std::wstring val;
int type = 3;
if (oox_cond_value->m_oVal.IsInit()) val = oox_cond_value->m_oVal.get2();
if (oox_cond_value->m_oType.IsInit()) type = oox_cond_value->m_oType->GetValue();
ods_context->current_table().set_conditional_value(type,val);
if (oox_cond_value->m_oFormula.IsInit()) val = oox_cond_value->m_oFormula->m_sText;
else if (oox_cond_value->m_oVal.IsInit()) val = oox_cond_value->m_oVal.get2();
ods_context->current_table().set_conditional_value(type, val);
}
void XlsxConverter::convert(OOX::Spreadsheet::CFormulaCF *oox_cond_formula)
void XlsxConverter::convert(OOX::Spreadsheet::CFormulaCF *oox_cond_formula)
{
if (!oox_cond_formula)return;
ods_context->current_table().set_conditional_formula(oox_cond_formula->m_sText);

View File

@ -89,7 +89,9 @@ namespace OOX
class CSi;
class CWorkbookView;
class CPictureWorksheet;
class CHeaderFooter;
class CHeaderFooter;
class CSparklineGroups;
class CAltTextTable;
}
}
@ -126,6 +128,8 @@ namespace Oox2Odf
class XlsxConverter : public OoxConverter
{
public:
friend class OoxConverter;
XlsxConverter(const std::wstring & path, const ProgressCallback* ffCallBack);
~XlsxConverter();
@ -207,6 +211,9 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CFormulaCF *oox_cond_formula);
void convert(OOX::Spreadsheet::CSi *oox_rtf_text);
void convert(OOX::Spreadsheet::CSparklineGroups *sparkline);
void convert(OOX::Spreadsheet::CAltTextTable *alt_text);
void convert(double oox_size, _CP_OPT(odf_types::length) & odf_size);
void convert_sharing_string(int number);
};

View File

@ -1055,7 +1055,7 @@ CElementPtr CPPTUserInfo::AddLayoutSlidePlaceholder (CSlide *pSlide, int placeho
{
CElementPtr pElement;
for (std::multimap<int, int>::iterator it = pLayout->m_mapPlaceholders.begin(); it != pLayout->m_mapPlaceholders.end(); it++)
for (std::multimap<int, int>::iterator it = pLayout->m_mapPlaceholders.begin(); it != pLayout->m_mapPlaceholders.end(); ++it)
{
pElement = NULL;
if (it->first == placeholderType )
@ -1099,7 +1099,7 @@ CElementPtr CPPTUserInfo::AddThemeLayoutPlaceholder (CLayout *pLayout, int plac
{
CElementPtr pElement;
for (std::multimap<int, int>::iterator it = pTheme->m_mapPlaceholders.begin(); it != pTheme->m_mapPlaceholders.end(); it++)
for (std::multimap<int, int>::iterator it = pTheme->m_mapPlaceholders.begin(); it != pTheme->m_mapPlaceholders.end(); ++it)
{
if (it->first == placeholderType )
{
@ -1230,7 +1230,7 @@ int CPPTUserInfo::AddNewLayout(CTheme* pTheme, CRecordSlide* pRecordSlide, bool
//if (layoutRecord.m_nGeom==0x0F) return ind; // big object only !!!
//копируем все элементы без idx которые не были прописаны явно
for (std::multimap<int, int>::iterator it = pTheme->m_mapPlaceholders.begin(); it != pTheme->m_mapPlaceholders.end(); it++)
for (std::multimap<int, int>::iterator it = pTheme->m_mapPlaceholders.begin(); it != pTheme->m_mapPlaceholders.end(); ++it)
{
if (pTheme->m_arElements[it->second]->m_lPlaceholderID >= 0) continue;

View File

@ -60,6 +60,7 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"

View File

@ -46,10 +46,12 @@
Optimization="0"
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include"
PreprocessorDefinitions="_DEBUG;_CONSOLE;_USE_MATH_DEFINES;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;_PRESENTATION_WRITER_;_SVG_CONVERT_TO_IMAGE_;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="false"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="0"
UsePrecompiledHeader="0"
ProgramDataBaseFileName="$(IntDir)\PptFileFormatTest.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
@ -67,7 +69,7 @@
Name="VCLinkerTool"
AdditionalDependencies="Urlmon.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMTD.lib;libcmt.lib"
IgnoreDefaultLibraryNames=""
IgnoreEmbeddedIDL="true"
GenerateDebugInformation="true"
SubSystem="1"

View File

@ -903,7 +903,7 @@ CDrawingConverter::~CDrawingConverter()
HRESULT CDrawingConverter::SetMainDocument(BinDocxRW::CDocxSerializer* pDocument)
{
m_pBinaryWriter->ClearNoAttack();
m_pBinaryWriter->m_pCommon->m_pImageManager->NewDocument();
m_pBinaryWriter->m_pCommon->m_pMediaManager->Clear();
m_pBinaryWriter->SetMainDocument(pDocument);
m_pReader->SetMainDocument(pDocument);
@ -926,7 +926,7 @@ void CDrawingConverter::SetDstPath(const std::wstring& sPath)
}
void CDrawingConverter::SetMediaDstPath(const std::wstring& sPath)
{
m_pBinaryWriter->m_pCommon->m_pImageManager->m_strDstMedia = sPath;
m_pBinaryWriter->m_pCommon->m_pMediaManager->m_strDstMedia = sPath;
m_pImageManager->SetDstMedia(sPath);
NSDirectory::CreateDirectory(sPath);
@ -2632,7 +2632,7 @@ void CDrawingConverter::doc_LoadShape(PPTX::Logic::SpTreeElem *elem, XmlUtils::C
if (sId.length() > 0 && m_pBinaryWriter->m_pCurrentContainer->IsInit())
{
OOX::RId rId(sId);
smart_ptr<PPTX::LegacyDiagramText> pExt = (*m_pBinaryWriter->m_pCurrentContainer)->GetLegacyDiagramText(rId);
smart_ptr<PPTX::LegacyDiagramText> pExt = (*m_pBinaryWriter->m_pCurrentContainer)->Get<PPTX::LegacyDiagramText>(rId);
if (pExt.IsInit())
{
@ -5379,6 +5379,8 @@ smart_ptr<OOX::IFileContainer> CDrawingConverter::GetRels()
}
void CDrawingConverter::SetFontManager(CFontManager* pFontManager)
{
if(NULL != m_pBinaryWriter && NULL != m_pBinaryWriter->m_pCommon && NULL != m_pBinaryWriter->m_pCommon->m_pImageManager)
m_pBinaryWriter->m_pCommon->m_pImageManager->SetFontManager(pFontManager);
if(NULL != m_pBinaryWriter && NULL != m_pBinaryWriter->m_pCommon && NULL != m_pBinaryWriter->m_pCommon->m_pMediaManager)
{
m_pBinaryWriter->m_pCommon->m_pMediaManager->SetFontManager(pFontManager);
}
}

View File

@ -313,8 +313,8 @@ HRESULT CPPTXFile::OpenDirectoryToPPTY(std::wstring bsInput, std::wstring bsOutp
m_strMediaDirectory = pathMedia.GetPath();
oBinaryWriter.m_strMainFolder = pathDstFileOutput.GetDirectory();
oBinaryWriter.m_pCommon->m_pImageManager->m_strDstMedia = m_strMediaDirectory;
oBinaryWriter.m_pCommon->m_pImageManager->SetFontManager(oBinaryWriter.m_pCommon->m_pNativePicker->m_pFontManager);
oBinaryWriter.m_pCommon->m_pMediaManager->m_strDstMedia = m_strMediaDirectory;
oBinaryWriter.m_pCommon->m_pMediaManager->SetFontManager(oBinaryWriter.m_pCommon->m_pNativePicker->m_pFontManager);
NSDirectory::CreateDirectory(m_strMediaDirectory);

View File

@ -78,14 +78,14 @@ namespace NSBinPptxRW
m_pNativePicker = NULL;
m_pFontPicker = NULL;
m_bDeleteFontPicker = true;
m_pImageManager = new NSShapeImageGen::CImageManager();
m_pMediaManager = new NSShapeImageGen::CMediaManager();
}
CCommonWriter::~CCommonWriter()
{
m_pNativePicker = NULL;
if(m_bDeleteFontPicker)
RELEASEOBJECT(m_pFontPicker);
RELEASEOBJECT(m_pImageManager);
RELEASEOBJECT(m_pMediaManager);
}
void CCommonWriter::CreateFontPicker(COfficeFontPicker* pPicker)
{
@ -186,6 +186,21 @@ namespace NSBinPptxRW
}
return nRes;
}
_imageManager2Info CImageManager2::GenerateMedia(const std::wstring& strInput)
{
std::map<std::wstring, _imageManager2Info>::const_iterator pPair = m_mapImages.find(strInput);
if (pPair != m_mapImages.end())
{
return pPair->second;
}
_imageManager2Info oImageManagerInfo = GenerateMediaExec(strInput);
m_mapImages[strInput] = oImageManagerInfo;
return oImageManagerInfo;
}
_imageManager2Info CImageManager2::GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image)
{
if (IsNeedDownload(strInput))
@ -197,7 +212,7 @@ namespace NSBinPptxRW
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit())
mediaFile->set_filename(pPair->second.sFilepathAdditional);
mediaFile->set_filename(pPair->second.sFilepathAdditional, false);
return pPair->second;
}
@ -273,21 +288,24 @@ namespace NSBinPptxRW
{
typeAdditional = 2;
std::wstring strMedia = strFolder + strFileName + mediaFile->filename().GetExtention();
if (OOX::CSystemUtility::IsFileExist(strMedia))
if (!mediaFile->IsExternal())
{
m_pContentTypes->AddDefault(mediaFile->filename().GetExtention(false));
strAdditional = strMedia;
}
else
{
strMedia = strFolder + strFileName;
if (mediaFile.is<OOX::Audio>()) strMedia += L".wav";
if (mediaFile.is<OOX::Video>()) strMedia += L".avi";
std::wstring strMedia = strFolder + strFileName + mediaFile->filename().GetExtention();
if (OOX::CSystemUtility::IsFileExist(strMedia))
{
m_pContentTypes->AddDefault(mediaFile->filename().GetExtention(false));
strAdditional = strMedia;
}
else
{
strMedia = strFolder + strFileName;
if (mediaFile.is<OOX::Audio>()) strMedia += L".wav";
if (mediaFile.is<OOX::Video>()) strMedia += L".avi";
if (OOX::CSystemUtility::IsFileExist(strMedia))
strAdditional = strMedia;
}
}
}
}
@ -310,7 +328,9 @@ namespace NSBinPptxRW
{
smart_ptr<OOX::Media> mediaFile = additionalFile.smart_dynamic_cast<OOX::Media>();
if (mediaFile.IsInit())
mediaFile->set_filename(oImageManagerInfo.sFilepathAdditional);
{
mediaFile->set_filename(oImageManagerInfo.sFilepathAdditional, false);
}
}
if (strBase64Image.empty())
@ -356,6 +376,30 @@ namespace NSBinPptxRW
}
return bRes;
}
_imageManager2Info CImageManager2::GenerateMediaExec(const std::wstring& strInput)
{
OOX::CPath oPathOutput;
_imageManager2Info oImageManagerInfo;
std::wstring strExts;
std::wstring strMedia = L"media" + std::to_wstring(++m_lIndexNextImage);
int pos = (int)strInput.rfind(L".");
if (pos >= 0)
{
strExts = strInput.substr(pos);
m_pContentTypes->AddDefault(strExts.substr(1));
}
oPathOutput = m_strDstMedia + FILE_SEPARATOR_STR + strMedia + strExts;
if (oPathOutput.GetPath() != strInput && NSFile::CFileBinary::Exists(strInput))
{
NSFile::CFileBinary::Copy(strInput, oPathOutput.GetPath());
oImageManagerInfo.sFilepathImage = oPathOutput.GetPath();
}
return oImageManagerInfo;
}
_imageManager2Info CImageManager2::GenerateImageExec(const std::wstring& strInput, const std::wstring& sExts, const std::wstring& strAdditionalImage, int nAdditionalType, const std::wstring& oleData)
{
OOX::CPath oPathOutput;
@ -1294,6 +1338,50 @@ namespace NSBinPptxRW
oFile.WriteStringUTF8(strMem);
oFile.CloseFile();
}
_relsGeneratorInfo CRelsGenerator::WriteMedia(const std::wstring& strImage, int type)
{
_imageManager2Info oImageManagerInfo = m_pManager->GenerateMedia(strImage);
std::wstring strImageRelsPath;
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strImageRelsPath = L"media/";
else strImageRelsPath = L"../media/";
_relsGeneratorInfo oRelsGeneratorInfo;
if (!oImageManagerInfo.sFilepathImage.empty())
{
strImageRelsPath += OOX::CPath(oImageManagerInfo.sFilepathImage).GetFilename();
std::map<std::wstring, _relsGeneratorInfo>::iterator pPair = m_mapImages.find(strImageRelsPath);
if (m_mapImages.end() != pPair)
{
return pPair->second;
}
oRelsGeneratorInfo.nImageRId = m_lNextRelsID++;
oRelsGeneratorInfo.sFilepathImage = oImageManagerInfo.sFilepathImage;
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nImageRId);
if (type == 0)
{
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.microsoft.com/office/2007/relationships/media\" Target=\"" + strImageRelsPath +
L"\"/>");
}
else if (type == 1)
{
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio\" Target=\"" + strImageRelsPath +
L"\"/>");
}
}
m_mapImages.insert(std::pair<std::wstring, _relsGeneratorInfo>(strImageRelsPath, oRelsGeneratorInfo));
return oRelsGeneratorInfo;
}
_relsGeneratorInfo CRelsGenerator::WriteImage(const std::wstring& strImage, smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image = _T(""))
{
@ -1370,14 +1458,21 @@ namespace NSBinPptxRW
{
std::wstring strRid = L"rId" + std::to_wstring(oRelsGeneratorInfo.nMediaRId);
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strMediaRelsPath = L"media/";
else strMediaRelsPath = L"../media/";
strMediaRelsPath += mediaFile->filename().GetFilename();
if (mediaFile->IsExternal())
{
strMediaRelsPath = mediaFile->filename().GetFilename();
}
else
{
if (m_pManager->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) strMediaRelsPath = L"media/";
else strMediaRelsPath = L"../media/";
strMediaRelsPath += mediaFile->filename().GetFilename();
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid
+ L"\" Type=\"http://schemas.microsoft.com/office/2007/relationships/media\" Target=\"" +
strMediaRelsPath + L"\"/>");
m_pWriter->WriteString( L"<Relationship Id=\"" + strRid
+ L"\" Type=\"http://schemas.microsoft.com/office/2007/relationships/media\" Target=\"" +
strMediaRelsPath + L"\"" + (mediaFile->IsExternal() ? L" TargetMode=\"External\"" : L"") + L"/>");
}
}
}
m_mapImages.insert(std::pair<std::wstring, _relsGeneratorInfo>(strImageRelsPath, oRelsGeneratorInfo));

View File

@ -76,7 +76,7 @@ namespace BinDocxRW
}
namespace NSShapeImageGen
{
class CImageManager;
class CMediaManager;
}
namespace NSFontCutter
{
@ -159,7 +159,7 @@ namespace NSBinPptxRW
std::vector<LONG> m_oNote_Rels;
std::vector<LONG> m_oNotesMasters_Rels;
NSShapeImageGen::CImageManager* m_pImageManager;
NSShapeImageGen::CMediaManager* m_pMediaManager;
NSFontCutter::CFontDstManager* m_pNativePicker;
COfficeFontPicker* m_pFontPicker;
@ -201,7 +201,10 @@ namespace NSBinPptxRW
int IsDisplayedImage(const std::wstring& strInput);
_imageManager2Info GenerateMedia(const std::wstring& strInput);
_imageManager2Info GenerateImage(const std::wstring& strInput, NSCommon::smart_ptr<OOX::File> & additionalFile, const std::wstring& oleData, std::wstring strBase64Image);
_imageManager2Info GenerateMediaExec(const std::wstring& strInput);
_imageManager2Info GenerateImageExec(const std::wstring& strInput, const std::wstring& strExts, const std::wstring& strAdditionalImage, int nAdditionalType, const std::wstring& oleData);
void SaveImageAsPng(const std::wstring& strFileSrc, const std::wstring& strFileDst);
@ -433,6 +436,7 @@ namespace NSBinPptxRW
void SaveRels (const std::wstring& strFile);
_relsGeneratorInfo WriteImage (const std::wstring& strImage, NSCommon::smart_ptr<OOX::File>& additionalFile, const std::wstring& oleData, std::wstring strBase64Image);
_relsGeneratorInfo WriteMedia (const std::wstring& strMedia, int type = 0);
};
class CBinaryFileReader

View File

@ -380,12 +380,12 @@ namespace PPTX2EditorAdvanced
oBinaryWriter.StartRecord(NSMainTables::ImageMap);
oBinaryWriter.WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
std::map<std::wstring, NSShapeImageGen::CImageInfo>* pIMaps = &oBinaryWriter.m_pCommon->m_pImageManager->m_mapImagesFile;
std::map<std::wstring, NSShapeImageGen::CMediaInfo>* pIMaps = &oBinaryWriter.m_pCommon->m_pMediaManager->m_mapMediaFiles;
LONG lIndexI = 0;
for (std::map<std::wstring, NSShapeImageGen::CImageInfo>::iterator pPair = pIMaps->begin(); pPair != pIMaps->end(); ++pPair)
for (std::map<std::wstring, NSShapeImageGen::CMediaInfo>::iterator pPair = pIMaps->begin(); pPair != pIMaps->end(); ++pPair)
{
NSShapeImageGen::CImageInfo& oRec = pPair->second;
NSShapeImageGen::CMediaInfo& oRec = pPair->second;
oBinaryWriter.WriteString1(lIndexI++, oRec.GetPath2());
}

View File

@ -274,7 +274,12 @@ namespace NSBinPptxRW
size_t _countL = m_arSlideMasters_Theme[i].m_arLayouts.size();
for (size_t j = 0; j < _countL; ++j)
{
m_arSlideLayouts_Master[m_arSlideMasters_Theme[i].m_arLayouts[j]] = (LONG)i;
int index = m_arSlideMasters_Theme[i].m_arLayouts[j];
if (index >= 0 && index < m_arSlideLayouts_Master.size())
{
m_arSlideLayouts_Master[index] = (LONG)i;
}
}
}
@ -350,7 +355,11 @@ namespace NSBinPptxRW
for (size_t i = 0; i < m_arNotesMasters_Theme.size(); i++)
{
arThemesSave[m_arNotesMasters_Theme[i]] = true;
int index = m_arNotesMasters_Theme[i];
if (index >= 0 && index < arThemesSave.size())
{
arThemesSave[index] = true;
}
}
LONG lCurrectTheme = 0;
for (LONG i = 0; i < nCountMasters; ++i)

View File

@ -66,77 +66,93 @@ namespace NSShapeImageGen
return CDirectory::CopyFile (strExists, strNew);
}
enum ImageType
enum MediaType
{
itJPG = 0,
itPNG = 1,
itVIF = 2,
itWMF = 3,
itEMF = 4,
itSVG = 5
itSVG = 5,
itMedia = 6
};
class CImageInfo
class CMediaInfo
{
public:
NSShapeImageGen::ImageType m_eType;
NSShapeImageGen::MediaType m_eType;
LONG m_lID;
bool m_bValid;
std::wstring m_sName;
std::wstring m_sExt;
CImageInfo()
CMediaInfo()
{
m_eType = itJPG;
m_lID = -1;
m_bValid = true;
m_sName = L"image";
}
CImageInfo(const CImageInfo& oSrc)
CMediaInfo(const CMediaInfo& oSrc)
{
*this = oSrc;
}
CImageInfo& operator=(const CImageInfo& oSrc)
CMediaInfo& operator=(const CMediaInfo& oSrc)
{
m_eType = oSrc.m_eType;
m_lID = oSrc.m_lID;
m_bValid = oSrc.m_bValid;
m_sName = oSrc.m_sName;
m_sExt = oSrc.m_sExt;
return *this;
}
void SetNameModificator(NSShapeImageGen::ImageType eType, int typeAdditionalFile )
void SetNameModificator(NSShapeImageGen::MediaType eType, int typeAdditionalFile = 0 )
{
if(itMedia == eType)
{
m_sName = L"media";
return;
}
int nRes = 0;
if(itWMF == eType) nRes += 1;
if(itEMF == eType) nRes += 2;
if(typeAdditionalFile == 1) nRes += 4;
if(typeAdditionalFile == 2) nRes += 8;
if(0 != nRes)
m_sName = L"display" + std::to_wstring(nRes) + L"image";
}
AVSINLINE std::wstring GetPath2()
{
std::wstring _strExt = L"png";
std::wstring _strExt;
switch (m_eType)
{
case itPNG:
_strExt = L".png";
break;
case itJPG:
_strExt = L"jpg";
_strExt = L".jpg";
break;
case itWMF:
_strExt = L"wmf";
_strExt = L".wmf";
break;
case itEMF:
_strExt = L"emf";
_strExt = L".emf";
break;
case itSVG:
_strExt = L"svg";
_strExt = L".svg";
break;
default:
_strExt = m_sExt;
break;
}
return m_sName + std::to_wstring(m_lID) + L"." + _strExt;
return m_sName + std::to_wstring(m_lID) + _strExt;
}
AVSINLINE std::wstring GetPathWithoutExtension()
{
@ -144,14 +160,11 @@ namespace NSShapeImageGen
}
};
class CImageManager
class CMediaManager
{
public:
std::map<std::wstring, CImageInfo> m_mapImagesFile;
std::map<DWORD, CImageInfo> m_mapImageData;
std::vector<void*> m_listDrawings;
std::list<CImageInfo> m_listImages;
std::map<std::wstring, CMediaInfo> m_mapMediaFiles; //map for files by link
std::map<DWORD, CMediaInfo> m_mapMediaData; //map for files by data
std::wstring m_strDstMedia;
@ -163,7 +176,7 @@ namespace NSShapeImageGen
NSWMFToImageConverter::CImageExt m_oImageExt;
CFontManager* m_pFontManager;
CImageManager()
CMediaManager()
{
m_lMaxSizeImage = c_nMaxImageSize;
m_lNextIDImage = 0;
@ -171,20 +184,19 @@ namespace NSShapeImageGen
m_pFontManager = NULL;
}
AVSINLINE void NewDocument()
AVSINLINE void Clear()
{
m_strDstMedia = L"";
m_lMaxSizeImage = 1200;
m_lNextIDImage = 0;
m_mapImageData.clear();
m_mapImagesFile.clear();
m_listImages.clear();
m_mapMediaData.clear();
m_mapMediaFiles.clear();
}
CImageInfo WriteImage(CBgraFrame& punkImage, double& x, double& y, double& width, double& height)
CMediaInfo WriteImage(CBgraFrame& punkImage, double& x, double& y, double& width, double& height)
{
CImageInfo info;
CMediaInfo info;
//if (NULL == punkImage)
// return info;
@ -197,7 +209,7 @@ namespace NSShapeImageGen
return GenerateImageID(punkImage, (std::max)(1.0, width), (std::max)(1.0, height));
}
CImageInfo WriteImage(const std::wstring& strFile, double& x, double& y, double& width, double& height, const std::wstring& strAdditionalFile, int typeAdditionalFile)
CMediaInfo WriteImage(const std::wstring& strFile, double& x, double& y, double& width, double& height, const std::wstring& strAdditionalFile, int typeAdditionalFile)
{
bool bIsDownload = false;
int n1 = (int)strFile.find (L"www");
@ -221,10 +233,10 @@ namespace NSShapeImageGen
XmlUtils::replace_all(strFileUrl, L"ftp:/", L"ftp://");
CImageInfo oInfo;
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(strFileUrl);
CMediaInfo oInfo;
std::map<std::wstring, CMediaInfo>::iterator pPair = m_mapMediaFiles.find(strFileUrl);
if (pPair != m_mapImagesFile.end())
if (pPair != m_mapMediaFiles.end())
return pPair->second;
std::wstring strDownload;
@ -240,13 +252,11 @@ namespace NSShapeImageGen
#endif
return GenerateImageID(strDownload, strFileUrl, (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
}
if (strAdditionalFile.empty())
{
CImageInfo info;
CMediaInfo info;
CFile oFile;
if (S_OK != oFile.OpenFile(strFile))
return info;
@ -257,6 +267,51 @@ namespace NSShapeImageGen
if (width < 0 && height < 0) return GenerateImageID(strFile, L"", -1, -1, strAdditionalFile, typeAdditionalFile);
return GenerateImageID(strFile, L"", (std::max)(1.0, width), (std::max)(1.0, height), strAdditionalFile, typeAdditionalFile);
}
CMediaInfo WriteMedia(const std::wstring& strFile)
{
bool bIsDownload = false;
int n1 = (int)strFile.find (L"www");
int n2 = (int)strFile.find (L"http");
int n3 = (int)strFile.find (L"ftp");
int n4 = (int)strFile.find (L"https");
//если nI сранивать не с 0, то будут проблемы
//потому что в инсталяции мы кладем файлы в /var/www...
if (0 == n1 || 0 == n2 || 0 == n3 || 0 == n4)
bIsDownload = true;
if (bIsDownload)
{
std::wstring strFileUrl = strFile;
XmlUtils::replace_all(strFileUrl, L"\\", L"/");
XmlUtils::replace_all(strFileUrl, L"http:/", L"http://");
XmlUtils::replace_all(strFileUrl, L"https:/", L"https://");
XmlUtils::replace_all(strFileUrl, L"ftp:/", L"ftp://");
CMediaInfo oInfo;
std::map<std::wstring, CMediaInfo>::iterator pPair = m_mapMediaFiles.find(strFileUrl);
if (pPair != m_mapMediaFiles.end())
return pPair->second;
std::wstring strDownload;
#ifndef DISABLE_FILE_DOWNLOADER
CFileDownloader oDownloader(strFileUrl, true);
if (oDownloader.DownloadSync())
{
strDownload = oDownloader.GetFilePath();
}
#endif return GenerateMediaID(strDownload, strFileUrl);
}
else
return GenerateMediaID(strFile, L"");
}
void SetFontManager(CFontManager* pFontManager)
{
m_pFontManager = pFontManager;
@ -267,7 +322,7 @@ namespace NSShapeImageGen
_CopyFile(strFileSrc, strFileDst, NULL, NULL);
}
bool CheckImageSimpleCopy(const std::wstring& strFileSrc, CImageInfo& oInfo)
bool CheckImageSimpleCopy(const std::wstring& strFileSrc, CMediaInfo& oInfo)
{
CFile oFile;
HRESULT hr = oFile.OpenFile(strFileSrc);
@ -310,7 +365,7 @@ namespace NSShapeImageGen
return false;
}
void SaveImage(const std::wstring& strFileSrc, CImageInfo& oInfo, LONG __width, LONG __height)
void SaveImage(const std::wstring& strFileSrc, CMediaInfo& oInfo, LONG __width, LONG __height)
{
if (CheckImageSimpleCopy(strFileSrc, oInfo))
return;
@ -332,7 +387,7 @@ namespace NSShapeImageGen
CDirectory::CopyFile(strFileSrc, strSaveItem);
}
}
void SaveImage(CBgraFrame& oBgraFrame, CImageInfo& oInfo, LONG __width, LONG __height)
void SaveImage(CBgraFrame& oBgraFrame, CMediaInfo& oInfo, LONG __width, LONG __height)
{
LONG lWidth = oBgraFrame.get_Width();
LONG lHeight = oBgraFrame.get_Height();
@ -378,12 +433,9 @@ namespace NSShapeImageGen
oBgraFrame.SaveFile(std::wstring(pathSaveItem.GetPath()), nOutputFormat);
}
CImageInfo GenerateImageID(CBgraFrame& punkData, double dWidth, double dHeight)
CMediaInfo GenerateImageID(CBgraFrame& punkData, double dWidth, double dHeight)
{
CImageInfo oInfo;
//if (NULL == punkData)
// return oInfo;
CMediaInfo oInfo;
LONG lWidth = (LONG)(dWidth * 96 / 25.4);
LONG lHeight = (LONG)(dHeight * 96 / 25.4);
@ -393,8 +445,8 @@ namespace NSShapeImageGen
DWORD dwSum = m_oCRC.Calc(pBuffer, lLen);
std::map<DWORD, CImageInfo>::iterator pPair = m_mapImageData.find(dwSum);
if (m_mapImageData.end() == pPair)
std::map<DWORD, CMediaInfo>::iterator pPair = m_mapMediaData.find(dwSum);
if (m_mapMediaData.end() == pPair)
{
// нужно добавить
++m_lNextIDImage;
@ -402,8 +454,7 @@ namespace NSShapeImageGen
oInfo.m_lID = m_lNextIDImage;
SaveImage(punkData, oInfo, lWidth, lHeight);
m_mapImageData.insert(std::pair<DWORD,CImageInfo>(dwSum, oInfo));
m_listImages.push_back(oInfo);
m_mapMediaData.insert(std::make_pair(dwSum, oInfo));
}
else
{
@ -413,20 +464,20 @@ namespace NSShapeImageGen
return oInfo;
}
CImageInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, double dWidth, double dHeight, const std::wstring& strAdditionalFile, int typeAdditionalFile)
CMediaInfo GenerateImageID(const std::wstring& strFileName, const std::wstring & strUrl, double dWidth, double dHeight, const std::wstring& strAdditionalFile, int typeAdditionalFile)
{
std::wstring sMapKey = strFileName;
if(!strUrl.empty()) sMapKey = strUrl;
if(!strAdditionalFile.empty()) sMapKey += strAdditionalFile;
CImageInfo oInfo;
std::map<std::wstring, CImageInfo>::iterator pPair = m_mapImagesFile.find(sMapKey);
CMediaInfo oInfo;
std::map<std::wstring, CMediaInfo>::iterator pPair = m_mapMediaFiles.find(sMapKey);
LONG lWidth = (LONG)(dWidth * 96 / 25.4);
LONG lHeight = (LONG)(dHeight * 96 / 25.4);
if (m_mapImagesFile.end() == pPair)
if (m_mapMediaFiles.end() == pPair)
{
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
@ -444,7 +495,7 @@ namespace NSShapeImageGen
oInfo.SetNameModificator(oInfo.m_eType, typeAdditionalFile);
std::wstring strSaveDir = m_strDstMedia + FILE_SEPARATOR_STR;
std::wstring strSaveItemWE = strSaveDir + std::wstring(oInfo.GetPathWithoutExtension());
std::wstring strSaveItemWE = strSaveDir + oInfo.GetPathWithoutExtension();
//copy ole bin or media
if(bOle || bMedia)
@ -516,8 +567,7 @@ namespace NSShapeImageGen
{
oInfo.m_eType = itPNG;
m_mapImagesFile.insert(std::pair<std::wstring,CImageInfo>(sMapKey, oInfo));
m_listImages.push_back(oInfo);
m_mapMediaFiles.insert(std::make_pair(sMapKey, oInfo));
return oInfo;
}
}
@ -526,8 +576,7 @@ namespace NSShapeImageGen
oInfo.m_eType = itSVG;
oWriterSVG.SaveFile(strSaveItemWE + L".svg");
m_mapImagesFile.insert(std::pair<std::wstring,CImageInfo>(sMapKey, oInfo));
m_listImages.push_back(oInfo);
m_mapMediaFiles.insert(std::make_pair(sMapKey, oInfo));
return oInfo;
}
}
@ -535,8 +584,7 @@ namespace NSShapeImageGen
SaveImage(strFileName, oInfo, lWidth, lHeight);
m_mapImagesFile.insert(std::pair<std::wstring,CImageInfo>(sMapKey, oInfo));
m_listImages.push_back(oInfo);
m_mapMediaFiles.insert(std::make_pair(sMapKey, oInfo));
}
else
{
@ -546,7 +594,45 @@ namespace NSShapeImageGen
return oInfo;
}
ImageType GetImageType(CBgraFrame& pFrame)
CMediaInfo GenerateMediaID(const std::wstring& strFileName, const std::wstring & strUrl)
{
std::wstring sMapKey;
if(!strUrl.empty()) sMapKey = strUrl;
else sMapKey = strFileName;
CMediaInfo oInfo;
std::map<std::wstring, CMediaInfo>::iterator pFind = m_mapMediaFiles.find(sMapKey);
if (m_mapMediaFiles.end() == pFind)
{
++m_lNextIDImage;
oInfo.m_lID = m_lNextIDImage;
oInfo.m_eType = itMedia;
oInfo.m_sName = L"media";
std::wstring strSaveItemWE = m_strDstMedia + FILE_SEPARATOR_STR + oInfo.GetPath2();
int nIndexExt = (int)strFileName.rfind(wchar_t('.'));
if (-1 != nIndexExt)
oInfo.m_sExt = strFileName.substr(nIndexExt);
std::wstring strCopyMediaPath = strSaveItemWE + oInfo.m_sExt;
CDirectory::CopyFile(strFileName, strCopyMediaPath);
m_mapMediaFiles.insert(std::make_pair(sMapKey, oInfo));
}
else
{
oInfo = pFind->second;
}
return oInfo;
}
MediaType GetImageType(CBgraFrame& pFrame)
{
if (2 == m_lDstFormat)
return itJPG;

View File

@ -40,10 +40,11 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Rels.h"
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Media.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FileTypes.h"
#include "../../DesktopEditor/common/Directory.h"
#include <map>
#include <boost/unordered_map.hpp>
namespace PPTX
{
@ -103,7 +104,7 @@ namespace PPTX
pSrcFile->type() == OOX::Presentation::FileTypes::NotesSlide) ? true : false;
}
for (std::map<std::wstring, OOX::Rels::CRelationShip*>::const_iterator it = rels.m_mapRelations.begin(); it != rels.m_mapRelations.end(); it++)
for (boost::unordered_map<std::wstring, OOX::Rels::CRelationShip*>::const_iterator it = rels.m_mapRelations.begin(); it != rels.m_mapRelations.end(); ++it)
{
OOX::Rels::CRelationShip* pRelation = it->second;
@ -113,7 +114,7 @@ namespace PPTX
if (bIsSlide && (pRelation->Type() == OOX::FileTypes::HyperLink ||
pRelation->Type() == OOX::Presentation::FileTypes::Slide))
{// + external audio, video ...
{// + external audio, video ... - в обычных ...
smart_ptr<OOX::File> file = smart_ptr<OOX::File>(new OOX::HyperLink(pRelation->Target()));
@ -177,12 +178,15 @@ namespace PPTX
void FileContainer::write(OOX::CRels& rels, const OOX::CPath& curdir, const OOX::CPath& directory, OOX::CContentTypes& content) const
{
std::map<std::wstring, size_t> mNamePair;
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mContainer.begin(); pPair != m_mContainer.end(); ++pPair)
boost::unordered_map<std::wstring, size_t> mNamePair;
for (boost::unordered_map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mContainer.begin(); pPair != m_mContainer.end(); ++pPair)
{
smart_ptr<OOX::File> pFile = pPair->second;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
if ( !pExt.IsInit() )
smart_ptr<OOX::File> pFile = pPair->second;
smart_ptr<OOX::External> pExt = pFile.smart_dynamic_cast<OOX::External>();
smart_ptr<OOX::Media> pMedia = pFile.smart_dynamic_cast<OOX::Media>();
bool bExternal = pExt.IsInit() || ((pMedia.IsInit()) && (pMedia->IsExternal()));
if ( !bExternal )
{
smart_ptr<PPTX::WrapperFile> file = pFile.smart_dynamic_cast<PPTX::WrapperFile>();
@ -226,7 +230,7 @@ namespace PPTX
void FileContainer::WrittenSetFalse()
{
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mContainer.begin(); pPair != m_mContainer.end(); ++pPair)
for (boost::unordered_map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mContainer.begin(); pPair != m_mContainer.end(); ++pPair)
{
smart_ptr<OOX::File> pFile = pPair->second;

View File

@ -65,9 +65,6 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalImage.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalAudio.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/ExternalVideo.h"
#include "../../Common/DocxFormat/Source/DocxFormat/UnknowTypeFile.h"
//
@ -76,7 +73,7 @@ namespace PPTX
{
const smart_ptr<OOX::File> FileFactory::CreateFilePPTX(const OOX::CPath& filename, OOX::Rels::CRelationShip& relation, FileMap& map)
{
if (NSFile::CFileBinary::Exists(filename.GetPath()) == false)
if (NSFile::CFileBinary::Exists(filename.GetPath()) == false && !relation.IsExternal())
{
return smart_ptr<OOX::File>(NULL);
}
@ -121,20 +118,14 @@ namespace PPTX
return smart_ptr<OOX::File>(new OOX::Spreadsheet::CChartSpace(filename, filename));
else if (relation.Type() == OOX::FileTypes::HyperLink)
return smart_ptr<OOX::File>(new OOX::HyperLink(relation.Target()));
else if ((relation.Type() == OOX::FileTypes::ExternalImage) && (relation.IsExternal()))
return smart_ptr<OOX::File>(new OOX::ExternalImage(relation.Target()));
else if ((relation.Type() == OOX::FileTypes::ExternalAudio) && (relation.IsExternal()))
return smart_ptr<OOX::File>(new OOX::ExternalAudio(relation.Target()));
else if ((relation.Type() == OOX::FileTypes::ExternalVideo) && (relation.IsExternal()))
return smart_ptr<OOX::File>(new OOX::ExternalVideo(relation.Target()));
else if (relation.Type() == OOX::FileTypes::Image)
return smart_ptr<OOX::File>(new OOX::Image(filename));
return smart_ptr<OOX::File>(new OOX::Image(filename, relation.IsExternal()));
else if (relation.Type() == OOX::FileTypes::Audio)
return smart_ptr<OOX::File>(new OOX::Audio(filename));
return smart_ptr<OOX::File>(new OOX::Audio(filename, relation.IsExternal()));
else if (relation.Type() == OOX::FileTypes::Media)
return smart_ptr<OOX::File>(new OOX::Media(filename));
return smart_ptr<OOX::File>(new OOX::Media(filename, relation.IsExternal()));
else if (relation.Type() == OOX::FileTypes::Video)
return smart_ptr<OOX::File>(new OOX::Video(filename));
return smart_ptr<OOX::File>(new OOX::Video(filename, relation.IsExternal()));
else if (relation.Type() == OOX::FileTypes::Data)
return smart_ptr<OOX::File>(new OOX::CDiagramData(filename));
else if (relation.Type() == OOX::FileTypes::DiagDrawing)

View File

@ -96,7 +96,7 @@ namespace PPTX
////проблема переноса картинок !!!
//if (controls.IsInit())
//{
// controls->AddObjectsTo(&spTree.SpTreeElems, pWriter->m_pCommon->m_pImageManager);
// controls->AddObjectsTo(&spTree.SpTreeElems, pWriter->m_pCommon->m_pMediaManager);
//}
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);

View File

@ -59,7 +59,7 @@ namespace PPTX
return xml;
}
void Control::AddObjectTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CImageManager* pImageManager) const
void Control::AddObjectTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CMediaManager* pMediaManager) const
{//проблема переноса картинок !!!
if (spid.IsInit() == false) return;
@ -78,15 +78,16 @@ namespace PPTX
NSBinPptxRW::CDrawingConverter oDrawingConverter;
oDrawingConverter.SetAdditionalParam(_T("parent_spTree"), (BYTE*)spTreeElements, 0);
RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = pImageManager;
RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = pMediaManager;
oDrawingConverter.SetRels(rels);
std::wstring *main_props = NULL;
HRESULT hRes = oDrawingConverter.AddObject(temp, &main_props);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = NULL;
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = NULL;
}
}
void Control::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
@ -104,11 +105,12 @@ namespace PPTX
std::wstring temp = _T("<v:object>");
temp += xml;
temp += L"</v:object>";
NSBinPptxRW::CDrawingConverter oDrawingConverter;
//oDrawingConverter.SetFontManager(pFontManager);
RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = pWriter->m_pCommon->m_pImageManager;
RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = pWriter->m_pCommon->m_pMediaManager;
std::wstring *main_props = NULL;
@ -119,17 +121,17 @@ namespace PPTX
{
pWriter->WriteBYTEArray(oDrawingConverter.m_pBinaryWriter->GetBuffer(),oDrawingConverter.m_pBinaryWriter->GetPosition());
}
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = NULL;
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = NULL;
}
}
void Controls::AddObjectsTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CImageManager* pImageManager) const
void Controls::AddObjectsTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CMediaManager* pMediaManager) const
{
for (size_t i=0; i < arrControls.size(); ++i)
{
if (arrControls[i].spid.IsInit() == false) continue;
arrControls[i].AddObjectTo (spTreeElements, pImageManager );
arrControls[i].AddObjectTo (spTreeElements, pMediaManager );
}
}
} // namespace Logic

View File

@ -48,8 +48,7 @@ namespace PPTX
public:
PPTX_LOGIC_BASE(Control)
public:
void AddObjectTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CImageManager* pImageManager) const ;
void AddObjectTo (const std::vector<SpTreeElem> *spTreeElements, NSShapeImageGen::CMediaManager* pMediaManager) const ;
std::wstring GetVmlXmlBySpid(std::wstring spid, smart_ptr<OOX::IFileContainer> & rels) const ;
@ -175,7 +174,7 @@ namespace PPTX
for (size_t i = 0; i <arrControls.size(); i++)
arrControls[i].toPPTY(pWriter);
}
void AddObjectsTo (const std::vector<PPTX::Logic::SpTreeElem> *spTreeElements, NSShapeImageGen::CImageManager* pImageManager) const;
void AddObjectsTo (const std::vector<PPTX::Logic::SpTreeElem> *spTreeElements, NSShapeImageGen::CMediaManager* pMediaManager) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{

View File

@ -133,7 +133,7 @@ namespace PPTX
if(style.is_init())
style->SetParentPointer(this);
}
void CxnSp::GetRect(Aggplus::RECT& pRect)const
{
pRect.bottom = 0;

View File

@ -69,6 +69,11 @@ namespace PPTX
DWORD GetLine(Ln& line)const;
DWORD GetFill(UniFill& fill)const;
//void FillLevelUp();
//void Merge(CxnSp& cxnSp, bool bIsSlidePlaceholder = false);
//void SetLevelUpElement( CxnSp* p){m_pLevelUp = p;};
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->StartRecord(SPTREE_TYPE_CXNSP);

View File

@ -105,42 +105,32 @@ namespace PPTX
{
if (pRels != NULL)
{
smart_ptr<OOX::Image> p = pRels->GetImage(*embed);
smart_ptr<OOX::Image> p = pRels->Get<OOX::Image>(*embed);
if (p.is_init())
return p->filename().m_strFilename;
}
if(parentFileIs<Slide>())
return parentFileAs<Slide>().GetMediaFullPathNameFromRId(*embed);
else if(parentFileIs<SlideLayout>())
return parentFileAs<SlideLayout>().GetMediaFullPathNameFromRId(*embed);
else if(parentFileIs<SlideMaster>())
return parentFileAs<SlideMaster>().GetMediaFullPathNameFromRId(*embed);
else if(parentFileIs<Theme>())
return parentFileAs<Theme>().GetMediaFullPathNameFromRId(*embed);
else if(parentFileIs<NotesSlide>())
return parentFileAs<NotesSlide>().GetMediaFullPathNameFromRId(*embed);
if(parentFileIs<Slide>()) return parentFileAs<Slide>().GetImagePathNameFromRId(*embed);
else if(parentFileIs<SlideLayout>()) return parentFileAs<SlideLayout>().GetImagePathNameFromRId(*embed);
else if(parentFileIs<SlideMaster>()) return parentFileAs<SlideMaster>().GetImagePathNameFromRId(*embed);
else if(parentFileIs<Theme>()) return parentFileAs<Theme>().GetImagePathNameFromRId(*embed);
else if(parentFileIs<NotesSlide>()) return parentFileAs<NotesSlide>().GetImagePathNameFromRId(*embed);
return _T("");
}
else if(link.IsInit())
{
if (pRels != NULL)
{
smart_ptr<OOX::Image> p = pRels->GetImage(*link);
smart_ptr<OOX::Image> p = pRels->Get<OOX::Image>(*link);
if (p.is_init())
return p->filename().m_strFilename;
}
if(parentFileIs<Slide>())
return parentFileAs<Slide>().GetMediaFullPathNameFromRId(*link);
else if(parentFileIs<SlideLayout>())
return parentFileAs<SlideLayout>().GetMediaFullPathNameFromRId(*link);
else if(parentFileIs<SlideMaster>())
return parentFileAs<SlideMaster>().GetMediaFullPathNameFromRId(*link);
else if(parentFileIs<Theme>())
return parentFileAs<Theme>().GetMediaFullPathNameFromRId(*link);
else if(parentFileIs<NotesSlide>())
return parentFileAs<NotesSlide>().GetMediaFullPathNameFromRId(*link);
if(parentFileIs<Slide>()) return parentFileAs<Slide>().GetImagePathNameFromRId(*link);
else if(parentFileIs<SlideLayout>()) return parentFileAs<SlideLayout>().GetImagePathNameFromRId(*link);
else if(parentFileIs<SlideMaster>()) return parentFileAs<SlideMaster>().GetImagePathNameFromRId(*link);
else if(parentFileIs<Theme>()) return parentFileAs<Theme>().GetImagePathNameFromRId(*link);
else if(parentFileIs<NotesSlide>()) return parentFileAs<NotesSlide>().GetImagePathNameFromRId(*link);
return _T("");
}
return _T("");
@ -149,12 +139,13 @@ namespace PPTX
{
smart_ptr<OOX::OleObject> pOleObject;
if (pRels != NULL) pOleObject = pRels->GetOleObject(oRId);
else if(parentFileIs<Slide>()) pOleObject = parentFileAs<Slide>().GetOleObject(oRId);
else if(parentFileIs<SlideLayout>()) pOleObject = parentFileAs<SlideLayout>().GetOleObject(oRId);
else if(parentFileIs<SlideMaster>()) pOleObject = parentFileAs<SlideMaster>().GetOleObject(oRId);
else if(parentFileIs<Theme>()) pOleObject = parentFileAs<Theme>().GetOleObject(oRId);
else if(parentFileIs<NotesSlide>()) pOleObject = parentFileAs<NotesSlide>().GetOleObject(oRId);
if (pRels != NULL) pOleObject = pRels->Get<OOX::OleObject>(oRId);
else if(parentFileIs<Slide>()) pOleObject = parentFileAs<Slide>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<SlideLayout>()) pOleObject = parentFileAs<SlideLayout>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<SlideMaster>()) pOleObject = parentFileAs<SlideMaster>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<Theme>()) pOleObject = parentFileAs<Theme>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<NotesSlide>()) pOleObject = parentFileAs<NotesSlide>().Get<OOX::OleObject>(oRId);
if (pOleObject.IsInit())
return pOleObject->filename().m_strFilename;
@ -250,7 +241,7 @@ namespace PPTX
imagePath = this->GetFullPicName(pRels);
}
NSShapeImageGen::CImageInfo oId = pWriter->m_pCommon->m_pImageManager->WriteImage(imagePath, dX, dY, dW, dH, additionalPath, additionalType);
NSShapeImageGen::CMediaInfo oId = pWriter->m_pCommon->m_pMediaManager->WriteImage(imagePath, dX, dY, dW, dH, additionalPath, additionalType);
std::wstring s = oId.GetPath2();
pWriter->StartRecord(3);

View File

@ -50,6 +50,7 @@ namespace PPTX
Blip(std::wstring ns = L"a")
{
m_namespace = ns;
mediaExternal = false;
}
Blip& operator=(const Blip& oSrc)
{
@ -69,6 +70,7 @@ namespace PPTX
mediaRid = oSrc.mediaRid;
mediaFilepath = oSrc.mediaFilepath;
mediaExternal = oSrc.mediaExternal;
return *this;
}
@ -105,6 +107,7 @@ namespace PPTX
//internal
std::wstring mediaRid;
std::wstring mediaFilepath;
bool mediaExternal;
std::wstring oleRid;
std::wstring oleFilepathBin;

View File

@ -468,8 +468,8 @@ namespace PPTX
NSBinPptxRW::CDrawingConverter oDrawingConverter;
//oDrawingConverter.SetFontManager(pFontManager);
RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = pWriter->m_pCommon->m_pImageManager;
RELEASEOBJECT(oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager);
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = pWriter->m_pCommon->m_pMediaManager;
std::wstring *main_props = NULL;
@ -481,7 +481,7 @@ namespace PPTX
{
pWriter->WriteBYTEArray(oDrawingConverter.m_pBinaryWriter->GetBuffer()+10,oDrawingConverter.m_pBinaryWriter->GetPosition()-10);
}
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pImageManager = NULL;
oDrawingConverter.m_pBinaryWriter->m_pCommon->m_pMediaManager = NULL;
return;
}
pWriter->StartRecord(SPTREE_TYPE_GRFRAME);

View File

@ -32,53 +32,170 @@
#include "Hyperlink.h"
#include "./../Slide.h"
#include "./../SlideMaster.h"
#include "./../SlideLayout.h"
#include "./../Theme.h"
#include "../Slide.h"
#include "../SlideMaster.h"
#include "../SlideLayout.h"
#include "../Theme.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
namespace PPTX
{
namespace Logic
{
std::wstring Hyperlink::GetFullHyperlinkName(OOX::IFileContainer* pRels)const
std::wstring Hyperlink::GetPathFromId(OOX::IFileContainer* pRels, const std::wstring & rId)const
{
if(id.IsInit() && *id != _T(""))
if (rId.empty()) return L"";
OOX::RId rid(rId);
std::wstring sLink = L"";
if (pRels != NULL)
{
OOX::RId rid(*id);
std::wstring sLink = _T("");
if (pRels != NULL)
{
smart_ptr<OOX::HyperLink> p = pRels->GetHyperlink(rid);
if (p.is_init())
sLink = p->Uri().m_strFilename;
}
if(sLink.empty())
{
if(parentFileIs<Slide>())
sLink = parentFileAs<Slide>().GetFullHyperlinkNameFromRId(rid);
else if(parentFileIs<SlideLayout>())
sLink = parentFileAs<SlideLayout>().GetFullHyperlinkNameFromRId(rid);
else if(parentFileIs<SlideMaster>())
sLink = parentFileAs<SlideMaster>().GetFullHyperlinkNameFromRId(rid);
else if(parentFileIs<Theme>())
sLink = parentFileAs<Theme>().GetFullHyperlinkNameFromRId(rid);
else if(parentFileIs<NotesSlide>())
sLink = parentFileAs<NotesSlide>().GetFullHyperlinkNameFromRId(rid);
}
XmlUtils::replace_all(sLink, L"\\", L"/");
XmlUtils::replace_all(sLink, L"//", L"/");
XmlUtils::replace_all(sLink, L"http:/", L"http://");
XmlUtils::replace_all(sLink, L"https:/",L"https://");
XmlUtils::replace_all(sLink, L"ftp:/", L"ftp://");
XmlUtils::replace_all(sLink, L"file:/", L"file://");
return sLink;
smart_ptr<OOX::HyperLink> p = pRels->Get<OOX::HyperLink>(rid);
if (p.is_init())
sLink = p->Uri().m_strFilename;
}
return _T("");
if(sLink.empty())
{
if(parentFileIs<Slide>()) sLink = parentFileAs<Slide>().GetLinkFromRId(rid);
else if(parentFileIs<SlideLayout>()) sLink = parentFileAs<SlideLayout>().GetLinkFromRId(rid);
else if(parentFileIs<SlideMaster>()) sLink = parentFileAs<SlideMaster>().GetLinkFromRId(rid);
else if(parentFileIs<Theme>()) sLink = parentFileAs<Theme>().GetLinkFromRId(rid);
else if(parentFileIs<NotesSlide>()) sLink = parentFileAs<NotesSlide>().GetLinkFromRId(rid);
}
XmlUtils::replace_all(sLink, L"\\", L"/");
XmlUtils::replace_all(sLink, L"//", L"/");
XmlUtils::replace_all(sLink, L"http:/", L"http://");
XmlUtils::replace_all(sLink, L"https:/",L"https://");
XmlUtils::replace_all(sLink, L"ftp:/", L"ftp://");
XmlUtils::replace_all(sLink, L"file:/", L"file://");
return sLink;
}
void Hyperlink::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
OOX::IFileContainer* pRels = NULL;
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
if (id.is_init())
{
std::wstring hyperlinkPath = GetPathFromId(pRels, id.IsInit() ? *id : L"");
pWriter->WriteString1(0, hyperlinkPath);
}
pWriter->WriteString2(1, invalidUrl);
pWriter->WriteString2(2, action);
pWriter->WriteString2(3, tgtFrame);
pWriter->WriteString2(4, tooltip);
pWriter->WriteBool2(5, history);
pWriter->WriteBool2(6, highlightClick);
pWriter->WriteBool2(7, endSnd);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->WriteRecord2(0, snd);
}
void Hyperlink::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
bool bIsPresentUrl = false;
std::wstring strUrl;
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
strUrl = pReader->GetString2();
bIsPresentUrl = true;
break;
}
case 1:
{
invalidUrl = pReader->GetString2();
break;
}
case 2:
{
action = pReader->GetString2();
break;
}
case 3:
{
tgtFrame = pReader->GetString2();
break;
}
case 4:
{
tooltip = pReader->GetString2();
break;
}
case 5:
{
history = pReader->GetBool();
break;
}
case 6:
{
highlightClick = pReader->GetBool();
break;
}
case 7:
{
endSnd = pReader->GetBool();
break;
}
default:
break;
}
}
while (pReader->GetPos() < _end_rec)
{
BYTE _at = pReader->GetUChar();
switch (_at)
{
case 0:
{
snd = new PPTX::Logic::WavAudioFile(L"snd");
snd->fromPPTY(pReader);
break;
}
default:
{
break;
}
}
}
pReader->Seek(_end_rec);
if (bIsPresentUrl)
{
if (strUrl == _T(""))
id = _T("");
else
{
LONG lId = pReader->m_pRels->WriteHyperlink(strUrl, action.is_init());
id = L"rId" + std::to_wstring(lId);
}
}
}
} // namespace Logic
} // namespace PPTX

View File

@ -47,7 +47,7 @@ namespace PPTX
public:
WritingElement_AdditionConstructors(Hyperlink)
Hyperlink(std::wstring name = L"hlinkClick")
Hyperlink(const std::wstring & name = L"hlinkClick")
{
m_name = name;
}
@ -107,111 +107,8 @@ namespace PPTX
node.ReadAttributeBase(L"endSnd", endSnd);
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
if (id.is_init())
{
OOX::IFileContainer* pRels = NULL;
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
std::wstring str = GetFullHyperlinkName(pRels);
pWriter->WriteString1(0, str);
}
pWriter->WriteString2(1, invalidUrl);
pWriter->WriteString2(2, action);
pWriter->WriteString2(3, tgtFrame);
pWriter->WriteString2(4, tooltip);
pWriter->WriteBool2(5, history);
pWriter->WriteBool2(6, highlightClick);
pWriter->WriteBool2(7, endSnd);
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
pWriter->WriteRecord2(0, snd);
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
bool bIsPresentUrl = false;
std::wstring strUrl = _T("");
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
strUrl = pReader->GetString2();
bIsPresentUrl = true;
break;
}
case 1:
{
invalidUrl = pReader->GetString2();
break;
}
case 2:
{
action = pReader->GetString2();
break;
}
case 3:
{
tgtFrame = pReader->GetString2();
break;
}
case 4:
{
tooltip = pReader->GetString2();
break;
}
case 5:
{
history = pReader->GetBool();
break;
}
case 6:
{
highlightClick = pReader->GetBool();
break;
}
case 7:
{
endSnd = pReader->GetBool();
break;
}
default:
break;
}
}
if (bIsPresentUrl)
{
if (strUrl == _T(""))
id = _T("");
else
{
LONG lId = pReader->m_pRels->WriteHyperlink(strUrl, action.is_init());
id = L"rId" + std::to_wstring(lId);
}
}
pReader->Seek(_end_rec);
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
virtual void toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{
pWriter->StartNode(L"a:" + m_name);
@ -235,7 +132,6 @@ namespace PPTX
pWriter->EndNode(L"a:" + m_name);
}
public:
nullable<WavAudioFile> snd;
nullable_string id; //<OOX::RId> id;// <xsd:attribute ref="r:id" use="optional"/>
@ -246,9 +142,8 @@ namespace PPTX
nullable_bool history; //default="true"
nullable_bool highlightClick; //default="false"
nullable_bool endSnd; //default="false"
//private:
public:
std::wstring m_name;
std::wstring m_name;
protected:
virtual void FillParentPointersForChilds()
{
@ -256,7 +151,7 @@ namespace PPTX
snd->SetParentPointer(this);
}
virtual std::wstring GetFullHyperlinkName(OOX::IFileContainer* pRels)const;
virtual std::wstring GetPathFromId(OOX::IFileContainer* pRels, const std::wstring &rId)const;
};
} // namespace Logic
} // namespace PPTX

View File

@ -0,0 +1,136 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "WavAudioFile.h"
#include "../../Slide.h"
#include "../../SlideMaster.h"
#include "../../SlideLayout.h"
#include "../../Theme.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Media/Media.h"
namespace PPTX
{
namespace Logic
{
std::wstring WavAudioFile::GetPathFromId(OOX::IFileContainer* pRels, const std::wstring & rId)const
{
if (rId.empty()) return L"";
OOX::RId rid(rId);
std::wstring sLink = L"";
if (pRels != NULL)
{
smart_ptr<OOX::Media> p = pRels->Get<OOX::Media>(rid);
if (p.is_init())
sLink = p->filename().GetPath();
}
if(sLink.empty())
{
if(parentFileIs<Slide>()) sLink = parentFileAs<Slide>().GetLinkFromRId(rid);
else if(parentFileIs<SlideLayout>()) sLink = parentFileAs<SlideLayout>().GetLinkFromRId(rid);
else if(parentFileIs<SlideMaster>()) sLink = parentFileAs<SlideMaster>().GetLinkFromRId(rid);
else if(parentFileIs<Theme>()) sLink = parentFileAs<Theme>().GetLinkFromRId(rid);
else if(parentFileIs<NotesSlide>()) sLink = parentFileAs<NotesSlide>().GetLinkFromRId(rid);
}
return sLink;
}
void WavAudioFile::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
OOX::IFileContainer* pRels = NULL;
if (pWriter->m_pCurrentContainer->is_init())
pRels = pWriter->m_pCurrentContainer->operator ->();
std::wstring audioPath = GetPathFromId(pRels, embed.get());
NSShapeImageGen::CMediaInfo oId = pWriter->m_pCommon->m_pMediaManager->WriteMedia(audioPath);
std::wstring s = oId.GetPath2();
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, s);
if (name.IsInit())
{
pWriter->WriteString1(1, *name);
}
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
}
void WavAudioFile::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
std::wstring strSoundPath;
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
strSoundPath = pReader->GetString2();
break;
}
case 1:
{
name = pReader->GetString2();
break;
}
default:
break;
}
}
pReader->Seek(_end_rec);
if (!strSoundPath.empty())
{
std::wstring strPath = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + strSoundPath;
NSBinPptxRW::_relsGeneratorInfo oRelsGeneratorInfo = pReader->m_pRels->WriteMedia(strPath, 1);
if (oRelsGeneratorInfo.nImageRId > 0)
{
embed = OOX::RId((size_t)oRelsGeneratorInfo.nImageRId);
}
}
}
} // namespace Logic
} // namespace PPTX

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