Compare commits

..

35 Commits

Author SHA1 Message Date
142f9f57a3 OdfFormatReader&Writer - refactoring converting wordarts from/to ooxml 2018-09-20 18:59:51 +03:00
28346c4571 Fix bug with squares in combobox fonts (& empty rects) 2018-09-20 14:53:10 +03:00
9810087ee1 Merge pull request #108 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-20 14:38:32 +03:00
2b8e1456c2 . 2018-09-20 11:41:42 +03:00
49723e648a . 2018-09-19 11:29:43 +03:00
b0a2104b21 Merge commit 'de51052f6ae59ac36665fb3f85804081a888c7c5' into develop 2018-09-18 20:03:33 +03:00
e4986f4202 . 2018-09-18 19:35:06 +03:00
bd1dc5a7b6 . 2018-09-17 17:28:46 +03:00
1ccbe323f4 . 2018-09-14 19:21:12 +03:00
3811169415 Merge commit '185dc3064f731e4adb04040e116dc53110c6d866' into develop 2018-09-14 11:36:36 +03:00
2871769479 . 2018-09-14 11:34:07 +03:00
acdce1edb9 . 2018-09-12 17:53:40 +03:00
67a40a5fc4 Constructor of __ox_drawing doesn't receive parameters 2018-09-12 15:41:37 +03:00
67cd654785 OdfFormatReader - convert form controls in spreadsheets 2018-09-11 14:59:10 +03:00
3816162555 Merge commit '3fb166f99a211e85474c121009019d06710722f8' into develop 2018-09-10 18:43:15 +03:00
d8121d1a12 [ios][x2t] fixed array check 2018-09-06 19:11:47 +03:00
a76bf57051 fix bug #38817 2018-09-06 13:46:47 +03:00
97b92cf75c . 2018-09-05 18:39:32 +03:00
506de8e9e1 fix bug #38678 2018-09-05 18:38:55 +03:00
677e3e49e0 . 2018-08-31 17:38:17 +03:00
02c84d107b Merge commit 'b59908e4c25b265641e77b2167826f236b3b9d64' into develop 2018-08-31 17:27:06 +03:00
49cd76d0f3 Ooxml encrypt files - add support compatibility with Office 2003-2007(+ add rc4 method to encrtypt); add des method in agile encryption 2018-08-30 17:47:17 +03:00
26f32dd511 [ios][pe] chart events 2018-08-29 18:25:08 +03:00
395e54cf76 [ios][x2t] fixed build 2018-08-24 15:11:04 +03:00
40476e7555 [ios][x2t] use system libxml2 2018-08-24 14:59:54 +03:00
04f06c23a1 DocxFormat - extend shading pPr 2018-08-24 13:22:45 +03:00
a9a635747a [ios][x2t] fixed build 2018-08-24 12:50:05 +03:00
4027a0de25 Merge commit 'a232fcd9e1042811d624ff8934dc689f57ac2f57' into develop 2018-08-24 11:10:03 +03:00
f4fa754ce4 Merge pull request #96 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-08-08 15:04:56 +02:00
7d88a91fcc up 2018-08-03 10:39:59 +03:00
069b12839f Merge commit 'c23ff4c8cd5bb2040f75a3a9845fc41d9d496216' into develop 2018-07-30 10:45:09 +03:00
aa609336ca [ios][x2t] fixed build 2018-07-23 19:48:36 +03:00
452917f213 [pe][ios] Apply timing to all 2018-07-19 11:13:28 +03:00
5b5ccdc9be [pe][ios] Events 2018-07-18 19:19:13 +03:00
adf7ca65ea [ios][pe] events 2018-07-18 16:48:45 +03:00
407 changed files with 5813 additions and 15454 deletions

2
.gitignore vendored
View File

@ -47,8 +47,6 @@ 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

@ -52,9 +52,9 @@
#include <string.h>
#endif
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#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
{
_UINT32 Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
{
if (!doc || !docx) return S_FALSE;
@ -202,18 +202,20 @@ namespace DocFileFormat
return S_OK;
}
_UINT32 Converter::LoadAndConvert(const std::wstring& strSrcFile, const std::wstring& strDstDirectory, const std::wstring& password, const ProgressCallback* progress, bool &bMacros)
long 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);
_UINT32 result = doc.LoadDocument(strSrcFile, password);
result = doc.LoadDocument(strSrcFile, password);
if (result == 0)
if (result == S_OK)
{
result = Convert(&doc, &docx, progress);
if (result == 0)
if (result == S_OK)
{
docx.SaveDocument(bMacros);

View File

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

View File

@ -484,266 +484,6 @@ 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)
{
@ -836,15 +576,289 @@ 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 sFieldString;
std::wstring f, sFieldString;
if (cpFieldEnd < (int)m_document->Text->size())
sFieldString = std::wstring( ( m_document->Text->begin() + cpFieldStart ), ( m_document->Text->begin() + cpFieldEnd + 1 ) );
writeField(sFieldString, cpFieldStart, cpFieldEnd);
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" );
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)
{
@ -1028,7 +1042,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[_endnoteNr]);
EndnoteDescriptor* desc = dynamic_cast<EndnoteDescriptor*>(m_document->EndnoteReferenceCharactersPlex->Elements[_footnoteNr]);
if (desc && desc->aEndIdx == 0)
{
m_pXmlWriter->WriteAttribute( L"w:customMarkFollows", L"1");
@ -1064,21 +1078,7 @@ 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 );
bool bStartField = _fieldLevels.empty() ? false : (_fieldLevels.back().bBegin && !_fieldLevels.back().bSeparate);
if (cpFieldStart < cpPic && cpPic < cpFieldEnd && !bStartField)
{
writeField(text, cpFieldStart, cpFieldEnd);
text.clear();
}
}
if (!text.empty())
{
//bool preserve_space = (text.find(L"\x20")) != text.npos) ? true : false;
@ -1348,8 +1348,6 @@ namespace DocFileFormat
{
iTap_current = FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize );
}break;
default:
break;
}
}
if (nestingLevel == iTap_current)
@ -1379,8 +1377,6 @@ namespace DocFileFormat
AddBoundary(boundary2, max_boundary, boundaries);
}break;
default:
break;
}
}
}

View File

@ -85,17 +85,21 @@ 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 );
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeParagraphRsid ( const ParagraphPropertyExceptions* papx );
// Writes the given text to the document
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
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 short rgwSpare0[3];
unsigned char 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) != 0;
m_FibBase.fGlsy = ((flag16 & 0x0002) >> 1) != 0;
m_FibBase.fComplex = ((flag16 & 0x0004) >> 2) != 0;
m_FibBase.fHasPic = ((flag16 & 0x0008) >> 3) != 0;
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.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,8 +134,6 @@ FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx,
bNilPICFAndBinData = true; // or bPICFAndOfficeArtData - shape, pic, ole
}
break;
default:
break;
}
}

View File

@ -31,7 +31,6 @@
*/
#include "MainDocumentMapping.h"
#include "OfficeDrawing/FillStyleBooleanProperties.h"
namespace DocFileFormat
{
@ -84,27 +83,16 @@ namespace DocFileFormat
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
bool bFilled = true;
m_document->DocProperties->bDisplayBackgroundShape = true;
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeBackgound();
OptionEntryPtr boolFill = pShape->ExtractOption(fillStyleBooleanProperties);
FillStyleBooleanProperties booleans(boolFill ? boolFill->op : 0);
if (booleans.fUsefFilled && !booleans.fFilled)
{
bFilled = false;
}
if (bFilled)
{
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
}
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
}
m_pXmlWriter->WriteNodeBegin( L"w:body", FALSE );

View File

@ -217,7 +217,7 @@ public:
private:
unsigned char* m_Data;
unsigned char* m_Data;
unsigned long m_Size;
unsigned long m_Position;
bool bMemoryCopy;

View File

@ -697,8 +697,6 @@ 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 = (int)i;
shape->m_nIndex = 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 < (int)guides.size())
if (index >= 0 && index < 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 < (int)guides.size())
if (index >= 0 && index < 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; //О реорганизации территориальных органов ПФР с 01.11.2018.doc
if ( (clientAnchor) && (clientAnchor->value == 0x80000000))
m_bSkip = true;
Shape* sh = dynamic_cast<Shape*>( this->Children[i] );
if (sh)
@ -101,24 +101,6 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
OptionEntryPtr ExtractOption(const PropertyId & prop) const
{
OptionEntryPtr ret;
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
if ( opt == NULL ) continue;
std::map<PropertyId, OptionEntryPtr>::iterator pFind = opt->OptionsByID.find(prop);
if (pFind != opt->OptionsByID.end())
{
ret = pFind->second;
}
}
return ret;
}
std::vector<OptionEntryPtr> ExtractOptions() const
{
std::vector<OptionEntryPtr> ret;

View File

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

View File

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

View File

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

View File

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

View File

@ -70,7 +70,9 @@ namespace DocFileFormat
case sprmTDefTable:
{
//SprmTDefTable tdef = new SprmTDefTable(sprm.Arguments);
}break;
}
break;
case sprmOldTTableHeader:
case sprmTTableHeader:
{ //header row
@ -82,7 +84,9 @@ namespace DocFileFormat
XMLTools::XMLElement header( L"w:tblHeader" );
_trPr->AppendChild( header );
}
}break;
}
break;
case sprmTWidthAfter:
{ //width after
XMLTools::XMLElement wAfter( L"w:wAfter" );
@ -92,7 +96,9 @@ 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 );
@ -107,7 +113,9 @@ namespace DocFileFormat
wBefore.AppendAttribute( wBeforeType );
_trPr->AppendChild( wBefore, true );
}
}break;
}
break;
case sprmOldTDyaRowHeight:
case sprmTDyaRowHeight:
{ //row height
@ -139,19 +147,19 @@ namespace DocFileFormat
_trPr->AppendChild( rowHeight );
}
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;
default:
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;
//borders 80 exceptions
//case SinglePropertyModifier.OperationCode.sprmTTableBorders80:
// unsigned char[] brc80 = new unsigned char[4];

View File

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

View File

@ -168,8 +168,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute(L"wrapcoords", wrapCoords);
}
break;
default:
break;
}
}
@ -1684,8 +1682,6 @@ namespace DocFileFormat
{
appendStyleProperty(oStyle, L"mso-wrap-distance-top", (FormatUtils::DoubleToWideString(EmuValue((int)iter->op).ToPoints()) + std::wstring(L"pt")));
}break;
default:
break;
}
}
@ -1823,12 +1819,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";
}
}
@ -1836,9 +1832,9 @@ namespace DocFileFormat
{
switch ( op )
{
default: return L"short";
case 1: return L"medium";
case 2: return L"long";
default: return L"short";
}
}
@ -1846,9 +1842,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
{
_UINT32 WordDocument::LoadDocument(const std::wstring & fileName, const std::wstring & password)
int 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();
_UINT32 LoadDocument(const std::wstring & fileName, const std::wstring & password);
int 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"
_UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
HRESULT COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::wstring & docxDirectory, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack)
{
_UINT32 hr = 0;
HRESULT hr = S_FALSE;
DocFileFormat::Converter docToDocx;
docToDocx.m_sTempFolder = m_sTempFolder;
@ -46,7 +46,7 @@ _UINT32 COfficeDocFile::LoadFromFile(const std::wstring & docFile, const std::w
return hr;
}
_UINT32 COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack )
HRESULT COfficeDocFile::SaveToFile (const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack )
{
return 0;
return S_OK;
}

View File

@ -53,8 +53,8 @@ public:
std::wstring m_sTempFolder;
_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);
HRESULT LoadFromFile(const std::wstring & sSrcFileName, const std::wstring & sDstFileName, const std::wstring & password, bool &bMacros, ProgressCallback *ffCallBack = NULL);
HRESULT SaveToFile(const std::wstring & sDstFileName, const std::wstring & sSrcFileName, ProgressCallback *ffCallBack = NULL);
};

View File

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

View File

@ -335,10 +335,48 @@ public:
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
switch(Value)
{
case SimpleTypes::shdClear : sShd += L" w:val=\"clear\""; break;
case SimpleTypes::shdDiagCross : sShd += L" w:val=\"diagCross\""; break;
case SimpleTypes::shdDiagStripe : sShd += L" w:val=\"diagStripe\""; break;
case SimpleTypes::shdHorzCross : sShd += L" w:val=\"horzCross\""; break;
case SimpleTypes::shdHorzStripe : sShd += L" w:val=\"horzStripe\""; break;
case SimpleTypes::shdNil : sShd += L" w:val=\"nil\""; break;
case SimpleTypes::shdPct10 : sShd += L" w:val=\"pct10\""; break;
case SimpleTypes::shdPct12 : sShd += L" w:val=\"pct12\""; break;
case SimpleTypes::shdPct15 : sShd += L" w:val=\"pct15\""; break;
case SimpleTypes::shdPct20 : sShd += L" w:val=\"pct20\""; break;
case SimpleTypes::shdPct25 : sShd += L" w:val=\"pct25\""; break;
case SimpleTypes::shdPct30 : sShd += L" w:val=\"pct30\""; break;
case SimpleTypes::shdPct35 : sShd += L" w:val=\"pct35\""; break;
case SimpleTypes::shdPct37 : sShd += L" w:val=\"pct37\""; break;
case SimpleTypes::shdPct40 : sShd += L" w:val=\"pct40\""; break;
case SimpleTypes::shdPct45 : sShd += L" w:val=\"pct45\""; break;
case SimpleTypes::shdPct5 : sShd += L" w:val=\"pct5\""; break;
case SimpleTypes::shdPct50 : sShd += L" w:val=\"pct50\""; break;
case SimpleTypes::shdPct55 : sShd += L" w:val=\"pct55\""; break;
case SimpleTypes::shdPct60 : sShd += L" w:val=\"pct60\""; break;
case SimpleTypes::shdPct62 : sShd += L" w:val=\"pct62\""; break;
case SimpleTypes::shdPct65 : sShd += L" w:val=\"pct65\""; break;
case SimpleTypes::shdPct70 : sShd += L" w:val=\"pct70\""; break;
case SimpleTypes::shdPct75 : sShd += L" w:val=\"pct75\""; break;
case SimpleTypes::shdPct80 : sShd += L" w:val=\"pct80\""; break;
case SimpleTypes::shdPct85 : sShd += L" w:val=\"pct85\""; break;
case SimpleTypes::shdPct87 : sShd += L" w:val=\"pct87\""; break;
case SimpleTypes::shdPct90 : sShd += L" w:val=\"pct90\""; break;
case SimpleTypes::shdPct95 : sShd += L" w:val=\"pct95\""; break;
case SimpleTypes::shdReverseDiagStripe : sShd += L" w:val=\"reverseDiagStripe\""; break;
case SimpleTypes::shdSolid : sShd += L" w:val=\"solid\""; break;
case SimpleTypes::shdThinDiagCross : sShd += L" w:val=\"thinDiagCross\""; break;
case SimpleTypes::shdThinDiagStripe : sShd += L" w:val=\"thinDiagStripe\""; break;
case SimpleTypes::shdThinHorzCross : sShd += L" w:val=\"thinHorzCross\""; break;
case SimpleTypes::shdThinHorzStripe : sShd += L" w:val=\"thinHorzStripe\""; break;
case SimpleTypes::shdThinReverseDiagStripe : sShd += L" w:val=\"thinReverseDiagStripe\""; break;
case SimpleTypes::shdThinVertStripe : sShd += L" w:val=\"thinVertStripe\""; break;
case SimpleTypes::shdVertStripe : sShd += L" w:val=\"vertStripe\""; break;
default : sShd += L" w:val=\"solid\""; break;
}
}
sShd += L" w:color=\"auto\"";
if(bColor)
@ -2115,7 +2153,7 @@ class CDrawingProperty
public:
bool bObject;
std::wstring sObjectProgram;
unsigned int nObjectId;
long nObjectId;
BYTE nObjectType;
long DataPos;

View File

@ -100,9 +100,10 @@ public:
RELEASEOBJECT(m_oRPr)
}
};
#define READ1_DEF(stLen, res, fReadFunction, arg) {\
long read1defCurPos = 0;\
while(read1defCurPos < (long)stLen)\
while(read1defCurPos < stLen)\
{\
BYTE read1defType = m_oBufferedStream.GetUChar();\
long read1defLength = m_oBufferedStream.GetLong();\
@ -119,7 +120,7 @@ public:
}
#define READ2_DEF(stLen, res, fReadFunction, arg) {\
long read2defCurPos = 0;\
while(read2defCurPos < (long)stLen)\
while(read2defCurPos < stLen)\
{\
BYTE read2defType = m_oBufferedStream.GetUChar();\
long read2defLenType = m_oBufferedStream.GetUChar();\
@ -2055,7 +2056,7 @@ public:
if(true == orowPrAfterBefore.bGridAfter && orowPrAfterBefore.nGridAfter > 0 && false == orowPrAfterBefore.oAfterWidth.bW)
{
//ищем по tblGrid
if(orowPrAfterBefore.nGridAfter < (long)m_aCurTblGrid.size())
if(orowPrAfterBefore.nGridAfter < m_aCurTblGrid.size())
{
double nSumW = 0;
for(int i = 0; i < orowPrAfterBefore.nGridAfter; i++)
@ -2597,7 +2598,7 @@ public:
if ( c_oSerNumTypes::Lvl == type )
{
docLvl* odocLvl = new docLvl();
odocLvl->ILvl = (long)odocANum->Lvls.size();
odocLvl->ILvl = odocANum->Lvls.size();
READ2_DEF(length, res, this->ReadLevel, odocLvl);
odocANum->Lvls.push_back(odocLvl);
}
@ -2831,8 +2832,7 @@ public:
}
else if(c_oSer_sts::Style_Default == type)
{
odocStyle->bDefault = true;
odocStyle->Default = m_oBufferedStream.GetBool();
odocStyle->bDefault = (0 != m_oBufferedStream.GetUChar());
}
else if(c_oSer_sts::Style_BasedOn == type)
{
@ -3893,7 +3893,7 @@ public:
oFile.WriteFile(pData, length);
oFile.CloseFile();
unsigned int lId = 0;
long lId;
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,12 +3970,6 @@ 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;
@ -4526,7 +4520,7 @@ public:
READ1_DEF(length, res, this->ReadParagraphContent, NULL);
if (!pHyperlink->sLink.empty())
{
unsigned int rId;
long 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);
@ -4598,12 +4592,6 @@ 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>")));
@ -4628,12 +4616,6 @@ 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>")));
@ -6889,7 +6871,7 @@ public:
std::wstring sNewImgRel = _T("media/") + sNewImgName;
sNewImgRel = XmlUtils::EncodeXmlString(sNewImgRel);
unsigned int rId;
long 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);
@ -7430,7 +7412,7 @@ public:
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
unsigned int rIdXlsx;
long rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
@ -7457,7 +7439,7 @@ public:
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels";
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
unsigned int rIdChart;
long rIdChart;
std::wstring bstrChartRelType = OOX::FileTypes::Chart.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, sRelsName, std::wstring(), &rIdChart);
@ -8564,7 +8546,7 @@ public:
m_oBufferedStream.Seek(nDocumentOffset);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
unsigned int stamdartRId;
long 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);
@ -8592,19 +8574,19 @@ public:
if(false == m_oFileWriter.m_oNumberingWriter.IsEmpty())
{
unsigned int rId;
long 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())
{
unsigned int rId;
long 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())
{
unsigned int rId;
long 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");
}
@ -8613,7 +8595,7 @@ public:
Writers::HdrFtrItem* pHeader = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[i];
if(false == pHeader->IsEmpty())
{
unsigned int rId;
long 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 );
@ -8625,7 +8607,7 @@ public:
Writers::HdrFtrItem* pFooter = m_oFileWriter.m_oHeaderFooterWriter.m_aFooters[i];
if(false == pFooter->IsEmpty())
{
unsigned int rId;
long 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 );
@ -8635,7 +8617,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;
unsigned int rId;
long rId;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::CustomXml.RelationType(), sRelsPath, L"", &rId);
}
@ -8656,19 +8638,19 @@ public:
if(false == oCommentsWriter.m_sComment.empty())
{
unsigned int rId;
long 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())
{
unsigned int rId;
long 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())
{
unsigned int rId;
long 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 = MBRACKETSTYPE::bracketsAngle; //???
EndBrackets(ebType, false, false);
MBRACKETSTYPE ebType;
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,
MRun = 25
BookmarkEnd = 24
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{

View File

@ -315,19 +315,19 @@ namespace BinDocxRW
void WriteShd(const ComplexTypes::Word::CShading& Shd)
{
//Type
if(false != Shd.m_oVal.IsInit())
if (false != Shd.m_oVal.IsInit())
{
m_oStream.WriteBYTE(c_oSerShdType::Value);
m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
switch(Shd.m_oVal.get().GetValue())
{
case SimpleTypes::shdNil: m_oStream.WriteBYTE(shd_Nil);break;
default: m_oStream.WriteBYTE(shd_Clear);break;
}
m_oStream.WriteBYTE(Shd.m_oVal.get().GetValue()); //Misalignment-footer.doc
}
//Value
if(false != Shd.m_oFill.IsInit())
if (false != Shd.m_oFill.IsInit())
WriteColor(c_oSerShdType::Color, Shd.m_oFill.get());
else if (false != Shd.m_oColor.IsInit())
WriteColor(c_oSerShdType::Color, Shd.m_oColor.get());
WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade);
}
void WriteDistance(const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistL,
@ -3505,14 +3505,6 @@ 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;
}
@ -4122,14 +4114,6 @@ 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);
@ -4182,14 +4166,6 @@ 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((unsigned int)i + 1);
pTableColumn->m_oId->SetValue(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((int)aSharedStrings.size() - 1);
pCell->m_oValue->m_sText = std::to_wstring(aSharedStrings.size() - 1);
}
else
{
@ -658,7 +658,7 @@ namespace BinXlsxRW{
if(NULL != format)
{
int nXfsIndex = (int)m_aXfs.size();
int nXfsIndex = 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((int)nBase64DataSize > nSigLength)
if(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();
}
_UINT32 CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
int 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);
}
_UINT32 CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
int 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);
_UINT32 result = oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions, m_bIsNoBase64);
int 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;
unsigned int rId;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);

View File

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

View File

@ -53,6 +53,12 @@
69F181AF1C77274E00B2952B /* FileDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F181AD1C77274E00B2952B /* FileDownloader.h */; };
8A404FD3208A01AF00F2D5CF /* FileDownloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A404FD2208A01AF00F2D5CF /* FileDownloader.cpp */; };
8A404FD5208A01CE00F2D5CF /* FileDownloader_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */; };
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */; };
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */; };
8AC6D2052130146000D9C0F1 /* xmlutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AC6D2042130146000D9C0F1 /* xmlutils.h */; };
8AC6D2092130146800D9C0F1 /* xmllight_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AC6D2062130146800D9C0F1 /* xmllight_private.h */; };
8AC6D20A2130146800D9C0F1 /* xmldom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AC6D2072130146800D9C0F1 /* xmldom.cpp */; };
8AC6D20B2130146800D9C0F1 /* xmllight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AC6D2082130146800D9C0F1 /* xmllight.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -103,6 +109,12 @@
69F181AD1C77274E00B2952B /* FileDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader.h; path = ../../../Common/FileDownloader/FileDownloader.h; sourceTree = "<group>"; };
8A404FD2208A01AF00F2D5CF /* FileDownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileDownloader.cpp; path = ../../../Common/FileDownloader/FileDownloader.cpp; sourceTree = "<group>"; };
8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader_private.h; path = ../../../Common/FileDownloader/FileDownloader_private.h; sourceTree = "<group>"; };
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustormXmlWriter.cpp; sourceTree = "<group>"; };
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustormXmlWriter.h; sourceTree = "<group>"; };
8AC6D2042130146000D9C0F1 /* xmlutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xmlutils.h; path = ../../../DesktopEditor/xml/include/xmlutils.h; sourceTree = "<group>"; };
8AC6D2062130146800D9C0F1 /* xmllight_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xmllight_private.h; path = ../../../DesktopEditor/xml/src/xmllight_private.h; sourceTree = "<group>"; };
8AC6D2072130146800D9C0F1 /* xmldom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xmldom.cpp; path = ../../../DesktopEditor/xml/src/xmldom.cpp; sourceTree = "<group>"; };
8AC6D2082130146800D9C0F1 /* xmllight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = xmllight.cpp; path = ../../../DesktopEditor/xml/src/xmllight.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -135,6 +147,7 @@
17E17EDE1AC453F800BEA2EA /* ASCOfficeDocxFile2Lib */ = {
isa = PBXGroup;
children = (
8AC6D2032130145600D9C0F1 /* XmlUtils */,
17E17F4D1AC454E200BEA2EA /* Common */,
17E17F1A1AC4549B00BEA2EA /* XlsxSerializerCom */,
17E17F0D1AC4546100BEA2EA /* DocWrapper */,
@ -149,6 +162,8 @@
children = (
17E17EEB1AC4544900BEA2EA /* ChartWriter.h */,
17E17EEC1AC4544900BEA2EA /* CommentsWriter.h */,
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */,
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */,
17A765271B0F3DC30046BC0B /* DefaultThemeWriter.h */,
17E17EF01AC4544900BEA2EA /* DocumentRelsWriter.h */,
17E17EF11AC4544900BEA2EA /* DocumentWriter.h */,
@ -252,6 +267,17 @@
name = BinWriter;
sourceTree = "<group>";
};
8AC6D2032130145600D9C0F1 /* XmlUtils */ = {
isa = PBXGroup;
children = (
8AC6D2072130146800D9C0F1 /* xmldom.cpp */,
8AC6D2062130146800D9C0F1 /* xmllight_private.h */,
8AC6D2082130146800D9C0F1 /* xmllight.cpp */,
8AC6D2042130146000D9C0F1 /* xmlutils.h */,
);
name = XmlUtils;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@ -276,7 +302,9 @@
17C1FEAD1ACC42C4006B99B3 /* ChartWriter.h in Headers */,
17C1FEAE1ACC42C4006B99B3 /* DocumentRelsWriter.h in Headers */,
17C1FEAF1ACC42C4006B99B3 /* CommentsWriter.h in Headers */,
8AC6D2052130146000D9C0F1 /* xmlutils.h in Headers */,
69F181AF1C77274E00B2952B /* FileDownloader.h in Headers */,
8AC6D2092130146800D9C0F1 /* xmllight_private.h in Headers */,
17C1FEB01ACC42C4006B99B3 /* BinaryCommonReader.h in Headers */,
17C1FEB11ACC42C4006B99B3 /* Common.h in Headers */,
8A404FD5208A01CE00F2D5CF /* FileDownloader_private.h in Headers */,
@ -292,6 +320,7 @@
17C1FEBC1ACC42C4006B99B3 /* DocxSerializer.h in Headers */,
17C1FEBD1ACC42C4006B99B3 /* FileWriter.h in Headers */,
17C1FEBE1ACC42C4006B99B3 /* CSVWriter.h in Headers */,
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -346,17 +375,20 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */,
17C1FE961ACC42C4006B99B3 /* Common.cpp in Sources */,
17C1FE971ACC42C4006B99B3 /* ChartFromToBinary.cpp in Sources */,
17C1FE981ACC42C4006B99B3 /* CSVReader.cpp in Sources */,
17C1FE991ACC42C4006B99B3 /* DocxSerializer.cpp in Sources */,
17C1FE9A1ACC42C4006B99B3 /* CommonWriter.cpp in Sources */,
8AC6D20B2130146800D9C0F1 /* xmllight.cpp in Sources */,
17C1FE9B1ACC42C4006B99B3 /* CSVWriter.cpp in Sources */,
69414A301CB51666003E771B /* ChartWriter.cpp in Sources */,
6967917E1D9E8AEE002CA4BA /* BinWriters.cpp in Sources */,
69BBDF251F0B8AAC00EB1BF7 /* FileDownloader_mac.mm in Sources */,
17C1FE9C1ACC42C4006B99B3 /* XlsxSerializer.cpp in Sources */,
690FE0851E9BBD68004B26D0 /* Readers.cpp in Sources */,
8AC6D20A2130146800D9C0F1 /* xmldom.cpp in Sources */,
17C1FE9D1ACC42C4006B99B3 /* FontProcessor.cpp in Sources */,
8A404FD3208A01AF00F2D5CF /* FileDownloader.cpp in Sources */,
);

View File

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

View File

@ -36,7 +36,6 @@
#include "../include/CPScopedPtr.h"
namespace cpdoccore {
namespace formulasconvert {
@ -45,7 +44,7 @@ namespace formulasconvert {
class odf2oox_converter
{
public:
odf2oox_converter();
odf2oox_converter();
~odf2oox_converter();
// of:=SUM([.DDA1:.BA3]) -> SUM(DDA1:BA3)

View File

@ -35,7 +35,6 @@
#include <boost/algorithm/string.hpp>
#include"../../Common/DocxFormat/Source/XML/Utils.h"
#include "../src/docx/xlsxconversioncontext.h"
namespace cpdoccore {
namespace formulasconvert {
@ -43,9 +42,6 @@ namespace formulasconvert {
class odf2oox_converter::Impl
{
public:
Impl() {}
static std::unordered_map<std::wstring, int> & mapExternalLink_;
std::wstring convert(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
@ -58,155 +54,21 @@ namespace formulasconvert {
void replace_tilda(std::wstring& expr);
void replace_vertical(std::wstring& expr);
void replace_space(std::wstring& expr);
std::wstring convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator);
std::wstring convert_named_expr(const std::wstring& expr, bool withTableName);
static std::wstring replace_named_ref_formater(boost::wsmatch const & what);
static std::wstring replace_named_ref_formater1(boost::wsmatch const & what);
//static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
void replace_named_formula(std::wstring & expr, bool w = true);
void replace_named_ref(std::wstring & expr, bool w = true);
bool find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref);
bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
static bool convert_with_TableName;
static std::wstring table_name_;
//-------------------------------------------------------------------------------------------------------------
static std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L",";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
static std::wstring replace_tilda_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
static std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"|", L";");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static void 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"\"");
}
static void 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");
}
static std::wstring convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
replace_tmp(inner);
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
replace_tmp(inner);
return inner;
}
else if (what[3].matched)
return what[3].str();
return L"";
}
static std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L" ", L",");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static std::wstring is_forbidden(const std::wstring & formula)
{
std::wstring result = formula;
std::map<std::wstring, std::wstring> forbidden_formulas;
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
{
if (boost::algorithm::contains(formula, it->first))
{
XmlUtils::replace_all(result, it->first, it->second);
}
}
return result;
}
static bool convert_with_TableName;
static std::wstring table_name_;
};
bool odf2oox_converter::Impl::convert_with_TableName = true;
std::wstring odf2oox_converter::Impl::table_name_ = L"";
std::unordered_map<std::wstring, int> &odf2oox_converter::Impl::mapExternalLink_ = oox::xlsx_conversion_context::mapExternalLink_;
bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
{
@ -214,14 +76,14 @@ namespace formulasconvert {
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L".:"), boost::algorithm::token_compress_on);
if (splitted.size() == 3)
if (splitted.size()==3)
{
table = splitted[0];
ref_first = splitted[1];
ref_last = splitted[2];
return true;
}
if (splitted.size() == 4)
if (splitted.size()==4)
{
table = splitted[0];
ref_first = splitted[1];
@ -233,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}\\.([\\w^0-9\\$]+\\d+)(?::\\.([\\w^0-9]+\\d+)){0,1}\\]");
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
boost::wsmatch result;
bool b = boost::regex_search(expr, result, re);
@ -256,92 +118,101 @@ namespace formulasconvert {
}
//std::wstring odf2oox_converter::Impl::replace_cell_range_formater(boost::wsmatch const & what)
//{
// const size_t sz = what.size();
// if (sz == 4 && !what[1].matched)
// {
// const std::wstring c1 = what[2].str();
// const std::wstring c2 = what[3].str();
// const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
// return s;
// }
// else if (sz == 4 && what[1].matched)
// {
// std::wstring sheet1 = what[1].str();
// XmlUtils::replace_all( sheet1, L"$", L"");
std::wstring odf2oox_converter::Impl::replace_cell_range_formater(boost::wsmatch const & what)
{
const size_t sz = what.size();
if (sz == 4 && !what[1].matched)
{
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
return s;
}
else if (sz == 4 && what[1].matched)
{
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
// const std::wstring c1 = what[2].str();
// std::wstring c2 = what[3].str();
// if (c2.empty()) c2 = what[4].str();
// const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
// return s;
// }
// return L"";
//}
const std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if (c2.empty()) c2 = what[4].str();
const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
return s;
}
return L"";
}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater(boost::wsmatch const & what)
{
const size_t sz = what.size();
if (sz < 6) return what[0].str();
std::wstring c0 = what[0].str();
std::wstring external = sz == 7 ? what[1].matched ? what[1].str() : what[2].str() : what[1].str();
std::wstring sheet1 = sz == 7 ? what[3].str() : what[2].str();
std::wstring ref1 = sz == 7 ? what[4].str() : what[3].str();
std::wstring sheet2 = sz == 7 ? what[5].str() : what[4].str();
std::wstring ref2 = sz == 7 ? what[6].str() : what[5].str();
XmlUtils::replace_all( sheet1, L"$", L"");
//XmlUtils::replace_all( sheet2, L"$", L"");
std::wstring result;
if (false == external.empty())
if (sz == 4 && !what[1].matched)
{
replace_tmp_back(external);
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
return s;
}
else if (sz == 4 && what[1].matched)
{
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
int id = -1;//add_external_link(external);
std::unordered_map<std::wstring, int>::iterator pFind = mapExternalLink_.find(external);
if ( pFind == mapExternalLink_.end())
table_name_ = sheet1;
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str();
if (convert_with_TableName)
{
id = (int)mapExternalLink_.size() + 1;
mapExternalLink_.insert(std::make_pair(external, id));
if (std::wstring::npos != sheet1.find(L" "))
{
if (sheet1[0] != L'\'')
{
sheet1 = L"'" + sheet1 + L"'";
}
}
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c2) );
}
else
{
id = pFind->second;
return c1 + (c2.empty() ? L"" : (L":" + c2) );
}
if (sheet1[0] == L'\'')
}
else if (sz == 5 && what[1].matched)
{
std::wstring sheet1 = what[1].str();
XmlUtils::replace_all( sheet1, L"$", L"");
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str(); //sheet name 2
const std::wstring c3 = what[4].str();
table_name_ = sheet1;
if (convert_with_TableName)
{
sheet1 = sheet1.substr(1, sheet1.length() - 2);
return (sheet1 + L"!") + c1 + (c3.empty() ? L"" : (L":" + c3) );
}
sheet1 = L"'[" + std::to_wstring(id) + L"]" + sheet1 + L"'";
}
else if (std::wstring::npos != sheet1.find(L" "))
{
if (sheet1[0] != L'\'')
else
{
sheet1 = L"'" + sheet1 + L"'";
return c1 + (c3.empty() ? L"" : (L":" + c3) );
}
}
table_name_ = sheet1;
if (convert_with_TableName)
else if (sz == 5 && !what[1].matched)
{
return (sheet1.empty() ? L"" : (sheet1 + L"!")) + ref1 + (ref2.empty() ? L"" : (L":" + ref2) );
}
else
{
return ref1 + (ref2.empty() ? L"" : (L":" + ref2) );
const std::wstring c1 = what[2].str();
const std::wstring c2 = what[3].str(); //sheet name 2
const std::wstring c3 = what[4].str();
return c1 + (c3.empty() ? L"" : (L":" + c3) );
}
return L"";
}
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
{
boost::wregex complexRef(L"(?:\'([^\']*)\'#){0,1}\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)(?::\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)){0,1}");
// 'external'# $ Sheet2 . A1 : ( $ Sheet2)? . B5
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}");
std::wstring expr = what[1].str();
const std::wstring res = boost::regex_replace(
expr,
@ -362,34 +233,26 @@ namespace formulasconvert {
// [$'Sheet2 A'.$B2] -> 'Sheet2 A'!$B2
void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr, bool withTableName)
{
XmlUtils::replace_all( expr, L"#REF !", L"#REF!");
XmlUtils::replace_all( expr, L"#REF!#REF!", L"#REF!");
XmlUtils::replace_all( expr, L"$#REF!$#REF!", L"#REF!");
convert_with_TableName = withTableName;
//boost::wregex complexRef(L"\\[(?:\'([^\']*)\'#){0,1}\\[{0,1}(?:\\$){0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]{0,1}");
boost::wregex complexRef(L"(?:(?:(?:(?:\\[\'([^\']*)\'#)|(?:\'([^\']*)\'#\\[)))|(?:\\[))\
(?:\\$){0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]");
// [ 'external'# [ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
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}\\]");
/*
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
*/
expr = boost::regex_replace(
expr,
const std::wstring res = boost::regex_replace(
expr,
complexRef,
&replace_named_ref_formater,
boost::match_default | boost::format_all);
expr = res;
}
void odf2oox_converter::Impl::replace_named_ref(std::wstring & expr, bool withTableName)
{
XmlUtils::replace_all( expr, L"#REF !", L"#REF!");
XmlUtils::replace_all( expr, L"#REF!#REF!", L"#REF!");
XmlUtils::replace_all( expr, L"$#REF!$#REF!", L"#REF!");
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}(?:\'([^\']*)\'#){0,1}\\${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}\\]{0,1}");
// 'external'# $ Sheet2 . A1 : ( $ Sheet2)? . B5
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}");
const std::wstring res = boost::regex_replace(
expr,
@ -418,7 +281,29 @@ namespace formulasconvert {
}
std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L",";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
std::wstring replace_tilda_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
else
return L"";
}
// TODO
// заменить точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
void odf2oox_converter::Impl::replace_semicolons(std::wstring& expr)
{
@ -442,6 +327,123 @@ namespace formulasconvert {
expr = res;
}
std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L"|", L";");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring replace_point_space(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L" ", L"PROBEL");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
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");
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");
return inner;
}
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L" ", L",");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
//std::wstring forbidden_formulas[] =
//{
// L"NULLFORMULA"
// //L"BETADIST",
// //L"CEILING",
// //L"FLOOR",
// //L"RANK",
// //L"ROUND",
// //L"ROUNDDOWN",
// //L"ROUNDUP",
// //L"SUBTOTAL",
// //L"FORMULA",
// //L"ISREF"
//};
std::wstring is_forbidden(const std::wstring & formula)
{
std::wstring result = formula;
std::map<std::wstring, std::wstring> forbidden_formulas;
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
{
if (boost::algorithm::contains(formula, it->first))
{
XmlUtils::replace_all(result, it->first, it->second);
}
}
return result;
}
// заменить вертикальную черту во всех вхождениях в фигурных скобках, но не внутри строк
void odf2oox_converter::Impl::replace_vertical(std::wstring& expr)
{
@ -466,11 +468,17 @@ namespace formulasconvert {
std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
{
std::wstring workstr = is_forbidden(expr);
//boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// Better_Donut.ods- cell(c27)
//std::wstring workstr = boost::regex_replace(
// expr,
// complexRef,
// &replace_point_space,
// boost::match_default | boost::format_all);
bool isFormula = check_formula(workstr);
//экранирование
workstr = boost::regex_replace(workstr,
boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
@ -484,9 +492,9 @@ namespace formulasconvert {
XmlUtils::replace_all( workstr, L"FDIST(", L"_xlfn.F.DIST(");
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
if (std::wstring::npos != workstr.find(L"CONCATINATE"))
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
{
bool l = true;
//могут быть частично заданы диапазоны
//todooo
}
@ -501,23 +509,39 @@ namespace formulasconvert {
//-----------------------------------------------------------
replace_tmp_back(workstr);
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"\"");
return workstr;
}
void odf2oox_converter::Impl::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
{
std::wstring workstr = boost::regex_replace(
std::wstring workstr = expr;
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
expr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
boost::algorithm::split(out, workstr, boost::algorithm::is_any_of(by), boost::algorithm::token_compress_on);
for (size_t i = 0; i < out.size(); i++)
{
replace_tmp_back(out[i]);
XmlUtils::replace_all( out[i], L"PROBEL", L" ");
XmlUtils::replace_all( out[i], L"TOCHKA", L".");
}
}
@ -527,10 +551,15 @@ namespace formulasconvert {
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
{
std::wstring workstr = boost::regex_replace(
is_forbidden(expr),
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
std::wstring workstr = is_forbidden(expr);
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
//распарсить по диапазонам - одф-пробел, ик-эль-запятая
@ -562,10 +591,10 @@ namespace formulasconvert {
cells_out.append(cells[j]);
cells_out.append(L":");
}
size_t res1 = sheet.find(L"-");
size_t res2 = sheet.find(L"'");
int res1 = sheet.find(L"-");
int res2 = sheet.find(L"'");
if (res1 != std::wstring::npos && res2 != std::wstring::npos && !(res2 == 0))
if (res1 >= 0 && !(res2 == 0))
{
sheet = L"'" + sheet + L"'";
}
@ -579,78 +608,12 @@ namespace formulasconvert {
result.append(distance_out[i]);
result.append(L",");
}
replace_tmp_back( result );
XmlUtils::replace_all( result, L"PROBEL" , L" ");
XmlUtils::replace_all( result, L"TOCHKA", L".");
return result.substr(0, result.size() - 1);// минус последняя лишняя запятая
}
std::wstring odf2oox_converter::Impl::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
std::wstring workstr = expr;
workstr = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
replace_named_ref(workstr, withTableName);
if (separator != L" ")
{
XmlUtils::replace_all( workstr, L" ", separator);
}
replace_tmp_back( workstr );
if (table_name_.empty() == false)
{
replace_tmp_back( table_name_ );
}
return workstr;
}
std::wstring odf2oox_converter::Impl::convert_named_expr(const std::wstring& expr, bool withTableName)
{
std::wstring workstr = expr;
bool isFormula = check_formula(workstr);
if (isFormula)
{
workstr = convert(expr);
}
else
{
workstr = boost::regex_replace(
workstr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
replace_cells_range(workstr, withTableName);
replace_semicolons(workstr);
replace_vertical(workstr);
size_t res_find = 0;
if ((res_find = workstr.find(L"CONCATINATE")) != std::wstring::npos)
{
//могут быть частично заданы диапазоны
//todooo
}
replace_tmp_back(workstr);
if (table_name_.empty() == false)
{
replace_tmp_back(table_name_);
}
}
return workstr;
}
//------------------------------------------------------------------------------------------------------------
odf2oox_converter::odf2oox_converter() : impl_(new odf2oox_converter::Impl())
odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl)
{
}
@ -677,11 +640,82 @@ namespace formulasconvert {
}
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
{
return impl_->convert_named_ref(expr, withTableName, separator);
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
std::wstring workstr = boost::regex_replace(
expr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
//XmlUtils::replace_all( workstr, L"", L"APOSTROF");
impl_->replace_named_ref(workstr, withTableName);
if (separator != L" ")
{
XmlUtils::replace_all( workstr, L" " , separator);
}
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
if (impl_->table_name_.empty() == false)
{
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
}
return workstr;
}
std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr, bool withTableName)
{
return impl_->convert_named_expr(expr, withTableName);
std::wstring workstr = expr;
bool isFormula = impl_->check_formula(workstr);
if (isFormula)
{
workstr = impl_->convert(expr);
}
else
{
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
workstr = boost::regex_replace(
workstr,
complexRef,
&replace_point_space,
boost::match_default | boost::format_all);
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
impl_->replace_cells_range(workstr, withTableName);
impl_->replace_semicolons(workstr);
impl_->replace_vertical(workstr);
int res_find=0;
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
{
//могут быть частично заданы диапазоны
//todooo
}
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
if (impl_->table_name_.empty() == false)
{
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
}
}
return workstr;
}
std::wstring odf2oox_converter::convert_ref(std::wstring const & expr)
@ -694,8 +728,8 @@ namespace formulasconvert {
{
while(true)
{
size_t pos = expr.find(L"%20");
if (pos == std::wstring::npos)break;
int pos = expr.find(L"%20");
if (pos <0)break;
expr.replace(pos,3,L" ");
}

View File

@ -39,22 +39,6 @@
namespace cpdoccore {
namespace formulasconvert {
static std::wstring forbidden_formulas1[] =
{
L"NULLFORMULA()"
/*
L"BETADIST",
L"CEILING",
L"FLOOR",
L"RANK",
L"ROUND",
L"ROUNDDOWN",
L"ROUNDUP",
L"SUBTOTAL",
L"FORMULA",
L"ISREF"*/
};
class oox2odf_converter::Impl
{
public:
@ -64,7 +48,7 @@ public:
std::wstring convert_conditional_formula(const std::wstring& expr);
std::wstring convert_chart_distance(const std::wstring& expr);
static void replace_cells_range(std::wstring& expr, bool bSelect = true);
static void replace_cells_range(std::wstring& expr);
static void replace_semicolons(std::wstring& expr);
static void replace_vertical(std::wstring& expr);
@ -75,104 +59,7 @@ public:
static std::wstring replace_arguments(boost::wsmatch const & what);
static std::wstring convert_scobci(boost::wsmatch const & what);
static std::wstring replace_tilda_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
static std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
static std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L";", L"|");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L",", L" ");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
static 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"\"");
}
static 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");
}
static bool is_forbidden1(const std::wstring & formula)
{
for (size_t i = 0; i < 1; i++)
{
if (boost::algorithm::contains(formula, forbidden_formulas1[i]))
return true;
}
return false;
}
void replace_named_ref(std::wstring & expr);
void replace_named_ref(std::wstring & expr);
void replace_named_formula(std::wstring & expr);
static bool isFindBaseCell_;
@ -183,11 +70,8 @@ public:
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
std::wstring oox2odf_converter::Impl::table_name_ = L"";
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSelect)
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;
@ -195,7 +79,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSele
if (b)
{
boost::wregex re1(L"(\\$?[^\']+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]*\\d*)\\:?([a-zA-Z$]*\\d*)?");
// $ Sheet2 ! $ A1 : $ B5
// $ Sheet2 ! $ A : $ A
// $ Sheet2 ! $ 1 : $ 1
@ -204,7 +88,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSele
std::wstring res = boost::regex_replace(
workstr,
re1,
bSelect ? &replace_cells_range_formater1 : &replace_cells_range_formater2,
&replace_cells_range_formater1,
boost::match_default | boost::format_all);
expr = res;
@ -227,12 +111,8 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
{
return c1;
}
else if (!c1.empty() || !c2.empty() || !sheet.empty())
if (!c1.empty() || !c2.empty() || !sheet.empty())
{
XmlUtils::replace_all( sheet, L"!", L"");
@ -242,8 +122,9 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
s = std::wstring(L"[") + sheet + L"." +
c1 +
(c2.empty() ? L"" : (L":" + sheet + L"." + c2) ) + std::wstring(L"]");
}
return s;
}
@ -263,43 +144,18 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
{
const size_t sz = what.size();
if (sz > 3)
{
std::wstring s;
std::wstring sheet = what[1].matched ? what[1].str() : L"";
std::wstring c1 = what[2].str();
std::wstring c2 = what[3].str();
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"");
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
{
table_name_ = sheet + L".$A$1";
}
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
s = sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"");
}
return s;
}
else
if (sz > 2)
{
const std::wstring c1 = what[1].str();
const std::wstring c2 = what[2].str();
const std::wstring s = std::wstring(L".") + c1 + (c2.empty() ? L"" : (L":." + c2) );
const std::wstring s = std::wstring(L"[.") + c1 + (c2.empty() ? L"" : (L":." + c2) ) + std::wstring(L"]");
return s;
}
return L"";
return L"";
}
void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
@ -311,6 +167,7 @@ void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
isFindBaseCell_ = false;
}
// Лист1!$A$1 -> $Лист1.$A$1
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
{
table_name_.clear();
@ -321,22 +178,27 @@ 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, res1, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
boost::algorithm::split(distance,workstr, 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];
replace_cells_range(d, false);
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);
oox_replace_tmp_back(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"\"");
out = out + d + std::wstring(L";");
}
@ -347,11 +209,47 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
if (table_name_.empty() == false)
{
oox_replace_tmp_back(table_name_);
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"\"");
}
}
namespace
{
std::wstring replace_tilda_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
std::wstring replace_semicolons_formater(boost::wsmatch const & what)
{
if (what[1].matched)
return L";";
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
//else if (what[4].matched)
// return what[4].str();
else
return L"";
}
}
// TODO
// заменить запятые на точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
@ -366,8 +264,67 @@ void oox2odf_converter::Impl::replace_semicolons(std::wstring& expr)
boost::match_default | boost::format_all);
expr = res;
}
namespace
{
std::wstring replace_vertical_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L";", L"|");
return L"{" + inner + L"}";
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring replace_space_formater(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L",", L" ");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
}
std::wstring forbidden_formulas1[] =
{
L"NULLFORMULA()"
/*
L"BETADIST",
L"CEILING",
L"FLOOR",
L"RANK",
L"ROUND",
L"ROUNDDOWN",
L"ROUNDUP",
L"SUBTOTAL",
L"FORMULA",
L"ISREF"*/
};
bool is_forbidden1(const std::wstring & formula)
{
for (size_t i = 0; i < 1; i++)
{
if (boost::algorithm::contains(formula, forbidden_formulas1[i]))
return true;
}
return false;
}
//void oox2odf_converter::Impl::split_(std::wstring& expr)
//{
// const std::wstring res = boost::regex_split(
@ -398,18 +355,47 @@ void oox2odf_converter::Impl::replace_space(std::wstring& expr)
expr = res;
}
std::wstring replace_(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
XmlUtils::replace_all( inner, L",", L" ");
return inner;
}
else if (what[2].matched)
return what[2].str();
else if (what[3].matched)
return what[3].str();
return L"";
}
std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what)
{
if (what[1].matched)
{
std::wstring inner = what[1].str();
oox_replace_tmp(inner);
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");
return inner;
}
else if (what[2].matched)
{
std::wstring inner = what[2].str();
oox_replace_tmp(inner);
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");
return inner;
}
else if (what[3].matched)
@ -422,7 +408,7 @@ std::wstring oox2odf_converter::Impl::replace_arguments(boost::wsmatch const &
{
std::wstring out;
size_t sz = what.size();
int sz = what.size();
if (what[1].matched)
{
@ -458,13 +444,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;
}
// (Formula) -> of:=(Formula)
// of:=(Formula) -> (Formula)
std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
{
std::wstring workstr = expr;
@ -476,13 +462,9 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
std::wstring res = boost::regex_replace(
res1,
boost::wregex(L"(?!([\\w^0-9]+\\d*\\())(([\\w^0-9]+\\!)?\\$?[\\w^0-9]*\\$?\\d*(\\:\\$?[\\w^0-9]*\\$?\\d*){0,1})"),
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\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
@ -494,7 +476,16 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
boost::match_default | boost::format_all);
}
oox_replace_tmp_back(res);
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"\"");
replace_vertical(res);
replace_semicolons(res);
@ -503,7 +494,17 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
if (table_name_.empty() == false)
{
oox_replace_tmp_back(table_name_);
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" ");
}
return std::wstring(L"of:=") + res;
@ -532,7 +533,12 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
}
oox_replace_tmp_back( res);
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"\"");
replace_vertical(res);
replace_semicolons(res);
@ -562,7 +568,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 (size_t i = 0; i < distance_inp.size(); i++)
for (int i = 0; i < distance_inp.size(); i++)
{
std::wstring sheet;
std::vector<std::wstring> range;
@ -570,7 +576,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 (size_t j = 0 ; j < range.size(); j++)
for (int j = 0 ; j < range.size(); j++)
{
int pos = range[j].find('!');
if (0 <= pos)
@ -582,7 +588,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring cells_out;
for (size_t c = 0; c < cells.size(); c++)
for (int c = 0; c < cells.size(); c++)
{
if (!sheet.empty())
cells_out += sheet + L".";
@ -601,7 +607,7 @@ std::wstring oox2odf_converter::Impl::convert_chart_distance(const std::wstring&
}
std::wstring result;
for (size_t i = 0 ; i < distance_out.size(); i++)
for (int i = 0 ; i < distance_out.size(); i++)
{
result += distance_out[i];
result += L" ";
@ -648,6 +654,8 @@ 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;
@ -735,7 +743,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 (size_t i=0; i < splitted.size(); i++)
for (long 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

@ -332,7 +332,6 @@ enum ElementType
typeTableTableRowGroup,
typeTableTableRowNoGroup,
typeTableTableSource,
typeTableTableProtection,
typeTableDataPilotTables,
typeTableDataPilotTable,
@ -455,7 +454,6 @@ enum ElementType
typeDrawPolyline,
typeDrawRegularPolyline,
typeDrawPath,
typeDrawContourPath,
typeDrawCircle,
typeDrawg,
typeDrawPageThumbnail,

View File

@ -43,7 +43,7 @@
#include <boost/variant.hpp>
#include <boost/lexical_cast.hpp>
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace cpdoccore
{

View File

@ -43,7 +43,7 @@
#include "../include/odf/odf_document.h"
_UINT32 ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
int 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 @@ _UINT32 ConvertOds2Xlsx(cpdoccore::odf_reader::odf_document & inputOdf, const st
outputXlsx.write(dstPath);
return 0;
}
_UINT32 ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
int 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 @@ _UINT32 ConvertOdt2Docx(cpdoccore::odf_reader::odf_document & inputOdf, const st
return 0;
}
_UINT32 ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const std::wstring & dstPath, const std::wstring & fontsPath)
int 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 @@ _UINT32 ConvertOdp2Pptx(cpdoccore::odf_reader::odf_document & inputOdf, const st
return 0;
}
_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 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 nResult = 0;
int nResult = 0;
try
{
@ -134,9 +134,9 @@ _UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstP
}
_UINT32 ConvertOTF2ODF(const std::wstring & srcPath)
int ConvertOTF2ODF(const std::wstring & srcPath)
{
_UINT32 nResult = 0;
int 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,11 +31,10 @@
*/
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include <string>
struct ProgressCallback;
_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 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 ConvertOTF2ODF(const std::wstring & otfPath);
int 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(), (LONG)_Utf8String.length());
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)_Utf8String.c_str(), _Utf8String.length());
}
std::string utf16_to_utf8(const std::wstring & _Utf16String)

View File

@ -131,7 +131,6 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
last_dump_page_properties_ (true),
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
@ -156,9 +155,12 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
odf_document_ (OdfDocument)
{
streams_man_ = streams_man::create(temp_stream_);
applicationFonts_ = NSFonts::NSApplication::Create();
}
docx_conversion_context::~docx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void docx_conversion_context::set_output_document(package::docx_document * document)
{
@ -166,7 +168,8 @@ void docx_conversion_context::set_output_document(package::docx_document * docum
}
void docx_conversion_context::set_font_directory(std::wstring pathFonts)
{
mediaitems_.set_font_directory(pathFonts);
if (applicationFonts_)
applicationFonts_->InitializeFromFolder(pathFonts);
}
std::wstring styles_map::get(const std::wstring & Name, odf_types::style_family::type Type)
{
@ -683,7 +686,7 @@ void docx_conversion_context::end_document()
output_document_->get_word_files().set_document ( package::simple_element::create(L"document.xml", document_xml_.str()) );
output_document_->get_word_files().set_settings ( package::simple_element::create(L"settings.xml", dump_settings_document()));
output_document_->get_word_files().set_media ( mediaitems_);
output_document_->get_word_files().set_media ( mediaitems_, applicationFonts_);
output_document_->get_word_files().set_comments ( comments_context_);
output_document_->get_word_files().set_headers_footers( headers_footers_);
@ -1426,22 +1429,14 @@ void docx_conversion_context::next_dump_page_properties(bool val)
if (process_headers_footers_ && val) return;
next_dump_page_properties_ = val;
if (val)
last_dump_page_properties(true);
}
bool docx_conversion_context::is_next_dump_page_properties()
{
return next_dump_page_properties_;
}
void docx_conversion_context::last_dump_page_properties(bool val)
{
last_dump_page_properties_ = val;
}
bool docx_conversion_context::is_last_dump_page_properties()
{
return last_dump_page_properties_;
}
void docx_conversion_context::start_text_list_style(const std::wstring & StyleName)
{
text_list_style_name_ = StyleName;

View File

@ -47,6 +47,8 @@
#include "hyperlinks.h"
#include "mediaitems.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace odf_types
@ -188,14 +190,14 @@ public:
}
void set_position_child_group(_INT32 x, _INT32 y)
{
if (groups_.empty()) return;
if (groups_.size() < 1) return;
if (groups_.back().x > x) groups_.back().x = x;
if (groups_.back().y > y) groups_.back().y = y;
}
void set_size_child_group(_INT32 cx, _INT32 cy)
{
if (groups_.empty()) return;
if (groups_.size() < 1) return;
if (groups_.back().cx < cx) groups_.back().cx = cx;
if (groups_.back().cy < cy) groups_.back().cy = cy;
@ -203,7 +205,7 @@ public:
void get_position_group(_INT32 & x, _INT32 & y)
{
x = y = 0;
if (groups_.empty()) return;
if (groups_.size() < 1) return;
x = groups_.back().x;
y = groups_.back().y;
@ -211,7 +213,7 @@ public:
void get_size_group(_INT32 & cx, _INT32 & cy)
{
cx = cy = 0;
if (groups_.empty()) return;
if (groups_.size() < 1) return;
cx = groups_.back().cx;
cy = groups_.back().cy;
@ -793,12 +795,12 @@ public:
bool next_dump_page_properties_;
bool next_dump_section_;
bool last_dump_page_properties_;
odf_reader::odf_document *root()
odf_reader::odf_document * root()
{
return odf_document_;
}
void start_document ();
void end_document ();
@ -863,8 +865,6 @@ public:
void next_dump_page_properties (bool val);
bool is_next_dump_page_properties ();
void last_dump_page_properties (bool val);
bool is_last_dump_page_properties ();
void set_master_page_name(const std::wstring & MasterPageName);
const std::wstring & get_master_page_name() const;
@ -1000,6 +1000,7 @@ private:
package::docx_document * output_document_;
odf_reader::odf_document * odf_document_;
NSFonts::IApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_;

View File

@ -147,11 +147,11 @@ void word_files::update_rels(docx_conversion_context & Context)
Context.dump_notes (rels_files_.get_rel_file()->get_rels());
}
void word_files::set_media(mediaitems & _Mediaitems)
void word_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{

View File

@ -40,6 +40,8 @@
#include "docx_content_type.h"
#include "oox_package.h"
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace oox {
@ -137,7 +139,7 @@ public:
void set_numbering (element_ptr Element);
void set_settings (element_ptr Element);
bool has_numbering ();
void set_media (mediaitems & mediaitems_);
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void set_headers_footers(headers_footers & HeadersFooters);
void set_notes (notes_context & notesContext);
void set_comments (comments_context & commentsContext);

View File

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

View File

@ -73,8 +73,7 @@ struct drawing_object_description
_oox_fill fill_;
bool in_group_;
bool lined_;
bool connector_;
int shape_type_; //default - frame
std::vector<drawing_object_description> child_objects_;

View File

@ -36,7 +36,7 @@
#include <float.h>
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace utils {

View File

@ -41,7 +41,6 @@
#include "../../DesktopEditor/common/Directory.h"
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace oox {
@ -75,32 +74,7 @@ mediaitems::item::item( std::wstring const & _href,
count_add = 1;
count_used = 0;
}
mediaitems::mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
applicationFonts_ = NSFonts::NSApplication::Create();
}
mediaitems::~mediaitems()
{
if (applicationFonts_)
delete applicationFonts_;
}
void mediaitems::set_font_directory(std::wstring pathFonts)
{
if (applicationFonts_)
applicationFonts_->InitializeFromFolder(pathFonts);
}
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal)
{
std::wstring ref;
@ -152,8 +126,8 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (sExt.empty())
{
size_t n = uri.find(L"ObjectReplacements");
if (n != std::wstring::npos)
int n = uri.find(L"ObjectReplacements");
if (n >= 0)
{
if (!isInternal) return L"";
@ -164,16 +138,14 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
if (sExt.empty())
{
//то что есть ..
size_t n = uri.rfind(L".");
if (n != std::wstring::npos)
sExt = XmlUtils::GetLower(uri.substr(n));
int n = uri.rfind(L".");
if (n > 0)
sExt = uri.substr(n);
}
}
if (type == typeOleObject && sExt.empty())
sExt = L".bin";
else if ( type == typeChart)
sExt = L".xml";
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
}
@ -195,7 +167,7 @@ std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
if (!sExt.empty()) sExt = std::wstring(L".") + sExt;
}
return XmlUtils::GetLower(sExt);
return sExt;
}
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
@ -242,6 +214,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart) outputPath = outputPath + L".xml";
std::wstring id;
for (size_t i = 0 ; i < items_.size(); i++)
@ -268,8 +242,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
}
else if ( type == typeImage)
{
size_t n_svm = outputPath.rfind (L".svm");
if ( n_svm != std::wstring::npos )
int n_svm = outputPath.rfind (L".svm");
if ( n_svm >= 0 )
{
outputPath = outputPath.substr(0, n_svm) + L".png";
}

View File

@ -33,12 +33,7 @@
#include "oox_rels.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace NSFonts
{
class IApplicationFonts;
}
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace cpdoccore {
namespace oox {
@ -46,8 +41,20 @@ namespace oox {
class mediaitems
{
public:
mediaitems(const std::wstring & odfPacket);
virtual ~mediaitems();
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
}
struct item
{
@ -80,9 +87,6 @@ public:
size_t count_activeX;
size_t count_control;
void set_font_directory(std::wstring pathFonts);
NSFonts::IApplicationFonts *applicationFonts() {return applicationFonts_;}
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);
@ -113,9 +117,9 @@ public:
}
static RelsType detectMediaType(const std::wstring & fileName)
{
size_t pos = fileName.rfind(L".");
int pos = fileName.rfind(L".");
std::wstring sExt = (pos != std::wstring::npos ? fileName.substr(pos + 1) : L"");
std::wstring sExt = (pos >=0 ? fileName.substr(pos + 1) : L"");
if (sExt.empty()) return typeMedia;
@ -143,7 +147,6 @@ private:
items_array items_;
std::wstring odf_packet_;
NSFonts::IApplicationFonts *applicationFonts_;
};
}

View File

@ -108,14 +108,6 @@ static const std::wstring _ooxShapeType[]=
L"custGeom",//uses sub-sub type,
L"polygon",
L"roundRect",
L"bentConnector3",
L"curvedConnector3",
L"",//3-D shape
L"",
L"polyline",
L"cube",
L"ellipse", //sphere
L""
};
@ -251,16 +243,12 @@ 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"heptagon") ||
std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
values.clear();
}
else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
names.push_back(L"vf");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
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");
@ -430,7 +418,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
shapeGeomPreset = L"rect";
}
}
else if (sub_type <= 16 && sub_type >= 0)
else if (sub_type < 10 && sub_type >= 0)
{
shapeGeomPreset = _ooxShapeType[sub_type]; //odf -> oox
}
@ -440,7 +428,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
CP_XML_WRITER(strm)
{
if (sub_type == 6 || sub_type == 8 || sub_type == 14)
if (sub_type == 6 || sub_type == 8)
{
CP_XML_NODE(L"a:custGeom")
{
@ -499,7 +487,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
}
}
}
if (bWordArt || lined)
if (bWordArt)
{
_oox_fill no_fill;
oox_serialize_fill(strm, no_fill);
@ -524,16 +512,29 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
_CP_OPT(double) dSkewY;
odf_reader::GetProperty(additional, L"svg:skewY", dSkewY);
_CP_OPT(double) dRotateAngle;
if (dRotate || dSkewX || dSkewY)
{
double tmp=0;
if (dRotate)tmp += *dRotate;
//if (dSkewX)tmp += *dSkewX;
//if (dSkewY)tmp += (*dSkewY) + 3.1415926;
dRotateAngle = tmp;
}
CP_XML_NODE(xfrm)
{
if (dRotate)
if (dRotateAngle)
{
double d = 360 - dRotate.get() * 180. / 3.14159265358979323846;
CP_XML_ATTR(L"rot", (int)( d * 60000) ); //60 000 per 1 gr - 19.5.5 oox
double d =360 - dRotateAngle.get() * 180. / 3.14159265358979323846;
d *= 60000; //60 000 per 1 gr - 19.5.5 oox
CP_XML_ATTR(L"rot", (int)d);
}
_CP_OPT(bool)bVal;
if (odf_reader::GetProperty(additional, L"flipH", bVal))
if (odf_reader::GetProperty(additional,L"flipH", bVal))
CP_XML_ATTR(L"flipH", bVal.get());
if (odf_reader::GetProperty(additional,L"flipV", bVal))

View File

@ -83,15 +83,13 @@ namespace oox {
class _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), lined(false), connector(false), name(L"object"), extExternal(false)
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object"), extExternal(false)
{
}
RelsType type;
bool inGroup;
size_t id;
bool lined;
bool connector;
std::wstring name;
int sub_type; //odf

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), bGrayscale(false)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
{
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>();}
@ -189,19 +189,7 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons
{
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
}
}
if (val.bitmap->bGrayscale)
{
CP_XML_NODE(ns + L":grayscl");
}
if (val.bitmap->luminance || val.bitmap->contrast)
{
CP_XML_NODE(ns + L":lum")
{
if (val.bitmap->luminance) CP_XML_ATTR2(L"bright", (int)(*val.bitmap->luminance * 1000));
if (val.bitmap->contrast) CP_XML_ATTR2(L"contrast", (int)(*val.bitmap->contrast * 1000));
}
}
}
}
if (val.bitmap->bCrop)
{
@ -304,7 +292,7 @@ void oox_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val, co
{
CP_XML_NODE(ns + L":gsLst")
{
for (size_t i = 0; i < val.gradient->colors.size(); i++)
for (int i = 0; i < val.gradient->colors.size(); i++)
{
oox_gradient_fill::_color_position & col = val.gradient->colors[i];
CP_XML_NODE(ns + L":gs")

View File

@ -75,10 +75,6 @@ namespace oox {
_CP_OPT(int) dpi;
_CP_OPT(bool) rotate;
bool bGrayscale;
_CP_OPT(double) luminance;
_CP_OPT(double) contrast;
};
/////////////////////////////////////////////////////////
class oox_hatch_fill;

View File

@ -79,15 +79,14 @@ static std::wstring get_mime_type(const std::wstring & extension)
else if (L"wav" == extension) return L"audio/wav";
else if (L"mp3" == extension) return L"audio/mpeg";
else if (L"wma" == extension) return L"audio/x-ms-wma";
else if (L"m4a" == extension) return L"audio/m4a";
else if (L"m4a" == extension) return L"audio/unknown";
else if (L"avi" == extension) return L"video/x-msvideo";
else if (L"wmv" == extension) return L"video/x-ms-wmv";
else if (L"mov" == extension) return L"video/mov";
else if (L"mp4" == extension) return L"video/mp4";
else if (L"m4v" == extension) return L"video/m4v";
else if (L"mkv" == extension) return L"video/mkv";
else if (L"webm" == extension) return L"video/webm";
else if (L"mov" == extension) return L"video/unknown";
else if (L"mp4" == extension) return L"video/unknown";
else if (L"m4v" == extension) return L"video/unknown";
else if (L"mkv" == extension) return L"video/unknown";
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
else if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

View File

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

View File

@ -42,7 +42,7 @@ namespace oox {
struct _pptx_comment
{
int x_, y_;
size_t x_, y_;
int author_id_;
int idx_;

View File

@ -45,6 +45,8 @@
#include "pptx_default_serializes.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
namespace odf_reader
@ -70,10 +72,13 @@ pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odf
,last_idx_placeHolder (1)
,last_uniq_big_id (1)
{
applicationFonts_ = NSFonts::NSApplication::Create();
}
pptx_conversion_context::~pptx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void pptx_conversion_context::set_output_document(package::pptx_document * document)
@ -83,7 +88,8 @@ void pptx_conversion_context::set_output_document(package::pptx_document * docum
void pptx_conversion_context::set_font_directory(std::wstring pathFonts)
{
pptx_slide_context_.get_mediaitems().set_font_directory(pathFonts);
if (applicationFonts_ )
applicationFonts_->InitializeFromFolder(pathFonts);
}
void pptx_conversion_context::process_layouts()
@ -327,7 +333,7 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().set_presentation (presentation_);
output_document_->get_ppt_files().set_comments (comments);
output_document_->get_ppt_files().set_authors_comments (authors_comments_);
output_document_->get_ppt_files().set_media (get_mediaitems());
output_document_->get_ppt_files().set_media (get_mediaitems(), applicationFonts_);
output_document_->get_content_types_file().set_media(get_mediaitems());
}

View File

@ -157,6 +157,7 @@ private:
package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_;
NSFonts::IApplicationFonts * applicationFonts_;
pptx_slide_context pptx_slide_context_;
pptx_text_context pptx_text_context_;

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);
@ -254,65 +254,7 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
}
} // CP_XML_WRITER
}
void pptx_serialize_connector(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:cxnSp")
{
CP_XML_NODE(L"p:nvCxnSpPr")
{
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"id", val.id);//числовое значение val.rId
CP_XML_ATTR(L"name", val.name);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
CP_XML_NODE(L"p:cNvCxnSpPr")//non visual properies (собственно тока 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);
}
}
CP_XML_NODE(L"p:nvPr")
{
if (val.place_holder_type_.length()>0)
{
CP_XML_NODE(L"p:ph")
{
CP_XML_ATTR(L"type",val.place_holder_type_);
if (val.place_holder_idx_ > 0) CP_XML_ATTR(L"idx", val.place_holder_idx_);
if (val.place_holder_type_ == L"dt") { CP_XML_ATTR(L"sz", L"half"); }
if (val.place_holder_type_ == L"ftr") { CP_XML_ATTR(L"sz", L"quarter"); }
if (val.place_holder_type_ == L"sldNum"){ CP_XML_ATTR(L"sz", L"quarter"); }
}
}
}
}
CP_XML_NODE(L"p:spPr")
{
_CP_OPT(bool) bNoRect;
odf_reader::GetProperty(val.additional,L"no_rect",bNoRect);
if (!bNoRect)
{
if (val.cx != 0 || val.cy != 0) //layout
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
}
val.serialize_shape(CP_XML_STREAM());
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
}
pptx_serialize_text(CP_XML_STREAM(), val);
}
} // CP_XML_WRITER
}
void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
@ -439,10 +381,7 @@ void _pptx_drawing::serialize(std::wostream & strm)
{
if (type == typeShape)
{
//if (connector) only for ms prst connectors, but not custom!!
// pptx_serialize_connector(strm, *this);
//else
pptx_serialize_shape(strm, *this);
pptx_serialize_shape(strm, *this);
}
else if (type == typeImage)
{

View File

@ -509,11 +509,11 @@ void ppt_files::add_notesMaster(slide_content_ptr slide)
{
notesMaster_files_.add_slide(slide);
}
void ppt_files::set_media(mediaitems & _Mediaitems)
void ppt_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{

View File

@ -217,7 +217,7 @@ public:
void add_notes (slide_content_ptr sheet);
void add_notesMaster(slide_content_ptr sheet);
void set_media(mediaitems & _Mediaitems);
void set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void add_charts(chart_content_ptr chart);
void add_theme (pptx_xml_theme_ptr theme);

View File

@ -147,13 +147,11 @@ void pptx_slide_context::Impl::process_drawings()
{
for (size_t i = 0; i < objects_.size(); i++)
{
_pptx_drawing drawing = _pptx_drawing();
_pptx_drawing drawing =_pptx_drawing();
drawing.type = objects_[i].type_;
drawing.name = objects_[i].name_;
drawing.id = next_rId();
drawing.lined = objects_[i].lined_;
drawing.connector = objects_[i].connector_;
drawing.type = objects_[i].type_;
drawing.name = objects_[i].name_;
drawing.id = next_rId();
process_common_properties(objects_[i], drawing);
@ -230,8 +228,6 @@ void pptx_slide_context::default_set()
impl_->object_description_.clipping_string_= L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->object_description_.connector_ = false;
impl_->object_description_.lined_ = false;
impl_->object_description_.hlinks_.clear();
impl_->object_description_.action_.clear();
@ -267,20 +263,21 @@ void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt
impl_->object_description_.svg_rect_ = _rect(width_pt, height_pt, x_pt, y_pt);
}
void pptx_slide_context::set_rotate(double angle, bool translate)
void pptx_slide_context::set_rotate(double angle)
{
set_property(odf_reader::_property(L"svg:rotate", angle));
set_property(odf_reader::_property(L"svg:rotate",angle));
if (impl_->object_description_.svg_rect_ && translate)
if (impl_->object_description_.svg_rect_)
{
_rect &r = impl_->object_description_.svg_rect_.get();
double new_x = (r.cx / 2 * cos(-angle) - r.cy / 2 * sin(-angle) ) - r.cx / 2;
double new_y = (r.cx / 2 * sin(-angle) + r.cy / 2 * cos(-angle) ) - r.cy / 2;
r.x += new_x;
r.y += new_y;
//вращение в open office от центральной точки
_rect r = impl_->object_description_.svg_rect_.get();
//r.x_-=r.width_;
//r.y_-=r.height_;
impl_->object_description_.svg_rect_= r;
}
}
void pptx_slide_context::set_translate(double x_pt, double y_pt)
{
if (impl_->object_description_.svg_rect_)
@ -324,18 +321,12 @@ void pptx_slide_context::set_clipping(const std::wstring & str)
{
impl_->object_description_.clipping_string_= str;
}
void pptx_slide_context::set_fill(_oox_fill & fill)
{
impl_->object_description_.fill_= fill;
}
void pptx_slide_context::set_is_line_shape(bool val)
{
impl_->object_description_.lined_ = val;
}
void pptx_slide_context::set_is_connector_shape(bool val)
{
impl_->object_description_.connector_ = val;
}
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & href)
{
++hlinks_size_;
@ -481,8 +472,8 @@ void pptx_slide_context::set_media_param(std::wstring name, std::wstring value)
void pptx_slide_context::set_image(const std::wstring & path)
{
size_t pos_replaicement = path.find(L"ObjectReplacements");
if (pos_replaicement != std::wstring::npos)
int pos_replaicement = path.find(L"ObjectReplacements");
if (pos_replaicement >= 0)
{
if (path.length() - (pos_replaicement + 18) < 2)
return; //object without image
@ -495,7 +486,7 @@ void pptx_slide_context::set_image(const std::wstring & path)
}
else if (impl_->use_image_replacement_)
{
impl_->object_description_.fill_.type = 2;
impl_->object_description_.fill_.type = 2;
impl_->object_description_.fill_.bitmap = oox::oox_bitmap_fill::create();
impl_->object_description_.fill_.bitmap->xlink_href_ = path;
impl_->object_description_.fill_.bitmap->bStretch = true;
@ -547,14 +538,8 @@ 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, sColorMode;
_CP_OPT(double) dLuminance, dContrast;
_CP_OPT(std::wstring) sTextContent;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = typeShape;
@ -562,11 +547,8 @@ 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, get_mediaitems().applicationFonts());
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->luminance = true;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;/// это ссылка на выходной внешний объект
@ -644,29 +626,25 @@ void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _
}
void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _pptx_drawing & drawing)
{
std::wstring ref, ref_image;
bool isMediaInternal = true, isMediaInternal_image = true;
std::wstring ref;
bool isMediaInternal = true;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
if (!drawing.fill.bitmap)
{
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.fill.bitmap->xlink_href_ = L"zero.png";
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
}
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
}
void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _pptx_drawing & drawing)
{
std::wstring ref, ref_image;
bool isMediaInternal = true, isMediaInternal_image = true;
std::wstring ref;
bool isMediaInternal = true;
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
@ -674,27 +652,26 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
drawing.extId = L"ext" + drawing.objectId;
drawing.extExternal = !isMediaInternal;
if (!drawing.fill.bitmap)
{
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
drawing.fill.bitmap->xlink_href_ = L"zero.png";
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
}
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
add_additional_rels( isMediaInternal, drawing.extId, ref, typeMedia);
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
}
void pptx_slide_context::Impl::process_common_properties(drawing_object_description & pic, _pptx_drawing & drawing)
{
if (pic.svg_rect_)
{
int val;
//todooo непонятки с отрицательными значениями
drawing.x = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
drawing.y = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
int val = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if ( val >= 0) drawing.x = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if ( val >= 0 ) drawing.y = val;
val = (int)(0.5 + odf_types::length(pic.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu));
if ( val >=0 ) drawing.cx = val;

View File

@ -59,11 +59,11 @@ public:
void set_transitionAction (bool val);
void set_transitionSpeed (std::wstring val);
///////////////////////////////////////////////////////////////////////////////////////////
void set_rect (double width_pt, double height_pt, double x_pt, double y_pt);
void set_rect (double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate (double x_pt, double y_pt);
void set_scale (double cx_pt, double cy_pt);
void set_rotate (double angle, bool translate = false);
void set_rotate (double angle);
void set_name (std::wstring const & name);
void set_anchor (std::wstring anchor, double x_pt, double y_pt);
@ -72,9 +72,6 @@ public:
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_is_line_shape(bool val);
void set_is_connector_shape(bool val);
void set_placeHolder_type (std::wstring typeHolder);
void set_placeHolder_idx (int idx);

View File

@ -99,6 +99,7 @@ private:
odf_reader::odf_read_context & odf_context_ ;
std::wstring hyperlink_hId;
bool in_span;
bool in_paragraph;
@ -274,7 +275,7 @@ void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name, std::
void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_properties & propertiesOut, int Level)
{
if (Level < 0)return;
if (Level <0)return;
if (list_style_stack_.empty())return;
odf_reader::style_list_level_properties *list_properties= NULL;
@ -361,7 +362,7 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{
get_styles_context().start();
int level = list_style_stack_.size() - 1;
int level = list_style_stack_.size()-1;
odf_reader::paragraph_format_properties paragraph_properties_;
@ -642,7 +643,7 @@ void pptx_text_context::Impl::start_list_item(bool restart)
void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Continue)
{
if (paragraphs_cout_ > 0 && ( in_paragraph || list_style_stack_.empty()))
if (paragraphs_cout_ > 0 && in_paragraph)
{
dump_paragraph();
}

View File

@ -62,7 +62,7 @@ public:
CP_XML_NODE(L"authors")
{
for (size_t i = 0 ; i < author_list_.size(); i++)
for (int 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 (size_t i = 0 ; i < xlsx_comment_.size(); i++)
for (int 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 (size_t i = 0; i < xlsx_comment_.size(); i++)
for (int 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 (size_t i = 0; i < author_list_.size(); i++)
for (long i = 0; i < author_list_.size(); i++)
{
if (c.author_ == author_list_[i])
{

View File

@ -36,10 +36,8 @@
#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 {
@ -150,10 +148,7 @@ public:
//CP_XML_ATTR(L"aboveAverage" , 0);
if (c.rules[j].type == 1)
{
if (c.rules[j].formula_type)
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
else
CP_XML_ATTR(L"type", L"cellIs");
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
if ((c.rules[j].formula) && (!c.rules[j].formula->empty()))
{
CP_XML_NODE(L"formula")
@ -182,11 +177,13 @@ public:
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
CP_XML_NODE(L"color")
if (c.rules[j].color.size() > 0)
{
CP_XML_ATTR(L"rgb", !c.rules[j].color.empty() ? c.rules[j].color[0] : L"FF000000");
}
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"rgb", c.rules[j].color[0]);
}
}
}
}
else if (c.rules[j].type == 3)
@ -248,7 +245,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)
@ -263,21 +260,7 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
int pos = -1;
std::wstring val;
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(")))
if ( 0 <= (pos = f.find(L"formula-is(")))
{
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
val = f.substr(11, f.size() - 12);
@ -309,45 +292,6 @@ 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";
@ -358,10 +302,14 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
if (0 <= (pos = f.find(L"(")))
{
val = f.substr(pos + 1, f.length() - pos - 2);
if (!val.empty())
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
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";
@ -413,8 +361,6 @@ 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) );
@ -452,11 +398,7 @@ 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 cfvo.val = L"0";
}
else if (!value.empty()) cfvo.val = value;
impl_->conditionalFormattings_.back().rules.back().cfvo.push_back(cfvo);
}

View File

@ -45,6 +45,13 @@ class xlsx_defined_names::Impl
public:
void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId)
{
int is_file_link = 0;
if (!formula)
{
if ((is_file_link = ref.find(L"\\")) >=0) return;
if ((is_file_link = ref.find(L"/")) >=0) return;
}
formulasconvert::odf2oox_converter converter;
std::wstring oox_ref;
@ -65,31 +72,34 @@ public:
void xlsx_serialize(std::wostream & _Wostream)
{
if (content_.empty()) return;
CP_XML_WRITER(_Wostream)
if (content_.size() > 0)
{
CP_XML_NODE(L"definedNames")
CP_XML_WRITER(_Wostream)
{
for (size_t i = 0 ; i < content_.size(); i++)
CP_XML_NODE(L"definedNames")
{
CP_XML_NODE(L"definedName")
for (int i = 0 ; i < content_.size(); i++)
{
CP_XML_ATTR(L"name", content_[i].name);
if (content_[i].tableId >= 0)
{
CP_XML_ATTR(L"localSheetId", content_[i].tableId);
}
if ( content_[i].ref.find(L"#REF!") != std::wstring::npos )
{
CP_XML_ATTR(L"comment", content_[i].ref);
CP_XML_CONTENT(L"#REF!");
}
else
CP_XML_CONTENT(content_[i].ref);
CP_XML_NODE(L"definedName")
{
CP_XML_ATTR(L"name", content_[i].name);
if (content_[i].tableId >= 0)
{
CP_XML_ATTR(L"localSheetId", content_[i].tableId);
}
int pos;
if ( (pos = content_[i].ref.find(L"#REF!")) >= 0 )
{
CP_XML_ATTR(L"comment", content_[i].ref);
CP_XML_CONTENT(L"#REF!");
}
else
CP_XML_CONTENT(content_[i].ref);
}
}
}
}

View File

@ -46,6 +46,7 @@ namespace oox {
xlsx_defined_names();
~xlsx_defined_names();
public:
void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId);
void xlsx_serialize(std::wostream & _Wostream);

View File

@ -162,7 +162,7 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
}
CP_XML_NODE(L"xdr:cNvSpPr")//non visual properies (собственно тока 1 там)
{
if (val.sub_type == 1)CP_XML_ATTR(L"txBox", 1);
if (val.sub_type==1)CP_XML_ATTR(L"txBox", 1);
}
} // xdr:nv_Pr
CP_XML_NODE(L"xdr:spPr")
@ -171,7 +171,11 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
val.serialize_shape(CP_XML_STREAM());
oox_serialize_ln(CP_XML_STREAM(),val.additional, val.lined);
bool draw_always = false;
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
draw_always = true;
oox_serialize_ln(CP_XML_STREAM(),val.additional, draw_always);
} // xdr:spPr
xlsx_serialize_text(CP_XML_STREAM(), val);

View File

@ -53,7 +53,8 @@ namespace oox {
class xlsx_drawing_context_handle::Impl
{
public:
Impl(mediaitems & items) : items_(items), next_rId_(1), next_drawing_id_(1)
Impl(mediaitems & items)
: items_(items), next_rId_(1), next_drawing_id_(1)
{
}
@ -161,8 +162,6 @@ void xlsx_drawing_context::clear()
{
impl_->object_description_.type_ = typeUnknown;
impl_->object_description_.in_group_ = false;
impl_->object_description_.lined_ = false;
impl_->object_description_.connector_ = false;
impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.name_ = L"";
impl_->object_description_.anchor_ = L"";
@ -203,25 +202,20 @@ void xlsx_drawing_context::end_group()
{
if (impl_->groups_.size() < 1) return;
if (impl_->groups_.back()->svg_rect_)
_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++)
{
_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;
}
_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_ && impl_->groups_.back()->svg_rect_)
if (impl_->groups_.back()->in_group_)
{
_rect & objct_rect = impl_->groups_.back()->svg_rect_.get();
@ -257,8 +251,7 @@ void xlsx_drawing_context::start_drawing(std::wstring const & name)
void xlsx_drawing_context::end_drawing()
{
if (impl_->object_description_.in_group_ &&
impl_->object_description_.svg_rect_)
if (impl_->object_description_.in_group_)
{
_rect & objct_rect = impl_->object_description_.svg_rect_.get();
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
@ -361,18 +354,17 @@ void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
}
}
void xlsx_drawing_context::set_rotate(double angle, bool translate)
void xlsx_drawing_context::set_rotate(double angle)
{
set_property(odf_reader::_property(L"svg:rotate", angle));
if (impl_->object_description_.svg_rect_ && translate)
if (impl_->object_description_.svg_rect_)
{
_rect &r = impl_->object_description_.svg_rect_.get();
double new_x = (r.cx / 2 * cos(-angle) - r.cy / 2 * sin(-angle) ) - r.cx / 2;
double new_y = (r.cx / 2 * sin(-angle) + r.cy / 2 * cos(-angle) ) - r.cy / 2;
_rect & r = impl_->object_description_.svg_rect_.get();
r.x += new_x;
r.y += new_y;
//r.x -= r.width_/2;
//r.y -= r.height_/2;
}
}
void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt)
@ -541,12 +533,8 @@ 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, sColorMode;
GetProperty(obj.additional_, L"text-content", sTextContent);
GetProperty(obj.additional_, L"color-mode", sColorMode);
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
_CP_OPT(std::wstring) sTextContent;
GetProperty(obj.additional_,L"text-content",sTextContent);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
@ -555,12 +543,9 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
}
std::wstring fileName = odf_packet_path_ + FILE_SEPARATOR_STR + obj.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, impl_->get_mediaitems().applicationFonts());
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;
@ -677,13 +662,11 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
_xlsx_drawing drawing =_xlsx_drawing();
drawing.type = obj.type_;
drawing.name = obj.name_;
drawing.fill = obj.fill_;
drawing.inGroup = obj.in_group_;
drawing.id = impl_->next_rId();
drawing.lined = obj.lined_;
drawing.connector = obj.connector_;
drawing.type = obj.type_;
drawing.name = obj.name_;
drawing.fill = obj.fill_;
drawing.inGroup = obj.in_group_;
drawing.id = impl_->next_rId();
drawing.sub_type = obj.shape_type_;
@ -747,14 +730,6 @@ void xlsx_drawing_context::set_link(std::wstring link, RelsType typeRels)
void xlsx_drawing_context::end_action()
{
}
void xlsx_drawing_context::set_is_line_shape(bool val)
{
impl_->object_description_.lined_ = val;
}
void xlsx_drawing_context::set_is_connector_shape(bool val)
{
impl_->object_description_.connector_ = val;
}
}

View File

@ -103,16 +103,13 @@ public:
void set_translate (double x_pt, double y_pt);
void set_scale (double cx_pt, double cy_pt);
void set_rotate (double angle, bool translate = false);
void set_rotate (double angle);
void set_anchor (std::wstring anchor, double x_pt, double y_pt, bool group = false);
void set_property (odf_reader::_property p);
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_is_line_shape(bool val);
void set_is_connector_shape(bool val);
std::vector<odf_reader::_property> & get_properties();
std::wstring add_hyperlink(std::wstring const & ref);

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 (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(CP_XML_STREAM());
}

View File

@ -90,7 +90,7 @@ void xlsx_dxfs::serialize(std::wostream & _Wostream) const
{
CP_XML_ATTR(L"count", impl_->dxf_array.size());
for (size_t i = 0; i < impl_->dxf_array.size(); i++)
for (int 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 (size_t i = 0 ; i < merges_.size(); i++)
for (int i = 0 ; i < merges_.size(); i++)
{
merge & m = merges_[i];

View File

@ -41,9 +41,8 @@ namespace oox {
class xlsx_xml_worksheet::Impl
{
public:
Impl(std::wstring const & name, bool hidden) : name_(name), hidden_(hidden) {}
Impl(std::wstring const & name) : name_(name){}
std::wstring name_;
bool hidden_;
std::wstringstream cols_;
std::wstringstream sheetFormat_;
@ -53,7 +52,6 @@ public:
std::wstringstream hyperlinks_;
std::wstringstream comments_;
std::wstringstream sort_;
std::wstringstream tableParts_;
std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
std::wstringstream picture_background_;
@ -61,7 +59,6 @@ public:
std::wstringstream ole_objects_;
std::wstringstream page_props_;
std::wstringstream controls_;
std::wstringstream protection_;
rels sheet_rels_;
@ -79,18 +76,14 @@ std::wstring xlsx_xml_worksheet::name() const
{
return impl_->name_;
}
bool xlsx_xml_worksheet::hidden() const
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name)
{
return impl_->hidden_;
return boost::make_shared<xlsx_xml_worksheet>(name);
}
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name, bool hidden)
{
return boost::make_shared<xlsx_xml_worksheet>(name, hidden);
}
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name, bool hidden)
: impl_(new xlsx_xml_worksheet::Impl(name, hidden))
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name)
: impl_(new xlsx_xml_worksheet::Impl(name))
{
}
@ -106,18 +99,16 @@ 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_;
@ -162,10 +153,6 @@ std::wostream & xlsx_xml_worksheet::dataValidations()
{
return impl_->dataValidations_;
}
std::wostream & xlsx_xml_worksheet::protection()
{
return impl_->protection_;
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::sheet_rels()
{
@ -194,10 +181,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_STREAM() << impl_->sheetData_.str();
}
if (!impl_->protection_.str().empty())
{
CP_XML_STREAM() << impl_->protection_.str();
}
//оказывается порядок нахождения элементов важен !!! (для office 2010)
//объединенные ячейки раньше чем гиперлинки !!!
@ -217,6 +200,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->hyperlinks_.str();
}
}
if (!impl_->page_props_.str().empty())
{
CP_XML_STREAM() << impl_->page_props_.str();
@ -245,13 +229,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->controls_.str();
}
}
if (!impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{
CP_XML_STREAM() << impl_->tableParts_.str();
}
}
CP_XML_STREAM() << impl_->picture_background_.str();
//CP_XML_NODE(L"headerFooter){}

View File

@ -47,11 +47,10 @@ typedef _CP_PTR(xlsx_xml_worksheet) xlsx_xml_worksheet_ptr;
class xlsx_xml_worksheet: noncopyable
{
public:
xlsx_xml_worksheet(std::wstring const & name, bool hidden);
xlsx_xml_worksheet(std::wstring const & name);
~xlsx_xml_worksheet();
std::wstring name() const;
bool hidden() const;
std::wostream & cols();
std::wostream & sheetFormat();
@ -61,7 +60,6 @@ public:
std::wostream & drawing();
std::wostream & comments();
std::wostream & autofilter();
std::wostream & tableParts();
std::wostream & conditionalFormatting();
std::wostream & picture_background();
std::wostream & dataValidations();
@ -69,7 +67,6 @@ public:
std::wostream & ole_objects();
std::wostream & page_properties();
std::wostream & controls();
std::wostream & protection();
rels & sheet_rels(); //hyperlink, background image, external, media ...
@ -83,7 +80,7 @@ public:
std::pair<std::wstring, std::wstring> get_vml_drawing_link() const;
std::pair<std::wstring, std::wstring> get_comments_link() const;
static xlsx_xml_worksheet_ptr create(std::wstring const & name, bool hidden);
static xlsx_xml_worksheet_ptr create(std::wstring const & name);
private:
class Impl;

View File

@ -88,6 +88,7 @@ void xlsx_document::write(const std::wstring & RootPath)
pivot_cache_content::pivot_cache_content() : definitions_rels_file_(rels_file::create(L""))
{
}
_CP_PTR(pivot_cache_content) pivot_cache_content::create()
{
return boost::make_shared<pivot_cache_content>();
@ -96,23 +97,17 @@ _CP_PTR(pivot_cache_content) pivot_cache_content::create()
pivot_table_content::pivot_table_content() : rels_file_(rels_file::create(L""))
{
}
_CP_PTR(pivot_table_content) pivot_table_content::create()
{
return boost::make_shared<pivot_table_content>();
}
//--------------------------------------------------------------------------------------------
external_links_content::external_links_content() : rels_file_(rels_file::create(L""))
{
}
_CP_PTR(external_links_content) external_links_content::create()
{
return boost::make_shared<external_links_content>();
}
//--------------------------------------------------------------------------------------------
sheet_content::sheet_content() : rels_(rels_file::create(L""))
{
}
_CP_PTR(sheet_content) sheet_content::create()
{
return boost::make_shared<sheet_content>();
@ -203,11 +198,8 @@ void xl_files::write(const std::wstring & RootPath)
control_props_files_.set_main_document( this->get_main_document() );
control_props_files_.write(path);
}
{
external_links_files_.set_rels(&rels_files_);
external_links_files_.set_main_document(get_main_document());
external_links_files_.write(path);
}
int index = 1;
if (true)
{
//workbook_->hyperlinks->write(path);
rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"xl/workbook.xml" ) );
@ -225,6 +217,7 @@ void xl_files::write(const std::wstring & RootPath)
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");
}
if (styles_)
{
styles_->write(path);
@ -252,11 +245,6 @@ 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_)
{
drawings_->set_main_document(get_main_document());
@ -298,11 +286,11 @@ void xl_files::add_sheet(sheet_content_ptr sheet)
sheets_files_.add_sheet(sheet);
}
void xl_files::set_media(mediaitems & _Mediaitems)
void xl_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
@ -334,10 +322,6 @@ 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);
@ -346,10 +330,6 @@ void xl_files::add_control_props (simple_element_ptr element)
{
control_props_files_.add_control_props(element);
}
void xl_files::add_external_links(external_links_content_ptr content)
{
external_links_files_.add_external_links(content);
}
//----------------------------------------------------------------------------------------
void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
{
@ -438,80 +418,20 @@ void xl_pivot_table_files::write(const std::wstring & RootPath)
}
}
//------------------------------------------------------------------------------------------------------
void xl_external_links_files::add_external_links(external_links_content_ptr content)
{
external_links_.push_back(content);
}
void xl_external_links_files::write(const std::wstring & RootPath)
{
if (external_links_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"externalLinks";
NSDirectory::CreateDirectory(path.c_str());
for (size_t i = 0; i < external_links_.size(); i++)
{
const std::wstring fileName = std::wstring(L"externalLink") + 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.externalLink+xml";
contentTypes->add_override(std::wstring(L"/xl/externalLinks/") + fileName, kWSConType);
package::simple_element(fileName, external_links_[i]->content_.str()).write(path);
{
rels_files relFiles;
external_links_[i]->rels_file_->set_file_name(fileName + L".rels");
relFiles.add_rel_file(external_links_[i]->rels_file_);
relFiles.write(path);
}
if (rels_)
{
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink";
const std::wstring fileRef = std::wstring(L"externalLinks/") + fileName;
rels_->add(external_links_[i]->rId_, kWSRel, fileRef);
}
}
}
//------------------------------------------------------------------------------------------------------
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 * contentTypes = this->get_main_document()->get_content_types_file().content();

View File

@ -72,7 +72,6 @@ typedef _CP_PTR(sheet_content) sheet_content_ptr;
//------------------------------------------------------------------------
class pivot_cache_content;
typedef _CP_PTR(pivot_cache_content) pivot_cache_content_ptr;
class pivot_cache_content : boost::noncopyable
{
public:
@ -95,7 +94,6 @@ private:
//------------------------------------------------------------------------
class pivot_table_content;
typedef _CP_PTR(pivot_table_content) pivot_table_content_ptr;
class pivot_table_content : boost::noncopyable
{
public:
@ -113,28 +111,6 @@ private:
rels_file_ptr rels_file_;
};
//------------------------------------------------------------------------
class external_links_content;
typedef _CP_PTR(external_links_content) external_links_content_ptr;
class external_links_content : boost::noncopyable
{
public:
external_links_content();
static external_links_content_ptr create();
std::wstring & rId() { return rId_;}
std::wostream & content() { return content_; }
rels & get_rels() { return rels_file_->get_rels(); }
std::wstring str() { return content_.str(); }
friend class xl_external_links_files;
private:
std::wstringstream content_;
rels_file_ptr rels_file_;
std::wstring rId_;
};
//------------------------------------------------------------------------
class sheets_files : public element
{
public:
@ -155,17 +131,7 @@ 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:
@ -177,22 +143,7 @@ public:
std::vector<chart_content_ptr> charts_;
};
class xl_external_links_files : public element
{
public:
xl_external_links_files(){}
void add_external_links(external_links_content_ptr content);
virtual void write(const std::wstring & RootPath);
void set_rels(rels_files * rels)
{
rels_ = rels;
}
private:
std::vector<external_links_content_ptr> external_links_;
rels_files * rels_;
};
class xl_pivot_table_files : public element
{
public:
@ -284,7 +235,7 @@ public:
void set_sharedStrings (element_ptr Element);
void set_connections (element_ptr Element);
void add_sheet (sheet_content_ptr sheet);
void set_media (mediaitems & _Mediaitems);
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
void set_drawings (element_ptr Element);
void set_vml_drawings (element_ptr Element);
void set_comments (element_ptr Element);
@ -293,8 +244,6 @@ public:
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);
void add_external_links (external_links_content_ptr content);
private:
rels_files rels_files_;
@ -303,9 +252,7 @@ private:
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_;
xl_external_links_files external_links_files_;
element_ptr theme_;
element_ptr workbook_;
@ -330,7 +277,7 @@ public:
virtual content_types_file & get_content_types_file() { return content_type_file_; }
xl_files & get_xl_files() { return xl_files_; }
rels_files & get_rels_files() { return rels_files_; }
private:
xlsx_content_types_file content_type_file_;
xl_files xl_files_;

View File

@ -302,24 +302,12 @@ void xlsx_pivots_context::Impl::calc_headers()
std::map<size_t, size_t>::iterator pFind;
//current_.bAxisCol = false;
//current_.bAxisRow = false;
size_t min_col = 0xffffff, min_row = 0xffffff;
size_t prev_col, prev_row;
for (size_t i = 0; i < current_.headers.size(); i++)//("F18","F19","F23","G21","H21")
{
size_t row = 0, col = 0;
oox::getCellAddressInv(current_.headers[i], col, row);
//if (i > 0)
//{
// if (col != prev_col)current_.bAxisCol = true;
// if (row != prev_row)current_.bAxisRow = true;
//}
prev_col = col;
prev_row = row;
if (col < min_col) min_col = col;
if (row < min_row) min_row = row;
@ -552,7 +540,7 @@ void xlsx_pivots_context::Impl::sort_fields()
}
else
{
if (count_items_row < (int)current_.fields[i].caches.size())
if (count_items_row < current_.fields[i].caches.size())
bAddRepeateRow = true;
}
}
@ -590,17 +578,11 @@ void xlsx_pivots_context::Impl::sort_fields()
i--;
}
}
bool data_col_repeate = false;
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow)) && (current_.grand_total == 1 || current_.grand_total == 3 || current_.data_on_row))/* && bShowEmptyRow*/
{
current_.row_fields.push_back(-2);
data_col_repeate = true;
}
if (!data_col_repeate && (bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol)) && (current_.grand_total == 1 || current_.grand_total == 2 || current_.data_fields.size() > 1 ))/* && bShowEmptyCol*/ ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
if ((bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol))/* && bShowEmptyCol*/) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
current_.col_fields.push_back(-2);
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))/* && bShowEmptyRow*/)
current_.row_fields.push_back(-2);
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{
@ -790,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 (int k = 0; k < ind_fld; k++)
for (size_t k = 0; k < ind_fld; k++)
{
if (current_.fields[k].type != 7 ) fld++;
}
@ -833,7 +815,7 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
}
std::wstring name;
if (ind_field_dirty >= 0 && ind_field_dirty < (int)current_.fields.size())
if (ind_field_dirty >= 0 && ind_field_dirty < current_.fields.size())
{
switch(current_.fields[ind_field_dirty].function)
{
@ -1488,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 > (int)impl_->current_.fields.back().caches.size())
while (index > 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 (size_t i = 0; i < region_.size(); i++)
for (int 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 < (int)region_.size(); i++)
for (i = 0; i < region_.size(); i++)
{
if (region_[i].count + c_skip > offset)
break;
@ -119,7 +119,7 @@ public:
}
for (size_t i = 0; i < region_.size(); i++)
for (int 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 (size_t i = 0; i < region_.size(); i++)
for (int i = 0; i < region_.size(); i++)
{
region & r = region_[i];

View File

@ -44,7 +44,6 @@
#include "../formulasconvert/formulasconvert.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
namespace cpdoccore {
namespace oox {
@ -82,8 +81,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
std::wstring ref1, ref2;
size_t col_1, row_1, col_2, row_2;
size_t pos = ref.find(L":");
if (pos != std::wstring::npos)
int pos = ref.find(L":");
if (pos >= 0)
{
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
@ -135,29 +134,10 @@ 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),
bRTL(false),
bHidden(false),
bProtected(false)
{
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();
bEndTable(false)
if (table_prop)
{
if (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;
}
if ((table_prop->content().table_display_) && (false == table_prop->content().table_display_))
{
bHidden = true;
}
}
{
memset(&group_row_,0,sizeof(_group_row));
}
void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
@ -169,31 +149,6 @@ 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;
}
void xlsx_table_state::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
bProtected = val;
protect_key = key;
size_t pos = algorithm.find(L"#");
if (pos != std::wstring::npos)
{
protect_key_algorithm = algorithm.substr(pos + 1);
}
//test
//CRYPT::odfWriteProtect protect;
//protect.SetProtectKey(DecodeBase64(protect_key));
//protect.SetPassword(L"123");
//bool res = protect.Verify();
}
unsigned int xlsx_table_state::columns_count() const
{
return columns_count_;
@ -240,7 +195,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 < (int)column_default_cell_style_name_.size())
if (current_table_column_ + 1 < column_default_cell_style_name_.size())
return column_default_cell_style_name_.at(current_table_column_ + 1);
else
{
@ -269,10 +224,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);
@ -286,16 +241,16 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
rows_spanned_.push_back(xlsx_row_spanned());
}
if ((int)rows_spanned_.size() <= current_table_column_)
if (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)
@ -418,21 +373,6 @@ void xlsx_table_state::serialize_background (std::wostream & strm)
}
}
}
void xlsx_table_state::serialize_protection (std::wostream & strm)
{
if (!bProtected) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"sheetProtection")
{
CP_XML_ATTR(L"sheet", 1);
CP_XML_ATTR(L"objects", 1);
CP_XML_ATTR(L"scenarios", 1);
//convert protection odf->ooxml impossible without password !!!
}
}
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
@ -481,9 +421,6 @@ 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++)
{
@ -521,6 +458,7 @@ 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.

View File

@ -32,7 +32,6 @@
#pragma once
#include <vector>
#include <map>
#include "xlsx_row_spanned.h"
#include "xlsx_merge_cells.h"
@ -54,68 +53,27 @@ 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
{
public:
xlsx_data_range() : byRow(true), filter(false), bTablePart(true), withHeader(false), cell_start(0,0), cell_end(0,0) {}
xlsx_data_range() : byRow(true), filter(false), withHeader(false), cell_start(0,0), cell_end(0,0) {}
std::wstring table_name;
std::wstring name;
std::wstring ref;
std::pair<int, int> cell_start;
std::pair<int, int> cell_end;
bool bTablePart;
bool byRow;
bool filter;
bool withHeader;
std::vector<std::pair<size_t, bool>> bySort; //field + order
std::vector<std::pair<int, bool>> bySort; //field + order
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
std::vector<std::wstring> header_values;
void set_header(size_t row, size_t col1, size_t col2)
{
row_header = row;
start_column_header = col1;
end_column_header = col2;
for (size_t i = start_column_header; i <= end_column_header; i++)
header_values.push_back(L"");
}
void set_header_value(size_t col, size_t row, const std::wstring& value)
{
while (col - start_column_header + 1 >= header_values.size())
header_values.push_back(L"");
std::map<std::wstring, int>::iterator pFind = map_unique_header_values.find(value);
if (pFind == map_unique_header_values.end())
{
map_unique_header_values.insert(std::make_pair(value, 1));
header_values[col - start_column_header] = value;
}
else
{
pFind->second++;
header_values[col - start_column_header] = value + std::to_wstring(pFind->second);
}
}
bool in_header(size_t col, size_t row)
{
return (row_header == row && (col >= start_column_header && col <= end_column_header));
}
private:
size_t row_header;
size_t start_column_header;
size_t end_column_header;
std::map<std::wstring, int> map_unique_header_values;
};
class xlsx_table_state
@ -124,10 +82,7 @@ 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 set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
@ -183,35 +138,27 @@ public:
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
std::wstring get_table_name() const { return tableName_; }
int get_table_id() const { return tableId_; }
bool get_table_hidden() const { return bHidden; }
struct _group_row
{
bool enabled = false;
int count = 0;
int level = 0;
bool collapsed = false;
bool enabled;
int count;
int level;
bool collapsed;
}group_row_;
friend class xlsx_conversion_context;
friend class xlsx_table_context;
private:
xlsx_conversion_context * context_;
bool bProtected;
std::wstring protect_key;
std::wstring protect_key_algorithm;
bool bRTL;
bool bEndTable;
bool bHidden;
xlsx_conversion_context * context_;
std::wstring tableName_;
int tableId_;

View File

@ -60,20 +60,23 @@ xlsx_table_state_ptr xlsx_table_context::state()
return xlsx_table_state_ptr();
}
bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref)
void xlsx_table_context::start_database_range(std::wstring tableName, std::wstring ref)
{
formulasconvert::odf2oox_converter convert;
std::wstring oox_ref = convert.convert_named_ref(ref);
ref = convert.convert_named_ref(ref);
std::wstring ref1, ref2;
size_t pos = oox_ref.find(L":");
int pos = ref.find(L":");
std::wstring xlsx_table_name;
if (pos != std::wstring::npos)
if (pos >= 0)
{
ref1 = oox_ref.substr(0, pos );
ref2 = oox_ref.substr(pos + 1);
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
xlsx_data_ranges_.back()->table_name = tableName;
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
pos = ref1.find(L"!");
if (pos > 0)
@ -85,33 +88,23 @@ bool xlsx_table_context::start_database_range(const std::wstring & name, const s
pos = ref2.find(L"!");
if (pos > 0) ref2 = ref2.substr(pos + 1);
size_t col1, col2, row1, row2;
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
getCellAddressInv(ref1, col1, row1);
getCellAddressInv(ref2, col2, row2);
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2)
{//check range in pivots
xlsx_data_ranges_.back()->bTablePart = false;
}
xlsx_data_ranges_.back()->name = name;
xlsx_data_ranges_.back()->table_name = xlsx_table_name;
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col1, row1);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col2, row2);
xlsx_data_ranges_.back()->set_header(row1, col1, col2);
size_t col, row;
getCellAddressInv(ref1, col, row);
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col,row);
getCellAddressInv(ref2, col, row);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col,row);
}
if (!xlsx_table_name.empty())
{
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
xlsx_data_ranges_map_.insert(std::pair<std::wstring, int> (xlsx_table_name, xlsx_data_ranges_.size() - 1));
}
return true;
}
void xlsx_table_context::set_database_orientation (bool val)
{
@ -135,63 +128,6 @@ void xlsx_table_context::end_database_range()
{
}
void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
{
if (index < 0 || index > xlsx_data_ranges_.size()) return;
size_t col = state()->current_column();
size_t row = state()->current_row();
xlsx_data_ranges_[index]->set_header_value(col, row, value);
}
void xlsx_table_context::check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref)
{
std::wstring ref1, ref2;
size_t col_1, row_1, col_2, row_2;
size_t pos = ref.find(L":");
if (pos != std::wstring::npos)
{
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
}
getCellAddressInv(ref1, col_1, row_1);
getCellAddressInv(ref2, col_2, row_2);
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
{
if (xlsx_data_ranges_[i]->table_name != table_name) continue;
//if ( xlsx_data_ranges_[i]->cell_start.second < row_2 || xlsx_data_ranges_[i]->cell_end.second > row_1
// || xlsx_data_ranges_[i]->cell_end.first < col_1 || xlsx_data_ranges_[i]->cell_start.first > col_2 )
if (((col_1 <= xlsx_data_ranges_[i]->cell_start.first && xlsx_data_ranges_[i]->cell_start.first <= col_2) ||
(xlsx_data_ranges_[i]->cell_start.first <= col_1 && col_1 <= xlsx_data_ranges_[i]->cell_end.first))
&&
(( row_1 <= xlsx_data_ranges_[i]->cell_start.second && xlsx_data_ranges_[i]->cell_start.second <= row_2) ||
(xlsx_data_ranges_[i]->cell_start.second <= row_1 && row_1 <= xlsx_data_ranges_[i]->cell_end.second )))
{
xlsx_data_ranges_[i]->bTablePart = false;
}
}
}
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_.size(); i++)
{
if (xlsx_data_ranges_[i]->table_name != state()->get_table_name()) continue;
if (/*(xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)&& */
xlsx_data_ranges_[i]->in_header(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 ));
@ -204,19 +140,17 @@ xlsx_text_context_(textContext)
{
}
void xlsx_table_context::start_table(const std::wstring & tableName, const std::wstring & tableStyleName, int id)
void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName, int id)
{
xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName, id);
xlsx_table_states_.push_back( state);
}
void xlsx_table_context::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
xlsx_table_states_.back()->set_protection(val, key, algorithm);
}
void xlsx_table_context::end_table()
{
//xlsx_table_states_.pop_back();
}
}
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
{
state()->start_cell(columnsSpanned, rowsSpanned);
@ -321,122 +255,9 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
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()->get_table_name());
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
// из за дебелизма мсофис которому ОБЯЗАТЕЛЬНО нужно прописывать имена колонок таблицы (и они должны быть еще
// прописаны и в самих данных таблицы !!
int i = xlsx_data_ranges_[it->second]->header_values.size() - 1;
for (; i >= 0; i--)
{
if (false == xlsx_data_ranges_[it->second]->header_values[i].empty())
{
break;
}
}
if (i == -1)
{
xlsx_data_ranges_[it->second]->bTablePart = false;
continue;
}
else
{
size_t erase = xlsx_data_ranges_[it->second]->header_values.size() - 1 - i;
if (erase > 0)
{
xlsx_data_ranges_[it->second]->header_values.erase(xlsx_data_ranges_[it->second]->header_values.begin() + i + 1, xlsx_data_ranges_[it->second]->header_values.end());
xlsx_data_ranges_[it->second]->cell_end.first -= erase;
std::wstring ref1 = getCellAddress(xlsx_data_ranges_[it->second]->cell_start.first, xlsx_data_ranges_[it->second]->cell_start.second);
std::wstring ref2 = getCellAddress(xlsx_data_ranges_[it->second]->cell_end.first, xlsx_data_ranges_[it->second]->cell_end.second);
xlsx_data_ranges_[it->second]->ref = ref1 + L":" + ref2;
}
}
//--------------------------------------------------------
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]->name);
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->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_[it->second]->header_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;
@ -452,8 +273,6 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
if (xlsx_data_ranges_[it->second]->filter)
{
if (cell_start.first < 0 || xlsx_data_ranges_[it->second]->cell_start.first < cell_start.first )
@ -479,16 +298,12 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
{
CP_XML_NODE(L"autoFilter")
{
//в автофильтре тока простые диапазоны .. для сложных - tablePart
//в автофильтре тока простые диапазоны .. для сложных нужно выделять tablePart - todooo
CP_XML_ATTR(L"ref", getCellAddress(cell_start.first, cell_start.second) + L":" + getCellAddress(cell_end.first, cell_end.second));
//CP_XML_ATTR(L"ref", ref);
}
}
}
void xlsx_table_context::serialize_protection(std::wostream & _Wostream)
{
return state()->serialize_protection(_Wostream);
}
void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
{
return state()->serialize_conditionalFormatting(_Wostream);

View File

@ -48,8 +48,7 @@ class xlsx_table_context
public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
void start_table(const std::wstring &tableName, const std::wstring & tableStyleName, int id);
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void end_table();
void start_cell(const std::wstring & formula,
@ -83,7 +82,6 @@ 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);
@ -95,7 +93,6 @@ public:
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_data_validation (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();
@ -114,25 +111,23 @@ public:
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
bool start_database_range(const std::wstring &table_name, const std::wstring &ref);
void start_database_range(std::wstring table_name, std::wstring ref);
void set_database_orientation (bool val);
void set_database_header (bool val);
void set_database_filter (bool val);
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);
void check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref);
void add_database_sort (int field_number, int order);
void end_database_range();
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::multimap<std::wstring, int> xlsx_data_ranges_map_;
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
};

View File

@ -45,6 +45,7 @@
#include "../odf/odfcontext.h"
#include "../odf/calcs_styles.h"
#include "../../DesktopEditor/graphics/pro/Fonts.h"
namespace cpdoccore {
@ -70,15 +71,14 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
math_context_ (odf_document_->odf_context().fontContainer(), true),
xlsx_style_ (this),
maxDigitSize_ (std::make_pair(-1.f, -1.f) ),
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),
default_style_ ( (std::numeric_limits<size_t>::max)() ),
mediaitems_ (odf_document_->get_folder()),
xlsx_drawing_context_handle_(mediaitems_)
{
applicationFonts_ = NSFonts::NSApplication::Create();
}
std::unordered_map<std::wstring, int> xlsx_conversion_context::mapExternalLink_;
void xlsx_conversion_context::set_output_document (package::xlsx_document * document)
{
output_document_ = document;
@ -86,11 +86,15 @@ void xlsx_conversion_context::set_output_document (package::xlsx_document * docu
xlsx_conversion_context::~xlsx_conversion_context()
{
if (applicationFonts_)
delete applicationFonts_;
}
void xlsx_conversion_context::set_font_directory(std::wstring pathFonts)
{
mediaitems_.set_font_directory(pathFonts);
if (applicationFonts_ == NULL) return;
applicationFonts_->InitializeFromFolder(pathFonts);
}
void xlsx_conversion_context::start_chart(std::wstring name)
@ -178,7 +182,7 @@ void xlsx_conversion_context::end_document()
{
CP_XML_ATTR(L"name", sheet->name()); // office 2010 ! ограничение на длину имени !!!
CP_XML_ATTR(L"sheetId", i + 1);
CP_XML_ATTR(L"state", sheet->hidden() ? L"hidden" : L"visible");
CP_XML_ATTR(L"state", L"visible");
CP_XML_ATTR(L"r:id", id);
}
}
@ -197,10 +201,6 @@ 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\" />";
{
@ -231,41 +231,7 @@ void xlsx_conversion_context::end_document()
{
CP_XML_STREAM() << workbook_content.str();
}
if (false == mapExternalLink_.empty())
{
CP_XML_NODE(L"externalReferences")
{
for (std::unordered_map<std::wstring, int>::iterator it = mapExternalLink_.begin();
it != mapExternalLink_.end(); ++it)
{
package::external_links_content_ptr content = package::external_links_content::create();
content->rId() = L"extRef" + std::to_wstring(it->second);
{
CP_XML_WRITER(content->content())
{
CP_XML_NODE(L"externalLink")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_NODE(L"externalBook")
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", L"rId1");
}
}
}
}
content->get_rels().add(relationship(L"rId1", mediaitems::get_rel_type(typeExternalLink), it->first, L"External"));
output_document_->get_xl_files().add_external_links(content);
CP_XML_NODE(L"externalReference")
{
CP_XML_ATTR(L"r:id", content->rId());
}
}
}
}
get_xlsx_defined_names().xlsx_serialize(CP_XML_STREAM());
int pivot_cache_count = xlsx_pivots_context_.get_count();
@ -321,7 +287,7 @@ void xlsx_conversion_context::end_document()
output_document_->get_xl_files().set_workbook( package::simple_element::create(L"workbook.xml", strm_workbook.str()) );
output_document_->get_content_types_file().set_media(get_mediaitems());
output_document_->get_xl_files().set_media(get_mediaitems());
output_document_->get_xl_files().set_media(get_mediaitems(), applicationFonts_);
package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content());
output_document_->get_xl_files().set_drawings(drawings);
@ -426,12 +392,15 @@ int xlsx_conversion_context::find_sheet_by_name(std::wstring tableName)
}
return -1;
}
void xlsx_conversion_context::create_new_sheet(std::wstring const & name)
{
sheets_.push_back(xlsx_xml_worksheet::create(name));
}
bool xlsx_conversion_context::start_table(std::wstring tableName, std::wstring tableStyleName)
{
create_new_sheet(tableName);
get_table_context().start_table(tableName, tableStyleName, sheets_.size() - 1);
sheets_.push_back(xlsx_xml_worksheet::create(tableName, get_table_context().state()->get_table_hidden()));
current_sheet().cols() << L"<cols>";
return true;
}
@ -467,13 +436,11 @@ 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_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());
get_table_context().serialize_protection (current_sheet().protection());
get_drawing_context().set_odf_packet_path (root()->get_folder());
get_drawing_context().process_objects (get_table_metrics());
@ -535,20 +502,6 @@ void xlsx_conversion_context::end_table()
}
get_table_context().end_table();
}
//int xlsx_conversion_context::add_external_link(const std::wstring & external)
//{
// std::unordered_map<std::wstring, int>::iterator pFind = mapExternalLink_.find(external);
// if ( pFind == mapExternalLink_.end())
// {
// int id = (int)mapExternalLink_.size() + 1;
// mapExternalLink_.insert(std::make_pair(external, id));
// return id;
// }
// else
// {
// return pFind->second;
// }
//}
void xlsx_conversion_context::add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props)
{
if (rid.empty()) return;
@ -694,43 +647,26 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
odf_reader::odf_read_context & odfContext = root()->odf_context();
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
{
inst = odfContext.styleContainer().style_by_name(L"Normal", odf_types::style_family::TableCell, false);
if (inst) instances.push_back(inst);
}
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);
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
if (textFormatProperties.fo_font_family_)
font_name = textFormatProperties.fo_font_family_.get();
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();
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";
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));
else
font_size =10;
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, mediaitems_.applicationFonts());
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, applicationFonts_);
}
return maxDigitSize_;
}

View File

@ -34,8 +34,6 @@
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
#include <unordered_map>
#include "oox_conversion_context.h"
@ -56,6 +54,11 @@
#include "mediaitems.h"
namespace NSFonts
{
class IApplicationFonts;
}
namespace cpdoccore {
namespace odf_reader
@ -157,12 +160,6 @@ public:
void add_jsaProject (const std::string &content);
void add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props);
//int add_external_link(const std::wstring & external);
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()
@ -195,9 +192,9 @@ public:
mediaitems & get_mediaitems() { return mediaitems_; }
static std::unordered_map<std::wstring, int> mapExternalLink_;
std::map<std::wstring, int> mapUsedNames_;
private:
void create_new_sheet (std::wstring const & name);
void serialize_bookViews(std::wostream & strm);
void serialize_calcPr (std::wostream & strm);
@ -205,18 +202,19 @@ private:
const odf_reader::office_element *spreadsheet_;
odf_reader::odf_document *odf_document_;
NSFonts::IApplicationFonts *applicationFonts_;
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_;
std::map<std::wstring, std::wstring>control_props_;
xlsx_style_manager xlsx_style_;
xlsx_defined_names xlsx_defined_names_;
@ -229,8 +227,6 @@ private:
math_context math_context_;
forms_context forms_context_;
static std::wstring change_external(boost::wsmatch const & what);
};
}

View File

@ -744,9 +744,6 @@ 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;
@ -1057,7 +1054,7 @@ void process_build_object::visit(table_table_cell& val)
if (cell_cash.empty())
cell_cash = cell_val;
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::_cell cell_= {object_odf_context_.current_table_column_, 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
{
size_t col;
size_t row;
int col;
int row;
std::wstring val;
};

View File

@ -106,13 +106,6 @@ 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)
{
@ -137,13 +130,6 @@ 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)
@ -164,14 +150,6 @@ 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,14 +111,6 @@ 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
@ -510,7 +502,7 @@ public:
_CP_OPT(std::wstring) draw_id_;
_CP_OPT(std::wstring) draw_layer_;
_CP_OPT(std::wstring) draw_transform_;
_CP_OPT(unsigned int) draw_z_index_;
_CP_OPT(int) draw_z_index_;
_CP_OPT(std::wstring) drawooo_display_;
};

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"can" ,0 ,0 ,0 },
{L"lightning" ,L"lightningBolt" ,0 ,0 ,0 },
{L"can" ,L"lightningBolt" ,0 ,0 ,0 },
{L"lightning" ,L"can" ,0 ,0 ,0 },
{L"heart" ,L"heart" ,0 ,0 ,0 },
{L"sun" ,L"sun" ,1 ,46875 ,12500 },
{L"moon" ,L"moon" ,0 ,0 ,0 },
@ -139,6 +139,13 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"mso-spt18" ,L"irregularSeal1" ,0 ,0 ,0 },
{L"mso-spt19" ,L"rect" ,0 ,0 ,0 },
{L"mso-spt24" ,L"textBox" ,0 ,0 ,0 },
{L"mso-spt25" ,L"" ,0 ,0 ,0 },
{L"mso-spt26" ,L"" ,0 ,0 ,0 },
{L"mso-spt27" ,L"" ,0 ,0 ,0 },
{L"mso-spt28" ,L"" ,0 ,0 ,0 },
{L"mso-spt29" ,L"" ,0 ,0 ,0 },
{L"mso-spt30" ,L"" ,0 ,0 ,0 },
{L"mso-spt31" ,L"" ,0 ,0 ,0 },
{L"mso-spt32" ,L"straightConnector1" ,0 ,0 ,0 },
{L"mso-spt33" ,L"bentConnector2" ,0 ,0 ,0 },
{L"mso-spt34" ,L"bentConnector3" ,0 ,0 ,0 },
@ -174,10 +181,10 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
{L"mso-spt107" ,L"ellipseRibbon" ,0 ,0 ,0 },
{L"mso-spt108" ,L"ellipseRibbon2" ,0 ,0 ,0 },
{L"mso-spt129" ,L"flowChartMagneticDrum" ,0 ,0 ,0 },
{L"mso-spt178" ,L"callout1" ,0 ,0 ,0 },
{L"mso-spt179" ,L"callout2" ,0 ,0 ,0 },
{L"mso-spt180" ,L"callout3" ,0 ,0 ,0 },
{L"mso-spt167" ,L"rect" ,0 ,0 ,0 },
{L"mso-spt178" ,L"" ,0 ,0 ,0 },
{L"mso-spt179" ,L"" ,0 ,0 ,0 },
{L"mso-spt180" ,L"" ,0 ,0 ,0 },
{L"mso-spt182" ,L"leftRightUpArrow" ,0 ,0 ,0 },
{L"mso-spt188" ,L"flowChartPunchedTape",0 ,0 ,0 },
{L"mso-spt189" ,L"actionButtonBlank" ,0 ,0 ,0 },
@ -215,6 +222,7 @@ 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 },
@ -292,13 +300,6 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"fontwork-slant-up" ,L"textSlantUp" ,0 ,0 ,0 },
{L"fontwork-slant-down" ,L"textSlantDown" ,0 ,0 ,0 },
{L"mso-spt25" ,L"textPlain" ,0 ,0 ,0 },//
{L"mso-spt26" ,L"textPlain" ,0 ,0 ,0 },
{L"mso-spt27" ,L"textCurveDown" ,0 ,0 ,0 },
{L"mso-spt28" ,L"textWave1" ,0 ,0 ,0 },
{L"mso-spt29" ,L"textRingInside" ,0 ,0 ,0 },
{L"mso-spt30" ,L"textPlain" ,0 ,0 ,0 },
{L"mso-spt31" ,L"textRingOutside" ,0 ,0 ,0 },
{L"mso-spt142" ,L"textRingInside" ,0 ,0 ,0 },
{L"mso-spt143" ,L"textRingOutside" ,0 ,0 ,0 },
{L"mso-spt157" ,L"textWave2" ,0 ,0 ,0 },
@ -310,8 +311,7 @@ static const _shape_converter _OO_OOX_wordart[]=
{L"mso-spt163" ,L"textDeflateBottom" ,0 ,0 ,0 },
{L"mso-spt164" ,L"textInflateTop" ,0 ,0 ,0 },
{L"mso-spt165" ,L"textDeflateTop" ,0 ,0 ,0 },
{L"mso-spt166" ,L"textDeflateInflate" ,0 ,0 ,0 },
{L"mso-spt167" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
{L"mso-spt166" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
{L"mso-spt174" ,L"textCanUp" ,0 ,0 ,0 },
{L"mso-spt175" ,L"textCanDown" ,0 ,0 ,0 },
{L"mso-spt188" ,L"textDoubleWave1" ,0 ,0 ,0 },

View File

@ -60,10 +60,6 @@ std::wostream & operator << (std::wostream & _Wostream, const marker_style & _Va
std::wstring marker_style::parse(const std::wstring & Str)
{
if (Str.empty())
{
return L"none";
}
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);

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 (size_t i = 0 ; i < splitted.size(); i++)
for (int i = 0 ; i < splitted.size(); i++)
{
if (splitted[i] == L"bold")
{

View File

@ -58,11 +58,13 @@ namespace _image_file_
{
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts* appFonts)
{
if (!appFonts) return false;
CBgraFrame image;
MetaFile::IMetaFile* meta_file = MetaFile::Create(appFonts);
bool bRet = false;
if ( appFonts && meta_file->LoadFromFile(fileName))
if ( meta_file->LoadFromFile(fileName))
{
double dX = 0, dY = 0, dW = 0, dH = 0;
meta_file->GetBounds(&dX, &dY, &dW, &dH);
@ -81,18 +83,6 @@ namespace _image_file_
RELEASEOBJECT(meta_file);
return bRet;
}
void GenerateZeroImage(const std::wstring & fileName)
{
NSFile::CFileBinary file;
if (file.CreateFileW(fileName))
{
BYTE pData[149] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x03, 0x00, 0x00, 0x01, 0x5f, 0xcc, 0x04, 0x2d, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x06, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x67, 0xb9, 0xcf, 0x00, 0x00, 0x00, 0x02, 0x74, 0x52, 0x4e, 0x53, 0xff, 0x00, 0xe5, 0xb7, 0x30, 0x4a, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x12, 0x74, 0x00, 0x00, 0x12, 0x74, 0x01, 0xde, 0x66, 0x1f, 0x78, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xa3, 0xda, 0x3d, 0x94, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
file.WriteFile(pData, 149);
file.CloseFile();
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace cpdoccore {
@ -111,11 +101,11 @@ int get_value_emu(double pt)
{
return static_cast<int>((pt* 360000 * 2.54) / 72);
}
bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts *appFonts)
bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts)
{
memset(clip_rect, 0, 4*sizeof(double));
if (strClipping.empty() || fileName.empty()) return false;
if (strClipping.length() <1 || fileName.length()<1)return false;
//<top>, <right>, <bottom>, <left> - http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html#clip
@ -124,7 +114,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
std::vector<std::wstring> Points;
std::vector<length> Points_pt;
boost::algorithm::split(Points, strClipping, boost::algorithm::is_any_of(L" ,"), boost::algorithm::token_compress_on);
boost::algorithm::split(Points,strClipping, boost::algorithm::is_any_of(L" ,"), boost::algorithm::token_compress_on);
for (size_t i = 0; i < Points.size(); i++)
{
@ -135,9 +125,9 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
if (!bEnableCrop) return false;
int fileWidth = 0,fileHeight = 0;
int fileWidth=0,fileHeight=0;
if (!_image_file_::GetResolution(fileName.data(), fileWidth, fileHeight, appFonts) || fileWidth < 1 || fileHeight < 1) return false;
if (!_image_file_::GetResolution(fileName.data(), fileWidth, fileHeight, appFonts) || fileWidth<1 || fileHeight<1) return false;
if (Points_pt.size() > 3)//если другое количество точек .. попозже
{
@ -153,7 +143,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
clip_rect[1] = clip_rect[1]*100/fileHeight;
clip_rect[3] = clip_rect[3]*100/fileHeight;
if (clip_rect[0] < 0.01 && clip_rect[1] < 0.01 && clip_rect[2] < 0.01 && clip_rect[3] < 0.01)
if (clip_rect[0]<0.01 && clip_rect[1]<0.01 && clip_rect[2]<0.01 && clip_rect[3]<0.01)
return false;
return true;
}
@ -485,8 +475,6 @@ 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_)
{
@ -619,7 +607,7 @@ void parse_string_to_points(std::wstring str, std::vector<length> & Points)
}
}
void docx_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
{
std::vector<std::wstring> transforms;
@ -688,10 +676,10 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
std::vector<std::wstring> transform;
boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
if (transform.size() > 1)//тока с аргументами
if (transform.size()>1)//тока с аргументами
{
size_t res=0;
if ((res = transform[0].find(L"translate")) != std::wstring::npos)//перемещение
int res=0;
if ((res = transform[0].find(L"translate"))>=0)//перемещение
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
@ -705,7 +693,7 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
Context.get_drawing_context().set_translate(x_pt,y_pt);
}
}
else if ((res = transform[0].find(L"scale")) != std::wstring::npos)//масштабирование
else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
@ -718,19 +706,19 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
Context.get_drawing_context().set_scale(x_pt,y_pt);
}
}
else if ((res = transform[0].find(L"rotate")) != std::wstring::npos)//вращение
else if ((res = transform[0].find(L"rotate"))>=0)//вращение
{
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]), true);
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]));
}
else if ((res = transform[0].find(L"skewX")) != std::wstring::npos)//сдвиг
else if ((res = transform[0].find(L"skewX"))>=0)//сдвиг
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:skewX", angle));
Context.get_drawing_context().set_property(_property(L"svg:skewX",angle));
}
else if ((res = transform[0].find(L"skewY")) != std::wstring::npos)//сдвиг
else if ((res = transform[0].find(L"skewY"))>=0)//сдвиг
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_drawing_context().set_property(_property(L"svg:skewY", angle));
Context.get_drawing_context().set_property(_property(L"svg:skewY",angle));
}
}
}
@ -748,50 +736,49 @@ void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_con
std::vector<std::wstring> transform;
boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
if (transform.size() > 1)//тока с аргументами
if (transform.size()>1)//тока с аргументами
{
size_t res = 0;
if ((res = transform[0].find(L"translate")) != std::wstring::npos)//перемещение
int res=0;
if ((res = transform[0].find(L"translate"))>=0)//перемещение
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
if (false == Points.empty())
if (Points.size()>0)
{
double x_pt = Points[0].get_value_unit(length::pt);
double y_pt = 0;
if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть
Context.get_slide_context().set_translate(x_pt, y_pt);
Context.get_slide_context().set_translate(x_pt,y_pt);
}
}
else if ((res = transform[0].find(L"scale")) != std::wstring::npos)//масштабирование
else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
{
std::vector<length> Points ;
parse_string_to_points(transform[1], Points);
if (false == Points.empty())
if (Points.size()>0)
{
double x_pt = Points[0].get_value_unit(length::pt);
double y_pt = x_pt;
if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть
Context.get_slide_context().set_scale(x_pt, y_pt);
Context.get_slide_context().set_scale(x_pt,y_pt);
}
}
else if ((res = transform[0].find(L"rotate")) != std::wstring::npos)//вращение
else if ((res = transform[0].find(L"rotate"))>=0)//вращение
{
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]), true);
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]));
}
else if ((res = transform[0].find(L"skewX")) != std::wstring::npos)//вращение
else if ((res = transform[0].find(L"skewX"))>=0)//вращение
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_slide_context().set_property(_property(L"svg:skewX", angle));
Context.get_slide_context().set_property(_property(L"svg:skewX",angle));
}
else if ((res = transform[0].find(L"skewY")) != std::wstring::npos)//вращение
else if ((res = transform[0].find(L"skewY"))>=0)//вращение
{
double angle = boost::lexical_cast<double>(transform[1]);
Context.get_slide_context().set_property(_property(L"svg:skewY", angle));
Context.get_slide_context().set_property(_property(L"svg:skewY",angle));
}
}
}

View File

@ -52,8 +52,7 @@
namespace _image_file_
{
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts *appFonts);
void GenerateZeroImage(const std::wstring & fileName);
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts * appFonts);
}
namespace cpdoccore {
@ -75,7 +74,7 @@ void Compute_GraphicFill(const odf_types::common_draw_fill_attlist & props,
const office_element_ptr & style_image, styles_lite_container &styles, oox::_oox_fill & fill, bool txbx = false);
typedef double double_4[4];
bool parse_clipping(std::wstring strClipping, std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts *appFonts);
bool parse_clipping(std::wstring strClipping,std::wstring fileName,double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class draw_a : public office_element_impl<draw_a>
{
@ -111,9 +110,10 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_a);
void docx_convert_transforms(std::wstring transformStr, std::vector<odf_reader::_property> & additional);
void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_context & Context);
void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_context & Context);
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional);
//void docx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
}
}

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