Compare commits

...

45 Commits

Author SHA1 Message Date
e26f836da7 Merge commit '69d2b12f5315e96442fc5a0620d4f4c2070c4e77' into develop 2018-09-24 18:34:51 +03:00
69d2b12f53 . 2018-09-24 17:48:02 +03:00
f2260748c8 . 2018-09-24 17:48:02 +03:00
b59f84b262 . 2018-09-24 17:48:02 +03:00
3e5fed8482 x2t - fix return codes 2018-09-24 17:48:02 +03:00
538e477818 Revert "[test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32"
This reverts commit 05694d13f3.
2018-09-24 13:19:18 +03:00
b212e878c6 Merge pull request #114 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-24 01:13:01 +03:00
05694d13f3 [test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32 2018-09-24 01:04:14 +03:00
1dd72c99a2 Remove define GetCharWidth 2018-09-21 16:43:39 +02:00
4b73e58693 [bug] Fix missing function name 2018-09-21 17:36:32 +03:00
bee4f57dd3 [bug] Fix opening encrypted odf files 2018-09-21 17:36:32 +03:00
dd40e3e53c Merge pull request #111 from ONLYOFFICE/feature/ComboFonts
Fix bug with squares in combobox fonts (& empty rects)
2018-09-21 14:54:43 +03:00
d657ece017 Fix bug with squares in combobox fonts (& empty rects) 2018-09-21 14:36:14 +03:00
b21b1b8aaf [bug] Fix missing function name 2018-09-21 13:02:23 +03:00
09fb980060 [bug] Fix opening encrypted odf files 2018-09-21 12:01:01 +03:00
142f9f57a3 OdfFormatReader&Writer - refactoring converting wordarts from/to ooxml 2018-09-20 18:59:51 +03:00
28346c4571 Fix bug with squares in combobox fonts (& empty rects) 2018-09-20 14:53:10 +03:00
9810087ee1 Merge pull request #108 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-20 14:38:32 +03:00
2b8e1456c2 . 2018-09-20 11:41:42 +03:00
274c000ce7 fix PdfReader 2018-09-20 11:35:30 +03:00
9e6dd1fbb1 fix OdfReader 2018-09-20 11:35:30 +03:00
49723e648a . 2018-09-19 11:29:43 +03:00
b0a2104b21 Merge commit 'de51052f6ae59ac36665fb3f85804081a888c7c5' into develop 2018-09-18 20:03:33 +03:00
e4986f4202 . 2018-09-18 19:35:06 +03:00
de51052f6a [bug] Fix file corruption after pasting picture with error 2018-09-18 18:47:12 +03:00
bd1dc5a7b6 . 2018-09-17 17:28:46 +03:00
1ccbe323f4 . 2018-09-14 19:21:12 +03:00
2c8efcb183 Merge pull request #106 from ONLYOFFICE/feature/provideARCtoKernel
send use ARC parameter to downloader
2018-09-14 18:46:40 +03:00
9c2a717870 send use ARC parameter to downloader 2018-09-14 17:03:12 +03:00
3811169415 Merge commit '185dc3064f731e4adb04040e116dc53110c6d866' into develop 2018-09-14 11:36:36 +03:00
2871769479 . 2018-09-14 11:34:07 +03:00
185dc3064f OdfFormat - fix comment in empty cell-row, fix default background color 2018-09-13 19:51:31 +03:00
c6f8a1cde8 [bug] Fix bug 38876 2018-09-13 16:47:50 +03:00
acdce1edb9 . 2018-09-12 17:53:40 +03:00
67a40a5fc4 Constructor of __ox_drawing doesn't receive parameters 2018-09-12 15:41:37 +03:00
67cd654785 OdfFormatReader - convert form controls in spreadsheets 2018-09-11 14:59:10 +03:00
3816162555 Merge commit '3fb166f99a211e85474c121009019d06710722f8' into develop 2018-09-10 18:43:15 +03:00
3fb166f99a OdfFormatWriter - fix repeated rows 2018-09-10 18:15:35 +03:00
d8121d1a12 [ios][x2t] fixed array check 2018-09-06 19:11:47 +03:00
a76bf57051 fix bug #38817 2018-09-06 13:46:47 +03:00
97b92cf75c . 2018-09-05 18:39:32 +03:00
506de8e9e1 fix bug #38678 2018-09-05 18:38:55 +03:00
fb34d57ee6 DocFormatReader - fix footnotes for doc1995; optimization convert 2018-09-05 14:45:24 +03:00
da2d997838 . 2018-09-03 19:50:02 +03:00
76d68fa70f Fix bug #38544
Fix the problem with calculating transformation matrix for the EMF. Add support of EMR_STRETCHBLT field.
2018-09-03 18:07:10 +03:00
141 changed files with 2671 additions and 1482 deletions

View File

@ -58,7 +58,8 @@ namespace DocFileFormat
}
else
{
short cch = reader->ReadInt16();
short cch = reader->ReadInt16();
unsigned char *chars = reader->ReadBytes(18, true);
@ -67,13 +68,34 @@ namespace DocFileFormat
newObject->m_AuthorIndex = reader->ReadUInt16();
//skip 4 bytes
reader->ReadBytes(4, false);
unsigned int skip = reader->ReadUInt32();
newObject->m_BookmarkId = reader->ReadInt32();
newObject->m_BookmarkId = reader->ReadInt32(); //-1 - comment is on a length zero text range in the Main Document
RELEASEARRAYOBJECTS(chars);
}
return static_cast<ByteStructure*>(newObject);
}
ByteStructure* AnnotationReferenceExDescriptor::ConstructObject(VirtualStreamReader* reader, int length)
{
AnnotationReferenceExDescriptor *newObject = new AnnotationReferenceExDescriptor();
if (reader->nWordVersion > 0)
{
}
else
{
m_nDTTM = reader->ReadUInt32();
reader->ReadUInt16(); //padding1
m_nDepth = reader->ReadUInt32();
m_nDiatrdParent = reader->ReadUInt32();
unsigned int flag = reader->ReadUInt32();
m_fInkAtn = GETBIT(flag, 1);
}
return static_cast<ByteStructure*>(newObject);
}
}

View File

@ -46,21 +46,6 @@ namespace DocFileFormat
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
inline std::wstring GetUserInitials() const
{
return m_UserInitials;
}
inline unsigned short GetAuthorIndex() const
{
return m_AuthorIndex;
}
inline int GetBookmarkId() const
{
return m_BookmarkId;
}
AnnotationReferenceDescriptor() : m_AuthorIndex(0), m_BookmarkId(0)
{
}
@ -71,13 +56,35 @@ namespace DocFileFormat
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
private:
/// The initials of the user who left the annotation.
std::wstring m_UserInitials;
/// An index into the string table of comment author names.
unsigned short m_AuthorIndex;
/// Identifies a bookmark.
int m_BookmarkId;
};
class AnnotationReferenceExDescriptor: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 18;
static const int STRUCTURE_SIZE_OLD = 0;
static const int GetSize(int nWordVersion)
{
return (nWordVersion > 0) ? STRUCTURE_SIZE_OLD : STRUCTURE_SIZE;
}
AnnotationReferenceExDescriptor() : m_nDTTM(0), m_nDepth(0), m_nDiatrdParent(0), m_fInkAtn(false)
{
}
virtual ~AnnotationReferenceExDescriptor()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length );
unsigned int m_nDTTM;
unsigned int m_nDepth;
unsigned int m_nDiatrdParent;
bool m_fInkAtn;
};
}

View File

@ -39,13 +39,8 @@ namespace DocFileFormat
class BookmarkFirst: public ByteStructure
{
private:
/// An unsigned integer that specifies a zero-based index into the PlcfBkl or PlcfBkld
/// that is paired with the PlcfBkf or PlcfBkfd containing this FBKF.
/// The entry found at said index specifies the location of the end of the bookmark associated with this FBKF.
/// Ibkl MUST be unique for all FBKFs inside a given PlcfBkf or PlcfBkfd.
short ibkl;
/// A BKC that specifies further information about the bookmark associated with this FBKF.
short bkc;
short ibkl;
short bkc;
public:
static const int STRUCTURE_SIZE = 4;
@ -78,4 +73,32 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
};
class AtnBookmarkFirst: public ByteStructure
{
public:
unsigned short bmc;
unsigned int lTag;
static const int STRUCTURE_SIZE = 10;
AtnBookmarkFirst()
{
}
virtual ~AtnBookmarkFirst()
{
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
AtnBookmarkFirst *newObject = new AtnBookmarkFirst();
newObject->bmc = reader->ReadUInt16(); //0x0100
newObject->lTag = reader->ReadUInt32();
unsigned int lTagOld = reader->ReadUInt32();
return static_cast<ByteStructure*>( newObject );
}
};
}

View File

@ -75,7 +75,7 @@ namespace DocFileFormat
convertSprms( dynamic_cast<CharacterPropertyExceptions*>( chpx )->grpprl, _rPr );
// apend revision changes
if (_revisionData->Type == Changed)
if ((_revisionData) && (_revisionData->Type == Changed))
{
XMLTools::XMLElement rPrChange( L"w:rPrChange");

View File

@ -52,8 +52,6 @@ namespace DocFileFormat
{
m_context->_docx->RegisterComments();
int index = 0;
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin( L"w:comments", TRUE );
@ -63,33 +61,60 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute( L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute( L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute( L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" );
m_pXmlWriter->WriteAttribute( L"xmlns:cx", L"http://schemas.microsoft.com/office/drawing/2014/chartex" );
m_pXmlWriter->WriteAttribute( L"xmlns:cx1", L"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" );
m_pXmlWriter->WriteAttribute( L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006" );
m_pXmlWriter->WriteAttribute( L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math" );
m_pXmlWriter->WriteAttribute( L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" );
m_pXmlWriter->WriteAttribute( L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" );
m_pXmlWriter->WriteAttribute( L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:w15", L"http://schemas.microsoft.com/office/word/2012/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:w16se", L"http://schemas.microsoft.com/office/word/2015/wordml/symex" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" );
m_pXmlWriter->WriteAttribute( L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk" );
m_pXmlWriter->WriteAttribute( L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml" );
m_pXmlWriter->WriteAttribute( L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape" );
m_pXmlWriter->WriteAttribute( L"mc:Ignorable", L"w14 w15 w16se wp14");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr;
size_t count = m_document->AnnotationsReferencePlex->Elements.size();
for (size_t i = 0; i < count; ++i)
for (size_t index = 0; index < count; ++index)
{
AnnotationReferenceDescriptor* atrdPre10 = static_cast<AnnotationReferenceDescriptor*>(m_document->AnnotationsReferencePlex->Elements[index]);
AnnotationReferenceExDescriptor* atrdPost10 = m_document->AnnotationsReferenceExPlex ? static_cast<AnnotationReferenceExDescriptor*>(m_document->AnnotationsReferenceExPlex->Elements[index]) : NULL;
unsigned short index_author = atrdPre10->GetAuthorIndex();
m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
if (index_author < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
if (atrdPre10->m_BookmarkId < 0)
{
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 + count + 1024 ));
}
else
{
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( index + 1 ));
}
if (atrdPost10)
{
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
}
if (atrdPre10->m_AuthorIndex < m_document->AnnotationOwners->size()) //conv_253l2H1CehgKwsxCtNk__docx.doc
{
m_pXmlWriter->WriteAttribute( L"w:author",
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( index_author ) ));
FormatUtils::XmlEncode(m_document->AnnotationOwners->at( atrdPre10->m_AuthorIndex ) ));
}
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->GetUserInitials());
m_pXmlWriter->WriteAttribute( L"w:initials", atrdPre10->m_UserInitials);
//!!!TODO!!!
/*//ATRDpost10 is optional and not saved in all files
if (doc.AnnotationReferenceExtraTable != null &&
doc.AnnotationReferenceExtraTable.Count > index)
{
AnnotationReferenceDescriptorExtra atrdPost10 = doc.AnnotationReferenceExtraTable[index];
atrdPost10.Date.Convert(new DateMapping(_writer));
}*/
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
@ -116,8 +141,6 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeEnd(L"w:comment" );
++index;
}
m_pXmlWriter->WriteNodeEnd( L"w:comments" );

View File

@ -61,7 +61,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
_UINT32 Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
{
if (!doc || !docx) return S_FALSE;
@ -202,20 +202,18 @@ namespace DocFileFormat
return S_OK;
}
long Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
_UINT32 Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
{
long result = S_FALSE;
WordDocument doc(progress, m_sTempFolder);
WordprocessingDocument docx(strDstDirectory, &doc);
result = doc.LoadDocument(strSrcFile, password);
_UINT32 result = doc.LoadDocument(strSrcFile, password);
if (result == S_OK)
if (result == 0)
{
result = Convert(&doc, &docx, progress);
if (result == S_OK)
if (result == 0)
{
docx.SaveDocument(bMacros);

View File

@ -32,6 +32,7 @@
#pragma once
#include <string>
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
struct ProgressCallback;
@ -48,9 +49,9 @@ namespace DocFileFormat
std::wstring m_sTempFolder;
long LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros);
_UINT32 LoadAndConvert(const std::wstring & strSrcFile, const std::wstring & strDstDirectory, const std::wstring & password, const ProgressCallback* progress, bool &bMacros);
private:
long Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
_UINT32 Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress);
};
}

View File

@ -45,7 +45,7 @@ namespace DocFileFormat
{
DocumentMapping::DocumentMapping(ConversionContext* context, IMapping* caller) : _skipRuns(0), _lastValidPapx(NULL), _lastValidSepx(NULL),
AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() ), _sectionNr(0), _footnoteNr(0),
_endnoteNr(0), _commentNr(0), _caller(caller)
_endnoteNr(0), _commentNr(1), _caller(caller)
{
m_document = NULL;
m_context = context;
@ -506,7 +506,7 @@ namespace DocFileFormat
}
//write text
for (unsigned int i = 0; i < chars->size(); ++i)
for (size_t i = 0; i < chars->size(); ++i)
{
wchar_t c = chars->at(i), code = c;
@ -526,7 +526,20 @@ namespace DocFileFormat
text.clear();
XMLTools::XMLElement elem(L"w:br");
if (textType == L"instrText")
{
m_pXmlWriter->WriteNodeEnd(L"w:r");
m_pXmlWriter->WriteNodeBegin(L"w:r");
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, NULL, _lastValidPapx, false);
if (rPr)
{
rPr->_webHidden = _writeWebHidden;
chpx->Convert(rPr);
RELEASEOBJECT(rPr);
}
}
XMLTools::XMLElement elem(L"w:br");
elem.AppendAttribute(L"w:type", L"textWrapping");
elem.AppendAttribute(L"w:clear", L"all");
@ -1013,6 +1026,11 @@ namespace DocFileFormat
if ((m_document->FootnoteReferenceCharactersPlex != NULL) && (m_document->FootnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( L"w:footnoteReference", true );
FootnoteDescriptor* desc = dynamic_cast<FootnoteDescriptor*>(m_document->FootnoteReferenceCharactersPlex->Elements[_footnoteNr]);
if (desc && desc->aFtnIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
}
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(_footnoteNr++ ) );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -1024,6 +1042,11 @@ namespace DocFileFormat
else if ((m_document->EndnoteReferenceCharactersPlex != NULL) && (m_document->EndnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( L"w:endnoteReference", true );
EndnoteDescriptor* desc = dynamic_cast<EndnoteDescriptor*>(m_document->EndnoteReferenceCharactersPlex->Elements[_footnoteNr]);
if (desc && desc->aEndIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
}
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(_endnoteNr++ ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
@ -1041,10 +1064,10 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( L"w:annotationRef", true );
m_pXmlWriter->WriteNodeEnd( L"", true );
}
else
else if ((m_document->AnnotationsReferencePlex) && (_commentNr <= m_document->AnnotationsReferencePlex->Elements.size()))
{
m_pXmlWriter->WriteNodeBegin( L"w:commentReference", true );
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr ));
m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString( _commentNr++ ));
m_pXmlWriter->WriteNodeEnd( L"", true );
}
}
@ -1196,7 +1219,7 @@ namespace DocFileFormat
// add the parts
for (unsigned int i = 0; i < splitIndices->size(); ++i)
for (size_t i = 0; i < splitIndices->size(); ++i)
{
int cch = splitIndices->at( i ) - startIndex;

View File

@ -37,21 +37,14 @@ namespace DocFileFormat
{
class EndnoteDescriptor: public ByteStructure
{
private:
short aEndIdx;
public:
static const int STRUCTURE_SIZE = 2;
EndnoteDescriptor():
aEndIdx(0)
{
}
EndnoteDescriptor(): aEndIdx(0) {}
virtual ~EndnoteDescriptor()
{
}
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
EndnoteDescriptor *newObject = new EndnoteDescriptor();
@ -60,5 +53,7 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
short aEndIdx;
};
}

View File

@ -560,8 +560,7 @@ namespace DocFileFormat
m_FibWord97.fcPlcffndRef = reader.ReadInt32();
m_FibWord97.lcbPlcffndRef = reader.ReadInt32();
m_FibWord97.lcbPlcfandTxt = reader.ReadInt32();//112
m_FibWord97.fcPlcffndTxt = reader.ReadInt32();//112
m_FibWord97.lcbPlcffndTxt = reader.ReadInt32();
m_FibWord97.fcPlcfandRef = reader.ReadInt32();

View File

@ -37,21 +37,15 @@ namespace DocFileFormat
{
class FootnoteDescriptor: public ByteStructure
{
private:
short aFtnIdx;
public:
static const int STRUCTURE_SIZE = 2;
FootnoteDescriptor():
aFtnIdx(0)
{
}
FootnoteDescriptor() : aFtnIdx(0) {}
virtual ~FootnoteDescriptor()
{
}
}
virtual ByteStructure* ConstructObject( VirtualStreamReader* reader, int length )
{
FootnoteDescriptor *newObject = new FootnoteDescriptor();
@ -60,5 +54,7 @@ namespace DocFileFormat
return static_cast<ByteStructure*>( newObject );
}
short aFtnIdx;
};
}

View File

@ -79,7 +79,7 @@ namespace DocFileFormat
drawing.dgglbl = (DrawingType)oStearmReader.ReadByte();
drawing.container = static_cast<DrawingContainer*>(RecordFactory::ReadRecord (&oStearmReader, 0));
for (unsigned int i = 0; i < drawing.container->Children.size(); ++i)
for (size_t i = 0; i < drawing.container->Children.size(); ++i)
{
Record* groupChild = drawing.container->Children[i];
if (groupChild)
@ -140,7 +140,7 @@ namespace DocFileFormat
GroupContainer* group = iter->container->FirstChildWithType<GroupContainer>();
if (group)
{
for (unsigned int i = 1; i < group->Children.size(); ++i)
for (size_t i = 1; i < group->Children.size(); ++i)
{
Record* groupChild = group->Children[i];

View File

@ -48,6 +48,7 @@ namespace DocFileFormat
std::vector<ByteStructure*> Elements;
bool m_bIsValid;
std::map<int, int> mapCP;
public:
Plex(int structureLength, POLE::Stream* stream, unsigned int fc, unsigned int lcb, int nWordVersion)
: m_bIsValid(false), CP_LENGTH(/*nWordVersion == 2 ? 2 :*/ 4)
@ -77,7 +78,10 @@ namespace DocFileFormat
for (int i = 0; i < (n + 1); ++i)
{
CharacterPositions.push_back(reader.ReadInt32());
int val = reader.ReadInt32();
mapCP.insert(std::make_pair(val, (int)CharacterPositions.size()));
CharacterPositions.push_back(val);
}
// read the n structs
@ -96,9 +100,9 @@ namespace DocFileFormat
~Plex()
{
for (std::vector<ByteStructure*>::iterator iter = Elements.begin(); iter != Elements.end(); ++iter)
for (size_t i = 0; i < Elements.size(); ++i)
{
RELEASEOBJECT(*iter);
RELEASEOBJECT(Elements[i]);
}
}
@ -109,15 +113,14 @@ namespace DocFileFormat
{
int index = -1;
for (int i = 0; i < (int)CharacterPositions.size(); ++i)
std::map<int, int>::iterator pFind = mapCP.find(cp);
if (pFind != mapCP.end())
{
if (CharacterPositions[i] == cp)
{
index = i;
break;
}
index = pFind->second;
}
if ((index >= 0) && (index < (int)Elements.size()))
return this->Elements[index];
@ -128,13 +131,11 @@ namespace DocFileFormat
{
bool result = false;
for (int i = 0; i < (int)CharacterPositions.size(); ++i)
std::map<int, int>::const_iterator pFind = mapCP.find(cp);
if (pFind != mapCP.end())
{
if (CharacterPositions[i] == cp)
{
result = true;
break;
}
result = true;
}
return result;
@ -142,7 +143,7 @@ namespace DocFileFormat
inline int operator [] (unsigned int index) const
{
if (index < CharacterPositions.size())
if (index < (unsigned int)CharacterPositions.size())
return CharacterPositions[index];
return -1;

View File

@ -156,9 +156,8 @@ namespace DocFileFormat
}break;
//div id
case sprmTIpgp:
case sprmTIpgp:// = PGPInfo.ipgpSelf (PGPInfo structure describes the border and margin properties)
{
appendValueElement( _trPr, L"divId", FormatUtils::IntToWideString( FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize ) ), true );
}break;
//borders 80 exceptions

View File

@ -85,7 +85,7 @@ namespace DocFileFormat
IndividualFootnotesPlex(NULL), FootnoteReferenceCharactersPlex(NULL), IndividualEndnotesPlex(NULL),
EndnoteReferenceCharactersPlex(NULL), FieldsPlex(NULL), FootnoteDocumentFieldsPlex(NULL),
EndnoteDocumentFieldsPlex(NULL), HeadersAndFootersDocumentFieldsPlex(NULL), HeaderStoriesPlex(NULL),
AnnotationsReferencePlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
AnnotationsReferencePlex(NULL), AnnotationsReferenceExPlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
TextboxIndividualPlex(NULL),AssocNames(NULL), BookmarkAnnotNames(NULL), Captions(NULL), AutoCaptions(NULL), ListPlex(NULL),
OfficeDrawingPlex(NULL), OfficeDrawingPlexHeader(NULL), SectionPlex(NULL), BookmarkStartPlex(NULL), BookmarkEndPlex(NULL),
AutoTextPlex(NULL), AllPapxFkps(NULL), AllChpxFkps(NULL), AllPapx(NULL), AllPapxVector(NULL), AllSepx(NULL), Styles(NULL), listTable(NULL),
@ -117,7 +117,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
int WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
_UINT32 WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
{
m_sFileName = fileName;
m_sPassword = password;
@ -318,8 +318,8 @@ namespace DocFileFormat
// Read all needed PLCFs
if (FIB->m_RgLw97.ccpFtn > 0)
{
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
FootnoteReferenceCharactersPlex = new Plex<FootnoteDescriptor>(FootnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndRef, FIB->m_FibWord97.lcbPlcffndRef, nWordVersion);
IndividualFootnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcffndTxt, FIB->m_FibWord97.lcbPlcffndTxt, nWordVersion);
}
if (nWordVersion > 0 && FIB->m_FibWord97.lcbPlcPad > 0)
@ -329,8 +329,8 @@ namespace DocFileFormat
if (FIB->m_RgLw97.ccpEdn > 0)
{
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
EndnoteReferenceCharactersPlex = new Plex<EndnoteDescriptor>(EndnoteDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendRef, FIB->m_FibWord97.lcbPlcfendRef, nWordVersion);
IndividualEndnotesPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfendTxt, FIB->m_FibWord97.lcbPlcfendTxt, nWordVersion);
}
if (FIB->m_RgLw97.ccpHdr > 0)
@ -343,6 +343,11 @@ namespace DocFileFormat
AnnotationsReferencePlex = new Plex<AnnotationReferenceDescriptor>(AnnotationReferenceDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcfandRef, FIB->m_FibWord97.lcbPlcfandRef, nWordVersion);
IndividualCommentsPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfandTxt, FIB->m_FibWord97.lcbPlcfandTxt, nWordVersion);
}
if (FIB->m_FibWord2002.lcbAtrdExtra > 0)
{
AnnotationsReferenceExPlex = new Plex<AnnotationReferenceExDescriptor>(AnnotationReferenceExDescriptor::GetSize(nWordVersion), TableStream, FIB->m_FibWord2002.fcAtrdExtra, FIB->m_FibWord2002.lcbAtrdExtra, nWordVersion);
}
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, nWordVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(nWordVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, nWordVersion);
@ -356,7 +361,7 @@ namespace DocFileFormat
TextboxBreakPlex = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxBkd, FIB->m_FibWord97.lcbPlcfTxbxBkd, nWordVersion);
TextboxBreakPlexHeader = new Plex<Tbkd> (Tbkd::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfTxbxHdrBkd, FIB->m_FibWord97.lcbPlcfTxbxHdrBkd, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkf, FIB->m_FibWord97.lcbPlcfAtnBkf, nWordVersion);
AnnotEndPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfAtnBkl, FIB->m_FibWord97.lcbPlcfAtnBkl, nWordVersion);
@ -368,18 +373,19 @@ namespace DocFileFormat
BookmarkStartEndCPs.push_back(std::make_pair(BookmarkStartPlex->CharacterPositions[i], BookmarkEndPlex->CharacterPositions[pBookmark->GetIndex()]));
}
}
for (size_t i = 0; i < AnnotStartPlex->Elements.size(); ++i)
for (size_t i = 0; AnnotStartPlex && i < AnnotStartPlex->Elements.size(); ++i)
{
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
BookmarkFirst* pBookmark = static_cast<BookmarkFirst*>(AnnotStartPlex->Elements[i]);
if (pBookmark)
{
short end = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() && end < AnnotEndPlex->CharacterPositions.size())
short ind = pBookmark->GetIndex();
if (i < AnnotStartPlex->CharacterPositions.size() -1 )
{
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[end]));
AnnotStartEndCPs.push_back(std::make_pair(AnnotStartPlex->CharacterPositions[i], AnnotEndPlex->CharacterPositions[i + 1]));
}
}
}
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, nWordVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, nWordVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, nWordVersion);
@ -435,7 +441,7 @@ namespace DocFileFormat
std::unordered_map<int, int> fonts_charsets;
bool bFontsCodePage = false;
for ( size_t i = 0; !bFontsCodePage && i < FontTable->Data.size(); ++i)
for ( size_t i = 0; FIB->m_FibWord97.lcbClx > 0 && !bFontsCodePage && i < FontTable->Data.size(); ++i)
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( FontTable->Data[i]);
if (!font) continue;
@ -488,13 +494,13 @@ namespace DocFileFormat
if (BookmarkNames)
{
for (unsigned int i = 0; i < BookmarkStartEndCPs.size(); ++i)
for (size_t i = 0; i < BookmarkStartEndCPs.size(); ++i)
{
WideString* bookmarkName = static_cast<WideString*>(BookmarkNames->operator[]( i ));
if ( ( bookmarkName != NULL ) && ( *bookmarkName == L"_PictureBullets" ) )
{
for (unsigned int j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
for (size_t j = BookmarkStartEndCPs[i].first, k = 0; j < Text->size(); ++j, ++k )
{
if ( Text->at( j ) == 1 )
{
@ -540,7 +546,7 @@ namespace DocFileFormat
{
AllSepx = new std::map<int, SectionPropertyExceptions*>();
for (unsigned int i = 0; i < SectionPlex->Elements.size(); ++i)
for (size_t i = 0; i < SectionPlex->Elements.size(); ++i)
{
//Read the SED
SectionDescriptor* sed = static_cast<SectionDescriptor*>(SectionPlex->Elements.at(i));
@ -869,6 +875,7 @@ namespace DocFileFormat
RELEASEOBJECT(HeaderStoriesPlex);
RELEASEOBJECT(IndividualCommentsPlex);
RELEASEOBJECT(AnnotationsReferencePlex);
RELEASEOBJECT(AnnotationsReferenceExPlex);
RELEASEOBJECT(TextboxBreakPlex);
RELEASEOBJECT(TextboxBreakPlexHeader);
RELEASEOBJECT(OfficeDrawingPlex);

View File

@ -94,7 +94,7 @@ namespace DocFileFormat
WordDocument (const ProgressCallback* pCallFunc, const std::wstring & tempFolder );
virtual ~WordDocument();
int LoadDocument(const std::wstring & fileName, const std::wstring & password);
_UINT32 LoadDocument(const std::wstring & fileName, const std::wstring & password);
int nWordVersion;
int nDocumentCodePage;
@ -224,6 +224,7 @@ namespace DocFileFormat
Plex<FieldCharacter> *EndnoteDocumentFieldsPlex;
Plex<FieldCharacter> *HeadersAndFootersDocumentFieldsPlex;
Plex<AnnotationReferenceDescriptor> *AnnotationsReferencePlex;
Plex<AnnotationReferenceExDescriptor> *AnnotationsReferenceExPlex;
Plex<EmptyStructure> *AutoTextPlex;
// Each character position specifies the beginning of a range of text that constitutes the contents of an AutoText item

View File

@ -34,9 +34,9 @@
#include "../DocDocxConverter/Converter.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
_UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
{
HRESULT hr = S_FALSE;
_UINT32 hr = 0;
DocFileFormat::Converter docToDocx;
docToDocx.m_sTempFolder = m_sTempFolder;
@ -46,7 +46,7 @@ HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::w
return hr;
}
HRESULT COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack )
_UINT32 COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack )
{
return S_OK;
return 0;
}

View File

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

View File

@ -85,7 +85,7 @@ namespace BinXlsxRW{
sMediaPath = pathMediaDir.GetPath();
sEmbedPath = pathEmbedDir.GetPath();
}
int CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
_UINT32 CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
@ -100,7 +100,7 @@ namespace BinXlsxRW{
BinXlsxRW::BinaryFileReader oBinaryFileReader;
return oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
}
int CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
_UINT32 CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
{
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -136,7 +136,7 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetFontPicker(pFontPicker);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
int result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
_UINT32 result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
RELEASEOBJECT(pFontPicker);
return result;

View File

@ -33,6 +33,7 @@
#define XLSX_SERIALIZER
#include <string>
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
namespace OOX
{
@ -62,8 +63,8 @@ namespace BinXlsxRW {
static void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
int loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
int saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
_UINT32 loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
_UINT32 saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber);

View File

@ -105,7 +105,7 @@ HRESULT convert_single(std::wstring srcFileName)
}
_CP_LOG << L"[info] " << srcFileName << std::endl;
nResult = ConvertODF2OOXml(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", srcTempPath2, L"password", NULL);
nResult = ConvertODF2OOXml(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", srcTempPath2, L"", NULL);
if (srcTempPath != srcFileName)
{

View File

@ -310,6 +310,7 @@ typedef xml::writer::element<wchar_t> xml_element;
#define CP_XML_WRITER(STRM) if (bool _b_ = false) {} else for (xml_writer _xml_wr_((STRM));!_b_;_b_=true)
#define CP_XML_NODE(NAME) if (bool _b_ = false) {} else for (xml_element _xml_node_(_xml_wr_, (NAME));!_b_;_b_=true)
#define CP_XML_ATTR(NAME, VAL) _xml_node_.attr((NAME),(VAL))
#define CP_XML_ATTR2(NAME, VAL) _xml_node_.attr((std::wstring(NAME).c_str()),(VAL))
#define CP_XML_CONTENT(VAL) _xml_node_.contents((VAL))
#define CP_XML_STREAM() _xml_node_.stream()

View File

@ -43,7 +43,7 @@
#include "../include/odf/odf_document.h"
int ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
_UINT32 ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
{
cpdoccore::oox::package::xlsx_document outputXlsx;
cpdoccore::oox::xlsx_conversion_context conversionContext( &inputOdf);
@ -56,7 +56,7 @@ int ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::w
outputXlsx.write(dstPath);
return 0;
}
int ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
_UINT32 ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
{
cpdoccore::oox::package::docx_document outputDocx;
cpdoccore::oox::docx_conversion_context conversionContext(&inputOdf);
@ -70,7 +70,7 @@ int ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::w
return 0;
}
int ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
_UINT32 ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
{
cpdoccore::oox::package::pptx_document outputPptx;
cpdoccore::oox::pptx_conversion_context conversionContext(&inputOdf);
@ -83,9 +83,9 @@ int ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::w
return 0;
}
int ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack)
_UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack)
{
int nResult = 0;
_UINT32 nResult = 0;
try
{
@ -134,9 +134,9 @@ int ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath,
}
int ConvertOTF2ODF(const std::wstring & srcPath)
_UINT32 ConvertOTF2ODF(const std::wstring & srcPath)
{
int nResult = 0;
_UINT32 nResult = 0;
std::wstring manifest_xml = srcPath + FILE_SEPARATOR_STR + L"META-INF" + FILE_SEPARATOR_STR + L"manifest.xml";
std::wstring mimetype_xml = srcPath + FILE_SEPARATOR_STR + L"mimetype";

View File

@ -31,10 +31,11 @@
*/
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include <string>
struct ProgressCallback;
int ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack);
_UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstPath, const std::wstring & fontsPath, const std::wstring & tempPath, const std::wstring & password, const ProgressCallback* CallBack);
int ConvertOTF2ODF(const std::wstring & otfPath);
_UINT32 ConvertOTF2ODF(const std::wstring & otfPath);

View File

@ -72,10 +72,10 @@ std::wostream & override_content_type::xml_to_stream(std::wostream & _Wostream)
return _Wostream;
}
const wchar_t * content_type_content::ns = L"";
const wchar_t * content_type_content::name = L"Types";
const wchar_t * content_type::ns = L"";
const wchar_t * content_type::name = L"Types";
std::wostream & content_type_content::xml_to_stream(std::wostream & _Wostream) const
std::wostream & content_type::xml_to_stream(std::wostream & _Wostream) const
{
CP_XML_WRITER(_Wostream)
{

View File

@ -86,8 +86,8 @@ public:
};
///////////////////////////////////////////////////////////////////////////////////////
// content_type_content
class content_type_content : public xml::element_impl<content_type_content>
// content_type
class content_type : public xml::element_impl<content_type>
{
public:
static const wchar_t * ns;

View File

@ -128,63 +128,14 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
void text_forms_context::start_element (int type)
{
current_state_.clear();
current_state_.type = type;
}
void text_forms_context::set_id (const std::wstring& id)
{
current_state_.id = id;
}
void text_forms_context::set_name (const std::wstring& name)
{
current_state_.name = name;
}
void text_forms_context::set_label (const std::wstring& label)
{
current_state_.label = label;
}
void text_forms_context::set_uuid (const std::wstring& uuid)
{
current_state_.uuid = uuid;
}
void text_forms_context::set_value (const std::wstring &value)
{
current_state_.value = value;
}
void text_forms_context::set_element(odf_reader::form_element *elm)
{
current_state_.element = elm;
}
void text_forms_context::end_element ()
{
mapElements_.insert( std::make_pair(current_state_.id, current_state_));
current_state_.clear();
}
text_forms_context::_state& text_forms_context::get_state_element (std::wstring id)
{
std::map<std::wstring, _state>::iterator it = mapElements_.find(id);
if (it != mapElements_.end())
{
return it->second;
}
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
in_automatic_style_ (false),
in_paragraph_ (false),
in_header_ (false),
in_drawing_content_ (false),
in_table_content_ (false),
@ -195,7 +146,6 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
new_list_style_number_ (0),
current_margin_left_ (0),
is_rtl_ (false),
is_paragraph_keep_ (false),
is_delete_text_ (false),
delayed_converting_ (false),
process_headers_footers_ (false),
@ -247,14 +197,14 @@ std::wstring styles_map::name(const std::wstring & Name, odf_types::style_family
}
void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
{
if (!in_run_)
if (!state_.in_run_)
{
in_run_ = true;
state_.in_run_ = true;
output_stream() << L"<w:r>";
if (!text_properties_stack_.empty() || parenStyleId.length() > 0)
if (!state_.text_properties_stack_.empty() || parenStyleId.length() > 0)
{
if (!text_properties_stack_.empty())
if (!state_.text_properties_stack_.empty())
{
odf_reader::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start();
@ -272,36 +222,36 @@ void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
void docx_conversion_context::start_paragraph(bool is_header)
{
if (in_paragraph_)
if (state_.in_paragraph_)
finish_paragraph();
output_stream() << L"<w:p>";
in_header_ = is_header;
in_paragraph_ = true;
is_rtl_ = false;
state_.in_paragraph_ = true;
start_changes();
}
void docx_conversion_context::finish_paragraph()
{
if (in_paragraph_)
if (state_.in_paragraph_)
{
end_changes();
output_stream() << L"</w:p>";
}
in_paragraph_ = false;
in_header_ = false;
is_paragraph_keep_ = false;
in_header_ = false;
state_.is_paragraph_keep_ = false;
state_.in_paragraph_ = false;
}
void docx_conversion_context::finish_run()
{
if (false == in_run_) return;
if (false == state_.in_run_) return;
if (get_comments_context().state() == 4)
{
@ -309,7 +259,7 @@ void docx_conversion_context::finish_run()
get_comments_context().state(0);
}
output_stream() << L"</w:r>";
in_run_ = false;
state_.in_run_ = false;
if (get_comments_context().state() == 2)
{
@ -631,6 +581,27 @@ oox_chart_context & docx_conversion_context::current_chart()
throw std::runtime_error("internal error");
}
}
void docx_conversion_context::reset_context_state()
{
keep_state_.push_back(state_);
state_.in_paragraph_ = false;
state_.in_run_ = false;
state_.is_paragraph_keep_ = false;
state_.drawing_text_props_.clear();
state_.text_properties_stack_.clear();
get_styles_context().text_style_ext().clear();
}
void docx_conversion_context::back_context_state()
{
state_ = keep_state_.back();
keep_state_.pop_back();
get_styles_context().text_style_ext().clear();
}
void docx_conversion_context::add_new_run(std::wstring parentStyleId)
{
finish_run();
@ -1046,13 +1017,36 @@ void docx_conversion_context::process_styles()
_Wostream << L"<w:pPrDefault>";
if ( odf_reader::style_content * content = defaultParStyle->content())
{
if (content->get_style_paragraph_properties())
{
if(content->get_style_paragraph_properties()->content_.fo_background_color_)
{
odf_types::background_color color = *content->get_style_paragraph_properties()->content_.fo_background_color_;
if ((color.get_type() != odf_types::background_color::Transparent &&
color.get_color() == odf_types::color(L"ffffff")) ||
(color.get_type() == odf_types::background_color::Transparent))
{
content->get_style_paragraph_properties()->content_.fo_background_color_ = boost::none;
}
}
}
get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this);
get_styles_context().end_process_style();
}
_Wostream << L"</w:pPrDefault>";
}
if (odf_reader::style_instance * defaultParStyle = styles.style_default_by_type(odf_types::style_family::Text))
{
_Wostream << L"<w:rPrDefault>";
if ( odf_reader::style_content * content = defaultParStyle->content())
{
get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this);
get_styles_context().end_process_style();
}
_Wostream << L"</w:rPrDefault>";
}
_Wostream << L"</w:docDefaults>";
for (size_t i = 0; i < arStyles.size(); i++)
@ -1100,7 +1094,7 @@ void docx_conversion_context::process_styles()
if (odf_reader::style_content * content = arStyles[i]->content())
{
get_tabs_context().clear();
odf_reader::calc_tab_stops(arStyles[i].get(), get_tabs_context());
calc_tab_stops(arStyles[i].get(), get_tabs_context());
get_styles_context().start_process_style(arStyles[i].get());
content->docx_convert(*this, true);
@ -1352,22 +1346,22 @@ bool docx_conversion_context::in_automatic_style()
void docx_conversion_context::push_text_properties(const odf_reader::style_text_properties * TextProperties)
{
text_properties_stack_.push_back(TextProperties);
state_.text_properties_stack_.push_back(TextProperties);
}
void docx_conversion_context::pop_text_properties()
{
text_properties_stack_.pop_back();
state_.text_properties_stack_.pop_back();
}
odf_reader::style_text_properties_ptr docx_conversion_context::current_text_properties()
{
odf_reader::style_text_properties_ptr cur = boost::make_shared<odf_reader::style_text_properties>();
for (size_t i = 0; i < text_properties_stack_.size(); i++)
for (size_t i = 0; i < state_.text_properties_stack_.size(); i++)
{
if (text_properties_stack_[i])
cur->content().apply_from( text_properties_stack_[i]->content() );
if (state_.text_properties_stack_[i])
cur->content().apply_from( state_.text_properties_stack_[i]->content() );
}
return cur;
}
@ -1575,7 +1569,7 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
start_automatic_style(id);
odf_reader::calc_tab_stops(styleInst, get_tabs_context());
calc_tab_stops(styleInst, get_tabs_context());
//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
@ -1767,6 +1761,11 @@ void docx_conversion_context::serialize_list_properties(std::wostream & strm)
}
}
void docx_conversion_context::set_drawing_text_props (const std::wstring &props)
{
get_styles_context().text_style_ext() = props;
}
void docx_conversion_context::add_delayed_element(odf_reader::office_element * Elm)
{
delayed_elements_.push_back(Elm);
@ -1942,7 +1941,7 @@ void docx_conversion_context::start_text_changes (const std::wstring &id)
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state_add));
if (in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
if (state_.in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
{
map_changes_iterator it = map_current_changes_.find(id);
text_tracked_context::_state &state = it->second;
@ -2114,7 +2113,7 @@ void docx_conversion_context::end_text_changes (const std::wstring &id)
if (state.active)
{
if (in_paragraph_)
if (state_.in_paragraph_)
finish_run();
if (state.type == 1) output_stream() << L"</w:ins>";

View File

@ -572,47 +572,6 @@ private:
std::map<std::wstring, _state> mapChanges_;
};
class text_forms_context
{
public:
struct _state
{
std::wstring id;
std::wstring name;
int type = 0; //enum?
std::wstring label;
std::wstring uuid;
std::wstring value;
odf_reader::form_element* element = NULL;
void clear()
{
type = 0;
id.clear();
name.clear();
label.clear();
value.clear();
uuid.clear();
element = NULL;
}
};
text_forms_context(){}
void start_element (int type);
void set_id (const std::wstring& id);
void set_name (const std::wstring& name);
void set_label (const std::wstring& label);
void set_uuid (const std::wstring& uuid);
void set_value (const std::wstring& value);
void set_element(odf_reader::form_element *elm);
void end_element ();
_state& get_state_element (std::wstring id);
private:
_state current_state_;
std::map<std::wstring, _state> mapElements_;
};
class table_content_context
{
public:
@ -797,9 +756,7 @@ public:
void add_element_to_run (std::wstring parenStyleId = _T(""));
void finish_run ();
void add_new_run (std::wstring parentStyleId = _T(""));
bool get_run_state () { return in_run_; }
void set_run_state (bool Val) { in_run_ = Val; }
void add_new_run (std::wstring parentStyleId = _T(""));
void start_paragraph (bool is_header = false);
void finish_paragraph ();
@ -807,10 +764,18 @@ public:
bool is_alphabetical_index () { return false == mapAlphabeticals.empty();}
bool is_table_content () { return in_table_content_; }
bool is_paragraph_header () { return in_header_; }
bool get_paragraph_state () { return in_paragraph_; }
void set_paragraph_state (bool val) { in_paragraph_ = val; }
bool get_paragraph_keep () { return is_paragraph_keep_;}
void set_paragraph_keep (bool val) { is_paragraph_keep_ = val; }
void reset_context_state();
void back_context_state();
bool get_run_state () { return state_.in_run_; }
void set_run_state (bool Val) { state_.in_run_ = Val; }
bool get_paragraph_state () { return state_.in_paragraph_; }
void set_paragraph_state (bool val) { state_.in_paragraph_ = val; }
bool get_paragraph_keep () { return state_.is_paragraph_keep_;}
void set_paragraph_keep (bool val) { state_.is_paragraph_keep_ = val; }
bool get_delete_text_state () { return is_delete_text_; }
void set_delete_text_state (bool Val) { is_delete_text_ = Val; }
@ -930,11 +895,13 @@ public:
section_context & get_section_context() { return section_context_; }
notes_context & get_notes_context() { return notes_context_; }
text_tracked_context& get_text_tracked_context(){ return text_tracked_context_; }
text_forms_context & get_forms_context() { return text_forms_context_; }
forms_context & get_forms_context() { return forms_context_; }
tabs_context & get_tabs_context() { return tabs_context_;}
table_content_context & get_table_content_context() { return table_content_context_;}
void set_drawing_text_props (const std::wstring &props);
void docx_convert_delayed ();
void add_delayed_element (odf_reader::office_element * Elm);
@ -975,10 +942,10 @@ public:
void add_alphabetical_index_text (odf_reader::office_element_ptr & elem);
void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; }
headers_footers & get_headers_footers() { return headers_footers_; }
headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; }
drop_cap_context & get_drop_cap_context(){return drop_cap_context_;}
drop_cap_context & get_drop_cap_context() {return drop_cap_context_;}
styles_map styles_map_;
bool process_headers_footers_;
@ -990,6 +957,19 @@ public:
void add_jsaProject(const std::string &content);
private:
struct _context_state
{
bool in_paragraph_ = false;
bool in_run_ = false;
bool is_paragraph_keep_ = false;
std::wstring drawing_text_props_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
}state_;
std::vector<_context_state> keep_state_;
std::wstringstream document_xml_;
std::wstringstream styles_xml_;
std::wstringstream fontTable_xml_;
@ -1012,7 +992,7 @@ private:
header_footer_context header_footer_context_;
notes_context notes_context_;
text_tracked_context text_tracked_context_;
text_forms_context text_forms_context_;
forms_context forms_context_;
tabs_context tabs_context_;
table_content_context table_content_context_;
@ -1045,12 +1025,10 @@ private:
bool in_automatic_style_;
bool in_drawing_content_;
bool in_table_content_;
bool in_paragraph_;
bool in_run_;
bool in_header_;
bool is_delete_text_;
bool is_rtl_; // right-to-left
bool is_paragraph_keep_;
std::wstring current_alphabetic_index_;
int current_margin_left_;
@ -1059,7 +1037,6 @@ private:
std::vector<odf_reader::office_element*> delayed_elements_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций

View File

@ -231,7 +231,7 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(),val.additional);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
}
}

View File

@ -243,7 +243,7 @@ void customXml_files::write(const std::wstring & RootPath)
const std::wstring fileNameItem = std::wstring(L"item") + std::to_wstring(i+1) + L".xml";
const std::wstring fileNameProps = std::wstring(L"itemProps") + std::to_wstring(i+1) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/customXml/") + fileNameProps,
L"application/vnd.openxmlformats-officedocument.customXmlProperties+xml");
@ -280,7 +280,7 @@ void docx_charts_files::write(const std::wstring & RootPath)
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(count) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/word/charts/") + fileName, kWSConType);
package::simple_element(fileName, charts_[i]->str()).write(path);

View File

@ -101,6 +101,10 @@ std::wstring static get_default_file_name(RelsType type)
return L"video";
case typeAudio:
return L"audio";
case typeControl:
return L"control";
case typeControlProps:
return L"controlProps";
default:
return L"";
}
@ -180,6 +184,10 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
sub_path = L"embeddings/";
}
else if ( type == typeControlProps)
{
sub_path = L"ctrlProps/";
}
else
{
isMediaInternal = is_internal(href, odf_packet_);
@ -198,6 +206,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
else if ( type == typeSlide) number = count_slide + 1;
else if ( type == typeMsObject ||
type == typeOleObject) number = count_object + 1;
else if ( type == typeControl) number = count_control + 1;
else
number = items_.size() + 1;
@ -277,7 +286,19 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
isInternal = isMediaInternal;
return id;
}
std::wstring mediaitems::add_control_props(std::wstring & oox_target)
{
const bool isMediaInternal = true;
count_control++;
std::wstring rId = std::wstring(L"ctrlId") + std::to_wstring(count_control);
oox_target = std::wstring(L"ctrlProp") + std::to_wstring(count_control) + L".xml";
items_.push_back( item(L"", typeControlProps, oox_target, isMediaInternal, rId) );
return rId;
}
void mediaitems::dump_rels(rels & Rels)
{
for (size_t i = 0; i < items_.size(); i++)

View File

@ -52,6 +52,8 @@ public:
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
}
struct item
@ -82,10 +84,14 @@ public:
size_t count_shape;
size_t count_tables;
size_t count_object;
size_t count_activeX;
size_t count_control;
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
std::wstring add_control_props (std::wstring & oox_target);
void dump_rels(rels & Rels);
items_array & items() { return items_; }
@ -102,6 +108,9 @@ public:
case typeAudio: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio";
case typeVideo: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video";
case typeSlide: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
case typeExternalLink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";
case typeActiveX: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/control";
case typeControlProps: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp";
default:
return L"";
}

View File

@ -171,7 +171,7 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
if (content_.dimension_ == L"y")
CP_XML_ATTR(L"val",L"l");// "b" | "l" | "r" | "t"// == bottom left right top
}
//oox_serialize_ln(_Wostream,content_.graphic_properties_);
//oox_serialize_ln(_Wostream, content_.graphic_properties_);
odf_reader::GetProperty(content_.properties_, L"num_format", strVal);
odf_reader::GetProperty(content_.properties_, L"link-data-style-to-source", boolVal);

View File

@ -318,7 +318,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
}
}
}
else if (values_[i].strRef_.present > 0 && !bLocalTable_)
else if (values_[i].strRef_.present && !bLocalTable_)
{
CP_XML_NODE(L"c:strRef")
{

View File

@ -42,7 +42,56 @@
#include "../odf/style_paragraph_properties.h"
namespace cpdoccore {
namespace oox
{
void forms_context::start_element (int type)
{
current_state_.clear();
current_state_.type = type;
}
void forms_context::set_id (const std::wstring& id)
{
current_state_.id = id;
}
void forms_context::set_name (const std::wstring& name)
{
current_state_.name = name;
}
void forms_context::set_label (const std::wstring& label)
{
current_state_.label = label;
}
void forms_context::set_uuid (const std::wstring& uuid)
{
current_state_.uuid = uuid;
}
void forms_context::set_value (const std::wstring &value)
{
current_state_.value = value;
}
void forms_context::set_element(odf_reader::form_element *elm)
{
current_state_.element = elm;
}
void forms_context::end_element ()
{
mapElements_.insert( std::make_pair(current_state_.id, current_state_));
current_state_.clear();
}
forms_context::_state& forms_context::get_state_element (std::wstring id)
{
std::map<std::wstring, _state>::iterator it = mapElements_.find(id);
if (it != mapElements_.end())
{
return it->second;
}
else
return current_state_; //empty
}
//----------------------------------------------------------------------------------------------------------------
void tabs_context::reset()
{
for (size_t i = 0; i < tabs.size(); i++)
@ -149,7 +198,9 @@ std::wstringstream & styles_context::list_style()
void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId, std::wstring & strChange)
{
if (!text_style_.str().empty())
const std::wstring & text_style_str = text_style_.str();
if (!text_style_str.empty() || !text_style_ext_.empty())
{
CP_XML_WRITER(strm)
{
@ -159,14 +210,17 @@ void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstrin
{
CP_XML_STREAM() << L"<w:rStyle w:val=\"" << parenStyleId << L"\" />";
}
const std::wstring & test_str = text_style_.str();
CP_XML_STREAM() << test_str;
CP_XML_STREAM() << text_style_str;
if (!strChange.empty())//rPrChange
{
CP_XML_STREAM() << strChange;
strChange.clear();
}
if (!text_style_ext_.empty())
{
CP_XML_STREAM() << text_style_ext_;
}
}
}
}
@ -190,8 +244,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
}
}
}
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :
base_font_size_(12), fonts_container_(fonts), is_need_e_(false)
{

View File

@ -56,9 +56,55 @@ namespace odf_reader
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
class office_element;
class form_element;
typedef boost::shared_ptr<office_element> office_element_ptr;
};
namespace oox {
class forms_context
{
public:
struct _state
{
std::wstring id;
std::wstring name;
int type = 0; //enum?
std::wstring label;
std::wstring uuid;
std::wstring value;
odf_reader::form_element* element = NULL;
std::wstring ctrlPropId;
void clear()
{
type = 0;
id.clear();
name.clear();
label.clear();
value.clear();
uuid.clear();
ctrlPropId.clear();
element = NULL;
}
};
forms_context(){}
void start_element (int type);
void set_id (const std::wstring& id);
void set_name (const std::wstring& name);
void set_label (const std::wstring& label);
void set_uuid (const std::wstring& uuid);
void set_value (const std::wstring& value);
void set_element(odf_reader::form_element *elm);
void end_element ();
_state& get_state_element (std::wstring id);
private:
_state current_state_;
std::map<std::wstring, _state> mapElements_;
};
class tabs_context : boost::noncopyable
{
public:
@ -95,6 +141,7 @@ public:
std::wstring & extern_node(){return extern_node_;}
std::wstring & hlinkClick(){return hlinkClick_;}
std::wstring & text_style_ext(){return text_style_ext_;}
const odf_reader::style_instance * get_current_processed_style() const { return current_processed_style_; }
@ -106,6 +153,7 @@ private:
std::wstring extern_node_;
std::wstring hlinkClick_;
std::wstring text_style_ext_;
std::wstringstream list_style_;
std::wstringstream text_style_;
@ -115,7 +163,6 @@ private:
};
namespace oox {
class math_context : boost::noncopyable
{

View File

@ -124,8 +124,14 @@ static const std::wstring _ooxDashStyle[]=
L"sysDashDotDot"
};
void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop, bool always_draw)
void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop, bool always_draw, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
std::wstring ns_node = L"a:ln";
if (ns == L"w14")
ns_node = L"w14:textOutline";
_CP_OPT(std::wstring) strStrokeColor;
_CP_OPT(int) iStroke;
_CP_OPT(double) dStrokeWidth;
@ -143,30 +149,30 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:ln")
CP_XML_NODE(ns_node)
{
std::wstring color, dash_style, fill = L"a:solidFill" ;
std::wstring color, dash_style, fill = ns + L":solidFill" ;
if (strStrokeColor) color = *strStrokeColor;
if (iStroke)
{
if (iStroke.get() == 0 || bWordArt) fill = L"a:noFill";
if (iStroke.get() == 0 || bWordArt) fill = ns + L":noFill";
else dash_style = _ooxDashStyle[iStroke.get()];
}
if ((dStrokeWidth) && (*dStrokeWidth >= 0) && fill != L"a:noFill")
if ((dStrokeWidth) && (*dStrokeWidth >= 0) && fill != ns + L":noFill")
{
int val = dStrokeWidth.get() * 12700; //in emu (1 pt = 12700)
if (val < 10) val = 12700;
CP_XML_ATTR(L"w", val);
CP_XML_ATTR2(ns_att + L"w", val);
if (color.length()<1)color = L"729FCF";
}
CP_XML_NODE(fill)
{
if (fill != L"a:noFill")
if (fill != ns + L":noFill")
{
if ( color.empty() )
{
@ -174,47 +180,49 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
else color = L"FFFFFF";
}
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val",color);
CP_XML_ATTR2(ns_att + L"val",color);
if (dStrokeOpacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", (int)(*dStrokeOpacity * 1000));
CP_XML_ATTR2(ns_att + L"val", (int)(*dStrokeOpacity * 1000));
}
}
}
}
}
if (fill != L"a:noFill")
if (fill != ns + L":noFill")
{
_CP_OPT(std::wstring) strVal;
if (dash_style.length() > 0 && dash_style != L"solid")
{
CP_XML_NODE(L"a:prstDash"){CP_XML_ATTR(L"val", dash_style);}
CP_XML_NODE(ns + L":prstDash"){CP_XML_ATTR2(ns_att + L"val", dash_style);}
}
odf_reader::GetProperty(prop,L"marker-start", strVal);
if (strVal)
{
CP_XML_NODE(L"a:headEnd"){CP_XML_ATTR(L"type", strVal.get());}
CP_XML_NODE(ns + L":headEnd"){CP_XML_ATTR2(ns_att + L"type", strVal.get());}
}
odf_reader::GetProperty(prop,L"marker-end",strVal);
if (strVal)
{
CP_XML_NODE(L"a:tailEnd"){CP_XML_ATTR(L"type",strVal.get());}
CP_XML_NODE(ns + L":tailEnd"){CP_XML_ATTR2(ns_att + L"type",strVal.get());}
}
}
}
}
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset)
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:avLst")
CP_XML_NODE(ns + L":avLst")
{
_CP_OPT(std::wstring) strModifiers;
odf_reader::GetProperty(prop, L"oox-draw-modifiers", strModifiers);
@ -268,20 +276,20 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
{
if (values[i].empty()) continue;
CP_XML_NODE(L"a:gd")
CP_XML_NODE(ns + L":gd")
{
if (names.size() > i)
{
CP_XML_ATTR(L"name", names[i]);
CP_XML_ATTR2(ns_att + L"name", names[i]);
}
else
{
if (values.size() > 1)
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i + 1));
CP_XML_ATTR2(ns_att + L"name", L"adj" + std::to_wstring(i + 1));
else
CP_XML_ATTR(L"name", L"adj");
CP_XML_ATTR2(ns_att + L"name", L"adj");
}
CP_XML_ATTR(L"fmla", L"val " + values[i]);
CP_XML_ATTR2(ns_att + L"fmla", L"val " + values[i]);
}
}
}

View File

@ -118,8 +118,8 @@ namespace oox {
};
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset);
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false, const std::wstring &ns = L"a");
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset, const std::wstring &ns = L"a");
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
}

View File

@ -53,55 +53,59 @@ namespace oox {
//////////////////////////////////////////////////////////////////////////////////////////////////////
void oox_serialize_none_fill(std::wostream & strm)
void oox_serialize_none_fill(std::wostream & strm, const std::wstring &ns)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:noFill");
CP_XML_NODE(ns + L":noFill");
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(double) opacity)
void oox_serialize_srgb(std::wostream & strm, const std::wstring &color,_CP_OPT(double) opacity, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val", color);
CP_XML_ATTR2(ns_att + L"val", color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
CP_XML_ATTR2(ns_att + L"val", std::to_wstring((int)(*opacity)*1000));// + L"%");
}
}
}
}
}
void oox_serialize_srgb(std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity)
void oox_serialize_srgb(std::wostream & strm, const std::wstring &color, _CP_OPT(odf_types::percent) opacity, const std::wstring &ns)
{
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:srgbClr")
CP_XML_NODE(ns + L":srgbClr")
{
CP_XML_ATTR(L"val",color);
CP_XML_ATTR2(ns_att + L"val",color);
if (opacity)
{
CP_XML_NODE(L"a:alpha")
CP_XML_NODE(ns + L":alpha")
{
CP_XML_ATTR(L"val", std::to_wstring((int)opacity->get_value()*1000));// + L"%");
CP_XML_ATTR2(ns_att + L"val", std::to_wstring((int)opacity->get_value() * 1000));// + L"%");
}
}
}
}
}
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_solid_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.solid)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:solidFill")
CP_XML_NODE(ns + L":solidFill")
{
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity);
oox_serialize_srgb(CP_XML_STREAM(), val.solid->color, val.opacity, ns);
}
}
@ -151,20 +155,25 @@ void vml_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.bitmap) return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(std::wstring(val.bitmap->name_space + L":blipFill"))
{
//if (val.bitmap->rotate) CP_XML_ATTR(L"a:rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(L"a:rotWithShape",1);
//if (val.bitmap->rotate) CP_XML_ATTR(ns + L":rotWithShape",*(val.bitmap->rotate));
//else CP_XML_ATTR(ns + L":rotWithShape",1);
if (val.bitmap->dpi) CP_XML_ATTR(L"a:dpi", *val.bitmap->dpi);
if (val.bitmap->dpi)
{
CP_XML_ATTR2(ns + L":dpi", *val.bitmap->dpi);
}
CP_XML_NODE(L"a:blip")
CP_XML_NODE(ns + L":blip")
{
if (val.bitmap->isInternal)
{
@ -176,38 +185,38 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
if (val.opacity)
{
CP_XML_NODE(L"a:alphaModFix")
CP_XML_NODE(ns + L":alphaModFix")
{
CP_XML_ATTR(L"amt",(int)(*val.opacity * 1000));
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
}
}
}
if (val.bitmap->bCrop)
{
CP_XML_NODE(L"a:srcRect")
CP_XML_NODE(ns + L":srcRect")
{
CP_XML_ATTR(L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR(L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR(L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR(L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
CP_XML_ATTR2(ns_att + L"l", static_cast<int>(val.bitmap->cropRect[0]*1000));
CP_XML_ATTR2(ns_att + L"t", static_cast<int>(val.bitmap->cropRect[1]*1000));
CP_XML_ATTR2(ns_att + L"r", static_cast<int>(val.bitmap->cropRect[2]*1000));
CP_XML_ATTR2(ns_att + L"b", static_cast<int>(val.bitmap->cropRect[3]*1000));
}
}
if (val.bitmap->bTile)
{
CP_XML_NODE(L"a:tile")
CP_XML_NODE(ns + L":tile")
{
//tx="0" ty="0" sx="100000" sy="100000"
CP_XML_ATTR(L"flip", "none");
CP_XML_ATTR(L"algn", L"ctr");
CP_XML_ATTR2(ns_att + L"flip", "none");
CP_XML_ATTR2(ns_att + L"algn", L"ctr");
}
}
else if (val.bitmap->bStretch)
{
CP_XML_NODE(L"a:stretch")
CP_XML_NODE(ns + L":stretch")
{
if (!val.bitmap->bCrop)
{
CP_XML_NODE(L"a:fillRect");
CP_XML_NODE(ns + L":fillRect");
}
}
}
@ -269,25 +278,27 @@ void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
}
}
}
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.gradient) return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:gradFill")
CP_XML_NODE(ns + L":gradFill")
{
if (val.gradient->colors.size()>0)
{
CP_XML_NODE(L"a:gsLst")
CP_XML_NODE(ns + L":gsLst")
{
for (int i = 0; i < val.gradient->colors.size(); i++)
{
oox_gradient_fill::_color_position & col = val.gradient->colors[i];
CP_XML_NODE(L"a:gs")
CP_XML_NODE(ns + L":gs")
{
CP_XML_ATTR(L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity);
CP_XML_ATTR2(ns_att + L"pos", (int)(col.pos * 1000));//%
oox_serialize_srgb(CP_XML_STREAM(), col.color_ref, col.opacity, ns);
}
}
}
@ -298,25 +309,25 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
switch(val.gradient->style)
{
case 0:
CP_XML_NODE(L"a:lin")
CP_XML_NODE(ns + L":lin")
{
CP_XML_ATTR(L"ang",(int)angle);//gr in rad
CP_XML_ATTR2(ns_att + L"ang",(int)angle);//gr in rad
}break;
case 1:
case 2:
case 3:
CP_XML_NODE(L"a:path")
CP_XML_NODE(ns + L":path")
{
if (val.gradient->style == 1) CP_XML_ATTR(L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR(L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR(L"path", L"shape");
if (val.gradient->style == 1) CP_XML_ATTR2(ns_att + L"path", L"rect");
if (val.gradient->style == 2) CP_XML_ATTR2(ns_att + L"path", L"circle");
if (val.gradient->style == 3) CP_XML_ATTR2(ns_att + L"path", L"shape");
CP_XML_NODE(L"a:fillToRect")
CP_XML_NODE(ns + L":fillToRect")
{
CP_XML_ATTR(L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR(L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR(L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR(L"b", (int)(val.gradient->rect[3] * 1000));
CP_XML_ATTR2(ns_att + L"l", (int)(val.gradient->rect[0] * 1000));
CP_XML_ATTR2(ns_att + L"t", (int)(val.gradient->rect[1] * 1000));
CP_XML_ATTR2(ns_att + L"r", (int)(val.gradient->rect[2] * 1000));
CP_XML_ATTR2(ns_att + L"b", (int)(val.gradient->rect[3] * 1000));
}
}break;
}
@ -324,22 +335,24 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
//tileRect (Tile Rectangle) §20.1.8.59
}
}
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val)
void oox_serialize_hatch_fill(std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
if (!val.hatch)return;
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pattFill")
CP_XML_NODE(ns + L":pattFill")
{
CP_XML_ATTR(L"prst",val.hatch->preset);
CP_XML_NODE(L"a:fgClr")//опять для ms важно что этот цвет перед back
CP_XML_ATTR2(ns_att + L"prst", val.hatch->preset);
CP_XML_NODE(ns + L":fgClr")//опять для ms важно что этот цвет перед back
{
oox_serialize_srgb(CP_XML_STREAM(), val.hatch->color_ref, val.opacity);
}
if (val.hatch->color_back_ref)
{
CP_XML_NODE(L"a:bgClr")
CP_XML_NODE(ns + L":bgClr")
{
oox_serialize_srgb(CP_XML_STREAM(), *val.hatch->color_back_ref ,val.opacity);
}
@ -379,23 +392,23 @@ void vml_serialize_background (std::wostream & strm, const _oox_fill & val, cons
}
}
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val)
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
{
switch (val.type)
{
case 0:
oox_serialize_none_fill(strm);
oox_serialize_none_fill(strm, ns);
break;
case 1:
oox_serialize_solid_fill(strm, val);
oox_serialize_solid_fill(strm, val, ns);
break;
case 2:
oox_serialize_bitmap_fill(strm, val);
oox_serialize_bitmap_fill(strm, val, ns);
break;
case 3:
oox_serialize_gradient_fill(strm, val);
oox_serialize_gradient_fill(strm, val, ns);
break;
case 4: oox_serialize_hatch_fill(strm, val);
case 4: oox_serialize_hatch_fill(strm, val, ns);
break;
}
}

View File

@ -143,10 +143,12 @@ namespace oox {
}
};
void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring & color, int id);
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(double) opacity);
void oox_serialize_srgb (std::wostream & strm,std::wstring color,_CP_OPT(odf_types::percent) opacity);
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val);
void vml_serialize_background (std::wostream & strm, const _oox_fill & val, const std::wstring &color, int id);
void oox_serialize_srgb (std::wostream & strm, const std::wstring &color, _CP_OPT(double) opacity, const std::wstring &ns = L"a");
void oox_serialize_srgb (std::wostream & strm, const std::wstring &color, _CP_OPT(odf_types::percent) opacity, const std::wstring &ns = L"a");
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
}
}

View File

@ -123,7 +123,7 @@ void content_types_file::write(const std::wstring & RootPath)
elm.write(RootPath);
}
content_type_content * content_types_file::content()
content_type * content_types_file::content()
{
return &content_type_content_;
}
@ -132,7 +132,7 @@ bool content_types_file::add_or_find_default(const std::wstring & extension)
{
std::vector<default_content_type> & defaults = content_type_content_.get_default();
for (int i = 0 ; i < defaults.size(); i++)
for (size_t i = 0 ; i < defaults.size(); i++)
{
if (defaults[i].extension() == extension)
return true;
@ -279,11 +279,11 @@ _CP_PTR(customXml_content) customXml_content::create(const std::wstring &item, c
return boost::make_shared<customXml_content>(item, props);
}
//-----------------------------------------------------------------------------------------------
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
simple_element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
{
return boost::make_shared<simple_element>(FileName, Content);
}
element_ptr simple_element::create(const std::wstring & FileName, const std::string & Content)
simple_element_ptr simple_element::create(const std::wstring & FileName, const std::string & Content)
{
return boost::make_shared<simple_element>(FileName, Content);
}

View File

@ -86,23 +86,27 @@ public:
bool add_or_find_default (const std::wstring & extension);
bool add_or_find_override(const std::wstring & fileName);
void set_media (mediaitems & _Mediaitems);
content_type_content * content ();
content_type * content ();
private:
content_type_content content_type_content_;
content_type content_type_content_;
std::wstring filename_;
};
class simple_element;
typedef boost::shared_ptr<simple_element> simple_element_ptr;
class simple_element : public element
{
public:
simple_element(const std::wstring & FileName, const std::wstring & Content);
static element_ptr create(const std::wstring & FileName, const std::wstring & Content);
static simple_element_ptr create(const std::wstring & FileName, const std::wstring & Content);
simple_element(const std::wstring & FileName, const std::string & Content);
static element_ptr create(const std::wstring & FileName, const std::string & Content);
static simple_element_ptr create(const std::wstring & FileName, const std::string & Content);
virtual void write(const std::wstring & RootPath);
std::wstring get_filename() {return file_name_;}
private:
std::wstring file_name_;
@ -111,7 +115,6 @@ private:
bool bXml;
};
//------------------------------------------------------------------------
class rels_file;
typedef boost::shared_ptr<rels_file> rels_file_ptr;

View File

@ -56,7 +56,10 @@ enum RelsType
typeSlide,
typeVideo,
typeAudio,
typeControl
typeExternalLink,
typeActiveX,
typeControl,
typeControlProps
};
struct _rel

View File

@ -274,7 +274,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{
@ -311,7 +311,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{
@ -352,7 +352,7 @@ void pptx_serialize_object(std::wostream & strm, _pptx_drawing & val)
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{

View File

@ -55,7 +55,7 @@ public:
pptx_drawings_.push_back(d);
bool present = false;
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
for (size_t i = 0; i < pptx_drawing_rels_.size(); i++)
{
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
present = true;
@ -83,7 +83,7 @@ public:
{
bool present = false;
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
for (size_t i = 0; i < pptx_drawing_rels_.size(); i++)
{
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
present = true;
@ -96,7 +96,7 @@ public:
}
void serialize(std::wostream & strm)
{
for (int i = 0; i < pptx_drawings_.size(); i++)
for (size_t i = 0; i < pptx_drawings_.size(); i++)
{
pptx_drawings_[i].serialize(strm);
}
@ -109,7 +109,7 @@ public:
void dump_rels(rels & Rels)
{
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
for (size_t i = 0; i < pptx_drawing_rels_.size(); i++)
{
if (pptx_drawing_rels_[i].type == typeUnknown ||
pptx_drawing_rels_[i].type == typeTable ||

View File

@ -352,7 +352,7 @@ std::pair<int,int> pptx_xml_authors_comments::add_or_find(std::wstring author)
int last_id=0;
bool find = false;
for (long i=0;i<list_.size();i++)
for (size_t i=0;i<list_.size();i++)
{
if (author == list_[i].name)
{

View File

@ -121,10 +121,10 @@ void slides_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slides" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -156,10 +156,10 @@ void notes_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"notesSlides" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -199,10 +199,10 @@ void slideMasters_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideMasters" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -233,10 +233,10 @@ void notesMaster_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"notesMasters" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
@ -275,14 +275,14 @@ void slideLayouts_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideLayouts" ;
NSDirectory::CreateDirectory(path.c_str());
for (int i = 0; i < slides_.size(); i++)
for (size_t i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slideLayout") + std::to_wstring( i + 1 ) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/slideLayouts/") + fileName, kWSConType);
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
@ -327,12 +327,12 @@ void ppt_charts_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
NSDirectory::CreateDirectory(path.c_str());
for (int i = 0; i < charts_.size(); i++)
for (size_t i = 0; i < charts_.size(); i++)
{
if (!charts_[i]) continue;
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring( i + 1 ) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
@ -357,14 +357,14 @@ void ppt_themes_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme" ;
NSDirectory::CreateDirectory(path.c_str());
for (int i = 0; i < themes_.size(); i++)
for (size_t i = 0; i < themes_.size(); i++)
{
if (!themes_[i]) continue;
const std::wstring fileName = std::wstring(L"theme") + std::to_wstring( i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
std::wstringstream content;
@ -383,9 +383,9 @@ void ppt_comments_files::write(const std::wstring & RootPath)
std::wstring comm_path = RootPath + FILE_SEPARATOR_STR + L"comments";
NSDirectory::CreateDirectory(comm_path.c_str());
for (int i = 0; i < comments_.size(); i++)
for (size_t i = 0; i < comments_.size(); i++)
{
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
content_type * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
contentTypes->add_override(std::wstring(L"/ppt/comments/") + comments_[i].filename, kWSConType);

View File

@ -282,7 +282,7 @@ void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_p
odf_reader::text_list_style * text_list_style = odf_context_.listStyleContainer().list_style_by_name(list_style_stack_.back());
if ((text_list_style) && (Level < text_list_style->get_content().size()))
if ((text_list_style) && (Level < (int)text_list_style->get_content().size()))
{
odf_reader::office_element_ptr elm = text_list_style->get_content()[Level];
odf_reader::office_element_ptr elm_list;

View File

@ -252,7 +252,7 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:cNvGraphicFramePr");
}
val.serialize_xfrm(CP_XML_STREAM(), L"xdr");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
//oox_serialize_ln(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:graphic")
{
@ -289,7 +289,8 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
xlsx_serialize_group(strm, val);
}
else if (val.type == typeOleObject ||
val.type == typeMsObject )
val.type == typeMsObject ||
val.type == typeControl)
{
xlsx_serialize_object(strm, val);
}
@ -371,5 +372,37 @@ void _xlsx_drawing::serialize_object (std::wostream & strm)
}
void _xlsx_drawing::serialize_control (std::wostream & strm)
{
if (type != typeControl) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"control")
{
CP_XML_ATTR(L"r:id", objectId);
CP_XML_ATTR(L"shapeId", id);
//CP_XML_ATTR(L"name", objectProgId);
CP_XML_NODE(L"controlPr")
{
CP_XML_ATTR(L"defaultSize", 0);
if (fill.bitmap)
{
CP_XML_ATTR(L"r:id", fill.bitmap->rId);
}
CP_XML_NODE(L"anchor")
{
CP_XML_ATTR(L"moveWithCells", 1);
from_.serialize (CP_XML_STREAM(), L"");
to_.serialize (CP_XML_STREAM(), L"");
}
}
}
}
}
}
}

View File

@ -66,7 +66,8 @@ public:
std::wstring content_group_;
void serialize (std::wostream & strm);
void serialize_object (std::wostream & strm);
void serialize_object (std::wostream & strm);
void serialize_control (std::wostream & strm);
};
}
}

View File

@ -297,6 +297,11 @@ void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::w
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void xlsx_drawing_context::set_control(const std::wstring & ctrlPropId)
{
impl_->object_description_.type_ = typeControl;
impl_->object_description_.xlink_href_ = ctrlPropId;
}
void xlsx_drawing_context::set_image(const std::wstring & path)
{
int pos_replaicement = path.find(L"ObjectReplacements");
@ -575,15 +580,14 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
}
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
bool isMediaInternal = true;
if (drawing.type_anchor == 2) // absolute
{
//пересчет нужен для оле
//пересчет нужен
xlsx_table_position from, to;
process_position_properties (obj, table_metrics, from, to);
@ -600,11 +604,19 @@ void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx
drawing.to_.position.row = to.row;
drawing.to_.position.rowOff = static_cast<size_t>(odf_types::length(to.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
}
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
if (obj.type_ == typeControl)
{
drawing.objectId = obj.xlink_href_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
}
else
{
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
}
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
@ -680,7 +692,8 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
case typeShape: process_shape ( obj, drawing, xlsx_drawings_); break;
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeMsObject:
case typeOleObject:
case typeOleObject:
case typeControl:
process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
}
}

View File

@ -95,6 +95,7 @@ public:
void set_chart (const std::wstring & path);
void set_ole_object (const std::wstring & path, const std::wstring & progId);
void set_ms_object (const std::wstring & path, const std::wstring & progId);
void set_control (const std::wstring & ctrlPropId);
void set_text_box ();
void end_frame();

View File

@ -121,7 +121,15 @@ public:
xlsx_drawings_[i].serialize_object(strm);
}
}
void serialize_controls(std::wostream & strm)
{
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
{
if (xlsx_drawings_[i].type != typeControl) continue;
xlsx_drawings_[i].serialize_control(strm);
}
}
bool empty() const
{
return (xlsx_drawings_.empty());
@ -193,6 +201,10 @@ void xlsx_drawings::serialize_objects(std::wostream & strm)
{
impl_->serialize_objects(strm);
}
void xlsx_drawings::serialize_controls(std::wostream & strm)
{
impl_->serialize_controls(strm);
}
bool xlsx_drawings::empty() const
{

View File

@ -73,6 +73,7 @@ public:
void serialize (std::wostream & _Wostream);
void serialize_objects (std::wostream & _Wostream);
void serialize_controls (std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;

View File

@ -58,6 +58,7 @@ public:
std::wstringstream dataValidations_;
std::wstringstream ole_objects_;
std::wstringstream page_props_;
std::wstringstream controls_;
rels sheet_rels_;
@ -136,6 +137,10 @@ std::wostream & xlsx_xml_worksheet::ole_objects()
{
return impl_->ole_objects_;
}
std::wostream & xlsx_xml_worksheet::controls()
{
return impl_->controls_;
}
std::wostream & xlsx_xml_worksheet::page_properties()
{
return impl_->page_props_;
@ -203,7 +208,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->drawing_.str();
if (impl_->commentsId_.length()>0)
if (!impl_->commentsId_.empty())
{
CP_XML_NODE(L"legacyDrawing")
{
@ -216,6 +221,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
if (!impl_->controls_.str().empty())
{
CP_XML_NODE(L"controls")
{
CP_XML_STREAM() << impl_->controls_.str();
}
}
CP_XML_STREAM() << impl_->picture_background_.str();

View File

@ -66,6 +66,7 @@ public:
std::wostream & sort();
std::wostream & ole_objects();
std::wostream & page_properties();
std::wostream & controls();
rels & sheet_rels(); //hyperlink, background image, external, media ...

View File

@ -148,7 +148,7 @@ void sheets_files::write(const std::wstring & RootPath)
const std::wstring fileName = std::wstring(L"sheet") + std::to_wstring(i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/xl/worksheets/") + fileName, kWSConType);
if (rels_)
@ -194,6 +194,10 @@ void xl_files::write(const std::wstring & RootPath)
sheets_files_.set_main_document( this->get_main_document() );
sheets_files_.write(path);
}
{
control_props_files_.set_main_document( this->get_main_document() );
control_props_files_.write(path);
}
int index = 1;
if (true)
{
@ -210,7 +214,7 @@ void xl_files::write(const std::wstring & RootPath)
connections_->write(path);
rels_files_.add( relationship( L"cnId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections", L"connections.xml" ) );
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
contentTypes->add_override(L"/xl/connections.xml", L"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml");
}
@ -322,6 +326,10 @@ void xl_files::add_jsaProject(const std::string &content)
{
jsaProject_ = package::simple_element::create(L"jsaProject.bin", content);
}
void xl_files::add_control_props (simple_element_ptr element)
{
control_props_files_.add_control_props(element);
}
//----------------------------------------------------------------------------------------
void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{
@ -332,7 +340,7 @@ void xl_pivot_cache_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"pivotCache";
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConTypeD = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
static const std::wstring kWSConTypeR = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
@ -384,7 +392,7 @@ void xl_pivot_table_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"pivotTables";
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
@ -425,7 +433,7 @@ void xl_charts_files::write(const std::wstring & RootPath)
{
count++;
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(i + 1) + L".xml";
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/xl/charts/") + fileName, kWSConType);
@ -440,6 +448,33 @@ void xl_charts_files::write(const std::wstring & RootPath)
relFiles.write(path);
}
}
//----------------------------------------------------------------------------------------
void xl_control_props_files::add_control_props(simple_element_ptr query_table)
{
control_props_.push_back(query_table);
}
void xl_control_props_files::write(const std::wstring & RootPath)
{
if (control_props_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"ctrlProps";
NSDirectory::CreateDirectory(path);
content_type *contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.ms-excel.controlproperties+xml";
for (size_t i = 0; i < control_props_.size(); i++)
{
if (!control_props_[i])continue;
const std::wstring fileName = control_props_[i]->get_filename();
contentTypes->add_override(std::wstring(L"/xl/ctrlProps/") + fileName, kWSConType);
control_props_[i]->write(path);
}
}
//------------------------------------------------------------------------------------------------------
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
{
@ -463,7 +498,7 @@ void xl_drawings::write(const std::wstring & RootPath)
relFiles.add_rel_file(r);
relFiles.write(path);
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
const std::wstring kDrawingCT = L"application/vnd.openxmlformats-officedocument.drawing+xml";
contentTypes->add_override(L"/xl/drawings/" + drawings_[i].filename, kDrawingCT);
@ -483,7 +518,7 @@ void xl_comments::write(const std::wstring & RootPath)
for (size_t i = 0; i < comments_.size(); i++)
{
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
contentTypes->add_override(std::wstring(L"/xl/") + comments_[i].filename, kWSConType);

View File

@ -211,13 +211,23 @@ private:
rels_files * rels_;
};
//----------------------------------------------------------------------------------------------------------
class xl_control_props_files : public element
{
public:
xl_control_props_files(){}
void add_control_props(simple_element_ptr props);
virtual void write(const std::wstring & RootPath);
std::vector<simple_element_ptr> control_props_;
};
//----------------------------------------------------------------------------------------------------------
class xl_files : public element
{
public:
xl_files();
public:
virtual void write(const std::wstring & RootPath);
void set_workbook (element_ptr Element);
@ -233,6 +243,7 @@ public:
void add_pivot_cache (pivot_cache_content_ptr cache);
void add_pivot_table (pivot_table_content_ptr table);
void add_jsaProject (const std::string &content);
void add_control_props (simple_element_ptr Element);
private:
rels_files rels_files_;
@ -240,7 +251,8 @@ private:
xl_charts_files charts_files_;
xl_pivot_cache_files pivot_cache_files_;
xl_pivot_table_files pivot_table_files_;
xl_control_props_files control_props_files_;
element_ptr theme_;
element_ptr workbook_;

View File

@ -492,6 +492,10 @@ void xlsx_table_state::serialize_ole_objects(std::wostream & strm)
{
return xlsx_drawing_context_.get_drawings()->serialize_objects(strm);
}
void xlsx_table_state::serialize_controls(std::wostream & strm)
{
return xlsx_drawing_context_.get_drawings()->serialize_controls(strm);
}
void xlsx_table_state::serialize_hyperlinks(std::wostream & strm)
{
return xlsx_hyperlinks_.xlsx_serialize(strm);

View File

@ -134,6 +134,7 @@ public:
void serialize_table_format (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_controls (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);

View File

@ -336,6 +336,10 @@ void xlsx_table_context::serialize_ole_objects(std::wostream & _Wostream)
{
return state()->serialize_ole_objects(_Wostream);
}
void xlsx_table_context::serialize_controls(std::wostream & _Wostream)
{
return state()->serialize_controls(_Wostream);
}
void xlsx_table_context::dump_rels_hyperlinks(rels & Rels)
{
return state()->dump_rels_hyperlinks(Rels);

View File

@ -89,6 +89,7 @@ public:
void serialize_conditionalFormatting(std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_controls (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_data_validation (std::wostream & _Wostream);

View File

@ -188,8 +188,10 @@ void xlsx_conversion_context::end_document()
}
}
//добавляем диаграммы
for (std::map<std::wstring, std::wstring>::iterator it = control_props_.begin(); it != control_props_.end(); ++it)
{
output_document_->get_xl_files().add_control_props( package::simple_element::create(it->first, it->second) );
}
for (size_t i = 0; i < charts_.size(); i++)
{
package::chart_content_ptr content = package::chart_content::create();
@ -444,7 +446,8 @@ void xlsx_conversion_context::end_table()
get_table_context().serialize_hyperlinks (current_sheet().hyperlinks());
get_table_context().serialize_ole_objects (current_sheet().ole_objects());
get_table_context().serialize_controls (current_sheet().controls());
get_table_context().dump_rels_hyperlinks (current_sheet().sheet_rels());
get_table_context().dump_rels_ole_objects (current_sheet().sheet_rels());
@ -499,6 +502,17 @@ void xlsx_conversion_context::end_table()
}
get_table_context().end_table();
}
void xlsx_conversion_context::add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props)
{
if (rid.empty()) return;
if (props.empty()) return;
control_props_.insert(std::make_pair(target, props));
current_sheet().sheet_rels().add(oox::relationship(rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp",
L"../ctrlProps/" + target));
}
void xlsx_conversion_context::start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax)
{

View File

@ -158,6 +158,8 @@ public:
void set_conditional_format_dataBar (_CP_OPT(int) min, _CP_OPT(int) max);
void add_jsaProject (const std::string &content);
void add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props);
//------------------------------------------------------------------------------------
odf_reader::odf_document * root()
@ -172,8 +174,9 @@ public:
xlsx_text_context & get_text_context() { return xlsx_text_context_; }
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
forms_context & get_forms_context() { return forms_context_; }
oox_chart_context & current_chart();
math_context & get_math_context() { return math_context_; }
num_format_context & get_num_format_context() { return num_format_context_; }
@ -210,16 +213,20 @@ private:
size_t default_style_;
mediaitems mediaitems_;
std::multimap<std::wstring, int> mapPivotsTableView_;
std::map<std::wstring, std::wstring>control_props_;
xlsx_style_manager xlsx_style_;
xlsx_defined_names xlsx_defined_names_;
xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_;
math_context math_context_;
xlsx_pivots_context xlsx_pivots_context_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_;
xlsx_dataValidations_context xlsx_dataValidations_context_;
math_context math_context_;
forms_context forms_context_;
};
}

View File

@ -156,7 +156,7 @@ paragraph_format_properties calc_paragraph_properties_content(const std::vector<
return result;
}
void calc_tab_stops(const style_instance * styleInstance, tabs_context & context)
void calc_tab_stops(const style_instance * styleInstance, oox::tabs_context & context)
{
std::vector<const style_paragraph_properties*> parProps;
while (styleInstance)

View File

@ -40,22 +40,26 @@
#include "odfcontext.h"
#include <vector>
namespace cpdoccore {
class tabs_context;
namespace odf_reader {
namespace cpdoccore
{
namespace oox
{
class tabs_context;
}
namespace odf_reader
{
graphic_format_properties calc_graphic_properties_content(const style_instance * styleInstance);
graphic_format_properties calc_graphic_properties_content(const std::vector<const style_instance *> & styleInstances);
graphic_format_properties calc_graphic_properties_content(const style_instance * styleInstance);
graphic_format_properties calc_graphic_properties_content(const std::vector<const style_instance *> & styleInstances);
text_format_properties_content calc_text_properties_content(const style_instance * styleInstance);
text_format_properties_content calc_text_properties_content(const std::vector<const style_instance *> & styleInstances);
text_format_properties_content calc_text_properties_content(const style_instance * styleInstance);
text_format_properties_content calc_text_properties_content(const std::vector<const style_instance *> & styleInstances);
paragraph_format_properties calc_paragraph_properties_content(const style_instance * styleInstance);
paragraph_format_properties calc_paragraph_properties_content(const std::vector<const style_instance *> & styleInstances);
paragraph_format_properties calc_paragraph_properties_content(const style_instance * styleInstance);
paragraph_format_properties calc_paragraph_properties_content(const std::vector<const style_instance *> & styleInstances);
style_table_cell_properties_attlist calc_table_cell_properties(const style_instance * styleInstance);
style_table_cell_properties_attlist calc_table_cell_properties(const std::vector<const style_instance *> & styleInstances);
style_table_cell_properties_attlist calc_table_cell_properties(const style_instance * styleInstance);
style_table_cell_properties_attlist calc_table_cell_properties(const std::vector<const style_instance *> & styleInstances);
void calc_tab_stops(const style_instance * styleInstance, tabs_context & context);
}
void calc_tab_stops(const style_instance * styleInstance, oox::tabs_context & context);
}
}

View File

@ -232,11 +232,7 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_frame());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool pState = Context.get_paragraph_state ();
bool runState = Context.get_run_state ();
Context.set_paragraph_state (false);
Context.set_run_state (false);
Context.reset_context_state();
Context.get_math_context().base_font_size_ = baseFontHeight_;
@ -246,9 +242,9 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
Context.set_stream_man (prev);
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_stream_man(prev);
Context.back_context_state();
}
else if(object_type_ == 4 && office_spreadsheet_)
{

View File

@ -284,7 +284,7 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr
point.pos = 0;
if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value();
if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
//if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
fill->colors.push_back(point);
@ -300,7 +300,7 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr
point.pos = 0;
if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
//if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);
@ -312,7 +312,7 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr
point.pos = 100;
if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
//if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);
}break;
@ -328,13 +328,13 @@ void Compute_GradientFill(draw_gradient * image_style,oox::oox_gradient_fill_ptr
point.pos = 0;
if (image_style->draw_start_color_) point.color_ref = image_style->draw_start_color_->get_hex_value();
if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
//if (image_style->draw_start_intensity_) point.opacity = image_style->draw_start_intensity_->get_value();
fill->colors.push_back(point);
point.pos = 100;
if (image_style->draw_end_color_) point.color_ref = image_style->draw_end_color_->get_hex_value();
if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
//if (image_style->draw_end_intensity_) point.opacity = image_style->draw_end_intensity_->get_value();
fill->colors.push_back(point);

View File

@ -312,7 +312,7 @@ std::wstring draw_object_ole::detectObject(const std::wstring &fileName)
//skip the CompObjHeader
pStream->seek(28);
int sz_obj = pStream->size() - 28;
int sz_obj = (int)pStream->size() - 28;
std::vector<std::string> str;
@ -430,29 +430,6 @@ void draw_plugin::add_child_element( xml::sax * Reader, const std::wstring & Ns,
{
CP_CREATE_ELEMENT(content_);
}
// draw:control
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_control::ns = L"draw";
const wchar_t * draw_control::name = L"control";
void draw_control::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"xml:id", xml_id_);
CP_APPLY_ATTR(L"draw:caption-id", caption_id_);
CP_APPLY_ATTR(L"draw:control", control_id_);
draw_attlists_.shape_with_text_and_styles_.add_attributes(Attributes);
draw_attlists_.position_.add_attributes(Attributes);
draw_attlists_.rel_size_.add_attributes(Attributes);
}
void draw_control::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"draw", L"glue-point")
{
CP_CREATE_ELEMENT(draw_glue_point_);
}
}
}
}

View File

@ -153,7 +153,7 @@ public:
static const ElementType type = typeDrawFrame;
CPDOCCORE_DEFINE_VISITABLE();
draw_frame() : oox_drawing_(NULL), idx_in_owner(-1) {}
draw_frame() : oox_drawing_(), idx_in_owner(-1) {}
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
@ -378,33 +378,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_plugin);
//----------------------------------------------------------------------------------------------
class draw_control : public office_element_impl<draw_control>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeDrawControl;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
odf_types::union_common_draw_attlists draw_attlists_;
_CP_OPT(std::wstring) xml_id_;
_CP_OPT(std::wstring) caption_id_;
_CP_OPT(std::wstring) control_id_;
office_element_ptr draw_glue_point_;
//<svg:desc>
//<svg:title>
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_control);
}
}

View File

@ -51,6 +51,7 @@
#include "../docx/docx_drawing.h"
#include "../docx/xlsx_package.h"
#include "../docx/oox_conversion_context.h"
#include "chart_build_oox.h"
@ -854,8 +855,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
}
if (drawing->styleWrap && drawing->styleWrap->get_type() == style_wrap::RunThrough
&& styleRunThrough && styleRunThrough->get_type() == run_through::Background
)
&& styleRunThrough && styleRunThrough->get_type() == run_through::Background)
{
drawing-> behindDoc = L"1";
}
@ -895,7 +895,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
//////////////////////////////////////////
bool bTxbx = (drawing->sub_type == 1);
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles() ,drawing->fill, bTxbx);
Compute_GraphicFill(graphicProperties.common_draw_fill_attlist_, graphicProperties.style_background_image_, Context.root()->odf_context().drawStyles(),drawing->fill, bTxbx);
if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.empty()))
{
@ -1039,7 +1039,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
if (drawing.sub_type !=5 )//line
{
drawing.additional.push_back(_property(L"text-content",Context.get_drawing_context().get_text_stream_shape()));
drawing.additional.push_back(_property(L"text-content", Context.get_drawing_context().get_text_stream_shape()));
}
Context.get_drawing_context().clear_stream_shape();
@ -1054,7 +1054,7 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
bad_shape_ = false;
}
if (drawing.fill.type < 1 && !IsExistProperty(drawing.additional,L"stroke"))//бывает что и не определено ничего
if (drawing.fill.type < 1 && !IsExistProperty(drawing.additional, L"stroke"))//бывает что и не определено ничего
{
drawing.fill.solid = oox::oox_solid_fill::create();
drawing.fill.solid->color = L"729FCF";
@ -1071,10 +1071,10 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
bool runState = Context.get_run_state();
bool paraState = Context.get_paragraph_state();
bool keepState = Context.get_paragraph_keep();
//Context.set_run_state (false);
Context.set_paragraph_state (false);
Context.reset_context_state();
Context.set_run_state (runState);
//Context.set_paragraph_state (false);
bool new_run = false;
@ -1106,7 +1106,8 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
}
}
Context.set_paragraph_state(paraState);
//Context.set_paragraph_state(paraState);
Context.back_context_state();
Context.get_drawing_context().stop_shape();
}
@ -1142,19 +1143,14 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_frame());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool runState = Context.get_run_state ();
bool pState = Context.get_paragraph_state ();
Context.set_run_state (false);
Context.set_paragraph_state (false);
Context.reset_context_state();
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
}
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.back_context_state();
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
Context.set_stream_man(prev);
@ -1208,13 +1204,8 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_frame());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool pState = Context.get_paragraph_state ();
bool runState = Context.get_run_state ();
bool keepState = Context.get_paragraph_keep ();
Context.reset_context_state();
Context.set_run_state (false);
Context.set_paragraph_state (false);
bool drState = Context.get_drawing_state_content();
Context.set_drawing_state_content(true);
@ -1227,10 +1218,8 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().get_text_stream_frame() = temp_stream.str();
Context.set_stream_man(prev);
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_drawing_state_content (drState);
Context.set_paragraph_keep (keepState);
Context.back_context_state();
//---------------------------------------------------------------------------------------------------------
@ -1355,11 +1344,7 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
std::wstringstream temp_stream(drawing.content_group_);
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool pState = Context.get_paragraph_state ();
bool runState = Context.get_run_state ();
Context.set_paragraph_state (false);
Context.set_run_state (false);
Context.reset_context_state();
for (size_t i = 0; i < content_.size(); i++)
{
@ -1368,9 +1353,9 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
}
drawing.content_group_ = temp_stream.str();
Context.set_stream_man (prev);
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_stream_man(prev);
Context.back_context_state();
//--------------------------------------------------
Context.get_drawing_context().get_size_group (drawing.cx , drawing.cy);
Context.get_drawing_context().get_position_group(drawing.x , drawing.y);
@ -1403,8 +1388,8 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
//--------------------------------------------------
std::wostream & strm = Context.output_stream();
runState = Context.get_run_state();
pState = Context.get_paragraph_state();
bool runState = Context.get_run_state();
bool pState = Context.get_paragraph_state();
if (!Context.get_drawing_context().in_group() && !pState)
{
@ -1465,10 +1450,8 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context)
//-----------------------------------------------------------------------------------------------------
bool runState = Context.get_run_state();
bool paraState = Context.get_paragraph_state();
bool keepState = Context.get_paragraph_keep();
Context.set_run_state (false);
Context.set_paragraph_state (false);
Context.reset_context_state();
if (!Context.get_drawing_context().in_group() && !runState)
{
@ -1490,9 +1473,7 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context)
}
}
Context.set_run_state (runState);
Context.set_paragraph_state (paraState);
Context.set_paragraph_keep (keepState);
Context.back_context_state();
Context.get_drawing_context().stop_frame();
}
@ -1577,6 +1558,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
const std::wstring & content = Context.get_drawing_context().get_text_stream_frame();
bool in_frame = !drawing->isInline;
bool runState = Context.get_run_state();
bool pState = Context.get_paragraph_state();
@ -1670,7 +1652,7 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
{
if (!control_id_) return;
oox::text_forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
oox::forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
if (state.id.empty()) return;
if ((state.type == 6 || state.type == 4) && state.element)
@ -1696,12 +1678,7 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_shape());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
bool pState = Context.get_paragraph_state ();
bool runState = Context.get_run_state ();
bool keepState = Context.get_paragraph_keep ();
Context.set_run_state (false);
Context.set_paragraph_state (false);
Context.reset_context_state();
bool drState = Context.get_drawing_state_content();
@ -1709,10 +1686,10 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
Context.start_paragraph(false);
if (draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
if (common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_)
{
text::paragraph_attrs attrs_;
attrs_.text_style_name_ = *draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_;
attrs_.text_style_name_ = *common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_text_style_name_;
int textStyle = Context.process_paragraph_attr(&attrs_);
}
@ -1739,10 +1716,9 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().get_text_stream_shape() = temp_stream.str();
Context.set_stream_man(prev);
Context.set_run_state (runState);
Context.set_paragraph_state (pState);
Context.set_drawing_state_content (drState);
Context.set_paragraph_keep (keepState);
Context.back_context_state();
const std::wstring & content = Context.get_drawing_context().get_text_stream_shape();
@ -1757,14 +1733,14 @@ void draw_control::docx_convert(oox::docx_conversion_context & Context)
//---------------------------------------------------------------------------------------------------------
/////////
common_draw_docx_convert(Context, draw_attlists_, &drawing);
common_draw_docx_convert(Context, common_draw_attlists_, &drawing);
/////////
std::wostream & strm = Context.output_stream();
pState = Context.get_paragraph_state();
runState = Context.get_run_state();
keepState = Context.get_paragraph_keep();
bool pState = Context.get_paragraph_state();
bool runState = Context.get_run_state();
bool keepState = Context.get_paragraph_keep();
//Context.set_run_state (false);
Context.set_paragraph_state (false);

View File

@ -52,9 +52,11 @@
#include "odf_document_impl.h"
#include "calcs_styles.h"
#include "../docx/xlsx_drawing.h"
#include "chart_build_oox.h"
#include "../docx/oox_conversion_context.h"
#include "../docx/xlsx_drawing.h"
#include "datatypes/length.h"
#include "datatypes/borderstyle.h"
@ -255,7 +257,7 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
}

View File

@ -61,7 +61,7 @@ namespace odf_reader {
const wchar_t * draw_shape::ns = L"draw";
const wchar_t * draw_shape::name = L"shape";
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/// draw-shape-attlist
void draw_shape_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
@ -69,7 +69,14 @@ void draw_shape_attlist::add_attributes( const xml::attributes_wc_ptr & Attribut
void draw_shape::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
if CP_CHECK_NAME(L"draw", L"enhanced-geometry")
{
CP_CREATE_ELEMENT(enhanced_geometry_);
}
else
{
CP_CREATE_ELEMENT(content_);
}
}
void draw_shape::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
@ -88,7 +95,9 @@ void draw_rect_attlist::add_attributes( const xml::attributes_wc_ptr & Attribute
CP_APPLY_ATTR(L"draw:filter-name", draw_filter_name_);
CP_APPLY_ATTR(L"draw:corner-radius",draw_corner_radius_);
}
//-------------------------------------------------------------------------------------------
/// draw:rect
//-------------------------------------------------------------------------------------------
const wchar_t * draw_rect::ns = L"draw";
const wchar_t * draw_rect::name = L"rect";
@ -103,9 +112,6 @@ void draw_rect::add_attributes( const xml::attributes_wc_ptr & Attributes )
sub_type_ = 9;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// draw-ellipse-attlist
void draw_ellipse_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
@ -113,7 +119,9 @@ void draw_ellipse_attlist::add_attributes( const xml::attributes_wc_ptr & Attrib
CP_APPLY_ATTR(L"draw:filter-name", draw_filter_name_);
}
//-------------------------------------------------------------------------------------------
/// draw:ellipse
//-------------------------------------------------------------------------------------------
const wchar_t * draw_ellipse::ns = L"draw";
const wchar_t * draw_ellipse::name = L"ellipse";
@ -133,7 +141,9 @@ void draw_circle_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
{
//CP_APPLY_ATTR(L"draw:filter-name", draw_filter_name_);
}
//-------------------------------------------------------------------------------------------
// draw:circle
//-------------------------------------------------------------------------------------------
const wchar_t * draw_circle::ns = L"draw";
const wchar_t * draw_circle::name = L"circle";
@ -144,7 +154,6 @@ void draw_circle::add_attributes( const xml::attributes_wc_ptr & Attributes )
sub_type_ = 4;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// draw-line-attlist
void draw_line_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
@ -153,7 +162,9 @@ void draw_line_attlist::add_attributes( const xml::attributes_wc_ptr & Attribute
CP_APPLY_ATTR(L"svg:y1", svg_y1_);
CP_APPLY_ATTR(L"svg:y2", svg_y2_);
}
//-------------------------------------------------------------------------------------------
// draw:line
//-------------------------------------------------------------------------------------------
const wchar_t * draw_line::ns = L"draw";
const wchar_t * draw_line::name = L"line";
@ -199,7 +210,9 @@ void draw_line::reset_svg_attributes()
void draw_custom_shape_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}
//-------------------------------------------------------------------------------------------
// draw:custom_shape
//-------------------------------------------------------------------------------------------
const wchar_t * draw_custom_shape::ns = L"draw";
const wchar_t * draw_custom_shape::name = L"custom-shape";
@ -218,7 +231,9 @@ void draw_path_attlist::add_attributes( const xml::attributes_wc_ptr & Attribute
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
//-------------------------------------------------------------------------------------------
// draw:path
//-------------------------------------------------------------------------------------------
const wchar_t * draw_path::ns = L"draw";
const wchar_t * draw_path::name = L"path";
@ -276,11 +291,15 @@ void draw_polygon_attlist::add_attributes( const xml::attributes_wc_ptr & Attrib
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
//-------------------------------------------------------------------------------------------
// draw:polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_polygon::ns = L"draw";
const wchar_t * draw_polygon::name = L"polygon";
//-------------------------------------------------------------------------------------------
// draw:contour-polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_contour_polygon::ns = L"draw";
const wchar_t * draw_contour_polygon::name = L"contour-polygon";
@ -338,7 +357,9 @@ void draw_polyline_attlist::add_attributes( const xml::attributes_wc_ptr & Attri
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
//-------------------------------------------------------------------------------------------
// draw:polyline
//-------------------------------------------------------------------------------------------
const wchar_t * draw_polyline::ns = L"draw";
const wchar_t * draw_polyline::name = L"polyline";
@ -396,7 +417,7 @@ void draw_polyline::reset_polyline_path()
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------
void draw_equation_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name", draw_name_);
@ -417,7 +438,9 @@ void draw_handle_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
CP_APPLY_ATTR(L"draw:handle-polar", draw_handle_polar_);
}
//-------------------------------------------------------------------------------------------
// draw:path
//-------------------------------------------------------------------------------------------
const wchar_t * draw_handle::ns = L"draw";
const wchar_t * draw_handle::name = L"handle";
@ -459,7 +482,9 @@ void draw_enhanced_geometry_attlist::add_attributes( const xml::attributes_wc_pt
CP_APPLY_ATTR(L"drawooo:enhanced-path" , drawooo_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:sub-view-size" , drawooo_sub_view_size_);
}
//-------------------------------------------------------------------------------------------
// draw:enhanced_geometry
//-------------------------------------------------------------------------------------------
const wchar_t * draw_enhanced_geometry::ns = L"draw";
const wchar_t * draw_enhanced_geometry::name = L"enhanced-geometry";
@ -584,13 +609,15 @@ void draw_enhanced_geometry::find_draw_type_oox()
//draw_handle_geometry_.push_back(elm);
// }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------
/// draw-caption-attlist
//-------------------------------------------------------------------------------------------
void draw_caption_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}
//-------------------------------------------------------------------------------------------
// draw:caption
//////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------
const wchar_t * draw_caption::ns = L"draw";
const wchar_t * draw_caption::name = L"caption";
@ -601,15 +628,18 @@ void draw_caption::add_attributes( const xml::attributes_wc_ptr & Attributes )
sub_type_ = 1;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------
/// draw-connector-attlist
//-------------------------------------------------------------------------------------------
void draw_connector_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"svg:d", svg_d_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
CP_APPLY_ATTR(L"draw:type", draw_type_);
}
//-------------------------------------------------------------------------------------------
// draw:connector
//-------------------------------------------------------------------------------------------
const wchar_t * draw_connector::ns = L"draw";
const wchar_t * draw_connector::name = L"connector";
@ -667,7 +697,9 @@ void draw_connector::reset_svg_path()
}
///////////////////////////////////////
//-------------------------------------------------------------------------------------------
// dr3d:scene
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_scene::ns = L"dr3d";
const wchar_t * dr3d_scene::name = L"scene";
@ -678,7 +710,9 @@ void dr3d_scene::add_attributes( const xml::attributes_wc_ptr & Attributes )
sub_type_ = 10;
}
//-------------------------------------------------------------------------------------------
// dr3d:extrude
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_extrude::ns = L"dr3d";
const wchar_t * dr3d_extrude::name = L"extrude";
@ -692,7 +726,9 @@ void dr3d_extrude::reset_svg_path()
if (!svg_d_) return;
}
//-------------------------------------------------------------------------------------------
// dr3d:light
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_light::ns = L"dr3d";
const wchar_t * dr3d_light::name = L"light";
@ -703,6 +739,28 @@ void dr3d_light::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"dr3d:specular", dr3d_specular_);
CP_APPLY_ATTR(L"dr3d:enabled", dr3d_enabled_);
}
//-------------------------------------------------------------------------------------------
// draw:control
//-------------------------------------------------------------------------------------------
const wchar_t * draw_control::ns = L"draw";
const wchar_t * draw_control::name = L"control";
void draw_control::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"xml:id", xml_id_);
CP_APPLY_ATTR(L"draw:caption-id", caption_id_);
CP_APPLY_ATTR(L"draw:control", control_id_);
draw_shape::add_attributes(Attributes);
}
void draw_control::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"draw", L"glue-point")
{
CP_CREATE_ELEMENT(draw_glue_point_);
}
}
}
}

View File

@ -85,7 +85,8 @@ public:
odf_types::common_xlink_attlist xlink_attlist_;
_CP_OPT(std::wstring) draw_id_; //используется для анимашек
office_element_ptr_array content_;
office_element_ptr_array content_;
office_element_ptr enhanced_geometry_;
bool bad_shape_;
bool word_art_;
@ -621,6 +622,31 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_light);
//----------------------------------------------------------------------------------------------
class draw_control : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeDrawControl;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
_CP_OPT(std::wstring) xml_id_;
_CP_OPT(std::wstring) caption_id_;
_CP_OPT(std::wstring) control_id_;
office_element_ptr draw_glue_point_;
//<svg:desc>
//<svg:title>
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_control);
}
}

View File

@ -42,6 +42,7 @@
#include <xml/xmlchar.h>
#include <xml/attributes.h>
#include <xml/utils.h>
#include <odf/odf_document.h>
#include "serialize_elements.h"
@ -53,7 +54,7 @@
#include "datatypes/borderstyle.h"
#include "../docx/xlsx_utils.h"
#include "../docx/oox_drawing.h"
#include "../docx/docx_drawing.h"
namespace cpdoccore {
@ -71,42 +72,68 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
Context.get_drawing_context().add_name_object(name.get_value_or(L"Shape"));
//////////////////////////////на другом контексте
//---------------------------сначала элементы графики потом все остальное
if (enhanced_geometry_)
enhanced_geometry_->docx_convert(Context);
//---------------------------на другом контексте
//тут может быть не только текст , но и таблицы, другие объекты ...
oox::StreamsManPtr prev = Context.get_stream_man();
std::wstringstream temp_stream(Context.get_drawing_context().get_text_stream_shape());
Context.set_stream_man( boost::shared_ptr<oox::streams_man>( new oox::streams_man(temp_stream) ));
//сначала элементы графики потом все остальное
for (size_t i = 0; i < content_.size(); i++)
{
ElementType type = content_[i]->get_type();
if (type == typeDrawCustomShape) // || ....
Context.reset_context_state();
if (word_art_)
{
const std::wstring styleName = common_draw_attlists_.shape_with_text_and_styles_.
common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,Context.process_headers_footers_);
style_content * content = styleInst ? styleInst->content() : NULL;
graphic_format_properties * graphicProp = content ? content->get_graphic_properties() : NULL;
if (graphicProp)
{
content_[i]->docx_convert(Context);
oox::_oox_fill fill;
Compute_GraphicFill(graphicProp->common_draw_fill_attlist_, graphicProp->style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
if ((fill.bitmap) && (fill.bitmap->rId.empty()))
{
std::wstring href = fill.bitmap->xlink_href_;
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
}
std::wstringstream strm_fill, strm_ln;
oox::oox_serialize_fill(strm_fill, fill, L"w14");
std::wstring textFill = strm_fill.str();
std::vector<_property> props;
graphicProp->apply_to(props);
oox::oox_serialize_ln(strm_ln, props, false, L"w14");
std::wstring textLn = strm_ln.str();
std::wstring text_props;
if (!textLn.empty())
{
text_props += textLn;
}
if (!textFill.empty())
{
text_props += L"<w14:textFill>" + textFill + L"</w14:textFill>";
}
Context.set_drawing_text_props(text_props);
}
}
bool pParaState = Context.get_paragraph_state();
bool pRunState = Context.get_run_state();
Context.set_paragraph_state (false);
Context.set_run_state (false);
}
for (size_t i = 0; i < content_.size(); i++)
{
ElementType type = content_[i]->get_type();
if (type != typeDrawCustomShape)
{
content_[i]->docx_convert(Context);
}
content_[i]->docx_convert(Context);
}
Context.set_paragraph_state(pParaState);
Context.set_run_state(pRunState);
Context.back_context_state();
Context.get_drawing_context().get_text_stream_shape() = temp_stream.str();
Context.set_stream_man(prev);

View File

@ -162,13 +162,22 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
}
////////////////////////////////////////////////////////////////////////////////////
Context.get_text_context().start_object();
if (enhanced_geometry_)
enhanced_geometry_->pptx_convert(Context);
if (word_art_)
{
//set fill & stroke to text
}
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->pptx_convert(Context);
}
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
}

View File

@ -44,6 +44,7 @@
#include <xml/attributes.h>
#include <odf/odf_document.h>
#include "office_forms.h"
#include "serialize_elements.h"
#include "style_graphic_properties.h"
#include "odfcontext.h"
@ -65,6 +66,9 @@ namespace odf_reader {
void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (enhanced_geometry_)
enhanced_geometry_->xlsx_convert(Context);
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
@ -129,20 +133,26 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
Context.root()->odf_context().drawStyles(), fill);
Context.get_drawing_context().set_fill(fill);
//////////////////////////////////////////////////////////////////////////////////////
Context.get_text_context().start_drawing_content();
if (word_art_)
{
//Context.get_text_context().start_drawing_fill(fill);
}
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
if (text_content_.length()>0)
if (!text_content_.empty())
{
Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
}
Context.get_drawing_context().end_drawing();
@ -355,5 +365,38 @@ void dr3d_light::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (!control_id_) return;
oox::forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
if (state.id.empty()) return;
if (state.ctrlPropId.empty())
{
std::wstring target;
state.ctrlPropId = Context.get_mediaitems().add_control_props(target);
std::wstringstream strm;
form_element* control = dynamic_cast<form_element*>(state.element);
if (control)
{
control->serialize_control_props(strm);
}
Context.add_control_props(state.ctrlPropId, target, strm.str());
}
Context.get_drawing_context().start_frame();
Context.get_drawing_context().set_control(state.ctrlPropId);
common_xlsx_convert(Context);
Context.get_drawing_context().end_frame();
Context.get_drawing_context().clear();
}
}
}

View File

@ -200,7 +200,11 @@ odf_document::Impl::Impl(const std::wstring & srcPath, const std::wstring & temp
if (false == map_encryptions_.empty())
{
if (password.empty()) return;
if (password.empty())
{
bError = true;
return;
}
//decrypt files
tmp_folder_ = NSDirectory::CreateDirectoryWithUniqueName(tempPath);
@ -286,17 +290,22 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
bool result = true;
for (size_t i = 0; i < arFiles.size(); ++i)
{
result = false;
std::wstring sFileName = NSFile::GetFileName(arFiles[i]);
std::map<std::wstring, std::pair<office_element_ptr, int>>::iterator pFind = map_encryptions_.find(arFiles[i]);
if ( pFind != map_encryptions_.end() )
std::map<std::wstring, std::pair<office_element_ptr, int>>::iterator pFind;
if (false == map_encryptions_.empty())
{
result = decrypt_file(password, arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName, pFind->second.first, pFind->second.second);
if (false == result)
break;
pFind = map_encryptions_.find(arFiles[i]);
if ( pFind != map_encryptions_.end() )
{
result = decrypt_file(password, arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName, pFind->second.first, pFind->second.second);
if (false == result)
break;
}
}
else
if (!result && false == map_encryptions_extra_.empty())
{
pFind = map_encryptions_extra_.find(arFiles[i]);
if ( pFind != map_encryptions_.end() )
@ -306,10 +315,11 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
if (false == result)
break;
}
else
{
NSFile::CFileBinary::Copy(arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName);
}
}
if (!result)
{
NSFile::CFileBinary::Copy(arFiles[i], dstPath + FILE_SEPARATOR_STR + sFileName);
result = true;
}
}
for (size_t i = 0; result && i < arDirectories.size(); ++i)

View File

@ -40,6 +40,7 @@
#include "serialize_elements.h"
#include "../formulasconvert/formulasconvert.h"
namespace cpdoccore {
namespace odf_reader {
@ -65,6 +66,13 @@ void office_forms::docx_convert(oox::docx_conversion_context & Context)
content_[i]->docx_convert(Context);
}
}
void office_forms::xlsx_convert(oox::xlsx_conversion_context & Context)
{
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
}
// form:form
//----------------------------------------------------------------------------------
const wchar_t * form_form::ns = L"form";
@ -117,6 +125,13 @@ void form_form::docx_convert(oox::docx_conversion_context & Context)
content_[i]->docx_convert(Context);
}
}
void form_form::xlsx_convert(oox::xlsx_conversion_context & Context)
{
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
}
// form:properties
//----------------------------------------------------------------------------------
const wchar_t * form_properties::ns = L"form";
@ -132,6 +147,10 @@ void form_properties::docx_convert(oox::docx_conversion_context & Context)
// {
// content_[i]->docx_convert(Context);
// }
}
void form_properties::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
// form:property
//----------------------------------------------------------------------------------
@ -165,6 +184,13 @@ void form_list_property::docx_convert(oox::docx_conversion_context & Context)
content_[i]->docx_convert(Context);
}
}
void form_list_property::xlsx_convert(oox::xlsx_conversion_context & Context)
{
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
}
// form:list-value
//----------------------------------------------------------------------------------
const wchar_t * form_list_value::ns = L"form";
@ -194,6 +220,7 @@ void form_element::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"form:title", title_);
CP_APPLY_ATTR(L"form:value", value_);
CP_APPLY_ATTR(L"form:current-value",current_value_);
CP_APPLY_ATTR(L"form:dropdown", dropdown_);
CP_APPLY_ATTR(L"xml:id", xml_id_);
CP_APPLY_ATTR(L"xforms:bind", xforms_bind_);
}
@ -224,6 +251,21 @@ void form_element::docx_convert(oox::docx_conversion_context & Context)
Context.get_forms_context().end_element();
}
void form_element::xlsx_convert(oox::xlsx_conversion_context & Context)
{
std::wstring id = id_ ? *id_ : (xml_id_ ? *xml_id_ : L"");
Context.get_forms_context().set_id(id);
if (name_) Context.get_forms_context().set_name(*name_);
if (label_) Context.get_forms_context().set_label(*label_);
if (current_value_) Context.get_forms_context().set_value(*current_value_);
else if (value_) Context.get_forms_context().set_value(*value_);
if (control_implementation_) Context.get_forms_context().set_uuid(*control_implementation_);
Context.get_forms_context().end_element();
}
// form:button
//----------------------------------------------------------------------------------
const wchar_t * form_button::ns = L"form";
@ -239,7 +281,27 @@ void form_button::docx_convert(oox::docx_conversion_context & Context)
form_element::docx_convert(Context);
}
void form_button::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(1);
form_element::xlsx_convert(Context);
}
void form_button::serialize_control_props(std::wostream & strm)
{
formulasconvert::odf2oox_converter converter;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"formControlPr")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"objectType", L"Button");
CP_XML_ATTR(L"dx", L"20");
CP_XML_ATTR(L"noThreeD", L"1");
}
}}
// form:text
//----------------------------------------------------------------------------------
const wchar_t * form_text::ns = L"form";
@ -256,6 +318,30 @@ void form_text::docx_convert(oox::docx_conversion_context & Context)
form_element::docx_convert(Context);
}
void form_text::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(2);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}
void form_text::serialize_control_props(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"formControlPr")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"objectType", L"EditBox");
CP_XML_ATTR(L"dx", L"20");
CP_XML_ATTR(L"noThreeD", L"1");
if (value_)
CP_XML_ATTR(L"val", *value_);
}
}}
void form_text::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
{
if (!draw) return;
@ -333,6 +419,30 @@ void form_checkbox::docx_convert(oox::docx_conversion_context & Context)
form_element::docx_convert(Context);
}
void form_checkbox::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(3);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}
void form_checkbox::serialize_control_props(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"formControlPr")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"objectType", L"CheckBox");
if (current_state_)
CP_XML_ATTR(L"checked", L"Checked");
CP_XML_ATTR(L"dx", L"20");
CP_XML_ATTR(L"noThreeD", L"1");
}
}
}
void form_checkbox::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
{
if (!draw) return;
@ -405,6 +515,9 @@ const wchar_t * form_combobox::name = L"combobox";
void form_combobox::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
form_element::add_attributes(Attributes);
CP_APPLY_ATTR(L"form:source-cell-range", source_cell_range_);
CP_APPLY_ATTR(L"form:list-source", list_source_);
}
void form_combobox::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
@ -424,6 +537,42 @@ void form_combobox::docx_convert(oox::docx_conversion_context & Context)
form_element::docx_convert(Context);
}
void form_combobox::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(4);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}
void form_combobox::serialize_control_props(std::wostream & strm)
{
formulasconvert::odf2oox_converter converter;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"formControlPr")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"objectType", L"Drop");
CP_XML_ATTR(L"dropStyle", L"combo");
CP_XML_ATTR(L"dx", L"20");
CP_XML_ATTR(L"noThreeD", L"1");
if (linked_cell_)
{
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
CP_XML_ATTR(L"fmlaLink", fmla);
}
if (source_cell_range_)
{
std::wstring fmla = converter.convert_named_expr(*source_cell_range_);
CP_XML_ATTR(L"fmlaRange", fmla);
}
//CP_XML_ATTR(L"sel", L"3");
if (value_)
CP_XML_ATTR(L"val", *value_);
}
}
}
void form_combobox::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
{
Context.finish_run();
@ -489,13 +638,60 @@ const wchar_t * form_listbox::name = L"listbox";
void form_listbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
form_element::add_attributes(Attributes);
CP_APPLY_ATTR(L"form:source-cell-range", source_cell_range_);
CP_APPLY_ATTR(L"form:list-source", list_source_);
CP_APPLY_ATTR(L"form:list-source-type", list_source_type_);
CP_APPLY_ATTR(L"form:list-linkage-type", list_linkage_type_);
}
void form_listbox::docx_convert(oox::docx_conversion_context & Context)
{
Context.get_forms_context().start_element(5);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::docx_convert(Context);
}
void form_listbox::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(5);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}
void form_listbox::serialize_control_props(std::wostream & strm)
{
formulasconvert::odf2oox_converter converter;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"formControlPr")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"objectType", L"List");
if ((dropdown_) && (dropdown_->get()))
{
CP_XML_ATTR(L"dropStyle", L"combo");
}
CP_XML_ATTR(L"dx", L"20");
CP_XML_ATTR(L"noThreeD", L"1");
if (linked_cell_)
{
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
CP_XML_ATTR(L"fmlaLink", fmla);
}
if (source_cell_range_)
{
std::wstring fmla = converter.convert_named_expr(*source_cell_range_);
CP_XML_ATTR(L"fmlaRange", fmla);
}
//CP_XML_ATTR(L"sel", L"3");
if (value_)
CP_XML_ATTR(L"val", *value_);
}
}
}
// form:button
//----------------------------------------------------------------------------------
const wchar_t * form_date::ns = L"form";
@ -512,6 +708,16 @@ void form_date::docx_convert(oox::docx_conversion_context & Context)
form_element::docx_convert(Context);
}
void form_date::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(6);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}
void form_date::serialize_control_props(std::wostream & strm)
{
}
void form_date::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
{
Context.finish_run();

View File

@ -57,10 +57,12 @@ public:
static const ElementType type = typeOfficeForms;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void docx_convert(oox::docx_conversion_context & Context) ;
public:
office_element_ptr_array content_;
@ -80,10 +82,12 @@ public:
static const ElementType type = typeFormForm;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void docx_convert(oox::docx_conversion_context & Context) ;
public:
office_element_ptr_array content_;
@ -128,10 +132,12 @@ public:
static const ElementType type = typeFormProperties;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void docx_convert(oox::docx_conversion_context & Context) ;
public:
office_element_ptr_array content_; //form property && form list-property
@ -168,10 +174,12 @@ public:
static const ElementType type = typeFormListProperty;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void docx_convert(oox::docx_conversion_context & Context) ;
public:
_CP_OPT(std::wstring) property_name_;
@ -210,18 +218,20 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeFormElement;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
form_element() {}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
virtual void pptx_convert(oox::pptx_conversion_context & Context) {}
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw) {}
virtual void docx_convert_field (oox::docx_conversion_context & Context, draw_control* draw) {}
form_element() {}
//CPDOCCORE_DEFINE_VISITABLE();
virtual void serialize_control_props(std::wostream & strm){}
friend class odf_document;
//----------------------------------------------------------------------------------------------
office_element_ptr office_event_listeners_;
@ -242,6 +252,7 @@ public:
_CP_OPT(std::wstring) xml_id_;
_CP_OPT(std::wstring) xforms_bind_;
_CP_OPT(std::wstring) current_value_;
_CP_OPT(odf_types::Bool) dropdown_;
};
// form:button
@ -254,7 +265,11 @@ public:
static const ElementType type = typeFormButton;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ;
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void serialize_control_props(std::wostream & strm);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
@ -285,9 +300,14 @@ public:
static const ElementType type = typeFormText;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
virtual void docx_convert_field (oox::docx_conversion_context & Context, draw_control* draw);
virtual void serialize_control_props(std::wostream & strm);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
@ -310,9 +330,15 @@ public:
static const ElementType type = typeFormCheckbox;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control *draw);
virtual void docx_convert_field (oox::docx_conversion_context & Context, draw_control* draw);
virtual void serialize_control_props(std::wostream & strm);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
@ -336,23 +362,26 @@ public:
static const ElementType type = typeFormCombobox;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
virtual void serialize_control_props(std::wostream & strm);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
_CP_OPT(odf_types::Bool) dropdown_;
office_element_ptr_array items_;
_CP_OPT(int ) size_;
//form:list-source-type
//form:size
_CP_OPT(std::wstring) source_cell_range_;
_CP_OPT(std::wstring) list_source_;
//form:auto-complete
//form:list-source
//form:sourcecell-range
//form:dropdown
};
CP_REGISTER_OFFICE_ELEMENT2(form_combobox);
@ -367,14 +396,19 @@ public:
static const ElementType type = typeFormListbox;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void serialize_control_props(std::wostream & strm);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
//form:list-source-type
//form:list-source
//form:source-cell-range
_CP_OPT(std::wstring) list_linkage_type_;
_CP_OPT(std::wstring) source_cell_range_;
_CP_OPT(std::wstring) list_source_;
_CP_OPT(std::wstring) list_source_type_;
//form:bound-column
//form:xforms-list-source
@ -395,8 +429,14 @@ public:
static const ElementType type = typeFormDate;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert (oox::docx_conversion_context & Context) ;
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
virtual void serialize_control_props(std::wostream & strm);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );

View File

@ -230,7 +230,7 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
{
double kf_max_width_ms = 1.;
int val = 0.5 + 20.0 * page_width;
int val = (int)(0.5 + 20.0 * page_width);
if (val > 31680.)
kf_max_width_ms = 31680./val;
@ -259,7 +259,7 @@ void style_table_column_properties::pptx_convert(oox::pptx_conversion_context &
if (attlist_.style_column_width_)
{
int val = attlist_.style_column_width_->get_value_unit(length::emu);
int val = (int)attlist_.style_column_width_->get_value_unit(length::emu);
strm << L"<a:gridCol w=\"" << val << "\"/>";
}

View File

@ -226,7 +226,7 @@ int text_format_properties_content::process_font_style(const _CP_OPT(font_style)
}
void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_context & Context)
{
styles_context & styles_context_ = Context.get_text_context().get_styles_context();
oox::styles_context & styles_context_ = Context.get_text_context().get_styles_context();
CP_XML_WRITER(styles_context_.text_style())
{
if (fo_color_)
@ -948,7 +948,7 @@ void text_format_properties_content::docx_serialize(std::wostream & _rPr, fonts_
void text_format_properties_content::pptx_convert(oox::pptx_conversion_context & Context)
{
styles_context & styles_context_ = Context.get_text_context().get_styles_context();
oox::styles_context & styles_context_ = Context.get_text_context().get_styles_context();
fonts_container & fonts_ = Context.root()->odf_context().fontContainer();
drawing_serialize(styles_context_.text_style(), styles_context_.extern_node(), fonts_, styles_context_.get_current_processed_style(), styles_context_.hlinkClick());
@ -1244,7 +1244,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7);//вместо 1 ДОЛЖНОБЫТЬ коэфф. межстрочного интервала!!!
if (fontSize < 1)
fontSize = Context.get_drop_cap_context().FontSize / 7.52;
fontSize = (int)(Context.get_drop_cap_context().FontSize / 7.52);
}
else
{

View File

@ -984,7 +984,7 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
if (fo_page_width_)
{
int val = 0.5 + 20.0 * fo_page_width_->get_value_unit(length::pt);
int val = (int)( 0.5 + 20.0 * fo_page_width_->get_value_unit(length::pt) );
if (val > 31680)
{
//Context.set_settings_property(odf_reader::_property(L"UnormalWidthPage",val));
@ -994,7 +994,7 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
}
if (fo_page_height_)
{
int val = 0.5 + 20.0 * fo_page_height_->get_value_unit(length::pt);
int val = (int)( 0.5 + 20.0 * fo_page_height_->get_value_unit(length::pt));
if (val > 31680) val =31680;//22"
w_h = std::to_wstring(val);
@ -1141,12 +1141,12 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
int val_step = 0;
if (style_layout_grid_base_height_ && style_layout_grid_ruby_height_)
{
val_step = 0.5 + 20. * style_layout_grid_ruby_height_->get_value_unit(odf_types::length::pt)
+ 20. * style_layout_grid_base_height_->get_value_unit(odf_types::length::pt);
val_step = (int)(0.5 + 20. * style_layout_grid_ruby_height_->get_value_unit(odf_types::length::pt)
+ 20. * style_layout_grid_base_height_->get_value_unit(odf_types::length::pt));
}
else if (style_layout_grid_lines_ && height_page > 0)
{
val_step = height_page / (*style_layout_grid_lines_);
val_step = (int)(height_page / (*style_layout_grid_lines_));
}
if (val_step > 0)CP_XML_ATTR(L"w:linePitch", val_step);

View File

@ -181,6 +181,10 @@ void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns,
else if CP_CHECK_NAME(L"calcext", L"conditional-formats")
{
CP_CREATE_ELEMENT(conditional_formats_);
}
else if CP_CHECK_NAME(L"office", L"forms")
{
CP_CREATE_ELEMENT(office_forms_);
}
else
CP_NOT_APPLICABLE_ELM();
@ -381,6 +385,7 @@ bool table_table_cell::empty()
{
if (!content_.elements_.empty()) return false;
if (attlist_.table_formula_) return false;
if (attlist_.table_style_name_) return false;
if (attlist_extra_.table_number_columns_spanned_ > 1) return false;
if (attlist_extra_.table_number_rows_spanned_ > 1) return false;

View File

@ -647,9 +647,9 @@ public:
office_element_ptr table_shapes_;
office_element_ptr_array table_named_;
office_element_ptr office_forms_;
//office-dde-source
//table-scenario
//office-forms
};
CP_REGISTER_OFFICE_ELEMENT2(table_table);

View File

@ -323,6 +323,11 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
_CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl;
if (office_forms_)
{
office_forms_->xlsx_convert(Context);
}
if (table_table_source_)
{
table_table_source* table_source = dynamic_cast<table_table_source*>( table_table_source_.get() );
@ -756,7 +761,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
double s;
if (oox::parseTime(tv, h, m, s))
{
boost::int64_t intTime = oox::convertTime(h, m, s);
boost::int64_t intTime = (boost::int64_t)oox::convertTime(h, m, s);
if (intTime > 0)
{
number_val = boost::lexical_cast<std::wstring>(intTime);

View File

@ -189,6 +189,8 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
if (str_start > store_str.length()) str_start = store_str.length(); // это если на буквы в буквице разные стили
str = store_str.substr(str_start, str_size);
if (textStyle==1) Context.pop_text_properties();
}
size_t paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)

View File

@ -407,6 +407,7 @@ void draw_enhanced_geometry_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"draw:type", draw_type_);
CP_XML_ATTR_OPT(L"drawooo:sub-view-size", draw_sub_view_size_);
CP_XML_ATTR_OPT(L"draw:text-areas", draw_text_areas_);
CP_XML_ATTR_OPT(L"draw:text-rotate-angle", draw_text_rotate_angle_);
CP_XML_ATTR_OPT(L"draw:modifiers", draw_modifiers_);
CP_XML_ATTR_OPT(L"drawooo:enhanced-path", draw_enhanced_path_);
//CP_XML_ATTR_OPT(L"draw:enhanced-path", draw_enhanced_path_);
@ -430,7 +431,7 @@ void draw_enhanced_geometry::serialize(std::wostream & _Wostream)
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_);
draw_enhanced_geometry_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < draw_equation_.size(); i++)
{

View File

@ -331,6 +331,8 @@ public:
_CP_OPT(odf_types::Bool) draw_text_path_same_letter_heights_;
_CP_OPT(std::wstring) draw_text_path_mode_;
_CP_OPT(std::wstring) draw_text_path_scale_;
_CP_OPT(int) draw_text_rotate_angle_;
void serialize(CP_ATTR_NODE);
};
@ -350,7 +352,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
draw_enhanced_geometry_attlist draw_enhanced_geometry_attlist_;
draw_enhanced_geometry_attlist attlist_;
_CP_OPT(std::wstring) svg_viewbox_;

View File

@ -186,6 +186,7 @@ struct odf_drawing_state
presentation_placeholder_ = boost::none;
rotateAngle_ = boost::none;
text_rotateAngle_ = boost::none;
path_ = L"";
view_box_ = L"";
@ -218,6 +219,7 @@ struct odf_drawing_state
_CP_OPT(double) rotateAngle_;
_CP_OPT(unsigned int) fill_color_;
_CP_OPT(int) text_rotateAngle_;
_CP_OPT(presentation_class) presentation_class_;
_CP_OPT(std::wstring) presentation_placeholder_;
@ -232,6 +234,7 @@ struct odf_drawing_state
int oox_shape_preset_;
bool in_group_;
bool text_box_tableframe_;
};
class odf_drawing_context::Impl
@ -536,7 +539,7 @@ void odf_drawing_context::end_drawing()
if (impl_->current_drawing_state_.rotateAngle_)
rotate += *impl_->current_drawing_state_.rotateAngle_;
if (fabs(rotate)>0.001)impl_->current_drawing_state_.rotateAngle_ = rotate;
if (fabs(rotate) > 0.001)impl_->current_drawing_state_.rotateAngle_ = rotate;
}
double x = impl_->current_drawing_state_.svg_x_ ? impl_->current_drawing_state_.svg_x_->get_value() : 0;
double y = impl_->current_drawing_state_.svg_y_ ? impl_->current_drawing_state_.svg_y_->get_value() : 0;
@ -615,8 +618,8 @@ void odf_drawing_context::end_drawing()
draw_enhanced_geometry* enhan = dynamic_cast<draw_enhanced_geometry*>(custom->draw_enhanced_geometry_.get());
if(enhan)
{
if (impl_->current_drawing_state_.flipV_) enhan->draw_enhanced_geometry_attlist_.draw_mirror_vertical_ = true;
if (impl_->current_drawing_state_.flipH_) enhan->draw_enhanced_geometry_attlist_.draw_mirror_horizontal_ = true;
if (impl_->current_drawing_state_.flipV_) enhan->attlist_.draw_mirror_vertical_ = true;
if (impl_->current_drawing_state_.flipH_) enhan->attlist_.draw_mirror_horizontal_ = true;
}
}else
{
@ -986,15 +989,17 @@ void odf_drawing_context::end_shape()
{
if (text_shape)
{
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_same_letter_heights_ = false;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_scale_ = L"path" ;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_mode_ = L"shape" ;
enhanced->draw_enhanced_geometry_attlist_.draw_text_path_ = true;
enhanced->attlist_.draw_text_path_same_letter_heights_ = false;
enhanced->attlist_.draw_text_path_scale_ = L"path" ;
enhanced->attlist_.draw_text_path_mode_ = L"shape" ;
enhanced->attlist_.draw_text_path_ = true;
enhanced->attlist_.draw_text_rotate_angle_ = impl_->current_drawing_state_.text_rotateAngle_;
}
if (!impl_->current_drawing_state_.path_.empty())
{
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_;
enhanced->attlist_.draw_enhanced_path_ =impl_->current_drawing_state_.path_;
}
if (!impl_->current_drawing_state_.view_box_.empty())
{
@ -1002,7 +1007,7 @@ void odf_drawing_context::end_shape()
}
if (!sub_type.empty())
{
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = sub_type;
enhanced->attlist_.draw_type_ = sub_type;
}
else
{
@ -1018,23 +1023,23 @@ void odf_drawing_context::end_shape()
else
enhanced->svg_viewbox_ = shape_define->view_box;
enhanced->draw_enhanced_geometry_attlist_.draw_type_ = shape_define->odf_type_name;
enhanced->draw_enhanced_geometry_attlist_.draw_text_areas_ = shape_define->text_areas;
enhanced->attlist_.draw_type_ = shape_define->odf_type_name;
enhanced->attlist_.draw_text_areas_ = shape_define->text_areas;
enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->draw_enhanced_geometry_attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
enhanced->attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty())
{
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
enhanced->attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
}
else // обязательно нужны дефолтовые
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = shape_define->modifiers;
enhanced->attlist_.draw_modifiers_ = shape_define->modifiers;
if (!shape_define->enhanced_path.empty())
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
enhanced->attlist_.draw_enhanced_path_ = shape_define->enhanced_path;
else
enhanced->draw_enhanced_geometry_attlist_.draw_enhanced_path_ = impl_->current_drawing_state_.path_;
enhanced->attlist_.draw_enhanced_path_ = impl_->current_drawing_state_.path_;
for (size_t i = 0; i < shape_define->equations.size(); i++)
{
@ -1074,6 +1079,18 @@ void odf_drawing_context::end_shape()
}
end_element();
}
if (impl_->current_drawing_state_.flipV_)
{
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"vertical");
}
if (impl_->current_drawing_state_.flipH_)
{
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"horizontal");
}
end_element();
}
@ -1178,7 +1195,7 @@ void odf_drawing_context::end_element()
impl_->current_level_.pop_back();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void odf_drawing_context::start_area_properties()
void odf_drawing_context::start_area_properties(bool reset)
{
impl_->current_drawing_part_ = Area;
}
@ -1186,9 +1203,11 @@ void odf_drawing_context::end_area_properties()
{
impl_->current_drawing_part_ = Unknown;
}
void odf_drawing_context::start_line_properties()
void odf_drawing_context::start_line_properties(bool reset)
{
impl_->current_drawing_part_ = Line;
if (reset)
impl_->current_graphic_properties->draw_stroke_ = boost::none;
}
void odf_drawing_context::end_line_properties()
{
@ -1344,7 +1363,7 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
switch(impl_->current_drawing_part_)
{
case Area:
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
//impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
@ -1597,26 +1616,10 @@ void odf_drawing_context::set_viewBox (double W, double H)
void odf_drawing_context::set_flip_H(bool bVal)
{
impl_->current_drawing_state_.flipH_ = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
//for image
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"horizontal");
}
void odf_drawing_context::set_flip_V(bool bVal)
{
impl_->current_drawing_state_.flipV_ = bVal;
if (impl_->current_graphic_properties == NULL) return;
if (bVal == false)return;
//for image
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" vertical");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"vertical");
}
void odf_drawing_context::set_rotate(double dVal)
@ -1656,7 +1659,7 @@ void odf_drawing_context::set_object_background(bool Val)
if (Val)
{
impl_->anchor_settings_.run_through_ = run_through(run_through::Background);
impl_->anchor_settings_.style_wrap_ = style_wrap(style_wrap::RunThrough);
//impl_->anchor_settings_.style_wrap_ = style_wrap(style_wrap::RunThrough);
}
}
void odf_drawing_context::set_object_foreground(bool Val)
@ -1671,7 +1674,7 @@ void odf_drawing_context::set_object_foreground(bool Val)
{
impl_->anchor_settings_.run_through_ = run_through(run_through::Foreground);
}
impl_->anchor_settings_.style_wrap_ = style_wrap(style_wrap::RunThrough);
//impl_->anchor_settings_.style_wrap_ = style_wrap(style_wrap::RunThrough);
}
}
@ -1796,9 +1799,15 @@ void odf_drawing_context::set_default_wrap_style()
}
void odf_drawing_context::set_wrap_style(style_wrap::type type)
{
impl_->anchor_settings_.style_wrap_ = style_wrap(type);
}
void odf_drawing_context::set_wrap_contour()
{
if (!impl_->current_graphic_properties)return;
impl_->current_graphic_properties->style_wrap_contour_ = true;
impl_->current_graphic_properties->style_wrap_contour_mode_ = wrap_contour_mode(wrap_contour_mode::Full);
}
void odf_drawing_context::set_overlap (bool val)
{
if (val)
@ -2130,7 +2139,7 @@ void odf_drawing_context::set_line_dash_preset(int style)
if (!impl_->current_graphic_properties)return;
if ((impl_->current_graphic_properties->draw_stroke_) &&
(impl_->current_graphic_properties->draw_stroke_->get_type() == line_style::None)) return;
(impl_->current_graphic_properties->draw_stroke_->get_type() == line_style::None) )return;
switch(style) //+создать стиль, привзать имена
{
@ -2142,15 +2151,15 @@ void odf_drawing_context::set_line_dash_preset(int style)
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::DotDash); break;
case 2://presetlinedashvalDot
case 10://presetlinedashvalSysDot
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::Dotted); break;
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::Dotted); break;
case 3://presetlinedashvalLgDash
case 4://presetlinedashvalLgDashDot
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::LongDash); break;
case 5://presetlinedashvalLgDashDotDot
case 9://presetlinedashvalSysDashDotDot
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::DotDotDash);break;
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::DotDotDash); break;
case 6://presetlinedashvalSolid
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::Solid); break;
impl_->current_graphic_properties->draw_stroke_=line_style(line_style::Solid); break;
}
}
void odf_drawing_context::set_paragraph_properties(style_paragraph_properties *paragraph_properties)
@ -2270,6 +2279,33 @@ void odf_drawing_context::set_textarea_writing_mode(int mode)
if (mode == 1) return;//незачем
if (impl_->current_drawing_state_.elements_.empty())return;
if (impl_->current_drawing_state_.oox_shape_preset_ > 2000 && impl_->current_drawing_state_.oox_shape_preset_ < 3000)
{
switch(mode)
{
case 5://textverticaltypeWordArtVert:
case 6://textverticaltypeWordArtVertRtl:
case 3://SimpleTypes::textverticaltypeVert:
case 2://SimpleTypes::textverticaltypeMongolianVert:
case 0://SimpleTypes::textverticaltypeEaVert:
impl_->current_drawing_state_.rotateAngle_ = 90. / 180. * 3.14159265358979323846;
break;
case 4://SimpleTypes::textverticaltypeVert270:
impl_->current_drawing_state_.rotateAngle_ = 270. / 180. * 3.14159265358979323846;
break;
case 1://SimpleTypes::textverticaltypeHorz:
default:
break;
}
if (impl_->current_drawing_state_.flipH_ && impl_->current_drawing_state_.rotateAngle_ )
{
impl_->current_drawing_state_.rotateAngle_ = - *impl_->current_drawing_state_.rotateAngle_;
impl_->current_drawing_state_.flipH_ = false;
}
return;
}
if (!impl_->current_paragraph_properties)
{
style* style_ = dynamic_cast<style*>(impl_->current_drawing_state_.elements_[0].style_elm.get());
@ -2475,6 +2511,12 @@ void odf_drawing_context::start_text_box()
}
void odf_drawing_context::set_text_box_min_size(bool val)
{
if (impl_->current_graphic_properties)
{
impl_->current_graphic_properties->draw_auto_grow_height_ = true;
impl_->current_graphic_properties->draw_auto_grow_width_ = true;
}
if (impl_->current_drawing_state_.elements_.empty()) return;
draw_text_box* draw = dynamic_cast<draw_text_box*>(impl_->current_drawing_state_.elements_.back().elm.get());
@ -2639,7 +2681,13 @@ void odf_drawing_context::end_image()
end_shape();
return;
}
if (impl_->current_drawing_state_.flipH_)
{
if (impl_->current_graphic_properties->style_mirror_)
impl_->current_graphic_properties->style_mirror_ = *impl_->current_graphic_properties->style_mirror_ + std::wstring(L" horizontal");
else
impl_->current_graphic_properties->style_mirror_ = std::wstring(L"horizontal");
}
end_element();
end_frame();
}
@ -2787,7 +2835,8 @@ void odf_drawing_context::set_text(odf_text_context* text_context)
}
}
if (impl_->current_graphic_properties)
if ((impl_->current_graphic_properties) &&
!impl_->current_graphic_properties->draw_auto_grow_height_)
{
//автоувеличение при добавлении текста
impl_->current_graphic_properties->draw_auto_grow_height_ = false;
@ -2852,10 +2901,20 @@ void odf_drawing_context::start_gradient_style()
if (gradient->draw_start_color_) gradient->draw_start_intensity_ = 100.;
gradient->draw_border_ = 0;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_gradient_name_ = gradient->draw_name_;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill(draw_fill::gradient);
switch(impl_->current_drawing_part_)
{
case Area:
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_gradient_name_ = gradient->draw_name_;
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill(draw_fill::gradient);
break;
case Line:
if (!impl_->current_graphic_properties->draw_stroke_)
impl_->current_graphic_properties->draw_stroke_ = line_style(line_style::Solid);//default
if (!impl_->current_graphic_properties->svg_stroke_width_)
impl_->current_graphic_properties->svg_stroke_width_ = length(length(1, length::pt).get_value_unit(length::cm), length::cm);//default
break;
}
}
void odf_drawing_context::set_gradient_type(gradient_style::type style)
{
@ -2874,6 +2933,11 @@ void odf_drawing_context::set_gradient_start(std::wstring hexColor, _CP_OPT(doub
gradient->draw_start_color_ = hexColor;
gradient->draw_start_intensity_ = 100.;
if (impl_->current_drawing_part_ == Line)
{
impl_->current_graphic_properties->svg_stroke_color_ = hexColor;
}
}
void odf_drawing_context::set_gradient_end (std::wstring hexColor, _CP_OPT(double) & intensiv)
{

View File

@ -93,7 +93,9 @@ public:
void set_horizontal_pos (double offset_pt);
void set_default_wrap_style();
void set_wrap_style (odf_types::style_wrap::type style);
void set_wrap_style(odf_types::style_wrap::type style);
void set_wrap_contour();
void set_overlap (bool val);
///////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -201,10 +203,10 @@ public:
void set_opacity (double percent);
//////////////////////////////////////////////////////////////
void start_area_properties();
void start_area_properties(bool reset = false);
void end_area_properties();
void start_line_properties ();
void start_line_properties (bool reset = false);
void set_line_width (double pt);
void set_line_dash_preset (int style);

View File

@ -192,10 +192,30 @@ void ods_conversion_context::start_row(int _start_row, int repeated, int level,
{
if (_start_row > current_table().current_row() + 1)
{
int repeated_default = _start_row - current_table().current_row()-1;
start_row(_start_row - repeated_default, repeated_default, 0, true);
end_row();
int repeated_default = _start_row - current_table().current_row() - 1;
while(true)
{
//делим на 3 - до, с комметом, после;
int comment_idx = current_table().is_row_comment(current_table().current_row() + 1, repeated_default);
if (comment_idx < 0) break;
int rows = current_table().comments_[comment_idx].row - current_table().current_row() - 1;
start_row(current_table().current_row() + 1, rows, 0, true);
end_row();
start_row(current_table().current_row() + 1, 1, 0, true);
end_row();
repeated_default -= (1 + rows);
}
if (repeated_default > 0)
{
start_row(_start_row - repeated_default, repeated_default, 0, true);
end_row();
}
}
/////////////////////////////////////////////////////////////////
while (level < current_table().current_level())

View File

@ -423,7 +423,7 @@ int ods_table_state::is_cell_comment(int col, int row, unsigned int repeate_col)
{
for (size_t i = 0; i < comments_.size(); i++)
{
if ((comments_[i].col < col + repeate_col && comments_[i].col >= col) && comments_[i].row == row)
if ((comments_[i].col < col + repeate_col && comments_[i].col >= col) && comments_[i].row == row && comments_[i].used == false)
{
return (int)i;
}
@ -434,7 +434,7 @@ int ods_table_state::is_row_comment(int row, int repeate_row)
{
for (size_t i = 0; i < comments_.size(); i++)
{
if (comments_[i].row < row + repeate_row && comments_[i].row >= row)
if (comments_[i].row < row + repeate_row && comments_[i].row >= row && comments_[i].used == false)
{
return i;
}
@ -1050,6 +1050,7 @@ void ods_table_state::end_cell()
{
office_element_ptr & comm_elm = comments_[cells_.back().comment_idx].elm;
cells_.back().elm->add_child_element(comm_elm);
comments_[cells_.back().comment_idx].used = true;
}
if (cells_.back().empty)
{
@ -1060,22 +1061,22 @@ void ods_table_state::end_cell()
void ods_table_state::add_default_cell( unsigned int repeated)
{
int comment_idx = is_cell_comment(current_table_column_ + 1 , current_table_row_, repeated);
int comment_idx = is_cell_comment(current_table_column_ + 1, current_table_row_, repeated);
if (comment_idx >= 0 && repeated > 1)
{
//делим на 3 - до, с комметом, после;
int c = current_table_column_;
add_default_cell(comments_[comment_idx].col - c -1);
add_default_cell(comments_[comment_idx].col - c - 1);
add_default_cell(1);
add_default_cell(repeated + c +1 - comments_[comment_idx].col);
add_default_cell(repeated + c + 1 - comments_[comment_idx].col);
return;
}
//////////////////////////////////////////////////
office_element_ptr default_cell_elm;
create_element(L"table", L"table-cell",default_cell_elm, context_);
create_element(L"table", L"table-cell", default_cell_elm, context_);
current_row_element()->add_child_element(default_cell_elm);

View File

@ -202,7 +202,8 @@ struct ods_comment_state
std::wstring author;
office_element_ptr elm;
//style graphic
bool used = false;
};
struct ods_shared_formula_state
{

View File

@ -593,7 +593,7 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
if (oox_shape->txBody.IsInit()) bodyPr = oox_shape->txBody->bodyPr.GetPointer();
else bodyPr = oox_shape->oTextBoxBodyPr.GetPointer();
if (bodyPr && bodyPr->fromWordArt.get_value_or(false))
if ((bodyPr) && (bodyPr->prstTxWarp.IsInit()))
{
int wordart_type = convert(bodyPr->prstTxWarp.GetPointer());
if (wordart_type > 0) type = wordart_type;
@ -782,9 +782,16 @@ void OoxConverter::convert(PPTX::Logic::UniFill *oox_fill, DWORD nARGB)
int OoxConverter::convert(PPTX::Logic::PrstTxWarp *oox_text_preset)
{
if (oox_text_preset == NULL) return -1;
if (oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextNoShape) return 2000;
return 2001 + oox_text_preset->prst.GetBYTECode();
if (oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextNoShape ||
oox_text_preset->prst.GetBYTECode() == SimpleTypes::textshapetypeTextPlain) // в зависимости от других настроек
{
return 2000;
}
else
{
return 2001 + oox_text_preset->prst.GetBYTECode();
}
}
void OoxConverter::convert(PPTX::Logic::PrstGeom *oox_geom)
{
@ -1067,8 +1074,13 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
std::wstring hexColorStart, hexColorEnd;
_CP_OPT(double) opacityStart, opacityEnd;
convert(&oox_grad_fill->GsLst[0].color,hexColorEnd, opacityEnd, nARGB);
convert(&oox_grad_fill->GsLst[oox_grad_fill->GsLst.size()-1].color,hexColorStart, opacityStart, nARGB);
convert(&oox_grad_fill->GsLst[0].color, hexColorEnd, opacityEnd, nARGB);
convert(&oox_grad_fill->GsLst[oox_grad_fill->GsLst.size() - 1].color, hexColorStart, opacityStart, nARGB);
if (hexColorEnd == hexColorStart && opacityEnd == opacityStart && oox_grad_fill->GsLst.size() > 2)
{
convert(&oox_grad_fill->GsLst[oox_grad_fill->GsLst.size() / 2].color, hexColorStart, opacityStart, nARGB);
}
odf_context()->drawing_context()->set_gradient_start(hexColorStart, opacityStart);
odf_context()->drawing_context()->set_gradient_end (hexColorEnd, opacityEnd);
@ -1253,6 +1265,16 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
{
if (!oox_bodyPr) return;
if ((oox_bodyPr->fromWordArt.IsInit() && (*oox_bodyPr->fromWordArt)) && oox_bodyPr->prstTxWarp.IsInit())
{
for (size_t i = 0; i < oox_bodyPr->prstTxWarp->avLst.size(); i++)
{
if (oox_bodyPr->prstTxWarp->avLst[i].fmla.IsInit())
{
odf_context()->drawing_context()->add_modifier(oox_bodyPr->prstTxWarp->avLst[i].fmla.get());
}
}
}
if (oox_bodyPr->vert.IsInit())
{
odf_context()->drawing_context()->set_textarea_writing_mode (oox_bodyPr->vert->GetBYTECode());
@ -1287,7 +1309,7 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
switch(oox_bodyPr->Fit.type)
{
case PPTX::Logic::TextFit::FitSpAuto:
{//изменяемы размеры
{//изменяемы размеры шейпа под текст
odf_context()->drawing_context()->set_text_box_min_size(true);//уже выставленые в min
}break;
case PPTX::Logic::TextFit::FitNo:
@ -1300,17 +1322,6 @@ void OoxConverter::convert(PPTX::Logic::BodyPr *oox_bodyPr)
{
}
}
if ((oox_bodyPr->fromWordArt.IsInit() && (*oox_bodyPr->fromWordArt)) && oox_bodyPr->prstTxWarp.IsInit())
{
for (size_t i = 0; i < oox_bodyPr->prstTxWarp->avLst.size(); i++)
{
if (oox_bodyPr->prstTxWarp->avLst[i].fmla.IsInit())
{
odf_context()->drawing_context()->add_modifier(oox_bodyPr->prstTxWarp->avLst[i].fmla.get());
}
}
}
}
void OoxConverter::convert(PPTX::Logic::NvSpPr *oox_nvSpPr)
{
@ -1807,7 +1818,7 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
if (drawing) //from styles drawing impossible( ... todoooo ???
{
if ((oox_run_pr->Fill.is<PPTX::Logic::GradFill>()) ||
((oox_run_pr->ln.IsInit()) && (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill)))
(oox_run_pr->ln.IsInit() /*&& (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill)*/))
{
drawing->change_text_box_2_wordart();
}
@ -1816,13 +1827,13 @@ void OoxConverter::convert(PPTX::Logic::RunProperties *oox_run_pr, odf_writer::s
{
if (oox_run_pr->Fill.is_init())
{
drawing->start_area_properties();
drawing->start_area_properties(true);
convert(&oox_run_pr->Fill);
drawing->end_area_properties();
}
if (oox_run_pr->ln.is_init())
{
drawing->start_line_properties();
drawing->start_line_properties(true);
if (oox_run_pr->ln->Fill.is_init() && oox_run_pr->ln->Fill.getType() != OOX::et_a_noFill )
{
drawing->set_line_dash_preset(6);

View File

@ -254,7 +254,7 @@ void DocxConverter::convert_document()
//----------------------------------------------------------------------------------------------------------
convert(docx_document->m_pDocument->m_oSectPr.GetPointer(), false, L"Standard");
convert(docx_document->m_pDocument->m_oSectPr.GetPointer(), false, L"Standard", true);
odt_context->text_context()->clear_params();
@ -1410,6 +1410,11 @@ void DocxConverter::convert( ComplexTypes::Word::CShading* shading, _CP_OPT(odf_
if (shading->m_oColor.IsInit())
{
if ((shading->m_oColor->GetValue() == SimpleTypes::hexcolorAuto) &&
(shading->m_oVal.IsInit()) && (shading->m_oVal->GetValue() == SimpleTypes::shdClear))
{
return;
}
BYTE ucR = 0xff, ucB = 0xff, ucG = 0xff; //auto fill
if (shading->m_oColor->GetValue() == SimpleTypes::hexcolorRGB)
{
@ -1502,7 +1507,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi
}
}
}
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name)
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name, bool bAlways)
{
if (oox_section_pr == NULL) return;
current_section_properties = NULL;
@ -1679,7 +1684,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
//nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle;
}
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit())
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit() || bAlways)
{
OOX::Logic::CSectionProperty* s = last_section_properties ? last_section_properties : oox_section_pr;
@ -2239,33 +2244,95 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
text_properties->content_.fo_font_weight_ = odf_types::font_weight(odf_types::font_weight::WNormal);
}
bool set_color = false;
if (oox_run_pr->m_oTextFill.getType() == OOX::et_a_gradFill)
{
NSCommon::smart_ptr<PPTX::Logic::GradFill> gradFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
odf_writer::odf_drawing_context *drawing_context = odf_context()->drawing_context();
if (drawing_context)
{
if (odf_context()->drawing_context()->change_text_box_2_wordart())
{
odf_context()->drawing_context()->start_area_properties();
{
OoxConverter::convert(gradFill.operator->());
}
odf_context()->drawing_context()->end_area_properties();
set_color = true;
}
}
else{} //обычный текст .. градиент по телу абзаца (
}
odf_writer::odf_drawing_context *drawing_context = odf_context()->drawing_context();
if (!set_color && oox_run_pr->m_oColor.IsInit())
bool set_word_art = drawing_context ? drawing_context->is_wordart() : false;
NSCommon::smart_ptr<PPTX::Logic::GradFill> gradFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
NSCommon::smart_ptr<PPTX::Logic::SolidFill> solidFill = oox_run_pr->m_oTextFill.Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
bool bFillText = (oox_run_pr->m_oTextFill.m_type != PPTX::Logic::UniFill::notInit) &&
(oox_run_pr->m_oTextFill.m_type != PPTX::Logic::UniFill::noFill);
bool bOutlineText = ((oox_run_pr->m_oTextOutline.is_init()) &&
(oox_run_pr->m_oTextOutline->Fill.m_type != PPTX::Logic::UniFill::notInit) &&
(oox_run_pr->m_oTextOutline->Fill.m_type != PPTX::Logic::UniFill::noFill));
bool bOutline = oox_run_pr->m_oOutline.IsInit();
bool bColorText = !bOutline && (oox_run_pr->m_oColor.IsInit() && (oox_run_pr->m_oColor->m_oVal.IsInit() && oox_run_pr->m_oColor->m_oVal->GetValue() == SimpleTypes::hexcolorRGB));
_CP_OPT(odf_types::color) color;
if (oox_run_pr->m_oColor.IsInit())
{
if(oox_run_pr->m_oColor->m_oVal.IsInit() && oox_run_pr->m_oColor->m_oVal->GetValue() == SimpleTypes::hexcolorAuto)
text_properties->content_.fo_color_ = odf_types::color(L"#000000");
color = odf_types::color(L"#000000");
else
convert(oox_run_pr->m_oColor.GetPointer(),text_properties->content_.fo_color_);
convert(oox_run_pr->m_oColor.GetPointer(), color);
text_properties->content_.fo_color_ = color;
}
if (gradFill.is_init() || (bOutlineText && (bFillText || bColorText)))
{
set_word_art = true;
}
if (drawing_context && set_word_art)
{
if (drawing_context->change_text_box_2_wordart())
{
drawing_context->start_area_properties(true);
if(gradFill.IsInit())
{
OoxConverter::convert(gradFill.operator->());
}
else if (solidFill.IsInit())
{
OoxConverter::convert(solidFill.operator->());
}
else if (color)
{
drawing_context->set_solid_fill(color->get_hex_value());
}
else
{
drawing_context->set_no_fill();
}
drawing_context->end_area_properties();
if (oox_run_pr->m_oTextOutline.IsInit())
{
drawing_context->start_line_properties(true);
OoxConverter::convert(oox_run_pr->m_oTextOutline.operator->());
drawing_context->end_line_properties();
}
}
else
{
set_word_art = false;
}
}
std::wstring hexString;
_CP_OPT(double) opacity;
if (bOutlineText)
{
text_properties->content_.style_text_outline_ = true;
gradFill = oox_run_pr->m_oTextOutline->Fill.Fill.smart_dynamic_cast<PPTX::Logic::GradFill>();
solidFill = oox_run_pr->m_oTextOutline->Fill.Fill.smart_dynamic_cast<PPTX::Logic::SolidFill>();
}
if (solidFill.is_init())
{
OoxConverter::convert(&solidFill->Color, hexString, opacity);
}
else if ((gradFill.is_init()) && (false == gradFill->GsLst.empty()))
{
OoxConverter::convert(&gradFill->GsLst[0].color, hexString, opacity);
}
if (!hexString.empty())
{
text_properties->content_.fo_color_ = hexString;
}
//text_properties->content_.style_text_underline_type_= odf_types::line_type(odf_types::line_type::None); //нельзя..если будет выше наследуемого то подчеркивания не будет
@ -2424,10 +2491,11 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
if (oox_run_pr->m_oShd.IsInit())
{
_CP_OPT(odf_types::color) odf_color;
convert(oox_run_pr->m_oShd->m_oFill.GetPointer(), oox_run_pr->m_oShd->m_oThemeFill.GetPointer(),
oox_run_pr->m_oShd->m_oThemeFillTint.GetPointer(), oox_run_pr->m_oShd->m_oThemeShade.GetPointer(), odf_color);
convert(oox_run_pr->m_oShd.GetPointer(), odf_color);
if (odf_color)
text_properties->content_.fo_background_color_ = *odf_color;
{
text_properties->content_.fo_background_color_= *odf_color;
}
}
if (oox_run_pr->m_oOutline.IsInit())
text_properties->content_.style_text_outline_ = true; //контур
@ -2877,14 +2945,30 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
else if (oox_anchor->m_oWrapThrough.IsInit())//style:wrap="run-through" draw:wrap-influence-on-position style:wrap-contour
{
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::RunThrough);
}
else if (oox_anchor->m_oWrapTight.IsInit())
{
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Parallel);
if (oox_anchor->m_oWrapTight->m_oWrapPolygon.IsInit())
bool bPolygon = oox_anchor->m_oWrapTight->m_oWrapPolygon.IsInit();
if (oox_anchor->m_oWrapTight->m_oWrapText.IsInit())
{
switch(oox_anchor->m_oWrapTight->m_oWrapText->GetValue())
{
case SimpleTypes::wraptextBothSides:
{
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Dynamic);
if (bPolygon)
{
odt_context->drawing_context()->set_wrap_contour();
}
}break;
case SimpleTypes::wraptextLargest: odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Biggest); break;
case SimpleTypes::wraptextLeft: odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Left); break;
case SimpleTypes::wraptextRight: odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Right); break;
}
}
wrap_set = true;
}
else if (oox_anchor->m_oWrapTopAndBottom.IsInit())
{
@ -4379,7 +4463,7 @@ void DocxConverter::convert(OOX::Logic::CTableRowProperties *oox_table_row_pr)
//nullable<ComplexTypes::Word::CTblWidth > m_oWAfter;
//nullable<ComplexTypes::Word::CTblWidth > m_oWBefore;
}
bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,odf_writer::style_table_cell_properties * table_cell_properties)
bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr, odf_writer::style_table_cell_properties *table_cell_properties)
{
if (oox_table_cell_pr == NULL) return false;
if (table_cell_properties == NULL) return false;
@ -4402,13 +4486,23 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,
{
switch(oox_table_cell_pr->m_oTextDirection->m_oVal->GetValue())
{
case SimpleTypes::textdirectionLr :
table_cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf_types::direction(odf_types::direction::Ltr);break;
case SimpleTypes::textdirectionTb :
{
table_cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf_types::direction(odf_types::direction::Ltr);
}break;
case SimpleTypes::textdirectionLr ://повернутость буковок
case SimpleTypes::textdirectionLrV :
case SimpleTypes::textdirectionTb ://повернутость буковок
case SimpleTypes::textdirectionTbV :
case SimpleTypes::textdirectionRlV :
table_cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf_types::direction(odf_types::direction::Ttb);break;
{
table_cell_properties->style_table_cell_properties_attlist_.style_direction_ = odf_types::direction(odf_types::direction::Ttb);
odf_writer::style_text_properties *text_cell_properties = odt_context->styles_context()->last_state()->get_text_properties();
if (text_cell_properties)
{
text_cell_properties->content_.style_text_rotation_angle_ = 90;
text_cell_properties->content_.style_text_rotation_scale_ = odf_types::text_rotation_scale::LineHeight;
}
}break;
case SimpleTypes::textdirectionRl ://rtl
break;
}
@ -4483,7 +4577,7 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,
if (parent_name.length() > 0)
{
odf_writer::style * style_ = NULL;
if (odt_context->styles_context()->find_odf_style(parent_name,odf_types::style_family::TableCell,style_))
if (odt_context->styles_context()->find_odf_style(parent_name, odf_types::style_family::TableCell, style_))
{
parent_cell_properties = style_->content_.get_style_table_cell_properties();
}
@ -4492,14 +4586,15 @@ bool DocxConverter::convert(OOX::Logic::CTableCellProperties *oox_table_cell_pr,
if (oox_table_cell_pr == NULL && is_base_styled == false && parent_cell_properties == NULL) return false;
odt_context->styles_context()->create_style(L"",odf_types::style_family::TableCell, true, false, -1);
odf_writer::style_table_cell_properties *cell_properties = odt_context->styles_context()->last_state()->get_table_cell_properties();
odf_writer::style_table_cell_properties *cell_properties = odt_context->styles_context()->last_state()->get_table_cell_properties();
if (cell_properties == NULL) return false;
if (is_base_styled)
{
odf_writer::style_text_properties * text_properties = odt_context->styles_context()->last_state()->get_text_properties();
odf_writer::style_paragraph_properties * paragraph_properties = odt_context->styles_context()->last_state()->get_paragraph_properties();
odf_writer::style_text_properties *text_properties = odt_context->styles_context()->last_state()->get_text_properties();
odf_writer::style_paragraph_properties *paragraph_properties = odt_context->styles_context()->last_state()->get_paragraph_properties();
if (col < 0) col=odt_context->table_context()->current_column()+1;
int row=odt_context->table_context()->current_row();

View File

@ -183,7 +183,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 bSection, const std::wstring & master_name = L"");
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name = L"", bool bAlways = false);
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

@ -301,7 +301,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
ods_context->start_rows();
for (size_t row = 0 ; row < oox_sheet->m_oSheetData->m_arrItems.size(); row++)
{
convert(oox_sheet->m_oSheetData->m_arrItems[row]);
convert(oox_sheet->m_oSheetData->m_arrItems[row], row > 0 ? oox_sheet->m_oSheetData->m_arrItems[row - 1] : NULL);
if ( oox_sheet->m_oSheetData->m_arrItems[row] )
delete oox_sheet->m_oSheetData->m_arrItems[row];
@ -487,6 +487,8 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C
{
if (oox_row == NULL)return;
int row_number = oox_row->m_oR.IsInit() ? oox_row->m_oR->GetValue() : -1;
if (oox_row_prev)
{
if (oox_row_prev->m_arrItems.empty() &&
@ -592,14 +594,15 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRow *oox_row, OOX::Spreadsheet::C
if (bEqual)
{
ods_context->add_row_repeated();
return;
if (false == ods_context->current_table().is_row_comment(row_number, 1))
{
ods_context->add_row_repeated();
return;
}
}
}
}
int row_number = oox_row->m_oR.IsInit() ? oox_row->m_oR->GetValue() : -1;
bool _default = true;
if (oox_row->m_oHt.IsInit() || oox_row->m_oCustomHeight.IsInit() || oox_row->m_oHidden.IsInit() || oox_row->m_oCollapsed.IsInit()) _default = false;

View File

@ -52,7 +52,7 @@ COfficePPTFile::~COfficePPTFile()
CloseFile();
}
long COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring & password, bool &bMacros)
_UINT32 COfficePPTFile::OpenFile(const std::wstring & sFileName, const std::wstring & password, bool &bMacros)
{
CloseFile();
@ -103,14 +103,14 @@ bool COfficePPTFile::CloseFile()
return S_OK;
}
HRESULT COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros)
_UINT32 COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros)
{
if (m_strTempDirectory.empty())
{
m_strTempDirectory = NSDirectory::GetTempPath();
}
long nResult = OpenFile(sSrcFileName, password, bMacros);
_UINT32 nResult = OpenFile(sSrcFileName, password, bMacros);
if (nResult != S_OK)
{
CloseFile();

View File

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

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