mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-02 16:41:48 +08:00
Compare commits
126 Commits
core-win-6
...
core-win-3
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a9abce180 | |||
| a78711a19c | |||
| 04e4f1adae | |||
| b69051a5b4 | |||
| 6e15370af2 | |||
| 57465b60bf | |||
| 24d58fe189 | |||
| 56bb39f716 | |||
| 60bcca0090 | |||
| 92ce863bdf | |||
| 48d4b72d4b | |||
| 85de7ec7a6 | |||
| 9e6d4950c2 | |||
| cb4befa078 | |||
| ac1292a17a | |||
| 007a984c36 | |||
| d3d3180402 | |||
| fa9c096f3c | |||
| e1ec9d942e | |||
| 4acaa75b06 | |||
| 431115ef48 | |||
| 2d66d9902e | |||
| 206dd12a47 | |||
| e8d3059fe8 | |||
| f624f731de | |||
| ed373b7e2d | |||
| a67eb5644d | |||
| 5040220d82 | |||
| 4f0b889f04 | |||
| c94768902b | |||
| f575947c03 | |||
| 16bdbafa75 | |||
| 089871d3ae | |||
| 765677d952 | |||
| 6afc38c899 | |||
| a43639587f | |||
| 46d022388d | |||
| 31363e8f83 | |||
| e1286e4b73 | |||
| 0366bcb341 | |||
| 452f717e0e | |||
| ab3add9577 | |||
| 54939bca61 | |||
| 7ccde9c777 | |||
| 6bdfa26c7e | |||
| a5bae64959 | |||
| 4d04a0d649 | |||
| fb7af5b902 | |||
| 77172fb39c | |||
| 78ecdc676c | |||
| bbccdf009b | |||
| 4b26066377 | |||
| 8742163d51 | |||
| 212753f831 | |||
| 903236d890 | |||
| 15bd732b22 | |||
| 3e86bf7644 | |||
| d6cd7c30f5 | |||
| 89b384abfe | |||
| f54baf3aa8 | |||
| b2184f7167 | |||
| 3a10eabfe9 | |||
| f9e80f3602 | |||
| 80b1e5e886 | |||
| d1a7800f36 | |||
| e223ffd0db | |||
| b140f4b521 | |||
| 2d570818be | |||
| 1462f08825 | |||
| 92fb4ac40b | |||
| 2bf55b7c8b | |||
| cf2159cd54 | |||
| decfeec7a1 | |||
| 50f47caea9 | |||
| 89cd81ecfd | |||
| 8df6286e80 | |||
| e947c91a7b | |||
| ef53ac4c63 | |||
| f50dd716ad | |||
| 54d0260ea2 | |||
| 2577365e08 | |||
| 792a722063 | |||
| 00df026108 | |||
| 56a4e80c83 | |||
| a7a78a09c1 | |||
| 6f93eeae69 | |||
| be45d169d7 | |||
| 0fc749f839 | |||
| 03267ba2ec | |||
| b0adc188a2 | |||
| 048fbc4b18 | |||
| c0a061f2cb | |||
| 0296a6ef33 | |||
| dcee112745 | |||
| 65709f9cc2 | |||
| bf5c41b9a0 | |||
| 66b45dba7c | |||
| 65e7372cf7 | |||
| 2ce5708599 | |||
| 1ea27ad7f8 | |||
| 48d94d24eb | |||
| f5c569ab2a | |||
| 2e61fcfdd9 | |||
| 3df883cbe8 | |||
| 0ed3f740b7 | |||
| af2e76aea6 | |||
| 6593230d48 | |||
| e02c72b564 | |||
| c2964f92af | |||
| 15fb3a4f4e | |||
| cff1836571 | |||
| cb57db3c8a | |||
| d22fb105b6 | |||
| 89aba918bc | |||
| 47c1e6f637 | |||
| f5284c967b | |||
| d465e29a0f | |||
| f43ef621cb | |||
| 2f9a8eb77f | |||
| a70087e1f2 | |||
| c3da9a66a1 | |||
| f907a90be7 | |||
| f65a27cf86 | |||
| ed59c2b998 | |||
| 925bca7149 | |||
| 89ce79dafc |
3
.gitignore
vendored
3
.gitignore
vendored
@ -45,3 +45,6 @@ OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
|
||||
*.tlb
|
||||
*.idb
|
||||
**/.hg
|
||||
*.zip
|
||||
*.tar.gz
|
||||
**/*.build/
|
||||
|
||||
@ -902,7 +902,7 @@ namespace DocFileFormat
|
||||
{
|
||||
int shape_type = oPicture.shapeContainer->getShapeType();
|
||||
|
||||
if (shape_type != msosptPictureFrame) picture = false;
|
||||
if (shape_type != msosptPictureFrame) picture = false;//шаблон 1.doc картинка в колонтитуле
|
||||
}
|
||||
|
||||
if (picture)
|
||||
|
||||
@ -75,6 +75,8 @@ namespace DocFileFormat
|
||||
|
||||
while ( ( cp - m_document->FIB->m_RgLw97.ccpText ) < (*m_document->IndividualFootnotesPlex)[id + 1] )
|
||||
{
|
||||
int cpStart = cp;
|
||||
|
||||
int fc = m_document->FindFileCharPos(cp);
|
||||
if (fc < 0) break;
|
||||
|
||||
@ -93,6 +95,8 @@ namespace DocFileFormat
|
||||
//this PAPX is for a normal paragraph
|
||||
cp = writeParagraph( cp );
|
||||
}
|
||||
while (cp <= cpStart) //conv_fQioC665ib4ngHkDGY4__docx.doc
|
||||
cp++;
|
||||
}
|
||||
|
||||
m_pXmlWriter->WriteNodeEnd( L"w:footnote");
|
||||
|
||||
@ -124,11 +124,14 @@ namespace DocFileFormat
|
||||
TableInfo tai(papx);
|
||||
if (tai.fInTable)
|
||||
{
|
||||
int cpStart = cp;
|
||||
//this PAPX is for a table
|
||||
//cp = writeTable( cp, tai.iTap );
|
||||
Table table( this, cp, ( ( tai.iTap > 0 ) ? ( 1 ) : ( 0 ) ) );
|
||||
table.Convert(this);
|
||||
cp = table.GetCPEnd();
|
||||
while (cp <= cpStart) //conv_eznHsm8em2unSv6_2QE__docx.doc
|
||||
cp++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -149,7 +149,14 @@ namespace DocFileFormat
|
||||
point.y = guides[index].param3;
|
||||
}
|
||||
}
|
||||
|
||||
if ((size_t)point.y > 0xffff)
|
||||
{
|
||||
point.y &= 0xffff;
|
||||
}
|
||||
if ((size_t)point.x > 0xffff)
|
||||
{
|
||||
point.x &= 0xffff;
|
||||
}
|
||||
m_arPoints.push_back(point);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,8 +63,25 @@ namespace DocFileFormat
|
||||
Shape* sh = dynamic_cast<Shape*>( *iter );
|
||||
if (sh)
|
||||
{
|
||||
if (sh->shapeType) return sh->shapeType->GetTypeCode();
|
||||
else return 0;
|
||||
if (sh->shapeType)
|
||||
{
|
||||
return sh->shapeType->GetTypeCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( std::vector<Record*>::const_iterator iter1 = this->Children.begin(); iter1 != this->Children.end(); iter1++ )
|
||||
{
|
||||
ShapeOptions* sh_options = dynamic_cast<ShapeOptions*>( *iter1 );
|
||||
if (sh_options)
|
||||
{
|
||||
if (sh_options->OptionsByID.end() != sh_options->OptionsByID.find(Pib))
|
||||
{
|
||||
return msosptPictureFrame;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -483,26 +483,27 @@ namespace DocFileFormat
|
||||
delete storageOut;
|
||||
return false;
|
||||
}
|
||||
DecryptStream( 0, "/", storageIn, storageOut, Decryptor);
|
||||
|
||||
std::list<std::string> listStream = storageIn->entries();
|
||||
//std::list<std::string> listStream = storageIn->entries();
|
||||
|
||||
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
|
||||
{
|
||||
if (storageIn->isDirectory(*it))
|
||||
{
|
||||
std::list<std::string> list_entry = storageIn->GetAllStreams(*it);
|
||||
|
||||
for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
|
||||
{
|
||||
DecryptStream(Decryptor, *it2, storageIn, storageOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DecryptStream(Decryptor, *it, storageIn, storageOut);
|
||||
}
|
||||
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
|
||||
//{
|
||||
// if (storageIn->isDirectory(*it))
|
||||
// {
|
||||
// std::list<std::string> list_entry = storageIn->GetAllStreams(*it);
|
||||
//
|
||||
// for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
|
||||
// {
|
||||
// DecryptStream(Decryptor, *it2, storageIn, storageOut);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DecryptStream(Decryptor, *it, storageIn, storageOut);
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
storageOut->close();
|
||||
delete storageOut;
|
||||
@ -525,34 +526,28 @@ namespace DocFileFormat
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool WordDocument::CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
|
||||
void WordDocument::DecryptStream( int level, std::string path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
{
|
||||
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
|
||||
if (!stream) return false;
|
||||
|
||||
stream->seek(0);
|
||||
int sz_stream = stream->size();
|
||||
|
||||
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, sz_stream);
|
||||
if (!streamNew) return false;
|
||||
|
||||
unsigned char* data_stream = new unsigned char[sz_stream];
|
||||
stream->read(data_stream, sz_stream);
|
||||
|
||||
streamNew->write(data_stream, sz_stream);
|
||||
|
||||
RELEASEARRAYOBJECTS(data_stream);
|
||||
|
||||
streamNew->flush();
|
||||
|
||||
delete streamNew;
|
||||
delete stream;
|
||||
|
||||
return true;
|
||||
std::list<std::string> entries;
|
||||
entries = storageIn->entries( path );
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for( it = entries.begin(); it != entries.end(); ++it )
|
||||
{
|
||||
std::string name = *it;
|
||||
std::string fullname = path + name;
|
||||
|
||||
if( storageIn->isDirectory( fullname ) )
|
||||
{
|
||||
DecryptStream( level + 1, fullname + "/", storageIn, storageOut, Decryptor );
|
||||
}
|
||||
else
|
||||
{
|
||||
DecryptStream(fullname, storageIn, storageOut, Decryptor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool WordDocument::DecryptStream(CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
|
||||
bool WordDocument::DecryptStream(std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
|
||||
{
|
||||
POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
|
||||
if (!stream) return false;
|
||||
@ -567,9 +562,9 @@ namespace DocFileFormat
|
||||
stream->read(data_stream, size_stream);
|
||||
|
||||
unsigned char* data_store = NULL;
|
||||
int size_data_store = 0;
|
||||
int size_data_store = 0;
|
||||
|
||||
if ("WordDocument" == streamName)
|
||||
if ( std::wstring::npos != streamName.find("WordDocument") )
|
||||
{
|
||||
size_data_store = 68;
|
||||
data_store = new unsigned char[size_data_store];
|
||||
|
||||
@ -102,9 +102,10 @@ namespace DocFileFormat
|
||||
|
||||
private:
|
||||
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
|
||||
bool DecryptStream (CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut);
|
||||
bool CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut);
|
||||
|
||||
|
||||
bool DecryptStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
void DecryptStream (int level, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
|
||||
|
||||
inline StructuredStorageReader* GetStorage() const
|
||||
{
|
||||
return m_pStorage;
|
||||
|
||||
@ -107,7 +107,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="C:\_WORK\trunk\ServerComponents\Common\DocxFormat\Source\XML\libxml2\XML\include"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions="_DEBUG;_LIB;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
||||
@ -2,34 +2,38 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocFormatLib", "..\DocFormatLib\Win32\DocFormatLib.vcproj", "{C5371405-338F-4B70-83BD-2A5CDF64F383}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
|
||||
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\..\DesktopEditor\graphics\graphics_vs2005.vcproj", "{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
|
||||
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
|
||||
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
|
||||
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
|
||||
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
|
||||
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
|
||||
{617F9069-5E37-4B80-9A3A-E77AFC4CC7AD} = {617F9069-5E37-4B80-9A3A-E77AFC4CC7AD}
|
||||
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B} = {78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}
|
||||
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\OfficeUtils\win32\OfficeUtilsLib.vcproj", "{F8274B05-168E-4D6E-B843-AA7510725363}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raster", "..\..\DesktopEditor\raster\raster_vs2005.vcproj", "{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
|
||||
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
|
||||
{EE1B576A-07C5-4ACC-920F-81C41DD0C8C1} = {EE1B576A-07C5-4ACC-920F-81C41DD0C8C1}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "..\..\DesktopEditor\cximage\CxImage\cximage_vs2005.vcproj", "{BC52A07C-A797-423D-8C4F-8678805BBB36}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
|
||||
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
|
||||
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
|
||||
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
|
||||
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
|
||||
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
|
||||
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
|
||||
{818753F2-DBB9-4D3B-898A-A604309BE470} = {818753F2-DBB9-4D3B-898A-A604309BE470}
|
||||
{FFDA5DA1-BB65-4695-B678-BE59B4A1355D} = {FFDA5DA1-BB65-4695-B678-BE59B4A1355D}
|
||||
{9A037A69-D1DF-4505-AB2A-6CB3641C476E} = {9A037A69-D1DF-4505-AB2A-6CB3641C476E}
|
||||
{40A69F40-063E-43FD-8543-455495D8733E} = {40A69F40-063E-43FD-8543-455495D8733E}
|
||||
{0588563C-F05C-428C-B21A-DD74756628B3} = {0588563C-F05C-428C-B21A-DD74756628B3}
|
||||
{DF861D33-9BC1-418C-82B1-581F590FE169} = {DF861D33-9BC1-418C-82B1-581F590FE169}
|
||||
{764C3A2D-FB0F-428E-B1C7-62D1DD2CE239} = {764C3A2D-FB0F-428E-B1C7-62D1DD2CE239}
|
||||
{43A0E60E-5C4A-4C09-A29B-7683F503BBD7} = {43A0E60E-5C4A-4C09-A29B-7683F503BBD7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jasper", "..\..\DesktopEditor\cximage\jasper\jasper_vs2005.vcproj", "{FFDA5DA1-BB65-4695-B678-BE59B4A1355D}"
|
||||
@ -54,17 +58,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XlsFormat", "..\..\ASCOffic
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocFormatTest", "DocFormatTest.vcproj", "{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C5371405-338F-4B70-83BD-2A5CDF64F383} = {C5371405-338F-4B70-83BD-2A5CDF64F383}
|
||||
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
|
||||
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
|
||||
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
|
||||
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
|
||||
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
|
||||
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
|
||||
{77DDC8D7-5B12-4FF2-9629-26AEBCA8436D} = {77DDC8D7-5B12-4FF2-9629-26AEBCA8436D}
|
||||
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
|
||||
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
|
||||
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
|
||||
{BC52A07C-A797-423D-8C4F-8678805BBB36} = {BC52A07C-A797-423D-8C4F-8678805BBB36}
|
||||
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
|
||||
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
|
||||
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
|
||||
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
|
||||
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
|
||||
{37CA072A-5BDE-498B-B3A7-5E404F5F9BF2} = {37CA072A-5BDE-498B-B3A7-5E404F5F9BF2}
|
||||
{C5371405-338F-4B70-83BD-2A5CDF64F383} = {C5371405-338F-4B70-83BD-2A5CDF64F383}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DocxFormat", "..\..\Common\DocxFormat\Projects\DocxFormat2005.vcproj", "{A100103A-353E-45E8-A9B8-90B87CC5C0B0}"
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\..\..\..\Common\OfficeDrawing;"..\..\..\..\..\DesktopEditor\freetype-2.5.2\include";..\..\..\..\..\Common\OfficeDrawing\Shapes"
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_ATL_CSTRINGS;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="false"
|
||||
BasicRuntimeChecks="3"
|
||||
|
||||
@ -40,11 +40,11 @@ namespace Writers
|
||||
class DocumentWriter : public ContentWriter
|
||||
{
|
||||
XmlUtils::CStringWriter m_oWriter;
|
||||
HeaderFooterWriter& m_oHeaderFooterWriter;
|
||||
HeaderFooterWriter& m_oHeaderFooterWriter;
|
||||
public:
|
||||
std::wstring m_sDir;
|
||||
public:
|
||||
DocumentWriter( std::wstring sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir), m_oHeaderFooterWriter(oHeaderFooterWriter)
|
||||
std::wstring m_sDir;
|
||||
|
||||
DocumentWriter( std::wstring sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir), m_oHeaderFooterWriter(oHeaderFooterWriter)
|
||||
{
|
||||
}
|
||||
void Write()
|
||||
@ -54,7 +54,22 @@ namespace Writers
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFileW(filePath.GetPath());
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">")));
|
||||
oFile.WriteStringUTF8( std::wstring(_T("<w:document \
|
||||
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
|
||||
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
|
||||
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
|
||||
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
|
||||
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
|
||||
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
|
||||
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
|
||||
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
|
||||
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
|
||||
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
|
||||
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
|
||||
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
|
||||
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
|
||||
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
|
||||
mc:Ignorable=\"w14 wp14\">")));
|
||||
|
||||
oFile.WriteStringUTF8(m_oBackground.GetData());
|
||||
|
||||
|
||||
@ -31,7 +31,9 @@
|
||||
*/
|
||||
#ifndef FILE_WRITER
|
||||
#define FILE_WRITER
|
||||
|
||||
#include "../../DesktopEditor/common/Path.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
|
||||
|
||||
#include "NumberingWriter.h"
|
||||
#include "fontTableWriter.h"
|
||||
@ -75,6 +77,8 @@ namespace Writers
|
||||
DocumentRelsWriter m_oDocumentRelsWriter;
|
||||
WebSettingsWriter m_oWebSettingsWriter;
|
||||
DefaultThemeWriter m_oTheme;
|
||||
|
||||
smart_ptr<OOX::VbaProject> m_pVbaProject;
|
||||
|
||||
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
|
||||
bool m_bSaveChartAsImg;
|
||||
|
||||
@ -34,6 +34,14 @@
|
||||
|
||||
namespace BinDocxRW {
|
||||
|
||||
int Binary_VbaProjectTableReader::Read()
|
||||
{
|
||||
m_oFileWriter.m_pVbaProject = new OOX::VbaProject();
|
||||
m_oFileWriter.m_pVbaProject->fromPPTY(&m_oBufferedStream);
|
||||
|
||||
return c_oSerConstants::ReadOk;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------
|
||||
Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments):Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_oHeaderFooterWriter(oFileWriter.m_oHeaderFooterWriter),m_pComments(pComments)
|
||||
{
|
||||
}
|
||||
@ -93,9 +101,9 @@ int Binary_HdrFtrTableReader::ReadHdrFtrItem(BYTE type, long length, void* poRes
|
||||
Binary_DocumentTableReader oBinary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, poHdrFtrItem->Header, m_pComments);
|
||||
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItemContent, this, &oBinary_DocumentTableReader);
|
||||
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") +
|
||||
FILE_SEPARATOR_STR + _T("_rels")+
|
||||
FILE_SEPARATOR_STR + poHdrFtrItem->m_sFilename + _T(".rels");
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" +
|
||||
FILE_SEPARATOR_STR + L"_rels"+
|
||||
FILE_SEPARATOR_STR + poHdrFtrItem->m_sFilename + L".rels";
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
|
||||
}
|
||||
|
||||
@ -273,6 +273,20 @@ private:
|
||||
return res;
|
||||
}
|
||||
};
|
||||
class Binary_VbaProjectTableReader : public Binary_CommonReader<Binary_VbaProjectTableReader>
|
||||
{
|
||||
Writers::FileWriter& m_oFileWriter;
|
||||
|
||||
public:
|
||||
|
||||
Binary_VbaProjectTableReader (NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter)
|
||||
: Binary_CommonReader(poBufferedStream), m_oFileWriter(oFileWriter)
|
||||
{
|
||||
}
|
||||
|
||||
int Read ();
|
||||
};
|
||||
|
||||
class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableReader>
|
||||
{
|
||||
Writers::FileWriter& m_oFileWriter;
|
||||
@ -282,12 +296,12 @@ class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableRe
|
||||
int nCurHeaderType;
|
||||
public:
|
||||
Writers::HeaderFooterWriter& m_oHeaderFooterWriter;
|
||||
public:
|
||||
|
||||
Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments);
|
||||
int Read();
|
||||
int ReadHdrFtrContent(BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrFEO(BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrItem(BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrContent (BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrFEO (BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrItem (BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrItemContent(BYTE type, long length, void* poResult);
|
||||
};
|
||||
class Binary_rPrReader : public Binary_CommonReader<Binary_rPrReader>
|
||||
@ -551,7 +565,7 @@ public:
|
||||
std::wstring strXml;
|
||||
HRESULT hRes = m_oFileWriter.m_pDrawingConverter->GetRecordXml(nCurPos, length, XMLWRITER_RECORD_TYPE_TEXT_FILL, XMLWRITER_DOC_TYPE_WORDART, strXml);
|
||||
if (S_OK == hRes)
|
||||
orPr->Fill = _T("<w14:textFill>") + strXml + _T("</w14:textFill>");
|
||||
orPr->Fill = L"<w14:textFill>" + strXml + L"</w14:textFill>";
|
||||
m_oBufferedStream.Seek(nCurPos + length);
|
||||
}
|
||||
}
|
||||
@ -560,35 +574,35 @@ public:
|
||||
{
|
||||
TrackRevision oDel;
|
||||
oBinary_CommonReader2.ReadTrackRevision(length, &oDel);
|
||||
orPr->Del = oDel.ToString(_T("w:del"));
|
||||
orPr->Del = oDel.ToString(L"w:del");
|
||||
}
|
||||
break;
|
||||
case c_oSerProp_rPrType::Ins:
|
||||
{
|
||||
TrackRevision oIns;
|
||||
oBinary_CommonReader2.ReadTrackRevision(length, &oIns);
|
||||
orPr->Ins = oIns.ToString(_T("w:ins"));
|
||||
orPr->Ins = oIns.ToString(L"w:ins");
|
||||
}
|
||||
break;
|
||||
case c_oSerProp_rPrType::MoveFrom:
|
||||
{
|
||||
TrackRevision oMoveFrom;
|
||||
oBinary_CommonReader2.ReadTrackRevision(length, &oMoveFrom);
|
||||
orPr->MoveFrom = oMoveFrom.ToString(_T("w:moveFrom"));
|
||||
orPr->MoveFrom = oMoveFrom.ToString(L"w:moveFrom");
|
||||
}
|
||||
break;
|
||||
case c_oSerProp_rPrType::MoveTo:
|
||||
{
|
||||
TrackRevision oMoveTo;
|
||||
oBinary_CommonReader2.ReadTrackRevision(length, &oMoveTo);
|
||||
orPr->MoveTo = oMoveTo.ToString(_T("w:moveTo"));
|
||||
orPr->MoveTo = oMoveTo.ToString(L"w:moveTo");
|
||||
}
|
||||
break;
|
||||
case c_oSerProp_rPrType::rPrChange:
|
||||
{
|
||||
TrackRevision oRPrChange;
|
||||
res = Read1(length, &Binary_rPrReader::ReadrPrChange, this, &oRPrChange);
|
||||
orPr->rPrChange = oRPrChange.ToString(_T("w:rPrChange"));
|
||||
orPr->rPrChange = oRPrChange.ToString(L"w:rPrChange");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -647,9 +661,9 @@ public:
|
||||
{
|
||||
BYTE contextualSpacing = m_oBufferedStream.GetUChar();
|
||||
if(0 != contextualSpacing)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:contextualSpacing w:val=\"true\"/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:contextualSpacing w:val=\"true\"/>"));
|
||||
else if(false == bDoNotWriteNullProp)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:contextualSpacing w:val=\"false\"/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:contextualSpacing w:val=\"false\"/>"));
|
||||
}break;
|
||||
case c_oSerProp_pPrType::Ind:
|
||||
{
|
||||
@ -657,9 +671,9 @@ public:
|
||||
res = Read2(length, &Binary_pPrReader::ReadInd, this, &oTempWriter);
|
||||
if(oTempWriter.GetCurSize() > 0)
|
||||
{
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:ind")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:ind"));
|
||||
pCStringWriter->Write(oTempWriter);
|
||||
pCStringWriter->WriteString(std::wstring(_T("/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"/>"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -668,35 +682,35 @@ public:
|
||||
BYTE jc = m_oBufferedStream.GetUChar();
|
||||
switch(jc)
|
||||
{
|
||||
case align_Right: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"right\" />")));break;
|
||||
case align_Left: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"left\" />")));break;
|
||||
case align_Center: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"center\" />")));break;
|
||||
case align_Justify: pCStringWriter->WriteString(std::wstring(_T("<w:jc w:val=\"both\" />")));break;
|
||||
case align_Right: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"right\" />"));break;
|
||||
case align_Left: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"left\" />"));break;
|
||||
case align_Center: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"center\" />"));break;
|
||||
case align_Justify: pCStringWriter->WriteString(std::wstring(L"<w:jc w:val=\"both\" />"));break;
|
||||
}
|
||||
}break;
|
||||
case c_oSerProp_pPrType::KeepLines:
|
||||
{
|
||||
BYTE KeepLines = m_oBufferedStream.GetUChar();
|
||||
if(0 != KeepLines)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:keepLines/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:keepLines/>"));
|
||||
else if(false == bDoNotWriteNullProp)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:keepLines w:val=\"false\"/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:keepLines w:val=\"false\"/>"));
|
||||
}break;
|
||||
case c_oSerProp_pPrType::KeepNext:
|
||||
{
|
||||
BYTE KeepNext = m_oBufferedStream.GetUChar();
|
||||
if(0 != KeepNext)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:keepNext/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:keepNext/>"));
|
||||
else if(false == bDoNotWriteNullProp)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:keepNext w:val=\"false\"/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:keepNext w:val=\"false\"/>"));
|
||||
}break;
|
||||
case c_oSerProp_pPrType::PageBreakBefore:
|
||||
{
|
||||
BYTE pageBreakBefore = m_oBufferedStream.GetUChar();
|
||||
if(0 != pageBreakBefore)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:pageBreakBefore/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:pageBreakBefore/>"));
|
||||
else if(false == bDoNotWriteNullProp)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:pageBreakBefore w:val=\"false\"/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:pageBreakBefore w:val=\"false\"/>"));
|
||||
break;
|
||||
}
|
||||
case c_oSerProp_pPrType::Spacing:
|
||||
@ -705,7 +719,7 @@ public:
|
||||
res = Read2(length, &Binary_pPrReader::ReadSpacing, this, &oSpacing);
|
||||
if(oSpacing.bLine || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
|
||||
{
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:spacing")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:spacing"));
|
||||
BYTE bLineRule = linerule_Auto;
|
||||
//проверяется bLine, а не bLineRule чтобы всегда писать LineRule, если есть w:line
|
||||
if(oSpacing.bLine)
|
||||
@ -745,9 +759,9 @@ public:
|
||||
if(oSpacing.bAfterAuto)
|
||||
{
|
||||
if(true == oSpacing.AfterAuto)
|
||||
pCStringWriter->WriteString(std::wstring(_T(" w:afterAutospacing=\"1\"")));
|
||||
pCStringWriter->WriteString(std::wstring(L" w:afterAutospacing=\"1\""));
|
||||
else
|
||||
pCStringWriter->WriteString(std::wstring(_T(" w:afterAutospacing=\"0\"")));
|
||||
pCStringWriter->WriteString(std::wstring(L" w:afterAutospacing=\"0\""));
|
||||
}
|
||||
if(oSpacing.bBefore)
|
||||
{
|
||||
@ -758,11 +772,11 @@ public:
|
||||
if(oSpacing.bBeforeAuto)
|
||||
{
|
||||
if(true == oSpacing.BeforeAuto)
|
||||
pCStringWriter->WriteString(std::wstring(_T(" w:beforeAutospacing=\"1\"")));
|
||||
pCStringWriter->WriteString(std::wstring(L" w:beforeAutospacing=\"1\""));
|
||||
else
|
||||
pCStringWriter->WriteString(std::wstring(_T(" w:beforeAutospacing=\"0\"")));
|
||||
pCStringWriter->WriteString(std::wstring(L" w:beforeAutospacing=\"0\""));
|
||||
}
|
||||
pCStringWriter->WriteString(std::wstring(_T("/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"/>"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -776,7 +790,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring sShd(_T("<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>"));
|
||||
std::wstring sShd(L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>");
|
||||
pCStringWriter->WriteString(sShd);
|
||||
}
|
||||
break;
|
||||
@ -787,10 +801,10 @@ public:
|
||||
if(0 != WidowControl)
|
||||
{
|
||||
if(false == bDoNotWriteNullProp)
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:widowControl/>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:widowControl/>"));
|
||||
}
|
||||
else
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:widowControl w:val=\"off\" />")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:widowControl w:val=\"off\" />"));
|
||||
break;
|
||||
}
|
||||
case c_oSerProp_pPrType::Tab:
|
||||
@ -800,7 +814,7 @@ public:
|
||||
size_t nLen = oTabs.m_aTabs.size();
|
||||
if(nLen > 0)
|
||||
{
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:tabs>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:tabs>"));
|
||||
for(size_t i = 0; i < nLen; ++i)
|
||||
{
|
||||
Tab& oTab = oTabs.m_aTabs[i];
|
||||
@ -808,14 +822,14 @@ public:
|
||||
std::wstring sVal;
|
||||
switch(oTab.Val)
|
||||
{
|
||||
case g_tabtype_right: sVal=_T("right"); break;
|
||||
case g_tabtype_center: sVal=_T("center"); break;
|
||||
case g_tabtype_clear: sVal=_T("clear"); break;
|
||||
default: sVal=_T("left"); break;
|
||||
case g_tabtype_right: sVal = L"right"; break;
|
||||
case g_tabtype_center: sVal = L"center"; break;
|
||||
case g_tabtype_clear: sVal = L"clear"; break;
|
||||
default: sVal = L"left"; break;
|
||||
}
|
||||
pCStringWriter->WriteString(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"/>");
|
||||
}
|
||||
pCStringWriter->WriteString(std::wstring(_T("</w:tabs>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"</w:tabs>"));
|
||||
}
|
||||
}break;
|
||||
case c_oSerProp_pPrType::ParaStyle:
|
||||
@ -826,9 +840,9 @@ public:
|
||||
}break;
|
||||
case c_oSerProp_pPrType::numPr:
|
||||
{
|
||||
pCStringWriter->WriteString(std::wstring(_T("<w:numPr>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"<w:numPr>"));
|
||||
res = Read2(length, &Binary_pPrReader::ReadNumPr, this, poResult);
|
||||
pCStringWriter->WriteString(std::wstring(_T("</w:numPr>")));
|
||||
pCStringWriter->WriteString(std::wstring(L"</w:numPr>"));
|
||||
}break;
|
||||
case c_oSerProp_pPrType::pPr_rPr:
|
||||
{
|
||||
@ -2917,7 +2931,8 @@ class Binary_OtherTableReader : public Binary_CommonReader<Binary_OtherTableRead
|
||||
Writers::FileWriter& m_oFileWriter;
|
||||
std::wstring m_sFileInDir;
|
||||
public:
|
||||
Binary_OtherTableReader(std::wstring sFileInDir, NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter):m_sFileInDir(sFileInDir),Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter)
|
||||
Binary_OtherTableReader(std::wstring sFileInDir, NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter)
|
||||
: m_sFileInDir(sFileInDir), Binary_CommonReader(poBufferedStream), m_oFileWriter(oFileWriter)
|
||||
{
|
||||
}
|
||||
int Read()
|
||||
@ -7022,13 +7037,13 @@ public:
|
||||
{
|
||||
if(false == m_oFileWriter.m_bSaveChartAsImg)
|
||||
{
|
||||
OOX::CPath pathChartsDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR +_T("charts");
|
||||
OOX::CPath pathChartsDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"charts";
|
||||
OOX::CSystemUtility::CreateDirectories(pathChartsDir.GetPath());
|
||||
|
||||
OOX::CPath pathChartsRelsDir = pathChartsDir.GetPath() + FILE_SEPARATOR_STR + _T("_rels");
|
||||
OOX::CPath pathChartsRelsDir = pathChartsDir.GetPath() + FILE_SEPARATOR_STR + L"_rels";
|
||||
OOX::CSystemUtility::CreateDirectories(pathChartsRelsDir.GetPath());
|
||||
|
||||
OOX::CPath pathChartsWorksheetDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR +_T("embeddings");
|
||||
OOX::CPath pathChartsWorksheetDir = m_oFileWriter.m_oChartWriter.m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"embeddings";
|
||||
OOX::CSystemUtility::CreateDirectories(pathChartsWorksheetDir.GetPath());
|
||||
|
||||
int nativeDocumentType = m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_nDocumentType;
|
||||
@ -7922,9 +7937,9 @@ public:
|
||||
|
||||
int res = ReadTable(&Binary_NotesTableReader::ReadNotes, this, &oBinary_DocumentTableReader);
|
||||
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") +
|
||||
FILE_SEPARATOR_STR + _T("_rels")+
|
||||
FILE_SEPARATOR_STR + sFilename + _T(".rels");
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word" +
|
||||
FILE_SEPARATOR_STR + L"_rels"+
|
||||
FILE_SEPARATOR_STR + sFilename + L".rels";
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
|
||||
return res;
|
||||
@ -7961,33 +7976,33 @@ public:
|
||||
XmlUtils::CStringWriter& writer = pBinary_DocumentTableReader->m_oDocumentWriter.m_oContent;
|
||||
if(m_bIsFootnote)
|
||||
{
|
||||
writer.WriteString(_T("<w:footnote"));
|
||||
writer.WriteString(L"<w:footnote");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteString(_T("<w:endnote"));
|
||||
writer.WriteString(L"<w:endnote");
|
||||
}
|
||||
if(m_oType.IsInit())
|
||||
{
|
||||
writer.WriteString(_T(" w:type=\""));
|
||||
writer.WriteString(L" w:type=\"");
|
||||
writer.WriteString(m_oType->ToString());
|
||||
writer.WriteString(_T("\""));
|
||||
writer.WriteString(L"\"");
|
||||
}
|
||||
if(m_oId.IsInit())
|
||||
{
|
||||
writer.WriteString(_T(" w:id=\""));
|
||||
writer.WriteString(L" w:id=\"");
|
||||
writer.WriteString(m_oId->ToString());
|
||||
writer.WriteString(_T("\""));
|
||||
writer.WriteString(L"\"");
|
||||
}
|
||||
writer.WriteString(_T(">"));
|
||||
writer.WriteString(L">");
|
||||
res = Read1(length, &Binary_NotesTableReader::ReadNoteContent, this, poResult);
|
||||
if(m_bIsFootnote)
|
||||
{
|
||||
writer.WriteString(_T("</w:footnote>"));
|
||||
writer.WriteString(L"</w:footnote>");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteString(_T("</w:endnote>"));
|
||||
writer.WriteString(L"</w:endnote>");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -8087,8 +8102,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<w:defaultTabStop w:val=\"708\"/>"));
|
||||
std::wstring sClrMap(_T("<w:clrSchemeMapping w:bg1=\"light1\" w:t1=\"dark1\" w:bg2=\"light2\" w:t2=\"dark2\" w:accent1=\"accent1\" w:accent2=\"accent2\" w:accent3=\"accent3\" w:accent4=\"accent4\" w:accent5=\"accent5\" w:accent6=\"accent6\" w:hyperlink=\"hyperlink\" w:followedHyperlink=\"followedHyperlink\"/>"));
|
||||
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"708\"/>");
|
||||
std::wstring sClrMap(L"<w:clrSchemeMapping w:bg1=\"light1\" w:t1=\"dark1\" w:bg2=\"light2\" w:t2=\"dark2\" w:accent1=\"accent1\" w:accent2=\"accent2\" w:accent3=\"accent3\" w:accent4=\"accent4\" w:accent5=\"accent5\" w:accent6=\"accent6\" w:hyperlink=\"hyperlink\" w:followedHyperlink=\"followedHyperlink\"/>");
|
||||
m_oFileWriter.m_oSettingWriter.AddSetting(sClrMap);
|
||||
m_oFileWriter.m_pDrawingConverter->LoadClrMap(sClrMap);
|
||||
}
|
||||
@ -8140,9 +8155,12 @@ public:
|
||||
case c_oSerTableTypes::Endnotes:
|
||||
res = Binary_NotesTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_pComments, false).Read();
|
||||
break;
|
||||
case c_oSerTableTypes::VbaProject:
|
||||
res = Binary_VbaProjectTableReader(m_oBufferedStream, m_oFileWriter).Read();
|
||||
break;
|
||||
|
||||
//Comments должны читаться раньше чем c_oSerTableTypes::Document
|
||||
//case c_oSerTableTypes::Comments:
|
||||
//case c_oSerTableTypes::Comments
|
||||
// res = oBinary_CommentsTableReader.Read();
|
||||
// break;
|
||||
//case c_oSerTableTypes::Other:
|
||||
@ -8165,7 +8183,18 @@ public:
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", L"fontTable.xml", L"", &stamdartRId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", L"theme/theme1.xml",L"", &stamdartRId);
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", L"/word", L"document.xml");
|
||||
if (m_oFileWriter.m_pVbaProject.IsInit())
|
||||
{
|
||||
//m_oFileWriter.m_pVbaProject->write();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2006/relationships/vbaProject", L"vbaProject.bin", L"", &stamdartRId);
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.ms-word.document.macroEnabled.main+xml", L"/word", L"document.xml");
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.ms-office.vbaProject", L"/word", L"vbaProject.bin");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", L"/word", L"document.xml");
|
||||
}
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", L"/word", L"styles.xml");
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", L"/word", L"settings.xml");
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml", L"/word", L"webSettings.xml");
|
||||
@ -8175,19 +8204,19 @@ public:
|
||||
if(false == m_oFileWriter.m_oNumberingWriter.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering")), std::wstring(_T("numbering.xml")), std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering", L"numbering.xml", std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", L"/word", L"numbering.xml");
|
||||
}
|
||||
if(false == m_oFileWriter.m_oFootnotesWriter.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes")), std::wstring(_T("footnotes.xml")), std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", L"footnotes.xml", std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", L"/word", L"footnotes.xml");
|
||||
}
|
||||
if(false == m_oFileWriter.m_oEndnotesWriter.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes")), std::wstring(_T("endnotes.xml")), std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", L"endnotes.xml", std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml", L"/word", L"endnotes.xml");
|
||||
}
|
||||
for(size_t i = 0; i < m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders.size(); ++i)
|
||||
@ -8196,7 +8225,7 @@ public:
|
||||
if(false == pHeader->IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header")), pHeader->m_sFilename, std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", pHeader->m_sFilename, std::wstring(), &rId);
|
||||
pHeader->rId = L"rId" + std::to_wstring( rId );
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml", L"/word", pHeader->m_sFilename);
|
||||
@ -8208,7 +8237,7 @@ public:
|
||||
if(false == pFooter->IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer")), pFooter->m_sFilename, std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", pFooter->m_sFilename, std::wstring(), &rId);
|
||||
pFooter->rId = L"rId" + std::to_wstring( rId );
|
||||
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml", L"/word", pFooter->m_sFilename);
|
||||
@ -8216,9 +8245,9 @@ public:
|
||||
}
|
||||
res = Binary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_oDocumentWriter, &oBinary_CommentsTableReader.m_oComments).Read();
|
||||
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word")
|
||||
+ FILE_SEPARATOR_STR + _T("_rels")
|
||||
+ FILE_SEPARATOR_STR + _T("document.xml.rels");
|
||||
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word"
|
||||
+ FILE_SEPARATOR_STR + L"_rels"
|
||||
+ FILE_SEPARATOR_STR + L"document.xml.rels";
|
||||
|
||||
CComments& oComments= oBinary_CommentsTableReader.m_oComments;
|
||||
Writers::CommentsWriter& oCommentsWriter = m_oFileWriter.m_oCommentsWriter;
|
||||
@ -8232,19 +8261,19 @@ public:
|
||||
if(false == oCommentsWriter.m_sComment.empty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments")), std::wstring(_T("comments.xml")), std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", L"comments.xml", std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml", L"/word", L"comments.xml");
|
||||
}
|
||||
if(false == oCommentsWriter.m_sCommentExt.empty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.microsoft.com/office/2011/relationships/commentsExtended")), std::wstring(_T("commentsExtended.xml")), std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/commentsExtended", L"commentsExtended.xml", std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml", L"/word", L"commentsExtended.xml");
|
||||
}
|
||||
if(false == oCommentsWriter.m_sPeople.empty())
|
||||
{
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(std::wstring(_T("http://schemas.microsoft.com/office/2011/relationships/people")), std::wstring(_T("people.xml")), std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(L"http://schemas.microsoft.com/office/2011/relationships/people", L"people.xml", std::wstring(), &rId);
|
||||
m_oFileWriter.m_pDrawingConverter->Registration(L"application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml", L"/word", L"people.xml");
|
||||
}
|
||||
|
||||
|
||||
@ -142,19 +142,20 @@ extern int g_nCurFormatVersion;
|
||||
};}
|
||||
namespace c_oSerTableTypes{enum c_oSerTableTypes
|
||||
{
|
||||
Signature = 0,
|
||||
Info = 1,
|
||||
Media = 2,
|
||||
Numbering = 3,
|
||||
HdrFtr = 4,
|
||||
Style = 5,
|
||||
Document = 6,
|
||||
Other = 7,
|
||||
Comments = 8,
|
||||
Settings = 9,
|
||||
Footnotes = 10,
|
||||
Endnotes = 11,
|
||||
Background
|
||||
Signature = 0,
|
||||
Info = 1,
|
||||
Media = 2,
|
||||
Numbering = 3,
|
||||
HdrFtr = 4,
|
||||
Style = 5,
|
||||
Document = 6,
|
||||
Other = 7,
|
||||
Comments = 8,
|
||||
Settings = 9,
|
||||
Footnotes = 10,
|
||||
Endnotes = 11,
|
||||
Background = 12,
|
||||
VbaProject = 13
|
||||
};}
|
||||
namespace c_oSerSigTypes{enum c_oSerSigTypes
|
||||
{
|
||||
@ -203,10 +204,10 @@ extern int g_nCurFormatVersion;
|
||||
};}
|
||||
namespace c_oSerOtherTableTypes{enum c_oSerOtherTableTypes
|
||||
{
|
||||
ImageMap = 0,
|
||||
ImageMap_Src = 1,
|
||||
EmbeddedFonts = 2,
|
||||
DocxTheme = 3
|
||||
ImageMap = 0,
|
||||
ImageMap_Src = 1,
|
||||
EmbeddedFonts = 2,
|
||||
DocxTheme = 3
|
||||
};}
|
||||
namespace c_oSerFontsTypes{enum c_oSerFontsTypes
|
||||
{
|
||||
@ -521,6 +522,10 @@ extern int g_nCurFormatVersion;
|
||||
endnoteReference = 27,
|
||||
arPr = 28
|
||||
};}
|
||||
namespace c_oSerVbaProjectTypes{enum c_oSerVbaProjectType
|
||||
{
|
||||
Name = 0
|
||||
};}
|
||||
namespace c_oSerBackgroundType{enum c_oSerBackgroundType
|
||||
{
|
||||
Color = 0,
|
||||
|
||||
@ -82,11 +82,11 @@ namespace BinDocxRW
|
||||
int m_nType;
|
||||
public:
|
||||
std::wstring m_sFld;
|
||||
public: FldStruct(std::wstring sFld, int nType):m_sFld(sFld),m_nType(nType){}
|
||||
public: int GetType()
|
||||
{
|
||||
return m_nType;
|
||||
}
|
||||
FldStruct(std::wstring sFld, int nType):m_sFld(sFld),m_nType(nType){}
|
||||
int GetType()
|
||||
{
|
||||
return m_nType;
|
||||
}
|
||||
};
|
||||
class BinaryCommonWriter
|
||||
{
|
||||
@ -3025,7 +3025,14 @@ namespace BinDocxRW
|
||||
std::wstring& sShapeType = aShapeTypes[i];
|
||||
pOfficeDrawingConverter->AddShapeType(sShapeType);
|
||||
}
|
||||
pOfficeDrawingConverter->SetRels(oldRels);
|
||||
pOfficeDrawingConverter->SetRels(oldRels);
|
||||
}
|
||||
void WriteVbaProject(OOX::VbaProject& oVbaProject)
|
||||
{
|
||||
m_oBcw.m_oStream.StartRecord(0);
|
||||
oVbaProject.toPPTY(&m_oBcw.m_oStream);
|
||||
m_oBcw.m_oStream.EndRecord();
|
||||
|
||||
}
|
||||
void Write(std::vector<OOX::WritingElement*>& aElems)
|
||||
{
|
||||
@ -7866,9 +7873,8 @@ namespace BinDocxRW
|
||||
//Write DocumentTable
|
||||
ParamsDocumentWriter oParamsDocumentWriter(poDocument);
|
||||
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
|
||||
|
||||
|
||||
//DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add...
|
||||
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
|
||||
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, &oBinaryHeaderFooterTableWriter);
|
||||
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_oParamsWriter.m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, poDocument->m_arrShapeTypes);
|
||||
|
||||
@ -7876,7 +7882,15 @@ namespace BinDocxRW
|
||||
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
|
||||
|
||||
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
|
||||
//Write Vba
|
||||
if(NULL != oDocx.m_pVbaProject)
|
||||
{
|
||||
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::VbaProject);
|
||||
oBinaryDocumentTableWriter.WriteVbaProject(*oDocx.m_pVbaProject);
|
||||
this->WriteTableEnd(nCurPos);
|
||||
}
|
||||
// Write content
|
||||
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
|
||||
oBinaryDocumentTableWriter.Write(poDocument->m_arrItems);
|
||||
this->WriteTableEnd(nCurPos);
|
||||
|
||||
|
||||
@ -93,6 +93,8 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const std::wstring& sSrcFileName, co
|
||||
oDrawingConverter.SetFontDir(m_sFontDir);
|
||||
oDrawingConverter.SetFontPicker(pFontPicker);
|
||||
oDrawingConverter.SetMainDocument(this);
|
||||
|
||||
oDrawingConverter.SetDstPath(pathMain.GetDirectory() + FILE_SEPARATOR_STR + L"word");
|
||||
oDrawingConverter.SetMediaDstPath(pathMedia.GetPath());
|
||||
|
||||
m_pParamsWriter = new ParamsWriter(&oBufferedStream, &fp, &oDrawingConverter, pEmbeddedFontsManager);
|
||||
@ -264,6 +266,8 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
|
||||
if (NULL != pData)
|
||||
{
|
||||
oDrawingConverter.SetMainDocument(this);
|
||||
oDrawingConverter.SetDstPath(sDstPath + FILE_SEPARATOR_STR + L"word");
|
||||
|
||||
oDrawingConverter.SetMediaDstPath(sMediaPath);
|
||||
oDrawingConverter.SetEmbedDstPath(sEmbedPath);
|
||||
|
||||
@ -273,7 +277,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
|
||||
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
|
||||
std::wstring sFileInDir = strFileInDir.c_str();
|
||||
|
||||
oDrawingConverter.SetSourceFileDir(sFileInDir);
|
||||
oDrawingConverter.SetSrcPath(sFileInDir);
|
||||
|
||||
BinaryFileReader oBinaryFileReader(sFileInDir, oBufferedStream, *m_pCurFileWriter);
|
||||
oBinaryFileReader.ReadFile();
|
||||
@ -292,7 +296,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const std::wstring& sSrcFileName,
|
||||
if (pApp)
|
||||
{
|
||||
pApp->SetApplication(_T("OnlyOffice"));
|
||||
pApp->SetAppVersion(_T("4.3000"));
|
||||
pApp->SetAppVersion(_T("5.0"));
|
||||
pApp->SetDocSecurity(0);
|
||||
pApp->SetScaleCrop(false);
|
||||
pApp->SetLinksUpToDate(false);
|
||||
|
||||
@ -86,15 +86,16 @@ namespace BinXlsxRW{
|
||||
}
|
||||
bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
|
||||
{
|
||||
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
|
||||
|
||||
NSBinPptxRW::CDrawingConverter oDrawingConverter;
|
||||
|
||||
oDrawingConverter.SetDstPath(sDstPath + FILE_SEPARATOR_STR + L"xl");
|
||||
oDrawingConverter.SetSrcPath(strFileInDir, 2);
|
||||
|
||||
oDrawingConverter.SetMediaDstPath(sMediaDir);
|
||||
oDrawingConverter.SetEmbedDstPath(sEmbedDir);
|
||||
|
||||
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
|
||||
|
||||
oDrawingConverter.SetSourceFileDir(strFileInDir, 2);
|
||||
|
||||
BinXlsxRW::BinaryFileReader oBinaryFileReader;
|
||||
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
|
||||
return true;
|
||||
|
||||
@ -314,7 +314,7 @@
|
||||
17E17ED41AC453F800BEA2EA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0710;
|
||||
LastUpgradeCheck = 0900;
|
||||
ORGANIZATIONNAME = "Ascensio System SIA";
|
||||
};
|
||||
buildConfigurationList = 17E17ED71AC453F800BEA2EA /* Build configuration list for PBXProject "ASCOfficeDocxFile2Lib" */;
|
||||
@ -441,13 +441,21 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
@ -455,6 +463,7 @@
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@ -467,7 +476,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -483,13 +492,21 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
@ -497,13 +514,14 @@
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
|
||||
@ -34,9 +34,11 @@
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "../../Common/OfficeFileFormatChecker.h"
|
||||
#include "../../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../src/ConvertOO2OOX.h"
|
||||
#include "../include/logging.h"
|
||||
|
||||
|
||||
#if defined(_WIN64)
|
||||
@ -45,30 +47,55 @@
|
||||
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
HRESULT convert_single(std::wstring srcFileName)
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
std::wstring srcFileName = argv[1];
|
||||
std::wstring dstPath = argc > 2 ? argv[2] : srcFileName + L"-my.docx"; //xlsx pptx docx
|
||||
|
||||
COfficeFileFormatChecker fileChecker(srcFileName);
|
||||
|
||||
std::wstring dstPath = srcFileName;// + ; //xlsx pptx docx
|
||||
switch(fileChecker.nFileType)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT: dstPath += L"-my.docx"; break;
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS:
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS_FLAT: dstPath += L"-my.xlsx"; break;
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP:
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP_FLAT: dstPath += L"-my.pptx"; break;
|
||||
|
||||
default:
|
||||
return S_FALSE;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
|
||||
std::wstring outputDir = NSDirectory::GetFolderPath(dstPath);
|
||||
|
||||
std::wstring srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
std::wstring srcTempPath;
|
||||
|
||||
// распаковываем исходник во временную директорию
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
|
||||
return S_FALSE;
|
||||
if (fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT ||
|
||||
fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS ||
|
||||
fileChecker.nFileType == AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP)
|
||||
{
|
||||
srcTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
|
||||
|
||||
if (S_OK != oCOfficeUtils.ExtractToDirectory(srcFileName.c_str(), srcTempPath.c_str(), NULL, 0))
|
||||
return S_FALSE;
|
||||
}
|
||||
else // flat
|
||||
{
|
||||
srcTempPath = srcFileName;
|
||||
}
|
||||
_CP_LOG << L"[info] " << srcFileName << std::endl;
|
||||
|
||||
hr = ConvertOO2OOX(srcTempPath, dstTempPath, L"C:\\Windows\\Fonts", false, NULL);
|
||||
|
||||
NSDirectory::DeleteDirectory(srcTempPath);
|
||||
if (srcTempPath != srcFileName)
|
||||
{
|
||||
NSDirectory::DeleteDirectory(srcTempPath);
|
||||
}
|
||||
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
@ -77,6 +104,35 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
|
||||
NSDirectory::DeleteDirectory(dstTempPath);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
return 0;
|
||||
return hr;
|
||||
}
|
||||
|
||||
HRESULT convert_directory(std::wstring pathName)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
std::vector<std::wstring> arFiles = NSDirectory::GetFiles(pathName, false);
|
||||
|
||||
for (size_t i = 0; i < arFiles.size(); i++)
|
||||
{
|
||||
convert_single(arFiles[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
if (argc < 2) return 1;
|
||||
|
||||
HRESULT hr = -1;
|
||||
if (NSFile::CFileBinary::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_single(argv[1]);
|
||||
}
|
||||
else if (NSDirectory::Exists(argv[1]))
|
||||
{
|
||||
hr = convert_directory(argv[1]);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
@ -43,6 +43,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/build/vs2005;../../DesktopEditor/xml/libxml2/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -335,6 +336,14 @@
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\Common\OfficeFileFormatChecker.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
|
||||
>
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../include/cpdoccore/CPScopedPtr.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -51,12 +52,15 @@ public:
|
||||
|
||||
// $Лист1.$A$1 -> Лист1!$A$1
|
||||
std::wstring convert_named_ref(std::wstring const & expr, bool withTableName = true, std::wstring separator = L" ");
|
||||
std::wstring get_table_name();
|
||||
|
||||
//a-la convert without check formula
|
||||
std::wstring convert_named_expr(std::wstring const & expr, bool withTableName = true);
|
||||
|
||||
//Sheet2.C3:Sheet2.C19 -> Sheet2!C3:C19
|
||||
std::wstring convert_chart_distance(std::wstring const & expr);
|
||||
|
||||
void split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out);
|
||||
|
||||
std::wstring convert_ref(std::wstring const & expr);
|
||||
|
||||
@ -90,7 +94,7 @@ public:
|
||||
std::wstring convert_named_ref (std::wstring const & expr);
|
||||
std::wstring convert_named_formula(std::wstring const & expr);
|
||||
|
||||
std::wstring get_base_cell_formula(std::wstring const & expr);
|
||||
std::wstring get_table_name();
|
||||
|
||||
//Sheet2!C3:C19 -> Sheet2.C3:Sheet2.C19
|
||||
std::wstring convert_chart_distance(std::wstring const & expr);
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
#include "formulasconvert.h"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include"../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
@ -43,10 +42,12 @@ namespace formulasconvert {
|
||||
class odf2oox_converter::Impl
|
||||
{
|
||||
public:
|
||||
static bool convert_with_TableName;
|
||||
|
||||
std::wstring convert(const std::wstring& expr);
|
||||
std::wstring convert_chart_distance(const std::wstring& expr);
|
||||
|
||||
void split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out);
|
||||
|
||||
void replace_cells_range(std::wstring& expr, bool withTableName);
|
||||
bool check_formula(std::wstring& expr);
|
||||
void replace_semicolons(std::wstring& expr);
|
||||
@ -61,8 +62,12 @@ namespace formulasconvert {
|
||||
void replace_named_ref(std::wstring & expr, bool w = true);
|
||||
bool find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref);
|
||||
bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
|
||||
|
||||
static bool convert_with_TableName;
|
||||
static std::wstring table_name_;
|
||||
};
|
||||
bool odf2oox_converter::Impl::convert_with_TableName = true;
|
||||
bool odf2oox_converter::Impl::convert_with_TableName = true;
|
||||
std::wstring odf2oox_converter::Impl::table_name_ = L"";
|
||||
|
||||
bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
|
||||
{
|
||||
@ -152,6 +157,8 @@ namespace formulasconvert {
|
||||
std::wstring sheet1 = what[1].str();
|
||||
XmlUtils::replace_all( sheet1, L"$", L"");
|
||||
|
||||
table_name_ = sheet1;
|
||||
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str();
|
||||
|
||||
@ -180,15 +187,25 @@ namespace formulasconvert {
|
||||
const std::wstring c2 = what[3].str(); //sheet name 2
|
||||
const std::wstring c3 = what[4].str();
|
||||
|
||||
table_name_ = sheet1;
|
||||
|
||||
if (convert_with_TableName)
|
||||
{
|
||||
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c3) );
|
||||
return (sheet1 + L"!") + c1 + (c3.empty() ? L"" : (L":" + c3) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return c1 + (c3.empty() ? L"" : (L":" + c3) );
|
||||
}
|
||||
}
|
||||
else if (sz == 5 && !what[1].matched)
|
||||
{
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str(); //sheet name 2
|
||||
const std::wstring c3 = what[4].str();
|
||||
|
||||
return c1 + (c3.empty() ? L"" : (L":" + c3) );
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
|
||||
@ -216,10 +233,10 @@ namespace formulasconvert {
|
||||
void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr, bool withTableName)
|
||||
{
|
||||
convert_with_TableName = withTableName;
|
||||
//boost::wregex simpleRef(L"\\[\\.([a-zA-Z]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
|
||||
boost::wregex complexRef(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
|
||||
|
||||
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
|
||||
/*
|
||||
[ $ Sheet2 . A1 : . B5 ]
|
||||
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
|
||||
*/
|
||||
|
||||
const std::wstring res = boost::regex_replace(
|
||||
@ -235,7 +252,7 @@ namespace formulasconvert {
|
||||
|
||||
//boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
|
||||
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}");
|
||||
|
||||
|
||||
const std::wstring res = boost::regex_replace(
|
||||
expr,
|
||||
complexRef,
|
||||
@ -372,30 +389,37 @@ namespace formulasconvert {
|
||||
}
|
||||
|
||||
|
||||
std::wstring forbidden_formulas[] =
|
||||
{
|
||||
L"NULLFORMULA"
|
||||
/*
|
||||
L"BETADIST",
|
||||
L"CEILING",
|
||||
L"FLOOR",
|
||||
L"RANK",
|
||||
L"ROUND",
|
||||
L"ROUNDDOWN",
|
||||
L"ROUNDUP",
|
||||
L"SUBTOTAL",
|
||||
L"FORMULA",
|
||||
L"ISREF"*/
|
||||
};
|
||||
//std::wstring forbidden_formulas[] =
|
||||
//{
|
||||
// L"NULLFORMULA"
|
||||
// //L"BETADIST",
|
||||
// //L"CEILING",
|
||||
// //L"FLOOR",
|
||||
// //L"RANK",
|
||||
// //L"ROUND",
|
||||
// //L"ROUNDDOWN",
|
||||
// //L"ROUNDUP",
|
||||
// //L"SUBTOTAL",
|
||||
// //L"FORMULA",
|
||||
// //L"ISREF"
|
||||
//};
|
||||
|
||||
bool is_forbidden(const std::wstring & formula)
|
||||
std::wstring is_forbidden(const std::wstring & formula)
|
||||
{
|
||||
BOOST_FOREACH(const std::wstring & s, forbidden_formulas)
|
||||
std::wstring result = formula;
|
||||
std::map<std::wstring, std::wstring> forbidden_formulas;
|
||||
|
||||
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); it++)
|
||||
{
|
||||
if (boost::algorithm::contains(formula, s))
|
||||
return true;
|
||||
if (boost::algorithm::contains(formula, it->first))
|
||||
{
|
||||
|
||||
XmlUtils::replace_all(result, it->first, it->second);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
// заменить вертикальную черту во всех вхождениях в фигурных скобках, но не внутри строк
|
||||
@ -421,10 +445,7 @@ namespace formulasconvert {
|
||||
|
||||
std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
|
||||
{
|
||||
if (is_forbidden(expr))
|
||||
return L"NULLFORMULA()";
|
||||
|
||||
std::wstring workstr = expr;
|
||||
std::wstring workstr = is_forbidden(expr);
|
||||
//boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// Better_Donut.ods- cell(c27)
|
||||
//std::wstring workstr = boost::regex_replace(
|
||||
// expr,
|
||||
@ -475,16 +496,34 @@ namespace formulasconvert {
|
||||
return workstr;
|
||||
}
|
||||
|
||||
void odf2oox_converter::Impl::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
|
||||
{
|
||||
std::wstring workstr = expr;
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
expr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
|
||||
boost::algorithm::split(out, workstr, boost::algorithm::is_any_of(by), boost::algorithm::token_compress_on);
|
||||
|
||||
for (size_t i = 0; i < out.size(); i++)
|
||||
{
|
||||
XmlUtils::replace_all( out[i], L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( out[i], L"TOCHKA", L".");
|
||||
}
|
||||
}
|
||||
|
||||
//Sheet2.C3:Sheet2.C19 Sheet2.L29:Sheet2.L36
|
||||
//в
|
||||
//Sheet2!C3:C19,Sheet2!L27:L34
|
||||
|
||||
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
|
||||
{
|
||||
if (is_forbidden(expr))
|
||||
return L"NULLFORMULA()";
|
||||
std::wstring workstr = is_forbidden(expr);
|
||||
|
||||
std::wstring workstr = expr;
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
@ -500,25 +539,27 @@ namespace formulasconvert {
|
||||
|
||||
boost::algorithm::split(distance_inp, workstr, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
BOOST_FOREACH(std::wstring &d,distance_inp)
|
||||
for (size_t i = 0; i < distance_inp.size(); i++)
|
||||
{
|
||||
std::wstring sheet;
|
||||
std::vector<std::wstring> range;
|
||||
std::vector<std::wstring> cells;
|
||||
|
||||
boost::algorithm::split(range,d, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(range, distance_inp[i], boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
|
||||
BOOST_FOREACH(std::wstring &c,range)
|
||||
for (size_t j = 0; j < range.size(); j++)
|
||||
{
|
||||
const std::string::size_type colon = c.find('.');
|
||||
cells.push_back(c.substr(colon+1));
|
||||
if (sheet.size()<1)
|
||||
sheet=c.substr(0, colon);
|
||||
const std::string::size_type colon = range[j].find('.');
|
||||
cells.push_back(range[j].substr(colon + 1));
|
||||
if (sheet.size() < 1)
|
||||
{
|
||||
sheet = range[j].substr(0, colon);
|
||||
}
|
||||
}
|
||||
std::wstring cells_out;
|
||||
BOOST_FOREACH(std::wstring &c,cells)
|
||||
for (size_t j = 0; j < cells.size(); j++)
|
||||
{
|
||||
cells_out.append(c);
|
||||
cells_out.append(cells[j]);
|
||||
cells_out.append(L":");
|
||||
}
|
||||
int res1 = sheet.find(L"-");
|
||||
@ -529,19 +570,19 @@ namespace formulasconvert {
|
||||
sheet = L"'" + sheet + L"'";
|
||||
}
|
||||
|
||||
distance_out.push_back(sheet+L"!" + cells_out.substr(0, cells_out.size()-1));
|
||||
distance_out.push_back(sheet + L"!" + cells_out.substr(0, cells_out.size()-1));
|
||||
}
|
||||
std::wstring result;
|
||||
|
||||
BOOST_FOREACH(std::wstring &d, distance_out)
|
||||
for (size_t i = 0; i < distance_out.size(); i++)
|
||||
{
|
||||
result.append(d);
|
||||
result.append(distance_out[i]);
|
||||
result.append(L",");
|
||||
}
|
||||
XmlUtils::replace_all( result, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( result, L"TOCHKA" , L".");
|
||||
XmlUtils::replace_all( result, L"TOCHKA", L".");
|
||||
|
||||
return result.substr(0, result.size()-1);// минус последняя лишняя запятая
|
||||
return result.substr(0, result.size() - 1);// минус последняя лишняя запятая
|
||||
}
|
||||
odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl)
|
||||
{
|
||||
@ -551,6 +592,11 @@ namespace formulasconvert {
|
||||
{
|
||||
}
|
||||
|
||||
std::wstring odf2oox_converter::get_table_name()
|
||||
{
|
||||
return impl_->table_name_;
|
||||
}
|
||||
|
||||
std::wstring odf2oox_converter::convert(const std::wstring& expr)
|
||||
{
|
||||
return impl_->convert(expr);
|
||||
@ -559,6 +605,10 @@ namespace formulasconvert {
|
||||
{
|
||||
return impl_->convert_chart_distance(expr);
|
||||
}
|
||||
void odf2oox_converter::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
|
||||
{
|
||||
return impl_->split_distance_by(expr, by, out);
|
||||
}
|
||||
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
|
||||
{
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
@ -582,6 +632,13 @@ namespace formulasconvert {
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
|
||||
|
||||
if (impl_->table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
|
||||
}
|
||||
return workstr;
|
||||
}
|
||||
std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr, bool withTableName)
|
||||
@ -590,34 +647,44 @@ namespace formulasconvert {
|
||||
|
||||
bool isFormula = impl_->check_formula(workstr);
|
||||
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
workstr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
|
||||
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
|
||||
|
||||
impl_->replace_cells_range(workstr, withTableName);
|
||||
impl_->replace_semicolons(workstr);
|
||||
impl_->replace_vertical(workstr);
|
||||
|
||||
int res_find=0;
|
||||
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
|
||||
if (isFormula)
|
||||
{
|
||||
//могут быть частично заданы диапазоны
|
||||
//todooo
|
||||
|
||||
workstr = impl_->convert(expr);
|
||||
}
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
|
||||
|
||||
if (!isFormula)
|
||||
else
|
||||
{
|
||||
workstr = L"\"" + workstr + L"\"";
|
||||
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
workstr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
|
||||
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
|
||||
|
||||
impl_->replace_cells_range(workstr, withTableName);
|
||||
impl_->replace_semicolons(workstr);
|
||||
impl_->replace_vertical(workstr);
|
||||
|
||||
int res_find=0;
|
||||
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
|
||||
{
|
||||
//могут быть частично заданы диапазоны
|
||||
//todooo
|
||||
|
||||
}
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
|
||||
|
||||
if (impl_->table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
|
||||
}
|
||||
}
|
||||
return workstr;
|
||||
}
|
||||
|
||||
@ -65,11 +65,11 @@ public:
|
||||
|
||||
static bool isFindBaseCell_;
|
||||
|
||||
static std::wstring base_cell_formula_;
|
||||
static std::wstring table_name_;
|
||||
};
|
||||
|
||||
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
|
||||
std::wstring oox2odf_converter::Impl::base_cell_formula_ = L"";
|
||||
std::wstring oox2odf_converter::Impl::table_name_ = L"";
|
||||
|
||||
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
|
||||
{
|
||||
@ -117,9 +117,9 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
|
||||
{
|
||||
XmlUtils::replace_all( sheet, L"!", L"");
|
||||
|
||||
if (isFindBaseCell_ && base_cell_formula_.empty() && !sheet.empty())
|
||||
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
|
||||
{
|
||||
base_cell_formula_ = sheet + L".$A$1";
|
||||
table_name_ = sheet + L".$A$1";
|
||||
}
|
||||
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
|
||||
|
||||
@ -161,7 +161,7 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
|
||||
|
||||
void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
|
||||
{
|
||||
base_cell_formula_.clear();
|
||||
table_name_.clear();
|
||||
|
||||
isFindBaseCell_ = true;
|
||||
expr = convert_formula(expr);
|
||||
@ -171,7 +171,7 @@ void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
|
||||
// Лист1!$A$1 -> $Лист1.$A$1
|
||||
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
|
||||
{
|
||||
base_cell_formula_.clear();
|
||||
table_name_.clear();
|
||||
|
||||
isFindBaseCell_ = true;
|
||||
std::wstring workstr = expr, out;
|
||||
@ -207,6 +207,15 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
|
||||
if (!out.empty()) expr = out.substr(0, out.length() - 1);
|
||||
|
||||
isFindBaseCell_ = false;
|
||||
|
||||
if (table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
|
||||
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
|
||||
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -471,6 +480,21 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
|
||||
|
||||
XmlUtils::replace_all( res, L"PROBEL", L" ");
|
||||
|
||||
if (table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
|
||||
|
||||
XmlUtils::replace_all( table_name_, L"KVADRATIN", L"[");
|
||||
XmlUtils::replace_all( table_name_, L"KVADRATOUT", L"]");
|
||||
|
||||
|
||||
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
|
||||
|
||||
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
|
||||
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
|
||||
}
|
||||
|
||||
return std::wstring(L"of:=") + res;
|
||||
|
||||
}
|
||||
@ -614,9 +638,9 @@ std::wstring oox2odf_converter::convert_named_formula(const std::wstring& expr)
|
||||
impl_->replace_named_formula(workstr);
|
||||
return workstr;
|
||||
}
|
||||
std::wstring oox2odf_converter::get_base_cell_formula(const std::wstring& expr)
|
||||
std::wstring oox2odf_converter::get_table_name()
|
||||
{
|
||||
return impl_->base_cell_formula_;
|
||||
return impl_->table_name_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -35,11 +35,15 @@
|
||||
#include "../CPSharedPtr.h"
|
||||
#include "../CPScopedPtr.h"
|
||||
|
||||
|
||||
struct ProgressCallback;
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace xml
|
||||
{
|
||||
class sax;
|
||||
}
|
||||
|
||||
namespace oox {
|
||||
class docx_conversion_context;
|
||||
class xlsx_conversion_context;
|
||||
@ -54,9 +58,10 @@ class odf_document
|
||||
{
|
||||
public:
|
||||
odf_document(const std::wstring & Folder, const ProgressCallback* CallBack);
|
||||
~odf_document();
|
||||
odf_document(xml::sax * Reader);
|
||||
|
||||
~odf_document();
|
||||
|
||||
public:
|
||||
odf_read_context & odf_context();
|
||||
|
||||
bool docx_convert(oox::docx_conversion_context & Context);
|
||||
@ -77,6 +82,7 @@ private:
|
||||
_CP_SCOPED_PTR(Impl) impl_;
|
||||
|
||||
};
|
||||
typedef shared_ptr<odf_document>::Type odf_document_ptr;
|
||||
|
||||
}
|
||||
}
|
||||
@ -217,6 +217,7 @@ SOURCES += \
|
||||
../src/odf/datatypes/tableorientation.cpp \
|
||||
../src/odf/datatypes/tablefunction.cpp \
|
||||
../src/odf/datatypes/tableorder.cpp \
|
||||
../src/odf/datatypes/dategroup.cpp \
|
||||
../src/docx/xlsx_conditionalFormatting.cpp \
|
||||
../src/docx/xlsx_dxfs.cpp \
|
||||
../src/docx/docx_content_type.cpp \
|
||||
|
||||
@ -126,3 +126,4 @@
|
||||
#include "../src/odf/datatypes/tableorientation.cpp"
|
||||
#include "../src/odf/datatypes/tablefunction.cpp"
|
||||
#include "../src/odf/datatypes/tableorder.cpp"
|
||||
#include "../src/odf/datatypes/dategroup.cpp"
|
||||
|
||||
@ -97,14 +97,6 @@ HRESULT ConvertOO2OOX(const std::wstring & srcPath, const std::wstring & dstPath
|
||||
|
||||
if (encrypted) return AVS_ERROR_DRM;
|
||||
|
||||
//if (type<1)
|
||||
//{
|
||||
// if (ext == L".odt")type = 1;
|
||||
// if (ext == L".ods")type = 2;
|
||||
// if (ext == L".odp")type = 3;
|
||||
|
||||
//}
|
||||
|
||||
if (bOnlyPresentation && type != 3)return AVS_ERROR_UNEXPECTED;
|
||||
|
||||
switch (type)
|
||||
|
||||
@ -127,6 +127,7 @@ public:
|
||||
if (sExt == L"m4v") return typeVideo;
|
||||
if (sExt == L"mp4") return typeVideo;
|
||||
if (sExt == L"mov") return typeVideo;
|
||||
if (sExt == L"mkv") return typeVideo;
|
||||
|
||||
return typeMedia;
|
||||
}
|
||||
|
||||
@ -118,6 +118,23 @@ void oox_chart_context::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"val",L"en-US");
|
||||
}
|
||||
|
||||
if (pivot_source_.empty() == false)
|
||||
{
|
||||
set_cache_only(true);
|
||||
|
||||
CP_XML_NODE(L"c:pivotSource")
|
||||
{
|
||||
CP_XML_NODE(L"c:name")
|
||||
{
|
||||
CP_XML_STREAM() << pivot_source_;
|
||||
}
|
||||
CP_XML_NODE(L"c:fmtId")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"c:chart")
|
||||
{
|
||||
if (plot_area_.current_chart_->is3D_)
|
||||
@ -148,10 +165,42 @@ void oox_chart_context::serialize(std::wostream & strm)
|
||||
shape.set(graphic_properties_, fill_);
|
||||
shape.oox_serialize(CP_XML_STREAM());
|
||||
|
||||
|
||||
if (pivot_source_.empty() == false)
|
||||
{
|
||||
CP_XML_NODE(L"c:extLst")
|
||||
{
|
||||
CP_XML_NODE(L"c:ext")
|
||||
{
|
||||
CP_XML_ATTR(L"uri", L"{781A3756-C4B2-4CAC-9D66-4F8BD8637D16}");
|
||||
CP_XML_ATTR(L"xmlns:c14", L"http://schemas.microsoft.com/office/drawing/2007/8/2/chart");
|
||||
CP_XML_NODE(L"c14:pivotOptions")
|
||||
{
|
||||
CP_XML_NODE(L"c14:dropZoneFilter")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
}
|
||||
CP_XML_NODE(L"c14:dropZoneCategories")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
}
|
||||
CP_XML_NODE(L"c14:dropZoneData")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
}
|
||||
CP_XML_NODE(L"c14:dropZoneSeries")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
}
|
||||
CP_XML_NODE(L"c14:dropZonesVisible")
|
||||
{
|
||||
CP_XML_ATTR(L"val", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
oox_chart_context::~oox_chart_context()
|
||||
@ -160,7 +209,7 @@ oox_chart_context::~oox_chart_context()
|
||||
|
||||
void oox_chart_context::set_cache_only (bool val)
|
||||
{
|
||||
for (int i = 0 ; i < plot_area_.charts_.size(); i++)
|
||||
for (size_t i = 0 ; i < plot_area_.charts_.size(); i++)
|
||||
{
|
||||
plot_area_.charts_[i]->set_cache_only(val);
|
||||
}
|
||||
|
||||
@ -63,6 +63,10 @@ public:
|
||||
void serialize(std::wostream & strm);
|
||||
void dump_rels(rels & Rels);
|
||||
|
||||
void set_pivot_chart(const std::wstring &source)
|
||||
{
|
||||
pivot_source_ = source;
|
||||
}
|
||||
void set_title(odf_reader::chart::title & t)
|
||||
{
|
||||
title_.set_content(t);
|
||||
@ -130,6 +134,8 @@ private:
|
||||
cpdoccore::oox::oox_plot_area plot_area_;
|
||||
cpdoccore::oox::oox_chart_legend legend_;
|
||||
|
||||
std::wstring pivot_source_;
|
||||
|
||||
std::vector<odf_reader::_property> graphic_properties_;
|
||||
_oox_fill fill_;
|
||||
};
|
||||
|
||||
@ -37,6 +37,8 @@
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
#include "../odf/style_text_properties.h"
|
||||
|
||||
#include "xlsx_utils.h"
|
||||
|
||||
#include "oox_chart_series.h"
|
||||
#include "../formulasconvert/formulasconvert.h"
|
||||
|
||||
@ -258,8 +260,11 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
|
||||
CP_XML_ATTR(L"idx", j);
|
||||
double val = 0;
|
||||
|
||||
try { val = boost::lexical_cast<double>(v);}
|
||||
catch(...){}
|
||||
if (oox::IsNumber(v))
|
||||
{
|
||||
try { val = boost::lexical_cast<double>(v);}
|
||||
catch(...){}
|
||||
}
|
||||
CP_XML_NODE(L"c:v")
|
||||
{
|
||||
CP_XML_CONTENT(val);
|
||||
@ -293,8 +298,11 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
|
||||
CP_XML_ATTR(L"idx", j);
|
||||
double val = 0;
|
||||
|
||||
try { val = boost::lexical_cast<double>(v);}
|
||||
catch(...){}
|
||||
if (oox::IsNumber(v))
|
||||
{
|
||||
try { val = boost::lexical_cast<double>(v);}
|
||||
catch(...){}
|
||||
}
|
||||
CP_XML_NODE(L"c:v")
|
||||
{
|
||||
CP_XML_CONTENT(val);
|
||||
|
||||
@ -171,7 +171,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
|
||||
if ( color.empty() )
|
||||
{
|
||||
if (always_draw) color = L"000000";
|
||||
else color = L"ffffff";
|
||||
else color = L"FFFFFFFF";
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"a:srgbClr")
|
||||
@ -232,11 +232,11 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
|
||||
if (values[i].empty()) continue;
|
||||
CP_XML_NODE(L"a:gd")
|
||||
{
|
||||
if (values.size() > 1 || bModifiers)
|
||||
//if (values.size() > 1 || bModifiers)
|
||||
//весьма странное .. для некоторых модификаторов (напр math...) нужно указывать множественность их
|
||||
CP_XML_ATTR(L"name", L"adj" + std::to_wstring(i+1));
|
||||
else
|
||||
CP_XML_ATTR(L"name", L"adj");
|
||||
//else
|
||||
// CP_XML_ATTR(L"name", L"adj");
|
||||
|
||||
CP_XML_ATTR(L"fmla", L"val " + values[i]);
|
||||
}
|
||||
@ -263,8 +263,8 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
|
||||
odf_reader::GetProperty(prop,L"text-padding-bottom" , dPaddingBottom);
|
||||
|
||||
if (dPaddingLeft) CP_XML_ATTR(L"lIns", (int)(*dPaddingLeft));
|
||||
if (dPaddingRight) CP_XML_ATTR(L"rIns", (int)(*dPaddingRight));
|
||||
if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop));
|
||||
if (dPaddingRight) CP_XML_ATTR(L"rIns", (int)(*dPaddingRight));
|
||||
if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom));
|
||||
|
||||
if (inGroup == false)
|
||||
|
||||
@ -168,7 +168,7 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val)
|
||||
{
|
||||
if (val.bitmap->isInternal)
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
//CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
CP_XML_ATTR(L"r:embed", val.bitmap->rId );
|
||||
}
|
||||
else
|
||||
|
||||
@ -81,6 +81,7 @@ static std::wstring get_mime_type(const std::wstring & extension)
|
||||
else if (L"mov" == extension) return L"video/unknown";
|
||||
else if (L"mp4" == extension) return L"video/unknown";
|
||||
else if (L"m4v" == extension) return L"video/unknown";
|
||||
else if (L"mkv" == extension) return L"video/unknown";
|
||||
|
||||
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
|
||||
else if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
|
||||
@ -74,6 +74,8 @@ xlsx_document::xlsx_document()
|
||||
|
||||
void xlsx_document::write(const std::wstring & RootPath)
|
||||
{
|
||||
_CP_LOG << L"[info][xlsx] process writing" << std::endl;
|
||||
|
||||
xl_files_.write (RootPath);
|
||||
docProps_files_.write (RootPath);
|
||||
rels_files_.write (RootPath);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -49,14 +49,36 @@ public:
|
||||
void start_table();
|
||||
int end_table();
|
||||
|
||||
void start_field();
|
||||
void start_field ();
|
||||
void set_field_name (std::wstring name);
|
||||
void set_field_type (int type, int hierarchy);
|
||||
void set_field_function (int type);
|
||||
void set_field_user_function (std::wstring f);
|
||||
void add_field_subtotal (int function_type);
|
||||
void add_field_cache (int index, std::wstring value);
|
||||
void set_field_show_empty (bool val);
|
||||
void set_field_data_layout (bool val);
|
||||
void set_field_sort (int type);
|
||||
void set_field_groups (int type);
|
||||
void set_repeat_item_labels(bool val);
|
||||
void end_field();
|
||||
|
||||
//int add_view(int indexCache);
|
||||
int get_view_count();
|
||||
int get_count();
|
||||
|
||||
void add_cache(std::wstring definitions, std::wstring records);
|
||||
int get_cache_count();
|
||||
void set_view_name(std::wstring name);
|
||||
void set_view_target_range(std::wstring ref);
|
||||
void set_view_target_table_name(std::wstring name);
|
||||
|
||||
void add_button_header(std::wstring ref);
|
||||
|
||||
void set_identify_categories(bool val);
|
||||
void set_drill(bool val);
|
||||
|
||||
void set_source_range(std::wstring table_name, std::wstring ref);
|
||||
|
||||
void set_source_database(std::wstring database, std::wstring table_name);
|
||||
void set_source_database_query(std::wstring database, std::wstring query);
|
||||
void set_source_database_sql(std::wstring database, std::wstring sql);
|
||||
|
||||
void write_cache_definitions_to (int index, std::wostream & strm);
|
||||
void write_cache_records_to (int index, std::wostream & strm);
|
||||
@ -67,12 +89,11 @@ public:
|
||||
void dump_rels_cache(int index, rels & Rels);
|
||||
void dump_rels_view (int index, rels & Rels);
|
||||
|
||||
std::wstring get_chart_source(std::wstring name);
|
||||
|
||||
void add_connections(std::wstring connections);
|
||||
bool is_connections();
|
||||
|
||||
std::wostream & stream_view();
|
||||
std::wostream & stream_cache();
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
_CP_PTR(Impl) impl_;
|
||||
|
||||
@ -160,7 +160,10 @@ void xlsx_table_state::set_table_row_group(int count, bool collapsed, int level)
|
||||
group_row_.collapsed = collapsed;
|
||||
group_row_.level = level;
|
||||
}
|
||||
|
||||
void xlsx_table_state::add_empty_row(int count)
|
||||
{
|
||||
current_table_row_ += count;
|
||||
}
|
||||
void xlsx_table_state::start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName)
|
||||
{
|
||||
empty_row_ = true;
|
||||
@ -391,6 +394,7 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
|
||||
{
|
||||
CP_XML_NODE(L"dimension")
|
||||
{
|
||||
if (current_table_column_ < 0) current_table_column_ = columns_count_;
|
||||
std::wstring ref2 = getCellAddress( current_table_column_, current_table_row_);
|
||||
CP_XML_ATTR(L"ref", L"A1:" + ref2);
|
||||
}
|
||||
@ -430,10 +434,10 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
|
||||
{
|
||||
CP_XML_NODE(L"selection")
|
||||
{
|
||||
CP_XML_ATTR(L"sqref", getCellAddress(col, row));
|
||||
CP_XML_ATTR(L"activeCellId", 0);
|
||||
CP_XML_ATTR(L"activeCell", getCellAddress(col, row));
|
||||
CP_XML_ATTR(L"activeCellId", 0);
|
||||
CP_XML_ATTR(L"pane", L"topLeft");
|
||||
CP_XML_ATTR(L"sqref", getCellAddress(col, row));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -89,6 +89,8 @@ public:
|
||||
void non_empty_row ();
|
||||
bool is_empty_row () const;
|
||||
void end_row ();
|
||||
|
||||
void add_empty_row(int count);
|
||||
|
||||
std::wstring current_row_style () const;
|
||||
std::wstring default_row_cell_style () const;
|
||||
|
||||
@ -148,9 +148,9 @@ void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableS
|
||||
|
||||
void xlsx_table_context::end_table()
|
||||
{
|
||||
xlsx_table_states_.pop_back();
|
||||
//xlsx_table_states_.pop_back();
|
||||
}
|
||||
|
||||
|
||||
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
|
||||
{
|
||||
state()->start_cell(columnsSpanned, rowsSpanned);
|
||||
|
||||
@ -48,7 +48,6 @@ class xlsx_table_context
|
||||
public:
|
||||
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
|
||||
|
||||
public:
|
||||
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
|
||||
void end_table();
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "xlsx_utils.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
@ -46,6 +45,14 @@ namespace cpdoccore {
|
||||
|
||||
namespace oox {
|
||||
|
||||
bool IsNumber(const std::wstring &value)
|
||||
{
|
||||
boost::wregex rule(L"\\-?^[0-9]*[.,]?[0-9]*$");
|
||||
boost::match_results<std::wstring::const_iterator> results;
|
||||
|
||||
return boost::regex_search(value/*.begin(), value.end(), results*/, rule);
|
||||
}
|
||||
|
||||
std::wstring getColAddress(size_t col)
|
||||
{
|
||||
static const size_t r = (L'Z' - L'A' + 1);
|
||||
@ -62,8 +69,6 @@ std::wstring getColAddress(size_t col)
|
||||
return std::wstring(1, (wchar_t)(L'A' + col));
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::wstring getRowAddress(size_t row)
|
||||
{
|
||||
return std::to_wstring(row + 1);
|
||||
|
||||
@ -40,6 +40,8 @@ namespace cpdoccore {
|
||||
|
||||
namespace oox {
|
||||
|
||||
bool IsNumber(const std::wstring &value);
|
||||
|
||||
std::wstring getColAddress(size_t col);
|
||||
std::wstring getRowAddress(size_t row);
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ void xlsx_conversion_context::end_document()
|
||||
|
||||
get_xlsx_defined_names().xlsx_serialize(CP_XML_STREAM());
|
||||
|
||||
int pivot_cache_count = xlsx_pivots_context_.get_cache_count();
|
||||
int pivot_cache_count = xlsx_pivots_context_.get_count();
|
||||
if (pivot_cache_count > 0)
|
||||
{
|
||||
CP_XML_NODE(L"pivotCaches")
|
||||
@ -259,7 +259,7 @@ void xlsx_conversion_context::end_document()
|
||||
}
|
||||
}
|
||||
}
|
||||
int pivot_view_count = xlsx_pivots_context_.get_view_count();
|
||||
int pivot_view_count = xlsx_pivots_context_.get_count();
|
||||
if (pivot_view_count > 0)
|
||||
{
|
||||
for (int i = 0; i < pivot_view_count; i++)
|
||||
@ -363,17 +363,33 @@ oox_chart_context & xlsx_conversion_context::current_chart()
|
||||
throw std::runtime_error("internal error");
|
||||
}
|
||||
}
|
||||
xlsx_xml_worksheet & xlsx_conversion_context::current_sheet()
|
||||
xlsx_xml_worksheet & xlsx_conversion_context::current_sheet(int index)
|
||||
{
|
||||
if (!sheets_.empty())
|
||||
{
|
||||
return *sheets_.back().get();
|
||||
if (index < 0) return *sheets_.back().get();
|
||||
else return *sheets_[index].get();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("internal error");
|
||||
}
|
||||
}
|
||||
int xlsx_conversion_context::find_sheet_by_name(std::wstring tableName)
|
||||
{
|
||||
if (tableName.empty()) return -1;
|
||||
|
||||
if (0 == tableName.find(L"'"))
|
||||
{
|
||||
tableName = tableName.substr(1, tableName.length() - 2);
|
||||
}
|
||||
for (size_t i = 0; i < sheets_.size(); i++)
|
||||
{
|
||||
if (sheets_[i]->name() == tableName)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void xlsx_conversion_context::create_new_sheet(std::wstring const & name)
|
||||
{
|
||||
sheets_.push_back(xlsx_xml_worksheet::create(name));
|
||||
@ -431,6 +447,18 @@ void xlsx_conversion_context::end_table()
|
||||
get_table_context().dump_rels_hyperlinks (current_sheet().sheet_rels());
|
||||
get_table_context().dump_rels_ole_objects (current_sheet().sheet_rels());
|
||||
|
||||
typedef std::multimap<std::wstring, int> _mapPivotsTableView;
|
||||
std::pair<_mapPivotsTableView::iterator, _mapPivotsTableView::iterator> range;
|
||||
|
||||
range = mapPivotsTableView_.equal_range(current_sheet().name());
|
||||
|
||||
for (_mapPivotsTableView::iterator it = range.first; it != range.second; ++it)
|
||||
{
|
||||
current_sheet().sheet_rels().add(oox::relationship(L"pvId" + std::to_wstring(it->second),
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
|
||||
L"../pivotTables/pivotTable" + std::to_wstring(it->second) + L".xml"));
|
||||
}
|
||||
|
||||
if (!get_drawing_context().empty())
|
||||
{
|
||||
std::wstringstream strm;
|
||||
@ -686,6 +714,10 @@ void xlsx_conversion_context::end_hyperlink(std::wstring const & href)
|
||||
xlsx_text_context_.end_span2();
|
||||
}
|
||||
}
|
||||
void xlsx_conversion_context::add_pivot_sheet_source (const std::wstring & sheet_name, int index_table_view)
|
||||
{//ващето в либре жесткая привязка что на одном листе тока одна сводная может быть ..
|
||||
mapPivotsTableView_.insert(std::make_pair(sheet_name, index_table_view));
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::start_conditional_format(std::wstring ref)
|
||||
{
|
||||
|
||||
@ -102,7 +102,10 @@ public:
|
||||
bool start_table (std::wstring tableName, std::wstring tableStyleName);
|
||||
void end_table ();
|
||||
|
||||
void start_table_column (unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax);
|
||||
int find_sheet_by_name(std::wstring tableName);
|
||||
xlsx_xml_worksheet & current_sheet(int index = -1);
|
||||
|
||||
void start_table_column (unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax);
|
||||
void table_column_last_width (double w);
|
||||
double table_column_last_width ();
|
||||
void end_table_column ();
|
||||
@ -134,6 +137,8 @@ public:
|
||||
void end_hyperlink (std::wstring const & href);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
void add_pivot_sheet_source (const std::wstring & sheet_name, int index_table_view);
|
||||
|
||||
void start_conditional_format (std::wstring ref);
|
||||
void end_conditional_format (){}
|
||||
|
||||
@ -162,7 +167,6 @@ public:
|
||||
xlsx_table_context & get_table_context() { return xlsx_table_context_; }
|
||||
const xlsx_table_context & get_table_context() const { return xlsx_table_context_; }
|
||||
xlsx_style_manager & get_style_manager() { return xlsx_style_; }
|
||||
xlsx_xml_worksheet & current_sheet();
|
||||
|
||||
oox_chart_context & current_chart();
|
||||
math_context & get_math_context() { return math_context_; }
|
||||
@ -198,6 +202,7 @@ private:
|
||||
num_format_context num_format_context_;
|
||||
size_t default_style_;
|
||||
mediaitems mediaitems_;
|
||||
std::multimap<std::wstring, int> mapPivotsTableView_;
|
||||
|
||||
xlsx_style_manager xlsx_style_;
|
||||
xlsx_defined_names xlsx_defined_names_;
|
||||
|
||||
@ -77,6 +77,15 @@ typedef shared_ptr<const office_element>::Type office_element_ptr_const;
|
||||
|
||||
// Класс для конструирования чартов
|
||||
using namespace chart;
|
||||
|
||||
void object_odf_context::set_pivot_source(std::wstring const & val)
|
||||
{
|
||||
pivot_source_ = val;
|
||||
if (pivot_source_.empty() == false)
|
||||
{
|
||||
bPivotChart_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void object_odf_context::set_width(double valPt)
|
||||
{
|
||||
@ -167,6 +176,11 @@ void object_odf_context::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (object_type_ == 1)
|
||||
{
|
||||
if (pivot_source_.empty() == false)
|
||||
{
|
||||
pivot_source_ = Context.get_pivots_context().get_chart_source(pivot_source_);
|
||||
|
||||
}
|
||||
Context.start_chart(L"");
|
||||
oox::oox_chart_context & chart = Context.current_chart();
|
||||
|
||||
@ -266,23 +280,60 @@ void object_odf_context::calc_cache_series(std::wstring adress, std::vector<std:
|
||||
{
|
||||
if (adress.empty()) return;
|
||||
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
|
||||
std::wstring ref_1, ref_2, table;
|
||||
size_t col_1=0, row_1=0, col_2=0, row_2=0;
|
||||
|
||||
if (!converter.find_first_last_ref(adress, table, ref_1, ref_2))return;
|
||||
//if ((res = table.find(L"local-table"))<0)return;
|
||||
|
||||
oox::getCellAddressInv(ref_1, col_1,row_1);
|
||||
oox::getCellAddressInv(ref_2, col_2,row_2);
|
||||
|
||||
for (size_t i = 0; i < cash_values.size(); i++)
|
||||
if (bPivotChart_)
|
||||
{
|
||||
if (cash_values[i].col >= col_1 && cash_values[i].col <= col_2 &&
|
||||
cash_values[i].row >= row_1 && cash_values[i].row <= row_2)
|
||||
std::map<std::wstring, _cell>::iterator pFind = cash_pivot.find(adress);
|
||||
if (pFind != cash_pivot.end())
|
||||
{
|
||||
cash.push_back(cash_values[i].val);
|
||||
int col = pFind->second.col;
|
||||
int row = pFind->second.row;
|
||||
|
||||
if (col == 0 || row == 0)
|
||||
{
|
||||
for (size_t i = 0; i < cash_values.size(); i++)
|
||||
{
|
||||
if (col == 0)
|
||||
{
|
||||
if (cash_values[i].col == col)
|
||||
{
|
||||
cash.push_back(cash_values[i].val);
|
||||
}
|
||||
}
|
||||
if (row == 0)
|
||||
{
|
||||
if (cash_values[i].row == row)
|
||||
{
|
||||
cash.push_back(cash_values[i].val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cash.push_back(pFind->second.val);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
|
||||
std::wstring ref_1, ref_2, table;
|
||||
size_t col_1 = 0, row_1 = 0, col_2 = 0, row_2 = 0;
|
||||
|
||||
if (!converter.find_first_last_ref(adress, table, ref_1, ref_2))return;
|
||||
//if ((res = table.find(L"local-table"))<0)return;
|
||||
|
||||
oox::getCellAddressInv(ref_1, col_1, row_1);
|
||||
oox::getCellAddressInv(ref_2, col_2, row_2);
|
||||
|
||||
for (size_t i = 0; i < cash_values.size(); i++)
|
||||
{
|
||||
if (cash_values[i].col >= col_1 && cash_values[i].col <= col_2 &&
|
||||
cash_values[i].row >= row_1 && cash_values[i].row <= row_2)
|
||||
{
|
||||
cash.push_back(cash_values[i].val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -297,6 +348,8 @@ struct axises_sort
|
||||
|
||||
void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
{
|
||||
chart_context.set_pivot_chart (pivot_source_);
|
||||
|
||||
chart_context.set_title (title_);
|
||||
chart_context.set_wall (wall_);
|
||||
chart_context.set_floor (floor_);
|
||||
@ -370,30 +423,36 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
|
||||
{
|
||||
if (last_set_type == chart_bubble)
|
||||
{ //bubble(x)
|
||||
current->set_formula_series(4, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(4, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (4, domain_cash);
|
||||
//y
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (3, cell_cash);
|
||||
}
|
||||
else
|
||||
{ //x
|
||||
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (2, domain_cash);
|
||||
//y
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series (3, cell_cash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //common
|
||||
current->set_formula_series(1, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(1, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true));
|
||||
current->set_values_series(1, cell_cash);
|
||||
}
|
||||
|
||||
if (categories_.empty() == false)//названия
|
||||
{
|
||||
current->set_formula_series(0, categories_[0], L"General", true);
|
||||
if (!bPivotChart_)
|
||||
current->set_formula_series(0, categories_[0], L"General", true);
|
||||
current->set_values_series(0, cat_cash);
|
||||
}
|
||||
current->set_name(series_[i].name_);
|
||||
@ -560,7 +619,13 @@ void process_build_object::on_not_impl(std::string const & message)
|
||||
_CP_LOG << L"[process_object visitor] : not impliment for \"" << utf8_to_utf16(message) << L"\"" << std::endl;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------------
|
||||
void process_build_object::visit(office_document & val)
|
||||
{
|
||||
if (val.office_body_)
|
||||
val.office_body_->accept(*this);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const office_document_content& val)
|
||||
{
|
||||
if (val.office_body_)
|
||||
@ -599,18 +664,21 @@ void process_build_object::visit(const chart_chart& val)
|
||||
{
|
||||
object_odf_context_.object_type_ = 1;
|
||||
|
||||
if (val.chart_chart_attlist_.common_draw_size_attlist_.svg_width_)
|
||||
if (val.attlist_.common_draw_size_attlist_.svg_width_)
|
||||
{
|
||||
object_odf_context_.set_width(val.chart_chart_attlist_.common_draw_size_attlist_.svg_width_->get_value_unit(length::pt));
|
||||
object_odf_context_.set_width(val.attlist_.common_draw_size_attlist_.svg_width_->get_value_unit(length::pt));
|
||||
}
|
||||
|
||||
if (val.chart_chart_attlist_.common_draw_size_attlist_.svg_height_)
|
||||
if (val.attlist_.common_draw_size_attlist_.svg_height_)
|
||||
{
|
||||
object_odf_context_.set_height(val.chart_chart_attlist_.common_draw_size_attlist_.svg_height_->get_value_unit(length::pt));
|
||||
object_odf_context_.set_height(val.attlist_.common_draw_size_attlist_.svg_height_->get_value_unit(length::pt));
|
||||
}
|
||||
ApplyGraphicProperties (val.chart_chart_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.chart_graphic_properties_, object_odf_context_.chart_fill_);
|
||||
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.chart_graphic_properties_, object_odf_context_.chart_fill_);
|
||||
|
||||
object_odf_context_.set_class(val.chart_chart_attlist_.chart_class_);
|
||||
object_odf_context_.set_class(val.attlist_.chart_class_);
|
||||
|
||||
if (val.attlist_.loext_data_pilot_source_)
|
||||
object_odf_context_.set_pivot_source(*val.attlist_.loext_data_pilot_source_);
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
|
||||
@ -626,13 +694,13 @@ void process_build_object::visit(const chart_title& val)
|
||||
val.text_p_->text_to_stream(v);
|
||||
t.content_ = v.str();
|
||||
}
|
||||
ApplyTextProperties(val.chart_title_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), t.text_properties_);
|
||||
ApplyTextProperties(val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), t.text_properties_);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
if (val.chart_title_attlist_.common_draw_position_attlist_.svg_x_)
|
||||
if (val.attlist_.common_draw_position_attlist_.svg_x_)
|
||||
{
|
||||
t.pos_x = val.chart_title_attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
|
||||
t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
|
||||
t.pos_x = val.attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
|
||||
t.pos_y = val.attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
|
||||
}
|
||||
t.bEnabled = true;
|
||||
|
||||
@ -650,10 +718,10 @@ void process_build_object::visit(const chart_subtitle & val)
|
||||
val.text_p_->text_to_stream(v);
|
||||
t.content_ = v.str();
|
||||
|
||||
if (val.chart_title_attlist_.common_draw_position_attlist_.svg_x_)
|
||||
if (val.attlist_.common_draw_position_attlist_.svg_x_)
|
||||
{
|
||||
t.pos_x = val.chart_title_attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
|
||||
t.pos_y = val.chart_title_attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
|
||||
t.pos_x = val.attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
|
||||
t.pos_y = val.attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
|
||||
}
|
||||
t.bEnabled = true;
|
||||
object_odf_context_.sub_title_ = t;
|
||||
@ -672,32 +740,32 @@ void process_build_object::visit(const chart_legend& val)
|
||||
{
|
||||
object_odf_context_.legend_.bEnabled = true;
|
||||
|
||||
ApplyChartProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.properties_);
|
||||
ApplyGraphicProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.graphic_properties_,object_odf_context_.legend_.fill_);
|
||||
ApplyTextProperties (val.chart_legend_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.text_properties_);
|
||||
ApplyChartProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.properties_);
|
||||
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.graphic_properties_,object_odf_context_.legend_.fill_);
|
||||
ApplyTextProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.legend_.text_properties_);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_plot_area& val)
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
|
||||
object_odf_context_.plot_area_.cell_range_address_ = val.chart_plot_area_attlist_.table_cell_range_address_.get_value_or(L"");
|
||||
object_odf_context_.plot_area_.cell_range_address_ = val.attlist_.table_cell_range_address_.get_value_or(L"");
|
||||
|
||||
ApplyChartProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.properties_);
|
||||
ApplyGraphicProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.graphic_properties_, object_odf_context_.plot_area_.fill_);
|
||||
ApplyTextProperties (val.chart_plot_area_attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.text_properties_);
|
||||
ApplyChartProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.properties_);
|
||||
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.graphic_properties_, object_odf_context_.plot_area_.fill_);
|
||||
ApplyTextProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""),object_odf_context_.plot_area_.text_properties_);
|
||||
}
|
||||
|
||||
|
||||
void process_build_object::visit(const chart_axis& val)
|
||||
{
|
||||
object_odf_context_.start_axis(val.chart_axis_attlist_.chart_dimension_.get_value_or(L""),
|
||||
val.chart_axis_attlist_.chart_name_.get_value_or(L""),
|
||||
val.chart_axis_attlist_.common_attlist_.chart_style_name_.get_value_or(L""));
|
||||
object_odf_context_.start_axis(val.attlist_.chart_dimension_.get_value_or(L""),
|
||||
val.attlist_.chart_name_.get_value_or(L""),
|
||||
val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""));
|
||||
|
||||
ACCEPT_ALL_CONTENT_CONST(val.content_);
|
||||
|
||||
std::wstring style_name = val.chart_axis_attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
|
||||
std::wstring style_name = val.attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
|
||||
|
||||
ApplyChartProperties (style_name, object_odf_context_.axises_.back().properties_);
|
||||
ApplyGraphicProperties (style_name, object_odf_context_.axises_.back().graphic_properties_, object_odf_context_.axises_.back().fill_);
|
||||
@ -708,7 +776,7 @@ void process_build_object::visit(const chart_axis& val)
|
||||
|
||||
void process_build_object::visit(const chart_series& val)
|
||||
{
|
||||
const chart_series_attlist & att = val.chart_series_attlist_;
|
||||
const chart_series_attlist & att = val.attlist_;
|
||||
|
||||
chart::class_type chartClass = get_series_class_type(att.chart_class_.get_value_or(object_odf_context_.str_class_));
|
||||
|
||||
@ -737,21 +805,21 @@ void process_build_object::visit(const chart_domain& val)
|
||||
}
|
||||
void process_build_object::visit(const chart_grid& val)
|
||||
{
|
||||
object_odf_context_.add_grid(val.chart_grid_attlist_.chart_class_.get_value_or(L""),
|
||||
val.chart_grid_attlist_.common_attlist_.chart_style_name_.get_value_or(L"") );
|
||||
object_odf_context_.add_grid(val.attlist_.chart_class_.get_value_or(L""),
|
||||
val.attlist_.common_attlist_.chart_style_name_.get_value_or(L"") );
|
||||
|
||||
oox::_oox_fill fill;
|
||||
|
||||
ApplyGraphicProperties (val.chart_grid_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), (object_odf_context_.axises_.back()).grids_.back().graphic_properties_, fill);
|
||||
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), (object_odf_context_.axises_.back()).grids_.back().graphic_properties_, fill);
|
||||
|
||||
}
|
||||
void process_build_object::visit(const chart_wall& val)
|
||||
{
|
||||
object_odf_context_.wall_.bEnabled = true;
|
||||
|
||||
ApplyChartProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.properties_);
|
||||
ApplyGraphicProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.graphic_properties_,object_odf_context_.wall_.fill_);
|
||||
ApplyTextProperties (val.chart_wall_attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.text_properties_);
|
||||
ApplyChartProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.properties_);
|
||||
ApplyGraphicProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.graphic_properties_,object_odf_context_.wall_.fill_);
|
||||
ApplyTextProperties (val.attlist_.common_attlist_.chart_style_name_.get_value_or(L""), object_odf_context_.wall_.text_properties_);
|
||||
}
|
||||
|
||||
void process_build_object::visit(const chart_floor& val)
|
||||
@ -765,12 +833,12 @@ void process_build_object::visit(const chart_floor& val)
|
||||
|
||||
void process_build_object::visit(const chart_data_point & val)
|
||||
{
|
||||
object_odf_context_.add_point( val.chart_data_point_attlist_.chart_repeated_.get_value_or(1));
|
||||
object_odf_context_.add_point( val.attlist_.chart_repeated_.get_value_or(1));
|
||||
|
||||
if (val.chart_data_point_attlist_.common_attlist_.chart_style_name_)
|
||||
if (val.attlist_.common_attlist_.chart_style_name_)
|
||||
{
|
||||
object_odf_context_.series_.back().points_.back().bEnabled = true;
|
||||
std::wstring style_name = val.chart_data_point_attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
|
||||
std::wstring style_name = val.attlist_.common_attlist_.chart_style_name_.get_value_or(L"");
|
||||
|
||||
ApplyGraphicProperties (style_name, object_odf_context_.series_.back().points_.back().graphic_properties_,
|
||||
object_odf_context_.series_.back().points_.back().fill_);
|
||||
@ -895,12 +963,21 @@ void process_build_object::visit(const table_table_cell& val)
|
||||
|
||||
unsigned int repeated = val.attlist_.table_number_columns_repeated_;
|
||||
|
||||
std::wstringstream wstream_temp;
|
||||
|
||||
val.content_.text_to_stream(wstream_temp);
|
||||
std::wstring cell_cash = wstream_temp.str();
|
||||
|
||||
std::wstring cell_val;
|
||||
std::wstring cell_val, cell_cash, cell_desc;
|
||||
|
||||
for (size_t i = 0 ; i < val.content_.elements_.size(); i++)
|
||||
{
|
||||
std::wstringstream wstream_temp;
|
||||
val.content_.elements_[i]->text_to_stream(wstream_temp);
|
||||
if (val.content_.elements_[i]->get_type() == typeTextP)
|
||||
{
|
||||
cell_cash += wstream_temp.str();
|
||||
}
|
||||
else if (val.content_.elements_[i]->get_type() == typeDrawG)
|
||||
{
|
||||
cell_desc += wstream_temp.str();
|
||||
}
|
||||
}
|
||||
|
||||
if (attlist.common_value_and_type_attlist_.office_value_) cell_val = *attlist.common_value_and_type_attlist_.office_value_;
|
||||
else if (attlist.common_value_and_type_attlist_.office_currency_) cell_val = *attlist.common_value_and_type_attlist_.office_currency_;
|
||||
@ -912,11 +989,16 @@ void process_build_object::visit(const table_table_cell& val)
|
||||
if (cell_cash.empty())
|
||||
cell_cash = cell_val;
|
||||
|
||||
object_odf_context::_cell cell_={object_odf_context_.current_table_column_, object_odf_context_.current_table_row_, cell_cash};
|
||||
object_odf_context::_cell cell_= {object_odf_context_.current_table_column_, object_odf_context_.current_table_row_, cell_cash};
|
||||
|
||||
object_odf_context_.cash_values.push_back(cell_);
|
||||
|
||||
object_odf_context_.current_table_column_+=repeated;
|
||||
|
||||
if (object_odf_context_.bPivotChart_)
|
||||
{
|
||||
object_odf_context_.cash_pivot.insert(std::make_pair(cell_desc, cell_));
|
||||
}
|
||||
}
|
||||
void process_build_object::visit(const table_covered_table_cell& val)
|
||||
{
|
||||
|
||||
@ -111,6 +111,7 @@ public:
|
||||
width_pt_ (0),
|
||||
height_pt_ (0),
|
||||
in_axis_ (false),
|
||||
bPivotChart_ (false),
|
||||
current_table_column_ (0),
|
||||
current_table_row_ (0),
|
||||
columns_spanned_num_ (0),
|
||||
@ -124,6 +125,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void set_pivot_source(std::wstring const & val);
|
||||
|
||||
void set_width(double valPt);
|
||||
|
||||
void set_height(double valPt);
|
||||
@ -170,6 +173,9 @@ public:
|
||||
std::wstring style_name_;
|
||||
std::wstring name_;
|
||||
|
||||
std::wstring pivot_source_;
|
||||
bool bPivotChart_;
|
||||
|
||||
bool in_axis_;
|
||||
std::vector<chart::axis> axises_;
|
||||
std::vector<chart::series> series_;
|
||||
@ -195,6 +201,7 @@ public:
|
||||
oox::_oox_fill chart_fill_;
|
||||
|
||||
std::vector<_cell> cash_values;
|
||||
std::map<std::wstring, _cell>cash_pivot;
|
||||
|
||||
//---------------------------------------
|
||||
std::wstring target_table_;
|
||||
@ -216,6 +223,8 @@ public:
|
||||
|
||||
class process_build_object
|
||||
: public base_visitor,
|
||||
public visitor<office_document>,
|
||||
|
||||
public const_visitor<office_document_content>,
|
||||
public visitor<office_document_content>,
|
||||
|
||||
@ -283,7 +292,8 @@ private:
|
||||
virtual void on_not_impl(std::string const & message);
|
||||
|
||||
public:
|
||||
|
||||
virtual void visit(office_document & val);
|
||||
|
||||
virtual void visit(const office_document_content& val);
|
||||
virtual void visit(office_document_content & val);
|
||||
|
||||
|
||||
@ -86,7 +86,8 @@ const std::wstring color::get_hex_value() const
|
||||
{
|
||||
boost::algorithm::trim(tmp);
|
||||
boost::algorithm::trim_left_if(tmp, boost::algorithm::is_any_of("#"));
|
||||
return tmp;
|
||||
|
||||
return XmlUtils::GetUpper(tmp);
|
||||
}
|
||||
else if (tmp.size() == 6)
|
||||
{
|
||||
@ -96,7 +97,7 @@ const std::wstring color::get_hex_value() const
|
||||
unsigned int t = 0;
|
||||
if ((s << tmp) && (s >> std::hex >> t) && (s >> std::ws).eof())
|
||||
{
|
||||
return tmp;
|
||||
return XmlUtils::GetUpper(tmp);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
|
||||
94
ASCOfficeOdfFile/src/odf/datatypes/dategroup.cpp
Normal file
94
ASCOfficeOdfFile/src/odf/datatypes/dategroup.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* (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 "dategroup.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace cpdoccore { namespace odf_types {
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const date_group & _Val)
|
||||
{
|
||||
switch(_Val.get_type())
|
||||
{
|
||||
case date_group::seconds:
|
||||
_Wostream << L"seconds";
|
||||
break;
|
||||
case date_group::minutes:
|
||||
_Wostream << L"minutes";
|
||||
break;
|
||||
case date_group::hours:
|
||||
_Wostream << L"hours";
|
||||
break;
|
||||
case date_group::days:
|
||||
_Wostream << L"days";
|
||||
break;
|
||||
case date_group::months:
|
||||
_Wostream << L"months";
|
||||
break;
|
||||
case date_group::quarters:
|
||||
_Wostream << L"quarters";
|
||||
break;
|
||||
case date_group::years:
|
||||
_Wostream << L"years";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return _Wostream;
|
||||
}
|
||||
date_group date_group::parse(const std::wstring & Str)
|
||||
{
|
||||
std::wstring tmp = Str;
|
||||
boost::algorithm::to_lower(tmp);
|
||||
|
||||
if (tmp == L"seconds")
|
||||
return date_group( seconds );
|
||||
else if (tmp == L"minutes")
|
||||
return date_group( minutes );
|
||||
else if (tmp == L"hours")
|
||||
return date_group( hours );
|
||||
else if (tmp == L"days")
|
||||
return date_group( days );
|
||||
else if (tmp == L"months")
|
||||
return date_group( months );
|
||||
else if (tmp == L"quarters")
|
||||
return date_group( quarters );
|
||||
else if (tmp == L"years")
|
||||
return date_group( years );
|
||||
else
|
||||
{
|
||||
return date_group( months );
|
||||
}
|
||||
}
|
||||
|
||||
} }
|
||||
@ -1,39 +1,78 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// FontMaps.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
/*
|
||||
* (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 <iosfwd>
|
||||
#include <string>
|
||||
#include "odfattributes.h"
|
||||
|
||||
|
||||
namespace cpdoccore { namespace odf_types {
|
||||
|
||||
class date_group
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
seconds,
|
||||
minutes,
|
||||
hours,
|
||||
days,
|
||||
months,
|
||||
quarters,
|
||||
years
|
||||
};
|
||||
|
||||
date_group() {}
|
||||
|
||||
date_group(type _Type) : type_(_Type)
|
||||
{}
|
||||
|
||||
type get_type() const
|
||||
{
|
||||
return type_;
|
||||
};
|
||||
|
||||
static date_group parse(const std::wstring & Str);
|
||||
|
||||
private:
|
||||
type type_;
|
||||
|
||||
};
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const date_group & _Val);
|
||||
|
||||
}
|
||||
|
||||
APPLY_PARSE_XML_ATTRIBUTES(odf_types::date_group);
|
||||
|
||||
}
|
||||
@ -105,7 +105,10 @@ void draw_image::add_child_element( xml::sax * Reader, const std::wstring & Ns,
|
||||
//CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
}
|
||||
|
||||
std::wostream & draw_image::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
return _Wostream;
|
||||
}
|
||||
// draw:chart
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_chart::ns = L"draw";
|
||||
@ -151,6 +154,13 @@ void draw_g::add_child_element( xml::sax * Reader, const std::wstring & Ns, cons
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
|
||||
std::wostream & draw_g::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(content_);
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
// draw:frame
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * draw_frame::ns = L"draw";
|
||||
@ -261,7 +271,11 @@ void draw_object::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
|
||||
void draw_object::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_NOT_APPLICABLE_ELM(); // TODO
|
||||
if CP_CHECK_NAME(L"office", L"document")
|
||||
{
|
||||
//embedded
|
||||
odf_document_ = odf_document_ptr( new odf_document(Reader));
|
||||
}
|
||||
}
|
||||
|
||||
// draw:object
|
||||
@ -328,8 +342,10 @@ std::wstring draw_object_ole::detectObject(const std::wstring &fileName)
|
||||
}
|
||||
|
||||
|
||||
std::wstring draw_object::office_convert(odf_document * odfDocument, int type)
|
||||
std::wstring draw_object::office_convert(odf_document_ptr odfDocument, int type)
|
||||
{
|
||||
if (!odfDocument) return L"";
|
||||
|
||||
std::wstring href_result;
|
||||
std::wstring folderPath = odfDocument->get_folder();
|
||||
std::wstring objectOutPath = NSDirectory::CreateDirectoryWithUniqueName(folderPath);
|
||||
@ -337,7 +353,7 @@ std::wstring draw_object::office_convert(odf_document * odfDocument, int type)
|
||||
if (type == 1)
|
||||
{
|
||||
oox::package::docx_document outputDocx;
|
||||
oox::docx_conversion_context conversionDocxContext ( odfDocument);
|
||||
oox::docx_conversion_context conversionDocxContext ( odfDocument.get());
|
||||
|
||||
conversionDocxContext.set_output_document (&outputDocx);
|
||||
//conversionContext.set_font_directory (fontsPath);
|
||||
@ -356,7 +372,7 @@ std::wstring draw_object::office_convert(odf_document * odfDocument, int type)
|
||||
if (type == 2)
|
||||
{
|
||||
oox::package::xlsx_document outputXlsx;
|
||||
oox::xlsx_conversion_context conversionXlsxContext ( odfDocument);
|
||||
oox::xlsx_conversion_context conversionXlsxContext ( odfDocument.get());
|
||||
|
||||
conversionXlsxContext.set_output_document (&outputXlsx);
|
||||
//conversionContext.set_font_directory (fontsPath);
|
||||
|
||||
@ -49,13 +49,14 @@ namespace cpdoccore {
|
||||
|
||||
namespace odf_reader {
|
||||
|
||||
/// draw-image-attlist
|
||||
class odf_document;
|
||||
typedef shared_ptr<odf_document>::Type odf_document_ptr;
|
||||
|
||||
class draw_image_attlist
|
||||
{
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_filter_name_;
|
||||
|
||||
};
|
||||
@ -69,7 +70,9 @@ public:
|
||||
static const ElementType type = typeDrawImage;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
@ -79,14 +82,15 @@ private:
|
||||
|
||||
draw_image_attlist draw_image_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
office_element_ptr office_binary_data_;
|
||||
|
||||
office_element_ptr office_binary_data_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_image);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//draw-chart-attlist
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
class draw_chart_attlist
|
||||
{
|
||||
public:
|
||||
@ -134,7 +138,6 @@ class draw_frame_attlist
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) draw_copy_of_;
|
||||
_CP_OPT(odf_types::length_or_percent) fo_min_width_;
|
||||
_CP_OPT(odf_types::length_or_percent) fo_min_height_;
|
||||
@ -191,15 +194,12 @@ private:
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_frame);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
//draw-frame-attlist
|
||||
class draw_g_attlist
|
||||
{
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
};
|
||||
|
||||
|
||||
class draw_g : public office_element_impl<draw_g>
|
||||
{
|
||||
public:
|
||||
@ -209,7 +209,9 @@ public:
|
||||
static const ElementType type = typeDrawG;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
@ -226,7 +228,6 @@ private:
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_g);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// draw-text-box-attlist
|
||||
class draw_text_box_attlist
|
||||
{
|
||||
public:
|
||||
@ -268,7 +269,6 @@ private:
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_text_box);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
/// draw-object-attlist
|
||||
class draw_object_attlist
|
||||
{
|
||||
public:
|
||||
@ -280,7 +280,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
// draw:object
|
||||
class draw_object : public office_element_impl<draw_object>
|
||||
{
|
||||
public:
|
||||
@ -297,16 +296,17 @@ public:
|
||||
draw_object_attlist draw_object_attlist_;
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
|
||||
odf_document_ptr odf_document_;
|
||||
|
||||
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);
|
||||
|
||||
std::wstring office_convert(odf_document * odfDocument, int type);
|
||||
std::wstring office_convert(odf_document_ptr odfDocument, int type);
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object);
|
||||
|
||||
// draw:object-ole
|
||||
class draw_object_ole : public office_element_impl<draw_object>
|
||||
{
|
||||
public:
|
||||
@ -332,7 +332,6 @@ private:
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole);
|
||||
|
||||
// draw:param
|
||||
class draw_param : public office_element_impl<draw_param>
|
||||
{
|
||||
public:
|
||||
@ -356,7 +355,6 @@ private:
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_param);
|
||||
|
||||
// draw:plugin
|
||||
class draw_plugin : public office_element_impl<draw_plugin>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -1408,22 +1408,25 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
if (!odf_document_)
|
||||
{
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
//normalize path ??? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
// normalize path ???? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath ,NULL);
|
||||
odf_document_ = odf_document_ptr(new odf_document(objectPath, NULL));
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
draw_frame* frame = NULL;
|
||||
oox::_docx_drawing * drawing = NULL;
|
||||
office_element* contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
office_element* contentSubDoc = odf_document_ ? odf_document_->get_impl()->get_content() : NULL;
|
||||
|
||||
object_odf_context objectBuild (href);
|
||||
if (contentSubDoc)
|
||||
{
|
||||
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
|
||||
process_build_object process_build_object_(objectBuild, odf_document_->odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
|
||||
objectBuild.docx_convert(Context);
|
||||
@ -1493,7 +1496,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
bool & use_image_replace = Context.get_drawing_context().get_use_image_replace();
|
||||
use_image_replace = true;
|
||||
|
||||
std::wstring href_new = office_convert(&objectSubDoc, 2);
|
||||
std::wstring href_new = office_convert(odf_document_, 2);
|
||||
|
||||
if (!href_new.empty())
|
||||
{
|
||||
|
||||
@ -255,18 +255,22 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
if (!odf_document_)
|
||||
{
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
//normalize path ??? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
// normalize path ???? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath, NULL);
|
||||
odf_document_ = odf_document_ptr(new odf_document(objectPath, NULL));
|
||||
}
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
office_element *contentSubDoc = odf_document_ ? odf_document_->get_impl()->get_content() : NULL;
|
||||
if (!contentSubDoc)
|
||||
{
|
||||
//здесь другой формат xml (не Open Office)
|
||||
@ -275,13 +279,13 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
object_odf_context objectBuild(href);
|
||||
|
||||
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
process_build_object process_build_object_(objectBuild, odf_document_->odf_context() );
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1)//диаграмма
|
||||
{
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"Chart");
|
||||
objectBuild.pptx_convert(Context);
|
||||
|
||||
Context.get_slide_context().set_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
@ -290,7 +294,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href_new = office_convert( &objectSubDoc, 1);
|
||||
std::wstring href_new = office_convert( odf_document_, 1);
|
||||
|
||||
if (!href_new.empty())
|
||||
{
|
||||
@ -324,7 +328,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href_new = office_convert( &objectSubDoc, 2);
|
||||
std::wstring href_new = office_convert( odf_document_, 2);
|
||||
|
||||
if (!href_new.empty())
|
||||
{
|
||||
|
||||
@ -203,8 +203,19 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
const std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
Context.get_drawing_context().set_image(href);
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
if (href.empty() && office_binary_data_)
|
||||
{
|
||||
office_binary_data* binary_data = dynamic_cast<office_binary_data*>(office_binary_data_.get());
|
||||
|
||||
if (binary_data)
|
||||
{
|
||||
href = binary_data->write_to(Context.root()->get_folder());
|
||||
}
|
||||
}
|
||||
|
||||
Context.get_drawing_context().set_image(href);
|
||||
|
||||
////////////////////////////////////в принципе достаточно общая часть ...
|
||||
Context.get_text_context().start_drawing_content();//... если в объекте есть текст он привяжется к объекту - иначе к ячейке
|
||||
@ -246,34 +257,39 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
if (text_content_.length()>0)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"text-content",text_content_));
|
||||
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
|
||||
}
|
||||
}
|
||||
void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
try {
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
try
|
||||
{
|
||||
std::wstring href = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
if (!odf_document_)
|
||||
{
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
std::wstring folderPath = Context.root()->get_folder();
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
// normalize path ???? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
// normalize path ???? todooo
|
||||
XmlUtils::replace_all( objectPath, FILE_SEPARATOR_STR + std::wstring(L"./"), FILE_SEPARATOR_STR);
|
||||
|
||||
cpdoccore::odf_reader::odf_document objectSubDoc(objectPath,NULL);
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
office_element *contentSubDoc = objectSubDoc.get_impl()->get_content();
|
||||
odf_document_ = odf_document_ptr(new odf_document(objectPath, NULL));
|
||||
}
|
||||
office_element *contentSubDoc = odf_document_ ? odf_document_->get_impl()->get_content() : NULL;
|
||||
if (!contentSubDoc)
|
||||
{
|
||||
//здесь другой формат xml (не Open Office)
|
||||
//временно - замещающая картинка(если она конечно присутствует)
|
||||
return;
|
||||
}
|
||||
object_odf_context objectBuild(href);
|
||||
|
||||
if (contentSubDoc)
|
||||
{
|
||||
process_build_object process_build_object_(objectBuild, objectSubDoc.odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
}
|
||||
process_build_object process_build_object_(objectBuild, odf_document_->odf_context() );
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
if (objectBuild.object_type_ == 1) //диаграмма
|
||||
{
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"");
|
||||
const std::wstring href_draw = common_xlink_attlist_.href_.get_value_or(L"chart");
|
||||
objectBuild.xlsx_convert(Context);
|
||||
|
||||
Context.get_drawing_context().set_chart(href_draw); // в рисовательной части только место объекта, рамочки ... и релсы
|
||||
@ -282,7 +298,7 @@ void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().set_use_image_replacement();
|
||||
|
||||
std::wstring href_new = office_convert( &objectSubDoc, 1);
|
||||
std::wstring href_new = office_convert( odf_document_, 1);
|
||||
|
||||
if (!href_new.empty())
|
||||
{
|
||||
|
||||
@ -41,9 +41,22 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
const wchar_t * svg_desc::ns = L"svg";
|
||||
const wchar_t * svg_desc::name = L"desc";
|
||||
|
||||
std::wostream & svg_desc::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
_Wostream << text_ ;
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void svg_desc::add_text(const std::wstring & Text)
|
||||
{
|
||||
text_ = Text;
|
||||
}
|
||||
|
||||
// svg:font-face-uri
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//---------------------------------------------------------------------------------------
|
||||
const wchar_t * svg_font_face_uri::ns = L"svg";
|
||||
const wchar_t * svg_font_face_uri::name = L"font-face-uri";
|
||||
|
||||
|
||||
@ -58,7 +58,6 @@ public:
|
||||
|
||||
odf_types::common_xlink_attlist common_xlink_attlist_;
|
||||
};
|
||||
|
||||
// svg:font-face-uri
|
||||
class svg_font_face_uri : public office_element_impl<svg_font_face_uri>
|
||||
{
|
||||
@ -80,7 +79,31 @@ 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_uri);
|
||||
|
||||
// svg:desc
|
||||
class svg_desc : public office_element_impl<svg_desc>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeSvgDesc;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
std::wstring text_;
|
||||
|
||||
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_REGISTER_OFFICE_ELEMENT2(svg_desc);
|
||||
|
||||
// svg:font-face-format
|
||||
class svg_font_face_format : public office_element_impl<svg_font_face_format>
|
||||
{
|
||||
public:
|
||||
@ -100,7 +123,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_format);
|
||||
|
||||
// svg:font-face-name
|
||||
|
||||
@ -64,7 +64,11 @@ void content_xml_t::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
|
||||
void content_xml_t::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"office", L"document-content")
|
||||
if CP_CHECK_NAME(L"office", L"document")
|
||||
{
|
||||
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"office", L"document-content")
|
||||
{
|
||||
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
|
||||
}
|
||||
@ -84,6 +88,10 @@ void content_xml_t::add_child_element( xml::sax * Reader, const std::wstring & N
|
||||
{
|
||||
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"manifest", L"manifest")
|
||||
{
|
||||
create_element_and_read(Reader, Ns, Name, xml_content_, getContext(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void content_xml_t::add_text(const std::wstring & Text)
|
||||
|
||||
@ -38,7 +38,9 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
odf_document::odf_document(const std::wstring & Folder, const ProgressCallback* CallBack) : impl_(new Impl(Folder,CallBack))
|
||||
odf_document::odf_document(const std::wstring & Folder, const ProgressCallback* CallBack) : impl_(new Impl(Folder, CallBack))
|
||||
{}
|
||||
odf_document::odf_document( xml::sax * Reader) : impl_(new Impl(Reader))
|
||||
{}
|
||||
|
||||
odf_document::~odf_document()
|
||||
|
||||
@ -106,47 +106,122 @@ content_xml_t_ptr read_file_content(const std::wstring & Path)
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
content_xml_t_ptr read_file_content(xml::sax * reader_owner)
|
||||
{
|
||||
if (!reader_owner) return content_xml_t_ptr();
|
||||
|
||||
odf_document::Impl::Impl(const std::wstring & folderPath, const ProgressCallback* CallBack) :
|
||||
context_(new odf_read_context()), base_folder_(folderPath), pCallBack(CallBack), bUserStopConvert (0)
|
||||
content_xml_t_ptr result( new content_xml_t() );
|
||||
|
||||
const std::wstring namespacePrefix = reader_owner->namespacePrefix();
|
||||
const std::wstring localName = reader_owner->nodeLocalName();
|
||||
|
||||
result->add_child_element(reader_owner, namespacePrefix, localName);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
odf_document::Impl::Impl(xml::sax * Reader):
|
||||
context_(new odf_read_context()), base_folder_(L""), pCallBack(NULL), bUserStopConvert (0)
|
||||
{
|
||||
office_mime_type_ = 0;
|
||||
encrypted = false;
|
||||
|
||||
std::wstring content_xml = folderPath + FILE_SEPARATOR_STR + L"content.xml";
|
||||
std::wstring styles_xml = folderPath + FILE_SEPARATOR_STR + L"styles.xml";
|
||||
std::wstring meta_xml = folderPath + FILE_SEPARATOR_STR + L"meta.xml";
|
||||
std::wstring settings_xml = folderPath + FILE_SEPARATOR_STR + L"settings.xml";
|
||||
std::wstring manifest_xml = folderPath + FILE_SEPARATOR_STR + L"META-INF" + FILE_SEPARATOR_STR + L"manifest.xml";
|
||||
content_xml_ = read_file_content(Reader);
|
||||
|
||||
if (content_xml_)
|
||||
{
|
||||
_CP_LOG << L"[info] parse fonts" << std::endl;
|
||||
parse_fonts(content_xml_->get_content());
|
||||
|
||||
_CP_LOG << L"[info] parse styles" << std::endl;
|
||||
parse_styles(content_xml_->get_content());
|
||||
|
||||
_CP_LOG << L"[info] read manifest.xml" << std::endl;
|
||||
manifest_xml_ = read_file_content(manifest_xml);
|
||||
_CP_LOG << L"[info] parse manifest" << std::endl;
|
||||
parse_manifests(content_xml_->get_content());
|
||||
|
||||
_CP_LOG << L"[info] read settings.xml" << std::endl;
|
||||
settings_xml_ = read_file_content(settings_xml);
|
||||
_CP_LOG << L"[info] parse settings" << std::endl;
|
||||
parse_settings(content_xml_->get_content());
|
||||
|
||||
tmp_folder_ = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetTempPath());
|
||||
}
|
||||
}
|
||||
|
||||
_CP_LOG << L"[info] read content.xml" << std::endl;
|
||||
content_xml_ = read_file_content(content_xml);
|
||||
odf_document::Impl::Impl(const std::wstring & srcPath, const ProgressCallback* CallBack) :
|
||||
context_(new odf_read_context()), pCallBack(CallBack), bUserStopConvert (0)
|
||||
{
|
||||
office_mime_type_ = 0;
|
||||
encrypted = false;
|
||||
|
||||
_CP_LOG << L"[info] read styles.xml" << std::endl;
|
||||
styles_xml_ = read_file_content(styles_xml);
|
||||
if (NSDirectory::Exists(srcPath))
|
||||
{
|
||||
base_folder_ = srcPath;
|
||||
|
||||
_CP_LOG << L"[info] parse fonts" << std::endl;
|
||||
parse_fonts();
|
||||
std::wstring content_xml = srcPath + FILE_SEPARATOR_STR + L"content.xml";
|
||||
std::wstring styles_xml = srcPath + FILE_SEPARATOR_STR + L"styles.xml";
|
||||
std::wstring meta_xml = srcPath + FILE_SEPARATOR_STR + L"meta.xml";
|
||||
std::wstring settings_xml = srcPath + FILE_SEPARATOR_STR + L"settings.xml";
|
||||
std::wstring manifest_xml = srcPath + FILE_SEPARATOR_STR + L"META-INF" + FILE_SEPARATOR_STR + L"manifest.xml";
|
||||
|
||||
_CP_LOG << L"[info] parse styles" << std::endl;
|
||||
parse_styles();
|
||||
_CP_LOG << L"[info] read manifest.xml" << std::endl;
|
||||
manifest_xml_ = read_file_content(manifest_xml);
|
||||
|
||||
_CP_LOG << L"[info] parse manifest" << std::endl;
|
||||
parse_manifests();
|
||||
_CP_LOG << L"[info] read settings.xml" << std::endl;
|
||||
settings_xml_ = read_file_content(settings_xml);
|
||||
|
||||
_CP_LOG << L"[info] parse settings" << std::endl;
|
||||
parse_settings();
|
||||
_CP_LOG << L"[info] read content.xml" << std::endl;
|
||||
content_xml_ = read_file_content(content_xml);
|
||||
|
||||
_CP_LOG << L"[info] read styles.xml" << std::endl;
|
||||
styles_xml_ = read_file_content(styles_xml);
|
||||
//----------------------------------------------------------------------------------------
|
||||
_CP_LOG << L"[info] parse fonts" << std::endl;
|
||||
parse_fonts(content_xml_ ? content_xml_->get_content() : NULL);
|
||||
|
||||
_CP_LOG << L"[info] parse styles" << std::endl;
|
||||
parse_styles(styles_xml_ ? styles_xml_->get_content() : NULL);
|
||||
|
||||
_CP_LOG << L"[info] parse manifest" << std::endl;
|
||||
parse_manifests(manifest_xml_ ? manifest_xml_->get_content() : NULL);
|
||||
|
||||
_CP_LOG << L"[info] parse settings" << std::endl;
|
||||
parse_settings(settings_xml_ ? settings_xml_->get_content() : NULL);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_CP_LOG << L"[info] read flat document" << std::endl;
|
||||
content_xml_ = read_file_content(srcPath);
|
||||
|
||||
if (content_xml_)
|
||||
{
|
||||
_CP_LOG << L"[info] parse fonts" << std::endl;
|
||||
parse_fonts(content_xml_->get_content());
|
||||
|
||||
_CP_LOG << L"[info] parse styles" << std::endl;
|
||||
parse_styles(content_xml_->get_content());
|
||||
|
||||
_CP_LOG << L"[info] parse manifest" << std::endl;
|
||||
parse_manifests(content_xml_->get_content());
|
||||
|
||||
_CP_LOG << L"[info] parse settings" << std::endl;
|
||||
parse_settings(content_xml_->get_content());
|
||||
|
||||
tmp_folder_ = NSDirectory::CreateDirectoryWithUniqueName(NSDirectory::GetTempPath());
|
||||
}
|
||||
}
|
||||
|
||||
UpdateProgress(400000);
|
||||
}
|
||||
|
||||
odf_document::Impl::~Impl()
|
||||
{
|
||||
if (!tmp_folder_.empty())
|
||||
NSDirectory::DeleteDirectory(tmp_folder_);
|
||||
}
|
||||
const std::wstring & odf_document::Impl::get_folder() const
|
||||
{
|
||||
if (!base_folder_.empty()) return base_folder_;
|
||||
else return tmp_folder_;
|
||||
}
|
||||
bool odf_document::Impl::UpdateProgress(long nComplete)
|
||||
{
|
||||
if (pCallBack)
|
||||
@ -162,17 +237,11 @@ bool odf_document::Impl::UpdateProgress(long nComplete)
|
||||
return false;
|
||||
}
|
||||
|
||||
void odf_document::Impl::parse_fonts()
|
||||
void odf_document::Impl::parse_fonts(office_element *element)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!content_xml_)
|
||||
{
|
||||
_CP_LOG << L"[warning] empty content xml\n";
|
||||
break;
|
||||
}
|
||||
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( content_xml_->get_content() );
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( element );
|
||||
if (!document)
|
||||
{
|
||||
_CP_LOG << L"[warning] empty document\n";
|
||||
@ -236,15 +305,12 @@ void odf_document::Impl::parse_fonts()
|
||||
}
|
||||
while (0);
|
||||
}
|
||||
void odf_document::Impl::parse_manifests()
|
||||
void odf_document::Impl::parse_manifests(office_element *element)
|
||||
{
|
||||
if (!manifest_xml_)return;
|
||||
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( manifest_xml_->get_content() );
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( element );
|
||||
|
||||
if (!document)return;
|
||||
|
||||
int res =-1;
|
||||
for (size_t i = 0; i < document->manifests_.size(); i++)
|
||||
{
|
||||
office_element_ptr & elm = document->manifests_[i];
|
||||
@ -252,34 +318,44 @@ void odf_document::Impl::parse_manifests()
|
||||
manifest_entry * entry = dynamic_cast<manifest_entry *>(elm.get());
|
||||
if (!entry)continue;
|
||||
|
||||
if (entry->full_path_==L"content.xml" && entry->encryption_) encrypted = true;
|
||||
if (entry->full_path_ == L"content.xml" && entry->encryption_) encrypted = true;
|
||||
|
||||
if (entry->full_path_==L"/")
|
||||
if (entry->full_path_ == L"/")
|
||||
{
|
||||
res = entry->media_type_.find(L"application/vnd.oasis.opendocument.text");
|
||||
if (res>=0)
|
||||
if (std::wstring::npos != entry->media_type_.find(L"application/vnd.oasis.opendocument.text"))
|
||||
{
|
||||
office_mime_type_ = 1;
|
||||
}
|
||||
res = entry->media_type_.find(L"application/vnd.oasis.opendocument.spreadsheet");
|
||||
if (res>=0)
|
||||
else if (std::wstring::npos != entry->media_type_.find(L"application/vnd.oasis.opendocument.spreadsheet"))
|
||||
{
|
||||
office_mime_type_ = 2;
|
||||
}
|
||||
res = entry->media_type_.find(L"application/vnd.oasis.opendocument.presentation");
|
||||
if (res>=0)
|
||||
else if (std::wstring::npos != entry->media_type_.find(L"application/vnd.oasis.opendocument.presentation"))
|
||||
{
|
||||
office_mime_type_ = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!office_mime_type_ && !document->office_mimetype_.empty())
|
||||
{
|
||||
if (std::wstring::npos != document->office_mimetype_.find(L"application/vnd.oasis.opendocument.text"))
|
||||
{
|
||||
office_mime_type_ = 1;
|
||||
}
|
||||
else if (std::wstring::npos != document->office_mimetype_.find(L"application/vnd.oasis.opendocument.spreadsheet"))
|
||||
{
|
||||
office_mime_type_ = 2;
|
||||
}
|
||||
else if (std::wstring::npos != document->office_mimetype_.find(L"application/vnd.oasis.opendocument.presentation"))
|
||||
{
|
||||
office_mime_type_ = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void odf_document::Impl::parse_settings()
|
||||
void odf_document::Impl::parse_settings(office_element *element)
|
||||
{
|
||||
if (!settings_xml_)return;
|
||||
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( settings_xml_->get_content() );
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( element );
|
||||
if (!document) return;
|
||||
|
||||
office_settings * settings = dynamic_cast<office_settings*>(document->office_settings_.get());
|
||||
@ -358,20 +434,14 @@ void odf_document::Impl::parse_settings()
|
||||
}
|
||||
}
|
||||
|
||||
void odf_document::Impl::parse_styles()
|
||||
void odf_document::Impl::parse_styles(office_element *element)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!styles_xml_)
|
||||
{
|
||||
_CP_LOG << L"[warning] empty styles xml\n";
|
||||
break;
|
||||
}
|
||||
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( styles_xml_->get_content() );
|
||||
office_document_base * document = dynamic_cast<office_document_base *>( element );
|
||||
if (!document)
|
||||
{
|
||||
_CP_LOG << L"[warning] empty document\n";
|
||||
_CP_LOG << L"[warning] empty styles\n";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -54,16 +54,19 @@ class odf_document::Impl
|
||||
{
|
||||
public:
|
||||
Impl(const std::wstring & Folder, const ProgressCallback* CallBack);
|
||||
Impl(xml::sax * Reader);
|
||||
virtual ~Impl();
|
||||
|
||||
odf_read_context & odf_context();
|
||||
|
||||
bool docx_convert(oox::docx_conversion_context & Context);
|
||||
bool xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
bool pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
const std::wstring & get_folder() const { return base_folder_; }
|
||||
const std::wstring & get_folder() const;
|
||||
|
||||
const office_element * get_content() const;
|
||||
office_element * get_content();
|
||||
const office_element * get_content() const;
|
||||
office_element * get_content();
|
||||
|
||||
long get_office_mime_type() {return office_mime_type_;}
|
||||
|
||||
@ -77,20 +80,20 @@ private:
|
||||
|
||||
odf_read_context_ptr context_;
|
||||
|
||||
void parse_styles();
|
||||
void parse_fonts();
|
||||
void parse_manifests();
|
||||
void parse_settings();
|
||||
void parse_styles (office_element *element);
|
||||
void parse_fonts (office_element *elemen);
|
||||
void parse_manifests(office_element *element);
|
||||
void parse_settings (office_element *element);
|
||||
|
||||
private:
|
||||
content_xml_t_ptr content_xml_;
|
||||
content_xml_t_ptr styles_xml_;
|
||||
content_xml_t_ptr meta_xml_;
|
||||
content_xml_t_ptr settings_xml_;
|
||||
content_xml_t_ptr manifest_xml_;
|
||||
|
||||
private:
|
||||
std::wstring base_folder_;
|
||||
std::wstring tmp_folder_;
|
||||
|
||||
long office_mime_type_;
|
||||
bool encrypted;
|
||||
|
||||
|
||||
@ -61,7 +61,34 @@ void office_binary_data::add_child_element( xml::sax * Reader, const std::wstrin
|
||||
|
||||
void office_binary_data::add_text(const std::wstring & Text)
|
||||
{
|
||||
base64Binary_ = Text;
|
||||
base64Binary_ = std::string(Text.begin(), Text.end());
|
||||
}
|
||||
|
||||
std::wstring office_binary_data::write_to(const std::wstring & path)
|
||||
{
|
||||
std::wstring result;
|
||||
|
||||
NSFile::CBase64Converter base64;
|
||||
int nLength = 0;
|
||||
unsigned char *pData = NULL;
|
||||
|
||||
NSFile::CBase64Converter::Decode(base64Binary_.c_str(), base64Binary_.length(), pData, nLength);
|
||||
if (pData)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
|
||||
std::wstring bin_file = file.CreateTempFileWithUniqueName(path + FILE_SEPARATOR_STR, L"bin");
|
||||
if (file.CreateFileW(bin_file))
|
||||
{
|
||||
file.WriteFile(pData, nLength);
|
||||
file.CloseFile();
|
||||
|
||||
int pos = bin_file.rfind(FILE_SEPARATOR_STR);
|
||||
result = bin_file.substr(pos + 1);
|
||||
}
|
||||
delete []pData; pData = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -53,17 +53,15 @@ public:
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
public:
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
std::wstring write_to(const std::wstring & path);
|
||||
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);
|
||||
|
||||
private:
|
||||
std::wstring base64Binary_;
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
std::string base64Binary_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_binary_data);
|
||||
|
||||
@ -63,9 +63,10 @@ void chart_chart_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
|
||||
common_draw_size_attlist_.add_attributes(Attributes);
|
||||
common_attlist_.add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"chart:class", chart_class_, std::wstring(L""));
|
||||
CP_APPLY_ATTR(L"chart:column-mapping", chart_column_mapping_);
|
||||
CP_APPLY_ATTR(L"chart:row-mapping", chart_row_mapping_);
|
||||
CP_APPLY_ATTR(L"chart:class", chart_class_, std::wstring(L""));
|
||||
CP_APPLY_ATTR(L"chart:column-mapping", chart_column_mapping_);
|
||||
CP_APPLY_ATTR(L"chart:row-mapping", chart_row_mapping_);
|
||||
CP_APPLY_ATTR(L"loext:data-pilot-source", loext_data_pilot_source_);
|
||||
}
|
||||
|
||||
// chart:chart
|
||||
@ -75,7 +76,7 @@ const wchar_t * chart_chart::name = L"chart";
|
||||
|
||||
void chart_chart::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_chart_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_chart::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -97,7 +98,7 @@ const wchar_t * chart_title::name = L"title";
|
||||
|
||||
void chart_title::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_title_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_title::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -117,7 +118,7 @@ const wchar_t * chart_subtitle::name = L"subtitle";
|
||||
|
||||
void chart_subtitle::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_title_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_subtitle::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -157,7 +158,7 @@ const wchar_t * chart_legend::name = L"legend";
|
||||
|
||||
void chart_legend::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_legend_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_legend::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -194,7 +195,7 @@ const wchar_t * chart_plot_area::name = L"plot-area";
|
||||
|
||||
void chart_plot_area::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_plot_area_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_plot_area::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -217,7 +218,7 @@ const wchar_t * chart_wall::name = L"wall";
|
||||
|
||||
void chart_wall::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_wall_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_wall::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -256,7 +257,7 @@ const wchar_t * chart_axis::name = L"axis";
|
||||
|
||||
void chart_axis::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_axis_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_axis::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -279,7 +280,7 @@ const wchar_t * chart_grid::name = L"grid";
|
||||
|
||||
void chart_grid::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_grid_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_grid::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -306,11 +307,12 @@ void chart_categories::add_child_element( xml::sax * Reader, const std::wstring
|
||||
|
||||
void chart_series_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"chart:values-cell-range-address", chart_values_cell_range_address_);
|
||||
CP_APPLY_ATTR(L"chart:label-cell-", chart_label_cell_address_);
|
||||
CP_APPLY_ATTR(L"chart:class", chart_class_);
|
||||
CP_APPLY_ATTR(L"chart:attached-axis", chart_attached_axis_);
|
||||
common_attlist_.add_attributes(Attributes);
|
||||
CP_APPLY_ATTR(L"chart:values-cell-range-address", chart_values_cell_range_address_);
|
||||
CP_APPLY_ATTR(L"chart:label-cell-address", chart_label_cell_address_);
|
||||
CP_APPLY_ATTR(L"chart:class", chart_class_);
|
||||
CP_APPLY_ATTR(L"chart:attached-axis", chart_attached_axis_);
|
||||
|
||||
common_attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
// chart:categories
|
||||
@ -320,7 +322,7 @@ const wchar_t * chart_series::name = L"series";
|
||||
|
||||
void chart_series::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_series_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_series::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -358,7 +360,7 @@ const wchar_t * chart_data_point::name = L"data-point";
|
||||
|
||||
void chart_data_point::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
chart_data_point_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void chart_data_point::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
|
||||
@ -82,12 +82,12 @@ class chart_chart_attlist
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
odf_types::common_draw_size_attlist common_draw_size_attlist_;
|
||||
common_chart_attlist common_attlist_;
|
||||
std::wstring chart_class_;
|
||||
_CP_OPT(std::wstring) chart_column_mapping_;
|
||||
_CP_OPT(std::wstring) chart_row_mapping_;
|
||||
_CP_OPT(std::wstring) loext_data_pilot_source_;
|
||||
};
|
||||
|
||||
// chart:chart
|
||||
@ -105,8 +105,8 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_chart_attlist chart_chart_attlist_;
|
||||
office_element_ptr_array content_;
|
||||
chart_chart_attlist attlist_;
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(chart_chart);
|
||||
@ -139,7 +139,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_title_attlist chart_title_attlist_;
|
||||
chart_title_attlist attlist_;
|
||||
office_element_ptr text_p_;
|
||||
};
|
||||
|
||||
@ -160,8 +160,8 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_title_attlist chart_title_attlist_;
|
||||
office_element_ptr text_p_;
|
||||
chart_title_attlist attlist_;
|
||||
office_element_ptr text_p_;
|
||||
|
||||
};
|
||||
|
||||
@ -183,7 +183,7 @@ private:
|
||||
|
||||
public:
|
||||
common_chart_attlist common_attlist_;
|
||||
office_element_ptr text_p_;
|
||||
office_element_ptr text_p_;
|
||||
|
||||
};
|
||||
|
||||
@ -195,11 +195,11 @@ public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) chart_legend_position_;
|
||||
_CP_OPT(std::wstring) chart_legend_align_;
|
||||
_CP_OPT(std::wstring) chart_legend_position_;
|
||||
_CP_OPT(std::wstring) chart_legend_align_;
|
||||
odf_types::common_draw_position_attlist common_draw_position_attlist_;
|
||||
_CP_OPT(std::wstring) style_legend_expansion_;
|
||||
_CP_OPT(double) style_legend_expansion_aspect_ratio_;
|
||||
_CP_OPT(std::wstring) style_legend_expansion_;
|
||||
_CP_OPT(double) style_legend_expansion_aspect_ratio_;
|
||||
common_chart_attlist common_attlist_;
|
||||
|
||||
};
|
||||
@ -219,7 +219,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_legend_attlist chart_legend_attlist_;
|
||||
chart_legend_attlist attlist_;
|
||||
|
||||
};
|
||||
|
||||
@ -234,7 +234,7 @@ public:
|
||||
public:
|
||||
odf_types::common_draw_position_attlist common_draw_position_attlist_;
|
||||
odf_types::common_draw_size_attlist common_draw_size_attlist_;
|
||||
common_chart_attlist common_attlist_;
|
||||
common_chart_attlist common_attlist_;
|
||||
|
||||
_CP_OPT(std::wstring) table_cell_range_address_;
|
||||
_CP_OPT(std::wstring) chart_data_source_has_labels_;
|
||||
@ -257,9 +257,8 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_plot_area_attlist chart_plot_area_attlist_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
chart_plot_area_attlist attlist_;
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(chart_plot_area);
|
||||
@ -270,7 +269,7 @@ public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(odf_types::length) svg_width_;
|
||||
_CP_OPT(odf_types::length) svg_width_;
|
||||
common_chart_attlist common_attlist_;
|
||||
|
||||
};
|
||||
@ -289,7 +288,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_wall_attlist chart_wall_attlist_;
|
||||
chart_wall_attlist attlist_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(chart_wall);
|
||||
@ -310,7 +309,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
common_chart_attlist common_attlist_;
|
||||
common_chart_attlist common_attlist_;
|
||||
|
||||
};
|
||||
|
||||
@ -322,8 +321,8 @@ public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) chart_dimension_;
|
||||
_CP_OPT(std::wstring) chart_name_;
|
||||
_CP_OPT(std::wstring) chart_dimension_;
|
||||
_CP_OPT(std::wstring) chart_name_;
|
||||
common_chart_attlist common_attlist_;
|
||||
};
|
||||
|
||||
@ -342,9 +341,8 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_axis_attlist chart_axis_attlist_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
chart_axis_attlist attlist_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
};
|
||||
|
||||
@ -376,7 +374,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_grid_attlist chart_grid_attlist_;
|
||||
chart_grid_attlist attlist_;
|
||||
|
||||
};
|
||||
|
||||
@ -432,9 +430,8 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_series_attlist chart_series_attlist_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
chart_series_attlist attlist_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
};
|
||||
|
||||
@ -486,7 +483,7 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
chart_data_point_attlist chart_data_point_attlist_;
|
||||
chart_data_point_attlist attlist_;
|
||||
|
||||
};
|
||||
|
||||
@ -550,8 +547,8 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
common_chart_attlist common_attlist_;
|
||||
_CP_OPT(bool) display_r_square_;
|
||||
common_chart_attlist common_attlist_;
|
||||
_CP_OPT(bool) display_r_square_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
// office_document_base
|
||||
class office_document_base : public office_element
|
||||
{
|
||||
public:
|
||||
@ -67,6 +66,8 @@ public:
|
||||
|
||||
// office-document-attrs
|
||||
// office-document-common-attrs
|
||||
office_element_ptr office_body_; // office-body
|
||||
|
||||
office_element_ptr office_meta_; // office-meta
|
||||
office_element_ptr office_settings_; // office-settings
|
||||
office_element_ptr office_scripts_;
|
||||
@ -75,14 +76,9 @@ public:
|
||||
office_element_ptr office_styles_; // office-styles
|
||||
office_element_ptr office_automatic_styles_; // office-automatic-styles
|
||||
office_element_ptr office_master_styles_; // office-master-styles
|
||||
office_element_ptr_array manifests_; // manifests
|
||||
|
||||
|
||||
public:
|
||||
office_element_ptr office_body_; // office-body
|
||||
office_element_ptr_array manifests_; // manifests
|
||||
|
||||
friend class odf_document;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -190,6 +190,7 @@ enum ElementType
|
||||
|
||||
typeStyleFontFace,
|
||||
|
||||
typeSvgDesc,
|
||||
typeSvgFontFaceUri,
|
||||
typeSvgFontFaceFormat,
|
||||
typeSvgFontFaceName,
|
||||
@ -234,7 +235,9 @@ enum ElementType
|
||||
typeTableDatabaseSourceQuery,
|
||||
typeTableDatabaseSourceSql,
|
||||
typeTableSourceCellRange,
|
||||
typeTableSourceCellRanges,
|
||||
typeTableSourceService,
|
||||
typeTableDataPilotGrandTotal,
|
||||
typeTableDataPilotSubtotals,
|
||||
typeTableDataPilotSubtotal,
|
||||
typeTableDataPilotGroupMember,
|
||||
|
||||
@ -88,13 +88,13 @@ void office_spreadsheet::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
if (database_ranges_)
|
||||
database_ranges_->xlsx_convert(Context);
|
||||
|
||||
if (data_pilot_tables_)
|
||||
data_pilot_tables_->xlsx_convert(Context);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
|
||||
if (data_pilot_tables_)
|
||||
data_pilot_tables_->xlsx_convert(Context);
|
||||
}
|
||||
|
||||
Context.end_office_spreadsheet();
|
||||
}
|
||||
|
||||
@ -318,8 +318,30 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
|
||||
CP_XML_NODE(node)//a:rPr & a:defRPr
|
||||
{
|
||||
//attr
|
||||
const int W = process_font_weight(fo_font_weight_);
|
||||
if (W > 0) CP_XML_ATTR(L"b", true);
|
||||
if (fo_language_ || style_language_asian_ || style_language_complex_)
|
||||
{
|
||||
std::wstring w_val;
|
||||
if (fo_language_)
|
||||
{
|
||||
w_val = *fo_language_;
|
||||
if (fo_country_) w_val += L"-" + *fo_country_;
|
||||
}
|
||||
else if (style_language_asian_)
|
||||
{
|
||||
w_val = *style_language_asian_;
|
||||
if (style_country_asian_) w_val += L"-" + *style_country_asian_;
|
||||
}
|
||||
else if (style_language_complex_)
|
||||
{
|
||||
w_val = *style_language_complex_;
|
||||
if (style_country_complex_)w_val += L"-" + *style_country_complex_;
|
||||
}
|
||||
|
||||
if (w_val.empty() == false)
|
||||
{
|
||||
CP_XML_ATTR(L"lang", w_val);
|
||||
}
|
||||
}
|
||||
|
||||
const int fontStyle = process_font_style(fo_font_style_);
|
||||
if (fontStyle > 0) CP_XML_ATTR(L"i", true);
|
||||
@ -354,6 +376,9 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
|
||||
CP_XML_ATTR(L"cap", "small");
|
||||
}
|
||||
}
|
||||
const int W = process_font_weight(fo_font_weight_);
|
||||
if (W > 0) CP_XML_ATTR(L"b", true);
|
||||
|
||||
// underline
|
||||
line_width under = style_text_underline_width_.get_value_or(line_width::Auto);
|
||||
bool underlineBold = under.get_type() == line_width::Bold ||
|
||||
@ -433,18 +458,6 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
|
||||
CP_XML_ATTR(L"spc",(int)(20.0 * fo_letter_spacing_->get_length().get_value_unit(length::pt)));
|
||||
}
|
||||
|
||||
if (fo_language_ || style_language_asian_ || style_language_complex_)
|
||||
{
|
||||
std::wstring w_val;
|
||||
if (fo_language_) w_val = *fo_language_;
|
||||
else if (fo_country_) w_val = *fo_country_;
|
||||
else if (style_country_asian_) w_val = *style_country_asian_;
|
||||
else if (style_language_asian_) w_val = *style_language_asian_;
|
||||
else if (style_language_complex_) w_val = *style_language_complex_;
|
||||
else if (style_country_complex_) w_val = *style_country_complex_;
|
||||
|
||||
CP_XML_ATTR(L"lang", w_val);
|
||||
}
|
||||
if (style_text_position_)
|
||||
{
|
||||
if (style_text_position_->get_type() == text_position::Percent)
|
||||
|
||||
@ -1274,16 +1274,27 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
|
||||
{
|
||||
if (horizontal_margins.fo_margin_left_ && horizontal_margins.fo_margin_left_->get_type() == odf_types::length_or_percent::Length)
|
||||
CP_XML_ATTR(L"left" , horizontal_margins.fo_margin_left_->get_length().get_value_unit(odf_types::length::inch));
|
||||
else CP_XML_ATTR(L"left", 0);
|
||||
|
||||
if (horizontal_margins.fo_margin_right_ && horizontal_margins.fo_margin_right_->get_type() == odf_types::length_or_percent::Length)
|
||||
CP_XML_ATTR(L"right" , horizontal_margins.fo_margin_right_->get_length().get_value_unit(odf_types::length::inch));
|
||||
else CP_XML_ATTR(L"right", 0);
|
||||
|
||||
if (vertical_margins.fo_margin_top_ && vertical_margins.fo_margin_top_->get_type() == odf_types::length_or_percent::Length)
|
||||
CP_XML_ATTR(L"top" , vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch));
|
||||
else CP_XML_ATTR(L"top", 1.025);
|
||||
|
||||
if (vertical_margins.fo_margin_bottom_ && vertical_margins.fo_margin_bottom_->get_type() == odf_types::length_or_percent::Length)
|
||||
CP_XML_ATTR(L"bottom" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch));
|
||||
else CP_XML_ATTR(L"bottom", 1.025);
|
||||
|
||||
CP_XML_ATTR(L"header" , vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch));
|
||||
CP_XML_ATTR(L"footer" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch));
|
||||
if (vertical_margins.fo_margin_top_)
|
||||
CP_XML_ATTR(L"header" , vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch));
|
||||
else CP_XML_ATTR(L"header", 0.7875);
|
||||
|
||||
if (vertical_margins.fo_margin_bottom_)
|
||||
CP_XML_ATTR(L"footer" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch));
|
||||
else CP_XML_ATTR(L"footer", 0.7875);
|
||||
}
|
||||
}
|
||||
if (attlist_.fo_page_width_ || attlist_.fo_page_height_ || attlist_.style_print_orientation_)
|
||||
|
||||
@ -356,7 +356,6 @@ void table_columns_and_groups::add_child_element( xml::sax * Reader, const std::
|
||||
*/
|
||||
}
|
||||
|
||||
// table-table-cell-content
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::wostream & table_table_cell_content::text_to_stream(std::wostream & _Wostream) const
|
||||
@ -393,9 +392,14 @@ void table_table_cell::add_child_element( xml::sax * Reader, const std::wstring
|
||||
void table_table_cell::add_text(const std::wstring & Text)
|
||||
{
|
||||
}
|
||||
bool table_table_cell::empty()
|
||||
{
|
||||
if (!content_.elements_.empty()) return false;
|
||||
if (attlist_.table_formula_) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
// table:covered-table-cell
|
||||
// table-covered-table-cell
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * table_covered_table_cell::ns = L"table";
|
||||
const wchar_t * table_covered_table_cell::name = L"covered-table-cell";
|
||||
@ -412,13 +416,19 @@ void table_covered_table_cell::add_attributes( const xml::attributes_wc_ptr & At
|
||||
|
||||
void table_covered_table_cell::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
empty_ = false;
|
||||
content_.add_child_element(Reader, Ns, Name, getContext());
|
||||
}
|
||||
|
||||
void table_covered_table_cell::add_text(const std::wstring & Text)
|
||||
{
|
||||
}
|
||||
bool table_covered_table_cell::empty()
|
||||
{
|
||||
if (!content_.elements_.empty()) return false;
|
||||
if (attlist_.table_formula_) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// table:table-row
|
||||
@ -445,7 +455,38 @@ void table_table_row::add_child_element( xml::sax * Reader, const std::wstring &
|
||||
else
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
bool table_table_row::empty()
|
||||
{
|
||||
if (content_.empty() && !attlist_.table_style_name_ && !attlist_.table_default_cell_style_name_) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool table_table_row::empty_content_cells()
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
for (size_t i = 0 ; i < content_.size(); i++)
|
||||
{
|
||||
table_table_cell *cell = dynamic_cast<table_table_cell*>(content_[i].get());
|
||||
table_covered_table_cell *cover_cell = dynamic_cast<table_covered_table_cell*>(content_[i].get());
|
||||
if (!cell && !cover_cell)
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
if (cell && cell->empty() == false)
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
if (cover_cell && cover_cell->empty() == false)
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// table:table-rows
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * table_table_rows::ns = L"table";
|
||||
|
||||
@ -361,6 +361,9 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
bool empty();
|
||||
bool empty_content_cells();
|
||||
|
||||
table_table_row_attlist attlist_;
|
||||
office_element_ptr_array content_; // table-table-cell or table-covered-table-cell
|
||||
|
||||
@ -408,6 +411,7 @@ private:
|
||||
|
||||
public:
|
||||
bool last_cell_;
|
||||
bool empty();
|
||||
|
||||
table_table_cell_attlist attlist_;
|
||||
table_table_cell_attlist_extra attlist_extra_;
|
||||
@ -427,7 +431,7 @@ public:
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
table_covered_table_cell() : last_cell_(false), empty_(true) {}
|
||||
table_covered_table_cell() : last_cell_(false){}
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) ;
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context) ;
|
||||
@ -443,7 +447,7 @@ private:
|
||||
|
||||
public:
|
||||
bool last_cell_;
|
||||
bool empty_;
|
||||
bool empty();
|
||||
|
||||
table_table_cell_attlist attlist_;
|
||||
table_table_cell_content content_;
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "table_data_pilot_tables.h"
|
||||
#include "../formulasconvert/formulasconvert.h"
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
@ -67,12 +68,12 @@ void table_data_pilot_table::add_attributes( const xml::attributes_wc_ptr & Attr
|
||||
CP_APPLY_ATTR(L"table:name" , table_name_);
|
||||
CP_APPLY_ATTR(L"table:application-data" , table_application_data_);
|
||||
CP_APPLY_ATTR(L"table:buttons" , table_buttons_);
|
||||
CP_APPLY_ATTR(L"table:drill-down-ondouble-click", table_drill_down_ondouble_click_);
|
||||
CP_APPLY_ATTR(L"table:drill-down-on-double-click", table_drill_down_ondouble_click_);
|
||||
CP_APPLY_ATTR(L"table:grand-total" , table_grand_total_);
|
||||
CP_APPLY_ATTR(L"table:identify-categories" , table_identify_categories_);
|
||||
CP_APPLY_ATTR(L"table:ignore-empty-rows" , table_ignore_empty_rows_);
|
||||
CP_APPLY_ATTR(L"table:show-filter-button" , table_show_filter_button_);
|
||||
CP_APPLY_ATTR(L"table:show-target-range-address", table_show_target_range_address_);
|
||||
CP_APPLY_ATTR(L"table:show-filter-button" , table_show_filter_button_, true);
|
||||
CP_APPLY_ATTR(L"table:target-range-address" , table_target_range_address_);
|
||||
|
||||
}
|
||||
|
||||
@ -80,6 +81,8 @@ void table_data_pilot_table::add_child_element( xml::sax * Reader, const std::ws
|
||||
{
|
||||
if (L"table" == Ns && L"data-pilot-field" == Name)
|
||||
CP_CREATE_ELEMENT (fields_);
|
||||
else if (L"tableooo" == Ns && L"data-pilot-grand-total" == Name)
|
||||
CP_CREATE_ELEMENT (grand_total_);
|
||||
else
|
||||
CP_CREATE_ELEMENT (source_);
|
||||
|
||||
@ -88,23 +91,56 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
{
|
||||
if (!source_) return;
|
||||
|
||||
formulasconvert::odf2oox_converter formulas_converter;
|
||||
|
||||
Context.get_pivots_context().start_table();
|
||||
|
||||
source_->xlsx_convert(Context);
|
||||
|
||||
std::wstring sheet_name;
|
||||
|
||||
if (table_name_) Context.get_pivots_context().set_view_name(*table_name_);
|
||||
if (table_target_range_address_)
|
||||
{
|
||||
std::wstring ref = formulas_converter.convert_named_ref(*table_target_range_address_, false);
|
||||
sheet_name = formulas_converter.get_table_name();
|
||||
|
||||
Context.get_pivots_context().set_view_target_range(ref);
|
||||
Context.get_pivots_context().set_view_target_table_name(sheet_name);
|
||||
}
|
||||
|
||||
if (table_buttons_)
|
||||
{
|
||||
std::vector<std::wstring> headers;
|
||||
formulas_converter.split_distance_by(*table_buttons_, L" ", headers);
|
||||
|
||||
for (size_t i = table_show_filter_button_ ? 1 : 0; i < headers.size(); i++)
|
||||
{
|
||||
std::wstring ref = formulas_converter.convert_named_ref(headers[i], false);
|
||||
Context.get_pivots_context().add_button_header(ref);
|
||||
}
|
||||
}
|
||||
if (table_identify_categories_)
|
||||
Context.get_pivots_context().set_identify_categories(table_identify_categories_->get());
|
||||
|
||||
if (table_drill_down_ondouble_click_)
|
||||
Context.get_pivots_context().set_drill(table_drill_down_ondouble_click_->get());
|
||||
|
||||
for (size_t i = 0; i < fields_.size(); i++)
|
||||
{
|
||||
fields_[i]->xlsx_convert(Context);
|
||||
}
|
||||
|
||||
int index_view = Context.get_pivots_context().end_table();
|
||||
int index_table_view = Context.get_pivots_context().end_table();
|
||||
|
||||
if (index_view > 0)
|
||||
if (index_table_view < 0)
|
||||
return;
|
||||
|
||||
if (0 == sheet_name.find(L"'"))
|
||||
{
|
||||
Context.current_sheet().sheet_rels().add(oox::relationship(L"pvId" + std::to_wstring(index_view),
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
|
||||
L"../pivotTables/pivotTable" + std::to_wstring(index_view) + L".xml"));
|
||||
}
|
||||
sheet_name = sheet_name.substr(1, sheet_name.length() - 2);
|
||||
}
|
||||
Context.add_pivot_sheet_source(sheet_name, index_table_view);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_field::ns = L"table";
|
||||
@ -123,17 +159,48 @@ void table_data_pilot_field::add_attributes( const xml::attributes_wc_ptr & Attr
|
||||
|
||||
void table_data_pilot_field::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT (content_);
|
||||
if (L"table" == Ns && L"data-pilot-field-reference" == Name)
|
||||
CP_CREATE_ELEMENT (reference_);
|
||||
else if (L"table" == Ns && L"data-pilot-level" == Name)
|
||||
CP_CREATE_ELEMENT (level_);
|
||||
else if (L"table" == Ns && L"data-pilot-groups" == Name)
|
||||
CP_CREATE_ELEMENT (groups_);
|
||||
}
|
||||
void table_data_pilot_field::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
int field_type = table_orientation_.get_value_or(table_orientation::data).get_type(); //?? default type ????
|
||||
int field_hierarchy = table_used_hierarchy_.get_value_or(-1);
|
||||
|
||||
Context.get_pivots_context().start_field();
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
|
||||
Context.get_pivots_context().set_field_name(table_source_field_name_.get_value_or(L""));
|
||||
|
||||
if (table_is_data_layout_field_)
|
||||
Context.get_pivots_context().set_field_data_layout(table_is_data_layout_field_->get());
|
||||
|
||||
if (table_function_)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
table_function::type type = table_function_->get_type();
|
||||
|
||||
if (type == table_function::String)
|
||||
{
|
||||
formulasconvert::odf2oox_converter formulas_converter;
|
||||
|
||||
std::wstring user_funtion = formulas_converter.convert(table_function_->get_string());
|
||||
Context.get_pivots_context().set_field_user_function(user_funtion);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.get_pivots_context().set_field_function(type);
|
||||
}
|
||||
}
|
||||
|
||||
if (reference_) reference_->xlsx_convert(Context);
|
||||
if (groups_) groups_->xlsx_convert(Context);
|
||||
if (level_) level_->xlsx_convert(Context);
|
||||
|
||||
Context.get_pivots_context().set_field_type(field_type, field_hierarchy);
|
||||
|
||||
Context.get_pivots_context().end_field();
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
@ -158,13 +225,16 @@ const wchar_t * table_database_source_table::name = L"database-source-table";
|
||||
|
||||
void table_database_source_table::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:database-name" , table_database_name_);
|
||||
CP_APPLY_ATTR(L"table:database-table-name" , table_database_table_name_);
|
||||
CP_APPLY_ATTR(L"table:database-name", table_database_name_);
|
||||
CP_APPLY_ATTR(L"table:table-name" , table_table_name_);
|
||||
}
|
||||
|
||||
void table_database_source_table::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
if (table_database_name_)
|
||||
{
|
||||
Context.get_pivots_context().set_source_database(*table_database_name_, table_table_name_.get_value_or(L""));
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_database_source_query::ns = L"table";
|
||||
@ -179,7 +249,10 @@ void table_database_source_query::add_attributes( const xml::attributes_wc_ptr &
|
||||
|
||||
void table_database_source_query::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
if (table_database_name_)
|
||||
{
|
||||
Context.get_pivots_context().set_source_database_query(*table_database_name_, table_query_name_.get_value_or(L""));
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_database_source_sql::ns = L"table";
|
||||
@ -194,7 +267,12 @@ void table_database_source_sql::add_attributes( const xml::attributes_wc_ptr & A
|
||||
|
||||
void table_database_source_sql::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
//todoooo split data-base-ranges & pivots
|
||||
|
||||
if (table_database_name_)
|
||||
{//table_parse_sql_statement_??
|
||||
Context.get_pivots_context().set_source_database_sql(*table_database_name_, table_sql_statement_.get_value_or(L""));
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_source_cell_range::ns = L"table";
|
||||
@ -202,7 +280,7 @@ const wchar_t * table_source_cell_range::name = L"source-cell-range";
|
||||
|
||||
void table_source_cell_range::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:cellrange-address", table_cellrange_address_);
|
||||
CP_APPLY_ATTR(L"table:cell-range-address", table_cell_range_address_);
|
||||
}
|
||||
|
||||
void table_source_cell_range::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -211,9 +289,34 @@ void table_source_cell_range::add_child_element( xml::sax * Reader, const std::w
|
||||
}
|
||||
void table_source_cell_range::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
if (table_cell_range_address_)
|
||||
{
|
||||
formulasconvert::odf2oox_converter formulas_converter;
|
||||
|
||||
std::wstring ref = formulas_converter.convert_named_ref(*table_cell_range_address_, false);
|
||||
std::wstring table_name = formulas_converter.get_table_name();
|
||||
|
||||
Context.get_pivots_context().set_source_range(table_name, ref);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_source_cell_ranges::ns = L"table";
|
||||
const wchar_t * table_source_cell_ranges::name = L"source-cell-ranges";
|
||||
|
||||
void table_source_cell_ranges::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:cell-ranges-address", table_cell_ranges_address_);
|
||||
}
|
||||
void table_source_cell_ranges::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (table_cell_ranges_address_)//??? split by ref
|
||||
{
|
||||
//formulasconvert::odf2oox_converter formulas_converter;
|
||||
//
|
||||
//std::wstring ref = formulas_converter.convert_named_ref(*table_cell_range_address_, false);
|
||||
//std::wstring table_name = formulas_converter.get_table_name();
|
||||
|
||||
//Context.get_pivots_context().set_source_range(table_name, ref);
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
@ -238,19 +341,47 @@ const wchar_t * table_data_pilot_level::name = L"data-pilot-level";
|
||||
|
||||
void table_data_pilot_level::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:show-empty-address", table_show_empty_);
|
||||
CP_APPLY_ATTR(L"table:show-empty", table_show_empty_);
|
||||
CP_APPLY_ATTR(L"calcext:repeat-item-labels", calcext_repeat_item_labels_);
|
||||
}
|
||||
void table_data_pilot_level::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT (content_);
|
||||
if (L"table" == Ns && L"data-pilot-members" == Name)
|
||||
CP_CREATE_ELEMENT (members_);
|
||||
else if (L"table" == Ns && L"data-pilot-subtotals" == Name)
|
||||
CP_CREATE_ELEMENT (subtotals_);
|
||||
else if (L"table" == Ns && L"data-pilot-display-info" == Name)
|
||||
CP_CREATE_ELEMENT ( display_info_);
|
||||
else if (L"table" == Ns && L"data-pilot-layout-info" == Name)
|
||||
CP_CREATE_ELEMENT ( layout_info_);
|
||||
else if (L"table" == Ns && L"data-pilot-sort-info" == Name)
|
||||
CP_CREATE_ELEMENT (sort_info_);
|
||||
}
|
||||
void table_data_pilot_level::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
if (table_show_empty_)
|
||||
Context.get_pivots_context().set_field_show_empty(table_show_empty_->get());
|
||||
|
||||
if (calcext_repeat_item_labels_)
|
||||
Context.get_pivots_context().set_repeat_item_labels(calcext_repeat_item_labels_->get());
|
||||
|
||||
if (members_)
|
||||
members_->xlsx_convert(Context);
|
||||
|
||||
if (subtotals_)
|
||||
subtotals_->xlsx_convert(Context);
|
||||
|
||||
|
||||
table_data_pilot_sort_info *sort = dynamic_cast<table_data_pilot_sort_info*>(sort_info_.get());
|
||||
if (sort)
|
||||
{
|
||||
Context.get_pivots_context().set_field_sort(sort->table_order_.get_value_or(table_order::ascending).get_type());
|
||||
}
|
||||
|
||||
table_data_pilot_layout_info *layout = dynamic_cast<table_data_pilot_layout_info*>(layout_info_.get());
|
||||
if (layout)
|
||||
{
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_groups::ns = L"table";
|
||||
@ -272,7 +403,10 @@ void table_data_pilot_groups::add_child_element( xml::sax * Reader, const std::w
|
||||
}
|
||||
void table_data_pilot_groups::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
if (table_grouped_by_)
|
||||
Context.get_pivots_context().set_field_groups(table_grouped_by_->get_type());
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
@ -324,7 +458,7 @@ void table_data_pilot_member::add_attributes( const xml::attributes_wc_ptr & Att
|
||||
|
||||
void table_data_pilot_member::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
Context.get_pivots_context().add_field_cache(-1, table_name_.get_value_or(L""));
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_group_member::ns = L"table";
|
||||
@ -365,7 +499,21 @@ void table_data_pilot_subtotal::add_attributes( const xml::attributes_wc_ptr & A
|
||||
|
||||
void table_data_pilot_subtotal::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_pivots_context().add_field_subtotal(table_function_.get_value_or(table_function::Auto).get_type());
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_grand_total::ns = L"tableooo";
|
||||
const wchar_t * table_data_pilot_grand_total::name = L"data-pilot-grand-total";
|
||||
|
||||
void table_data_pilot_grand_total::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:display" , table_display_);
|
||||
CP_APPLY_ATTR(L"table:orientation" , table_orientation_);
|
||||
//CP_APPLY_ATTR(L"table:display-name" , table_display_name_);
|
||||
CP_APPLY_ATTR(L"tableooo:display-name" , table_display_name_);
|
||||
}
|
||||
void table_data_pilot_grand_total::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_layout_info::ns = L"table";
|
||||
@ -375,10 +523,6 @@ void table_data_pilot_layout_info::add_attributes( const xml::attributes_wc_ptr
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:add-empty-lines" , table_add_empty_lines_);
|
||||
CP_APPLY_ATTR(L"table:layout-mode" , table_layout_mode_);
|
||||
}
|
||||
void table_data_pilot_layout_info::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_sort_info::ns = L"table";
|
||||
@ -389,10 +533,6 @@ void table_data_pilot_sort_info::add_attributes( const xml::attributes_wc_ptr &
|
||||
CP_APPLY_ATTR(L"table:data-field" , table_data_field_);
|
||||
CP_APPLY_ATTR(L"table:order" , table_order_);
|
||||
CP_APPLY_ATTR(L"table:sort-mode" , table_sort_mode_);
|
||||
}
|
||||
void table_data_pilot_sort_info::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const wchar_t * table_data_pilot_display_info::ns = L"table";
|
||||
@ -404,10 +544,6 @@ void table_data_pilot_display_info::add_attributes( const xml::attributes_wc_ptr
|
||||
CP_APPLY_ATTR(L"table:display-member-mode" , table_display_member_mode_);
|
||||
CP_APPLY_ATTR(L"table:enabled" , table_enabled_);
|
||||
CP_APPLY_ATTR(L"table:member-count" , table_member_count_);
|
||||
}
|
||||
void table_data_pilot_display_info::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -46,6 +46,7 @@
|
||||
#include "datatypes/tabletype.h"
|
||||
#include "datatypes/tablefunction.h"
|
||||
#include "datatypes/tableorder.h"
|
||||
#include "datatypes/dategroup.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
@ -65,8 +66,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);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
public:
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_tables);
|
||||
@ -87,18 +88,20 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_name_;
|
||||
_CP_OPT(std::wstring) table_target_range_address_;
|
||||
_CP_OPT(std::wstring) table_application_data_;
|
||||
_CP_OPT(std::wstring) table_buttons_;
|
||||
_CP_OPT(odf_types::Bool) table_drill_down_ondouble_click_;
|
||||
_CP_OPT(odf_types::grand_total)table_grand_total_;
|
||||
_CP_OPT(odf_types::Bool) table_identify_categories_;
|
||||
_CP_OPT(odf_types::Bool) table_ignore_empty_rows_;
|
||||
_CP_OPT(odf_types::Bool) table_show_filter_button_;
|
||||
_CP_OPT(odf_types::Bool) table_show_target_range_address_;
|
||||
bool table_show_filter_button_;
|
||||
|
||||
office_element_ptr source_;
|
||||
office_element_ptr_array fields_;
|
||||
office_element_ptr grand_total_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_table);
|
||||
@ -119,6 +122,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_source_field_name_;
|
||||
_CP_OPT(odf_types::table_orientation) table_orientation_;
|
||||
_CP_OPT(int) table_used_hierarchy_;
|
||||
@ -127,11 +131,37 @@ private:
|
||||
_CP_OPT(std::wstring) table_selected_page_;
|
||||
_CP_OPT(odf_types::Bool) table_is_data_layout_field_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr reference_;
|
||||
office_element_ptr level_;
|
||||
office_element_ptr groups_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_field);
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
class table_data_pilot_grand_total : public office_element_impl<table_data_pilot_grand_total>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableDataPilotGrandTotal;
|
||||
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){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_display_name_;
|
||||
_CP_OPT(odf_types::Bool) table_display_;
|
||||
_CP_OPT(odf_types::table_orientation) table_orientation_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_grand_total );
|
||||
//-------------------------------------------------------------------------------------
|
||||
class table_data_pilot_field_reference : public office_element_impl<table_data_pilot_field_reference>
|
||||
{
|
||||
public:
|
||||
@ -147,6 +177,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_field_name_;
|
||||
_CP_OPT(std::wstring) table_member_name_;
|
||||
_CP_OPT(odf_types::member_type) table_member_type_;
|
||||
@ -171,8 +202,9 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_database_name_;
|
||||
_CP_OPT(std::wstring) table_database_table_name_;
|
||||
_CP_OPT(std::wstring) table_table_name_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_database_source_table);
|
||||
@ -193,6 +225,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_database_name_;
|
||||
_CP_OPT(std::wstring) table_query_name_;
|
||||
};
|
||||
@ -215,6 +248,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_database_name_;
|
||||
_CP_OPT(odf_types::Bool)table_parse_sql_statement_;
|
||||
_CP_OPT(std::wstring) table_sql_statement_;
|
||||
@ -238,12 +272,34 @@ 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_cellrange_address_;
|
||||
office_element_ptr_array content_;
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_cell_range_address_;
|
||||
office_element_ptr_array content_; //filters
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_source_cell_range);
|
||||
//-------------------------------------------------------------------------------------
|
||||
class table_source_cell_ranges : public office_element_impl<table_source_cell_ranges>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableSourceCellRanges;
|
||||
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){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_cell_ranges_address_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_source_cell_ranges);
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
class table_source_service : public office_element_impl<table_source_service>
|
||||
{
|
||||
@ -260,6 +316,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_name_;
|
||||
_CP_OPT(std::wstring) table_object_name_;
|
||||
_CP_OPT(std::wstring) table_password_;
|
||||
@ -285,8 +342,15 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
_CP_OPT(odf_types::Bool) table_show_empty_;
|
||||
office_element_ptr_array content_;
|
||||
_CP_OPT(odf_types::Bool) calcext_repeat_item_labels_;
|
||||
|
||||
office_element_ptr members_;
|
||||
office_element_ptr subtotals_;
|
||||
office_element_ptr display_info_;
|
||||
office_element_ptr layout_info_;
|
||||
office_element_ptr sort_info_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_level);
|
||||
//-------------------------------------------------------------------------------------
|
||||
@ -306,13 +370,14 @@ 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_date_end_;
|
||||
_CP_OPT(std::wstring) table_date_start_;
|
||||
_CP_OPT(std::wstring) table_start; //double 18.2 or auto.
|
||||
_CP_OPT(std::wstring) table_end_; //double 18.2 or auto.
|
||||
_CP_OPT(std::wstring) table_grouped_by_; //seconds, minutes, hours, days, months, quarters or years.
|
||||
_CP_OPT(std::wstring) table_source_field_name_;
|
||||
_CP_OPT(double) table_step;
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_date_end_;
|
||||
_CP_OPT(std::wstring) table_date_start_;
|
||||
_CP_OPT(std::wstring) table_start; //double 18.2 or auto.
|
||||
_CP_OPT(std::wstring) table_end_; //double 18.2 or auto.
|
||||
_CP_OPT(odf_types::date_group) table_grouped_by_;
|
||||
_CP_OPT(std::wstring) table_source_field_name_;
|
||||
_CP_OPT(double) table_step;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
@ -334,6 +399,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_name_;
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
@ -356,7 +422,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);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
public:
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_members);
|
||||
|
||||
@ -377,8 +444,9 @@ 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::Bool) table_display_;
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_name_;
|
||||
_CP_OPT(odf_types::Bool) table_display_;
|
||||
_CP_OPT(odf_types::Bool) table_show_details_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_member);
|
||||
@ -399,6 +467,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_name_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_group_member);
|
||||
@ -419,6 +488,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
|
||||
@ -440,6 +510,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(odf_types::table_function) table_function_;
|
||||
};
|
||||
|
||||
@ -455,12 +526,13 @@ public:
|
||||
static const ElementType type = typeTableDataLayoutInfo;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
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){}
|
||||
|
||||
public:
|
||||
_CP_OPT(odf_types::Bool) table_add_empty_lines_;
|
||||
_CP_OPT(std::wstring) table_layout_mode_; //tabular-layout, outlinesubtotals-top or outline-subtotals-bottom.
|
||||
};
|
||||
@ -476,12 +548,13 @@ public:
|
||||
static const ElementType type = typeTableDataSortInfo;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
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){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_data_field_;
|
||||
_CP_OPT(odf_types::table_order) table_order_;
|
||||
_CP_OPT(std::wstring) table_sort_mode_; //data, none, manual or name.
|
||||
@ -498,12 +571,13 @@ public:
|
||||
static const ElementType type = typeTableDataDisplayInfo;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
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){}
|
||||
|
||||
public:
|
||||
_CP_OPT(std::wstring) table_data_field_;
|
||||
_CP_OPT(std::wstring) table_display_member_mode_; //from-top or from-bottom.
|
||||
_CP_OPT(odf_types::Bool) table_enabled_;
|
||||
@ -512,6 +586,5 @@ private:
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_data_pilot_display_info);
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -78,6 +78,17 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
|
||||
|
||||
void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (attlist_.table_number_rows_repeated_ > 1 && empty())
|
||||
{
|
||||
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
|
||||
return;
|
||||
}
|
||||
if (attlist_.table_number_rows_repeated_ > 0xf000 && empty_content_cells())
|
||||
{
|
||||
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
|
||||
return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods
|
||||
}
|
||||
|
||||
std::wostream & strm = Context.current_sheet().sheetData();
|
||||
///обработка чтилей для роу -
|
||||
size_t Default_Cell_style_in_row_ = 0;
|
||||
@ -253,26 +264,20 @@ void table_rows::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
table_table_rows_->xlsx_convert(Context);
|
||||
else
|
||||
{
|
||||
if (table_table_row_.size() > 1)
|
||||
while (table_table_row_.size() > 1)
|
||||
{
|
||||
//check 2 last rows for repeate > 65000 & 1024
|
||||
table_table_row* row_last = dynamic_cast<table_table_row*>(table_table_row_[table_table_row_.size() - 1].get());
|
||||
table_table_row* row_last_1 = dynamic_cast<table_table_row*>(table_table_row_[table_table_row_.size() - 2].get());
|
||||
|
||||
if (row_last->attlist_.table_number_rows_repeated_ > 1000 &&
|
||||
row_last_1->attlist_.table_number_rows_repeated_ > 1000 ||
|
||||
row_last_1->attlist_.table_number_rows_repeated_ > 0xf000)
|
||||
{
|
||||
std::wstring style = row_last->attlist_.table_style_name_.get_value_or(L"");
|
||||
std::wstring style_1 = row_last->attlist_.table_style_name_.get_value_or(L"");
|
||||
std::wstring style = row_last->attlist_.table_style_name_.get_value_or(L"");
|
||||
std::wstring style_1 = row_last->attlist_.table_style_name_.get_value_or(L"");
|
||||
|
||||
if (style == style_1)//check for empty also ????
|
||||
{
|
||||
row_last_1->attlist_.table_number_rows_repeated_ = 1024;
|
||||
table_table_row_.pop_back();
|
||||
}
|
||||
}
|
||||
if (style != style_1)break;
|
||||
if (row_last_1->empty_content_cells() == false) break;
|
||||
if (row_last->empty_content_cells() == false) break;
|
||||
|
||||
row_last_1->attlist_.table_number_rows_repeated_ += row_last->attlist_.table_number_rows_repeated_;
|
||||
table_table_row_.pop_back();
|
||||
}
|
||||
for (size_t i = 0; i < table_table_row_.size(); i++)
|
||||
{
|
||||
|
||||
@ -449,6 +449,14 @@
|
||||
RelativePath="..\src\odf\datatypes\common_attlists.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\dategroup.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\dategroup.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\odf\datatypes\direction.cpp"
|
||||
>
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include;"../../DesktopEditor/freetype-2.5.2/include""
|
||||
AdditionalIncludeDirectories="../include;"../../DesktopEditor/freetype-2.5.2/include";../../DesktopEditor/xml/libxml2/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="8,00"
|
||||
Name="OdfFileWriterTest"
|
||||
ProjectGUID="{FBA8446A-150F-4A10-B4DA-1022048D6473}"
|
||||
RootNamespace="ASCOfficeOdfFileWTest"
|
||||
@ -43,6 +43,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;__WORDSIZE=32;DONT_WRITE_EMBEDDED_FONTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
||||
@ -32,8 +32,6 @@
|
||||
|
||||
#include "abstract_xml.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
|
||||
@ -31,8 +31,6 @@
|
||||
*/
|
||||
#include "calcext_elements.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
@ -86,9 +84,9 @@ void calcext_conditional_formats::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
BOOST_FOREACH(const office_element_ptr & item, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
item->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,9 +113,9 @@ void calcext_conditional_format::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"calcext:target-range-address",calcext_target_range_address_);
|
||||
|
||||
BOOST_REVERSE_FOREACH(const office_element_ptr & item, content_)
|
||||
for (int i = (int)content_.size() - 1; i >= 0; i--)
|
||||
{
|
||||
item->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -144,9 +142,9 @@ void calcext_data_bar::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
calcext_data_bar_attr_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & item, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
item->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -170,9 +168,9 @@ void calcext_color_scale::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
BOOST_FOREACH(const office_element_ptr & item, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
item->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -198,9 +196,9 @@ void calcext_icon_set::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
calcext_icon_set_attr_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & item, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
item->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,4 +269,4 @@ void calcext_date_is::serialize(std::wostream & _Wostream)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
@ -68,11 +67,11 @@ void draw_base::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void draw_base::serialize(std::wostream & _Wostream)
|
||||
void draw_base::serialize(std::wostream & strm)
|
||||
{
|
||||
BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
elm->serialize(_Wostream);
|
||||
content_[i]->serialize(strm);
|
||||
}
|
||||
}
|
||||
void draw_base::serialize_attlist(CP_ATTR_NODE)
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/regex.h>
|
||||
|
||||
@ -88,9 +87,9 @@ void draw_image::serialize(std::wostream & _Wostream)
|
||||
|
||||
if (office_binary_data_)office_binary_data_->serialize(CP_XML_STREAM());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,9 +135,9 @@ void draw_chart::serialize(std::wostream & _Wostream)
|
||||
draw_chart_attlist_.serialize(CP_GET_XML_NODE());
|
||||
common_xlink_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,9 +166,9 @@ void draw_g::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
common_draw_attlists_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & elm, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,16 +430,15 @@ void draw_enhanced_geometry::serialize(std::wostream & _Wostream)
|
||||
CP_XML_ATTR_OPT(L"svg:viewBox", svg_viewbox_);
|
||||
draw_enhanced_geometry_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
BOOST_FOREACH(office_element_ptr & elm, draw_equation_)
|
||||
for (size_t i = 0; i < draw_equation_.size(); i++)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
draw_equation_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
|
||||
BOOST_FOREACH(office_element_ptr & elm, draw_handle_)
|
||||
for (size_t i = 0; i < draw_handle_.size(); i++)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
draw_handle_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,8 +32,6 @@
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
@ -80,9 +78,9 @@ void text_list_item::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
if (text_number_)text_number_->serialize(CP_XML_STREAM());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & parElement, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
parElement->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,9 +127,9 @@ void text_list_header::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
if (text_number_)text_number_->serialize(CP_XML_STREAM());
|
||||
|
||||
BOOST_FOREACH(const office_element_ptr & parElement, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
parElement->serialize(CP_XML_STREAM());
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include "odf_rels.h"
|
||||
|
||||
#include <boost/regex.h>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
|
||||
#include <cpdoccore/xml/utils.h>
|
||||
@ -85,11 +84,11 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
|
||||
|
||||
std::wstring output_path ;
|
||||
|
||||
BOOST_FOREACH(item const & elm, items_)
|
||||
for (size_t i = 0; i < items_.size(); i++)
|
||||
{
|
||||
if (elm.oox_ref == input_path)
|
||||
if (items_[i].oox_ref == input_path)
|
||||
{
|
||||
output_path = elm.odf_ref;
|
||||
output_path = items_[i].odf_ref;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -110,12 +109,11 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
|
||||
}
|
||||
void _mediaitems::dump_rels(rels & Rels, std::wstring local_path)
|
||||
{
|
||||
size_t i = 0;
|
||||
BOOST_FOREACH(item & elm, items_)
|
||||
for (size_t i = 0; i < items_.size(); i++)
|
||||
{
|
||||
Rels.add( relationship(
|
||||
utils::media::get_rel_type(elm.type),
|
||||
local_path + elm.odf_ref)
|
||||
Rels.add( relationship(
|
||||
utils::media::get_rel_type(items_[i].type),
|
||||
local_path + items_[i].odf_ref)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
|
||||
#include "mediaitems_utils.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
@ -30,9 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
#include <cpdoccore/xml/xmlchar.h>
|
||||
@ -67,13 +64,13 @@ void number_style_base::serialize(std::wostream & strm)
|
||||
if (style_text_properties_)
|
||||
style_text_properties_->serialize(strm);
|
||||
|
||||
BOOST_FOREACH(office_element_ptr & elm, style_map_)
|
||||
{
|
||||
elm->serialize(strm);
|
||||
for (size_t i = 0; i < style_map_.size(); i++)
|
||||
{
|
||||
style_map_[i]->serialize(strm);
|
||||
}
|
||||
BOOST_FOREACH(office_element_ptr & elm, content_)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
elm->serialize(strm);
|
||||
content_[i]->serialize(strm);
|
||||
}
|
||||
}
|
||||
void number_style_base::serialize(CP_ATTR_NODE)
|
||||
@ -166,9 +163,9 @@ void number_text::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
BOOST_FOREACH(office_element_ptr & elm, text_)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
{
|
||||
text_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,10 +191,10 @@ void number_embedded_text::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"number:position", number_position_);
|
||||
|
||||
BOOST_FOREACH(office_element_ptr & elm, text_)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
}
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
{
|
||||
text_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,10 +225,10 @@ void number_number::serialize(std::wostream & strm)
|
||||
|
||||
CP_XML_ATTR_OPT(L"number:min-integer-digits", number_min_integer_digits_);
|
||||
CP_XML_ATTR_OPT(L"number:grouping", number_grouping_);
|
||||
|
||||
BOOST_FOREACH(office_element_ptr & elm, number_embedded_text_)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
|
||||
for (size_t i = 0; i < number_embedded_text_.size(); i++)
|
||||
{
|
||||
number_embedded_text_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,9 +333,9 @@ void number_text_content::serialize(std::wostream & strm)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
BOOST_FOREACH(office_element_ptr & elm, text_)
|
||||
{
|
||||
elm->serialize(CP_XML_STREAM());
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
{
|
||||
text_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <cpdoccore/utf8cpp/utf8.h>
|
||||
#include <cpdoccore/xml/simple_xml_writer.h>
|
||||
|
||||
@ -92,9 +90,10 @@ namespace odf_writer
|
||||
///////////////
|
||||
void manifect_file::add_rels(rels & r)
|
||||
{
|
||||
BOOST_FOREACH(relationship & item, r.relationships())
|
||||
std::vector<relationship> & rels = r.relationships();
|
||||
for (size_t i = 0; i < rels.size(); i++)
|
||||
{
|
||||
rels_.add(item);
|
||||
rels_.add(rels[i]);
|
||||
}
|
||||
}
|
||||
manifect_file::manifect_file(std::wstring t)
|
||||
@ -188,13 +187,14 @@ namespace odf_writer
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"Media";
|
||||
NSDirectory::CreateDirectory(path);
|
||||
|
||||
BOOST_FOREACH( _mediaitems::item & item, mediaitems_.items() )
|
||||
std::vector< _mediaitems::item > & items = mediaitems_.items();
|
||||
for (size_t i = 0; i < items.size(); i++)
|
||||
{
|
||||
if (item.type == _mediaitems::typeMedia)
|
||||
if (items[i].type == _mediaitems::typeMedia)
|
||||
{
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.odf_ref;
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].odf_ref;
|
||||
|
||||
NSFile::CFileBinary::Copy(item.oox_ref, file_name_out);
|
||||
NSFile::CFileBinary::Copy(items[i].oox_ref, file_name_out);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,15 +212,16 @@ namespace odf_writer
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"Pictures";
|
||||
NSDirectory::CreateDirectory(path);
|
||||
|
||||
BOOST_FOREACH( _mediaitems::item & item, mediaitems_.items() )
|
||||
std::vector< _mediaitems::item > & items = mediaitems_.items();
|
||||
for (size_t i = 0; i < items.size(); i++)
|
||||
{
|
||||
if (item.type == _mediaitems::typeImage && item.oox_ref.length()>0)
|
||||
if (items[i].type == _mediaitems::typeImage && items[i].oox_ref.length()>0)
|
||||
{
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.odf_ref;
|
||||
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].odf_ref;
|
||||
|
||||
try
|
||||
{
|
||||
NSFile::CFileBinary::Copy(item.oox_ref, file_name_out);
|
||||
NSFile::CFileBinary::Copy(items[i].oox_ref, file_name_out);
|
||||
}catch (...)
|
||||
{
|
||||
}
|
||||
@ -289,13 +290,12 @@ namespace odf_writer
|
||||
{
|
||||
if (base_)base_->write(RootPath);
|
||||
|
||||
long count = 0;
|
||||
BOOST_FOREACH(const element_ptr & item, objects_)
|
||||
{
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + item->local_path;
|
||||
for (size_t i = 0; i < objects_.size(); i++)
|
||||
{
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + objects_[i]->local_path;
|
||||
NSDirectory::CreateDirectory(path);
|
||||
|
||||
item->write(path);
|
||||
objects_[i]->write(path);
|
||||
}
|
||||
if (manifest_) manifest_->write(RootPath);
|
||||
if (mimetype_) mimetype_->write(RootPath);
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "../../../ASCOfficeOdfFile/formulasconvert/formulasconvert.h"
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "office_spreadsheet.h"
|
||||
@ -134,16 +132,15 @@ void odf_conversion_context::end_document()
|
||||
objects_.back().scripts->serialize(content_root_->styles());
|
||||
|
||||
object.content->serialize(content_root_->content());
|
||||
BOOST_FOREACH(const office_element_ptr & elm, object.content_styles)
|
||||
|
||||
for (size_t i = 0; i < object.content_styles.size(); i++)
|
||||
{
|
||||
elm->serialize(content_root_->styles());
|
||||
object.content_styles[i]->serialize(content_root_->styles());
|
||||
}
|
||||
|
||||
package::content_simple_ptr content_style_ = package::content_simple::create();
|
||||
BOOST_FOREACH(const office_element_ptr & elm, object.styles)
|
||||
for (size_t i = 0; i < object.styles.size(); i++)
|
||||
{// мастер-пейджы, заданные заливки (градиенты, битмапы), дефолтные стили, колонтитулы, разметки, заметки,...
|
||||
|
||||
elm->serialize(content_style_->content());
|
||||
object.styles[i]->serialize(content_style_->content());
|
||||
}
|
||||
package::content_simple_ptr content_settings_ = package::content_simple::create();
|
||||
object.settings->serialize(content_settings_->content());
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -32,7 +32,6 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "odf_page_layout_context.h"
|
||||
|
||||
@ -30,9 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "odf_rels.h"
|
||||
|
||||
#include <cpdoccore/xml/attributes.h>
|
||||
@ -54,11 +51,11 @@ void relationship::serialize(std::wostream & _Wostream)
|
||||
}
|
||||
}
|
||||
|
||||
void rels::serialize(std::wostream & _Wostream)
|
||||
void rels::serialize(std::wostream & strm)
|
||||
{
|
||||
BOOST_FOREACH(relationship & r, relationship_)
|
||||
for (size_t i = 0; i < relationship_.size(); i++)
|
||||
{
|
||||
r.serialize(_Wostream);
|
||||
relationship_[i].serialize(strm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
|
||||
#include "style_paragraph_properties.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -55,11 +54,12 @@ static int style_family_counts_[26]={};//согласно количеству
|
||||
void calc_paragraph_properties_content(std::vector<style_paragraph_properties*> & parProps, paragraph_format_properties * result)
|
||||
{
|
||||
if (result == NULL)return;
|
||||
if (parProps.empty()) return;
|
||||
|
||||
BOOST_REVERSE_FOREACH(style_paragraph_properties* v, parProps)
|
||||
for (int i = (int)parProps.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (v)
|
||||
result->apply_from(v->content_);
|
||||
if (parProps[i])
|
||||
result->apply_from(parProps[i]->content_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ void odf_style_context::create_style(std::wstring oox_name, style_family::type f
|
||||
{
|
||||
std::wstring odf_name = oox_name;
|
||||
|
||||
if (odf_name.length() <1)odf_name = find_free_name(family);
|
||||
if (odf_name.empty()) odf_name = find_free_name(family);
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"style", L"style", elm, odf_context_);
|
||||
@ -445,4 +445,4 @@ void odf_style_context::calc_paragraph_properties(std::wstring style_name, style
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,8 +32,6 @@
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "odf_conversion_context.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user