Compare commits

...

62 Commits

Author SHA1 Message Date
a7bf12c052 . 2018-01-31 18:17:45 +03:00
5c01b23dee . 2018-01-30 20:09:22 +03:00
db11b75a2e x2t version 2.4.514 2018-01-30 19:37:10 +03:00
2ba4c18cdf bug: initialize m_pWorkbookComments 2018-01-30 17:22:39 +03:00
b264f20f29 . 2018-01-30 15:21:05 +03:00
5e04ea62f7 fix operation priority 2018-01-30 14:44:52 +03:00
3d1db63c0e bug: bug on save onlyoffice extention for comments in xlsx 2018-01-29 19:51:06 +03:00
f124d18256 bug: save nil shading to docx 2018-01-29 18:14:23 +03:00
9bffb65dcb x2t 2.4.512 2018-01-29 15:46:08 +03:00
2fbcc3832f feat: add workbookComments, presentationComments 2018-01-26 20:37:27 +03:00
97b4311e95 . 2018-01-26 19:18:41 +03:00
228b3a52e9 . 2018-01-26 17:55:04 +03:00
2f2236646d Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
* 'develop' of https://github.com/ONLYOFFICE/core:
  OdfFormatReader - data validation (type dropdown list)
  no squares
  fix previous commit
  font by symbol table
2018-01-26 17:08:57 +03:00
30603d0561 build fixed 2018-01-26 17:08:51 +03:00
933af771b7 OdfFormatReader - data validation (type dropdown list) 2018-01-26 14:45:24 +03:00
c04a537d69 no squares 2018-01-26 13:55:24 +03:00
e49d78db47 fix previous commit 2018-01-26 11:39:56 +03:00
99ec420ee5 font by symbol table 2018-01-26 11:36:19 +03:00
f764b034a1 . 2018-01-25 18:33:12 +03:00
73fe023460 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-01-25 18:26:55 +03:00
242af3c80e . 2018-01-25 18:26:14 +03:00
7756e4b8bd . 2018-01-25 18:17:46 +03:00
56a1d1f627 x2t -fix appVersion 2018-01-25 18:16:15 +03:00
11bd4ff61d . 2018-01-25 17:20:56 +03:00
93a06d7f86 . 2018-01-25 17:18:40 +03:00
76d2d429b7 x2t version 2.4.511 2018-01-25 17:07:43 +03:00
c6de37dbad . 2018-01-25 17:02:31 +03:00
d022e669f0 . 2018-01-25 15:57:17 +03:00
184e79bae1 . 2018-01-25 15:52:14 +03:00
e6581671c8 . 2018-01-25 15:27:06 +03:00
e0a1c688bf . 2018-01-24 19:28:04 +03:00
9e0b301179 write verion x2t to converted files 2018-01-24 18:25:23 +03:00
8680fb2e0e . 2018-01-24 15:45:10 +03:00
c7c605a970 fix bug #31327
convert script text in toggle property in simple text
2018-01-23 19:34:07 +03:00
23d648d92d fix bug #36409 2018-01-23 16:53:40 +03:00
b098c98dbb x2t version 2.4.510 2018-01-23 16:23:09 +03:00
b88726beaf fix bug #36514 2018-01-23 14:09:55 +03:00
b2d3e5e194 . 2018-01-22 19:21:57 +03:00
a8315efae0 . 2018-01-22 18:26:40 +03:00
3781cf6774 . 2018-01-22 17:45:21 +03:00
7e36d47991 fix bug #8010
OdfFormatReader - dropdown & user fields
2018-01-22 15:09:23 +03:00
419a01bd09 fix bug #36725 2018-01-22 11:21:28 +03:00
804a01cab3 x2t version 2.4.509 2018-01-20 15:22:31 +03:00
931d6aa17c . 2018-01-20 14:24:40 +03:00
2861539949 . 2018-01-19 19:33:12 +03:00
281dad68fb . 2018-01-19 14:42:32 +03:00
04ba432cde x2t version 2.4.508 2018-01-19 14:14:33 +03:00
61c943a3b2 up 2018-01-19 13:46:06 +03:00
9fdc7641b3 . 2018-01-18 15:24:33 +03:00
1029ee9101 OoxToBinary - modify preparing to binary write 2018-01-18 15:13:21 +03:00
9ef5bec2a5 [ios] fixed build 2018-01-17 12:43:03 +03:00
93132eb8a0 x2t version 2.4.506 2018-01-17 11:18:24 +03:00
9828c25e51 . 2018-01-16 19:45:34 +03:00
db1204288b OdfFormatWriter - keeping current font size 2018-01-15 18:16:41 +03:00
26c3d37be5 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-01-15 17:57:45 +03:00
077ea08368 OdfFormatWriter - text position (%) 2018-01-15 17:57:32 +03:00
98eab74e97 . 2018-01-15 17:51:30 +03:00
2a7e88ca76 v5.0.7 2018-01-15 15:19:37 +03:00
369596b860 OdfFormatWriter - fix dropCap, sections 2018-01-13 14:59:56 +03:00
15af8f561a OdfFormatWriter - fix picture size from placeholder 2018-01-12 17:02:33 +03:00
58f8d13d71 . 2018-01-12 13:57:26 +03:00
5039cec847 diagramm save error 2017-12-19 15:09:10 +03:00
301 changed files with 8136 additions and 6088 deletions

View File

@ -69,8 +69,13 @@ namespace OpenXmlContentTypes
static const wchar_t* Tiff = L"image/tiff";
static const wchar_t* Wmf = L"image/x-wmf";
static const wchar_t* Bmp = L"image/bmp";
static const wchar_t* Pcz = L"image/x-pcz";
}
namespace DocPrContentTypes
{
static const wchar_t* App = L"application/vnd.openxmlformats-officedocument.extended-properties+xml";
static const wchar_t* Core = L"application/vnd.openxmlformats-package.core-properties+xml";
}
namespace WordprocessingMLContentTypes
{
// WordprocessingML content types
@ -136,7 +141,7 @@ namespace OpenXmlNamespaces
namespace OpenXmlRelationshipTypes
{
static const wchar_t* CoreProperties = L"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
static const wchar_t* CoreProperties = L"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
static const wchar_t* ExtendedProperties = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
static const wchar_t* Theme = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";

View File

@ -110,6 +110,11 @@ namespace DocFileFormat
unused2 = Reader->ReadByte();
unused3 = Reader->ReadByte();
if (btMacOS != btWin32)
{
btWin32 = btMacOS = (Global::BlipType)this->Instance;
}
if (BodySize > 0x24)
{
Blip = RecordFactory::ReadRecord(Reader, 0);

View File

@ -192,14 +192,14 @@ public:
{
if (!bIsCompressed)
{
m_pMetaFile = pCompress;
m_lMetaFileSize = lUncompressSize;
m_pMetaFile = new BYTE[lCompressSize];
m_lMetaFileSize = lCompressSize;
memcpy(m_pMetaFile, pCompress, lCompressSize);
}
else
{
ULONG lSize = lUncompressSize;
m_pMetaFile = new BYTE[lUncompressSize];
//bool bRes = NSZLib::Decompress(pCompress, (ULONG)lCompressSize, m_pMetaFile, lSize);
HRESULT res = S_OK;
COfficeUtils* pOfficeUtils = new COfficeUtils(NULL);
@ -340,6 +340,8 @@ typedef enum _BlipCompression
if (typeCode == 0xf01b)
{
oMetaFile.m_sExtension = L".wmf";
WmfPlaceableFileHeader oWmfHeader = {};
oMetaHeader.ToWMFHeader(&oWmfHeader);
@ -349,24 +351,12 @@ typedef enum _BlipCompression
oMetaFile.SetHeader(pMetaHeader, lLenHeader);
}
if (typeCode == 0xf01c)
{
oMetaFile.m_sExtension = L".pcz";
//decompress???
}
oMetaFile.SetData(m_pvBits, oMetaHeader.cbSave, oMetaHeader.cbSize, 0 == oMetaHeader.compression);
//if (pos < sz)
//{
// NSFile::CFileBinary oFile;
// if (oFile.CreateFile(L"d:\\blop.dat"))
// {
// BYTE * d = Reader->ReadBytes( sz - pos, true );
// if (d)
// {
// oFile.WriteFile (d, sz - pos);
// delete []d;
// oFile.CloseFile();
// }
// }
//}
}
virtual ~MetafilePictBlip()

View File

@ -64,6 +64,8 @@ namespace DocFileFormat
DocumentContentTypesFile._defaultTypes.insert( make_pair( L"xml", std::wstring( OpenXmlContentTypes::Xml ) ) );
MainRelationshipsFile.Relationships.push_back( Relationship( std::wstring( L"rId1"), OpenXmlRelationshipTypes::OfficeDocument, L"word/document.xml") );
MainRelationshipsFile.Relationships.push_back( Relationship( std::wstring( L"rId2"), OpenXmlRelationshipTypes::CoreProperties, L"docProps/core.xml") );
MainRelationshipsFile.Relationships.push_back( Relationship( std::wstring( L"rId3"), OpenXmlRelationshipTypes::ExtendedProperties, L"docProps/app.xml") );
}
@ -195,14 +197,18 @@ namespace DocFileFormat
delete storageOut;
return S_OK;
}
int OpenXmlPackage::RegisterDocument()
void OpenXmlPackage::RegisterDocPr()
{
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocument, L"");
AddPart( L"docProps", L"app.xml", DocPrContentTypes::App, L"");
AddPart( L"docProps", L"core.xml", DocPrContentTypes::Core, L"");
}
int OpenXmlPackage::RegisterDocumentMacros()
void OpenXmlPackage::RegisterDocument()
{
return AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocumentMacro, L"");
AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocument, L"");
}
void OpenXmlPackage::RegisterDocumentMacros()
{
AddPart( L"word", L"document.xml", WordprocessingMLContentTypes::MainDocumentMacro, L"");
}
int OpenXmlPackage::RegisterVbaProject()
{

View File

@ -165,8 +165,9 @@ namespace DocFileFormat
HRESULT SaveOLEObject ( const std::wstring& fileName, const OleObjectFileStructure& oleObjectFileStructure );
HRESULT SaveEmbeddedObject ( const std::wstring& fileName, const std::string& data );
int RegisterDocument();
int RegisterDocumentMacros();
void RegisterDocPr();
void RegisterDocument();
void RegisterDocumentMacros();
int RegisterFontTable();
int RegisterNumbering();
int RegisterSettings();

View File

@ -156,7 +156,7 @@ namespace DocFileFormat
file.CloseFile();
OOX::CPath path(sTempXmlFile);
OOX::CDocument docEmbedded(path, path);
OOX::CDocument docEmbedded(NULL, path, path);
bool res = false;
for (std::vector<OOX::WritingElement*>::iterator it = docEmbedded.m_arrItems.begin(); it != docEmbedded.m_arrItems.end(); ++it)
@ -500,6 +500,7 @@ namespace DocFileFormat
{
case Global::msoblipEMF:
case Global::msoblipWMF:
case Global::msoblipPICT:
{
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(oBlipEntry->Blip);
if (metaBlip)
@ -567,6 +568,9 @@ namespace DocFileFormat
case Global::msoblipWMF:
return std::wstring(L".wmf");
case Global::msoblipPICT:
return std::wstring(L".pcz");
default:
return std::wstring(L".png");
}
@ -601,6 +605,9 @@ namespace DocFileFormat
case Global::msoblipWMF:
return std::wstring(OpenXmlContentTypes::Wmf);
case Global::msoblipPICT:
return std::wstring(OpenXmlContentTypes::Pcz);
case Global::msoblipDIB:
return std::wstring(OpenXmlContentTypes::Bmp);

View File

@ -1287,6 +1287,7 @@ namespace DocFileFormat
{
case Global::msoblipEMF:
case Global::msoblipWMF:
case Global::msoblipPICT:
{
//it's a meta image
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(RecordFactory::ReadRecord(&reader, 0));
@ -1373,6 +1374,9 @@ namespace DocFileFormat
case Global::msoblipWMF:
return std::wstring( L".wmf" );
case Global::msoblipPICT:
return std::wstring( L".pcz" );
default:
return std::wstring( L".png" );
}

View File

@ -35,6 +35,10 @@
#include "../../DesktopEditor/raster/BgraFrame.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
namespace ImageHelper
{
struct __BITMAPINFOHEADER
@ -211,6 +215,37 @@ namespace DocFileFormat
{
RegisterDocument();
}
OOX::CContentTypes oContentTypes;
OOX::CPath pathDocProps = m_strOutputPath + FILE_SEPARATOR_STR + _T("docProps");
NSDirectory::CreateDirectory(pathDocProps.GetPath());
OOX::CPath DocProps = std::wstring(_T("docProps"));
OOX::CApp* pApp = new OOX::CApp(NULL);
if (pApp)
{
pApp->SetApplication(L"ONLYOFFICE");
#if defined(INTVER)
pApp->SetAppVersion(VALUE2STR(INTVER));
#endif
pApp->SetDocSecurity(0);
pApp->SetScaleCrop(false);
pApp->SetLinksUpToDate(false);
pApp->SetSharedDoc(false);
pApp->SetHyperlinksChanged(false);
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, oContentTypes);
delete pApp;
}
OOX::CCore* pCore = new OOX::CCore(NULL);
if (pCore)
{
pCore->SetCreator(_T(""));
pCore->SetLastModifiedBy(_T(""));
pCore->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), DocProps, oContentTypes);
delete pCore;
}
RegisterDocPr();
WritePackage();

View File

@ -21,8 +21,6 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

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

View File

@ -318,20 +318,29 @@ public:
docRGB Color;
CThemeColor ThemeColor;
bool bValue;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bValue = false;
bColor = false;
bThemeColor = false;
}
std::wstring ToString()
{
std::wstring sShd;
if(bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
if(bValue || bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
{
sShd += L"<w:shd w:val=\"clear\" w:color=\"auto\"";
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
}
sShd += L" w:color=\"auto\"";
if(bColor)
sShd += L" w:fill=\"" + Color.ToString() + L"\"";
if(bThemeColor && ThemeColor.IsNoEmpty())

View File

@ -36,7 +36,7 @@ namespace BinDocxRW {
int Binary_VbaProjectTableReader::Read()
{
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
m_oFileWriter.m_pVbaProject = new OOX::VbaProject(NULL);
m_oFileWriter.m_pVbaProject->fromPPTY(&m_oBufferedStream);
return c_oSerConstants::ReadOk;

View File

@ -37,7 +37,17 @@
#include "../BinWriter/BinReaderWriterDefines.h"
#include "../../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Numbering.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Comments.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Styles.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Footnote.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Endnote.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Settings/Settings.h"
#include "../DocWrapper/XlsxSerializer.h"
#include "../../DesktopEditor/common/ASCVariant.h"
@ -256,7 +266,10 @@ private:
Shd* pShd = static_cast<Shd*>(poResult);
switch(type)
{
case c_oSerShdType::Value: pShd->Value = m_oBufferedStream.GetUChar();break;
case c_oSerShdType::Value:
pShd->bValue = true;
pShd->Value = m_oBufferedStream.GetUChar();
break;
case c_oSerShdType::Color:
pShd->bColor = true;
pShd->Color = ReadColor();
@ -441,11 +454,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
orPr->bShd = true;
orPr->Shd = oShd.ToString();
}
orPr->bShd = true;
orPr->Shd = oShd.ToString();
break;
}
case c_oSerProp_rPrType::RStyle:
@ -791,15 +801,7 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
else
{
std::wstring sShd(L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>");
pCStringWriter->WriteString(sShd);
}
pCStringWriter->WriteString(oShd.ToString());
break;
}
case c_oSerProp_pPrType::WidowControl:
@ -1772,11 +1774,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
else if( c_oSerProp_tblPrType::tblpPr == type )
{
@ -2234,10 +2233,7 @@ public:
bCellShd = true;
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
pCStringWriter->WriteString(oShd.ToString());
}
else if( c_oSerProp_cellPrType::TableCellBorders == type )
{
@ -2981,7 +2977,7 @@ public:
int Read()
{
return ReadTable(&Binary_OtherTableReader::ReadOtherContent, this);
};
}
int ReadOtherContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -2991,7 +2987,7 @@ public:
}
else if(c_oSerOtherTableTypes::DocxTheme == type)
{
smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme();
smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme(NULL);
pTheme->fromPPTY(&m_oBufferedStream);
NSBinPptxRW::CXmlWriter xmlWriter;
pTheme->toXmlWriter(&xmlWriter);
@ -3000,7 +2996,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadImageMapContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3043,7 +3039,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
};
class Binary_CommentsTableReader : public Binary_CommonReader<Binary_CommentsTableReader>
{
@ -7258,7 +7254,7 @@ public:
BinXlsxRW::SaveParams oSaveParams(m_oFileWriter.m_sThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes());
BinXlsxRW::BinaryChartReader oBinaryChartReader(m_oBufferedStream, oSaveParams, m_oFileWriter.m_pDrawingConverter);
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace();
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace(NULL);
oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace);
//save xlsx
@ -7439,6 +7435,8 @@ public:
{
PPTX::Logic::CNvPr pNonVisualDrawingProps(L"wp");
res = Read1(length, &Binary_DocumentTableReader::ReadDocPr, this, &pNonVisualDrawingProps);
pNonVisualDrawingProps.id = pDrawingProperty->m_nDocPr;
pDrawingProperty->sDocPr = pNonVisualDrawingProps.toXML2(L"wp:docPr");
}
else

View File

@ -87,10 +87,14 @@ namespace BinDocxRW
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, pHdrFtr->m_arrShapeTypes);
smart_ptr<OOX::IFileContainer> oldRels = m_pOfficeDrawingConverter->GetRels();
m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_pOfficeDrawingConverter->ClearShapeTypes();
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
m_pOfficeDrawingConverter->SetRels(oldRels);
}
}

View File

@ -37,12 +37,30 @@
#include "../../Common/Base64.h"
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
#include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/MathEquation/MathEquation.h"
#include "BinEquationWriter.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/MathEquation/MathEquation.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Numbering.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Comments.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Styles.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Footnote.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Endnote.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Settings/WebSettings.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Settings/Settings.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Image.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/ActiveX.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/HeaderFooter.h"
namespace BinDocxRW
{
class ParamsWriter
@ -2998,25 +3016,13 @@ namespace BinDocxRW
bool m_bWriteSectPr;//Записывать ли свойства верхнего уровня в данном экземпляре BinaryOtherTableWriter
//---------------------------------
BinaryDocumentTableWriter(ParamsWriter& oParamsWriter, ParamsDocumentWriter& oParamsDocumentWriter, std::map<int, bool>* mapIgnoreComments, BinaryHeaderFooterTableWriter* oBinaryHeaderFooterTableWriter):
m_oParamsWriter(oParamsWriter), m_oParamsDocumentWriter(oParamsDocumentWriter),m_oBcw(oParamsWriter),bpPrs(oParamsWriter, oBinaryHeaderFooterTableWriter),brPrs(oParamsWriter),btblPrs(oParamsWriter),m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter),m_mapIgnoreComments(mapIgnoreComments)
m_oParamsWriter(oParamsWriter), m_oParamsDocumentWriter(oParamsDocumentWriter), m_oBcw(oParamsWriter),bpPrs(oParamsWriter, oBinaryHeaderFooterTableWriter),brPrs(oParamsWriter),btblPrs(oParamsWriter),m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter),m_mapIgnoreComments(mapIgnoreComments)
{
pBackground = NULL;
pSectPr = NULL;
poDocument = NULL;
m_bWriteSectPr = false;
}
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, OOX::IFileContainer *rels, std::vector<std::wstring>& aShapeTypes)
{
smart_ptr<OOX::IFileContainer> oldRels = pOfficeDrawingConverter->GetRels();
pOfficeDrawingConverter->SetRels(rels);
for(size_t i = 0, length = aShapeTypes.size(); i < length; ++i)
{
std::wstring& sShapeType = aShapeTypes[i];
pOfficeDrawingConverter->AddShapeType(sShapeType);
}
pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteVbaProject(OOX::VbaProject& oVbaProject)
{
m_oBcw.m_oStream.StartRecord(0);
@ -3113,23 +3119,6 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
//Write JsaProject
if (NULL != poDocument)
{
smart_ptr<OOX::File> pFile = poDocument->Get(OOX::FileTypes::JsaProject);
if (pFile.IsInit() && OOX::FileTypes::JsaProject == pFile->type())
{
OOX::JsaProject& jsaProject = pFile.as<OOX::JsaProject>();
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(jsaProject.filename().GetPath(), &pData, nBytesCount))
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
m_oBcw.WriteItemEnd(nCurPos);
}
}
}
}
void WriteBackground (OOX::Logic::CBackground* pBackground)
{
@ -7723,7 +7712,7 @@ namespace BinDocxRW
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter, oFootnotes.m_arrShapeTypes);
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteEndnotes(OOX::CEndnotes& oEndnotes)
@ -7732,20 +7721,27 @@ namespace BinDocxRW
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter, oEndnotes.m_arrShapeTypes);
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<std::wstring>& arrShapeTypes)
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter)
{
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
smart_ptr<OOX::IFileContainer> oldRels = m_pOfficeDrawingConverter->GetRels();
m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_pOfficeDrawingConverter->ClearShapeTypes();
int nCurPos = 0;
for(size_t i = 0 ; i < arrNotes.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::Note);
WriteNote(*arrNotes[i], oParamsDocumentWriter, arrShapeTypes);
WriteNote(*arrNotes[i], oBinaryDocumentTableWriter);
m_oBcw.WriteItemEnd(nCurPos);
}
m_pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteNote(const OOX::CFtnEdn& oFtnEdn, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<std::wstring>& arrShapeTypes)
void WriteNote(const OOX::CFtnEdn& oFtnEdn, BinaryDocumentTableWriter & oBinaryDocumentTableWriter)
{
int nCurPos = 0;
if(oFtnEdn.m_oType.IsInit())
@ -7760,10 +7756,6 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteLONG(oFtnEdn.m_oId->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::NoteContent);
oBinaryDocumentTableWriter.WriteDocumentContent(oFtnEdn.m_arrItems);
@ -7846,101 +7838,93 @@ namespace BinDocxRW
OOX::CDocx oDocx = OOX::CDocx(OOX::CPath(sDir));
m_oParamsWriter.m_poTheme = oDocx.GetTheme();
m_oParamsWriter.m_oSettings = oDocx.GetSettings();
m_oParamsWriter.m_poTheme = oDocx.m_pTheme;
m_oParamsWriter.m_oSettings = oDocx.m_pSettings;
*oBufferedStream.m_pTheme = smart_ptr<PPTX::Theme>(oDocx.GetTheme());
*oBufferedStream.m_pTheme = smart_ptr<PPTX::Theme>(oDocx.m_pTheme);
oBufferedStream.m_pTheme->AddRef();
OOX::CFontTable* pFontTable = oDocx.GetFontTable();
if(NULL != pFontTable)
m_oParamsWriter.m_pFontProcessor->setFontTable(pFontTable);
if(NULL != oDocx.m_pFontTable)
m_oParamsWriter.m_pFontProcessor->setFontTable(oDocx.m_pFontTable);
//ищем первый SectPr и расставляем pageBreak
OOX::CDocument* poDocument = oDocx.GetDocument();
if (poDocument == NULL) return;
OOX::Logic::CSectionProperty* pFirstSectPr = poDocument->m_oSectPr.GetPointer();
if (oDocx.m_pDocument == NULL) return;
OOX::Logic::CSectionProperty* pFirstSectPr = oDocx.m_pDocument->m_oSectPr.GetPointer();
this->WriteMainTableStart();
int nCurPos = 0;
//Write Settings
OOX::CSettings* pSettings = oDocx.GetSettings();
if(NULL != pSettings)
if(NULL != oDocx.m_pSettings)
{
BinDocxRW::BinarySettingsTableWriter oBinarySettingsTableWriter(m_oParamsWriter);
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Settings);
oBinarySettingsTableWriter.Write(*pSettings);
oBinarySettingsTableWriter.Write(*oDocx.m_pSettings);
this->WriteTableEnd(nCurPos);
}
//Write Comments
OOX::CComments* pComments = oDocx.GetComments();
OOX::CCommentsExt* pCommentsExt = oDocx.GetCommentsExt();
OOX::CPeople* pPeople = oDocx.GetPeople();
if(NULL != pComments)
if(NULL != oDocx.m_pComments)
{
BinDocxRW::BinaryCommentsTableWriter oBinaryCommentsTableWriter(m_oParamsWriter);
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Comments);
oBinaryCommentsTableWriter.Write(*pComments, pCommentsExt, pPeople, m_oParamsWriter.m_mapIgnoreComments);
oBinaryCommentsTableWriter.Write(*oDocx.m_pComments, oDocx.m_pCommentsExt, oDocx.m_pPeople, m_oParamsWriter.m_mapIgnoreComments);
this->WriteTableEnd(nCurPos);
}
//Write StyleTable
OOX::CStyles* pStyles = oDocx.GetStyles();
BinDocxRW::BinaryStyleTableWriter oBinaryStyleTableWriter(m_oParamsWriter);
if(NULL != pStyles)
if(NULL != oDocx.m_pStyles)
{
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Style);
oBinaryStyleTableWriter.Write(*pStyles);
oBinaryStyleTableWriter.Write(*oDocx.m_pStyles);
this->WriteTableEnd(nCurPos);
}
//Write Numbering
OOX::CNumbering* pNumbering = oDocx.GetNumbering();
BinDocxRW::BinaryNumberingTableWriter oBinaryNumberingTableWriter(m_oParamsWriter);
if(NULL != pNumbering)
if(NULL != oDocx.m_pNumbering)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Numbering);
oBinaryNumberingTableWriter.Write(*pNumbering);
oBinaryNumberingTableWriter.Write(*oDocx.m_pNumbering);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryNotesTableWriter oBinaryNotesWriter(m_oParamsWriter);
//Write Footnotes
OOX::CFootnotes* pFootnotes = oDocx.GetFootnotes();
if(NULL != pFootnotes)
if(NULL != oDocx.m_pFootnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Footnotes);
oBinaryNotesWriter.WriteFootnotes(*pFootnotes);
oBinaryNotesWriter.WriteFootnotes(*oDocx.m_pFootnotes);
this->WriteTableEnd(nCurPos);
}
//Write Endnotes
OOX::CEndnotes* pEndnotes = oDocx.GetEndnotes();
if(NULL != pEndnotes)
if(NULL != oDocx.m_pEndnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Endnotes);
oBinaryNotesWriter.WriteEndnotes(*pEndnotes);
oBinaryNotesWriter.WriteEndnotes(*oDocx.m_pEndnotes);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, poDocument, &m_oParamsWriter.m_mapIgnoreComments);
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, oDocx.m_pDocument, &m_oParamsWriter.m_mapIgnoreComments);
//Write DocumentTable
ParamsDocumentWriter oParamsDocumentWriter(poDocument);
ParamsDocumentWriter oParamsDocumentWriter(oDocx.m_pDocument);
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
//DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add...
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, &oBinaryHeaderFooterTableWriter);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_oParamsWriter.m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, poDocument->m_arrShapeTypes);
m_oParamsWriter.m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_oParamsWriter.m_pOfficeDrawingConverter->ClearShapeTypes();
oBinaryDocumentTableWriter.pSectPr = pFirstSectPr;
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = poDocument;
oBinaryDocumentTableWriter.pBackground = oDocx.m_pDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = oDocx.m_pDocument;
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
//Write Vba
if(NULL != oDocx.m_pVbaProject)
{
@ -7948,9 +7932,22 @@ namespace BinDocxRW
oBinaryDocumentTableWriter.WriteVbaProject(*oDocx.m_pVbaProject);
this->WriteTableEnd(nCurPos);
}
//Write JsaProject
if (NULL != oDocx.m_pJsaProject)
{
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(oDocx.m_pJsaProject->filename().GetPath(), &pData, nBytesCount))
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
m_oBcw.WriteItemEnd(nCurPos);
}
}
// Write content
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
oBinaryDocumentTableWriter.Write(poDocument->m_arrItems);
oBinaryDocumentTableWriter.Write(oDocx.m_pDocument->m_arrItems);
this->WriteTableEnd(nCurPos);
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::HdrFtr);

View File

@ -32,7 +32,12 @@
#include "ChartWriter.h"
#include <algorithm>
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#define NUMID_START 160
const wchar_t* gc_Cat = L"cat";
@ -127,11 +132,11 @@ namespace BinXlsxRW{
}
ChartWriter::~ChartWriter()
{
for (boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
{
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
for(boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
{
delete itRow->second;
}
@ -141,30 +146,34 @@ namespace BinXlsxRW{
void ChartWriter::toXlsx(OOX::Spreadsheet::CXlsx& oXlsx)
{
std::vector<std::wstring> aSharedStrings;
//Sheet
OOX::Spreadsheet::CWorkbook* pWorkbook = oXlsx.CreateWorkbook();
pWorkbook->m_oSheets.Init();
oXlsx.CreateWorkbook();
oXlsx.m_pWorkbook->m_oSheets.Init();
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets = oXlsx.GetWorksheets();
int nSheetId = 1;
OOX::Spreadsheet::CWorksheet* pFirstWorksheet = NULL;
for (boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
{
const std::wstring& sSheetName = it->first;
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(mapWorksheets, sSheetName);
//find or generate black worksheet
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(oXlsx.m_arWorksheets, oXlsx.m_mapWorksheets, sSheetName);
//fill data to worksheet
toXlsxSheetdata(pWorksheet, *it->second, aSharedStrings);
OOX::Spreadsheet::CSheet* pSheet = new OOX::Spreadsheet::CSheet();
pSheet->m_oName.Init();
pSheet->m_oName->append(sSheetName);
pSheet->m_oSheetId.Init();
pSheet->m_oSheetId->SetValue(nSheetId++);
smart_ptr<OOX::File> oWorksheetFile = smart_ptr<OOX::File>(pWorksheet);
const OOX::RId oRId = pWorkbook->Add(oWorksheetFile);
const OOX::RId oRId = oXlsx.m_pWorkbook->Add(oWorksheetFile);
pSheet->m_oRid.Init();
pSheet->m_oRid->SetValue(oRId.get());
pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
mapWorksheets[pSheet->m_oName.get()] = pWorksheet;
oXlsx.m_pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
if(NULL == pFirstWorksheet)
{
@ -173,7 +182,7 @@ namespace BinXlsxRW{
}
//SharedStrings
OOX::Spreadsheet::CSharedStrings* pSharedStrings = oXlsx.CreateSharedStrings();
oXlsx.CreateSharedStrings();
for(size_t i = 0; i < aSharedStrings.size(); ++i)
{
OOX::Spreadsheet::CText* pText = new OOX::Spreadsheet::CText();
@ -185,20 +194,20 @@ namespace BinXlsxRW{
}
OOX::Spreadsheet::CSi* pSi = new OOX::Spreadsheet::CSi();
pSi->m_arrItems.push_back(pText);
pSharedStrings->AddSi(pSi);
oXlsx.m_pSharedStrings->AddSi(pSi);
}
pSharedStrings->m_oCount.Init();
pSharedStrings->m_oCount->SetValue(pSharedStrings->m_nCount);
pSharedStrings->m_oUniqueCount.Init();
pSharedStrings->m_oUniqueCount->SetValue(pSharedStrings->m_nCount);
oXlsx.m_pSharedStrings->m_oCount.Init();
oXlsx.m_pSharedStrings->m_oCount->SetValue(oXlsx.m_pSharedStrings->m_nCount);
oXlsx.m_pSharedStrings->m_oUniqueCount.Init();
oXlsx.m_pSharedStrings->m_oUniqueCount->SetValue(oXlsx.m_pSharedStrings->m_nCount);
//Styles
OOX::Spreadsheet::CStyles* pStyles = oXlsx.CreateStyles();
pStyles->m_oCellXfs.Init();
oXlsx.CreateStyles();
oXlsx.m_pStyles->m_oCellXfs.Init();
for(size_t i = 0; i < m_aXfs.size(); ++i)
{
pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
}
pStyles->m_oNumFmts.Init();
oXlsx.m_pStyles->m_oNumFmts.Init();
for (boost::unordered_map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); ++it)
{
@ -207,12 +216,13 @@ namespace BinXlsxRW{
pNumFmt->m_oFormatCode->append(it->first);
pNumFmt->m_oNumFmtId.Init();
pNumFmt->m_oNumFmtId->SetValue(NUMID_START + it->second);
pStyles->m_oNumFmts->m_arrItems.push_back(pNumFmt);
oXlsx.m_pStyles->m_oNumFmts->m_arrItems.push_back(pNumFmt);
}
pStyles->m_oNumFmts->m_oCount.Init();
pStyles->m_oNumFmts->m_oCount->SetValue(pStyles->m_oNumFmts->m_arrItems.size());
pStyles->m_oCellXfs->m_oCount.Init();
pStyles->m_oCellXfs->m_oCount->SetValue(pStyles->m_oCellXfs->m_arrItems.size());
oXlsx.m_pStyles->m_oNumFmts->m_oCount.Init();
oXlsx.m_pStyles->m_oNumFmts->m_oCount->SetValue(oXlsx.m_pStyles->m_oNumFmts->m_arrItems.size());
oXlsx.m_pStyles->m_oCellXfs->m_oCount.Init();
oXlsx.m_pStyles->m_oCellXfs->m_oCount->SetValue(oXlsx.m_pStyles->m_oCellXfs->m_arrItems.size());
OOX::Spreadsheet::CDxf* pDxf = new OOX::Spreadsheet::CDxf();
pDxf->m_oBorder.Init();
pDxf->m_oBorder->m_oStart.Init();
@ -239,15 +249,16 @@ namespace BinXlsxRW{
pDxf->m_oBorder->m_oBottom->m_oColor.Init();
pDxf->m_oBorder->m_oBottom->m_oColor->m_oIndexed.Init();
pDxf->m_oBorder->m_oBottom->m_oColor->m_oIndexed->SetValue(12);
pStyles->m_oDxfs.Init();
pStyles->m_oDxfs->m_arrItems.push_back(pDxf);
pStyles->m_oDxfs->m_oCount.Init();
pStyles->m_oDxfs->m_oCount->SetValue(pStyles->m_oDxfs->m_arrItems.size());
oXlsx.m_pStyles->m_oDxfs.Init();
oXlsx.m_pStyles->m_oDxfs->m_arrItems.push_back(pDxf);
oXlsx.m_pStyles->m_oDxfs->m_oCount.Init();
oXlsx.m_pStyles->m_oDxfs->m_oCount->SetValue(oXlsx.m_pStyles->m_oDxfs->m_arrItems.size());
//Table
//todo table в случае нескольких sheet или если серии разнесены по sheet
if(m_aTableNames.size() > 0)
{
OOX::Spreadsheet::CTableFile* pTable = new OOX::Spreadsheet::CTableFile();
OOX::Spreadsheet::CTableFile* pTable = new OOX::Spreadsheet::CTableFile(NULL);
pTable->m_oTable.Init();
pTable->m_oTable->m_oDisplayName.Init();
pTable->m_oTable->m_oDisplayName->append(L"Table1");
@ -290,9 +301,11 @@ namespace BinXlsxRW{
{
OOX::Spreadsheet::CTablePart* pTablePart = new OOX::Spreadsheet::CTablePart();
NSCommon::smart_ptr<OOX::File> pTableFile(pTable);
const OOX::RId oRId = pFirstWorksheet->Add(pTableFile);
pTablePart->m_oRId.Init();
pTablePart->m_oRId->SetValue(oRId.get());
pFirstWorksheet->m_oTableParts.Init();
pFirstWorksheet->m_oTableParts->m_arrItems.push_back(pTablePart);
pFirstWorksheet->m_oTableParts->m_oCount.Init();
@ -462,15 +475,15 @@ namespace BinXlsxRW{
//проверяем можем ли создать таблицу
if(m_mapSheets.size() > 0 && m_nRow1 > 0 && m_nRow2 > 0 && m_nCol1 > 0 && m_nCol2 > 0 && m_nRow1 < m_nRow2)
{
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
if(itRows != rows->end())
{
boost::unordered_map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
std::map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
std::vector<int> aIndexesCell;
for(boost::unordered_map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); ++it)
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); ++it)
{
aIndexesCell.push_back(it->first);
}
@ -490,14 +503,14 @@ namespace BinXlsxRW{
}
}
}
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(std::vector<OOX::Spreadsheet::CWorksheet*>& arWorksheets, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
{
OOX::Spreadsheet::CWorksheet* pWorksheet = NULL;
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator it = mapWorksheets.find(sName);
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator pFind = mapWorksheets.find(sName);
if (it == mapWorksheets.end())
if (pFind == mapWorksheets.end())
{
pWorksheet = new OOX::Spreadsheet::CWorksheet();
pWorksheet = new OOX::Spreadsheet::CWorksheet(NULL);
pWorksheet->m_oSheetFormatPr.Init();
pWorksheet->m_oSheetFormatPr->m_oDefaultRowHeight.Init();
pWorksheet->m_oSheetFormatPr->m_oDefaultRowHeight->SetValue(15);
@ -517,19 +530,20 @@ namespace BinXlsxRW{
pWorksheet->m_oPageMargins->m_oFooter->FromInches(0.3);
mapWorksheets[sName] = pWorksheet;
arWorksheets.push_back(pWorksheet);
}
else
{
pWorksheet = it->second;
pWorksheet = pFind->second;
}
return pWorksheet;
}
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
{
pWorksheet->m_oSheetData.Init();
std::vector<int> aIndexesRow;
for(boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); ++it)
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); ++it)
{
aIndexesRow.push_back(it->first);
}
@ -544,10 +558,10 @@ namespace BinXlsxRW{
pRow->m_oR.Init();
pRow->m_oR->SetValue(nIndexRow);
const boost::unordered_map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
const std::map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
std::vector<int> aIndexesCell;
for(boost::unordered_map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); ++it)
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); ++it)
{
aIndexesCell.push_back(it->first);
}
@ -605,24 +619,24 @@ namespace BinXlsxRW{
}
void ChartWriter::parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format = NULL)
{
boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
if(itSheets == m_mapSheets.end())
{
rows = new boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>();
rows = new std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>();
m_mapSheets.insert(std::make_pair(sheet, rows));
}
else
{
rows = itSheets->second;
}
boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
boost::unordered_map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
std::map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
if(itRows == rows->end())
{
cells = new boost::unordered_map<int, OOX::Spreadsheet::CCell*>();
cells = new std::map<int, OOX::Spreadsheet::CCell*>();
rows->insert(std::make_pair(nRow, cells));
}
else

View File

@ -34,6 +34,7 @@
#include <string>
#include <vector>
#include <map>
#include <boost/unordered_map.hpp>
namespace OOX
@ -59,8 +60,8 @@ namespace BinXlsxRW {
class ChartWriter
{
public:
boost::unordered_map<std::wstring, boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>*> m_mapSheets;
boost::unordered_map<std::wstring, int> m_mapFormats;
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*> m_mapSheets;
boost::unordered_map<std::wstring, int> m_mapFormats;
std::vector<OOX::Spreadsheet::CXfs*> m_aXfs;
std::vector<std::wstring> m_aTableNames;
@ -76,8 +77,9 @@ namespace BinXlsxRW {
void parseChart(const OOX::Spreadsheet::CT_Chart* pChart);
private:
OOX::Spreadsheet::CWorksheet* toXlsxGetSheet(boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName);
void toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const boost::unordered_map<int, boost::unordered_map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings);
OOX::Spreadsheet::CWorksheet* toXlsxGetSheet(std::vector<OOX::Spreadsheet::CWorksheet*>& arWorksheets, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName);
void toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings);
void parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format);
OOX::Spreadsheet::CCell* parseCreateCell(const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format);
void parseStrRef(const OOX::Spreadsheet::CT_StrRef* pStrRef, bool bUpdateRange, const wchar_t* cRangeName);

View File

@ -39,6 +39,9 @@
#include "../../ASCOfficePPTXFile/Editor/FontPicker.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Core.h"
int BinDocxRW::g_nCurFormatVersion = 0;
BinDocxRW::CDocxSerializer::CDocxSerializer()
@ -47,7 +50,7 @@ BinDocxRW::CDocxSerializer::CDocxSerializer()
m_pCurFileWriter = NULL;
m_bIsNoBase64Save = false;
m_bIsNoBase64 = false;
m_bIsNoBase64 = false;
m_bSaveChartAsImg = false;
}
BinDocxRW::CDocxSerializer::~CDocxSerializer()
@ -292,11 +295,13 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
OOX::CPath DocProps = std::wstring(_T("docProps"));
OOX::CApp* pApp = new OOX::CApp();
OOX::CApp* pApp = new OOX::CApp(NULL);
if (pApp)
{
pApp->SetApplication(_T("OnlyOffice"));
pApp->SetAppVersion(_T("5.0"));
pApp->SetApplication(L"ONLYOFFICE");
#if defined(INTVER)
pApp->SetAppVersion(VALUE2STR(INTVER));
#endif
pApp->SetDocSecurity(0);
pApp->SetScaleCrop(false);
pApp->SetLinksUpToDate(false);
@ -306,7 +311,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, *pContentTypes);
delete pApp;
}
OOX::CCore* pCore = new OOX::CCore();
OOX::CCore* pCore = new OOX::CCore(NULL);
if (pCore)
{
pCore->SetCreator(_T(""));

View File

@ -33,6 +33,12 @@
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/TableStyles.h"
#include "../../ASCOfficePPTXFile/PPTXFormat/Theme.h"
#include "../../Common/ASCUtils.h"
namespace DocWrapper {

View File

@ -42,6 +42,7 @@
#include "ChartWriter.h"
#include "../BinReader/DefaultThemeWriter.h"
//#include "../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
namespace BinXlsxRW{
int g_nCurFormatVersion = 0;
@ -168,7 +169,7 @@ namespace BinXlsxRW{
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath, m_pExternalDrawingConverter->GetContentTypes());
OOX::Spreadsheet::CChartSpace oChartSpace;
OOX::Spreadsheet::CChartSpace oChartSpace(NULL);
BinXlsxRW::BinaryChartReader oBinaryChartReader(*pReader, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);

View File

@ -16,8 +16,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
USE_AVSOFFICESTUDIO_XMLUTILS \
SOLUTION_ASCOFFICEDOCXFILE2 \
#DISABLE_FILE_DOWNLOADER \

View File

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

View File

@ -22,8 +22,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS
@ -288,6 +286,7 @@ SOURCES += \
../src/docx/xlsx_table_state.cpp \
../src/docx/xlsx_textcontext.cpp \
../src/docx/xlsx_pivots_context.cpp \
../src/docx/xlsx_data_validation.cpp \
../src/docx/xlsx_utils.cpp \
../src/docx/xlsx_xf.cpp
}
@ -551,6 +550,7 @@ HEADERS += \
../src/docx/xlsx_table_position.h \
../src/docx/xlsx_table_state.h \
../src/docx/xlsx_textcontext.h \
../src/docx/xlsx_data_validation.h \
../src/docx/xlsx_utils.h \
../src/docx/xlsx_xf.h \
../include/logging.h \

View File

@ -101,3 +101,4 @@
#include "../src/docx/xlsx_utils.cpp"
#include "../src/docx/xlsx_xf.cpp"
#include "../src/docx/xlsx_pivots_context.cpp"
#include "../src/docx/xlsx_data_validation.cpp""

View File

@ -732,16 +732,38 @@ void docx_conversion_context::start_process_style_content()
styles_context_.start();
}
void docx_conversion_context::process_section(std::wostream & strm, odf_reader::style_columns * columns)
void docx_conversion_context::process_section(std::wostream & strm, odf_reader::style_columns * columns)//from page layout
{
int count_columns = 1;
bool sep_columns = false;
oox::section_context::_section & section = get_section_context().get();
if (!columns)
{
if (const odf_reader::style_instance * secStyle = root()->odf_context().styleContainer().style_by_name(section.style_, odf_types::style_family::Section, process_headers_footers_))
{
if (const odf_reader::style_content * content = secStyle->content())
{
if (odf_reader::style_section_properties * sectPr = content->get_style_section_properties())
{
columns = dynamic_cast<odf_reader::style_columns *>( sectPr->style_columns_.get());
section.margin_left_ = sectPr->common_horizontal_margin_attlist_.fo_margin_left_;
section.margin_right_ = sectPr->common_horizontal_margin_attlist_.fo_margin_right_;
}
}
if (section.is_dump_)
{
get_section_context().remove_section();
}
}
}
std::vector<std::pair<double, double>> width_space;
if (columns)
{
if ((columns->fo_column_count_) && (*columns->fo_column_count_ > 1))
if (columns->fo_column_count_)
{
count_columns = *columns->fo_column_count_;
}
@ -750,44 +772,64 @@ void docx_conversion_context::process_section(std::wostream & strm, odf_reader::
if (columns_sep->style_style_ != _T("none"))
sep_columns = true;
}
}
if (const odf_reader::style_instance * secStyle = root()->odf_context().styleContainer().style_by_name(section.style_, odf_types::style_family::Section, process_headers_footers_))
{
if (const odf_reader::style_content * content = secStyle->content())
{
if (odf_reader::style_section_properties * sectPr = content->get_style_section_properties())
{
if (odf_reader::style_columns * columns = dynamic_cast<odf_reader::style_columns *>( sectPr->style_columns_.get() ))
{
if (columns->fo_column_count_)
{
count_columns = *columns->fo_column_count_;
}
if (odf_reader::style_column_sep * columns_sep = dynamic_cast<odf_reader::style_column_sep *>( columns->style_column_sep_.get() ))
{
if (columns_sep->style_style_ != _T("none"))
sep_columns = true;
}
}
section.margin_left_ = sectPr->common_horizontal_margin_attlist_.fo_margin_left_;
section.margin_right_ = sectPr->common_horizontal_margin_attlist_.fo_margin_right_;
if (!columns->style_columns_.empty())
{
double page_width = 0;
const odf_reader::page_layout_instance * pp = root()->odf_context().pageLayoutContainer().page_layout_first();
if ((pp) && (pp->properties()))
{
odf_reader::style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
if (attr_page.fo_page_width_)
{
page_width = attr_page.fo_page_width_->get_value_unit(odf_types::length::pt);
}
if (attr_page.common_horizontal_margin_attlist_.fo_margin_left_)
{
page_width -= attr_page.common_horizontal_margin_attlist_.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt);
}
if (attr_page.common_horizontal_margin_attlist_.fo_margin_right_)
{
page_width -= attr_page.common_horizontal_margin_attlist_.fo_margin_right_->get_length().get_value_unit(odf_types::length::pt);
}
}
for (size_t i = 0; page_width > 0, i < columns->style_columns_.size(); i++)
{
odf_reader::style_column * col = dynamic_cast<odf_reader::style_column*>( columns->style_columns_[i].get());
if (!col) continue;
double width = page_width * (col->style_rel_width_ ? col->style_rel_width_->get_value() / 65535. : 0);
double space = col->fo_end_indent_ ? col->fo_end_indent_->get_value_unit(odf_types::length::pt) : 0;
if (i < columns->style_columns_.size() - 1)
{
col = dynamic_cast<odf_reader::style_column*>( columns->style_columns_[i + 1].get());
space += col->fo_start_indent_ ? col->fo_start_indent_->get_value_unit(odf_types::length::pt) : 0;
}
width_space.push_back(std::make_pair(width, space));
}
}
if (section.is_dump_)
{
get_section_context().remove_section();
}
}
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:cols")
{
CP_XML_ATTR(L"w:equalWidth", L"true");
CP_XML_ATTR(L"w:equalWidth", width_space.empty());
CP_XML_ATTR(L"w:num", count_columns);
CP_XML_ATTR(L"w:sep", sep_columns);
CP_XML_ATTR(L"w:space",0);
CP_XML_ATTR(L"w:space", 708);
for (size_t i = 0; i < width_space.size(); i++)
{
CP_XML_NODE(L"w:col")
{
CP_XML_ATTR(L"w:w", (int)(width_space[i].first * 20));
CP_XML_ATTR(L"w:space", (int)(width_space[i].second * 20));
}
}
}
}
}
@ -846,18 +888,18 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
CP_XML_WRITER(strm)
{
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
&& !get_table_context().in_table() && !in_drawing)
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
CP_XML_NODE(L"w:pPr")
{
CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();
}
finish_paragraph();
start_paragraph();
}
////Tutor_Charlotte_Tutor_the_Entire_World_.odt
//if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
// && !get_table_context().in_table() && !in_drawing)
//{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
// CP_XML_NODE(L"w:pPr")
// {
// CP_XML_STREAM() << get_section_context().dump_;
// get_section_context().dump_.clear();
// }
// finish_paragraph();
// start_paragraph();
//}
if (!paragraph_style.str().empty() || !ParentId.empty())
{

View File

@ -40,6 +40,7 @@
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/raster/Metafile/MetaFile.h"
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../Common/DocxFormat/Source/Base/Base.h"
namespace cpdoccore {
namespace oox {
@ -284,8 +285,8 @@ void core_file::write(const std::wstring & RootPath)
L"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" "
L"xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" >";
//resStream << L"<dc:creator>ONLYOFFICE Online Editor</dc:creator>";
//resStream << L"<cp:lastModifiedBy>ONLYOFFICE Online Editor</cp:lastModifiedBy>";
//resStream << L"<dc:creator>ONLYOFFICE</dc:creator>";
//resStream << L"<cp:lastModifiedBy>ONLYOFFICE</cp:lastModifiedBy>";
resStream << L"<cp:revision>1</cp:revision>";
resStream << L"</cp:coreProperties>";
@ -300,8 +301,12 @@ void app_file::write(const std::wstring & RootPath)
resStream << L"<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" "
L"xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\" >";
resStream << L"<Application>OnlyOffice</Application>";
resStream << L"</Properties>";
resStream << L"<Application>ONLYOFFICE";
#if defined(INTVER)
std::string s = VALUE2STR(INTVER);
resStream << L"/" << std::wstring(s.begin(), s.end()) ;
#endif
resStream << L"</Application></Properties>";
simple_element elm(L"app.xml", resStream.str());
elm.write(RootPath);

View File

@ -116,7 +116,7 @@ public:
int priority = 1;
CP_XML_WRITER(_Wostream)
{
for (int i = 0 ; i < conditionalFormattings_.size(); i++)
for (size_t i = 0 ; i < conditionalFormattings_.size(); i++)
{
conditionalFormatting & c = conditionalFormattings_[i];
@ -126,7 +126,7 @@ public:
{
CP_XML_ATTR(L"sqref", c.ref);
for (int j = 0 ; j < c.rules.size(); j++)
for (size_t j = 0 ; j < c.rules.size(); j++)
{
if (c.rules[j].type < 1 || c.rules[j].type > 5) continue;
@ -171,7 +171,7 @@ public:
if (c.rules[j].minLength) CP_XML_ATTR(L"minLength", *c.rules[j].minLength);
if (c.rules[j].maxLength) CP_XML_ATTR(L"maxLength", *c.rules[j].maxLength);
for (int k = 0; k < c.rules[j].cfvo.size(); k++)
for (size_t k = 0; k < c.rules[j].cfvo.size(); k++)
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
@ -189,11 +189,11 @@ public:
CP_XML_ATTR(L"type", L"colorScale");
CP_XML_NODE(L"colorScale")
{
for (int k = 0; k < c.rules[j].cfvo.size(); k++)
for (size_t k = 0; k < c.rules[j].cfvo.size(); k++)
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
for (int k = 0; k < c.rules[j].color.size(); k++)
for (size_t k = 0; k < c.rules[j].color.size(); k++)
{
CP_XML_NODE(L"color")
{
@ -209,7 +209,7 @@ public:
{
if (c.rules[j].showValue) CP_XML_ATTR(L"showValue", *c.rules[j].showValue);
for (int k = 0; k < c.rules[j].cfvo.size(); k++)
for (size_t k = 0; k < c.rules[j].cfvo.size(); k++)
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}

View File

@ -0,0 +1,212 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "xlsx_data_validation.h"
#include "xlsx_utils.h"
#include <vector>
#include <map>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <cpdoccore/CPSharedPtr.h>
#include "../formulasconvert/formulasconvert.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace cpdoccore {
namespace oox {
class xlsx_dataValidation
{
public:
xlsx_dataValidation() : showErrorMessage(false), showInputMessage(false), showDropDown(false), allowBlank(false) {}
std::wstring ref;
std::wstring activate_ref;
std::wstring type;
std::wstring formula1;
std::wstring formula2;
std::wstring operator_;
bool showErrorMessage;
bool showInputMessage;
bool showDropDown;
bool allowBlank;
};
typedef shared_ptr<xlsx_dataValidation>::Type xlsx_dataValidation_ptr;
class xlsx_dataValidations_context::Impl
{
public:
void serialize(std::wostream & _Wostream)
{
if (mapActivateDataValidations.empty()) return;
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"dataValidations")
{
CP_XML_ATTR(L"count", mapActivateDataValidations.size());
for (std::map<std::wstring, xlsx_dataValidation_ptr>::iterator it = mapActivateDataValidations.begin();
it != mapActivateDataValidations.end(); ++it)
{
CP_XML_NODE(L"dataValidation")
{
CP_XML_ATTR(L"sqref", it->second->activate_ref);
CP_XML_ATTR(L"allowBlank", it->second->allowBlank);
CP_XML_ATTR(L"operator", it->second->operator_);
CP_XML_ATTR(L"showDropDown", it->second->showDropDown);
CP_XML_ATTR(L"showErrorMessage", it->second->showErrorMessage);
CP_XML_ATTR(L"showInputMessage", it->second->showInputMessage);
CP_XML_ATTR(L"type", it->second->type);
if (!it->second->formula1.empty())
{
CP_XML_NODE(L"formula1")
{
CP_XML_STREAM() << it->second->formula1;
}
}
if (!it->second->formula2.empty())
{
CP_XML_NODE(L"formula2")
{
CP_XML_STREAM() << it->second->formula2;
}
}
}
}
}
}
mapActivateDataValidations.clear();
}
std::map<std::wstring, xlsx_dataValidation_ptr> mapDataValidations; //for all tables
std::map<std::wstring, xlsx_dataValidation_ptr> mapActivateDataValidations; //in current table
};
xlsx_dataValidations_context::xlsx_dataValidations_context() :
impl_(new xlsx_dataValidations_context::Impl())
{}
xlsx_dataValidations_context::~xlsx_dataValidations_context()
{
}
void xlsx_dataValidations_context::serialize(std::wostream & _Wostream)
{
return impl_->serialize(_Wostream);
}
void xlsx_dataValidations_context::activate(const std::wstring & name, const std::wstring & ref)
{
std::map<std::wstring, xlsx_dataValidation_ptr>::iterator pFindActivate = impl_->mapActivateDataValidations.find(name);
if (pFindActivate != impl_->mapActivateDataValidations.end())
{
pFindActivate->second->activate_ref += L" " + ref;
}
else
{
std::map<std::wstring, xlsx_dataValidation_ptr>::iterator pFind = impl_->mapDataValidations.find(name);
if (pFind != impl_->mapDataValidations.end())
{
pFind->second->activate_ref = ref;
impl_->mapActivateDataValidations.insert(std::make_pair(name, pFind->second));
}
}
}
void xlsx_dataValidations_context::add_help_msg(const std::wstring & name, bool val)
{
std::map<std::wstring, xlsx_dataValidation_ptr>::iterator pFind = impl_->mapDataValidations.find(name);
if (pFind == impl_->mapDataValidations.end()) return;
pFind->second->showInputMessage = val;
}
void xlsx_dataValidations_context::add_error_msg(const std::wstring & name, bool val)
{
std::map<std::wstring, xlsx_dataValidation_ptr>::iterator pFind = impl_->mapDataValidations.find(name);
if (pFind == impl_->mapDataValidations.end()) return;
pFind->second->showErrorMessage = val;
}
void xlsx_dataValidations_context::add(const std::wstring & name, const std::wstring &ref)
{
xlsx_dataValidation_ptr _new = xlsx_dataValidation_ptr(new xlsx_dataValidation());
formulasconvert::odf2oox_converter converter;
_new->ref = converter.convert_named_ref(ref, false, L";");
impl_->mapDataValidations.insert(std::make_pair(name, _new));
}
void xlsx_dataValidations_context::add_formula(const std::wstring & name, const std::wstring & f) // todooo пооптимальней
{
std::map<std::wstring, xlsx_dataValidation_ptr>::iterator pFind = impl_->mapDataValidations.find(name);
if (pFind == impl_->mapDataValidations.end()) return;
formulasconvert::odf2oox_converter converter;
int pos = -1;
std::wstring val;
if ( 0 <= (pos = f.find(L"cell-content-is-in-list"))) //oooc: , of:
{
pFind->second->type = L"list";
val = f.substr(24 + pos, f.size() - 25 - pos);
if ( val.substr(0, 1) == L"\"")
{
XmlUtils::replace_all(val, L"\"", L"");
pFind->second->formula1 = converter.convert(val);
if ( std::wstring::npos != val.find(L";") )//convert formula replacing ; on ,
{
pFind->second->formula1 = L"\"" + pFind->second->formula1 + L"\"";
}
}
else
{
pFind->second->formula1 = converter.convert(val);
}
}
}
}
}

View File

@ -1,44 +1,61 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef COMMON_UTILS_INCLUDE_H_
#define COMMON_UTILS_INCLUDE_H_
#include "../SystemUtility/SystemUtility.h"
#include <vector>
namespace Common
{
void readAllShapeTypes(const OOX::CPath& oPath, std::vector<std::wstring>& aShapetypes);
} // namespace Common
#endif // COMMON_UTILS_INCLUDE_H_
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/CPScopedPtr.h>
#include <string>
namespace cpdoccore {
namespace oox {
class xlsx_dataValidations_context
{
public:
xlsx_dataValidations_context();
~xlsx_dataValidations_context();
void add(const std::wstring & name, const std::wstring & ref);
void add_formula(const std::wstring & name, const std::wstring & f);
void add_help_msg(const std::wstring & name, bool val);
void add_error_msg(const std::wstring & name, bool val);
void activate(const std::wstring & name, const std::wstring & ref);
void serialize(std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}

View File

@ -54,6 +54,8 @@ public:
std::wstringstream sort_;
std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
std::wstringstream picture_background_;
std::wstringstream dataValidations_;
std::wstringstream ole_objects_;
std::wstringstream page_props_;
@ -138,7 +140,14 @@ std::wostream & xlsx_xml_worksheet::page_properties()
{
return impl_->page_props_;
}
std::wostream & xlsx_xml_worksheet::picture_background()
{
return impl_->picture_background_;
}
std::wostream & xlsx_xml_worksheet::dataValidations()
{
return impl_->dataValidations_;
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::sheet_rels()
{
@ -178,6 +187,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->conditionalFormatting_.str();
CP_XML_STREAM() << impl_->dataValidations_.str();
if (!impl_->hyperlinks_.str().empty())
{
CP_XML_NODE(L"hyperlinks")
@ -207,6 +217,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
CP_XML_STREAM() << impl_->picture_background_.str();
//CP_XML_NODE(L"headerFooter){}

View File

@ -61,6 +61,8 @@ public:
std::wostream & comments();
std::wostream & autofilter();
std::wostream & conditionalFormatting();
std::wostream & picture_background();
std::wostream & dataValidations();
std::wostream & sort();
std::wostream & ole_objects();
std::wostream & page_properties();

View File

@ -120,7 +120,7 @@ public:
xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; }
xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_context_; }
xlsx_comments_context & get_comments_context() { return xlsx_comments_context_; }
xlsx_conditionalFormatting_context & get_conditionalFormatting_context() {return xlsx_conditionalFormatting_context_;}
xlsx_conditionalFormatting_context & get_conditionalFormatting_context() { return xlsx_conditionalFormatting_context_;}
void table_column_last_width(double w) { table_column_last_width_ = w; }
double table_column_last_width() const { return table_column_last_width_; };

View File

@ -324,6 +324,10 @@ void xlsx_table_context::serialize_background(std::wostream & _Wostream)
{
return state()->serialize_background(_Wostream);
}
void xlsx_table_context::serialize_data_validation(std::wostream & _Wostream)
{
return xlsx_conversion_context_->get_dataValidations_context().serialize(_Wostream);
}
void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
{
return state()->serialize_hyperlinks(_Wostream);

View File

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

View File

@ -49,13 +49,6 @@
namespace cpdoccore {
namespace oox {
void removeCharsFromString( std::wstring &str, std::wstring charsToRemove )
{
for ( unsigned int i = 0; i < charsToRemove.length(); ++i )
{
str.erase( std::remove(str.begin(), str.end(), charsToRemove[i]), str.end() );
}
}
class xlsx_text_context::Impl: boost::noncopyable
{

View File

@ -437,6 +437,7 @@ void xlsx_conversion_context::end_table()
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_drawing_context().set_odf_packet_path (root()->get_folder());
get_drawing_context().process_objects (get_table_metrics());

View File

@ -49,6 +49,7 @@
#include "xlsx_defined_names.h"
#include "xlsx_table_metrics.h"
#include "xlsx_pivots_context.h"
#include "xlsx_data_validation.h"
#include "oox_chart_context.h"
#include "mediaitems.h"
@ -179,6 +180,7 @@ public:
xlsx_drawing_context_handle & get_drawing_context_handle();
xlsx_comments_context & get_comments_context();
xlsx_comments_context_handle & get_comments_context_handle();
xlsx_dataValidations_context& get_dataValidations_context() { return xlsx_dataValidations_context_;}
mediaitems & get_mediaitems() { return mediaitems_; }
@ -212,6 +214,7 @@ private:
xlsx_pivots_context xlsx_pivots_context_;
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
xlsx_comments_context_handle xlsx_comments_context_handle_;
xlsx_dataValidations_context xlsx_dataValidations_context_;
};
}

View File

@ -233,8 +233,9 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
Context.set_paragraph_state (false);
Context.set_run_state (false);
Context.get_math_context().base_font_size_ = baseFontHeight_;
Context.start_math_formula();
Context.get_math_context().base_font_size_ = baseFontHeight_;
office_math_->oox_convert(Context.get_math_context());
Context.end_math_formula();

View File

@ -41,9 +41,10 @@ std::wostream & operator << (std::wostream & _Wostream, const chart_data_label_n
{
switch(_Val.get_type())
{
case chart_data_label_number::none: _Wostream << L"none"; break;
case chart_data_label_number::value: _Wostream << L"value"; break;
case chart_data_label_number::percentage : _Wostream << L"percentage"; break;
case chart_data_label_number::none: _Wostream << L"none"; break;
case chart_data_label_number::value: _Wostream << L"value"; break;
case chart_data_label_number::percentage : _Wostream << L"percentage"; break;
case chart_data_label_number::value_and_percentage: _Wostream << L"value-and-percentage"; break;
}
return _Wostream;
}
@ -59,9 +60,10 @@ chart_data_label_number chart_data_label_number::parse(const std::wstring & Str)
return chart_data_label_number( value );
else if (tmp == L"percentage")
return chart_data_label_number( percentage );
else
else if (tmp == L"value-and-percentage")
return chart_data_label_number( value_and_percentage );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return chart_data_label_number( none );
}
}

View File

@ -45,7 +45,8 @@ public:
{
none,
value,
percentage
percentage,
value_and_percentage
};
chart_data_label_number() {}

View File

@ -61,6 +61,7 @@ private:
document_context::document_context() : impl_( new document_context::Impl() )
{
level = 0;
}
document_context::~document_context()

View File

@ -45,10 +45,11 @@ class document_context
public:
document_context();
virtual ~document_context();
public:
void set_last_paragraph(text::paragraph * Paragraph);
text::paragraph * get_last_paragraph();
int level;
private:
class Impl;

View File

@ -144,7 +144,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(svg_font_face_name);
// svg:definition-src
@ -164,10 +163,8 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(svg_definition_src);
// style:font-face
class style_font_face : public office_element_impl<style_font_face>
{
@ -233,7 +230,6 @@ public:
friend class odf_document;
};
CP_REGISTER_OFFICE_ELEMENT2(style_font_face);
// office-font-face-decls
@ -257,7 +253,6 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(office_font_face_decls);
}

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "paragraph_elements.h"

View File

@ -38,7 +38,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/CPColorUtils.h>
#include "serialize_elements.h"

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
namespace cpdoccore {
namespace odf_reader {

View File

@ -36,7 +36,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/odf/odf_document.h>
@ -152,6 +151,8 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
{
if (page_layout_instance * lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{
Context.next_dump_page_properties(true);
lastPageLayout->docx_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();
}

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"
@ -81,7 +80,16 @@ void chart_chart::add_attributes( const xml::attributes_wc_ptr & Attributes )
void chart_chart::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
if CP_CHECK_NAME(L"text", L"tracked-changes")
{
CP_CREATE_ELEMENT(tracked_changes_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
}
else
CP_CREATE_ELEMENT(content_);
}
void chart_title_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{

View File

@ -60,7 +60,10 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
office_element_ptr_array content_;
office_element_ptr tracked_changes_;
office_element_ptr content_validations_;
office_element_ptr_array content_;
};
@ -105,6 +108,10 @@ private:
public:
chart_chart_attlist attlist_;
office_element_ptr tracked_changes_;
office_element_ptr content_validations_;
office_element_ptr_array content_;
};

View File

@ -69,8 +69,14 @@ enum ElementType
typeTextTime,
typeTextModificationTime,
typeTextFileName,
typeTextSequence,
typeTextSheetName,
typeTextTemplateName,
typeTextDropDown,
typeTextLabel,
typeTextSequenceDecls,
typeTextSequenceDecl,
typeTextSequence,
typePresentationFooter,
typePresentationDateTime,
@ -78,6 +84,8 @@ enum ElementType
typeDcCreator,
typeDcDate,
typeDrawA,
typeTextH,
typeTextP,
@ -90,28 +98,42 @@ enum ElementType
typeTextSectionSource,
typeTextIndexTitle,
typeTextIndexBody,
typeTextNumberedParagraph,
typeDrawA,
typeTextNumberedParagraph,
typeTextExpression,
typeTextTableOfContent,
typeTextIllustrationIndex,
typeTextTableIndex,
typeTextObjectIndex,
typeTextUserIndex,
typeTextAlphabeticalIndex,
typeTextBibliography,
typeTextBibliographyMark,
typeTextTableOfContentSource,
typeTextIllustrationIndex,
typeTextIllustrationIndexSource,
typeTextTableIndex,
typeTextTableIndexSource,
typeTextObjectIndex,
typeTextObjectIndexSource,
typeTextUserIndex,
typeTextUserIndexSource,
typeTextAlphabeticalIndex,
typeTextAlphabeticalIndexSource,
typeTextBibliographySource,
typeTextBibliography,
typeTextBibliographyMark,
typeTextBibliographySource,
typeTextVariableInput,
typeTextVariableGet,
typeTextVariableSet,
typeTextVariableDecl,
typeTextVariableDecls,
typeTextUserFieldDecls,
typeTextUserFieldDecl,
typeTextUserFieldGet,
typeTextUserFieldSet,
typeTextUserFieldInput,
typeTextTrackedChanges,
typeTextChangedRegion,
@ -125,6 +147,11 @@ enum ElementType
typeTextFormatChange,
typeTextInsertion,
typeTextMeta,
typeTextMetaField,
typeTextTextInput,
typeShape,
typeChangeMarks,
@ -206,6 +233,14 @@ enum ElementType
typeTableDatabaseRange,
typeTableSort,
typeTableSortBy,
typeTableCalculationSettings,
typeTableNullDate,
typeTableShapes,
typeTableContentValidation,
typeTableContentValidations,
typeTableHelpMassage,
typeTableErrorMassage,
typeTableErrorMacro,
typeTableFilter,
typeTableFilterAnd,
@ -384,9 +419,6 @@ enum ElementType
typeScriptEventListener,
typeTableCalculationSettings,
typeTableNullDate,
typeNumberNumberStyle,
typeNumberDataStyle,
typeNumberText,
@ -409,7 +441,6 @@ enum ElementType
typeNumberMinutes,
typeNumberSeconds,
typeNumberAmPm,
typeTableShapes,
typeChartChart,
typeChartTitle,

View File

@ -54,11 +54,25 @@ const wchar_t * office_presentation::name = L"presentation";
void office_presentation::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"draw", L"page")
{
CP_CREATE_ELEMENT(pages_);
}
else if CP_CHECK_NAME(L"table", L"tracked-changes")
{
CP_CREATE_ELEMENT(tracked_changes_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
}
else if CP_CHECK_NAME(L"presentation", L"footer-decl")
{
CP_CREATE_ELEMENT(footer_decls_);
}
else if CP_CHECK_NAME(L"presentation", L"date-time-decl")
{
CP_CREATE_ELEMENT(date_time_decls_);
}
}

View File

@ -62,10 +62,13 @@ private:
public:
office_element_ptr_array date_time_decls_;
office_element_ptr_array footer_decls_;
office_element_ptr tracked_changes_;
office_element_ptr content_validations_;
office_element_ptr_array date_time_decls_;
office_element_ptr_array footer_decls_;
office_element_ptr_array pages_;
office_element_ptr_array pages_;
};

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"

View File

@ -63,6 +63,10 @@ void office_spreadsheet::add_child_element( xml::sax * Reader, const std::wstrin
{
CP_CREATE_ELEMENT(tracked_changes_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
}
else
CP_CREATE_ELEMENT(content_);
}
@ -88,6 +92,9 @@ void office_spreadsheet::xlsx_convert(oox::xlsx_conversion_context & Context)
if (database_ranges_)
database_ranges_->xlsx_convert(Context);
if (content_validations_)
content_validations_->xlsx_convert(Context);
if (data_pilot_tables_)
data_pilot_tables_->xlsx_convert(Context);

View File

@ -62,12 +62,12 @@ public:
office_element_ptr database_ranges_;
office_element_ptr data_pilot_tables_;
office_element_ptr tracked_changes_;
office_element_ptr content_validations_;
office_element_ptr_array content_;
// table:calculation-settings
// table:consolidation
// table:content-validations
// table:dde-links
// table:label-ranges

View File

@ -101,6 +101,10 @@ void office_text::add_child_element( xml::sax * Reader, const std::wstring & Ns,
{
CP_CREATE_ELEMENT(tracked_changes_);
}
else if CP_CHECK_NAME(L"table", L"content-validations")
{
CP_CREATE_ELEMENT(content_validations_);
}
else if (is_text_content(Ns, Name))
{
CP_CREATE_ELEMENT(content_);

View File

@ -67,7 +67,9 @@ private:
// TODO: table-decls
office_element_ptr tracked_changes_;
office_element_ptr_array content_;
office_element_ptr content_validations_;
office_element_ptr_array content_;
// TODO: text-page-sequence
// TODO: office-text-content-epilogue:
// TODO: table-functions

View File

@ -39,7 +39,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/common/readstring.h>
#include <cpdoccore/odf/odf_document.h>
@ -742,7 +741,7 @@ std::wostream & title::text_to_stream(std::wostream & _Wostream) const
void title::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_field_fixed_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
}
void title::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -806,7 +805,7 @@ std::wostream & subject::text_to_stream(std::wostream & _Wostream) const
void subject::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_field_fixed_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
}
void subject::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -823,8 +822,8 @@ void subject::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & strm = Context.output_stream();
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\" /></w:r>";
strm << L"<w:r><w:instrText>SUBJECT</w:instrText></w:r><w:r><w:fldChar w:fldCharType=\"separate\" /></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>";
strm << L"<w:r><w:instrText>SUBJECT</w:instrText></w:r><w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
Context.add_new_run();
std::wstring textNode = L"w:t";
@ -838,7 +837,7 @@ void subject::docx_convert(oox::docx_conversion_context & Context)
strm << L"</" << textNode << L">";
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"end\" /></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
void subject::xlsx_convert(oox::xlsx_conversion_context & Context)
@ -869,7 +868,7 @@ std::wostream & chapter::text_to_stream(std::wostream & _Wostream) const
void chapter::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
common_field_fixed_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
}
void chapter::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -1379,9 +1378,77 @@ void sequence::pptx_convert(oox::pptx_conversion_context & Context)
text_[i]->pptx_convert(Context);
}
}
//-------------------------------------------------------------------------------------------------------------------
// text:drop-down
//-------------------------------------------------------------------------------------------------------------------
const wchar_t * text_drop_down::ns = L"text";
const wchar_t * text_drop_down::name = L"drop-down";
// text:sequesheet-namence
//////////////////////////////////////////////////////////////////////////////////////////////////
void text_drop_down::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", text_name_);
}
void text_drop_down::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"label")
{
CP_CREATE_ELEMENT(content_);
}
else
{
}
}
void text_drop_down::add_text(const std::wstring & Text)
{
text_ = Text;
}
std::wostream & text_drop_down::text_to_stream(std::wostream & _Wostream) const
{
_Wostream << xml::utils::replace_text_to_xml( text_ );
return _Wostream;
}
void text_drop_down::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & strm = Context.output_stream();
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"><w:ffData><w:name w:val=\"" << text_name_.get_value_or(L"") << L"\"/><w:enabled/>";
strm << L"<w:ddList><w:result w:val=\"0\"/>";
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
}
strm << L"</w:ddList></w:ffData>";
strm << L"</w:fldChar></w:r>";
strm << L"<w:r><w:instrText>FORMDROPDOWN</w:instrText></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
strm << L"<w:r><w:t>" << text_ << L"</w:t></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
//-------------------------------------------------------------------------------------------------------------------
// text:label
//-------------------------------------------------------------------------------------------------------------------
const wchar_t * text_label::ns = L"text";
const wchar_t * text_label::name = L"label";
void text_label::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:value", text_value_);
}
void text_label::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & strm = Context.output_stream();
strm << L"<w:listEntry w:val=\"" << text_value_.get_value_or(L"") << L"\"/>";
}
//-------------------------------------------------------------------------------------------------------------------
// text:sheet-name
//-------------------------------------------------------------------------------------------------------------------
const wchar_t * sheet_name::ns = L"text";
const wchar_t * sheet_name::name = L"sheet-name";

View File

@ -122,7 +122,6 @@ private:
_CP_OPT(unsigned int) text_c_;
_CP_OPT(std::wstring) content_;
};
CP_REGISTER_OFFICE_ELEMENT2(s);
// text:tab
@ -431,7 +430,6 @@ CP_REGISTER_OFFICE_ELEMENT2(a);
// text:note
//////////////////////////////////////////////////////////////////////////////////////////////////
class note : public paragraph_content_element<note>
{
public:
@ -452,18 +450,16 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
std::wstring text_id_;
odf_types::noteclass text_note_class_;
office_element_ptr text_note_citation_;
office_element_ptr text_note_body_;
std::wstring text_id_;
odf_types::noteclass text_note_class_;
office_element_ptr text_note_citation_;
office_element_ptr text_note_body_;
};
CP_REGISTER_OFFICE_ELEMENT2(note);
// text:ruby
//////////////////////////////////////////////////////////////////////////////////////////////////
class ruby : public paragraph_content_element<ruby>
{
public:
@ -485,7 +481,6 @@ private:
office_element_ptr text_ruby_text_;
};
CP_REGISTER_OFFICE_ELEMENT2(ruby);
class common_field_fixed_attlist
@ -521,8 +516,8 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
common_field_fixed_attlist common_field_fixed_attlist_;
office_element_ptr_array content_;
common_field_fixed_attlist attlist_;
office_element_ptr_array content_;
};
@ -549,7 +544,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
common_field_fixed_attlist common_field_fixed_attlist_;
common_field_fixed_attlist attlist_;
office_element_ptr_array content_;
};
@ -577,7 +572,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
common_field_fixed_attlist common_field_fixed_attlist_;
common_field_fixed_attlist attlist_;
office_element_ptr_array content_;
};
@ -687,7 +682,7 @@ public:
_CP_OPT(bool) text_fixed_;
_CP_OPT(std::wstring) text_date_value_;//with format
office_element_ptr_array text_;
office_element_ptr_array text_;
private:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
@ -715,8 +710,9 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(text_modification_date);
//-------------------------------------------------------------------------------------------------------------------
// text:time
//////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
class text_time : public paragraph_content_element<text_time>
{
public:
@ -745,8 +741,9 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(text_time);
//-------------------------------------------------------------------------------------------------------------------
// text:modification-date
//////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
class text_modification_time : public text_time
{
public:
@ -762,8 +759,9 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(text_modification_time);
//-------------------------------------------------------------------------------------------------------------------
// text:file-name
//////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
class text_file_name : public paragraph_content_element<text_file_name>
{
public:
@ -787,11 +785,11 @@ private:
office_element_ptr_array text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_file_name);
//-------------------------------------------------------------------------------------------------------------------
// text:sequence
//////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
class sequence : public paragraph_content_element<sequence>
{
public:
@ -815,11 +813,58 @@ private:
office_element_ptr_array text_;
};
CP_REGISTER_OFFICE_ELEMENT2(sequence);
//-------------------------------------------------------------------------------------------------------------------
//text:drop-down
//-------------------------------------------------------------------------------------------------------------------
class text_drop_down : public paragraph_content_element<text_drop_down>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextDropDown;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
_CP_OPT(std::wstring) text_name_;
office_element_ptr_array content_;
std::wstring text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_drop_down);
//-------------------------------------------------------------------------------------------------------------------
//text:drop-down
//-------------------------------------------------------------------------------------------------------------------
class text_label : public paragraph_content_element<text_label>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextLabel;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
_CP_OPT(std::wstring) text_value_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_label);
//-------------------------------------------------------------------------------------------------------------------
// text:sheet-name
//////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
class sheet_name : public paragraph_content_element<sheet_name>
{
public:
@ -837,11 +882,11 @@ private:
office_element_ptr_array text_;
};
CP_REGISTER_OFFICE_ELEMENT2(sheet_name);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
//presentation:footer
//-------------------------------------------------------------------------------------------------------------------
class presentation_footer : public paragraph_content_element<presentation_footer>
{
public:
@ -861,8 +906,9 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_footer);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------------------------------------
//presentation:date-time
//-------------------------------------------------------------------------------------------------------------------
class presentation_date_time: public paragraph_content_element<presentation_date_time>
{
public:

View File

@ -33,7 +33,6 @@
#include "ruby.h"
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/xmlchar.h>

View File

@ -201,18 +201,24 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co
CP_XML_NODE(L"w:keepNext");
CP_XML_NODE(L"w:framePr")
{
CP_XML_ATTR(L"w:dropCap", L"drop");
if (Context.get_drop_cap_context().Scale > 0)
{
CP_XML_ATTR(L"w:lines",Context.get_drop_cap_context().Scale);
}
else
{
CP_XML_ATTR(L"w:hSpace", Context.get_drop_cap_context().Space);
}
CP_XML_ATTR(L"w:wrap", L"around");
CP_XML_ATTR(L"w:hAnchor", L"text");
CP_XML_ATTR(L"w:vAnchor", L"text");
CP_XML_ATTR(L"w:wrap", L"around");
CP_XML_ATTR(L"w:dropCap", L"drop");
CP_XML_ATTR(L"w:hSpace", Context.get_drop_cap_context().Space);
CP_XML_ATTR(L"w:lines",Context.get_drop_cap_context().Scale);
}
CP_XML_NODE(L"w:spacing")
{
CP_XML_ATTR(L"w:after", 0);
if (Context.get_drop_cap_context().FontSize>0)
if (Context.get_drop_cap_context().FontSize > 0)
CP_XML_ATTR(L"w:line", Context.get_drop_cap_context().FontSize);
else
CP_XML_ATTR(L"w:line", 240);

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"

View File

@ -213,7 +213,7 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
double kf_max_width_ms =1.;
const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();//
if (pp)
if ((pp) && (pp->properties()))
{
style_page_layout_properties_attlist & attr_page = pp->properties()->attlist_;
if (attr_page.fo_page_width_)

View File

@ -53,7 +53,7 @@ namespace odf_reader {
void removeCharsFromString( std::wstring &str, std::wstring charsToRemove )
{
for ( unsigned int i = 0; i < charsToRemove.length(); ++i )
for ( size_t i = 0; i < charsToRemove.length(); ++i )
{
str.erase( std::remove(str.begin(), str.end(), charsToRemove[i]), str.end() );
}
@ -292,14 +292,14 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
w_font = font->name();
//'Arial' глючит
removeCharsFromString(w_font, _T("'"));
removeCharsFromString(w_font, L"'");
}
if (w_font.length()>0)
{
CP_XML_NODE(L"a:buFont")
{
removeCharsFromString(w_font, _T("'"));
removeCharsFromString(w_font, L"'");
CP_XML_ATTR(L"typeface", w_font);
if ((style_font_charset_))
{
@ -1236,12 +1236,19 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
{
int fontSize=0;
if (Context.get_drop_cap_context().state()==2)
{
fontSize = process_font_size(fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7);//вместо 1 ДОЛЖНОБЫТЬ коэфф. межстрочного интервала!!!
if (fontSize < 1)
fontSize = Context.get_drop_cap_context().FontSize / 7.52;
}
else
{
fontSize = process_font_size(fo_font_size_, Context.get_styles_context().get_current_processed_style());
}
if (fontSize>0)
if (fontSize > 0)
{
_rPr << L"<w:sz w:val=\"" << fontSize << "\" />";
}

View File

@ -34,7 +34,6 @@
#include "styles.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <cpdoccore/odf/odf_document.h>
@ -734,7 +733,7 @@ void style_columns::add_attributes( const xml::attributes_wc_ptr & Attributes )
void style_columns::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if (L"style" == Ns && L"column" == Name)
CP_CREATE_ELEMENT(style_column_);
CP_CREATE_ELEMENT(style_columns_);
else if (L"style" == Ns && L"column-sep" == Name)
CP_CREATE_ELEMENT(style_column_sep_);
else
@ -750,11 +749,10 @@ const wchar_t * style_column::name = L"column";
void style_column::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"fo:start-indent", fo_start_indent_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:end-indent", fo_end_indent_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:space-before", fo_space_before_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:space-after", fo_space_after_, length(0.0, length::cm));
CP_APPLY_ATTR(L"fo:start-indent", fo_start_indent_);
CP_APPLY_ATTR(L"fo:end-indent", fo_end_indent_);
CP_APPLY_ATTR(L"fo:space-before", fo_space_before_);
CP_APPLY_ATTR(L"fo:space-after", fo_space_after_);
}
void style_column::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -764,7 +762,7 @@ void style_column::add_child_element( xml::sax * Reader, const std::wstring & Ns
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_column_sep::ns = L"style";
const wchar_t * style_column_sep::name = L":column-sep";
const wchar_t * style_column_sep::name = L"column-sep";
void style_column_sep::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
@ -1349,16 +1347,20 @@ void style_page_layout_properties::docx_serialize(std::wostream & strm, oox::doc
{
Context.process_section( CP_XML_STREAM(), columns);
bool next_page = Context.is_next_dump_page_properties();
bool change_page_layout = Context.is_next_dump_page_properties();
CP_XML_NODE(L"w:type")
{
if (next_page) CP_XML_ATTR(L"w:val", L"nextPage");
else CP_XML_ATTR(L"w:val", L"continuous");
if (change_page_layout)
{
CP_XML_ATTR(L"w:val", L"nextPage");
}
else
CP_XML_ATTR(L"w:val", L"continuous");
}
std::wstring masterPageName = Context.get_master_page_name();
bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, change_page_layout, strm);
if (res == false)
{
@ -1369,7 +1371,7 @@ void style_page_layout_properties::docx_serialize(std::wostream & strm, oox::doc
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, change_page_layout, strm);
}
oox::section_context::_section & section = Context.get_section_context().get();

View File

@ -674,9 +674,6 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(style_footer_left);
/// style_columns
/// style-columns
/// style:columns
class style_columns : public office_element_impl<style_columns>
{
public:
@ -695,15 +692,12 @@ public:
_CP_OPT(odf_types::length) fo_column_gap_;
office_element_ptr style_column_sep_;
office_element_ptr_array style_column_;
office_element_ptr_array style_columns_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_columns);
/// style_column
/// style-column
/// style:column
class style_column : public office_element_impl<style_column>
{
public:
@ -719,18 +713,14 @@ private:
public:
_CP_OPT(odf_types::length) style_rel_width_;
odf_types::length fo_start_indent_;
odf_types::length fo_end_indent_;
odf_types::length fo_space_before_;
odf_types::length fo_space_after_;
_CP_OPT(odf_types::length) fo_start_indent_;
_CP_OPT(odf_types::length) fo_end_indent_;
_CP_OPT(odf_types::length) fo_space_before_;
_CP_OPT(odf_types::length) fo_space_after_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_column);
/// style_column_sep
/// style-column-sep
/// style:column-sep
class style_column_sep : public office_element_impl<style_column_sep>
{
public:
@ -751,11 +741,9 @@ public:
odf_types::vertical_align style_vertical_align_; //default top
odf_types::color style_color_; // default #000000
};
CP_REGISTER_OFFICE_ELEMENT2(style_column_sep);
/// style:section-properties
class style_section_properties : public office_element_impl<style_section_properties>
{
public:

View File

@ -35,7 +35,6 @@
#include <boost/make_shared.hpp>
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"
@ -729,7 +728,61 @@ void table_shapes::add_child_element( xml::sax * Reader, const std::wstring & Ns
CP_CREATE_ELEMENT(content_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:content-validations
const wchar_t * table_content_validations::ns = L"table";
const wchar_t * table_content_validations::name = L"content-validations";
void table_content_validations::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:content-validation
const wchar_t * table_content_validation::ns = L"table";
const wchar_t * table_content_validation::name = L"content-validation";
void table_content_validation::add_attributes(xml::attributes_wc_ptr const & Attributes)
{
CP_APPLY_ATTR(L"table:name", table_name_);
CP_APPLY_ATTR(L"table:condition", table_condition_);
CP_APPLY_ATTR(L"table:display-list", table_display_list_);
CP_APPLY_ATTR(L"table:allowempty-cell", table_allowempty_cell_);
CP_APPLY_ATTR(L"table:base-cell-address", table_base_cell_address_);
}
void table_content_validation::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:content-validation
const wchar_t * table_error_message::ns = L"table";
const wchar_t * table_error_message::name = L"error-message";
void table_error_message::add_attributes(xml::attributes_wc_ptr const & Attributes)
{
CP_APPLY_ATTR(L"table:title", table_title_);
CP_APPLY_ATTR(L"table:message-type", table_message_type_);
CP_APPLY_ATTR(L"table:display", table_display_);
}
void table_error_message::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:content-validation
const wchar_t * table_help_message::ns = L"table";
const wchar_t * table_help_message::name = L"help-message";
void table_help_message::add_attributes(xml::attributes_wc_ptr const & Attributes)
{
CP_APPLY_ATTR(L"table:title", table_title_);
CP_APPLY_ATTR(L"table:message-type", table_message_type_);
CP_APPLY_ATTR(L"table:display", table_display_);
}
void table_help_message::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
}
}

View File

@ -653,6 +653,7 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(table_table);
//table:content-shapes
class table_shapes : public office_element_impl<table_shapes>
{
public:
@ -676,5 +677,105 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(table_shapes);
//table:content-validations
class table_content_validations : public office_element_impl<table_content_validations>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableContentValidations;
CPDOCCORE_DEFINE_VISITABLE();
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_content_validations);
//table:content-validation
class table_content_validation : public office_element_impl<table_content_validation>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableContentValidation;
CPDOCCORE_DEFINE_VISITABLE();
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
_CP_OPT(std::wstring) table_name_;
_CP_OPT(odf_types::Bool) table_allowempty_cell_;
_CP_OPT(std::wstring) table_display_list_;
_CP_OPT(std::wstring) table_condition_;
_CP_OPT(std::wstring) table_base_cell_address_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_content_validation);
//table:error-message
class table_error_message : public office_element_impl<table_error_message>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableErrorMassage;
CPDOCCORE_DEFINE_VISITABLE();
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
_CP_OPT(std::wstring) table_title_;
_CP_OPT(odf_types::Bool) table_display_;
_CP_OPT(std::wstring) table_message_type_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_error_message);
//table:help-message
class table_help_message : public office_element_impl<table_help_message>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableHelpMassage;
CPDOCCORE_DEFINE_VISITABLE();
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) ;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
_CP_OPT(std::wstring) table_title_;
_CP_OPT(odf_types::Bool) table_display_;
_CP_OPT(std::wstring) table_message_type_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_help_message);
//table:error-macro
}
}

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"
#include "odfcontext.h"

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "serialize_elements.h"

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/simple_xml_writer.h>
@ -804,11 +803,13 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
is_style_visible = (!cellStyleName.empty() || defaultColumnCellStyle) ? true : false;
if ( content_.elements_.size() > 0 ||
!formula.empty() ||
if ( content_.elements_.size() > 0 || attlist_.table_content_validation_name_ || !formula.empty() ||
( t_val == oox::XlsxCellType::n && !number_val.empty()) ||
( t_val == oox::XlsxCellType::b && bool_val) ||
(( t_val == oox::XlsxCellType::str || oox::XlsxCellType::inlineStr) && str_val)) is_data_visible = true;
(( t_val == oox::XlsxCellType::str || oox::XlsxCellType::inlineStr) && str_val))
{
is_data_visible = true;
}
if (attlist_.table_number_columns_repeated_ < 199 && last_cell_) last_cell_ = false;
@ -838,15 +839,20 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
if (skip_next_cell)break;
// пустые ячейки пропускаем.
// пустые ячейки пропускаем.
if ( is_data_visible || ((cellStyle || defaultColumnCellStyle) && is_style_visible))
{
CP_XML_WRITER(strm)
std::wstring ref = oox::getCellAddress(Context.current_table_column(), Context.current_table_row());
if (attlist_.table_content_validation_name_)
{
Context.get_dataValidations_context().activate(*attlist_.table_content_validation_name_, ref);
}
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"c")
{
CP_XML_ATTR(L"r", oox::getCellAddress(Context.current_table_column(), Context.current_table_row()));
CP_XML_ATTR(L"r", ref);
CP_XML_ATTR(L"t", oox::cellType2Str(t_val));
CP_XML_ATTR(L"s", xfId_last_set);
@ -888,6 +894,7 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
{
CP_XML_NODE(L"v") { CP_XML_CONTENT((int)(bool_val.get())); }
}
}
if ( is_data_visible || (cellStyle && is_style_visible && !last_cell_))
{
@ -1180,5 +1187,38 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
}
}
void table_content_validations::xlsx_convert(oox::xlsx_conversion_context & Context)
{
for (size_t i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
}
void table_content_validation::xlsx_convert(oox::xlsx_conversion_context & Context)
{
std::wstring name = table_name_.get_value_or(L"");
Context.get_dataValidations_context().add(name, table_base_cell_address_.get_value_or(L""));
Context.get_dataValidations_context().add_formula(name, table_condition_.get_value_or(L""));
for (size_t i = 0 ; i < content_.size(); i++)
{
if (content_[i]->get_type() == typeTableErrorMassage)
{
Context.get_dataValidations_context().add_error_msg(name, true);
}
else if (content_[i]->get_type() == typeTableErrorMassage)
{
Context.get_dataValidations_context().add_help_msg(name, true);
}
content_[i]->xlsx_convert(Context);
}
}
void table_error_message::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
void table_help_message::xlsx_convert(oox::xlsx_conversion_context & Context)
{
}
}
}

View File

@ -34,7 +34,7 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/utils.h>
#include "paragraph_elements.h"
#include "serialize_elements.h"
@ -126,8 +126,8 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con
if ((text_properties) && (text_properties->content().fo_font_size_))
{
Context.get_drop_cap_context().FontSize = styleContent->get_style_text_properties()->content().process_font_size(
text_properties->content().fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7));//формула ачуметь !! - подбор вручную
text_properties->content().fo_font_size_, Context.get_styles_context().get_current_processed_style(), false, //1.);
7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7));//формула ачуметь !! - подбор вручную
}
return;
}
@ -185,6 +185,29 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
Context.end_automatic_style();
Context.push_text_properties(styleContent->get_style_text_properties());
if (!Context.get_section_context().dump_.empty()
&& !Context.get_table_context().in_table()
&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
&& !in_drawing)
{
Context.output_stream() << L"<w:pPr>";
if (Context.is_paragraph_header() )
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
Context.output_stream() << L"</w:pPr>";
Context.finish_paragraph();
Context.start_paragraph();
}
else
{
Context.output_stream() << Context.get_section_context().dump_;
Context.get_section_context().dump_.clear();
Context.output_stream() << L"</w:pPr>";
}
}
return 1;
}
}
@ -289,14 +312,29 @@ void paragraph::afterCreate(document_context * Context)
// вызывается сразу после создания объекта
if (Context)
{
// выставляем у предыдущего параграфа указатель на следующий (т.е. на вновь созданный)
if (paragraph * prevPar = Context->get_last_paragraph())
prevPar->set_next(this);
// запоминаем в контексте вновь созданный параграф
Context->set_last_paragraph(this);
Context->level++;
// выставляем у предыдущего параграфа указатель на следующий (т.е. на вновь созданный)
if (Context->level == 1)
{
if (paragraph * prevPar = Context->get_last_paragraph())
{
prevPar->set_next(this);
}
// запоминаем в контексте вновь созданный параграф
Context->set_last_paragraph(this);
}
}
}
void paragraph::afterReadContent(document_context * Context)
{
if (Context)
{
Context->level--;
}
}
const wchar_t * emptyParagraphContent = L"<w:pPr></w:pPr><w:r><w:rPr></w:rPr></w:r>";
const wchar_t * emptyParagraphDrawing = L"<w:p><w:pPr></w:pPr></w:p>";
@ -318,26 +356,37 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
int textStyle = process_paragraph_attr(attrs_, Context);
first_text_paragraph->docx_convert(Context);
int str_start = Context.get_drop_cap_context().Length;
int str_size = store_str.length()-Context.get_drop_cap_context().Length;
size_t str_start = Context.get_drop_cap_context().Length;
size_t str_size = store_str.length() - Context.get_drop_cap_context().Length;
if (str_size < 0) str_size = 0; // это если на буквы в буквице разные стили
if (str_start > store_str.length()) str_start = store_str.length(); // это если на буквы в буквице разные стили
str=store_str.substr(str_start, str_size);
str = store_str.substr(str_start, str_size);
}
void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
size_t paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
{
if ( content_.empty()) return;
if ( content_.empty()) return 0;
size_t index = 0;
while(index < content_.size()) // могут быть track-change, ...
{
if (content_[index]->get_type() == typeTextText ||
content_[index]->get_type() == typeTextSpan)
break;
content_[index++]->docx_convert(Context);
}
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!- todooo сделать возможным множественным span
if ( content_[0]->get_type() == typeTextText)
if ( content_[index]->get_type() == typeTextText)
{
drop_cap_text_docx_convert(content_[0],Context);
drop_cap_text_docx_convert(content_[index], Context);
}
else if (content_[0]->get_type() == typeTextSpan)
else if (content_[index]->get_type() == typeTextSpan)
{
span* first_span_in_paragraph = dynamic_cast<span*>(content_[0].get());
span* first_span_in_paragraph = dynamic_cast<span*>(content_[index].get());
if (Context.get_drop_cap_context().FontSize < 1)
{
style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(first_span_in_paragraph->text_style_name_, style_family::Text,Context.process_headers_footers_);
@ -350,19 +399,20 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
if ((text_properties) && (text_properties->content().fo_font_size_))
{
Context.get_drop_cap_context().FontSize = styleContent->get_style_text_properties()->content().process_font_size(
text_properties->content().fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
text_properties->content().fo_font_size_, Context.get_styles_context().get_current_processed_style(), false, //1);
7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7));
}
}
}
}
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!
if ((first_span_in_paragraph->content_.size()>0) &&
if ((!first_span_in_paragraph->content_.empty()) &&
(first_span_in_paragraph->content_[0]->get_type() == typeTextText))
{
drop_cap_text_docx_convert(first_span_in_paragraph->content_[0],Context);
drop_cap_text_docx_convert(first_span_in_paragraph->content_[0], Context);
}
}
return index;
}
void paragraph::docx_convert(oox::docx_conversion_context & Context)
{
@ -400,27 +450,6 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
std::wostream & _Wostream = Context.output_stream();
if (next_par_)
{
// проверяем не сменит ли следующий параграф свойства страницы.
// если да — устанавливаем контексту флаг на то что необходимо в конце текущего параграфа
// распечатать свойства секции
//проверить ... не она ли основная - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const std::wstring & next_styleName = next_par_->attrs_.text_style_name_;
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
{
Context.next_dump_page_properties(true);
is_empty = false;
}
}
if (next_section_ || next_end_section_)
{
Context.get_section_context().get().is_dump_ = true;
is_empty = false;
}
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName);
if (masterPageName)
@ -435,11 +464,37 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty = false;
}
if (next_par_)
{
// проверяем не сменит ли следующий параграф свойства страницы.
// если да — устанавливаем контексту флаг на то что необходимо в текущем параграфе
// распечатать свойства раздела/секции
//проверить ... не она ли текущая - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const std::wstring & next_styleName = next_par_->attrs_.text_style_name_;
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
{
Context.next_dump_page_properties(true);
is_empty = false;
}
}
if (next_section_/* || next_end_section_*/)
{
Context.get_section_context().get().is_dump_ = true;
is_empty = false;
}
std::wstringstream strm;
if (Context.process_page_properties(strm))
{
Context.get_section_context().dump_ = strm.str();
}
process_paragraph_drop_cap_attr(attrs_, Context);
size_t index = 0;
if (Context.get_drop_cap_context().state() == 2)//active
{
drop_cap_docx_convert(Context);
index = drop_cap_docx_convert(Context);
Context.finish_run();
Context.finish_paragraph();
@ -453,7 +508,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
Context.add_note_reference();
for (size_t i = 0; i < content_.size(); i++)
for (size_t i = index; i < content_.size(); i++)
{
if (Context.get_page_break())
{
@ -495,14 +550,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
if (is_empty)
Context.output_stream() << emptyParagraphContent;
Context.finish_paragraph();
std::wstringstream strm;
if (Context.process_page_properties(strm))
{
Context.get_section_context().dump_ = strm.str();
}
}
void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
@ -571,7 +619,10 @@ void h::afterCreate()
{
paragraph_.afterCreate( getContext() );
}
void h::afterReadContent()
{
paragraph_.afterReadContent( getContext() );
}
void h::docx_convert(oox::docx_conversion_context & Context)
{
paragraph_.docx_convert(Context);
@ -594,7 +645,10 @@ void p::afterCreate()
{
paragraph_.afterCreate( getContext() );
}
void p::afterReadContent()
{
paragraph_.afterReadContent( getContext() );
}
std::wostream & p::text_to_stream(std::wostream & _Wostream) const
{
return paragraph_.text_to_stream(_Wostream);
@ -1391,7 +1445,119 @@ void text_change_end::docx_convert(oox::docx_conversion_context & Context)
{
Context.end_text_changes (*text_change_id_);
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_variable_input::ns = L"text";
const wchar_t * text_variable_input::name = L"variable-input";
void text_variable_input::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"office:value-type", office_value_type_);
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
CP_APPLY_ATTR(L"text:description", text_description_);
CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"text:name", text_name_);
}
void text_variable_input::add_text(const std::wstring & Text)
{
text_ = Text;
}
std::wostream & text_variable_input::text_to_stream(std::wostream & _Wostream) const
{
_Wostream << xml::utils::replace_text_to_xml( text_ );
return _Wostream;
}
void text_variable_input::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & strm = Context.output_stream();
Context.finish_run();
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>";
strm << L"<w:r><w:instrText>ASK &quot;" << text_name_.get_value_or(L"") << L"&quot; " << text_description_.get_value_or(L"") << L" \\d ";
strm << text_;
strm << L"</w:instrText></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>";
strm << L"<w:r><w:instrText>REF &quot;" << text_name_.get_value_or(L"") << L"&quot; </w:instrText></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
strm << L"<w:r><w:t>" << text_ << L"</w:t></w:r>";
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_variable_get::ns = L"text";
const wchar_t * text_variable_get::name = L"variable-get";
void text_variable_get::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"text:name", text_name_);
}
void text_variable_get::docx_convert(oox::docx_conversion_context & Context)
{
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_variable_set::ns = L"text";
const wchar_t * text_variable_set::name = L"variable-set";
void text_variable_set::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"office:value-type", office_value_type_);
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"text:name", text_name_);
CP_APPLY_ATTR(L"office:value", office_value_);
CP_APPLY_ATTR(L"office:boolean-value", office_boolean_value_);
CP_APPLY_ATTR(L"office:date-value", office_date_value_);
CP_APPLY_ATTR(L"office:time-value", office_time_value_);
CP_APPLY_ATTR(L"office:string-value", office_string_value_);
CP_APPLY_ATTR(L"office:currency", office_currency_);
CP_APPLY_ATTR(L"office:formula", office_formula_);
}
void text_variable_set::docx_convert(oox::docx_conversion_context & Context)
{
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_variable_decl::ns = L"text";
const wchar_t * text_variable_decl::name = L"variable-decl";
void text_variable_decl::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"office:value-type", office_value_type_);
CP_APPLY_ATTR(L"text:display", text_display_);
CP_APPLY_ATTR(L"text:name", text_name_);
}
void text_variable_decl::docx_convert(oox::docx_conversion_context & Context)
{
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_variable_decls::ns = L"text";
const wchar_t * text_variable_decls::name = L"variable-decls";
void text_variable_decls::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"variable-decl")
{
CP_CREATE_ELEMENT(content_);
}
else
{
}
}
void text_variable_decls::docx_convert(oox::docx_conversion_context & Context)
{
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
}
}
}
}
}

View File

@ -73,12 +73,13 @@ public:
}
void afterCreate(document_context * ctx);
void afterReadContent(document_context * ctx);
void docx_convert (oox::docx_conversion_context & Context) ;
void xlsx_convert (oox::xlsx_conversion_context & Context) ;
void pptx_convert (oox::pptx_conversion_context & Context) ;
void drop_cap_docx_convert(oox::docx_conversion_context & Context);
size_t drop_cap_docx_convert(oox::docx_conversion_context & Context);
office_element_ptr_array content_;
private:
@ -114,7 +115,9 @@ public:
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual void afterCreate();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void afterReadContent();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
paragraph paragraph_;
@ -151,8 +154,9 @@ public:
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual void afterCreate();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void afterReadContent();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
p(){};
paragraph paragraph_;
@ -245,7 +249,8 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void afterCreate();
virtual void afterCreate();
virtual void afterReadContent();
private:
@ -535,8 +540,6 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(text_index_title);
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
class text_unknown_base_change : public office_element_impl<text_unknown_base_change>
{
@ -717,8 +720,137 @@ public:
virtual void docx_convert(oox::docx_conversion_context & Context);
};
CP_REGISTER_OFFICE_ELEMENT2(text_change_end);
//-------------------------------------------------------------------------------------------------------------------
//text:variable-input
//---------------------------------------------------------------------------------------------------
class text_variable_input : public office_element_impl<text_variable_input>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextVariableInput;
CPDOCCORE_DEFINE_VISITABLE()
void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
_CP_OPT(odf_types::office_value_type) office_value_type_;
_CP_OPT(std::wstring) style_data_style_name_;
_CP_OPT(std::wstring) text_description_;
_CP_OPT(std::wstring) text_display_;
_CP_OPT(std::wstring) text_name_;
std::wstring text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_variable_input);
//-------------------------------------------------------------------------------------------------------------------
//text:variable-get
//---------------------------------------------------------------------------------------------------
class text_variable_get : public office_element_impl<text_variable_get>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextVariableGet;
CPDOCCORE_DEFINE_VISITABLE()
void docx_convert(oox::docx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
_CP_OPT(std::wstring) style_data_style_name_;
_CP_OPT(std::wstring) text_display_;
_CP_OPT(std::wstring) text_name_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_variable_get);
//-------------------------------------------------------------------------------------------------------------------
//text:variable-set
//---------------------------------------------------------------------------------------------------
class text_variable_set : public office_element_impl<text_variable_set>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextVariableSet;
CPDOCCORE_DEFINE_VISITABLE()
void docx_convert(oox::docx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
_CP_OPT(odf_types::office_value_type) office_value_type_;
_CP_OPT(std::wstring) office_boolean_value_;
_CP_OPT(std::wstring) office_date_value_;
_CP_OPT(std::wstring) office_time_value_;
_CP_OPT(std::wstring) office_string_value_;
_CP_OPT(std::wstring) office_value_;
_CP_OPT(std::wstring) office_currency_;
_CP_OPT(std::wstring) office_formula_;
_CP_OPT(std::wstring) style_data_style_name_;
_CP_OPT(std::wstring) text_display_;
_CP_OPT(std::wstring) text_name_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_variable_set);
//---------------------------------------------------------------------------------------------------
//text:variable-decl
//---------------------------------------------------------------------------------------------------
class text_variable_decl : public office_element_impl<text_variable_decl>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextVariableDecl;
CPDOCCORE_DEFINE_VISITABLE()
void docx_convert(oox::docx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
_CP_OPT(odf_types::office_value_type) office_value_type_;
_CP_OPT(std::wstring) text_display_;
_CP_OPT(std::wstring) text_name_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_variable_decl);
//---------------------------------------------------------------------------------------------------
//text:variable-decls
//---------------------------------------------------------------------------------------------------
class text_variable_decls : public office_element_impl<text_variable_decls>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextVariableDecls;
CPDOCCORE_DEFINE_VISITABLE()
void docx_convert(oox::docx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_variable_decls);
}
}
}

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -642,6 +642,14 @@
RelativePath="..\src\docx\xlsx_conditionalFormatting.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_data_validation.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_data_validation.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_defined_names.cpp"
>

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -49,7 +49,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -59,7 +59,7 @@ HRESULT convert_single(std::wstring srcFileName)
switch(fileChecker.nFileType)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"document"; break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"text"; break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: dstPath += L"-my.ods"; type = L"spreadsheet"; break;

View File

@ -22,8 +22,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -151,13 +151,17 @@ namespace odf_writer
CP_XML_ATTR(L"xmlns:smil", L"urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0");
CP_XML_ATTR(L"xmlns:anim", L"urn:oasis:names:tc:opendocument:xmlns:animation:1.0");
CP_XML_ATTR(L"xmlns:chartooo", L"http://openoffice.org/2010/chart");
CP_XML_ATTR(L"office:version", L"1.2");
CP_XML_ATTR(L"office:version", L"1.2");
CP_XML_NODE(L"office:meta")
{
CP_XML_NODE(L"meta:generator")
{
CP_XML_STREAM() << L"ONLYOFFICE Online Editor";
CP_XML_STREAM() << L"ONLYOFFICE";
#if defined(INTVER)
std::string s = VALUE2STR(INTVER);
CP_XML_STREAM() << L"/" << std::wstring (s.begin(), s.end() );
#endif
}
CP_XML_NODE(L"meta:initial-creator");
CP_XML_NODE(L"meta:creation-date");

View File

@ -482,14 +482,12 @@ void odf_page_layout_context::set_page_size(_CP_OPT(length) width, _CP_OPT(lengt
if (width)
{
props->attlist_.fo_page_width_ =
length(width->get_value_unit(length::cm), length::cm);
props->attlist_.fo_page_width_ = length(width->get_value_unit(length::cm), length::cm);
current_page_width_ = width->get_value_unit(length::pt);
}
if (height)
props->attlist_.fo_page_height_ =
length(height->get_value_unit(length::cm),length::cm);
props->attlist_.fo_page_height_ = length(height->get_value_unit(length::cm), length::cm);
}
void odf_page_layout_context::set_page_number_format(_CP_OPT(int) & type, _CP_OPT(int) & start)
{

View File

@ -39,6 +39,7 @@
#include "styles.h"
#include "style_paragraph_properties.h"
#include "style_text_properties.h"
#include <iostream>
@ -62,7 +63,17 @@ void calc_paragraph_properties_content(std::vector<style_paragraph_properties*>
result->apply_from(parProps[i]->content_);
}
}
void calc_text_properties_content(std::vector<style_text_properties*> & textProps, text_format_properties_content * result)
{
if (result == NULL)return;
if (textProps.empty()) return;
for (int i = (int)textProps.size() - 1; i >= 0; i--)
{
if (textProps[i])
result->apply_from(textProps[i]->content_);
}
}
odf_style_context::odf_style_context()
{
//memset(style_family_counts_,0,sizeof(style_family_counts_));
@ -424,12 +435,29 @@ office_element_ptr & odf_style_context::add_or_find(std::wstring name, style_fam
return style_state_list_.back()->get_office_element();
}
void odf_style_context::calc_text_properties(std::wstring style_name, odf_types::style_family::type family, text_format_properties_content * result)
{
std::vector<style_text_properties*> textProps;
while (!style_name.empty())
{
style *style_ = NULL;
if (!find_odf_style(style_name, family, style_) || !style_)break;
if (style_text_properties * textProp = style_->content_.get_style_text_properties())
textProps.push_back(textProp);
style_name = style_->style_parent_style_name_ ? *style_->style_parent_style_name_ : L"";
}
calc_text_properties_content(textProps, result);
}
void odf_style_context::calc_paragraph_properties(std::wstring style_name, style_family::type family, paragraph_format_properties * result)
{
std::vector<style_paragraph_properties*> parProps;
while (style_name.length()>0)
while (!style_name.empty())
{
style *style_ = NULL;
if (!find_odf_style(style_name, family, style_) || !style_)break;

View File

@ -52,6 +52,7 @@ typedef shared_ptr<odf_style_context>::Type odf_style_context_ptr;
class style;
class paragraph_format_properties;
class text_format_properties_content;
class odf_style_context
{
@ -94,7 +95,7 @@ public:
//////////////////////////////////////////////////////////////////////
void calc_paragraph_properties(std::wstring style_name, odf_types::style_family::type family, paragraph_format_properties * result);
void calc_text_properties(std::wstring style_name, odf_types::style_family::type family, text_format_properties_content * result);
//////////////////////////////////////////////////////////////////////
std::wstring find_odf_style_name (int oox_id_style, odf_types::style_family::type family, bool root, bool automatic);//xlsx only
bool find_odf_style_state(int oox_id_style, odf_types::style_family::type family, odf_style_state_ptr & state, bool root, bool automatic);//xlsx only

View File

@ -118,7 +118,7 @@ void odt_conversion_context::start_document()
void odt_conversion_context::end_document()
{
//add sections to root
for (size_t i = 0; i< sections_.size(); i++)
for (size_t i = 0; i < sections_.size(); i++)
{
root_document_->add_child_element(sections_[i].elm);
}
@ -183,7 +183,8 @@ odf_text_context* odt_conversion_context::text_context()
}
void odt_conversion_context::start_text_context()
{
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, odf_conversion_context::styles_context()));
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, /*odf_conversion_context::*/styles_context()));
//объекты с текстом в колонтитулах
if (!new_text_context_)return;
text_context_.push_back(new_text_context_);
@ -199,17 +200,18 @@ void odt_conversion_context::add_text_content(const std::wstring & text)
{
if (drop_cap_state_.enabled)
{
int count = text.size();
int count = text.length();
drop_cap_state_.characters += count;
if (drop_cap_state_.inline_style == false)
style_text_properties * props = text_context()->get_text_properties();
if (props)
{
style_text_properties * props = text_context()->get_text_properties();
if (props)
if (drop_cap_state_.inline_style == false)
{
std::wstring f_name = props->content_.fo_font_family_.get_value_or(L"Arial");
double f_size = props->content_.fo_font_size_.get_value_or(font_size(length(12,length::pt))).get_length().get_value_unit(length::pt);
drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size, applicationFonts_);
double f_size = props->content_.fo_font_size_.get_value_or(font_size(length(12, length::pt))).get_length().get_value_unit(length::pt);
drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size, applicationFonts_);
}
}
}
@ -479,6 +481,14 @@ int odt_conversion_context::get_current_section_columns()
}
void odt_conversion_context::add_section(bool continuous)
{
//--dump first elements to root------------------------------------------------
for (size_t i = 0; i< current_root_elements_.size(); i++)
{
root_document_->add_child_element(current_root_elements_[i].elm);
}
current_root_elements_.clear();
//----------------------------------------------------------------------------
odt_section_state state;
state.empty = true;
@ -497,7 +507,7 @@ void odt_conversion_context::add_section(bool continuous)
}
void odt_conversion_context::add_section_columns(int count, double space_pt, bool separator)
{
if (sections_.size() < 1 || count < 1) return;
if (sections_.empty() || count < 1) return;
style* style_ = dynamic_cast<style*>(sections_.back().style_elm.get());
if (!style_)return;
@ -505,8 +515,10 @@ void odt_conversion_context::add_section_columns(int count, double space_pt, boo
style_section_properties * section_properties = style_->content_.get_style_section_properties();
create_element(L"style", L"columns",section_properties->style_columns_,this);
style_columns* columns = dynamic_cast<style_columns*>(section_properties->style_columns_.get());
if (!columns)return;
sections_.back().count_columns = count;
columns->fo_column_count_ = count;
@ -518,14 +530,14 @@ void odt_conversion_context::add_section_columns(int count, double space_pt, boo
style_column_sep* sep = dynamic_cast<style_column_sep*>(columns->style_column_sep_.get());
if (sep)//default set
{
sep->style_width_ = length(0,length::cm);
sep->style_width_ = length(0.035, length::cm);
sep->style_height_ = percent(100);
sep->style_vertical_align_ = vertical_align(vertical_align::Middle);
sep->style_color_ = color(L"#000000");
}
}
}
void odt_conversion_context::add_section_column(std::vector<std::pair<double,double>> width_space)
void odt_conversion_context::add_section_column(std::vector<std::pair<double, double>> width_space)
{
if (sections_.size() < 1 || width_space.size() < 1) return;
@ -543,16 +555,15 @@ void odt_conversion_context::add_section_column(std::vector<std::pair<double,dou
{
if (width_space[i].first >= 0)
width_all += width_space[i].first/* + width_space[i].second*/;
width_all += width_space[i].first + width_space[i].second;
}
double curr = 0;
int width_absolute = 0;
if (width_all < 1) return;
section_properties->style_editable_ = false;
double last_space = 0;
for (size_t i = 0; i < width_space.size() && width_all > 0 ; i++)
{
office_element_ptr col_elm;
@ -561,18 +572,17 @@ void odt_conversion_context::add_section_column(std::vector<std::pair<double,dou
style_column* col = dynamic_cast<style_column*>(col_elm.get());
if (!col) continue;
int val = (width_space[i].first/* + width_space[i].second*/)* 65535. /width_all /*:65535 - width_absolute*/;
int val = (width_space[i].first)* 65535. / width_all ;
col->style_rel_width_ = odf_types::percent_rel(val);
width_absolute += val;
//col->fo_start_indent_ = odf_types::length(curr,odf_types::length::pt);
//curr += width_space[0].first;
//
//col->fo_end_indent_ = odf_types::length(curr,odf_types::length::pt);
//curr += width_space[0].second;
col->fo_start_indent_ = odf_types::length(last_space / 2, odf_types::length::pt);
col->fo_end_indent_ = odf_types::length(width_space[i].second / 2, odf_types::length::pt);
columns->add_child_element(col_elm);
last_space = width_space[i].second;
}
}
void odt_conversion_context::end_field()
@ -662,9 +672,9 @@ void odt_conversion_context::set_no_list()
}
void odt_conversion_context::flush_section()
{
if (sections_.size() > 0 && sections_.back().empty)
if (!sections_.empty() && sections_.back().empty)
{
for (size_t i=0; i< current_root_elements_.size(); i++)
for (size_t i = 0; i < current_root_elements_.size(); i++)
{
if ((sections_.back().continuous && i < 2) || !sections_.back().continuous)
// при вставлении параграфа возможен искусственный разрыв в параграфах - см add_page_break
@ -697,7 +707,7 @@ void odt_conversion_context::start_run(bool styled)
if (is_hyperlink_ && text_context_.size() > 0) return;
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && !current_field_.in_span)
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && !current_field_.in_span)
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
@ -705,7 +715,14 @@ void odt_conversion_context::start_run(bool styled)
text_context()->start_span(styled);
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
if (drop_cap_state_.enabled)
{
style_text_properties *props = text_context()->get_text_properties();
if (props)
props->apply_from(dynamic_cast<style_text_properties*>(drop_cap_state_.text_properties.get()));
}
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
@ -945,7 +962,14 @@ void odt_conversion_context::end_change (int id, int type)
// return (text_changes_state_.current_types.back() == 2);
//}
//--------------------------------------------------------------------------------------------------------
style_text_properties* odt_conversion_context::get_drop_cap_properties()
{
if (!drop_cap_state_.text_properties)
{
create_element(L"style", L"text-properties", drop_cap_state_.text_properties, this);
}
return dynamic_cast<style_text_properties *>(drop_cap_state_.text_properties.get());
}
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
{
if (drop_cap_state_.enabled)
@ -967,6 +991,8 @@ void odt_conversion_context::set_drop_cap_lines(int lines)
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get());
if (drop_cap)drop_cap->style_lines_ = lines;
drop_cap_state_.lines = lines;
}
void odt_conversion_context::set_drop_cap_margin(bool val)
{
@ -977,7 +1003,7 @@ void odt_conversion_context::end_drop_cap()
{
if (!drop_cap_state_.enabled) return;
if (drop_cap_state_.characters >0 && drop_cap_state_.paragraph_properties)
if (drop_cap_state_.characters > 0 && drop_cap_state_.paragraph_properties)
{
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get());
if (drop_cap)

View File

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

View File

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

View File

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

View File

@ -52,11 +52,15 @@
#include "../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Presentation.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Logic/Vml.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramDrawing.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Diagram/DiagramData.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Shape.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/CxnSp.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/GraphicFrame.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Pic.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/SmartArt.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Sparkline.h"

View File

@ -45,7 +45,10 @@
#include "../OdfFormat/style_paragraph_properties.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
namespace Oox2Odf
{
@ -1092,6 +1095,27 @@ void OoxConverter::convert(OOX::Spreadsheet::CT_DLbls* ser_lbls)
{
bool boolVal = false;
bool bIsFound = false;
switch(*ser_lbls->m_ItemsElementName0[i])
{
case OOX::Spreadsheet::itemschoicetype3DELETE :
case OOX::Spreadsheet::itemschoicetype3SHOWBUBBLESIZE:
case OOX::Spreadsheet::itemschoicetype3SHOWCATNAME:
case OOX::Spreadsheet::itemschoicetype3SHOWLEADERLINES:
case OOX::Spreadsheet::itemschoicetype3SHOWLEGENDKEY:
case OOX::Spreadsheet::itemschoicetype3SHOWPERCENT:
case OOX::Spreadsheet::itemschoicetype3SHOWSERNAME:
case OOX::Spreadsheet::itemschoicetype3SHOWVAL:
bIsFound = true;
break;
default:
break;
}
if (!bIsFound)
continue;
OOX::Spreadsheet::CT_Boolean * ct_boolean = (OOX::Spreadsheet::CT_Boolean*)ser_lbls->m_Items[i];
if (ct_boolean && ct_boolean->m_val) boolVal = * ct_boolean->m_val;

View File

@ -33,6 +33,18 @@
#include "../utils.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Numbering.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Comments.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Styles.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Footnote.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Endnote.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Settings/WebSettings.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Settings/Settings.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/HeaderFooter.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Logic/Pict.h"
@ -56,8 +68,41 @@
using namespace cpdoccore;
std::vector<double> current_font_size;
namespace Oox2Odf
{
bool compare (OOX::Logic::CSectionProperty* props1, OOX::Logic::CSectionProperty* props2)
{
size_t cols_1 = 1, cols_2 = 1;
if (props1 && props1->m_oCols.IsInit())
{
cols_1 = props1->m_oCols->m_oNum.IsInit() ? props1->m_oCols->m_oNum->GetValue() : 1;
if (!props1->m_oCols->m_arrColumns.empty())
cols_1 = (std::min)(cols_1, props1->m_oCols->m_arrColumns.size());
}
if (props2)
{
if (props2->m_oCols.IsInit())
{
cols_2 = props2->m_oCols->m_oNum.IsInit() ? props2->m_oCols->m_oNum->GetValue() : 1;
if (!props2->m_oCols->m_arrColumns.empty())
cols_2 = (std::min)(cols_2, props2->m_oCols->m_arrColumns.size());
}
else
{
if (props2->m_oType.IsInit() && props2->m_oType->m_oVal.IsInit())
{
if (props2->m_oType->m_oVal->GetValue() == SimpleTypes::sectionmarkContinious)
cols_2 = cols_1;
}
}
}
return cols_1 == cols_2;
}
DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{
const OOX::CPath oox_path(std::wstring(path.c_str()));
@ -96,7 +141,7 @@ odf_writer::odf_conversion_context* DocxConverter::odf_context()
PPTX::Theme* DocxConverter::oox_theme()
{
if (docx_document)
return docx_document->GetTheme();
return docx_document->m_pTheme;
else
return NULL;
}
@ -106,22 +151,17 @@ OOX::IFileContainer* DocxConverter::current_document()
return oox_current_child_document;
else
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
return dynamic_cast<OOX::IFileContainer*>(oox_doc);
return dynamic_cast<OOX::IFileContainer*>(docx_document->m_pDocument);
}
}
NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
smart_ptr<OOX::File> oFile;
if (oox_doc)
{
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else
oFile = oox_doc->Find(sId);
}
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else if (docx_document->m_pDocument)
oFile = docx_document->m_pDocument->Find(sId);
return oFile;
}
@ -140,10 +180,9 @@ std::wstring DocxConverter::find_link_by_id (std::wstring sId, int type)
}
if (!ref.empty()) return ref;
OOX::CDocument *oox_doc = docx_document->GetDocument();
if (oox_doc == NULL) return L"";
if (docx_document->m_pDocument == NULL) return L"";
oFile = oox_doc->Find(sId);
oFile = docx_document->m_pDocument->Find(sId);
ref = OoxConverter::find_link_by(oFile, type);
return ref;
@ -176,21 +215,22 @@ void DocxConverter::convertDocument()
void DocxConverter::convert_document()
{
const OOX::CDocument* document = docx_document->GetDocument();
if (!document)return;
if (!docx_document->m_pDocument)return;
std::vector<_section> sections;
//----------------------------------------------------------------------------------------------------------
std::vector<OOX::WritingElement*>::const_iterator last_section_start = document->m_arrItems.begin();
//считаем количесво секций и запоминаем их свойства ..
for (std::vector<OOX::WritingElement*>::const_iterator it = document->m_arrItems.begin(); it != document->m_arrItems.end(); ++it)
{
if ((*it) == NULL) continue;
size_t last_section_start = 0;
if ((*it)->getType() == OOX::et_w_p)
OOX::Logic::CSectionProperty* prev = NULL;
for (size_t i = 0; i < docx_document->m_pDocument->m_arrItems.size(); ++i)
{
if ((docx_document->m_pDocument->m_arrItems[i]) == NULL) continue;
if (docx_document->m_pDocument->m_arrItems[i]->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(*it);
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(docx_document->m_pDocument->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
{
@ -200,33 +240,39 @@ void DocxConverter::convert_document()
section.props = para->m_oParagraphProperty->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = it; section.end_para++;
section.end_para = i + 1;
section.bContinue = compare (prev, section.props);
sections.push_back(section);
last_section_start = it; last_section_start++;
last_section_start = i + 1;
prev = section.props;
}
}
}
}
_section section;
section.props = document->m_oSectPr.GetPointer();
section.props = docx_document->m_pDocument->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = document->m_arrItems.end();
section.end_para = docx_document->m_pDocument->m_arrItems.size();
section.bContinue = compare (prev, section.props);
sections.push_back(section);
//----------------------------------------------------------------------------------------------------------
convert(docx_document->m_pDocument->m_oSectPr.GetPointer(), false, L"Standard");
odt_context->text_context()->clear_params();
for (size_t sect = 0; sect < sections.size(); sect++)
{
current_section_properties = &sections[sect];
for (std::vector<OOX::WritingElement*>::const_iterator it = sections[sect].start_para; it != sections[sect].end_para; ++it)
for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
{
convert(*it);
convert(docx_document->m_pDocument->m_arrItems[i]);
}
}
}
@ -382,7 +428,7 @@ void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
{
if (oox_paragraph == NULL) return;
//---------------------------------------------------------------------------------------------------------------------
if (current_section_properties)
{
@ -391,6 +437,8 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
odt_context->text_context()->set_KeepNextParagraph(false);
}
//---------------------------------------------------------------------------------------------------------------------
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
bool bStyled = false;
bool bStartNewParagraph = !odt_context->text_context()->get_KeepNextParagraph();
@ -479,20 +527,29 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if (odt_context->text_context()->get_KeepNextParagraph())
{
odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
if (state)
{
paragraph_properties = state->get_paragraph_properties();
paragraph_properties = state->get_paragraph_properties();
if (bRunPara)
text_properties = state->get_text_properties();
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit())
if (bRunPara)
text_properties = state->get_text_properties();
if (odt_context->in_drop_cap()) //после буквицы (Nadpis.docx) - нужно накатить свойства параграфа нормального
{
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами
paragraph_properties->content_.clear();
if (text_properties)
text_properties->content_.clear();
//очистить все кроме drop_cap
paragraph_properties->content_.clear(false);
}
else
{
// ????
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit())
{
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами
paragraph_properties->content_.clear(true);
if (text_properties)
text_properties->content_.clear();
}
}
}
}
@ -510,10 +567,33 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
odt_context->styles_context()->last_state()->set_list_style_name(list_style_name);
}
}
if (odt_context->in_drop_cap())
{
odt_context->end_drop_cap();
}
convert(oox_paragraph->m_oParagraphProperty, paragraph_properties);
if (text_properties && oox_paragraph->m_oParagraphProperty)
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
{
if (odt_context->in_drop_cap())
{
//вообще то свойства правильные параграфа идут в следующем после буквицы параграфе
odf_writer::style_text_properties *text_properties_drop_cap = odt_context->get_drop_cap_properties();
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties_drop_cap);
if (text_properties_drop_cap->content_.fo_font_size_)
{
double sz = text_properties_drop_cap->content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
sz = sz / 1.75 / odt_context->get_drop_cap_lines();
text_properties_drop_cap->content_.fo_font_size_= odf_types::length(sz, odf_types::length::pt);
}
}
else
{
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
}
}
}
else
{
@ -572,8 +652,6 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
}
//---------------------------------------------------------------------------------------------------------------------
if (odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_drop_cap();
if (!odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_paragraph();
if(list_present && !odt_context->text_context()->get_KeepNextParagraph())
@ -1055,7 +1133,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
{
if (current_section_properties)
{
convert(current_section_properties->props, current_section_properties->root);
convert(current_section_properties->props, !current_section_properties->bContinue);
}
return;
}
@ -1076,6 +1154,14 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
outline_level = *parent_paragraph_properties.content_.outline_level_;
}
//список тож явно ??? угу :( - выше + велосипед для хранения
odf_writer::style_text_properties parent_text_properties;
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Paragraph, &parent_text_properties.content_);
if (parent_text_properties.content_.fo_font_size_)
{
current_font_size.push_back(parent_text_properties.content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));
}
}
if (oox_paragraph_pr->m_oSpacing.IsInit())
@ -1232,7 +1318,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
{
paragraph_properties->content_.style_page_number_ = current_section_properties->props->m_oPgNumType->m_oStart->GetValue();
}
convert(current_section_properties->props, current_section_properties->root);
convert(current_section_properties->props, !current_section_properties->bContinue);
//odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
//if (odt_context->is_paragraph_in_current_section_ && state)
@ -1328,7 +1414,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi
}
}
}
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root)
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection, const std::wstring & master_name)
{
if (oox_section_pr == NULL) return;
current_section_properties = NULL;
@ -1353,18 +1439,24 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!last_section_properties && (root || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
{
last_section_properties = oox_section_pr;
}
else if (root || continuous == false)
bool bDefault = (master_name == L"Standard");
if (!bDefault)
{
apply_HF_from(last_section_properties, oox_section_pr);
if (!last_section_properties && (!bSection || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
{
last_section_properties = oox_section_pr;
}
else if (!bSection || continuous == false)
{
apply_HF_from(last_section_properties, oox_section_pr);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (root || continuous == false)
if (!bSection || continuous == false)
{
odt_context->page_layout_context()->add_master_page(root ? L"Standard" : L"");
odt_context->page_layout_context()->add_master_page(master_name);
}
bool present_header = false;
@ -1481,7 +1573,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<SimpleTypes::CDecimalNumber<> > m_oCode;
}
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 1);//подложка - вот в таком она месте :(, причём одна на все разделы, не как в оо
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 1);//подложка - вот в таком она месте :(, причём одна на все разделы, не как в оо
//nullable<ComplexTypes::Word::CTextDirection > m_oTextDirection;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oRtlGutter;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
@ -1499,9 +1591,9 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle;
}
if (continuous == false || root || oox_section_pr->m_oTitlePg.IsInit())
if (continuous == false || oox_section_pr->m_oTitlePg.IsInit())
{
OOX::Logic::CSectionProperty* s = last_section_properties;
OOX::Logic::CSectionProperty* s = last_section_properties ? last_section_properties : oox_section_pr;
bool present_title_page = s->m_oTitlePg.IsInit() ? true : false;
bool present_odd_even_pages = odt_context->page_layout_context()->even_and_left_headers_;
@ -1530,7 +1622,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (s->m_arrHeaderReference[i]->m_oId.IsInit())
{
convert_hdr_ftr(s->m_arrHeaderReference[i]->m_oId->GetValue());
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 2);
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 2);
}
odt_context->end_header_footer();
@ -1558,7 +1650,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (s->m_arrFooterReference[i]->m_oId.IsInit())
{
convert_hdr_ftr(s->m_arrFooterReference[i]->m_oId->GetValue());
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 3);
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 3);
}
odt_context->end_header_footer();
@ -1568,7 +1660,8 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
if (!add_odd_even_pages_footer && present_odd_even_pages) odt_context->add_empty_footer(1);
if (!add_default_footer && (present_odd_even_pages || present_title_page)) odt_context->add_empty_footer(0);
odt_context->is_paragraph_in_current_section_ = true;
if (!bDefault)
odt_context->is_paragraph_in_current_section_ = true;
//odt_context->set_master_page_name(odt_context->page_layout_context()->last_master() ?
// odt_context->page_layout_context()->last_master()->get_name() : L"");
@ -1590,37 +1683,34 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<ComplexTypes::Word::CRel > m_oPrinterSettings;
//nullable<OOX::Logic::CSectPrChange > m_oSectPrChange;
//--------------------------------------------------------------------------------------------------------------------------------------------
int num_columns = 1;
if (oox_section_pr->m_oCols.IsInit())
if (bSection)
{
num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1;
odt_context->add_section(continuous);
}
if (bSection && oox_section_pr->m_oCols.IsInit())
{
int num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1;
if (num_columns > 1 && oox_section_pr->m_oCols->m_arrColumns.size() > 0)
num_columns = /*(std::max)*/( /*num_columns,*/ (int)oox_section_pr->m_oCols->m_arrColumns.size()) ;
}
if (/*num_columns != odt_context->get_current_section_columns() || */num_columns >= 1) //колонки
{
if (!root || num_columns > 1)
odt_context->add_section(continuous);
double default_space_pt = -1;
if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints();
if (oox_section_pr->m_oCols.IsInit())
{
double default_space_pt = -1;
if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints();
bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
if (num_columns > 1) //
{
std::vector<std::pair<double,double>> width_space;
for (size_t i =0; i< oox_section_pr->m_oCols->m_arrColumns.size(); i++)
for (size_t i = 0; i < oox_section_pr->m_oCols->m_arrColumns.size(); i++)
{
if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue;
double space = default_space_pt;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit())
space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints();
@ -1631,10 +1721,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
width_space.push_back(std::pair<double,double>(w, space));
}
//for (size_t i= oox_section_pr->m_oCols->m_arrColumns.size(); i< num_columns; i ++)
//{
// width_space.push_back(std::pair<double,double>(-1, default_space_pt));
//}
odt_context->add_section_column(width_space);
}
}
@ -2032,7 +2119,16 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
if (oox_run_pr->m_oRStyle.IsInit() && oox_run_pr->m_oRStyle->m_sVal.IsInit())
{
odt_context->styles_context()->last_state()->set_parent_style_name(*oox_run_pr->m_oRStyle->m_sVal);
std::wstring style_name = *oox_run_pr->m_oRStyle->m_sVal;
odt_context->styles_context()->last_state()->set_parent_style_name(style_name);
odf_writer::style_text_properties parent_text_properties;
odt_context->styles_context()->calc_text_properties(style_name, odf_types::style_family::Text, &parent_text_properties.content_);
if (parent_text_properties.content_.fo_font_size_)
{
current_font_size.push_back(parent_text_properties.content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));
}
}
if (oox_run_pr->m_oBold.IsInit())
{
@ -2132,7 +2228,10 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
}
if (oox_run_pr->m_oSz.IsInit() && oox_run_pr->m_oSz->m_oVal.IsInit())
{
OoxConverter::convert(oox_run_pr->m_oSz->m_oVal->ToPoints(), text_properties->content_.fo_font_size_);
double font_size_pt = oox_run_pr->m_oSz->m_oVal->ToPoints();
current_font_size.push_back(font_size_pt);
OoxConverter::convert(font_size_pt, text_properties->content_.fo_font_size_);
}
if (oox_run_pr->m_oKern.IsInit() && oox_run_pr->m_oKern->m_oVal.IsInit())
{
@ -2183,7 +2282,22 @@ void DocxConverter::convert(OOX::Logic::CRunProperty *oox_run_pr, odf_writer::st
{
text_properties->content_.style_text_line_through_type_ = odf_types::line_type(odf_types::line_type::Single);
}
if (oox_run_pr->m_oDStrike.IsInit() && oox_run_pr->m_oDStrike->m_oVal.ToBool())
{
text_properties->content_.style_text_line_through_type_ = odf_types::line_type(odf_types::line_type::Double);
}
if (oox_run_pr->m_oSpacing.IsInit() && oox_run_pr->m_oSpacing->m_oVal.IsInit())
{
double spacing = oox_run_pr->m_oSpacing->m_oVal->ToPoints();
text_properties->content_.fo_letter_spacing_ = odf_types::letter_spacing(odf_types::length(spacing, odf_types::length::pt));
}
if (oox_run_pr->m_oPosition.IsInit() && oox_run_pr->m_oPosition->m_oVal.IsInit())
{
double position_pt = oox_run_pr->m_oPosition->m_oVal->ToPoints();
double percent = current_font_size.empty() ? 0 : position_pt / current_font_size.back() * 100;
text_properties->content_.style_text_position_ = odf_types::text_position(percent, 100.);
}
if (oox_run_pr->m_oBdr.IsInit())
{
std::wstring odf_border;
@ -2226,8 +2340,7 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
if (oox_font_theme == NULL) return;
PPTX::Theme * docx_theme= docx_document->GetTheme();
if (docx_theme == NULL) return;
if (docx_document->m_pTheme == NULL) return;
std::wstring font;
@ -2235,23 +2348,23 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
case SimpleTypes::themeMajorAscii:
case SimpleTypes::themeMajorHAnsi :
font = docx_theme->themeElements.fontScheme.majorFont.latin.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.latin.typeface;
break;
case SimpleTypes::themeMajorBidi:
font = docx_theme->themeElements.fontScheme.majorFont.cs.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.cs.typeface;
break;
case SimpleTypes::themeMajorEastAsia:
font = docx_theme->themeElements.fontScheme.majorFont.ea.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.ea.typeface;
break;
case SimpleTypes::themeMinorAscii:
case SimpleTypes::themeMinorHAnsi:
font = docx_theme->themeElements.fontScheme.minorFont.latin.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.latin.typeface;
break;
case SimpleTypes::themeMinorBidi:
font = docx_theme->themeElements.fontScheme.minorFont.cs.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.cs.typeface;
break;
case SimpleTypes::themeMinorEastAsia:
font = docx_theme->themeElements.fontScheme.minorFont.ea.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.ea.typeface;
break;
}
if (!font.empty()) odf_font_name = font;
@ -2651,6 +2764,9 @@ void DocxConverter::convert(OOX::Drawing::CAnchor *oox_anchor)
else if (oox_anchor->m_oWrapTight.IsInit())
{
odt_context->drawing_context()->set_wrap_style(odf_types::style_wrap::Parallel);
if (oox_anchor->m_oWrapTight->m_oWrapPolygon.IsInit())
{
}
wrap_set = true;
}
else if (oox_anchor->m_oWrapTopAndBottom.IsInit())
@ -2755,11 +2871,9 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
}
if(theme_color && result == false)
{
PPTX::Theme * docx_theme= docx_document->GetTheme();
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_theme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_document->m_pTheme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
if (pFind != docx_theme->themeElements.clrScheme.Scheme.end())
if (pFind != docx_document->m_pTheme->themeElements.clrScheme.Scheme.end())
{
PPTX::Logic::UniColor & color = pFind->second;
@ -2778,38 +2892,36 @@ void DocxConverter::convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf_types
PPTX::Logic::ClrMap* DocxConverter::oox_clrMap()
{
//return current_clrMap; todoooo
OOX::CSettings * docx_settings = docx_document->GetSettings();
if (!docx_settings) return NULL;
if (!docx_document->m_pSettings) return NULL;
return docx_settings->m_oClrSchemeMapping.GetPointer();
return docx_document->m_pSettings->m_oClrSchemeMapping.GetPointer();
}
void DocxConverter::convert_settings()
{
if (!odt_context) return;
OOX::CSettings * docx_settings = docx_document->GetSettings();
if (!docx_settings) return;
if (!docx_document->m_pSettings) return;
if (docx_settings->m_oZoom.IsInit())
if (docx_document->m_pSettings->m_oZoom.IsInit())
{
}
if (docx_settings->m_oMirrorMargins.IsInit())
if (docx_document->m_pSettings->m_oMirrorMargins.IsInit())
{
odt_context->page_layout_context()->set_pages_mirrored(true);
}
odt_context->page_layout_context()->even_and_left_headers_ = docx_settings->m_oEvenAndOddHeaders.IsInit();
odt_context->page_layout_context()->even_and_left_headers_ = docx_document->m_pSettings->m_oEvenAndOddHeaders.IsInit();
if (docx_settings->m_oPrintTwoOnOne.IsInit())
if (docx_document->m_pSettings->m_oPrintTwoOnOne.IsInit())
{
if (docx_settings->m_oGutterAtTop.IsInit()){} //portrait
if (docx_document->m_pSettings->m_oGutterAtTop.IsInit()){} //portrait
else {}//landscape
}
if (docx_settings->m_oDefaultTabStop.IsInit())
if (docx_document->m_pSettings->m_oDefaultTabStop.IsInit())
{
_CP_OPT(odf_types::length) length;
convert(docx_settings->m_oDefaultTabStop->m_oVal.GetPointer(), length);
convert(docx_document->m_pSettings->m_oDefaultTabStop->m_oVal.GetPointer(), length);
odf_writer::odf_style_state_ptr state;
if (odt_context->styles_context()->find_odf_default_style_state(odf_types::style_family::Paragraph, state) && state)
@ -2829,7 +2941,7 @@ void DocxConverter::convert_lists_styles()
{
if (!odt_context) return;
OOX::CNumbering * lists_styles = docx_document->GetNumbering();
OOX::CNumbering * lists_styles = docx_document->m_pNumbering;
if (!lists_styles)return;
@ -2867,22 +2979,25 @@ void DocxConverter::convert_lists_styles()
void DocxConverter::convert_styles()
{
if (!odt_context) return;
OOX::CStyles * docx_styles = docx_document->GetStyles();
if (!docx_styles)return;
if (!docx_document->m_pStyles)return;
//nullable<OOX::CLatentStyles > m_oLatentStyles;
convert(docx_styles->m_oDocDefaults.GetPointer());
convert(docx_document->m_pStyles->m_oDocDefaults.GetPointer());
for (size_t i=0; i< docx_styles->m_arrStyle.size(); i++)
for (size_t i=0; i< docx_document->m_pStyles->m_arrStyle.size(); i++)
{
if (docx_styles->m_arrStyle[i] == NULL) continue;
if (docx_document->m_pStyles->m_arrStyle[i] == NULL) continue;
if (!current_font_size.empty())
{
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
}
convert(docx_styles->m_arrStyle[i]);
convert(docx_document->m_pStyles->m_arrStyle[i]);
if (i == 0 && docx_styles->m_arrStyle[i]->m_oDefault.IsInit() && docx_styles->m_arrStyle[i]->m_oDefault->ToBool())
if (i == 0 && docx_document->m_pStyles->m_arrStyle[i]->m_oDefault.IsInit() && docx_document->m_pStyles->m_arrStyle[i]->m_oDefault->ToBool())
{
//NADIE_COMO_TU.docx тут дефолтовый стиль не прописан явно, берем тот что Normal
odf_writer::odf_style_state_ptr def_style_state;
@ -2900,6 +3015,11 @@ void DocxConverter::convert_styles()
def_para_properties->apply_from(para_properties);
def_text_properties->apply_from(text_properties);
if (def_text_properties->content_.fo_font_size_)
{
current_font_size.push_back(def_text_properties->content_.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));
}
}
}
}
@ -3163,7 +3283,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
if (oox_num_lvl->m_oLvlPicBulletId.IsInit() && oox_num_lvl->m_oLvlPicBulletId->m_oVal.IsInit())
{
int id = oox_num_lvl->m_oLvlPicBulletId->m_oVal->GetValue();
OOX::CNumbering * lists_styles = docx_document->GetNumbering();
OOX::CNumbering * lists_styles = docx_document->m_pNumbering;
for (size_t i = 0; (lists_styles) && (i < lists_styles->m_arrNumPicBullet.size()); i++)
{
@ -3460,12 +3580,11 @@ void DocxConverter::convert(OOX::Logic::CEndnoteReference* oox_ref)
}
void DocxConverter::convert_comment(int oox_comm_id)
{
OOX::CComments * docx_comments = docx_document->GetComments();
if (!docx_comments)return;
if (!docx_document->m_pComments)return;
for (size_t comm = 0 ; comm < docx_comments->m_arrComments.size(); comm++)
for (size_t comm = 0 ; comm < docx_document->m_pComments->m_arrComments.size(); comm++)
{
OOX::CComment* oox_comment = docx_comments->m_arrComments[comm];
OOX::CComment* oox_comment = docx_document->m_pComments->m_arrComments[comm];
if (oox_comment == NULL) continue;
if (oox_comment->m_oId.IsInit() == false) continue;
@ -3489,14 +3608,13 @@ void DocxConverter::convert_comment(int oox_comm_id)
}
void DocxConverter::convert_footnote(int oox_ref_id)
{
OOX::CFootnotes * footnotes = docx_document->GetFootnotes();
if (!footnotes)return;
if (!docx_document->m_pFootnotes)return;
odt_context->start_note(oox_ref_id, 1);
for (size_t n = 0 ; n < footnotes->m_arrFootnote.size(); n++)
for (size_t n = 0 ; n < docx_document->m_pFootnotes->m_arrFootnote.size(); n++)
{
OOX::CFtnEdn* oox_note = footnotes->m_arrFootnote[n];
OOX::CFtnEdn* oox_note = docx_document->m_pFootnotes->m_arrFootnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;
@ -3517,14 +3635,13 @@ void DocxConverter::convert_footnote(int oox_ref_id)
}
void DocxConverter::convert_endnote(int oox_ref_id)
{
OOX::CEndnotes * endnotes = docx_document->GetEndnotes();
if (!endnotes)return;
if (!docx_document->m_pEndnotes)return;
odt_context->start_note(oox_ref_id, 2);
for (size_t n = 0 ; n < endnotes->m_arrEndnote.size(); n++)
for (size_t n = 0 ; n < docx_document->m_pEndnotes->m_arrEndnote.size(); n++)
{
OOX::CFtnEdn* oox_note = endnotes->m_arrEndnote[n];
OOX::CFtnEdn* oox_note = docx_document->m_pEndnotes->m_arrEndnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;
@ -3612,7 +3729,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
if (in_frame)
{
if (current_section_properties)
convert(current_section_properties->props, current_section_properties->root);
convert(current_section_properties->props, !current_section_properties->bContinue);
odt_context->start_paragraph();

View File

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

View File

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

View File

@ -45,12 +45,12 @@ namespace OOX
}
namespace PPTX
{
class Document;
class TableStyles;
class NotesSlide;
class NotesMaster;
class Presentation;
class Comments;
class Folder;
namespace Logic
{
@ -161,7 +161,7 @@ private:
void convert(PPTX::Logic::SplitTransition *oox_transition);
void convert(PPTX::Logic::ZoomTransition *oox_transition);
PPTX::Folder *pptx_document;
PPTX::Document *pptx_document;
PPTX::Presentation *presentation;
cpdoccore::odf_writer::package::odf_document *output_document;

View File

@ -31,6 +31,17 @@
*/
#include "XlsxConverter.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Comments/Comments.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/CalcChain/CalcChain.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinks.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinkPath.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotTable.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheDefinition.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Pivot/PivotCacheRecords.h"
#include "../OdfFormat/ods_conversion_context.h"
@ -89,7 +100,7 @@ odf_writer::odf_conversion_context* XlsxConverter::odf_context()
PPTX::Theme* XlsxConverter::oox_theme()
{
if (xlsx_document)
return xlsx_document->GetTheme();
return xlsx_document->m_pTheme.operator->();
else
return NULL;
}
@ -159,10 +170,10 @@ void XlsxConverter::convert_sheets()
{
if (!ods_context) return;
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->GetWorkbook();
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->m_pWorkbook;
if (!Workbook) return;
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*> &arrWorksheets = xlsx_document->GetWorksheets();
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*> &mapWorksheets = xlsx_document->m_mapWorksheets;
if(Workbook->m_oBookViews.IsInit())
{
@ -180,9 +191,9 @@ void XlsxConverter::convert_sheets()
if(pSheet->m_oRid.IsInit())
{
std::wstring sSheetRId = pSheet->m_oRid.get2().ToString();
boost::unordered_map<std::wstring, OOX::Spreadsheet::CWorksheet*>::iterator pItWorksheet = arrWorksheets.find(sSheetRId);
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::iterator pFind = mapWorksheets.find(sSheetRId);
if (pItWorksheet->second)
if (pFind != mapWorksheets.end())
{
ods_context->start_sheet();
ods_context->current_table().set_table_name(pSheet->m_oName.get2());
@ -190,7 +201,7 @@ void XlsxConverter::convert_sheets()
pSheet->m_oState->GetValue() == SimpleTypes::Spreadsheet::visibleVeryHidden))
ods_context->current_table().set_table_hidden(true);
convert(pItWorksheet->second);
convert(pFind->second);
ods_context->end_sheet();
}
}
@ -444,10 +455,11 @@ void XlsxConverter::convert(OOX::Spreadsheet::CHyperlink *oox_hyperlink,OOX::Spr
std::wstring ref = oox_hyperlink->m_oRef.IsInit() ? oox_hyperlink->m_oRef.get() : L"";
std::wstring link;
if (oox_hyperlink->m_oRid.IsInit() && oox_sheet->GetCurRls())
if (oox_hyperlink->m_oRid.IsInit() && oox_sheet->m_pCurRels.IsInit())
{
OOX::Rels::CRelationShip* oRels = NULL;
oox_sheet->GetCurRls()->GetRel( OOX::RId(oox_hyperlink->m_oRid->GetValue()), &oRels);
oox_sheet->m_pCurRels->GetRel( OOX::RId(oox_hyperlink->m_oRid->GetValue()), &oRels);
if(NULL != oRels && _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") == oRels->Type() )
{
if(oRels->IsExternal())
@ -567,7 +579,7 @@ void XlsxConverter::convert_sharing_string(int number)
{
if (!ods_context) return;
const OOX::Spreadsheet::CSharedStrings *SharedStrings= xlsx_document->GetSharedStrings();
const OOX::Spreadsheet::CSharedStrings *SharedStrings= xlsx_document->m_pSharedStrings;
if (!SharedStrings) return;
if (number >=0 && number < SharedStrings->m_arrItems.size())
@ -877,7 +889,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CSheetPr *oox_sheet_pr)
void XlsxConverter::convert(OOX::Spreadsheet::CWorkbookView *oox_book_views)
{
if (!oox_book_views)return;
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->GetWorkbook();
const OOX::Spreadsheet::CWorkbook *Workbook= xlsx_document->m_pWorkbook;
if (!Workbook) return;
ods_context->settings_context()->start_view();
@ -1208,7 +1220,7 @@ void XlsxConverter::convert_styles()
ods_context->styles_context()->create_default_style(odf_types::style_family::TableCell);
///////////////////////////////////////////////////////////////////////////////////////////////////
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->m_pStyles;
if (!xlsx_styles)return;
//todooo ?? стоит ли обращать на параметр Count ??
@ -1632,7 +1644,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CColor *color, _CP_OPT(odf_types::
}
if(color->m_oIndexed.IsInit())
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->m_pStyles;
int ind = color->m_oIndexed->GetValue();
@ -1755,7 +1767,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CDxf *dxFmt, int oox_dx_id)
}
void XlsxConverter::convert(OOX::Spreadsheet::CXfs * xfc_style, int oox_id, bool automatic, bool root)
{
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->GetStyles();
OOX::Spreadsheet::CStyles * xlsx_styles = xlsx_document->m_pStyles;
int id_parent = xfc_style->m_oXfId.IsInit() ? xfc_style->m_oXfId->GetValue() : -1;
int fill_id = xfc_style->m_oFillId.IsInit() ? xfc_style->m_oFillId->GetValue() : -1;

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4996"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -23,8 +23,6 @@ DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
USE_LITE_READER \
_USE_XMLLITE_READER_ \
_PRESENTATION_WRITER_ \
_SVG_CONVERT_TO_IMAGE_ \
DONT_WRITE_EMBEDDED_FONTS

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