Compare commits

..

95 Commits

Author SHA1 Message Date
90f1aa055c OdfFormatReader - fix after testing 2018-11-15 19:49:54 +03:00
d75352f1f2 x2t - fix convert vml -> drawing_ml 2018-11-13 14:29:19 +03:00
eef66b3498 OdfFormat - fix convert same autoshapes 2018-11-12 18:37:19 +03:00
b41170a233 Update .gitignore 2018-11-12 15:17:34 +03:00
5626963bdf Fix build 2018-11-12 12:16:04 +03:00
643f117a92 . 2018-11-12 11:53:01 +03:00
dd24ca837f x2t - version up. 2.4.555. 2018-11-10 19:04:30 +03:00
f555e3f821 OdfFormat - refactoring same auto shapes 2018-11-10 19:03:18 +03:00
07a07a1abd PdfWriter - fix encrypt 2018-11-09 19:18:09 +03:00
30473ee9b7 MacOS build (clang) 2018-11-09 15:38:15 +03:00
8b6e5f17c8 MacOS 2018-11-09 14:06:51 +03:00
4d0e44c8b6 Fix PRODUCT_VERSION substitution 2018-11-07 11:39:03 +03:00
b6b79576a1 Update base.pri 2018-11-06 14:25:39 +03:00
1c1223b148 Fix misprint 2018-11-06 14:22:40 +03:00
9947f058a9 XlsFormat - fix bug #39541 2018-11-06 13:17:16 +03:00
54f55ad2ac Fix build without PRODUCT_VERSION env 2018-11-06 12:22:40 +03:00
e4edb9cca4 Fix current year substitution into copyright on windows 2018-11-02 18:18:18 +03:00
aacea2f015 Fix year in copyright on windows 2018-11-02 17:14:31 +03:00
1475b2fef9 Fix misprint 2018-11-02 16:31:01 +03:00
8e58975095 Add publisher name and version env param 2018-11-02 16:25:26 +03:00
04550f06ad Fix bug with metadata in UTF16 format 2018-11-02 15:20:36 +03:00
988423f6e0 OdfFormatReader - write part tables
x2t version 2.4..554
2018-10-31 18:12:11 +03:00
2b096f0977 Wmf meta file - fix bug #39533 2018-10-31 18:03:19 +03:00
7c0962f834 Fix multi-thread build crash 2018-10-31 14:45:25 +03:00
17423cdcdb Merge pull request #123 from ONLYOFFICE/feature/qt_word
Feature/qt word
2018-10-30 19:05:23 +03:00
5dc512dc3b Merge pull request #122 from ONLYOFFICE/feature/Bug_builder
Fix builder bug
2018-10-30 19:03:48 +03:00
1393073694 Merge branch 'feature/fix2_v5.2.3' into hotfix/v5.2.4 2018-10-30 17:43:06 +03:00
7da761a009 Standart Tester epsilon for pixel diffs 2018-10-30 16:45:19 +03:00
626eb87203 v5.2.3 2018-10-30 12:58:37 +03:00
5b0dad3d99 Standart Tester bugs (+ gamma for stroke functionality) 2018-10-29 19:31:27 +03:00
9d3b7b91af Fix builder bug 2018-10-29 15:40:29 +03:00
01691950b9 . 2018-10-29 13:18:34 +03:00
9e085c5ae8 OdfFormat - fix conditional formatting 2018-10-28 17:45:25 +03:00
f55cafa2af OdfFormat -fix after testing 2018-10-26 19:51:12 +03:00
17bc27199c OdfFormatWriter - fix bug#39467 2018-10-25 18:51:07 +03:00
e436c13fcc [x2t] Fix bug 39456 2018-10-25 17:45:03 +03:00
8e2c980152 OdfFormat - fix after testing (#118)
OdfFormat - fix after testing
2018-10-25 17:43:11 +03:00
ff9ef8f941 PptFormatReader - fix users files 2018-10-23 13:19:30 +03:00
0a2401471e [x2t] Fix bug 39391
Fix writing only last ConditionalFormatting from Editor.bin
2018-10-23 11:37:06 +03:00
e55dc5ea75 . 2018-10-22 15:47:09 +03:00
fef30772fd OdfFormatWriter - fix after testing 2018-10-21 18:10:29 +03:00
866af012eb . 2018-10-19 17:55:39 +03:00
8bae2e3255 . 2018-10-19 14:25:35 +03:00
35113a76ca . 2018-10-19 12:10:06 +03:00
f776bb6c4e OdfFormatWriter - fix after testing 2018-10-19 10:36:02 +03:00
8d3e50f8c0 x2t - version up 2018-10-16 19:11:14 +03:00
2439106397 Fix crash on empty dash pen 2018-10-16 17:52:22 +03:00
8953b74579 Fix bug 39214 (text selection in pdf/xps) 2018-10-16 17:17:13 +03:00
bd7978e474 Correct test 2018-10-16 15:52:28 +03:00
95238af0f5 Merge branch 'hotfix/v5.2.3' of https://github.com/ONLYOFFICE/core into hotfix/v5.2.3 2018-10-15 14:02:06 +03:00
e83daf6c91 RtfFormatReader - fix bug #39315 2018-10-15 14:01:27 +03:00
a4cade5a58 Test for work with standart docs 2018-10-15 13:59:52 +03:00
4fb284ebee x2t - fix bug #39307 2018-10-15 13:12:27 +03:00
900ed115c7 Test for work with standart docs 2018-10-12 19:44:43 +03:00
cc31becec1 [x2t] Fix bug 39305
Fix String.ToString2 after f7a13e04d8
2018-10-12 16:39:01 +03:00
9b5f052c97 OdfFormatWriter - fix after testing 2018-10-11 17:57:45 +03:00
2017a8c692 OdfFormat - fix after testing 2018-10-10 19:29:31 +03:00
558c669fb6 Disable truetype fonts convertasion in html viewer 2018-10-10 15:58:26 +03:00
6268e8c3f3 PptxFormat - fix after testing 2018-10-10 11:27:39 +03:00
3c24392e16 PptxFormat - fix after testing 2018-10-09 18:13:57 +03:00
5c1a2f11f9 XlsFormatReader - fix users file (external defined names) 2018-10-09 14:53:04 +03:00
f7a13e04d8 DocxFormat - fix read binary file - bug #39248 2018-10-09 14:02:15 +03:00
c6e47a7bcf DocxFormat - fix bug #39216 2018-10-08 13:08:17 +03:00
62d6581c43 DocFormatReader - fix bug #39236 2018-10-08 11:32:31 +03:00
2d0e5aefa0 Merge pull request #117 from ONLYOFFICE/feature/aspose-math
Feature/aspose math
2018-10-05 17:04:41 +03:00
78a5546d0a PptxFormat - fix binary convert mathType version over 3.0 2018-10-05 12:49:01 +03:00
f55a5418e9 x2t - fix pptx section list 2018-10-04 17:39:32 +03:00
9410862444 [x2t] Fix bin->docx default style falg 2018-10-04 15:08:14 +03:00
f078605031 x2t - select method encrypt files 2018-10-04 13:01:49 +03:00
9105894416 . 2018-10-04 11:32:05 +03:00
1102f7f9b0 OdfFormat - not strong encryption 2018-10-03 20:13:49 +03:00
9aad3d1adb x2t - ooxml - not strong encryption 2018-10-03 20:01:57 +03:00
8d664c2a4f . 2018-10-03 17:22:33 +03:00
cbfa907451 graphics - metafile - fix convert to rastr on linux without set fonts 2018-10-03 15:02:29 +03:00
0712bcfd5c OdfFormatwriter - convert bookmarks 2018-10-02 19:16:14 +03:00
474873531d OdfFormatReader - fix bug #39192 2018-10-02 14:47:38 +03:00
fb79df8c6c . 2018-10-01 11:40:48 +03:00
071ad3f86e . 2018-09-30 17:21:48 +03:00
65bcdb3bea . 2018-09-30 17:08:42 +03:00
f9f26e84fd . 2018-09-30 14:35:49 +03:00
a3888a8186 . 2018-09-28 17:19:20 +03:00
94ec819e68 x2t clear compiling warnings 2018-09-28 15:56:59 +03:00
cb7c7cb4d5 . 2018-09-28 14:55:50 +03:00
d94595f755 OdfFormat - refactoring convert word-arts from/to ooxml; convert form controls in spreadsheets 2018-09-28 14:50:09 +03:00
c7eb16fa64 x2t - clear compiling warnings 2018-09-28 14:30:27 +03:00
d9922e4782 x2t - binary file - add converting effects for drawings 2018-09-28 14:29:33 +03:00
6ee7d79cc4 RtfFormatReader - fix bug #39172 2018-09-28 14:25:18 +03:00
332348ef5b release/v5.2.0 2018-09-27 19:07:44 +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
1955dc98df [x2t] Set default value for math nodes with val attribute and COnOff type 2018-09-20 17:38:30 +03:00
158692f824 [x2t] Fix opening docx with track changes and math created by aspose 2018-09-19 16:53:05 +03:00
94548131a1 v5.1.5 2018-07-17 17:08:49 +03:00
364 changed files with 14340 additions and 4889 deletions

2
.gitignore vendored
View File

@ -47,6 +47,8 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c
ASCOfficeXlsFile2/win32/dlldata.c
OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
X2tConverter/**/Makefile.*
X2tConverter/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/Makefile
X2tConverter/Common/DocxFormat/DocxFormatLib/Makefile
*.7z
*.obj
*.pdb

View File

@ -54,6 +54,7 @@
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../UnicodeConverter/UnicodeConverter.h"
#include <boost/format.hpp>

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

@ -484,6 +484,266 @@ namespace DocFileFormat
return result_cp;
}
void DocumentMapping::writeField(const std::wstring& sFieldString, int cpFieldStart, int cpFieldEnd)
{
_fieldLevels.push_back(fieldLevels());
std::vector<std::wstring> arField;
boost::algorithm::split(arField, sFieldString, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
std::wstring f;
std::wstring EMBED ( L"EMBED" );
std::wstring embed ( L"embed" );
std::wstring LINK ( L"LINK" );
std::wstring FORM ( L"FORM" );
std::wstring Excel ( L"Excel" );
std::wstring Word ( L"Word" );
std::wstring opendocument(L"opendocument" );
std::wstring Equation ( L"Equation" );
std::wstring MERGEFORMAT( L"MERGEFORMAT" );
std::wstring QUOTE ( L"QUOTE" );
std::wstring chart ( L"Chart" );
std::wstring PBrush ( L"PBrush" );
std::wstring TOC ( L"TOC" );
std::wstring HYPERLINK ( L"HYPERLINK" );
std::wstring PAGEREF ( L"PAGEREF" );
std::wstring PAGE ( L"PAGE" );
std::wstring SHAPE ( L"SHAPE" );
if (arField.empty() == false)
f = arField[0];
else
f = sFieldString;
bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end();
bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end() ||
search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end();
bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end();
bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end();
bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end();
bool bMERGEFORMAT = search( f.begin(), f.end(), MERGEFORMAT.begin(), MERGEFORMAT.end()) != f.end();
bool bExcel = search( f.begin(), f.end(), Excel.begin(), Excel.end()) != f.end();
bool bWord = search( f.begin(), f.end(), Word.begin(), Word.end()) != f.end();
bool bHYPERLINK = search( f.begin(), f.end(), HYPERLINK.begin(), HYPERLINK.end()) != f.end();
bool bQUOTE = search( f.begin(), f.end(), QUOTE.begin(), QUOTE.end()) != f.end();
bool bEquation = search( f.begin(), f.end(), Equation.begin(), Equation.end()) != f.end();
bool bPAGE = search( f.begin(), f.end(), PAGE.begin(), PAGE.end()) != f.end();
bool bTOC = search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end();
bool bSHAPE = search( f.begin(), f.end(), SHAPE.begin(), SHAPE.end()) != f.end();
bool bPAGEREF = false;
if (bHYPERLINK && arField.size() > 1)
{
std::wstring f1 = arField[1];
bPAGEREF = search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end();
}
if (bTOC)
_bContentWrite = true;
if ( bFORM )
{
std::wstring FORMTEXT ( L" FORMTEXT" );
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
{
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
if (chpxs)
{
CharacterPropertyExceptions* chpxSep = chpxs->front();
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
ffdata.Convert(&data_mapping);
RELEASEOBJECT( chpxs );
}
}
}
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if ( ( bMERGEFORMAT || bExcel || bWord || bOpendocument )
&&
( ( bEMBED || bLINK ) && bChart) )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if (bHYPERLINK && bPAGEREF)
{
int cpFieldSep2 = cpFieldStart, cpFieldSep1 = cpFieldStart;
std::vector<std::wstring> toc;
if (arField.size() > 1)
f = arField[1];
if ( _bContentWrite )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
else
{
for (size_t i = 1; i < arField.size(); i++)
{
std::wstring f1 = arField[1];
int d = (int)f1.find(PAGEREF);
if (d > 0)
{
_writeWebHidden = true;
std::wstring _writeTocLink =f1.substr(d + 9);
d = (int)_writeTocLink.find(L" ");
_writeTocLink = _writeTocLink.substr(0, d);
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
_writeAfterRun += _writeTocLink;
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
break;
//cp = cpFieldSep1;
}
//cpFieldSep1 = cpFieldSep2;
}
_skipRuns = 5; //with separator
}
}
else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
CharacterPropertyExceptions* chpxObj = chpxs->front();
RevisionData oData = RevisionData(chpxObj);
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &oData, _lastValidPapx, false);
if(rPr)
{
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XMLTools::CStringXmlWriter oleWriter;
XMLTools::CStringXmlWriter oleObjectWriter;
VMLPictureMapping oVmlMapper (m_context, &oleWriter, true, _caller);
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ));
oleWriter.WriteNodeEnd( L"", true, false );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.m_shapeId);
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ) );
oleWriter.WriteNodeEnd( L"", true, false );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
if ( cpFieldSep < cpFieldEnd && m_document->m_PieceTable)
{
int fcFieldSep = m_document->m_PieceTable->FileCharacterPositions->operator []( cpFieldSep );
int fcFieldSep1 = m_document->FindFileCharPos( cpFieldSep );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
{
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
}
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
RELEASEOBJECT( chpxs );
}
}
oleWriter.WriteString( _lastOLEObject );
oleWriter.WriteNodeEnd( L"w:object" );
if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
}
else
{
m_pXmlWriter->WriteString(oleWriter.GetXmlString());
}
}
_skipRuns = 3;
_embeddedObject = true;
}
else
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
}
// Writes the given text to the document
int DocumentMapping::writeText(std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText)
{
@ -576,289 +836,15 @@ namespace DocFileFormat
}
else if (TextMark::FieldBeginMark == code)
{
_fieldLevels.push_back(fieldLevels());
int cpFieldStart = initialCp + i;
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
std::wstring f, sFieldString;
std::wstring sFieldString;
if (cpFieldEnd < (int)m_document->Text->size())
sFieldString = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
std::vector<std::wstring> arField;
boost::algorithm::split(arField, sFieldString, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
std::wstring EMBED ( L"EMBED" );
std::wstring embed ( L"embed" );
std::wstring LINK ( L"LINK" );
std::wstring FORM ( L"FORM" );
std::wstring Excel ( L"Excel" );
std::wstring Word ( L"Word" );
std::wstring opendocument(L"opendocument" );
std::wstring Equation ( L"Equation" );
std::wstring MERGEFORMAT( L"MERGEFORMAT" );
std::wstring QUOTE ( L"QUOTE" );
std::wstring chart ( L"Chart" );
std::wstring PBrush ( L"PBrush" );
std::wstring TOC ( L"TOC" );
std::wstring HYPERLINK ( L"HYPERLINK" );
std::wstring PAGEREF ( L"PAGEREF" );
std::wstring PAGE ( L"PAGE" );
std::wstring SHAPE ( L"SHAPE" );
writeField(sFieldString, cpFieldStart, cpFieldEnd);
if (arField.empty() == false)
f = arField[0];
else
f = sFieldString;
bool bChart = search( f.begin(), f.end(), chart.begin(), chart.end()) != f.end();
bool bEMBED = search( f.begin(), f.end(), EMBED.begin(), EMBED.end()) != f.end() ||
search( f.begin(), f.end(), embed.begin(), embed.end()) != f.end();
bool bLINK = search( f.begin(), f.end(), LINK.begin(), LINK.end()) != f.end();
bool bOpendocument = search( f.begin(), f.end(), opendocument.begin(), opendocument.end()) != f.end();
bool bFORM = search( f.begin(), f.end(), FORM.begin(), FORM.end()) != f.end();
bool bMERGEFORMAT = search( f.begin(), f.end(), MERGEFORMAT.begin(), MERGEFORMAT.end()) != f.end();
bool bExcel = search( f.begin(), f.end(), Excel.begin(), Excel.end()) != f.end();
bool bWord = search( f.begin(), f.end(), Word.begin(), Word.end()) != f.end();
bool bHYPERLINK = search( f.begin(), f.end(), HYPERLINK.begin(), HYPERLINK.end()) != f.end();
bool bQUOTE = search( f.begin(), f.end(), QUOTE.begin(), QUOTE.end()) != f.end();
bool bEquation = search( f.begin(), f.end(), Equation.begin(), Equation.end()) != f.end();
bool bPAGE = search( f.begin(), f.end(), PAGE.begin(), PAGE.end()) != f.end();
bool bTOC = search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end();
bool bSHAPE = search( f.begin(), f.end(), SHAPE.begin(), SHAPE.end()) != f.end();
bool bPAGEREF = false;
if (bHYPERLINK && arField.size() > 1)
{
std::wstring f1 = arField[1];
bPAGEREF = search( f1.begin(), f1.end(), PAGEREF.begin(), PAGEREF.end()) != f1.end();
}
if (bTOC)
_bContentWrite = true;
if ( bFORM )
{
std::wstring FORMTEXT ( L" FORMTEXT" );
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
{
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
if (chpxs)
{
CharacterPropertyExceptions* chpxSep = chpxs->front();
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
ffdata.Convert(&data_mapping);
RELEASEOBJECT( chpxs );
}
}
}
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if ( ( bMERGEFORMAT || bExcel || bWord || bOpendocument )
&&
( ( bEMBED || bLINK ) && bChart) )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
_fieldLevels.back().bBegin = true;
}
else if (bHYPERLINK && bPAGEREF)
{
int cpFieldSep2 = cpFieldStart, cpFieldSep1 = cpFieldStart;
std::vector<std::wstring> toc;
if (arField.size() > 1)
f = arField[1];
if ( _bContentWrite )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
else
{
for (size_t i = 1; i < arField.size(); i++)
{
std::wstring f1 = arField[1];
int d = (int)f1.find(PAGEREF);
if (d > 0)
{
_writeWebHidden = true;
std::wstring _writeTocLink =f1.substr(d + 9);
d = (int)_writeTocLink.find(L" ");
_writeTocLink = _writeTocLink.substr(0, d);
_writeAfterRun = std::wstring (L"<w:hyperlink w:anchor = \"");
_writeAfterRun += _writeTocLink;
_writeAfterRun += std::wstring (L"\" w:history=\"1\">");
break;
//cp = cpFieldSep1;
}
//cpFieldSep1 = cpFieldSep2;
}
_skipRuns = 5; //with separator
}
}
//else if ( bHYPERLINK )
//{//todooo - выделение гиперссылки отдельно
// std::vector<std::wstring> arRefs;
// boost::algorithm::split(arRefs, f, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
//
// std::wstring sLink = arRefs[2];
// m_pXmlWriter->WriteNodeBegin( L"w:hyperlink", true );
// int relID = m_context->_docx->RegisterHyperlink(_caller, sLink);
// m_pXmlWriter->WriteAttribute( L"r:id", L"rId"+ FormatUtils::IntToWideString( relID ) );
// m_pXmlWriter->WriteAttribute( L"w:history", 1 );
// m_pXmlWriter->WriteNodeEnd( L"", true, false );
// if (arRefs.size() > 2)
// {
// writeTextElement(arRefs[3].substr(1, arRefs[3].length() - 2), textType);
// }
// m_pXmlWriter->WriteNodeEnd( L"w:hyperlink", false, true );
// _skipRuns = 1;
//}
else if ( bEMBED || (bLINK && !bHYPERLINK)|| bQUOTE)
{
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldSep = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::FieldSeparator);
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
CharacterPropertyExceptions* chpxObj = chpxs->front();
RevisionData oData = RevisionData(chpxObj);
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &oData, _lastValidPapx, false);
if(rPr)
{
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XMLTools::CStringXmlWriter oleWriter;
XMLTools::CStringXmlWriter oleObjectWriter;
VMLPictureMapping oVmlMapper (m_context, &oleWriter, true, _caller);
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
if (m_document->nWordVersion > 0)
{
OleObject ole ( chpxObj, m_document);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ));
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ));
oleWriter.WriteNodeEnd( L"", true, false );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.m_shapeId);
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->nWordVersion);
oleWriter.WriteNodeBegin (L"w:object", true);
oleWriter.WriteAttribute( L"w:dxaOrig", FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ) );
oleWriter.WriteAttribute( L"w:dyaOrig", FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ) );
oleWriter.WriteNodeEnd( L"", true, false );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
if ( cpFieldSep < cpFieldEnd && m_document->m_PieceTable)
{
int fcFieldSep = m_document->m_PieceTable->FileCharacterPositions->operator []( cpFieldSep );
int fcFieldSep1 = m_document->FindFileCharPos( cpFieldSep );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions( fcFieldSep, ( fcFieldSep + 1 ) );
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
if (oVmlMapper.m_isEmbedded)
{
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
ole.emeddedData = oVmlMapper.m_embeddedData;
}
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
RELEASEOBJECT( chpxs );
}
}
oleWriter.WriteString( _lastOLEObject );
oleWriter.WriteNodeEnd( L"w:object" );
if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation)
{
//нельзя в Run писать oMath
//m_pXmlWriter->WriteString(oVmlMapper.m_equationXml);
_writeAfterRun = oVmlMapper.m_equationXml;
}
else
{
m_pXmlWriter->WriteString(oleWriter.GetXmlString());
}
}
_skipRuns = 3;
_embeddedObject = true;
}
else
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar", true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType", L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true );
_fieldLevels.back().bBegin = true;
}
}
else if (TextMark::FieldSeparator == code)
{
@ -1042,7 +1028,7 @@ 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]);
EndnoteDescriptor* desc = dynamic_cast<EndnoteDescriptor*>(m_document->EndnoteReferenceCharactersPlex->Elements[_endnoteNr]);
if (desc && desc->aEndIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
@ -1078,7 +1064,19 @@ namespace DocFileFormat
cp++;
}
if (std::wstring::npos != text.find(L"EMBED"))
{//если есть мааркер конца поля и маркер замещающей картинки и нету маркера начала
//О реорганизации территориальных органов ПФР с 01.11.2018.doc
int cpFieldStart = initialCp;
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
if (cpFieldStart < cpPic && cpPic < cpFieldEnd)
{
writeField(text, cpFieldStart, cpFieldEnd);
text.clear();
}
}
if (!text.empty())
{
//bool preserve_space = (text.find(L"\x20")) != text.npos) ? true : false;
@ -1348,6 +1346,8 @@ namespace DocFileFormat
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
default:
break;
}
}
if (nestingLevel == iTap_current)
@ -1377,6 +1377,8 @@ namespace DocFileFormat
AddBoundary(boundary2, max_boundary, boundaries);
}break;
default:
break;
}
}
}

View File

@ -85,21 +85,17 @@ namespace DocFileFormat
int getCurrentSection (int cp);
//---------------------------------
bool isSectionEnd ( int cp );
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
int writeParagraph( int cp, int cpEnd );
// Writes a Paragraph that starts at the given cpStart and
// ends at the given cpEnd
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false );
// Writes a Paragraph RSID
void writeParagraphRsid( const ParagraphPropertyExceptions* papx );
// Writes a run with the given characters and CHPX
int writeRun( std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
// Writes the given text to the document
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeParagraphRsid ( const ParagraphPropertyExceptions* papx );
void writeTextElement ( const std::wstring& text, const std::wstring& textType );
void writeTextStart ( const std::wstring& textType, bool preserve_space);
void writeTextEnd ( const std::wstring& textType );
void writeField (const std::wstring& sFieldString, int cpFieldStart, int cpFieldEnd);
std::vector<int> searchBookmarks( std::vector<wchar_t>* chars, int initialCp );
std::vector<int> searchAnnot(std::vector<wchar_t>* chars, int initialCp);

View File

@ -110,7 +110,7 @@ namespace DocFileFormat
typedef struct FibWord2
{
unsigned int Spare = 0;
unsigned char rgwSpare0[3];
unsigned short rgwSpare0[3];
unsigned int fcPlcMcr = 0;
unsigned int lcbPlcMcr = 0;
@ -1312,10 +1312,10 @@ namespace DocFileFormat
flag16 = reader.ReadUInt16(); //10
m_FibBase.fDot = (flag16 & 0x0001) >> 2;
m_FibBase.fGlsy = (flag16 & 0x0002) >> 1;
m_FibBase.fComplex = (flag16 & 0x0004) >> 2;
m_FibBase.fHasPic = (flag16 & 0x0008) >> 3;
m_FibBase.fDot = ((flag16 & 0x0001) >> 2) != 0;
m_FibBase.fGlsy = ((flag16 & 0x0002) >> 1) != 0;
m_FibBase.fComplex = ((flag16 & 0x0004) >> 2) != 0;
m_FibBase.fHasPic = ((flag16 & 0x0008) >> 3) != 0;
m_FibBase.cQuickSaves = (WORD)(((int)flag16 & 0x00F0) >> 4);
m_FibBase.fEncrypted = FormatUtils::BitmaskToBool((int)flag16, 0x0100);
m_FibBase.fWhichTblStm = FormatUtils::BitmaskToBool((int)flag16, 0x0200);

View File

@ -134,6 +134,8 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx,
bNilPICFAndBinData = true; // or bPICFAndOfficeArtData - shape, pic, ole
}
break;
default:
break;
}
}

View File

@ -78,7 +78,14 @@ public:
return rdUShort;
}
void WriteUInt16(unsigned short val)
{
if (m_Data)
{
((unsigned short *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(unsigned short);
}
}
virtual short ReadInt16()
{
short rdShort = 0;
@ -104,7 +111,14 @@ public:
return rdInt;
}
void WriteInt32(_INT32 val)
{
if (m_Data)
{
((_INT32 *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(_INT32);
}
}
virtual unsigned int ReadUInt32()
{
int rdUInt = 0;
@ -117,7 +131,22 @@ public:
return rdUInt;
}
void WriteByte(unsigned char val)
{
if (m_Data)
{
m_Data[m_Position] = val;
m_Position += 1;
}
}
void WriteUInt32(_UINT32 val)
{
if (m_Data)
{
((_UINT32 *)(m_Data + m_Position))[0] = val;
m_Position += sizeof(_UINT32);
}
}
virtual unsigned char ReadByte()
{
unsigned char rdByte = 0;
@ -159,6 +188,14 @@ public:
return pBytes;
}
void WriteBytes(unsigned char* pData, int size)
{
if (m_Data)
{
memcpy(m_Data + m_Position, pData, size);
m_Position += size;
}
}
virtual unsigned long GetPosition() const
{
@ -172,7 +209,7 @@ public:
virtual int Seek (int offset, int origin = 0/*STREAM_SEEK_SET*/)
{
if ( (m_Data != NULL) && (offset > 0) && ((unsigned int)offset < m_Size) )
if ( (m_Data != NULL) && (offset >= 0) && ((unsigned int)offset < m_Size) )
return m_Position = offset;
return 0;

View File

@ -697,6 +697,8 @@ namespace DocFileFormat
{
isPictureBullet = FormatUtils::BitmaskToBool(FormatUtils::BytesToUInt16(iter->Arguments, 0, iter->argumentsSize), 0x1);
}break;
default:
break;
}
}

View File

@ -97,7 +97,7 @@ namespace DocFileFormat
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
if (shape)
{
shape->m_nIndex = i;
shape->m_nIndex = (int)i;
if (shape->m_bBackground)
{
m_pBackgroud = shape;

View File

@ -112,7 +112,7 @@ namespace DocFileFormat
if (lMinF <= point.x)
{
int index = (DWORD)point.x - 0x80000000;
if (index >= 0 && index < guides.size())
if (index >= 0 && index < (int)guides.size())
{
point.x = guides[index].param3;
}
@ -120,7 +120,7 @@ namespace DocFileFormat
if (lMinF <= point.y)
{
int index = (DWORD)point.y - 0x80000000;
if (index >= 0 && index < guides.size())
if (index >= 0 && index < (int)guides.size())
{
point.y = guides[index].param3;
}

View File

@ -60,8 +60,8 @@ namespace DocFileFormat
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ClientAnchor *clientAnchor = dynamic_cast<ClientAnchor*>( this->Children[i] );
if ( (clientAnchor) && (clientAnchor->value == 0x80000000))
m_bSkip = true;
//if ( (clientAnchor) && (clientAnchor->value == 0x80000000))
// m_bSkip = true; //О реорганизации территориальных органов ПФР с 01.11.2018.doc
Shape* sh = dynamic_cast<Shape*>( this->Children[i] );
if (sh)

View File

@ -244,6 +244,8 @@ namespace DocFileFormat
case sprmOldCFData:
case sprmCFData:
break;
default:
break;
}
}

View File

@ -117,6 +117,8 @@ namespace DocFileFormat
this->RsidDel = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
}
break;
default:
break;
}
//put the sprm on the revision stack

View File

@ -130,6 +130,8 @@ namespace DocFileFormat
appendValueAttribute( &pgBorders, L"w:display", L"notFirstPage" );
}break;
default:
break;
}
}
if (_ctx->_doc->nWordVersion == 2)

View File

@ -92,6 +92,8 @@ namespace DocFileFormat
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
default:
break;
}
}
std::list<SinglePropertyModifier>::const_reverse_iterator rend = tapx->grpprl->rend();
@ -318,6 +320,8 @@ namespace DocFileFormat
}
}
break;
default:
break;
}
}
if (_gridSpan <= 1 && nComputedCellWidth > _width && _width > 1)

View File

@ -70,9 +70,7 @@ namespace DocFileFormat
case sprmTDefTable:
{
//SprmTDefTable tdef = new SprmTDefTable(sprm.Arguments);
}
break;
}break;
case sprmOldTTableHeader:
case sprmTTableHeader:
{ //header row
@ -84,9 +82,7 @@ namespace DocFileFormat
XMLTools::XMLElement header( L"w:tblHeader" );
_trPr->AppendChild( header );
}
}
break;
}break;
case sprmTWidthAfter:
{ //width after
XMLTools::XMLElement wAfter( L"w:wAfter" );
@ -96,9 +92,7 @@ namespace DocFileFormat
XMLTools::XMLAttribute wAfterType( L"w:type", L"dxa" );
wAfter.AppendAttribute( wAfterType );
_trPr->AppendChild( wAfter, true );
}
break;
}break;
case sprmTWidthBefore:
{ //width before
short before = FormatUtils::BytesToInt16( iter->Arguments, 1, iter->argumentsSize );
@ -113,9 +107,7 @@ namespace DocFileFormat
wBefore.AppendAttribute( wBeforeType );
_trPr->AppendChild( wBefore, true );
}
}
break;
}break;
case sprmOldTDyaRowHeight:
case sprmTDyaRowHeight:
{ //row height
@ -147,19 +139,19 @@ namespace DocFileFormat
_trPr->AppendChild( rowHeight );
}
break;
case sprmOldTFCantSplit:
case sprmTFCantSplit:
case sprmTFCantSplit90:
{ //can't split
appendFlagElement( _trPr, *iter, L"cantSplit", true );
}break;
case sprmOldTFCantSplit:
case sprmTFCantSplit:
case sprmTFCantSplit90:
{ //can't split
appendFlagElement( _trPr, *iter, L"cantSplit", true );
}break;
//div id
case sprmTIpgp:// = PGPInfo.ipgpSelf (PGPInfo structure describes the border and margin properties)
{
}break;
//div id
case sprmTIpgp:// = PGPInfo.ipgpSelf (PGPInfo structure describes the border and margin properties)
{
}break;
default:
break;
//borders 80 exceptions
//case SinglePropertyModifier.OperationCode.sprmTTableBorders80:
// unsigned char[] brc80 = new unsigned char[4];

View File

@ -427,8 +427,9 @@ namespace DocFileFormat
{
appendStyleProperty(&strStyle, L"visibility", L"hidden");
}
}
break;
}break;
default:
break;
}
}

View File

@ -168,6 +168,8 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"wrapcoords", wrapCoords);
}
break;
default:
break;
}
}
@ -1682,6 +1684,8 @@ namespace DocFileFormat
{
appendStyleProperty(oStyle, L"mso-wrap-distance-top", (FormatUtils::DoubleToWideString(EmuValue((int)iter->op).ToPoints()) + std::wstring(L"pt")));
}break;
default:
break;
}
}
@ -1819,12 +1823,12 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"none";
case 1: return L"block";
case 2: return L"classic";
case 3: return L"diamond";
case 4: return L"oval";
case 5: return L"open";
default: return L"none";
}
}
@ -1832,9 +1836,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"short";
case 1: return L"medium";
case 2: return L"long";
default: return L"short";
}
}
@ -1842,9 +1846,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"narrow";
case 1: return L"medium";
case 2: return L"wide";
default: return L"narrow";
}
}

View File

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

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;

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

@ -66,7 +66,7 @@ namespace Writers
NSDirectory::CreateDirectories(sCustomXmlRelsDir);
m_pDrawingConverter->SetDstContentRels();
long lId;
unsigned int lId;
m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXmlProps.RelationType(), sCustomXMLPropsFilename, L"", &lId);
m_pDrawingConverter->SaveDstContentRels(sCustomXmlRelsDir + FILE_SEPARATOR_STR + sCustomXmlFilename + L".rels");

View File

@ -2115,7 +2115,7 @@ class CDrawingProperty
public:
bool bObject;
std::wstring sObjectProgram;
long nObjectId;
unsigned int nObjectId;
BYTE nObjectType;
long DataPos;

View File

@ -100,10 +100,9 @@ public:
RELEASEOBJECT(m_oRPr)
}
};
#define READ1_DEF(stLen, res, fReadFunction, arg) {\
long read1defCurPos = 0;\
while(read1defCurPos < stLen)\
while(read1defCurPos < (long)stLen)\
{\
BYTE read1defType = m_oBufferedStream.GetUChar();\
long read1defLength = m_oBufferedStream.GetLong();\
@ -120,7 +119,7 @@ public:
}
#define READ2_DEF(stLen, res, fReadFunction, arg) {\
long read2defCurPos = 0;\
while(read2defCurPos < stLen)\
while(read2defCurPos < (long)stLen)\
{\
BYTE read2defType = m_oBufferedStream.GetUChar();\
long read2defLenType = m_oBufferedStream.GetUChar();\
@ -2056,7 +2055,7 @@ public:
if(true == orowPrAfterBefore.bGridAfter && orowPrAfterBefore.nGridAfter > 0 && false == orowPrAfterBefore.oAfterWidth.bW)
{
//ищем по tblGrid
if(orowPrAfterBefore.nGridAfter < m_aCurTblGrid.size())
if(orowPrAfterBefore.nGridAfter < (long)m_aCurTblGrid.size())
{
double nSumW = 0;
for(int i = 0; i < orowPrAfterBefore.nGridAfter; i++)
@ -2598,7 +2597,7 @@ public:
if ( c_oSerNumTypes::Lvl == type )
{
docLvl* odocLvl = new docLvl();
odocLvl->ILvl = odocANum->Lvls.size();
odocLvl->ILvl = (long)odocANum->Lvls.size();
READ2_DEF(length, res, this->ReadLevel, odocLvl);
odocANum->Lvls.push_back(odocLvl);
}
@ -2832,7 +2831,8 @@ public:
}
else if(c_oSer_sts::Style_Default == type)
{
odocStyle->bDefault = (0 != m_oBufferedStream.GetUChar());
odocStyle->bDefault = true;
odocStyle->Default = m_oBufferedStream.GetBool();
}
else if(c_oSer_sts::Style_BasedOn == type)
{
@ -3893,7 +3893,7 @@ public:
oFile.WriteFile(pData, length);
oFile.CloseFile();
long lId;
unsigned int lId = 0;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), sJsaProject.GetPath(), L"", &lId);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(sJsaProject.GetExtention(false));
}
@ -3970,6 +3970,12 @@ public:
READ1_DEF(length, res, this->ReadMathArg, poResult);
m_oDocumentWriter.m_oContent.WriteString(std::wstring(_T("</m:oMath>")));
}
else if ( c_oSerParType::MRun == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:r>")));
READ1_DEF(length, res, this->ReadMathMRun, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:r>")));
}
else if ( c_oSerParType::Hyperlink == type )
{
CHyperlink oHyperlink;
@ -4520,7 +4526,7 @@ public:
READ1_DEF(length, res, this->ReadParagraphContent, NULL);
if (!pHyperlink->sLink.empty())
{
long rId;
unsigned int rId;
std::wstring sHref = XmlUtils::EncodeXmlString(pHyperlink->sLink);
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink")), sHref, std::wstring(_T("External")), &rId);
pHyperlink->rId = L"rId" + std::to_wstring(rId);
@ -4592,6 +4598,12 @@ public:
READ1_DEF(length, res, this->ReadMathDelimiter, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:d>")));
}
else if ( c_oSer_OMathContentType::Del == type )
{
TrackRevision oTrackRevision;
READ1_DEF(length, res, this->ReadDelIns, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:del"));
}
else if ( c_oSer_OMathContentType::EqArr == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:eqArr>")));
@ -4616,6 +4628,12 @@ public:
READ1_DEF(length, res, this->ReadMathGroupChr, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:groupChr>")));
}
else if ( c_oSer_OMathContentType::Ins == type )
{
TrackRevision oTrackRevision;
READ1_DEF(length, res, this->ReadDelIns, &oTrackRevision);
oTrackRevision.Write(&GetRunStringWriter(), _T("w:ins"));
}
else if ( c_oSer_OMathContentType::LimLow == type )
{
GetRunStringWriter().WriteString(std::wstring(_T("<m:limLow>")));
@ -6871,7 +6889,7 @@ public:
std::wstring sNewImgRel = _T("media/") + sNewImgName;
sNewImgRel = XmlUtils::EncodeXmlString(sNewImgRel);
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")), sNewImgRel, std::wstring(), &rId);
odocImg.srId = L"rId" + std::to_wstring(rId);
//odocImg.srId = m_oMediaWriter.m_poDocumentRelsWriter->AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"), sNewImgRel, false);
@ -7412,7 +7430,7 @@ public:
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
unsigned int rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
@ -7439,7 +7457,7 @@ public:
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
long rIdChart;
unsigned int rIdChart;
std::wstring bstrChartRelType = OOX::FileTypes::Chart.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, sRelsName, std::wstring(), &rIdChart);
@ -8546,7 +8564,7 @@ public:
m_oBufferedStream.Seek(nDocumentOffset);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
long stamdartRId;
unsigned int stamdartRId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml", L"", &stamdartRId);
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", L"settings.xml", L"", &stamdartRId);
@ -8574,19 +8592,19 @@ public:
if(false == m_oFileWriter.m_oNumberingWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", L"numbering.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", L"/word", L"numbering.xml");
}
if(false == m_oFileWriter.m_oFootnotesWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", L"footnotes.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", L"/word", L"footnotes.xml");
}
if(false == m_oFileWriter.m_oEndnotesWriter.IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", L"endnotes.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", L"/word", L"endnotes.xml");
}
@ -8595,7 +8613,7 @@ public:
Writers::HdrFtrItem* pHeader = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[i];
if(false == pHeader->IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", pHeader->m_sFilename, std::wstring(), &rId);
pHeader->rId = L"rId" + std::to_wstring( rId );
@ -8607,7 +8625,7 @@ public:
Writers::HdrFtrItem* pFooter = m_oFileWriter.m_oHeaderFooterWriter.m_aFooters[i];
if(false == pFooter->IsEmpty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", pFooter->m_sFilename, std::wstring(), &rId);
pFooter->rId = L"rId" + std::to_wstring( rId );
@ -8617,7 +8635,7 @@ public:
if(!oSettingsCustom.IsEmpty()){
std::wstring sFilename = m_oFileWriter.m_oCustomXmlWriter.WriteCustomXml(oSettingsCustom.GetSchemaUrl(), oSettingsCustom.ToXml());
std::wstring sRelsPath = L"../" + OOX::FileTypes::CustomXml.DefaultDirectory().GetPath() + L"/" + sFilename;
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXml.RelationType(), sRelsPath, L"", &rId);
}
@ -8638,19 +8656,19 @@ public:
if(false == oCommentsWriter.m_sComment.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", L"comments.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml", L"/word", L"comments.xml");
}
if(false == oCommentsWriter.m_sCommentExt.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word", L"commentsExtended.xml");
}
if(false == oCommentsWriter.m_sPeople.empty())
{
long rId;
unsigned int rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/people", L"people.xml", std::wstring(), &rId);
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml", L"/word", L"people.xml");
}

View File

@ -1438,8 +1438,8 @@ namespace MathEquation
}
else if (eType == commandBrackets)
{
MBRACKETSTYPE ebType;
EndBrackets(ebType, false,false);
MBRACKETSTYPE ebType = MBRACKETSTYPE::bracketsAngle; //???
EndBrackets(ebType, false, false);
}
}
virtual void BeginAngleBracketsWithSeparator(MANGLEBRACKETSWITHSEPARATORTYPE eType)

View File

@ -499,8 +499,8 @@ extern int g_nCurFormatVersion;
MoveToRangeEnd = 21,
JsaProject = 22,
BookmarkStart = 23,
BookmarkEnd = 24
BookmarkEnd = 24,
MRun = 25
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{

View File

@ -3505,6 +3505,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_m_r:
{
OOX::Logic::CMRun* pMRun = static_cast<OOX::Logic::CMRun*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::MRun);
WriteMathRunContent(pMRun);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
default:
break;
}
@ -4114,6 +4122,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_del:
{
OOX::Logic::CDel* pDel = static_cast<OOX::Logic::CDel*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Del);
WriteDel(*pDel);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_m_eqArr:
{
OOX::Logic::CEqArr* pEqArr = static_cast<OOX::Logic::CEqArr*>(item);
@ -4166,6 +4182,14 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_w_ins:
{
OOX::Logic::CIns* pIns = static_cast<OOX::Logic::CIns*>(item);
nCurPos = m_oBcw.WriteItemStart(c_oSer_OMathContentType::Ins);
WriteIns(*pIns);
m_oBcw.WriteItemEnd(nCurPos);
break;
}
case OOX::et_m_limLow:
{
OOX::Logic::CLimLow* pLimLow = static_cast<OOX::Logic::CLimLow*>(item);

View File

@ -282,7 +282,7 @@ namespace BinXlsxRW{
{
OOX::Spreadsheet::CTableColumn* pTableColumn = new OOX::Spreadsheet::CTableColumn();
pTableColumn->m_oId.Init();
pTableColumn->m_oId->SetValue(i + 1);
pTableColumn->m_oId->SetValue((unsigned int)i + 1);
pTableColumn->m_oName.Init();
pTableColumn->m_oName->append(m_aTableNames[i]);
pTable->m_oTable->m_oTableColumns->m_arrItems.push_back(pTableColumn);
@ -604,7 +604,7 @@ namespace BinXlsxRW{
// Не число
aSharedStrings.push_back(val);
pCell->m_oType->SetValue(SimpleTypes::Spreadsheet::celltypeSharedString);
pCell->m_oValue->m_sText = std::to_wstring(aSharedStrings.size() - 1);
pCell->m_oValue->m_sText = std::to_wstring((int)aSharedStrings.size() - 1);
}
else
{
@ -658,7 +658,7 @@ namespace BinXlsxRW{
if(NULL != format)
{
int nXfsIndex = m_aXfs.size();
int nXfsIndex = (int)m_aXfs.size();
boost::unordered_map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
if(itFormat == m_mapFormats.end())

View File

@ -196,7 +196,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
bool bValidFormat = false;
std::wstring sSignature(g_sFormatSignature);
int nSigLength = (int)sSignature.length();
if(nBase64DataSize > nSigLength)
if((int)nBase64DataSize > nSigLength)
{
std::string sCurSig((char*)pBase64Data, nSigLength);
if(sSignature == std::wstring(sCurSig.begin(), sCurSig.end()))

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;
@ -186,7 +186,7 @@ namespace BinXlsxRW{
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
unsigned int rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);

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

@ -95,7 +95,7 @@ namespace formulasconvert {
bool odf2oox_converter::Impl::find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref)
{
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([\\w^0-9\\$]+\\d+)(?::\\.([\\w^0-9]+\\d+)){0,1}\\]");
boost::wsmatch result;
bool b = boost::regex_search(expr, result, re);
@ -211,7 +211,7 @@ namespace formulasconvert {
}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
{
boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)(?::\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)){0,1}");
std::wstring expr = what[1].str();
const std::wstring res = boost::regex_replace(
@ -235,7 +235,7 @@ namespace formulasconvert {
{
convert_with_TableName = withTableName;
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]");
/*
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
*/
@ -252,7 +252,7 @@ namespace formulasconvert {
convert_with_TableName = withTableName;
//boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}");
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}");
const std::wstring res = boost::regex_replace(
expr,
@ -358,35 +358,52 @@ namespace formulasconvert {
return L"";
}
void odf_replace_tmp_back(std::wstring &expr)
{
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
XmlUtils::replace_all( expr, L"VOSKL", L"!");
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( expr, L"PROBEL", L" ");
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
}
void odf_replace_tmp(std::wstring &expr)
{
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
XmlUtils::replace_all( expr, L"!", L"VOSKL");
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
XmlUtils::replace_all( expr, L" ", L"PROBEL");
XmlUtils::replace_all( expr, L"'", L"APOSTROF");
XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
}
std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
odf_replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
odf_replace_tmp(inner);
return inner;
}
else if (what[3].matched)
@ -492,9 +509,9 @@ namespace formulasconvert {
XmlUtils::replace_all( workstr, L"FDIST(", L"_xlfn.F.DIST(");
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
if (std::wstring::npos != workstr.find(L"CONCATINATE"))
{
bool l = true;
//могут быть частично заданы диапазоны
//todooo
}
@ -509,18 +526,7 @@ namespace formulasconvert {
//-----------------------------------------------------------
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"ТОСHKA" , L".");
XmlUtils::replace_all( workstr, L"SCOBCAIN" , L"(");
XmlUtils::replace_all( workstr, L"SCOBCAOUT" , L")");
XmlUtils::replace_all( workstr, L"KVADRATIN" , L"[");
XmlUtils::replace_all( workstr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"KAVYCHKA" , L"\"");
odf_replace_tmp_back(workstr);
return workstr;
}

View File

@ -69,9 +69,42 @@ public:
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::table_name_ = L"";
void oox_replace_tmp_back(std::wstring &expr)
{
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
XmlUtils::replace_all( expr, L"VOSKL", L"!");
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
XmlUtils::replace_all( expr, L"PROBEL", L" ");
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
}
void oox_replace_tmp(std::wstring &expr)
{
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
XmlUtils::replace_all( expr, L"!", L"VOSKL");
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
XmlUtils::replace_all( expr, L" ", L"PROBEL");
XmlUtils::replace_all( expr, L"'", L"APOSTROF");
XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
}
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
{
if ((0 == expr.find(L"KAVYCHKA")) && (expr.length() - 8 == expr.rfind(L"KAVYCHKA") ))
return;
boost::wregex re(L"([:$!])+");
boost::wsmatch result;
@ -79,7 +112,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
if (b)
{
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]*\\d*)\\:?([a-zA-Z$]*\\d*)?");
boost::wregex re1(L"(\\$?\\w+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
@ -111,8 +144,12 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if (!c1.empty() || !c2.empty() || !sheet.empty())
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
{
return c1;
}
else if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
@ -122,9 +159,8 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = std::wstring(L"[") + sheet + L"." +
c1 +
(c2.empty() ? L"" : (L":" + sheet + L"." + c2) ) + std::wstring(L"]");
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
}
return s;
}
@ -178,27 +214,22 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
replace_vertical(workstr);
replace_semicolons(workstr);
std::wstring res1 = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&oox2odf_converter::Impl::convert_scobci, boost::match_default | boost::format_all);
std::vector<std::wstring> distance;
boost::algorithm::split(distance,workstr, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
boost::algorithm::split(distance, res1, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < distance.size(); i++)
{
std::wstring &d = distance[i];
XmlUtils::replace_all( d, L"(", L"SCOBCAIN");
XmlUtils::replace_all( d, L")", L"SCOBCAOUT");
XmlUtils::replace_all( d, L" ", L"PROBEL");
XmlUtils::replace_all( d, L"'", L"APOSTROF");
XmlUtils::replace_all( d, L"\"", L"KAVYCHKA");
replace_cells_range(d);
XmlUtils::replace_all( d, L"SCOBCAIN", L"(");
XmlUtils::replace_all( d, L"SCOBCAOUT", L")");
XmlUtils::replace_all( d, L"PROBEL", L" ");
XmlUtils::replace_all( d, L"APOSTROF", L"'");
XmlUtils::replace_all( d, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(d);
out = out + d + std::wstring(L";");
}
@ -209,11 +240,7 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
if (table_name_.empty() == false)
{
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(table_name_);
}
}
@ -370,32 +397,19 @@ std::wstring replace_(boost::wsmatch const & what)
return L"";
}
std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
oox_replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
XmlUtils::replace_all( inner, L" ", L"PROBEL");
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
oox_replace_tmp(inner);
return inner;
}
else if (what[3].matched)
@ -408,7 +422,7 @@ std::wstring oox2odf_converter::Impl::replace_arguments(boost::wsmatch const &
{
std::wstring out;
int sz = what.size();
size_t sz = what.size();
if (what[1].matched)
{
@ -444,13 +458,13 @@ std::wstring oox2odf_converter::Impl::convert(const std::wstring& expr)
if (is_forbidden1(expr))
return L"NULLFORMULA";
std::wstring workstr = expr;
std::wstring workstr = expr;
replace_cells_range(workstr);
replace_vertical(workstr);
replace_semicolons(workstr);
return workstr;
}
// of:=(Formula) -> (Formula)
// (Formula) -> of:=(Formula)
std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
{
std::wstring workstr = expr;
@ -462,9 +476,13 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
boost::wregex(L"(?!([\\w^0-9]+\\d*\\())(([\\w^0-9]+\\!)?\\$?[\\w^0-9]*\\$?\\d*(\\:\\$?[\\w^0-9]*\\$?\\d*){0,1})"),
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
//SUBTOTAL(109,Expense31[Amount])
XmlUtils::replace_all( res, L"[", L"KVADRATIN");
XmlUtils::replace_all( res, L"]", L"KVADRATOUT");
if (res1 == res)
{
XmlUtils::replace_all( res1, L"KAVYCHKA", L"\""); //IMCONJUGATE_emb.xlsx
@ -476,16 +494,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::match_default | boost::format_all);
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"KVADRATIN", L"[");
XmlUtils::replace_all( res, L"KVADRATOUT", L"]");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
oox_replace_tmp_back(res);
replace_vertical(res);
replace_semicolons(res);
@ -494,17 +503,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
if (table_name_.empty() == false)
{
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
XmlUtils::replace_all( table_name_, L"KVADRATIN", L"[");
XmlUtils::replace_all( table_name_, L"KVADRATOUT", L"]");
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
oox_replace_tmp_back(table_name_);
}
return std::wstring(L"of:=") + res;
@ -533,12 +532,7 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
}
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
XmlUtils::replace_all( res, L"APOSTROF", L"'");
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
oox_replace_tmp_back( res);
replace_vertical(res);
replace_semicolons(res);
@ -568,7 +562,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
boost::algorithm::split(distance_inp,expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (int i = 0; i < distance_inp.size(); i++)
for (size_t i = 0; i < distance_inp.size(); i++)
{
std::wstring sheet;
std::vector<std::wstring> range;
@ -576,7 +570,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
boost::algorithm::split(range, distance_inp[i], boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
for (int j = 0 ; j < range.size(); j++)
for (size_t j = 0 ; j < range.size(); j++)
{
int pos = range[j].find('!');
if (0 <= pos)
@ -588,7 +582,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring cells_out;
for (int c = 0; c < cells.size(); c++)
for (size_t c = 0; c < cells.size(); c++)
{
if (!sheet.empty())
cells_out += sheet + L".";
@ -607,7 +601,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring result;
for (int i = 0 ; i < distance_out.size(); i++)
for (size_t i = 0 ; i < distance_out.size(); i++)
{
result += distance_out[i];
result += L" ";
@ -654,8 +648,6 @@ std::wstring oox2odf_converter::get_table_name()
{
return impl_->table_name_;
}
std::wstring oox2odf_converter::convert_ref(std::wstring const & expr)
{
std::wstring workstr = expr;
@ -743,7 +735,7 @@ int oox2odf_converter::get_count_value_points(std::wstring expr)
XmlUtils::replace_all( expr, L")", L"");
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (long i=0; i < splitted.size(); i++)
for (size_t i=0; i < splitted.size(); i++)
{
int res = splitted[i].find(L"!");
if (res > 0) splitted[i] = splitted[i].substr(res+1, splitted[i].size()-res);

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

@ -42,7 +42,7 @@ std::string ansi_to_utf8(const std::string & _AnsiString)
std::wstring utf8_to_utf16(const std::string & _Utf8String)
{
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_Utf8String.c_str(), _Utf8String.length());
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_Utf8String.c_str(), (LONG)_Utf8String.length());
}
std::string utf16_to_utf8(const std::wstring & _Utf16String)

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,54 +128,7 @@ 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),
@ -290,7 +243,7 @@ void docx_conversion_context::finish_paragraph()
output_stream() << L"</w:p>";
}
in_header_ = false;
in_header_ = false;
state_.is_paragraph_keep_ = false;
state_.in_paragraph_ = false;
}
@ -636,12 +589,17 @@ void docx_conversion_context::reset_context_state()
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)
@ -1136,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);
@ -1611,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);
@ -1803,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);

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,7 +756,7 @@ public:
void add_element_to_run (std::wstring parenStyleId = _T(""));
void finish_run ();
void add_new_run (std::wstring parentStyleId = _T(""));
void add_new_run (std::wstring parentStyleId = _T(""));
void start_paragraph (bool is_header = false);
void finish_paragraph ();
@ -936,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);
@ -981,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_;
@ -1003,6 +964,8 @@ private:
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_;
@ -1029,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_;

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

@ -98,7 +98,7 @@ double docx_table_state::get_current_cell_width()
{
//return columns_width_[current_table_column_];
double res = 0;
for (int i = 0; i < columns_spanned_num_ + 1; i++)
for (unsigned int i = 0; i < columns_spanned_num_ + 1; i++)
{
res += columns_width_[current_table_column_ + i];
}

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

@ -108,6 +108,8 @@ static const std::wstring _ooxShapeType[]=
L"custGeom",//uses sub-sub type,
L"polygon",
L"roundRect",
L"bentConnector3",
L"curvedConnector3"
};
@ -124,8 +126,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 +151,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 +182,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);
@ -235,16 +245,16 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
{
names.push_back(L"adj1");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
{
names.push_back(L"hf");
names.push_back(L"vf");
}
//else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
//{
// names.push_back(L"vf");
//}
//else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
// std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
//{
// names.push_back(L"hf");
// names.push_back(L"vf");
//}
else if (std::wstring::npos != shapeGeomPreset.find(L"hexagon"))
{
names.push_back(L"adj");
@ -268,20 +278,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]);
}
}
}
@ -410,7 +420,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
shapeGeomPreset = L"rect";
}
}
else if (sub_type < 10 && sub_type >= 0)
else if (sub_type <= 12 && sub_type >= 0)
{
shapeGeomPreset = _ooxShapeType[sub_type]; //odf -> oox
}

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

@ -37,9 +37,9 @@
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true), bGrayscale(false)
{
memset(cropRect,0,sizeof(double)*4);
memset(cropRect, 0, sizeof(double)*4);
}
oox_bitmap_fill_ptr oox_bitmap_fill::create(){return boost::make_shared<oox_bitmap_fill>();}
@ -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,42 @@ 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->bGrayscale)
{
CP_XML_NODE(ns + L":grayscl");
}
}
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 +282,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++)
for (size_t 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 +313,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 +339,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 +396,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

@ -70,6 +70,7 @@ namespace oox {
bool bStretch;
bool bCrop;
bool bTile;
bool bGrayscale;
double cropRect[4];//0-left, 1 -top, 2- right, 3 - bottom
@ -143,10 +144,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

@ -39,7 +39,7 @@ namespace oox {
void oox_chart::set_cache_only (bool val)
{
for (int i = 0 ; i < series_.size(); i++)
for (size_t i = 0 ; i < series_.size(); i++)
{
series_[i]->set_cache_only(val);
}

View File

@ -212,7 +212,7 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
}
CP_XML_NODE(L"p:cNvSpPr")//non visual properies (собственно тока 1 там)
{
if (val.sub_type==1 || val.sub_type==2)CP_XML_ATTR(L"txBox", 1);
if (val.sub_type == 1 || val.sub_type == 2)CP_XML_ATTR(L"txBox", 1);
CP_XML_NODE(L"a:spLocks")
{
CP_XML_ATTR(L"noGrp", 1);
@ -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

@ -538,8 +538,11 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
_CP_OPT(std::wstring) sTextContent, sColorMode;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = typeShape;
@ -549,6 +552,9 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL);
drawing.fill.bitmap->bStretch = true;
if ((sColorMode) && (*sColorMode == L"greyscale"))
drawing.fill.bitmap->bGrayscale = true;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;/// это ссылка на выходной внешний объект

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

@ -62,7 +62,7 @@ public:
CP_XML_NODE(L"authors")
{
for (int i = 0 ; i < author_list_.size(); i++)
for (size_t i = 0 ; i < author_list_.size(); i++)
{
const std::wstring & a = author_list_[i];
CP_XML_NODE(L"author")
@ -74,7 +74,7 @@ public:
CP_XML_NODE(L"commentList")
{
for (int i = 0 ; i < xlsx_comment_.size(); i++)
for (size_t i = 0 ; i < xlsx_comment_.size(); i++)
{
const _xlsx_comment & c = xlsx_comment_[i];
@ -107,7 +107,7 @@ public:
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
for (int i = 0; i < xlsx_comment_.size(); i++)
for (size_t i = 0; i < xlsx_comment_.size(); i++)
{
const _xlsx_comment & c = xlsx_comment_[i];
@ -222,7 +222,7 @@ public:
void add(_xlsx_comment & c)
{
bool find = false;
for (long i = 0; i < author_list_.size(); i++)
for (size_t i = 0; i < author_list_.size(); i++)
{
if (c.author_ == author_list_[i])
{

View File

@ -36,8 +36,10 @@
#include <vector>
#include <boost/lexical_cast.hpp>
#include <xml/simple_xml_writer.h>
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../formulasconvert/formulasconvert.h"
namespace cpdoccore {
namespace oox {
@ -148,7 +150,10 @@ public:
//CP_XML_ATTR(L"aboveAverage" , 0);
if (c.rules[j].type == 1)
{
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
if (c.rules[j].formula_type)
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
else
CP_XML_ATTR(L"type", L"cellIs");
if ((c.rules[j].formula) && (!c.rules[j].formula->empty()))
{
CP_XML_NODE(L"formula")
@ -177,13 +182,11 @@ public:
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
if (c.rules[j].color.size() > 0)
CP_XML_NODE(L"color")
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"rgb", c.rules[j].color[0]);
}
}
CP_XML_ATTR(L"rgb", !c.rules[j].color.empty() ? c.rules[j].color[0] : L"FF000000");
}
}
}
else if (c.rules[j].type == 3)
@ -245,7 +248,7 @@ void xlsx_conditionalFormatting_context::add(std::wstring ref)
formulasconvert::odf2oox_converter converter;
impl_->conditionalFormattings_.push_back(conditionalFormatting());
impl_->conditionalFormattings_.back().ref = converter.convert_named_ref(ref, false, L";");
impl_->conditionalFormattings_.back().ref = converter.convert_named_ref(ref, false, L" ");
}
void xlsx_conditionalFormatting_context::add_rule(int type)
@ -260,7 +263,21 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
int pos = -1;
std::wstring val;
if ( 0 <= (pos = f.find(L"formula-is(")))
if ( f == L"unique")
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"uniqueValues";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else if ( f == L"duplicate")
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else if ( f == L"above-average")
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"aboveAverage";
}
else if ( 0 <= (pos = f.find(L"formula-is(")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
val = f.substr(11, f.size() - 12);
@ -292,6 +309,45 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
std::wstring text = f.substr(14, f.length() - 15);
if (std::wstring::npos != text.find(L"IF(") ||
std::wstring::npos != text.find(L"AND(") ||
std::wstring::npos != text.find(L"NOT(") ||
std::wstring::npos != text.find(L"ISERROR(") ||
std::wstring::npos != text.find(L"SEARCH("))
{
impl_->conditionalFormattings_.back().rules.back().text = L"";
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert(text);
}
else if (std::wstring::npos != text.find(L"LEN(TRIM(") &&
std::wstring::npos != text.find(L"=0"))
{
impl_->conditionalFormattings_.back().rules.back().text = L"";
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
}
else
{
impl_->conditionalFormattings_.back().rules.back().operator_ = L"containsText";
if ( 0 == text.find(L"\"") && text.length() - 1 == text.rfind(L"\""))
{
text = text.substr(1, text.length() - 2);
}
std::wstring ref = impl_->conditionalFormattings_.back().ref;
size_t pos;
if ((pos = ref.find(L":")) != std::wstring::npos)
{
ref = ref.substr(0, pos);
}
impl_->conditionalFormattings_.back().rules.back().text = text;
impl_->conditionalFormattings_.back().rules.back().formula = L"NOT(ISERROR(SEARCH(\"" + text + L"\"," + ref + L")))";
}
}
else if (0 <= (pos = f.find(L"top")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
@ -302,14 +358,10 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
if (0 <= (pos = f.find(L"(")))
{
val = f.substr(pos + 1, f.length() - pos - 2);
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
if (!val.empty())
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
}
}
else if (0 <= (pos = f.find(L"contains-text")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
}
else
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs";
@ -361,6 +413,8 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
impl_->conditionalFormattings_.back().rules.back().operator_ = L"between";
val = f.substr(8, f.length() - 9);
XmlUtils::replace_all(val, L"(", L"");
XmlUtils::replace_all(val, L")", L"");
if (0 <= (pos = val.find(L",")))
{
impl_->conditionalFormattings_.back().rules.back().formula2 = converter.convert_named_expr( val.substr(pos + 1) );
@ -398,7 +452,11 @@ void xlsx_conditionalFormatting_context::add_sfv(int type, std::wstring value)
impl_->conditionalFormattings_.back().rules.back().formula.reset();
}
else if (!value.empty()) cfvo.val = value;
else
{
if (!value.empty()) cfvo.val = value;
else cfvo.val = L"0";
}
impl_->conditionalFormattings_.back().rules.back().cfvo.push_back(cfvo);
}

View File

@ -78,7 +78,7 @@ public:
{
CP_XML_NODE(L"definedNames")
{
for (int i = 0 ; i < content_.size(); i++)
for (size_t i = 0 ; i < content_.size(); i++)
{
CP_XML_NODE(L"definedName")
{

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

@ -202,20 +202,25 @@ void xlsx_drawing_context::end_group()
{
if (impl_->groups_.size() < 1) return;
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
group_rect.cy -= group_rect.y;
group_rect.cx -= group_rect.x;
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
if (impl_->groups_.back()->svg_rect_)
{
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
r.y -= group_rect.y;
r.x -= group_rect.x;
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
group_rect.cy -= group_rect.y;
group_rect.cx -= group_rect.x;
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
{
if (!impl_->groups_.back()->child_objects_[i].svg_rect_) continue;
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
r.y -= group_rect.y;
r.x -= group_rect.x;
}
}
if (impl_->groups_.back()->in_group_)
if (impl_->groups_.back()->in_group_ && impl_->groups_.back()->svg_rect_)
{
_rect & objct_rect = impl_->groups_.back()->svg_rect_.get();
@ -251,7 +256,8 @@ void xlsx_drawing_context::start_drawing(std::wstring const & name)
void xlsx_drawing_context::end_drawing()
{
if (impl_->object_description_.in_group_)
if (impl_->object_description_.in_group_ &&
impl_->object_description_.svg_rect_)
{
_rect & objct_rect = impl_->object_description_.svg_rect_.get();
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
@ -297,6 +303,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");
@ -528,8 +539,10 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
}
_CP_OPT(std::wstring) sTextContent;
GetProperty(obj.additional_,L"text-content",sTextContent);
_CP_OPT(std::wstring) sTextContent, sColorMode;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
@ -541,6 +554,9 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL/*applicationFonts_*/);
drawing.fill.bitmap->bStretch = true;
if ((sColorMode) && (*sColorMode == L"greyscale"))
drawing.fill.bitmap->bGrayscale = true;
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
@ -575,15 +591,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 +615,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 +703,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

@ -104,7 +104,7 @@ public:
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(CP_XML_STREAM());
}
@ -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

@ -90,7 +90,7 @@ void xlsx_dxfs::serialize(std::wostream & _Wostream) const
{
CP_XML_ATTR(L"count", impl_->dxf_array.size());
for (int i = 0; i < impl_->dxf_array.size(); i++)
for (size_t i = 0; i < impl_->dxf_array.size(); i++)
{
CP_XML_NODE(L"dxf")
{

View File

@ -65,7 +65,7 @@ public:
{
CP_XML_ATTR(L"count", merges_.size());
for (int i = 0 ; i < merges_.size(); i++)
for (size_t i = 0 ; i < merges_.size(); i++)
{
merge & m = merges_[i];

View File

@ -52,12 +52,14 @@ public:
std::wstringstream hyperlinks_;
std::wstringstream comments_;
std::wstringstream sort_;
std::wstringstream tableParts_;
std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
std::wstringstream picture_background_;
std::wstringstream dataValidations_;
std::wstringstream ole_objects_;
std::wstringstream page_props_;
std::wstringstream controls_;
rels sheet_rels_;
@ -98,16 +100,18 @@ std::wostream & xlsx_xml_worksheet::sheetFormat()
{
return impl_->sheetFormat_;
}
std::wostream & xlsx_xml_worksheet::sheetData()
{
return impl_->sheetData_;
}
std::wostream & xlsx_xml_worksheet::mergeCells()
{
return impl_->mergeCells_;
}
std::wostream & xlsx_xml_worksheet::tableParts()
{
return impl_->tableParts_;
}
std::wostream & xlsx_xml_worksheet::conditionalFormatting()
{
return impl_->conditionalFormatting_;
@ -136,6 +140,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,19 +211,33 @@ 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")
{
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
}
}
if (!impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{
CP_XML_STREAM() << impl_->tableParts_.str();
}
}
if (!impl_->ole_objects_.str().empty())
{
CP_XML_NODE(L"oleObjects")
{
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

@ -60,12 +60,14 @@ public:
std::wostream & drawing();
std::wostream & comments();
std::wostream & autofilter();
std::wostream & tableParts();
std::wostream & conditionalFormatting();
std::wostream & picture_background();
std::wostream & dataValidations();
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");
}
@ -240,6 +244,10 @@ void xl_files::write(const std::wstring & RootPath)
{
charts_files_.set_main_document(get_main_document());
charts_files_.write(path);
}
{
table_part_files_.set_main_document(get_main_document());
table_part_files_.write(path);
}
if (drawings_)
{
@ -318,10 +326,18 @@ void xl_files::add_pivot_table(pivot_table_content_ptr pivot_table)
{
pivot_table_files_.add_pivot_table(pivot_table);
}
void xl_files::add_table_part(const std::wstring &content)
{
table_part_files_.add_table_part(content);
}
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 +348,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 +400,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";
@ -410,22 +426,44 @@ void xl_pivot_table_files::write(const std::wstring & RootPath)
}
}
//------------------------------------------------------------------------------------------------------
void xl_table_part_files::add_table_part(const std::wstring & table_part)
{
table_parts_.push_back(table_part);
}
void xl_table_part_files::write(const std::wstring & RootPath)
{
if (table_parts_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"tables";
NSDirectory::CreateDirectory(path.c_str());
for (size_t i = 0; i < table_parts_.size(); i++)
{
const std::wstring fileName = std::wstring(L"table") + std::to_wstring(i + 1) + L".xml";
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
contentTypes->add_override(std::wstring(L"/xl/tables/") + fileName, kWSConType);
package::simple_element(fileName, table_parts_[i]).write(path);
}
}
//------------------------------------------------------------------------------------------------------
void xl_charts_files::add_chart(chart_content_ptr chart)
{
charts_.push_back(chart);
}
void xl_charts_files::write(const std::wstring & RootPath)
{
if (charts_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
NSDirectory::CreateDirectory(path.c_str());
size_t count = 0;
for (size_t i = 0; i < charts_.size(); i++)
{
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 +478,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 +528,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 +548,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

@ -131,7 +131,17 @@ public:
};
class xl_table_part_files : public element
{
public:
xl_table_part_files(){}
void add_table_part(const std::wstring & table_part);
virtual void write(const std::wstring & RootPath);
std::vector<std::wstring> table_parts_;
};
class xl_charts_files : public element
{
public:
@ -211,13 +221,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 +253,8 @@ 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);
void add_table_part (const std::wstring &content);
private:
rels_files rels_files_;
@ -240,7 +262,9 @@ 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_;
xl_table_part_files table_part_files_;
element_ptr theme_;
element_ptr workbook_;

View File

@ -540,7 +540,7 @@ void xlsx_pivots_context::Impl::sort_fields()
}
else
{
if (count_items_row < current_.fields[i].caches.size())
if (count_items_row < (int)current_.fields[i].caches.size())
bAddRepeateRow = true;
}
}
@ -772,7 +772,7 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{
int fld = 0, ind_fld = current_.fields[ind_field_dirty].references_field < 0 ? ind_field_dirty :
current_.fields[ind_field_dirty].references_field;
for (size_t k = 0; k < ind_fld; k++)
for (int k = 0; k < ind_fld; k++)
{
if (current_.fields[k].type != 7 ) fld++;
}
@ -815,7 +815,7 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
}
std::wstring name;
if (ind_field_dirty >= 0 && ind_field_dirty < current_.fields.size())
if (ind_field_dirty >= 0 && ind_field_dirty < (int)current_.fields.size())
{
switch(current_.fields[ind_field_dirty].function)
{
@ -1470,7 +1470,7 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value, bool sh
if (index < 0)
index = impl_->current_.fields.back().caches.size();
while (index > impl_->current_.fields.back().caches.size())
while (index > (int)impl_->current_.fields.back().caches.size())
{
Impl::_field_value f(L"", L"m", true);

View File

@ -68,7 +68,7 @@ public:
{
double length_pt =0;
for (int i = 0; i < region_.size(); i++)
for (size_t i = 0; i < region_.size(); i++)
{
region & r = region_[i];
if (cell <= r.start_cell + r.count)
@ -102,7 +102,7 @@ public:
if (pos < 0)//cs102.ods
{
int c_skip = 0, i = 0;
for (i = 0; i < region_.size(); i++)
for (i = 0; i < (int)region_.size(); i++)
{
if (region_[i].count + c_skip > offset)
break;
@ -119,7 +119,7 @@ public:
}
for (int i = 0; i < region_.size(); i++)
for (size_t i = 0; i < region_.size(); i++)
{
region & r = region_[i];
if (r.start_cell + r.count <= offset)
@ -172,7 +172,7 @@ public:
}
std::pair<int, double> search(double pos)
{
for (int i = 0; i < region_.size(); i++)
for (size_t i = 0; i < region_.size(); i++)
{
region & r = region_[i];

View File

@ -134,10 +134,21 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false),
bEndTable(false)
bEndTable_(false),
bRTL_(false)
{
memset(&group_row_,0,sizeof(_group_row));
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = context_->root()->odf_context().styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
if ((tableStyle) && (tableStyle->content()))
table_prop = tableStyle->content()->get_style_table_properties();
if ((table_prop) && (table_prop->content().common_writing_mode_attlist_.style_writing_mode_))
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
bRTL_ = true;
}
}
void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
@ -149,6 +160,11 @@ void xlsx_table_state::start_column(unsigned int repeated, const std::wstring &
columns_.push_back(repeated);
}
void xlsx_table_state::set_rtl(bool val)
{
bRTL_ = val;
}
unsigned int xlsx_table_state::columns_count() const
{
return columns_count_;
@ -195,7 +211,7 @@ std::wstring xlsx_table_state::default_row_cell_style() const
std::wstring xlsx_table_state::default_column_cell_style() const
{
if (current_table_column_ + 1 < column_default_cell_style_name_.size())
if (current_table_column_ + 1 < (int)column_default_cell_style_name_.size())
return column_default_cell_style_name_.at(current_table_column_ + 1);
else
{
@ -224,10 +240,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
xlsx_merge_cells_.add_merge(current_table_column_, current_table_row_, columnsSpanned, rowsSpanned);
}
if ( current_columns_spaned() > 0 )
{
_CP_LOG << L"[warning] current columns spanned > 0\n";
}
//if ( current_columns_spaned() > 0 )
//{
// _CP_LOG << L"[warning] current columns spanned > 0\n";
//}
columns_spanned_num_ = static_cast<int>(columnsSpanned);
@ -241,16 +257,16 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
rows_spanned_.push_back(xlsx_row_spanned());
}
if (rows_spanned_.size() <= current_table_column_)
if ((int)rows_spanned_.size() <= current_table_column_)
{
_CP_LOG << L"[warning] set_rows_spanned error\n";
}
else
{
if (rows_spanned_[current_table_column_].num() > 0)
{
_CP_LOG << L"[warning] current rows spanned > 0\n";
}
//if (rows_spanned_[current_table_column_].num() > 0)
//{
// _CP_LOG << L"[warning] current rows spanned > 0\n";
//}
rows_spanned_[current_table_column_].num(static_cast<unsigned int>(rowsSpanned));
rows_spanned_[current_table_column_].column_spanned(static_cast<unsigned int>(columnsSpanned));
for (size_t i = 0; i <= columns_spanned_num_; ++i)
@ -421,6 +437,9 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
CP_XML_ATTR(L"workbookViewId", 0);
if (bRTL_)
CP_XML_ATTR(L"rightToLeft", 1);
std::wstring s_col, s_row;
for (int i = 0; i < odfContext.Settings().get_table_view_count(0, tableName_); i++)
{
@ -458,7 +477,6 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
}
}
// -showRowColHeaders
// -rightToLeft
}
double default_height = (2 * context_->getMaxDigitSize().second * 72. / 96. * 100.) /100.;//in point size.
@ -492,6 +510,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

@ -53,6 +53,36 @@ typedef _CP_PTR(xlsx_table_state) xlsx_table_state_ptr;
class xlsx_data_range;
typedef _CP_PTR(xlsx_data_range) xlsx_data_range_ptr;
class xlsx_data_range_values;
typedef _CP_PTR(xlsx_data_range_values) xlsx_data_range_values_ptr;
class xlsx_data_range_values
{
public:
xlsx_data_range_values(size_t row, size_t col1, size_t col2) : withHeader(false), filter(false), row_header(row), start_column(col1), end_column(col2)
{
for (size_t i = start_column; i <= end_column; i++)
values.push_back(L"");
}
size_t row_header;
size_t start_column;
size_t end_column;
bool withHeader;
bool filter;
std::vector<std::wstring> values;
void set_value(size_t col, size_t row, const std::wstring& value)
{
while (col - start_column + 1 >= values.size())
values.push_back(L"");
values[col - start_column] = value;
}
bool in_range(size_t col, size_t row) {return (row_header == row && (col >= start_column && col <= end_column));}
};
class xlsx_data_range
{
@ -70,7 +100,7 @@ public:
bool filter;
bool withHeader;
std::vector<std::pair<int, bool>> bySort; //field + order
std::vector<std::pair<size_t, bool>> bySort; //field + order
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
@ -82,6 +112,8 @@ public:
xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName, int tableId);
std::wstring current_style() const { return table_style_; }
void set_rtl(bool val);
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
@ -92,8 +124,8 @@ public:
void add_empty_row(int count);
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
void set_end_table(){ bEndTable_ = true; }
bool get_end_table(){ return bEndTable_; }
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
@ -134,6 +166,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);
@ -146,17 +179,18 @@ public:
struct _group_row
{
bool enabled;
int count;
int level;
bool collapsed;
bool enabled = false;
int count = 0;
int level = 0;
bool collapsed = false;
}group_row_;
friend class xlsx_conversion_context;
friend class xlsx_table_context;
private:
bool bEndTable;
bool bRTL_;
bool bEndTable_;
xlsx_conversion_context * context_;
std::wstring tableName_;

View File

@ -66,11 +66,11 @@ void xlsx_table_context::start_database_range(std::wstring tableName, std::wstri
ref = convert.convert_named_ref(ref);
std::wstring ref1, ref2;
int pos = ref.find(L":");
size_t pos = ref.find(L":");
std::wstring xlsx_table_name;
if (pos >= 0)
if (pos != std::wstring::npos)
{
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
xlsx_data_ranges_.back()->table_name = tableName;
@ -90,13 +90,15 @@ void xlsx_table_context::start_database_range(std::wstring tableName, std::wstri
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
size_t col, row;
size_t col1, col2, row1, row2;
getCellAddressInv(ref1, col, row);
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col,row);
getCellAddressInv(ref1, col1, row1);
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col1, row1);
getCellAddressInv(ref2, col, row);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col,row);
getCellAddressInv(ref2, col2, row2);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col2, row2);
xlsx_data_ranges_values_.push_back(xlsx_data_range_values_ptr(new xlsx_data_range_values(row1, col1, col2)));
}
if (!xlsx_table_name.empty())
@ -117,17 +119,42 @@ void xlsx_table_context::set_database_header (bool val)
if (xlsx_data_ranges_.empty()) return;
xlsx_data_ranges_.back()->withHeader = val;
xlsx_data_ranges_values_.back()->withHeader = val;
}
void xlsx_table_context::set_database_filter (bool val)
{
if (xlsx_data_ranges_.empty()) return;
xlsx_data_ranges_.back()->filter = val;
xlsx_data_ranges_values_.back()->filter = val;
}
void xlsx_table_context::end_database_range()
{
}
void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
{
size_t col = state()->current_column();
size_t row = state()->current_row();
xlsx_data_ranges_values_[index]->set_value(col, row, value);
}
int xlsx_table_context::in_database_range()
{
int col = state()->current_column();
int row = state()->current_row();
for (size_t i = 0; i < xlsx_data_ranges_values_.size(); i++)
{
if ((xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)
&& xlsx_data_ranges_values_[i]->in_range(col, row))
{
return (int)i;
}
}
return -1;
}
void xlsx_table_context::add_database_sort(int field_number, int order)
{
xlsx_data_ranges_.back()->bySort.push_back(std::pair<int, bool>(field_number, order == 1 ? false : true ));
@ -258,6 +285,83 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
}
}
void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels & Rels)
{
if (xlsx_data_ranges_.empty()) return;
std::pair<std::multimap<std::wstring, int>::iterator, std::multimap<std::wstring, int>::iterator> range;
range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
std::wstring rId = L"tprtId" + std::to_wstring(id);
std::wstring ref = L"../tables/table" + std::to_wstring(id) + L".xml";
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"tablePart")
{
CP_XML_ATTR(L"r:id", rId);
}
}
Rels.add( relationship(rId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", ref));
std::wstringstream strm;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"table")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"id", id);
CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->table_name);
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->table_name);
CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
if (xlsx_data_ranges_[it->second]->withHeader == false &&
xlsx_data_ranges_[it->second]->filter == false)
CP_XML_ATTR(L"headerRowCount", 0);
CP_XML_ATTR(L"totalsRowCount", 0);
CP_XML_ATTR(L"totalsRowShown", 0);
xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
xlsx_data_ranges_[it->second]->serialize_sort(CP_XML_STREAM());
CP_XML_NODE(L"tableColumns")
{
CP_XML_ATTR(L"count", xlsx_data_ranges_[it->second]->cell_end.first -
xlsx_data_ranges_[it->second]->cell_start.first + 1);
for (int id = 0, i = xlsx_data_ranges_[it->second]->cell_start.first; i <= xlsx_data_ranges_[it->second]->cell_end.first; i++, id++)
{
CP_XML_NODE(L"tableColumn")
{
std::wstring column_name = xlsx_data_ranges_values_[it->second]->values[id];
if (column_name.empty())
{
column_name = L"Column_" + std::to_wstring(id + 1);
}
CP_XML_ATTR(L"id", id + 1);
CP_XML_ATTR(L"name", column_name);
}
}
}
CP_XML_NODE(L"tableStyleInfo")
{
CP_XML_ATTR(L"showFirstColumn", 0);
CP_XML_ATTR(L"showLastColumn", 0);
CP_XML_ATTR(L"showRowStripes", 1);
CP_XML_ATTR(L"showColumnStripes", 0);
}
}
}
xlsx_conversion_context_->add_table_part(strm.str());
}
}
void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
{
if (xlsx_data_ranges_.empty()) return;
@ -336,6 +440,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

@ -82,6 +82,7 @@ public:
unsigned int columns_count();
void serialize_tableParts (std::wostream & _Wostream, rels & Rels);
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
@ -89,6 +90,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);
@ -118,15 +120,17 @@ public:
void add_database_sort (int field_number, int order);
void end_database_range();
int in_database_range();
void set_database_range_value(int index, const std::wstring& value);
private:
xlsx_conversion_context *xlsx_conversion_context_;
xlsx_text_context &xlsx_text_context_;
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
std::vector<xlsx_data_range_values_ptr> xlsx_data_ranges_values_;
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
};

View File

@ -71,7 +71,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
math_context_ (odf_document_->odf_context().fontContainer(), true),
xlsx_style_ (this),
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),
maxDigitSize_ (std::make_pair(-1.f, -1.f) ),
default_style_ ( (std::numeric_limits<size_t>::max)() ),
mediaitems_ (odf_document_->get_folder()),
xlsx_drawing_context_handle_(mediaitems_)
@ -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();
@ -199,6 +201,10 @@ void xlsx_conversion_context::end_document()
output_document_->get_xl_files().add_charts(content);
}
for (size_t i = 0; i < table_parts_.size(); i++)
{
output_document_->get_xl_files().add_table_part(table_parts_[i]);
}
//workbook_content << L"<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.0001\" />";
{
@ -434,8 +440,9 @@ void xlsx_conversion_context::end_table()
get_table_context().serialize_table_format (current_sheet().sheetFormat());
get_table_context().serialize_page_properties (current_sheet().page_properties());
get_table_context().serialize_conditionalFormatting (current_sheet().conditionalFormatting());
get_table_context().serialize_autofilter (current_sheet().autofilter());
get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_tableParts (current_sheet().tableParts(), current_sheet().sheet_rels());
//get_table_context().serialize_autofilter (current_sheet().autofilter());
//get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
get_table_context().serialize_data_validation (current_sheet().dataValidations());
@ -444,7 +451,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 +507,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)
{
@ -633,19 +652,36 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
odf_reader::odf_read_context & odfContext = root()->odf_context();
instances.push_back(odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell));
instances.push_back(odfContext.styleContainer().style_by_name(L"Default",odf_types::style_family::TableCell,false));
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
if (textFormatProperties.style_font_name_)
font_name = textFormatProperties.style_font_name_.get();
else if (textFormatProperties.style_font_name_complex_)
font_name = textFormatProperties.style_font_name_complex_.get();
else if (textFormatProperties.style_font_name_asian_)
font_name = textFormatProperties.style_font_name_asian_.get();
odf_reader::style_instance *inst = odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell);
if (inst) instances.push_back(inst);
inst = odfContext.styleContainer().style_by_name(L"Default", odf_types::style_family::TableCell, false);
if (inst) instances.push_back(inst);
else
font_name = L"Arial";
{
inst = odfContext.styleContainer().style_by_name(L"Normal", odf_types::style_family::TableCell, false);
if (inst) instances.push_back(inst);
}
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
if (textFormatProperties.fo_font_family_)
font_name = textFormatProperties.fo_font_family_.get();
else
{
std::wstring style_font_name;
if (textFormatProperties.style_font_name_) style_font_name = textFormatProperties.style_font_name_.get();
else if (textFormatProperties.style_font_name_complex_) style_font_name = textFormatProperties.style_font_name_complex_.get();
else if (textFormatProperties.style_font_name_asian_) style_font_name = textFormatProperties.style_font_name_asian_.get();
odf_reader::fonts_container & fonts = odf_document_->odf_context().fontContainer();
odf_reader::font_instance * font = fonts.font_by_style_name(style_font_name);
if (font)
{
font_name = font->name();
}
}
if (font_name.empty()) font_name = L"Arial";
if ((textFormatProperties.fo_font_size_) && (textFormatProperties.fo_font_size_->get_type() == odf_types::font_size::Length))
font_size = (int)(0.5 + textFormatProperties.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));

View File

@ -158,6 +158,11 @@ 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);
void add_table_part(const std::wstring & table) {table_parts_.push_back(table);}
size_t get_table_parts_size() {return table_parts_.size();}
//------------------------------------------------------------------------------------
odf_reader::odf_document * root()
@ -172,8 +177,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_; }
@ -203,23 +209,28 @@ private:
std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_;
std::vector<std::wstring> table_parts_;
std::wstringstream defaultOutput_;
std::pair<float,float> maxDigitSize_;
num_format_context num_format_context_;
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_)
{
@ -748,6 +744,9 @@ void process_build_object::visit(chart_title& val)
if (val.attlist_.common_draw_position_attlist_.svg_x_)
{
t.pos_x = val.attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
}
if (val.attlist_.common_draw_position_attlist_.svg_y_)
{
t.pos_y = val.attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
}
t.bEnabled = true;
@ -1058,7 +1057,7 @@ void process_build_object::visit(table_table_cell& val)
if (cell_cash.empty())
cell_cash = cell_val;
object_odf_context::_cell cell_= {object_odf_context_.current_table_column_, object_odf_context_.current_table_row_, cell_cash};
object_odf_context::_cell cell_= {(size_t)object_odf_context_.current_table_column_, (size_t)object_odf_context_.current_table_row_, cell_cash};
object_odf_context_.cash_values.push_back(cell_);

View File

@ -101,8 +101,8 @@ class object_odf_context
public:
struct _cell
{
int col;
int row;
size_t col;
size_t row;
std::wstring val;
};

View File

@ -106,6 +106,13 @@ void common_draw_fill_attlist::add_attributes( const xml::attributes_wc_ptr & At
CP_APPLY_ATTR(L"draw:fill-image-width", draw_fill_image_width_);
CP_APPLY_ATTR(L"draw:fill-image-height", draw_fill_image_height_);
CP_APPLY_ATTR(L"draw:color-mode", draw_color_mode_);
CP_APPLY_ATTR(L"draw:contrast", draw_contrast_);
CP_APPLY_ATTR(L"draw:luminance", draw_luminance_);
CP_APPLY_ATTR(L"draw:gamma", draw_gamma_);
CP_APPLY_ATTR(L"draw:red", draw_red_);
CP_APPLY_ATTR(L"draw:green", draw_green_);
CP_APPLY_ATTR(L"draw:blue", draw_blue_);
}
void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
{
@ -130,6 +137,13 @@ void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
CP_XML_ATTR_OPT(L"draw:fill-image-width", draw_fill_image_width_);
CP_XML_ATTR_OPT(L"draw:fill-image-height", draw_fill_image_height_);
CP_XML_ATTR_OPT(L"draw:color-mode", draw_color_mode_);
CP_XML_ATTR_OPT(L"draw:contrast", draw_contrast_);
CP_XML_ATTR_OPT(L"draw:luminance", draw_luminance_);
CP_XML_ATTR_OPT(L"draw:gamma", draw_gamma_);
CP_XML_ATTR_OPT(L"draw:red", draw_red_);
CP_XML_ATTR_OPT(L"draw:green", draw_green_);
CP_XML_ATTR_OPT(L"draw:blue", draw_blue_);
}
void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other)
@ -150,6 +164,14 @@ void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other
_CP_APPLY_PROP2(draw_fill_image_width_);
_CP_APPLY_PROP2(draw_fill_image_height_);
_CP_APPLY_PROP2(draw_color_mode_);
_CP_APPLY_PROP2(draw_contrast_);
_CP_APPLY_PROP2(draw_luminance_);
_CP_APPLY_PROP2(draw_gamma_);
_CP_APPLY_PROP2(draw_red_);
_CP_APPLY_PROP2(draw_green_);
_CP_APPLY_PROP2(draw_blue_);
}
void common_horizontal_margin_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )

View File

@ -111,6 +111,14 @@ public:
_CP_OPT(length_or_percent) draw_fill_image_width_;
_CP_OPT(length_or_percent) draw_fill_image_height_;
_CP_OPT(std::wstring) draw_color_mode_;
_CP_OPT(odf_types::percent) draw_contrast_;
_CP_OPT(odf_types::percent) draw_luminance_;
_CP_OPT(odf_types::percent) draw_gamma_;
_CP_OPT(odf_types::percent) draw_red_;
_CP_OPT(odf_types::percent) draw_green_;
_CP_OPT(odf_types::percent) draw_blue_;
};
// common-horizontal-margin-attlist

View File

@ -79,8 +79,8 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"up-down-arrow-callout" ,L"upDownArrowCallout" ,0 ,0 ,0 },
{L"quad-arrow-callout" ,L"quadArrowCallout" ,0 ,0 ,0 },
{L"circular-arrow" ,L"circularArrow" ,0 ,0 ,0 },
{L"can" ,L"lightningBolt" ,0 ,0 ,0 },
{L"lightning" ,L"can" ,0 ,0 ,0 },
{L"can" ,L"can" ,0 ,0 ,0 },
{L"lightning" ,L"lightningBolt" ,0 ,0 ,0 },
{L"heart" ,L"heart" ,0 ,0 ,0 },
{L"sun" ,L"sun" ,1 ,46875 ,12500 },
{L"moon" ,L"moon" ,0 ,0 ,0 },
@ -222,7 +222,6 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"concave-star6" ,L"" ,0 ,0 ,0 },
{L"signet" ,L"" ,0 ,0 ,0 },
{L"doorplate" ,L"" ,0 ,0 ,0 },
{L"" ,L"round1Rect" ,0 ,0 ,0 },
{L"" ,L"round2DiagRect" ,0 ,0 ,0 },
{L"" ,L"snip2DiagRect" ,0 ,0 ,0 },

View File

@ -86,7 +86,7 @@ math_variant::math_variant(const std::wstring & Value) : none_(true)
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, Value, boost::algorithm::is_any_of(L" \t"), boost::algorithm::token_compress_on);
for (int i = 0 ; i < splitted.size(); i++)
for (size_t i = 0 ; i < splitted.size(); i++)
{
if (splitted[i] == L"bold")
{

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);
@ -475,6 +475,8 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
}
}
}
if ((props.draw_color_mode_) && (*props.draw_color_mode_ == L"greyscale"))
fill.bitmap->bGrayscale = true;
}
if (props.draw_fill_gradient_name_)
{

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_);
}
}
}
}

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