Compare commits

..

159 Commits

Author SHA1 Message Date
8680fb2e0e . 2018-01-24 15:45:10 +03:00
c7c605a970 fix bug #31327
convert script text in toggle property in simple text
2018-01-23 19:34:07 +03:00
23d648d92d fix bug #36409 2018-01-23 16:53:40 +03:00
b098c98dbb x2t version 2.4.510 2018-01-23 16:23:09 +03:00
b88726beaf fix bug #36514 2018-01-23 14:09:55 +03:00
b2d3e5e194 . 2018-01-22 19:21:57 +03:00
a8315efae0 . 2018-01-22 18:26:40 +03:00
3781cf6774 . 2018-01-22 17:45:21 +03:00
7e36d47991 fix bug #8010
OdfFormatReader - dropdown & user fields
2018-01-22 15:09:23 +03:00
419a01bd09 fix bug #36725 2018-01-22 11:21:28 +03:00
804a01cab3 x2t version 2.4.509 2018-01-20 15:22:31 +03:00
931d6aa17c . 2018-01-20 14:24:40 +03:00
2861539949 . 2018-01-19 19:33:12 +03:00
281dad68fb . 2018-01-19 14:42:32 +03:00
04ba432cde x2t version 2.4.508 2018-01-19 14:14:33 +03:00
61c943a3b2 up 2018-01-19 13:46:06 +03:00
9fdc7641b3 . 2018-01-18 15:24:33 +03:00
1029ee9101 OoxToBinary - modify preparing to binary write 2018-01-18 15:13:21 +03:00
9ef5bec2a5 [ios] fixed build 2018-01-17 12:43:03 +03:00
93132eb8a0 x2t version 2.4.506 2018-01-17 11:18:24 +03:00
9828c25e51 . 2018-01-16 19:45:34 +03:00
db1204288b OdfFormatWriter - keeping current font size 2018-01-15 18:16:41 +03:00
26c3d37be5 Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop 2018-01-15 17:57:45 +03:00
077ea08368 OdfFormatWriter - text position (%) 2018-01-15 17:57:32 +03:00
98eab74e97 . 2018-01-15 17:51:30 +03:00
2a7e88ca76 v5.0.7 2018-01-15 15:19:37 +03:00
369596b860 OdfFormatWriter - fix dropCap, sections 2018-01-13 14:59:56 +03:00
15af8f561a OdfFormatWriter - fix picture size from placeholder 2018-01-12 17:02:33 +03:00
58f8d13d71 . 2018-01-12 13:57:26 +03:00
d6413057e2 x2t version 2.4.505
OOXML - add external audio, video; add sound effects for shapes; fix chart theme override, clrmap; convert canvas drawingML
RtfWriter - add image scaling from DrawingML
fix convert from google csv
2018-01-12 12:54:22 +03:00
008382213b Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop
Conflicts:
	Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h
2018-01-12 12:13:38 +03:00
dd5b4a719b x2t version 2.4.504 2018-01-12 12:03:44 +03:00
3d198bc211 for xlsx comments: Tahoma 9, User name in comment body 2018-01-11 20:43:10 +03:00
05ff75eeb2 fix bug #36652 2018-01-11 17:41:37 +03:00
597414ea6b DocFormatFile - fix users file (1995) without codepage 2017-12-26 13:08:02 +03:00
7f06ce7064 . 2017-12-26 11:21:39 +03:00
adf39680b6 OdfFormatWriter - extendede condition conditional formatting (x14) 2017-12-25 20:06:22 +03:00
ce77d478e3 x2t version 2.4.498 2017-12-25 15:42:59 +03:00
e1e14ae243 . 2017-12-25 13:52:57 +03:00
4f6e364225 . 2017-12-25 13:48:50 +03:00
26c02c5766 . 2017-12-23 19:33:05 +03:00
0d8c668f95 OdfFormat, fix bug 36596 (only for onlyoffice editors) 2017-12-23 17:34:20 +03:00
310cff0dfe change non-defined temp directory to unique 2017-12-23 14:48:44 +03:00
7f6611ab21 .. 2017-12-23 14:35:52 +03:00
bb37e348f5 . 2017-12-23 13:26:11 +03:00
6b5e03df5e . 2017-12-23 12:29:40 +03:00
d0e0109560 . 2017-12-22 15:10:45 +03:00
dc33f7f197 fix WriteAutoFilter error 2017-12-21 19:06:21 +03:00
85f4aa5679 fix error in sheetViews toXML 2017-12-21 17:28:55 +03:00
d2c5ea026f OOXML - fix ole object read 2017-12-21 13:52:17 +03:00
419ec7ed33 x2t version up 2017-12-20 19:17:15 +03:00
5f7d9eea02 x2t - optimization read ooxml files 2017-12-20 18:33:35 +03:00
709ee1942d fix bug #36568 2017-12-19 16:31:54 +03:00
5039cec847 diagramm save error 2017-12-19 15:09:10 +03:00
e59eff3a16 fix user file 2017-12-18 18:57:05 +03:00
2206b3b366 Remove unused code 2017-12-18 16:43:12 +03:00
a2d37e8a22 OdfFormaReader - fix 3d charts with 2 axis 2017-12-16 16:24:51 +03:00
b13eba5f01 x2t optimization rels 2017-12-15 17:05:47 +03:00
a48058c7d5 merge from 5.0.7 2017-12-15 14:52:11 +03:00
ab76aff379 . 2017-12-15 14:49:54 +03:00
b8b8a14268 fix bug 36524 (fix MathType equation) 2017-12-15 14:47:57 +03:00
e5ef749718 . 2017-12-15 12:24:35 +03:00
5d524369b8 . 2017-12-14 19:31:33 +03:00
e78fc0befc x2t - fix users files 2017-12-14 16:46:29 +03:00
d9986d09cd x2t - fix users file 2017-12-13 19:15:13 +03:00
bd67f4bf1c . 2017-12-13 15:13:37 +03:00
475bfaf93d Merge remote-tracking branch 'origin/hotfix/v5.0.7' into develop 2017-12-13 15:12:19 +03:00
1a8af4d8ed x2t - fix users file 2017-12-13 15:11:16 +03:00
cdf8dc7a4c Changed cef update condition 2017-12-13 12:55:54 +03:00
d71552bddd Merge remote-tracking branch 'origin/hotfix/v5.0.7' into develop
# Conflicts:
#	ASCOfficeDocFile/DocFormatTest/DocFormatTest.cpp
2017-12-13 12:40:08 +03:00
548c5ab608 x2t - fix users files 2017-12-13 11:59:49 +03:00
6a01384023 . 2017-12-13 00:01:15 +03:00
d70f36e36d DocFormat - fix users files 2017-12-12 19:41:50 +03:00
f65984f079 . 2017-12-12 19:41:16 +03:00
5b48a7a330 DocFormat - fix users file, add data form field 2017-12-12 19:10:08 +03:00
1496aece57 v8 (mac os) 2017-12-12 19:06:09 +03:00
60cf51ad0d Move ASCDOCUMENTSCORE to separated target 2017-12-12 16:30:44 +03:00
8e7231b322 removed unused code 2017-12-12 12:43:33 +03:00
2b339b6842 Cherrypick from develop 2017-12-12 12:43:03 +03:00
fb0dbfc231 Cherrypick from develop 2017-12-12 12:40:28 +03:00
756613e883 Merge pull request #56 from ONLYOFFICE/hotfix/v5.0.7
for b599a6bc43 to fix build error
2017-12-11 20:17:01 +03:00
ede03fafea for b599a6bc43 to fix build error 2017-12-11 19:52:44 +03:00
bdec91bfd5 Merge remote-tracking branch 'origin/hotfix/v5.0.7' into develop 2017-12-11 18:44:50 +03:00
260c2edd21 . 2017-12-11 18:42:11 +03:00
3eeec8fc67 RtfFormat - fix users file 2017-12-11 18:39:37 +03:00
ba6c7e8151 Merge remote-tracking branch 'origin/feature/v5.0.7.1' into develop 2017-12-11 14:05:03 +03:00
41a213491e fix image content type 2017-12-11 13:45:28 +03:00
b599a6bc43 Add open/save JsaProject.bin for OnlyOffice Macros 2017-12-11 13:31:48 +03:00
a0fd139027 Merge pull request #55 from ONLYOFFICE/feature/v5.0.7.1
Feature/v5.0.7.1
2017-12-06 18:54:01 +03:00
48852bc618 removed unused code 2017-12-06 18:51:58 +03:00
20b781cb7e pdf checker bug 2017-12-06 18:50:09 +03:00
704b3b709f update cef if newer version exist 2017-12-06 18:21:58 +03:00
e4674915c2 Update cef if exist newer version 2017-12-06 17:19:46 +03:00
51fe936e5f ... 2017-12-06 12:18:06 +03:00
d8b177411f x2t - options for check macro in file 2017-12-05 16:56:50 +03:00
717b628055 ... 2017-12-05 14:37:10 +03:00
e4f94646b6 x2t version up 2017-12-05 10:54:43 +03:00
dcec7447e4 XlsFormat - apply theme style from format office 2010 and later 2017-12-04 19:24:27 +03:00
5f12552f78 XlsFormat - theme 2017-12-03 16:09:35 +03:00
d293769c1f XlsFormat .. 2017-12-02 17:31:10 +03:00
b45e772a50 remove stub for hyperlink without link 2017-12-01 18:34:04 +03:00
fdb7716abc builder error (save to pdf & open file by url) 2017-12-01 14:23:21 +03:00
f72d6dfe0e XlsFormat-... 2017-11-30 20:04:08 +03:00
23029a6a92 Change cef number 2017-11-30 16:28:48 +03:00
eda8e4d13f add c_oSerCellTypes::ValueText for cell value; Read1 error with empty length 2017-11-30 14:18:46 +03:00
64f578e59f XlsFormat - ... 2017-11-29 19:32:21 +03:00
16c57b50cc XlsFormat - table parts 2017-11-29 14:48:02 +03:00
83c0ba9dab XlsFormat - table parts 2017-11-28 19:41:16 +03:00
a2443dadeb use external directory for fonts 2017-11-28 19:17:30 +03:00
789bb1d4b3 add open/save bookmarks 2017-11-28 17:49:14 +03:00
4138ae5ce2 add save to odp 2017-11-28 17:29:12 +03:00
239b5dbf11 fix bug #36451 (ole object old style in master slide) 2017-11-28 17:01:03 +03:00
c046776b9c Merge branch 'hotfix/v5.0.5' into develop
# Conflicts:
#	X2tConverter/src/cextracttools.h
2017-11-27 18:14:40 +03:00
055a02570b XlsFormat - ... 2017-11-27 17:44:55 +03:00
e7bbbec0de v5.0.5 2017-11-27 17:06:49 +03:00
1e2e5996f3 . 2017-11-23 19:40:37 +03:00
875717acd4 Add m_sSavePassword (m_sPassword - only for open) 2017-11-23 18:40:31 +03:00
033feeaf9d fix bug #18178 2017-11-23 18:16:44 +03:00
de336e5f96 Merge remote-tracking branch 'origin/hotfix/v5.0.5' into develop 2017-11-23 17:43:20 +03:00
82b3dbdae6 OdfFormatReader - fix users files 2017-11-23 17:42:09 +03:00
d1227f7759 x2t - add native commands for crypt file 2017-11-23 17:28:28 +03:00
4d134387f9 . 2017-11-23 17:15:06 +03:00
3f8600dfb7 XlsFormat - attachedToolbar,refactoring 2017-11-23 15:34:55 +03:00
511f043d63 . 2017-11-23 14:26:49 +03:00
69a41343c2 build with clang++ 2017-11-23 10:55:04 +03:00
578327bab6 XlsFormat - split sheets by type (ala original file) 2017-11-22 20:05:03 +03:00
52908908a5 fix linux build 2017-11-22 11:44:33 +03:00
24d9b99a44 Merge remote-tracking branch 'origin/hotfix/v5.0.5' into develop 2017-11-21 18:10:56 +03:00
dce58b628f fix bug #36322 2017-11-21 18:10:05 +03:00
f42cb4580c fix users files
XlsFormat olap hierarchy
...
2017-11-21 17:02:22 +03:00
52777e36cb refactoring 2017-11-21 12:49:32 +03:00
7b7e9f3e6e . 2017-11-20 16:21:58 +03:00
d39fa156e7 fix build 2017-11-20 15:47:40 +03:00
48bf40919c fix... 2017-11-17 19:33:38 +03:00
fd53a987be fix bug #36272 2017-11-17 19:02:51 +03:00
b4d298542a fix bug #36251 2017-11-17 15:58:19 +03:00
bae854027b fix bug #36380
Problem with picture in footnote
2017-11-17 13:18:20 +03:00
9723c379dd . 2017-11-17 12:44:51 +03:00
e8d8b2e56c . 2017-11-17 12:27:58 +03:00
adb84b0f05 x2t version up 2017-11-17 12:01:51 +03:00
a4ee30d031 fix bug #36201 2017-11-17 11:44:07 +03:00
e05194b277 Move ASCDOCUMENTSCORE to separated target 2017-11-16 18:14:37 +03:00
21f7f6ed5b fix bug #36335 2017-11-15 13:28:19 +03:00
80863ae25b v5.0.4 2017-11-13 17:46:10 +03:00
07562a9582 v5.0.4 2017-11-13 17:44:36 +03:00
6da196e426 fix bug #36311 2017-11-13 11:48:28 +03:00
d220cc8c79 removed stubs on writing tblLayout 2017-11-09 19:56:04 +03:00
f53c3d9f50 Merge pull request #51 from ONLYOFFICE/feature/pre5.0.4
pdf reader bug
2017-11-07 10:40:46 +03:00
fa98f22e3d fixed crush on Revision: 069544bf6c 2017-11-03 19:07:29 +03:00
e01c09bcc9 XlsFormat - olap .. 2017-11-03 15:36:15 +03:00
069544bf6c tab leader 2017-11-02 19:09:00 +03:00
b0f0f656af Merge pull request #50 from ONLYOFFICE/feature/bug36176
fix bug 36176
2017-11-02 18:00:26 +03:00
99191e65b0 XlsFormat - fix connections (oleDb, query...) 2017-11-02 15:39:18 +03:00
fb41720817 for bug 35900 (CWorkbookPr::toXml) 2017-11-02 13:31:14 +03:00
406c290be4 . 2017-11-01 15:40:15 +03:00
5ae4d7f819 XlsFormat - ... 2017-11-01 13:43:24 +03:00
e69c1677b2 v5.0.3 2017-10-31 18:49:25 +03:00
e1340c63ec pdf reader bug 2017-10-30 15:06:43 +03:00
867438833b fix bug 36176 2017-10-30 13:40:57 +03:00
964 changed files with 35923 additions and 16235 deletions

View File

@ -69,6 +69,7 @@ namespace OpenXmlContentTypes
static const wchar_t* Tiff = L"image/tiff";
static const wchar_t* Wmf = L"image/x-wmf";
static const wchar_t* Bmp = L"image/bmp";
static const wchar_t* Pcz = L"image/x-pcz";
}
namespace WordprocessingMLContentTypes

View File

@ -47,30 +47,17 @@ namespace DocFileFormat
virtual ~ConversionContext()
{
}
// Adds a new RSID to the set
inline void AddRsid(const std::wstring& rsid)
{
if (AllRsids.find(rsid) == AllRsids.end())
AllRsids.insert(rsid);
}
inline WordDocument* GetDocument()
{
return _doc;
}
inline WordprocessingDocument* GetXmlDocument()
{
return _docx;
}
public:
WordprocessingDocument* _docx;
WordDocument* _doc;
/// A set thta contains all revision ids.
std::set<std::wstring> AllRsids;
};
}

View File

@ -63,8 +63,16 @@ namespace DocFileFormat
{
long Converter::Convert(WordDocument* doc, WordprocessingDocument* docx, const ProgressCallback* progress)
{
if (!doc || !docx) return S_FALSE;
ConversionContext context( doc, docx );
//Write fontTable.xml
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
}
//Write styles.xml
if (doc->Styles)
{
@ -107,14 +115,6 @@ namespace DocFileFormat
return S_FALSE;
}
}
//Write fontTable.xml
if (doc->FontTable)
{
FontTableMapping fontTableMapping( &context );
doc->FontTable->Convert( &fontTableMapping );
}
if ( progress != NULL )
{
progress->OnProgress( progress->caller, DOC_ONPROGRESSEVENT_ID, 875000 );

View File

@ -559,7 +559,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteString(elem.GetXMLString());
}
else if (TextMark::FieldBeginMark == code)
{
{//todooo в отдельный mapping
int cpFieldStart = initialCp + i;
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
@ -599,20 +599,38 @@ namespace DocFileFormat
if ( bFORM )
{
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
std::wstring FORMTEXT ( L" FORMTEXT" );
std::wstring FORMCHECKBOX ( L" FORMCHECKBOX" );
std::wstring FORMDROPDOWN ( L" FORMDROPDOWN" );
m_pXmlWriter->WriteNodeBegin( L"w:fldChar" , true );
m_pXmlWriter->WriteAttribute( L"w:fldCharType" , L"begin" );
m_pXmlWriter->WriteNodeEnd( L"", true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
bool bFORMTEXT = search( f.begin(), f.end(), FORMTEXT.begin(), FORMTEXT.end()) != f.end();
bool bFORMCHECKBOX = search( f.begin(), f.end(), FORMCHECKBOX.begin(), FORMCHECKBOX.end()) != f.end();
bool bFORMDROPDOWN = search( f.begin(), f.end(), FORMDROPDOWN.begin(), FORMDROPDOWN.end()) != f.end();
/*if (cpPic < cpFieldEnd)
if (bFORMTEXT || bFORMCHECKBOX || bFORMDROPDOWN)
{
int fcPic = _doc.PieceTable.FileCharacterPositions[cpPic];
CharacterPropertyExceptions chpxPic = _doc.GetCharacterPropertyExceptions(fcPic, fcPic + 1)[0];
NilPicfAndBinData npbd = new NilPicfAndBinData(chpxPic, _doc.DataStream);
FormFieldData ffdata = new FormFieldData(npbd.binData);
ffdata.Convert(new FormFieldDataMapping(m_pXmlWriter));
}*/
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
if (cpPic < cpFieldEnd)
{
int fcPic = m_document->FindFileCharPos( cpPic );
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fcPic, fcPic + 1);
if (chpxs)
{
CharacterPropertyExceptions* chpxSep = chpxs->front();
FormFieldData ffdata (2, chpxSep, m_document->DataStream, false);
FormFieldDataMapping data_mapping(m_pXmlWriter, m_context, _caller);
ffdata.Convert(&data_mapping);
RELEASEOBJECT( chpxs );
}
}
}
m_pXmlWriter->WriteNodeEnd( L"w:fldChar" );
@ -809,6 +827,13 @@ namespace DocFileFormat
{
if (_fldCharCounter > 0)
{
if (_writeInstrText == true && !text.empty())
{
writeTextElement(text, textType);
text.clear();
}
_writeInstrText = false;
XMLTools::XMLElement elem( L"w:fldChar" );
elem.AppendAttribute( L"w:fldCharType", L"end" );
@ -1257,20 +1282,20 @@ namespace DocFileFormat
{
case sprmTDefTable:
case sprmOldTDefTable:
{
unsigned char itcMac = iter->Arguments[0];
{
unsigned char itcMac = iter->Arguments[0];
while(boundaries.size() < itcMac + 1)
boundaries.push_back(-0x7fff);
short boundary0 = -0x7fff;
for (unsigned char i = 0; i < itcMac; i++)
{
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
{
short boundary1 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( i * 2 ), iter->argumentsSize );
short boundary2 = FormatUtils::BytesToInt16( iter->Arguments, 1 + ( ( i + 1 ) * 2 ), iter->argumentsSize );
if (boundary2 - boundary1 > 1 && boundary1 - boundary0 > 1)
{
{
if ( boundaries[i] == -0x7fff || boundaries[i+1] == -0x7fff)
{
boundaries[i] = boundary1;
@ -1280,12 +1305,12 @@ namespace DocFileFormat
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary1 ) == boundaries_all.end() )
{
boundaries_all.push_back( boundary1 );
}
}
if ( find( boundaries_all.begin(), boundaries_all.end(), boundary2 ) == boundaries_all.end() )
{
{
boundaries_all.push_back( boundary2 );
}
}
boundary0 = boundary1;
}break;
}
@ -1513,11 +1538,11 @@ namespace DocFileFormat
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int DocumentMapping::writeTableCell(int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, std::vector<short>* grid_write, int& gridIndex, int cellIndex, unsigned int nestingLevel )
{
int cp = initialCp;
int cp = initialCp;
int cpCellEnd = findCellEndCp( initialCp, nestingLevel );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
//start w:tc
m_pXmlWriter->WriteNodeBegin( L"w:tc" );
TableCellPropertiesMapping* tcpMapping = new TableCellPropertiesMapping( m_pXmlWriter, grid, grid_write, gridIndex, cellIndex );
@ -1530,7 +1555,7 @@ namespace DocFileFormat
RELEASEOBJECT( tcpMapping );
//write the paragraphs of the cell
//write the paragraphs of the cell
while ( cp < cpCellEnd )
{
//cp = writeParagraph(cp);
@ -1561,7 +1586,7 @@ namespace DocFileFormat
}
}
//end w:tc
//end w:tc
m_pXmlWriter->WriteNodeEnd( L"w:tc" );
return cp;

View File

@ -48,6 +48,8 @@
#include "OleObjectMapping.h"
#include "ConversionContext.h"
#include "IMapping.h"
#include "FormFieldData.h"
#include "FormFieldDataMapping.h"
namespace DocFileFormat
{

View File

@ -48,7 +48,8 @@ namespace DocFileFormat
class FontFamilyName: public ByteStructure
{
friend class CharacterPropertiesMapping;
friend class WordDocument;
friend class CharacterPropertiesMapping;
friend class DocumentMapping;
friend class FontTableMapping;
friend class StyleSheetMapping;

View File

@ -34,32 +34,30 @@
namespace DocFileFormat
{
FontTableMapping::FontTableMapping( ConversionContext* ctx ): AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
FontTableMapping::FontTableMapping( ConversionContext* ctx ) : AbstractOpenXmlMapping( new XMLTools::CStringXmlWriter() )
{
_ctx = ctx;
}
/*========================================================================================================*/
FontTableMapping::~FontTableMapping()
{
RELEASEOBJECT (m_pXmlWriter);
}
/*========================================================================================================*/
void FontTableMapping::Apply( IVisitable* visited )
{
StringTable<FontFamilyName>* table = static_cast<StringTable<FontFamilyName>*>( visited );
this->_ctx->_docx->RegisterFontTable();
_ctx->_docx->RegisterFontTable();
m_pXmlWriter->WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_pXmlWriter->WriteNodeBegin( L"w:fonts", TRUE );
m_pXmlWriter->WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
int sz_fonts = table->Data.size();
int sz_fonts = table->Data.size();
int users_fonts = 0;
for ( std::vector<ByteStructure*>::iterator iter = table->Data.begin(); iter != table->Data.end(); iter++ )
@ -140,6 +138,6 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"w:fonts");
this->_ctx->_docx->FontTableXML = std::wstring( m_pXmlWriter->GetXmlString() );
_ctx->_docx->FontTableXML = m_pXmlWriter->GetXmlString() ;
}
}

View File

@ -0,0 +1,170 @@
/*
* (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 "FormFieldData.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
namespace DocFileFormat
{
std::wstring readXstz(VirtualStreamReader *reader)
{
if (!reader) return L"";
unsigned short flags, cch, chTerm;
cch = reader->ReadUInt16();
std::wstring ret;
if (cch > 0)
{
std::shared_ptr<unsigned char>data = std::shared_ptr<unsigned char>(reader->ReadBytes(cch * 2, true));
#if defined(_WIN32) || defined(_WIN64)
ret = std::wstring((wchar_t*)data.get(), cch );
#else
ret = convertUtf16ToWString((UTF16*)data.get(), cch );
#endif
}
chTerm = reader->ReadUInt16();
return ret;
};
void FormFieldData::_HFD::read(VirtualStreamReader *reader)
{
if (!reader) return;
}
void FormFieldData::_FFData::read(VirtualStreamReader *reader)
{
if (!reader) return;
bExist = true;
unsigned short flags;
version = reader->ReadUInt32();
flags = reader->ReadUInt16();
iType = GETBITS(flags, 0, 1);
iRes = GETBITS(flags, 2, 6);
fOwnHelp = GETBIT(flags, 7);
fOwnStat = GETBIT(flags, 8);
fProt = GETBIT(flags, 9);
iSize = GETBIT(flags, 10);
iTypeTxt = GETBITS(flags, 11, 13);
fRecalc = GETBIT(flags, 14);
fHasListBox = GETBIT(flags, 15);
cch_field = reader->ReadUInt16();
hps = reader->ReadUInt16();
xstzName = readXstz(reader);
xstzTextDef = readXstz(reader);
wDef = reader->ReadUInt16();
xstzTextFormat = readXstz(reader);
xstzHelpText = readXstz(reader);
xstzStatText = readXstz(reader);
xstzEntryMcr = readXstz(reader);
xstzExitMcr = readXstz(reader);
}
FormFieldData::FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion_ )
{
binary_data_size = 0;
if (!chpx) return;
int fc = -1;
bool bNilPICFAndBinData = false;
for ( std::list<SinglePropertyModifier>::iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{
switch ( iter->OpCode)
{
case sprmCFSpec:
{
}
break;
case sprmCFFldVanish:
{
}
break;
case sprmCPicLocation:
{
fc = FormatUtils::BytesToInt32( iter->Arguments, 0, iter->argumentsSize );
}
break;
case sprmCRsidText:
{
rsid = FormatUtils::IntToFormattedWideString(FormatUtils::BytesToInt32(iter->Arguments, 0, iter->argumentsSize), L"%08x");
}
break;
case sprmCFData:
{
bNilPICFAndBinData = true; // or bPICFAndOfficeArtData - shape, pic, ole
}
break;
}
}
if (fc >= 0 && bNilPICFAndBinData)
{
VirtualStreamReader reader(stream, fc, bOlderVersion_);
int sz_stream = reader.GetSize();
int lcb = reader.ReadUInt32();
int cbHeader = reader.ReadUInt16();
if (cbHeader != 0x44) return;
//ignored
reader.ReadBytes(62, false);
switch(type)
{
case 1:
HFD.read(&reader);
case 2:
FFData.read(&reader);
break;
default:
binary_data_size = lcb - cbHeader;
binary_data = std::shared_ptr<unsigned char>(reader.ReadBytes(binary_data_size, true));
break;
}
}
}
}

View File

@ -0,0 +1,126 @@
/*
* (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 "IVisitable.h"
#include "CharacterPropertyExceptions.h"
#include "StructuredStorageReader.h"
#include "VirtualStreamReader.h"
namespace DocFileFormat
{
class FormFieldData : public IVisitable
{
public:
struct _HFD
{
bool bExist = false;
bool fNew = false;
bool fNoHist = false;
bool fImageMap = false;
bool fLocation = false;
bool fTooltip = false;
std::wstring clsid;
_UINT32 streamVersion = 0;
bool hlstmfHasMoniker = false;
bool hlstmfIsAbsolute = false;
bool hlstmfSiteGaveDisplayName = false;
bool hlstmfHasLocationStr = false;
bool hlstmfHasDisplayName = false;
bool hlstmfHasGUID = false;
bool hlstmfHasCreationTime = false;
bool hlstmfHasFrameName = false;
bool hlstmfMonikerSavedAsStr = false;
bool hlstmfAbsFromGetdataRel = false;
std::wstring displayName;
std::wstring targetFrameName;
std::wstring moniker;
std::wstring oleMoniker_clsid;
std::wstring oleMoniker_data;
std::wstring location;
std::wstring guid;
_UINT64 fileTime = 0;
void read(VirtualStreamReader* reader);
};
struct _FFData
{
bool bExist = false;
_UINT32 version = 0;
unsigned char iType = 0;
unsigned char iRes = 0;
bool fOwnHelp = false;
bool fOwnStat = false;
bool fProt = false;
bool iSize = false;
unsigned char iTypeTxt = 0;
bool fRecalc = false;
bool fHasListBox = false;
unsigned short cch_field = 0;
unsigned short hps = 0;
std::wstring xstzName;
std::wstring xstzTextDef;
unsigned short wDef = 0;
std::wstring xstzTextFormat;
std::wstring xstzHelpText;
std::wstring xstzStatText;
std::wstring xstzEntryMcr;
std::wstring xstzExitMcr;
//STTB hsttbDropList;
void read(VirtualStreamReader* reader);
};
FormFieldData( int type, const CharacterPropertyExceptions* chpx, POLE::Stream* stream, bool bOlderVersion );
virtual ~FormFieldData() {}
private:
friend class FormFieldDataMapping;
std::wstring name;
std::wstring rsid;
_FFData FFData;
_HFD HFD;
std::shared_ptr<unsigned char> binary_data;
int binary_data_size;
};
}

View File

@ -0,0 +1,87 @@
/*
* (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 "ConversionContext.h"
#include "FormFieldData.h"
#include "AbstractOpenXmlMapping.h"
#include "IMapping.h"
namespace DocFileFormat
{
class FormFieldDataMapping: public AbstractOpenXmlMapping, public IMapping
{
public:
FormFieldDataMapping(XMLTools::CStringXmlWriter* writer, ConversionContext* context, IMapping* caller)
: AbstractOpenXmlMapping(writer), m_context(NULL),_caller(NULL)
{
m_context = context;
_caller = caller;
}
virtual void Apply(IVisitable* visited)
{
FormFieldData* ffData = static_cast<FormFieldData*>(visited);
if ( ffData == NULL ) return;
if (ffData->FFData.bExist)
{
m_pXmlWriter->WriteNodeBegin( L"w:ffData");
m_pXmlWriter->WriteNodeBegin( L"w:name", true);
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.xstzName);
m_pXmlWriter->WriteNodeEnd(L"w:name", true, true );
m_pXmlWriter->WriteNodeBegin( L"w:calcOnExit", true);
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.fRecalc);
m_pXmlWriter->WriteNodeEnd(L"w:calcOnExit", true, true );
m_pXmlWriter->WriteNodeBegin( L"w:textInput");
m_pXmlWriter->WriteNodeBegin( L"w:maxLength", true);
m_pXmlWriter->WriteAttribute(L"w:val", ffData->FFData.cch_field);
m_pXmlWriter->WriteNodeEnd(L"w:maxLength", true, true );
m_pXmlWriter->WriteNodeEnd( L"w:textInput" );
m_pXmlWriter->WriteNodeEnd( L"w:ffData" );
}
}
private:
ConversionContext* m_context;
IMapping* _caller;
};
}

View File

@ -33,6 +33,9 @@
#include "IMapping.h"
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
#define GETBIT(from, num) ((from & (1 << num)) != 0)
namespace DocFileFormat
{
class IVisitable

View File

@ -38,8 +38,8 @@ namespace DocFileFormat
{
if (m_context)
{
m_document = m_context->GetDocument();
m_xmldocument = m_context->GetXmlDocument();
m_document = m_context->_doc;
m_xmldocument = m_context->_docx;
}
}
@ -582,7 +582,7 @@ namespace DocFileFormat
// The style id is used for a reverse reference.
// It can happen that the reference points to the wrong style.
if (styleIndex != ListData::ISTD_NIL)
if (styleIndex != ListData::ISTD_NIL && styleIndex < m_document->Styles->Styles->size())
{
m_pXmlWriter->WriteNodeBegin( L"w:pStyle", TRUE );
m_pXmlWriter->WriteAttribute( L"w:val", FormatUtils::XmlEncode(StyleSheetMapping::MakeStyleId(m_document->Styles->Styles->at(styleIndex))));

View File

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

View File

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

View File

@ -53,62 +53,31 @@ namespace DocFileFormat
PathParser (const unsigned char* pSegmentInfo, unsigned int pSegmentInfoSize, const unsigned char* pVertices, unsigned int pVerticesSize, std::vector<_guides> & guides)
{
int offset = 6;
if ((pSegmentInfo != NULL) && (pSegmentInfoSize > 0))
{
int offset = 6;
unsigned short nElems = FormatUtils::BytesToUInt16(pSegmentInfo, 0, pSegmentInfoSize);
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pSegmentInfo, 2, pSegmentInfoSize);
unsigned short cb = FormatUtils::BytesToUInt16(pSegmentInfo, 4, pSegmentInfoSize);
// видимо без шапки сразу пишутся все элементы
bool headerIs = ((0xfff0 != cb) && (cb > 8) || nElems > nElemsAlloc);
if (headerIs)
{
cb = 2;
offset = 0;
nElems = pSegmentInfoSize / 2;
unsigned short cbElement = 4;
for (unsigned short i = 0; i < nElems; ++i)
{
PathSegment oSegment = PathSegment(FormatUtils::BytesToUInt16(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
m_arSegments.push_back (oSegment);
}
}
else
if (cb == 0xfff0)
cbElement = 2;
if (nElems == 0)
{
if ((0xfff0 != cb) && (8 != cb) && (4 != cb) && (2 != cb))
{
cb = 0xfff0;
offset = 0;
nElems = pSegmentInfoSize / 2;
}
if (0xfff0 == cb)
{
cb = 4;
for (unsigned short i = 0; i < nElems; ++i)
{
PathSegment oSegment = PathSegment(FormatUtils::BytesToUInt16(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
m_arSegments.push_back (oSegment);
}
}
else
{
if ((2 != cb) && (1 != cb))
cb = 8;
for (unsigned short i = 0; i < nElems; ++i)
{
PathSegment oSegment = PathSegment(FormatUtils::BytesToInt32(pSegmentInfo + offset, (i * cb), pSegmentInfoSize));
m_arSegments.push_back (oSegment);
}
if ((long)pSegmentInfoSize < (long)(cb*nElems)) // Есть несколько файлов с мусором вместо данных
m_arSegments.clear();
}
nElems = (pSegmentInfoSize - offset) / cbElement;
}
for (unsigned short i = 0; i < nElems; ++i)
{
PathSegment oSegment = PathSegment(FormatUtils::BytesToInt32(pSegmentInfo + offset, (i * cbElement), pSegmentInfoSize - offset));
m_arSegments.push_back (oSegment);
}
if ((long)pSegmentInfoSize < (long)(cb * nElems)) // Есть несколько файлов с мусором вместо данных
m_arSegments.clear();
}
if ((NULL != pVertices) && (pVerticesSize > 0))
@ -117,26 +86,30 @@ namespace DocFileFormat
unsigned short nElemsAlloc = FormatUtils::BytesToUInt16(pVertices, 2, pVerticesSize);
unsigned short cb = FormatUtils::BytesToUInt16(pVertices, 4, pVerticesSize);
unsigned short cbElement = cb;
if (cb == 0xfff0)
cbElement = 4;
for (unsigned short i = 0; i < nElems; ++i)
{
POINT point;
if (0xfff0 == cb)
if (cbElement == 4)
{
cb = 4;
point.x = FormatUtils::BytesToInt16(pVertices + 6, (i * cb), pVerticesSize);
point.y = FormatUtils::BytesToInt16(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
point.x = FormatUtils::BytesToInt16(pVertices + offset, (i * cbElement), pVerticesSize - offset);
point.y = FormatUtils::BytesToInt16(pVertices + offset, (i * cbElement) + (cbElement / 2), pVerticesSize - offset);
}
else
{
point.x = FormatUtils::BytesToInt32(pVertices + 6, (i * cb), pVerticesSize);
point.y = FormatUtils::BytesToInt32(pVertices + 6, (i * cb) + (cb / 2), pVerticesSize);
point.x = FormatUtils::BytesToInt32(pVertices + offset, (i * cbElement), pVerticesSize - offset);
point.y = FormatUtils::BytesToInt32(pVertices + offset, (i * cbElement) + (cbElement / 2), pVerticesSize - offset);
}
LONG lMinF = (LONG)0x80000000;
if (lMinF <= point.x)
{
int index = (DWORD)point.x - 0x80000000;
if (index >= 0 && index < (int)guides.size())
if (index >= 0 && index < guides.size())
{
point.x = guides[index].param3;
}
@ -144,7 +117,7 @@ namespace DocFileFormat
if (lMinF <= point.y)
{
int index = (DWORD)point.y - 0x80000000;
if (index >= 0 && index < (int)guides.size())
if (index >= 0 && index < guides.size())
{
point.y = guides[index].param3;
}

View File

@ -597,16 +597,12 @@ namespace DocFileFormat
virtual ~ShapeOptions()
{
//for (std::vector<OptionEntry>::iterator iter = Options.begin(); iter != Options.end(); ++iter)
// RELEASEARRAYOBJECTS( iter->opComplex );
}
ShapeOptions (IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance) : Record (_reader, size, typeCode, version, instance)
{
long pos = Reader->GetPosition();
//instance is the count of properties stored in this record
//parse the flags and the simple values
for (unsigned int i = 0; i < instance; ++i)
{
@ -621,9 +617,7 @@ namespace DocFileFormat
Options.push_back( entry );
}
//parse the complex values
//these values are stored directly at the end
//of the OptionEntry arry, sorted by pid
//parse the complex values & sorted by pid
for (unsigned int i = 0; i < instance; ++i)
{
if (Options[i]->fComplex && Options[i]->op > 0)

View File

@ -43,6 +43,7 @@
#include "MainDocumentMapping.h"
#include "OleObjectMapping.h"
#include "VMLPictureMapping.h"
#include "FormFieldDataMapping.h"
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Directory.h"
@ -144,9 +145,9 @@ namespace DocFileFormat
{
if (docFile == NULL) return S_FALSE;
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
POLE::Storage *storageOut = new POLE::Storage(fileName.c_str());
if (storageOut == NULL) return S_FALSE;
if (storageOut->open(true, true)==false)
{
delete storageOut;
@ -163,7 +164,7 @@ namespace DocFileFormat
std::wstring path = L"ObjectPool/" + oleObjectFileStructure.objectID;
std::list<std::wstring> entries = storageInp->entries(path);
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++)
for (std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it)
{
POLE::Stream *stream_inp = new POLE::Stream(storageInp, path + L"/"+ (*it));
if (stream_inp == NULL)continue;

View File

@ -462,57 +462,60 @@ namespace DocFileFormat
void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc )
{
std::wstring pattern = getShadingPattern( desc );
if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal ))
{
XMLTools::XMLElement shd( L"w:shd" );
//fill color
XMLTools::XMLAttribute fill( L"w:fill" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvBackAuto )
{
fill.SetValue( L"auto" );
}
else
{
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
}
}
else
{
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( fill );
//foreground color
XMLTools::XMLAttribute color( L"w:color" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvForeAuto )
{
color.SetValue( L"auto" );
}
else
{
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
}
}
else
{
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( color );
//pattern
XMLTools::XMLAttribute val( L"w:val" );
val.SetValue( getShadingPattern( desc ));
val.SetValue( pattern);
shd.AppendAttribute( val );
if (pattern != L"nil")
{
//fill color
XMLTools::XMLAttribute fill( L"w:fill" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvBackAuto )
{
fill.SetValue( L"auto" );
}
else
{
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
}
}
else
{
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( fill );
//foreground color
XMLTools::XMLAttribute color( L"w:color" );
if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvForeAuto )
{
color.SetValue( L"auto" );
}
else
{
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
}
}
else
{
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( color );
}
parent->RemoveChildByName( L"w:shd" );
parent->AppendChild( shd );
}

View File

@ -40,19 +40,13 @@ namespace DocFileFormat
RELEASEOBJECT( Changes );
}
/*========================================================================================================*/
RevisionData::RevisionData():
Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
{
this->Changes = new std::list<SinglePropertyModifier>();
}
/*========================================================================================================*/
/// Collects the revision data of a CHPX
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ):
Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
RevisionData::RevisionData( CharacterPropertyExceptions* chpx ) : Dttm(), Isbt(0), Type(NoRevision), Changes(NULL), RsidDel(0), RsidProp(0), Rsid(0)
{
bool collectRevisionData = true;
this->Changes = new std::list<SinglePropertyModifier>();

View File

@ -174,9 +174,9 @@ namespace DocFileFormat
//it's a Word 97 SPRM
short val = FormatUtils::BytesToInt16(bytes, 0, size);
icoFore = (val & 0x1F);
icoBack = ((val >> 5) & 0x1F);
ipat = (ShadingPattern) ((val >> 10) & 0x3F);
icoFore = GETBITS(val, 0, 4);
icoBack = GETBITS(val, 5, 9);
ipat = (ShadingPattern) GETBITS(val, 10, 15);
shadingType = shadingTypeShd80;
@ -209,7 +209,7 @@ namespace DocFileFormat
else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); }
else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); }
if (0x00 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); cvBackAuto = true; }
if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; }
else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); }
else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); }
else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); }

View File

@ -41,6 +41,7 @@ namespace DocFileFormat
{
template<class T> class StringTable: public IVisitable
{
friend class WordDocument;
friend class CharacterPropertiesMapping;
friend class FontTableMapping;
friend class StyleSheetMapping;

View File

@ -90,7 +90,7 @@ namespace DocFileFormat
std::list<std::wstring> entries, entries_sort;
entries = m_pStorage->entries_with_prefix( path );
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
{
std::wstring name = *it;
std::wstring fullname = path + name;
@ -104,8 +104,8 @@ namespace DocFileFormat
entries_sort.push_front(name);
}
}
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); it++ )
//for( std::list<std::string>::iterator it = entries.begin(); it != entries.end(); ++it )
for( std::list<std::wstring>::iterator it = entries_sort.begin(); it != entries_sort.end(); ++it )
{
std::wstring name = *it;
std::wstring fullname = path + name;

View File

@ -354,7 +354,7 @@ namespace DocFileFormat
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)
{
if (sprmArg)
if (sprmArg && cellIndex >= 0)
{
//shading descriptor can have 10 bytes (Word 2000) or 2 bytes (Word 97)
int shdLength = 2;

View File

@ -156,33 +156,35 @@ namespace DocFileFormat
file.CloseFile();
OOX::CPath path(sTempXmlFile);
OOX::CDocument docEmbedded(path, path);
OOX::CDocument docEmbedded(NULL, path, path);
bool res = false;
for (size_t i = 0 ; i < docEmbedded.m_arrItems.size(); i++)
for (std::vector<OOX::WritingElement*>::iterator it = docEmbedded.m_arrItems.begin(); it != docEmbedded.m_arrItems.end(); ++it)
{
if (docEmbedded.m_arrItems[i]->getType() == OOX::et_w_p)
if ((*it)->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(docEmbedded.m_arrItems[i]);
OOX::Logic::CParagraph *paragraph = dynamic_cast<OOX::Logic::CParagraph *>(*it);
for (size_t j = 0; (paragraph) && (j < paragraph->m_arrItems.size()); j++)
for (std::vector<OOX::WritingElement*>::iterator jt = paragraph->m_arrItems.begin();
(paragraph) && (jt != paragraph->m_arrItems.end()); jt++)
{
if (paragraph->m_arrItems[j]->getType() == OOX::et_m_oMath)
if ((*jt)->getType() == OOX::et_m_oMath)
{
res = true;
newXmlString = paragraph->m_arrItems[j]->toXML();
newXmlString = (*jt)->toXML();
break;
}
else if (paragraph->m_arrItems[j]->getType() == OOX::et_m_oMathPara)
else if ((*jt)->getType() == OOX::et_m_oMathPara)
{
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(paragraph->m_arrItems[j]);
OOX::Logic::COMathPara *mathPara = dynamic_cast<OOX::Logic::COMathPara *>(*jt);
for (size_t k = 0; (mathPara) && (k < mathPara->m_arrItems.size()); k++)
for (std::vector<OOX::WritingElement*>::iterator kt = mathPara->m_arrItems.begin();
(mathPara) && (kt != mathPara->m_arrItems.end()); kt++)
{
if (mathPara->m_arrItems[k]->getType() == OOX::et_m_oMath)
if ((*kt)->getType() == OOX::et_m_oMath)
{
res = true;
newXmlString = mathPara->m_arrItems[k]->toXML();
newXmlString = (*kt)->toXML();
break;
}
}
@ -498,6 +500,7 @@ namespace DocFileFormat
{
case Global::msoblipEMF:
case Global::msoblipWMF:
case Global::msoblipPICT:
{
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(oBlipEntry->Blip);
if (metaBlip)
@ -565,6 +568,9 @@ namespace DocFileFormat
case Global::msoblipWMF:
return std::wstring(L".wmf");
case Global::msoblipPICT:
return std::wstring(L".pcz");
default:
return std::wstring(L".png");
}
@ -599,6 +605,9 @@ namespace DocFileFormat
case Global::msoblipWMF:
return std::wstring(OpenXmlContentTypes::Wmf);
case Global::msoblipPICT:
return std::wstring(OpenXmlContentTypes::Pcz);
case Global::msoblipDIB:
return std::wstring(OpenXmlContentTypes::Bmp);

View File

@ -288,6 +288,7 @@ namespace DocFileFormat
int ndyTextBottom = -1;
bool bHavePath = false;
int nShapePath = -1;
int nAdjValues = 0;
int nLTxID = -1;
@ -361,6 +362,7 @@ namespace DocFileFormat
case shapePath :
{
bHavePath = true;
nShapePath = iter->op;
}break;
case pVertices:
{
@ -1285,6 +1287,7 @@ namespace DocFileFormat
{
case Global::msoblipEMF:
case Global::msoblipWMF:
case Global::msoblipPICT:
{
//it's a meta image
MetafilePictBlip* metaBlip = static_cast<MetafilePictBlip*>(RecordFactory::ReadRecord(&reader, 0));
@ -1371,6 +1374,9 @@ namespace DocFileFormat
case Global::msoblipWMF:
return std::wstring( L".wmf" );
case Global::msoblipPICT:
return std::wstring( L".pcz" );
default:
return std::wstring( L".png" );
}
@ -1653,7 +1659,7 @@ namespace DocFileFormat
}
if (!bRelV && m_pSpa)
{
appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->bx));
appendStyleProperty(oStyle, L"mso-position-vertical-relative", mapVerticalPositionRelative(m_pSpa->by));
}
if (!m_isInlineShape && !bZIndex)
{
@ -2165,7 +2171,7 @@ namespace DocFileFormat
//todooo нарисовать кастомный шейп
}
else
WritePrimitiveProps(primitive, (index==0 ? true : false));
WritePrimitiveProps(primitive, (index==0?true:false));
if (primitive->type == 0x0000)

View File

@ -40,8 +40,45 @@
#include "../../DesktopEditor/common/File.h"
#include "../../DesktopEditor/common/Directory.h"
#include <unordered_map>
namespace DocFileFormat
{
static const int aCodePages[][2] = {
//charset codepage
0, 1252, //ANSI
1, 0,//Default
2, 42,//Symbol
77, 10000,//Mac Roman
78, 10001,//Mac Shift Jis
79, 10003,//Mac Hangul
80, 10008,//Mac GB2312
81, 10002,//Mac Big5
83, 10005,//Mac Hebrew
84, 10004,//Mac Arabic
85, 10006,//Mac Greek
86, 10081,//Mac Turkish
87, 10021,//Mac Thai
88, 10029,//Mac East Europe
89, 10007,//Mac Russian
128, 932,//Shift JIS
129, 949,//Hangul
130, 1361,//Johab
134, 936,//GB2312
136, 950,//Big5
238, 1250,//Greek
161, 1253,//Greek
162, 1254,//Turkish
163, 1258,//Vietnamese
177, 1255,//Hebrew
178, 1256, //Arabic
186, 1257,//Baltic
204, 1251,//Russian
222, 874,//Thai
238, 1250,//Eastern European
254, 437,//PC 437
255, 850//OEM
};
WordDocument::WordDocument (const ProgressCallback* pCallFunc, const std::wstring & sTempFolder ) :
m_PieceTable(NULL), WordDocumentStream(NULL), TableStream(NULL), DataStream(NULL), FIB(NULL),
Text(NULL), RevisionAuthorTable(NULL), FontTable(NULL), BookmarkNames(NULL), AutoTextNames(NULL),
@ -55,12 +92,15 @@ namespace DocFileFormat
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL),
AnnotStartPlex(NULL), AnnotEndPlex(NULL), encryptionHeader(NULL)
{
m_pCallFunc = pCallFunc;
m_sTempFolder = sTempFolder;
m_pCallFunc = pCallFunc;
m_sTempFolder = sTempFolder;
m_pStorage = NULL;
officeArtContent = NULL;
bOlderVersion = false;
m_pStorage = NULL;
officeArtContent = NULL;
bOlderVersion = false;
bDocumentCodePage = false;
nDocumentCodePage = ENCODING_WINDOWS_1250;
}
WordDocument::~WordDocument()
@ -178,8 +218,6 @@ namespace DocFileFormat
m_pStorage->GetStream (L"SummaryInformation", &Summary);
m_pStorage->GetStream (L"DocumentSummaryInformation", &DocSummary);
document_code_page = ENCODING_WINDOWS_1250;
if ((Summary) && (Summary->size() > 0))
{
@ -188,7 +226,10 @@ namespace DocFileFormat
int document_code_page1 = summary_info.GetCodePage(); //from software last open
if (document_code_page1 > 0)
document_code_page = document_code_page1;
{
nDocumentCodePage = document_code_page1;
bDocumentCodePage = true;
}
}
if ((DocSummary) && (DocSummary->size() > 0))
{
@ -197,12 +238,18 @@ namespace DocFileFormat
int document_code_page2 = doc_summary_info.GetCodePage();
if (document_code_page2 > 0)
document_code_page = document_code_page2;
{
nDocumentCodePage = document_code_page2;
bDocumentCodePage = true;
}
}
if (!bOlderVersion)
document_code_page = ENCODING_UTF16;
{
nDocumentCodePage = ENCODING_UTF16;
bDocumentCodePage = true;
}
FIB->m_CodePage = document_code_page;
FIB->m_CodePage = nDocumentCodePage;
//-------------------------------------------------------------------------------------------------
try
{
@ -353,6 +400,31 @@ namespace DocFileFormat
return AVS_ERROR_FILEFORMAT;
}
}
if (!bDocumentCodePage && FontTable)
{
std::unordered_map<int, int> fonts_charsets;
for ( std::vector<ByteStructure*>::iterator iter = FontTable->Data.begin();!bDocumentCodePage && iter != FontTable->Data.end(); iter++ )
{
FontFamilyName* font = dynamic_cast<FontFamilyName*>( *iter );
if (!font) continue;
if (fonts_charsets.find(font->chs) == fonts_charsets.end())
{
fonts_charsets.insert(std::make_pair(font->chs, font->ff));
for (int i = 0 ; i < sizeof(aCodePages) / 2; i++)
{
if (aCodePages[i][0] == font->chs && font->chs != 0)
{
nDocumentCodePage = aCodePages[i][1];
bDocumentCodePage = true;
break;
}
}
}
}
}
if (FIB->m_FibWord97.lcbClx > 0)
{
@ -371,7 +443,7 @@ namespace DocFileFormat
WordDocumentStream->read (bytes, cb);
Text = new std::vector<wchar_t>();
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, document_code_page);
FormatUtils::GetSTLCollectionFromBytes<std::vector<wchar_t> >(Text, bytes, cb, nDocumentCodePage);
RELEASEARRAYOBJECTS(bytes);
}
@ -487,7 +559,7 @@ namespace DocFileFormat
//std::list<std::string> listStream = storageIn->entries();
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
//for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); ++it)
//{
// if (storageIn->isDirectory(*it))
// {
@ -531,7 +603,7 @@ namespace DocFileFormat
std::list<std::wstring> entries, entries_files, entries_dir;
entries = storageIn->entries_with_prefix( path );
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); it++ )
for( std::list<std::wstring>::iterator it = entries.begin(); it != entries.end(); ++it )
{
std::wstring name = *it;
std::wstring fullname = path + name;

View File

@ -69,7 +69,6 @@ namespace DocFileFormat
{
class WordDocument: public IVisitable
{
/*Mapping classes with direct access to the Word Document.*/
friend class FootnotesMapping;
friend class EndnotesMapping;
friend class CommentsMapping;
@ -98,7 +97,8 @@ namespace DocFileFormat
long LoadDocument (const std::wstring & fileName, const std::wstring & password);
bool bOlderVersion;
int document_code_page;
int nDocumentCodePage;
bool bDocumentCodePage;
inline StructuredStorageReader* GetStorage() const
{

View File

@ -94,6 +94,7 @@ SOURCES += \
../../DocDocxConverter/VMLShapeTypeMapping.cpp \
../../DocDocxConverter/WordDocument.cpp \
../../DocDocxConverter/WordprocessingDocument.cpp \
../../DocDocxConverter/FormFieldData.cpp \
../../DocDocxConverter/OfficeDrawing/Record.cpp \
../../DocDocxConverter/OfficeDrawing/RecordFactory.cpp \
../../DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp

View File

@ -74,6 +74,7 @@
#include "../../DocDocxConverter/VMLShapeTypeMapping.cpp"
#include "../../DocDocxConverter/WordDocument.cpp"
#include "../../DocDocxConverter/WordprocessingDocument.cpp"
#include "../../DocDocxConverter/FormFieldData.cpp"
#include "../../DocDocxConverter/OfficeDrawing/Record.cpp"
#include "../../DocDocxConverter/OfficeDrawing/RecordFactory.cpp"
#include "../../DocDocxConverter/OfficeDrawing/ShapeTypeFactory.cpp"

View File

@ -47,7 +47,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
@ -479,6 +479,14 @@
RelativePath="..\..\DocDocxConverter\FormattedDiskPagePAPX.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\FormFieldData.cpp"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\FormFieldData.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\Global.h"
>
@ -1090,6 +1098,10 @@
RelativePath="..\..\DocDocxConverter\FootnotesMapping.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\FormFieldDataMapping.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\HeaderMapping.cpp"
>

View File

@ -29,19 +29,17 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
// DocFormatTest.cpp : Defines the entry point for the console application.
//
#include "../DocFormatLib/DocFormatLib.h"
#include "../../OfficeUtils/src/ASCOfficeCriticalSection.h"
#include <iostream>
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../OfficeUtils/src/OfficeUtils.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../DocFormatLib/DocFormatLib.h"
#include <string>
#include <windows.h>
#include <tchar.h>
#pragma comment(lib,"Shell32.lib")
#pragma comment(lib,"Advapi32.lib")
#pragma comment(lib,"Rpcrt4.lib")
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
@ -49,34 +47,34 @@
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
HRESULT convert_single(std::wstring sSrcDoc)
HRESULT convert_single(std::wstring srcFileName)
{
HRESULT hr = S_OK;
std::wstring outputDir = NSDirectory::GetFolderPath(sSrcDoc);
std::wstring outputDir = NSDirectory::GetFolderPath(srcFileName);
std::wstring dstTempPath = NSDirectory::CreateDirectoryWithUniqueName(outputDir);
std::wstring dstPath;
COfficeDocFile docFile;
docFile.m_sTempFolder = outputDir;
bool bMacros = true;
HRESULT hRes = docFile.LoadFromFile( sSrcDoc, dstTempPath, L"password", bMacros, NULL);
HRESULT hRes = docFile.LoadFromFile( srcFileName, dstTempPath, L"password", bMacros, NULL);
std::wstring sDstDocx;
if (bMacros)
{
sDstDocx = sSrcDoc + L"-my.docm";
dstPath = srcFileName + L"-my.docm";
}
else
{
sDstDocx = sSrcDoc + L"-my.docx";
dstPath = srcFileName + L"-my.docx";
}
if (hRes == S_OK)
{
COfficeUtils oCOfficeUtils(NULL);
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), sDstDocx, -1);
hRes = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath, -1);
}
NSDirectory::DeleteDirectory(dstTempPath);

View File

@ -48,7 +48,7 @@
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"
RuntimeLibrary="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
@ -67,7 +67,7 @@
Name="VCLinkerTool"
AdditionalDependencies="Urlmon.lib"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMT.lib"
IgnoreDefaultLibraryNames=""
IgnoreEmbeddedIDL="true"
GenerateDebugInformation="true"
SubSystem="1"
@ -392,6 +392,14 @@
<File
RelativePath="..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/bigobj"
/>
</FileConfiguration>
</File>
</Filter>
<File
@ -442,6 +450,10 @@
RelativePath="..\..\Common\OfficeFileFormatChecker2.cpp"
>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>

View File

@ -55,7 +55,9 @@ namespace Writers
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: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\" \

View File

@ -60,16 +60,50 @@ namespace Writers
std::wstring rId;
SimpleTypes::EHdrFtr eType;
};
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr 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\">");
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<w:hdr 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:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_hdr_End = _T("</w:hdr>");
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:ftr 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\">");
static std::wstring g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\
<w:ftr 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:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_ftr_End = _T("</w:ftr>");
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes 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\">");
static std::wstring g_string_footnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:footnotes 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\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_footnotes_End = _T("</w:footnotes>");
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes 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\">");
static std::wstring g_string_endnotes_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:endnotes 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\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" mc:Ignorable=\"w14 wp14\">");
static std::wstring g_string_endnotes_End = _T("</w:endnotes>");
class HeaderFooterWriter

View File

@ -355,10 +355,13 @@ class Tab
public:
BYTE Val;
double Pos;
BYTE Leader;
bool bLeader;
Tab()
{
Val = shd_Nil;
Pos = 0;
bLeader = false;
}
};
class Tabs
@ -369,7 +372,7 @@ public:
class rPr
{
private:
std::map<std::wstring, int>& m_mapFonts;
boost::unordered_map<std::wstring, int>& m_mapFonts;
public:
bool Bold;
bool Italic;
@ -442,7 +445,7 @@ public:
bool bDoNotWriteNullProp;
public:
rPr(std::map<std::wstring, int>& mapFonts) : m_mapFonts(mapFonts)
rPr(boost::unordered_map<std::wstring, int>& mapFonts) : m_mapFonts(mapFonts)
{
Reset();
@ -1784,8 +1787,8 @@ w15:paraIdParent=\"" + pComment->m_sParaIdParent + L"\" w15:done=\"" + sDone + L
};
class CComments
{
std::map<int, CComment*> m_mapComments;
std::map<std::wstring, CComment*> m_mapAuthors;
boost::unordered_map<int, CComment*> m_mapComments;
boost::unordered_map<std::wstring, CComment*> m_mapAuthors;
public:
IdCounter m_oFormatIdCounter;
IdCounter m_oParaIdCounter;
@ -1795,7 +1798,7 @@ public:
}
~CComments()
{
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
delete it->second;
}
@ -1819,7 +1822,7 @@ public:
CComment* get(int nInd)
{
CComment* pRes = NULL;
std::map<int, CComment*>::const_iterator pair = m_mapComments.find(nInd);
boost::unordered_map<int, CComment*>::const_iterator pair = m_mapComments.find(nInd);
if(m_mapComments.end() != pair)
pRes = pair->second;
return pRes;
@ -1831,7 +1834,7 @@ public:
std::wstring writeContent()
{
std::wstring sRes;
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
sRes += (it->second->writeTemplates(CComment::writeContent));
}
@ -1840,7 +1843,7 @@ public:
std::wstring writeContentExt()
{
std::wstring sRes;
for (std::map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
for (boost::unordered_map<int, CComment*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
sRes += (it->second->writeTemplates(CComment::writeContentExt));
}
@ -1849,7 +1852,7 @@ public:
std::wstring writePeople()
{
std::wstring sRes;
for (std::map<std::wstring, CComment*>::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it)
for (boost::unordered_map<std::wstring, CComment*>::const_iterator it = m_mapAuthors.begin(); it != m_mapAuthors.end(); ++it)
{
sRes += (it->second->writePeople(it->second));
}
@ -2337,7 +2340,7 @@ public:
{
return Jc.empty() && TableInd.empty() && TableW.empty() && TableCellMar.empty() && TableBorders.empty() && Shd.empty() && tblpPr.empty()&& Style.empty() && Look.empty() && tblPrChange.empty() && TableCellSpacing.empty() && RowBandSize.empty() && ColBandSize.empty();
}
std::wstring Write(bool bBandSize, bool bLayout)
std::wstring Write()
{
std::wstring sRes;
sRes += L"<w:tblPr>";
@ -2361,13 +2364,8 @@ public:
sRes += (TableBorders);
if(false == Shd.empty())
sRes += (Shd);
if(bLayout)
{
if(false == Layout.empty())
sRes += (Layout);
else if(g_nCurFormatVersion < 4)
sRes += L"<w:tblLayout w:type=\"fixed\"/>";
}
if(false == Layout.empty())
sRes += (Layout);
if(false == TableCellMar.empty())
sRes += (TableCellMar);
if(false == Look.empty())
@ -2755,7 +2753,7 @@ public:
}
if(NULL != tblPr)
{
pCStringWriter->WriteString(tblPr->Write(false, true));
pCStringWriter->WriteString(tblPr->Write());
}
if(NULL != tblGridChange)
{

View File

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

View File

@ -37,7 +37,17 @@
#include "../BinWriter/BinReaderWriterDefines.h"
#include "../../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Document.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FontTable.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Numbering.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Comments.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Styles.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Footnote.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Endnote.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Settings/Settings.h"
#include "../DocWrapper/XlsxSerializer.h"
#include "../../DesktopEditor/common/ASCVariant.h"
@ -61,6 +71,13 @@ enum ETblStyleOverrideType
tblstyleoverridetypeSwCell = 11,
tblstyleoverridetypeWholeTable = 12
};
struct RowHeight
{
unsigned char HRule = 0;
long nHeight = 0;
};
class SdtWraper
{
public:
@ -827,7 +844,23 @@ public:
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(L"<w:tab w:val=\"" + sVal + L"\" w:pos=\"" + std::to_wstring(nTab) + L"\"");
if (oTab.bLeader)
{
std::wstring sLeader;
switch(oTab.Leader)
{
case SimpleTypes::tabtlcDot : sLeader = (L"dot");break;
case SimpleTypes::tabtlcHeavy : sLeader = (L"heavy");break;
case SimpleTypes::tabtlcHyphen : sLeader = (L"hyphen");break;
case SimpleTypes::tabtlcMiddleDot : sLeader = (L"middleDot");break;
case SimpleTypes::tabtlcNone : sLeader = (L"none");break;
case SimpleTypes::tabtlcUnderscore : sLeader = (L"underscore");break;
default : sLeader = (L"none");break;
}
pCStringWriter->WriteString(L" w:leader=\"" + sLeader + L"\"");
}
pCStringWriter->WriteString(L"/>");
}
pCStringWriter->WriteString(std::wstring(L"</w:tabs>"));
}
@ -1008,6 +1041,11 @@ public:
poTabItem->Val = m_oBufferedStream.GetUChar();
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
poTabItem->Pos = m_oBufferedStream.GetDouble();
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
{
poTabItem->bLeader = true;
poTabItem->Leader = m_oBufferedStream.GetUChar();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2090,7 +2128,17 @@ public:
}
else if( c_oSerProp_rowPrType::Height == type )
{
res = Read2(length, &Binary_tblPrReader::ReadHeight, this, poResult);
RowHeight val;
res = Read2(length, &Binary_tblPrReader::ReadHeight, this, &val);
pCStringWriter->WriteString(L"<w:trHeight w:val=\"" + std::to_wstring(val.nHeight) + L"\"");
switch (val.HRule)
{
case 1: pCStringWriter->WriteString(L" w:hRule=\"auto\""); break;
case 2: pCStringWriter->WriteString(L" w:hRule=\"exact\""); break;
}
pCStringWriter->WriteString(L"/>");
}
else if( c_oSerProp_rowPrType::TableHeader == type )
{
@ -2159,17 +2207,17 @@ public:
int ReadHeight(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
XmlUtils::CStringWriter* pCStringWriter = static_cast<XmlUtils::CStringWriter*>(poResult);
/*if( c_oSerProp_rowPrType::Height_Rule == type )
RowHeight* pHeight = static_cast<RowHeight*>(poResult);
if( c_oSerProp_rowPrType::Height_Rule == type )
{
Height.HRule = this.stream.GetUChar();
pHeight->HRule = m_oBufferedStream.GetUChar();
}
else */if( c_oSerProp_rowPrType::Height_Value == type )
else if( c_oSerProp_rowPrType::Height_Value == type )
{
double dHeight = m_oBufferedStream.GetDouble();
long nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
pCStringWriter->WriteString(L"<w:trHeight w:val=\"" + std::to_wstring(nHeight) + L"\"/>");
pHeight->nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
}
else
res = c_oSerConstants::ReadUnknown;
@ -2805,7 +2853,7 @@ public:
{
CWiterTblPr oWiterTblPr;
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
odocStyle->TablePr = oWiterTblPr.Write(true, false);
odocStyle->TablePr = oWiterTblPr.Write();
}
else if(c_oSer_sts::Style_RowPr == type)
{
@ -2901,7 +2949,7 @@ public:
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
if(false == oWiterTblPr.IsEmpty())
ptblStylePr->Writer.WriteString(oWiterTblPr.Write(false, false));
ptblStylePr->Writer.WriteString(oWiterTblPr.Write());
}
else if(c_oSerProp_tblStylePrType::TrPr == type)
{
@ -2943,7 +2991,7 @@ public:
int Read()
{
return ReadTable(&Binary_OtherTableReader::ReadOtherContent, this);
};
}
int ReadOtherContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -2953,7 +3001,7 @@ public:
}
else if(c_oSerOtherTableTypes::DocxTheme == type)
{
smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme();
smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme(NULL);
pTheme->fromPPTY(&m_oBufferedStream);
NSBinPptxRW::CXmlWriter xmlWriter;
pTheme->toXmlWriter(&xmlWriter);
@ -2962,7 +3010,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
int ReadImageMapContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3005,7 +3053,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
}
};
class Binary_CommentsTableReader : public Binary_CommonReader<Binary_CommentsTableReader>
{
@ -3713,6 +3761,33 @@ public:
res = Read2(length, &Binary_DocumentTableReader::Read_Background, this, &oBackground);
m_oDocumentWriter.m_oBackground.WriteString(oBackground.Write());
}
else if ( c_oSerParType::BookmarkStart == type )
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
}
else if ( c_oSerParType::BookmarkEnd == type )
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
}
else if(c_oSerParType::JsaProject == type)
{
BYTE* pData = m_oBufferedStream.GetPointer(length);
OOX::CPath sJsaProject = OOX::FileTypes::JsaProject.DefaultFileName();
std::wstring filePath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + L"word"+ FILE_SEPARATOR_STR + sJsaProject.GetPath();
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath);
oFile.WriteFile(pData, length);
oFile.CloseFile();
long lId;
m_oFileWriter.m_pDrawingConverter->WriteRels(OOX::FileTypes::JsaProject.RelationType(), sJsaProject.GetPath(), L"", &lId);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(sJsaProject.GetExtention(false));
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3851,6 +3926,18 @@ public:
SdtWraper oSdt(1);
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
}
else if ( c_oSerParType::BookmarkStart == type )
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkStart.toXML());
}
else if ( c_oSerParType::BookmarkEnd == type )
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
m_oDocumentWriter.m_oContent.WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -4246,6 +4333,57 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadBookmarkStart(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CBookmarkStart* pBookmarkStart = static_cast<OOX::Logic::CBookmarkStart*>(poResult);
if ( c_oSerBookmark::Id == type )
{
pBookmarkStart->m_oId.Init();
pBookmarkStart->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerBookmark::Name == type )
{
pBookmarkStart->m_sName.Init();
pBookmarkStart->m_sName->append(m_oBufferedStream.GetString3(length));
}
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
{
pBookmarkStart->m_oDisplacedByCustomXml.Init();
pBookmarkStart->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else if ( c_oSerBookmark::ColFirst == type )
{
pBookmarkStart->m_oColFirst.Init();
pBookmarkStart->m_oColFirst->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerBookmark::ColLast == type )
{
pBookmarkStart->m_oColLast.Init();
pBookmarkStart->m_oColLast->SetValue(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadBookmarkEnd(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
OOX::Logic::CBookmarkEnd* pBookmarkEnd = static_cast<OOX::Logic::CBookmarkEnd*>(poResult);
if ( c_oSerBookmark::Id == type )
{
pBookmarkEnd->m_oId.Init();
pBookmarkEnd->m_oId->SetValue(m_oBufferedStream.GetLong());
}
else if ( c_oSerBookmark::DisplacedByCustomXml == type )
{
pBookmarkEnd->m_oDisplacedByCustomXml.Init();
pBookmarkEnd->m_oDisplacedByCustomXml->SetValue((SimpleTypes::EDisplacedByCustomXml)m_oBufferedStream.GetUChar());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadHyperlink(BYTE type, long length, void* poResult)
{
@ -4439,6 +4577,18 @@ public:
res = Read1(length, &Binary_DocumentTableReader::ReadMathSSup, this, poResult);
GetRunStringWriter().WriteString(std::wstring(_T("</m:sSup>")));
}
else if ( c_oSer_OMathContentType::BookmarkStart == type )
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
GetRunStringWriter().WriteString(oBookmarkStart.toXML());
}
else if ( c_oSer_OMathContentType::BookmarkEnd == type )
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
GetRunStringWriter().WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -6830,7 +6980,7 @@ public:
{
CWiterTblPr oWiterTblPr;
oBinary_tblPrReader.Read_tblPrOut(length, &oWiterTblPr);
pCStringWriter->WriteString(oWiterTblPr.Write(false, true));
pCStringWriter->WriteString(oWiterTblPr.Write());
}
else if( c_oSerDocTableType::tblGrid == type )
{
@ -6902,6 +7052,18 @@ public:
SdtWraper oSdt(2);
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
}
else if (c_oSerDocTableType::BookmarkStart == type)
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
pCStringWriter->WriteString(oBookmarkStart.toXML());
}
else if (c_oSerDocTableType::BookmarkEnd == type)
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
pCStringWriter->WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -6939,6 +7101,18 @@ public:
SdtWraper oSdt(3);
res = Read1(length, &Binary_DocumentTableReader::ReadSdt, this, &oSdt);
}
else if (c_oSerDocTableType::BookmarkStart == type)
{
OOX::Logic::CBookmarkStart oBookmarkStart;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkStart, this, &oBookmarkStart);
pCStringWriter->WriteString(oBookmarkStart.toXML());
}
else if (c_oSerDocTableType::BookmarkEnd == type)
{
OOX::Logic::CBookmarkEnd oBookmarkEnd;
res = Read1(length, &Binary_DocumentTableReader::ReadBookmarkEnd, this, &oBookmarkEnd);
pCStringWriter->WriteString(oBookmarkEnd.toXML());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -7094,7 +7268,7 @@ public:
BinXlsxRW::SaveParams oSaveParams(m_oFileWriter.m_sThemePath, m_oFileWriter.m_pDrawingConverter->GetContentTypes());
BinXlsxRW::BinaryChartReader oBinaryChartReader(m_oBufferedStream, oSaveParams, m_oFileWriter.m_pDrawingConverter);
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace();
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace(NULL);
oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace);
//save xlsx
@ -7104,21 +7278,22 @@ public:
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(nChartIndex) + L".xlsx";
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
if (oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace))
{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rIdXlsx);
m_oFileWriter.m_pDrawingConverter->m_pImageManager->m_pContentTypes->AddDefault(L"xlsx");
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
pChartSpace->m_oChartSpace.m_externalData->m_id->append(L"rId");
pChartSpace->m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rIdXlsx));
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
pChartSpace->m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
//save chart.xml
NSStringUtils::CStringBuilder sw;

View File

@ -35,6 +35,7 @@
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#include <boost/unordered_map.hpp>
namespace Writers
{
@ -48,7 +49,7 @@ namespace Writers
CApplicationFonts m_oApplicationFonts;
CFontManager* m_pFontManager;
public:
std::map<std::wstring, int> m_mapFonts;
boost::unordered_map<std::wstring, int> m_mapFonts;
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
{
@ -81,7 +82,7 @@ namespace Writers
bool bCalibri = false;
bool bTimes = false;
bool bCambria = false;
for (std::map<std::wstring, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
for (boost::unordered_map<std::wstring, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
{
const std::wstring& sFontName = it->first;
if(_T("Calibri") == sFontName)

View File

@ -144,9 +144,13 @@ namespace MathEquation
void AddAccent (MEMBELTYPE eType)
{
LONG lPos = GetSize() - 1;
if (lPos < 0) return;
EquationRun oRun;
oRun = arrRun[lPos];
RemoveElem(lPos);
oRun.bAccent = true;
oRun.eType = eType;
Add(oRun);
@ -614,7 +618,7 @@ namespace MathEquation
nRows = m_aRowsCounter.top();
m_aRowsCounter.pop();
}
int nPos = 0;
int nPos = m_oStream.GetPosition();
if (!m_aRowsPosCounter.empty())
{
nPos = m_aRowsPosCounter.top();
@ -1675,7 +1679,7 @@ namespace MathEquation
void WriteEndNode(BinaryEquationWriter* pWriter)
{
int nCurPos;
int nCurPos = -1;
if (!m_aBaseStack.empty())
{
nCurPos = m_aBaseStack.top();
@ -1687,14 +1691,20 @@ namespace MathEquation
}
if (bPile && bEqArrayStart)
{
pWriter->WriteItemEnd(nCurPos);
}
else if (!bPile && !bEqArrayStart)
{
pWriter->WriteItemEnd(nCurPos);
}
else if (!bPile && bEqArrayStart)
{
pWriter->m_aRowsCounter.push(nRows);
bEqArrayStart = false;
pWriter->WriteItemEnd(nCurPos);//eqArr
if (nCurPos > 0)
pWriter->WriteItemEnd(nCurPos);//eqArr
if (!m_aBaseStack.empty())
{

View File

@ -345,7 +345,8 @@ extern int g_nCurFormatVersion;
SectPr = 31,
numPr_Ins = 32,
pPrChange = 33,
outlineLvl = 34
outlineLvl = 34,
Tab_Item_Leader = 35
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{
@ -475,7 +476,11 @@ extern int g_nCurFormatVersion;
MoveFromRangeStart = 18,
MoveFromRangeEnd = 19,
MoveToRangeStart = 20,
MoveToRangeEnd = 21
MoveToRangeEnd = 21,
JsaProject = 22,
BookmarkStart = 23,
BookmarkEnd = 24
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -490,7 +495,9 @@ extern int g_nCurFormatVersion;
Cell_Pr = 7,
Cell_Content = 8,
tblGridChange = 9,
Sdt = 10
Sdt = 10,
BookmarkStart = 11,
BookmarkEnd = 12
};}
namespace c_oSerRunType{enum c_oSerRunType
{
@ -899,7 +906,9 @@ extern int g_nCurFormatVersion;
Ins = 62,
Del = 63,
columnbreak = 64,
ARPr = 65
ARPr = 65,
BookmarkStart = 66,
BookmarkEnd = 67
};}
namespace c_oSer_FramePrType{ enum c_oSer_FramePrType
{
@ -1104,6 +1113,14 @@ extern int g_nCurFormatVersion;
Name = 6,
UserId = 7
};}
namespace c_oSerBookmark{enum c_oSerBookmark
{
Id = 0,
Name = 1,
DisplacedByCustomXml = 2,
ColFirst = 3,
ColLast = 4
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,12 @@
#include "ChartWriter.h"
#include <algorithm>
#include "../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
#include "../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#define NUMID_START 160
const wchar_t* gc_Cat = L"cat";
@ -127,10 +132,11 @@ namespace BinXlsxRW{
}
ChartWriter::~ChartWriter()
{
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); it++)
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
{
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = it->second;
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRow = rows->begin(); itRow != rows->end(); itRow++)
{
delete itRow->second;
}
@ -140,28 +146,34 @@ namespace BinXlsxRW{
void ChartWriter::toXlsx(OOX::Spreadsheet::CXlsx& oXlsx)
{
std::vector<std::wstring> aSharedStrings;
//Sheet
OOX::Spreadsheet::CWorkbook* pWorkbook = oXlsx.CreateWorkbook();
pWorkbook->m_oSheets.Init();
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets = oXlsx.GetWorksheets();
oXlsx.CreateWorkbook();
oXlsx.m_pWorkbook->m_oSheets.Init();
int nSheetId = 1;
OOX::Spreadsheet::CWorksheet* pFirstWorksheet = NULL;
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); it++)
for (std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::iterator it = m_mapSheets.begin(); it != m_mapSheets.end(); ++it)
{
const std::wstring& sSheetName = it->first;
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(mapWorksheets, sSheetName);
//find or generate black worksheet
OOX::Spreadsheet::CWorksheet* pWorksheet = toXlsxGetSheet(oXlsx.m_arWorksheets, oXlsx.m_mapWorksheets, sSheetName);
//fill data to worksheet
toXlsxSheetdata(pWorksheet, *it->second, aSharedStrings);
OOX::Spreadsheet::CSheet* pSheet = new OOX::Spreadsheet::CSheet();
pSheet->m_oName.Init();
pSheet->m_oName->append(sSheetName);
pSheet->m_oSheetId.Init();
pSheet->m_oSheetId->SetValue(nSheetId++);
smart_ptr<OOX::File> oWorksheetFile = smart_ptr<OOX::File>(pWorksheet);
const OOX::RId oRId = pWorkbook->Add(oWorksheetFile);
const OOX::RId oRId = oXlsx.m_pWorkbook->Add(oWorksheetFile);
pSheet->m_oRid.Init();
pSheet->m_oRid->SetValue(oRId.get());
pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
mapWorksheets[pSheet->m_oName.get()] = pWorksheet;
oXlsx.m_pWorkbook->m_oSheets->m_arrItems.push_back(pSheet);
if(NULL == pFirstWorksheet)
{
@ -170,7 +182,7 @@ namespace BinXlsxRW{
}
//SharedStrings
OOX::Spreadsheet::CSharedStrings* pSharedStrings = oXlsx.CreateSharedStrings();
oXlsx.CreateSharedStrings();
for(size_t i = 0; i < aSharedStrings.size(); ++i)
{
OOX::Spreadsheet::CText* pText = new OOX::Spreadsheet::CText();
@ -182,33 +194,35 @@ namespace BinXlsxRW{
}
OOX::Spreadsheet::CSi* pSi = new OOX::Spreadsheet::CSi();
pSi->m_arrItems.push_back(pText);
pSharedStrings->m_arrItems.push_back(pSi);
oXlsx.m_pSharedStrings->AddSi(pSi);
}
pSharedStrings->m_oCount.Init();
pSharedStrings->m_oCount->SetValue(pSharedStrings->m_arrItems.size());
pSharedStrings->m_oUniqueCount.Init();
pSharedStrings->m_oUniqueCount->SetValue(pSharedStrings->m_arrItems.size());
oXlsx.m_pSharedStrings->m_oCount.Init();
oXlsx.m_pSharedStrings->m_oCount->SetValue(oXlsx.m_pSharedStrings->m_nCount);
oXlsx.m_pSharedStrings->m_oUniqueCount.Init();
oXlsx.m_pSharedStrings->m_oUniqueCount->SetValue(oXlsx.m_pSharedStrings->m_nCount);
//Styles
OOX::Spreadsheet::CStyles* pStyles = oXlsx.CreateStyles();
pStyles->m_oCellXfs.Init();
oXlsx.CreateStyles();
oXlsx.m_pStyles->m_oCellXfs.Init();
for(size_t i = 0; i < m_aXfs.size(); ++i)
{
pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
oXlsx.m_pStyles->m_oCellXfs->m_arrItems.push_back(m_aXfs[i]);
}
pStyles->m_oNumFmts.Init();
for (std::map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); it++)
oXlsx.m_pStyles->m_oNumFmts.Init();
for (boost::unordered_map<std::wstring, int>::iterator it = m_mapFormats.begin(); it != m_mapFormats.end(); ++it)
{
OOX::Spreadsheet::CNumFmt* pNumFmt = new OOX::Spreadsheet::CNumFmt();
pNumFmt->m_oFormatCode.Init();
pNumFmt->m_oFormatCode->append(it->first);
pNumFmt->m_oNumFmtId.Init();
pNumFmt->m_oNumFmtId->SetValue(NUMID_START + it->second);
pStyles->m_oNumFmts->m_arrItems.push_back(pNumFmt);
oXlsx.m_pStyles->m_oNumFmts->m_arrItems.push_back(pNumFmt);
}
pStyles->m_oNumFmts->m_oCount.Init();
pStyles->m_oNumFmts->m_oCount->SetValue(pStyles->m_oNumFmts->m_arrItems.size());
pStyles->m_oCellXfs->m_oCount.Init();
pStyles->m_oCellXfs->m_oCount->SetValue(pStyles->m_oCellXfs->m_arrItems.size());
oXlsx.m_pStyles->m_oNumFmts->m_oCount.Init();
oXlsx.m_pStyles->m_oNumFmts->m_oCount->SetValue(oXlsx.m_pStyles->m_oNumFmts->m_arrItems.size());
oXlsx.m_pStyles->m_oCellXfs->m_oCount.Init();
oXlsx.m_pStyles->m_oCellXfs->m_oCount->SetValue(oXlsx.m_pStyles->m_oCellXfs->m_arrItems.size());
OOX::Spreadsheet::CDxf* pDxf = new OOX::Spreadsheet::CDxf();
pDxf->m_oBorder.Init();
pDxf->m_oBorder->m_oStart.Init();
@ -235,15 +249,16 @@ namespace BinXlsxRW{
pDxf->m_oBorder->m_oBottom->m_oColor.Init();
pDxf->m_oBorder->m_oBottom->m_oColor->m_oIndexed.Init();
pDxf->m_oBorder->m_oBottom->m_oColor->m_oIndexed->SetValue(12);
pStyles->m_oDxfs.Init();
pStyles->m_oDxfs->m_arrItems.push_back(pDxf);
pStyles->m_oDxfs->m_oCount.Init();
pStyles->m_oDxfs->m_oCount->SetValue(pStyles->m_oDxfs->m_arrItems.size());
oXlsx.m_pStyles->m_oDxfs.Init();
oXlsx.m_pStyles->m_oDxfs->m_arrItems.push_back(pDxf);
oXlsx.m_pStyles->m_oDxfs->m_oCount.Init();
oXlsx.m_pStyles->m_oDxfs->m_oCount->SetValue(oXlsx.m_pStyles->m_oDxfs->m_arrItems.size());
//Table
//todo table в случае нескольких sheet или если серии разнесены по sheet
if(m_aTableNames.size() > 0)
{
OOX::Spreadsheet::CTableFile* pTable = new OOX::Spreadsheet::CTableFile();
OOX::Spreadsheet::CTableFile* pTable = new OOX::Spreadsheet::CTableFile(NULL);
pTable->m_oTable.Init();
pTable->m_oTable->m_oDisplayName.Init();
pTable->m_oTable->m_oDisplayName->append(L"Table1");
@ -286,9 +301,11 @@ namespace BinXlsxRW{
{
OOX::Spreadsheet::CTablePart* pTablePart = new OOX::Spreadsheet::CTablePart();
NSCommon::smart_ptr<OOX::File> pTableFile(pTable);
const OOX::RId oRId = pFirstWorksheet->Add(pTableFile);
pTablePart->m_oRId.Init();
pTablePart->m_oRId->SetValue(oRId.get());
pFirstWorksheet->m_oTableParts.Init();
pFirstWorksheet->m_oTableParts->m_arrItems.push_back(pTablePart);
pFirstWorksheet->m_oTableParts->m_oCount.Init();
@ -458,18 +475,22 @@ namespace BinXlsxRW{
//проверяем можем ли создать таблицу
if(m_mapSheets.size() > 0 && m_nRow1 > 0 && m_nRow2 > 0 && m_nCol1 > 0 && m_nCol2 > 0 && m_nRow1 < m_nRow2)
{
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
if(itRows != rows->end())
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = m_mapSheets.begin()->second;
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::iterator itRows = rows->find(m_nRow1);
if(itRows != rows->end())
{
std::map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
std::map<int, OOX::Spreadsheet::CCell*>* cells = itRows->second;
std::vector<int> aIndexesCell;
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); it++)
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells->begin(); it != cells->end(); ++it)
{
aIndexesCell.push_back(it->first);
}
std::sort(aIndexesCell.begin(), aIndexesCell.end());
if(m_nCol2 - m_nCol1 + 1 == aIndexesCell.size() && m_nCol1 == aIndexesCell[0] && m_nCol2 == aIndexesCell[aIndexesCell.size() - 1])
std::sort(aIndexesCell.begin(), aIndexesCell.end());
if(m_nCol2 - m_nCol1 + 1 == aIndexesCell.size() && m_nCol1 == aIndexesCell[0] && m_nCol2 == aIndexesCell[aIndexesCell.size() - 1])
{
for(size_t j = 0; j < aIndexesCell.size(); ++j)
{
@ -482,13 +503,14 @@ namespace BinXlsxRW{
}
}
}
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
OOX::Spreadsheet::CWorksheet* ChartWriter::toXlsxGetSheet(std::vector<OOX::Spreadsheet::CWorksheet*>& arWorksheets, std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>& mapWorksheets, const std::wstring& sName)
{
OOX::Spreadsheet::CWorksheet* pWorksheet = NULL;
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator it = mapWorksheets.find(sName);
if (it == mapWorksheets.end())
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*>::const_iterator pFind = mapWorksheets.find(sName);
if (pFind == mapWorksheets.end())
{
pWorksheet = new OOX::Spreadsheet::CWorksheet();
pWorksheet = new OOX::Spreadsheet::CWorksheet(NULL);
pWorksheet->m_oSheetFormatPr.Init();
pWorksheet->m_oSheetFormatPr->m_oDefaultRowHeight.Init();
pWorksheet->m_oSheetFormatPr->m_oDefaultRowHeight->SetValue(15);
@ -508,39 +530,48 @@ namespace BinXlsxRW{
pWorksheet->m_oPageMargins->m_oFooter->FromInches(0.3);
mapWorksheets[sName] = pWorksheet;
arWorksheets.push_back(pWorksheet);
}
else
{
pWorksheet = it->second;
pWorksheet = pFind->second;
}
return pWorksheet;
}
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
void ChartWriter::toXlsxSheetdata(OOX::Spreadsheet::CWorksheet* pWorksheet, const std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>& rows, std::vector<std::wstring>& aSharedStrings)
{
pWorksheet->m_oSheetData.Init();
std::vector<int> aIndexesRow;
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); it++)
for(std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator it = rows.begin(); it != rows.end(); ++it)
{
aIndexesRow.push_back(it->first);
}
std::sort(aIndexesRow.begin(), aIndexesRow.end());
for(size_t i = 0; i < aIndexesRow.size(); ++i)
std::sort(aIndexesRow.begin(), aIndexesRow.end());
for(size_t i = 0; i < aIndexesRow.size(); ++i)
{
int nIndexRow = aIndexesRow[i];
OOX::Spreadsheet::CRow* pRow = new OOX::Spreadsheet::CRow();
OOX::Spreadsheet::CRow* pRow = new OOX::Spreadsheet::CRow();
pRow->m_oR.Init();
pRow->m_oR->SetValue(nIndexRow);
const std::map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
const std::map<int, OOX::Spreadsheet::CCell*>& cells = *rows.at(nIndexRow);
std::vector<int> aIndexesCell;
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); it++)
for(std::map<int, OOX::Spreadsheet::CCell*>::const_iterator it = cells.begin(); it != cells.end(); ++it)
{
aIndexesCell.push_back(it->first);
}
std::sort(aIndexesCell.begin(), aIndexesCell.end());
for(size_t j = 0; j < aIndexesCell.size(); ++j)
for(size_t j = 0; j < aIndexesCell.size(); ++j)
{
int nIndexCell = aIndexesCell[j];
OOX::Spreadsheet::CCell* pCell = cells.at(nIndexCell);
OOX::Spreadsheet::CCell* pCell = cells.at(nIndexCell);
//SharedStrings
if(pCell->m_oValue.IsInit())
{
@ -588,22 +619,24 @@ namespace BinXlsxRW{
}
void ChartWriter::parseCell(const std::wstring& sheet, const int& nRow, const int& nCol, const std::wstring& val, std::wstring* format = NULL)
{
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
if(itSheets == m_mapSheets.end())
std::map<std::wstring, std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>*>::const_iterator itSheets = m_mapSheets.find(sheet);
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>* rows = NULL;
if(itSheets == m_mapSheets.end())
{
rows = new std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>();
rows = new std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>();
m_mapSheets.insert(std::make_pair(sheet, rows));
}
else
{
rows = itSheets->second;
}
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
std::map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
if(itRows == rows->end())
std::map<int, std::map<int, OOX::Spreadsheet::CCell*>*>::const_iterator itRows = rows->find(nRow);
std::map<int, OOX::Spreadsheet::CCell*>* cells = NULL;
if(itRows == rows->end())
{
cells = new std::map<int, OOX::Spreadsheet::CCell*>();
cells = new std::map<int, OOX::Spreadsheet::CCell*>();
rows->insert(std::make_pair(nRow, cells));
}
else
@ -622,10 +655,12 @@ namespace BinXlsxRW{
//пока добавляем как есть, shared string после записи таблицы
pNewCell->m_oValue.Init();
pNewCell->m_oValue->m_sText = val;
if(NULL != format)
if(NULL != format)
{
int nXfsIndex = m_aXfs.size();
std::map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
boost::unordered_map<std::wstring, int>::const_iterator itFormat = m_mapFormats.find(*format);
if(itFormat == m_mapFormats.end())
{
m_mapFormats[*format] = nXfsIndex;
@ -658,8 +693,7 @@ namespace BinXlsxRW{
std::wstring wb, sheetFrom, sheetTo;
int nRow1, nCol1, nRow2, nCol2;
if(OOX::Spreadsheet::CCell::parse3DRef(*pStrRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() &&
NULL != pStrRef->m_strCache)
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pStrRef->m_strCache)
{
bool bRow = nRow1 == nRow2;
if(bUpdateRange)
@ -727,7 +761,7 @@ namespace BinXlsxRW{
std::wstring wb, sheetFrom, sheetTo;
int nRow1, nCol1, nRow2, nCol2;
if(OOX::Spreadsheet::CCell::parse3DRef(*pNumRef->m_f, wb, sheetFrom, sheetTo, nRow1, nCol1, nRow2, nCol2) &&
sheetFrom.length() > 0 && 0 == wb.length() && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
sheetFrom.length() > 0 && 0 == sheetTo.length() && NULL != pNumRef->m_numCache)
{
bool bRow = nRow1 == nRow2;
if(bUpdateRange)

View File

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

View File

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

View File

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

View File

@ -42,6 +42,7 @@
#include "ChartWriter.h"
#include "../BinReader/DefaultThemeWriter.h"
//#include "../../Common/DocxFormat/Source/XlsxFormat/Chart/Chart.h"
namespace BinXlsxRW{
int g_nCurFormatVersion = 0;
@ -168,7 +169,7 @@ namespace BinXlsxRW{
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath, m_pExternalDrawingConverter->GetContentTypes());
OOX::Spreadsheet::CChartSpace oChartSpace;
OOX::Spreadsheet::CChartSpace oChartSpace(NULL);
BinXlsxRW::BinaryChartReader oBinaryChartReader(*pReader, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
@ -181,20 +182,22 @@ namespace BinXlsxRW{
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
if (writeChartXlsx(sXlsxPath, oChartSpace))
{
pReader->m_pRels->m_pManager->m_pContentTypes->AddDefault(L"xlsx");
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
oChartSpace.m_oChartSpace.m_externalData->m_id->append(L"rId");
oChartSpace.m_oChartSpace.m_externalData->m_id->append(std::to_wstring(rId));
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate = new OOX::Spreadsheet::CT_Boolean();
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
}
std::wstring strFilepath = sFilepath;
@ -233,7 +236,7 @@ namespace BinXlsxRW{
m_bIsNoBase64 = bIsNoBase64;
}
void CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
bool CXlsxSerializer::writeChartXlsx(const std::wstring& sDstFile, const OOX::Spreadsheet::CChartSpace& oChart)
{
//анализируем chart
BinXlsxRW::ChartWriter helper;
@ -252,11 +255,15 @@ namespace BinXlsxRW{
helper.toXlsx(oXlsx);
//write
OOX::CContentTypes oContentTypes;
oXlsx.Write(oPath, oContentTypes);
//zip
COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
bool res = oXlsx.Write(oPath, oContentTypes);
if (res)
{
//zip
COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
}
//clean
NSDirectory::DeleteDirectory(sTempDir);
return res;
}
};

View File

@ -72,7 +72,7 @@ namespace BinXlsxRW {
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
void setIsNoBase64 (bool bIsNoBase64);
void writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
};
}
#endif // #ifndef XLSX_SERIALIZER

View File

@ -47,7 +47,7 @@
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE;UNICODE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
@ -68,6 +68,7 @@
ShowProgress="0"
Version=""
LinkIncremental="2"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
@ -356,6 +357,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
>
</File>
<File
RelativePath="..\..\UnicodeConverter\UnicodeConverter.cpp"
>

View File

@ -407,11 +407,11 @@ namespace formulasconvert {
std::wstring is_forbidden(const std::wstring & formula)
{
std::wstring result = formula;
std::map<std::wstring, std::wstring> forbidden_formulas;
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++)
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
{
if (boost::algorithm::contains(formula, it->first))
{

View File

@ -335,8 +335,8 @@ namespace internal
inline bool starts_with_bom (octet_iterator it, octet_iterator end)
{
return (
((it != end) && (internal::mask8(*it++)) == bom[0]) &&
((it != end) && (internal::mask8(*it++)) == bom[1]) &&
((it != end) && (internal::mask8(*++it)) == bom[0]) &&
((it != end) && (internal::mask8(*++it)) == bom[1]) &&
((it != end) && (internal::mask8(*it)) == bom[2])
);
}
@ -346,8 +346,8 @@ namespace internal
inline bool is_bom (octet_iterator it)
{
return (
(internal::mask8(*it++)) == bom[0] &&
(internal::mask8(*it++)) == bom[1] &&
(internal::mask8(*++it)) == bom[0] &&
(internal::mask8(*++it)) == bom[1] &&
(internal::mask8(*it)) == bom[2]
);
}

View File

@ -66,7 +66,7 @@ namespace utf8
case 1:
break;
case 2:
it++;
++it;
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break;
case 3:

View File

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

View File

@ -48,13 +48,19 @@ _CP_PTR(oox_axis_content) oox_axis_content::create(int type)
oox_axis_content::oox_axis_content(int type/*,std::wstring name*/)
{
//id_ = abs((int)*((_UINT32*)this));
id_ = abs((long)this);
type_=type; //dimension
if (type == 0)
{
id_ = 0;
}
else
{
id_ = abs((long)this);
}
type_ = type;
}
void oox_axis_content::oox_serialize(std::wostream & _Wostream)
{
if (id_ <0 )return;//not activate
if (id_ < 1 )return; //not activate, blank axis
CP_XML_WRITER(_Wostream)
{

View File

@ -153,7 +153,7 @@ void oox_chart_context::serialize(std::wostream & strm)
}
CP_XML_NODE(L"c:dispBlanksAs")
{
CP_XML_ATTR(L"val", L"zero");
CP_XML_ATTR(L"val", plot_area_.current_chart_->dispBlanksAs_);
}
CP_XML_NODE(L"c:showDLblsOverMax")
{

View File

@ -103,7 +103,7 @@ public:
reset_fill(l.fill_);
//floor_.content_= l;
}
void set_legend(odf_reader::chart::simple & l)
void set_legend(odf_reader::chart::legend & l)
{
reset_fill(l.fill_);
legend_.content_= l;

View File

@ -52,10 +52,9 @@ void oox_chart_legend::oox_serialize(std::wostream & _Wostream)
{
CP_XML_NODE(L"c:legend")
{
CP_XML_NODE(L"c:legendPos")
{
CP_XML_ATTR(L"val", "r");// "b" | "l" | "r" | "t"// == bottom left right top
CP_XML_ATTR(L"val", content_.position);
}
layout_.oox_serialize(CP_XML_STREAM());

View File

@ -48,7 +48,7 @@ public:
void oox_serialize(std::wostream & _Wostream);
odf_reader::chart::simple content_;
odf_reader::chart::legend content_;
private:
cpdoccore::oox::oox_layout layout_; //layout (Layout) §21.2.2.88

View File

@ -250,7 +250,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_CONTENT(values_[i].numRef_.formula);
}
if (values_[i].numRef_.num_cache_count>0)
if (values_[i].numRef_.num_cache_count > 0)
{
CP_XML_NODE(L"c:numCache")
{

View File

@ -71,7 +71,7 @@ void oox_data_labels::oox_serialize(std::wostream & _Wostream)
{
oox_serialize_default_text(CP_XML_STREAM(), textPr_);
for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); it++)
for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); ++it)
{
CP_XML_NODE(L"c:dLbl")
{

View File

@ -31,10 +31,10 @@
*/
#include "oox_plot_area.h"
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_text_properties.h"
#include "oox_chart_shape.h"
@ -90,7 +90,7 @@ void oox_plot_area::add_chart(int type)
void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
{
oox_axis_content_ptr ax=oox_axis_content::create(type);
oox_axis_content_ptr ax = oox_axis_content::create(type);
ax->content_ = content;
axis_.push_back(ax);
@ -98,21 +98,25 @@ void oox_plot_area::add_axis(int type, odf_reader::chart::axis & content)
void oox_plot_area::reset_cross_axis()//обязательно после всех добавлений
{
BOOST_FOREACH(oox_axis_content_ptr const & ax, axis_)
for (size_t i = 0; i < axis_.size(); i++)
{
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
for (size_t j = 0; j < charts_.size(); j++)
{
ch->add_axis(ax->get_Id());
charts_[j]->add_axis(axis_[i]->get_Id());
}
}
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
{
int curr_id = a->get_Id();
BOOST_FOREACH(oox_axis_content_ptr const & b, axis_)
{
if (b->get_Id()==curr_id)continue;
b->add_CrossedId(curr_id);
for (size_t i = 0; i < axis_.size(); i++)
{
int curr_id = axis_[i]->get_Id();
if (curr_id < 1) continue;
for (size_t j = 0; j < axis_.size(); j++)
{
if (axis_[j]->get_Id() == curr_id)continue;
axis_[j]->add_CrossedId(curr_id);
}
}
}
@ -130,18 +134,18 @@ void oox_plot_area::oox_serialize(std::wostream & _Wostream)
//CP_XML_NODE(L"c:layout"){}
bool axisPresent = true;
BOOST_FOREACH(oox_chart_ptr const & ch, charts_)
{
ch->oox_serialize(CP_XML_STREAM());
for (size_t i = 0; i < charts_.size(); i++)
{
charts_[i]->oox_serialize(CP_XML_STREAM());
if (ch->type_ == CHART_TYPE_PIE ||
ch->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
if (charts_[i]->type_ == CHART_TYPE_PIE ||
charts_[i]->type_ == CHART_TYPE_DOUGHNUT) axisPresent = false;
}
if (axisPresent)
{
BOOST_FOREACH(oox_axis_content_ptr const & a, axis_)
{
a->oox_serialize(CP_XML_STREAM());
for (size_t i = 0; i < axis_.size(); i++)
{
axis_[i]->oox_serialize(CP_XML_STREAM());
}
}
shape.oox_serialize(CP_XML_STREAM());

View File

@ -63,7 +63,7 @@ void oox_chart::set_content_series(odf_reader::chart::series & content)
}
void oox_chart::set_values_series(int ind, std::vector<std::wstring> & val)
{
if (val.size()<1)return;
if (val.empty())return;
oox_series_ptr & current_ptr = series_.back();
current_ptr->setValues (ind, val);
@ -74,9 +74,11 @@ void oox_chart::set_properties(std::vector<odf_reader::_property> g)
_CP_OPT(bool) bStacked;
_CP_OPT(bool) bPercent;
_CP_OPT(int) iGapWidth;
odf_reader::GetProperty(g, L"stacked",bStacked);
odf_reader::GetProperty(g, L"percentage",bPercent);
odf_reader::GetProperty(g, L"stacked", bStacked);
odf_reader::GetProperty(g, L"percentage", bPercent);
odf_reader::GetProperty(g, L"gap-width", iGapWidth);
if ( (bStacked) && (bStacked.get()))
{
@ -87,6 +89,10 @@ void oox_chart::set_properties(std::vector<odf_reader::_property> g)
{
grouping_ = L"percentStacked";
}
if (iGapWidth)
{
dispBlanksAs_ = L"gap";
}
//solid-type - трехмерные
}
void oox_chart::oox_serialize_common(std::wostream & _Wostream)
@ -128,17 +134,15 @@ void oox_bar_chart::set_properties(std::vector<odf_reader::_property> g)
{
oox_chart::set_properties(g);
odf_reader::GetProperty(g, L"vertical",bVertical);
odf_reader::GetProperty(g, L"connect-bars",bConnectBars);
odf_reader::GetProperty(g, L"vertical", bVertical);
odf_reader::GetProperty(g, L"connect-bars", bConnectBars);
odf_reader::GetProperty(g, L"gap-width",iGapWidth);
odf_reader::GetProperty(g, L"overlap",iOverlap);
odf_reader::GetProperty(g, L"gap-width", iGapWidth);
odf_reader::GetProperty(g, L"overlap", iOverlap);
}
void oox_bar_chart::set_additional_properties(std::vector<odf_reader::_property> g)
{
odf_reader::GetProperty(g, L"gap-width",iGapWidth);
odf_reader::GetProperty(g, L"overlap",iOverlap);
}
void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
@ -169,13 +173,13 @@ void oox_bar_chart::oox_serialize(std::wostream & _Wostream)
}
CP_XML_NODE(L"c:overlap")//-100 to 100
{
CP_XML_ATTR(L"val",Overlap);
CP_XML_ATTR(L"val", Overlap);
}
if (iGapWidth)
{
CP_XML_NODE(L"c:gapWidth")
{
CP_XML_ATTR(L"val",iGapWidth.get());
CP_XML_ATTR(L"val", iGapWidth.get());
}
}
CP_XML_NODE(L"c:varyColors")

View File

@ -63,9 +63,10 @@ public:
oox_chart()
{
grouping_ = L"standard";
is3D_ = false;
type_ = 0;
grouping_ = L"standard";
is3D_ = false;
type_ = 0;
dispBlanksAs_ = L"zero";
}
~oox_chart(){}
@ -98,9 +99,10 @@ public:
int type_;
bool is3D_;
std::vector<int> axisId_; //axId (Axis ID) §21.2.2.9
std::wstring dispBlanksAs_;
std::vector<int> axisId_; // axId (Axis ID) §21.2.2.9
std::wstring grouping_; // clustered | percentStacked | stacked | standard
std::vector<oox_series_ptr> series_; //ser (Bar Chart Series) §21.2.2.170
std::vector<oox_series_ptr> series_; // ser (Bar Chart Series) §21.2.2.170
virtual void set_properties(std::vector<odf_reader::_property> g);
virtual void set_additional_properties(std::vector<odf_reader::_property> g){}

View File

@ -194,7 +194,7 @@ private:
std::map<size_t, size_t> count;
size_t max_size = 0;
for (std::map<size_t, size_t>::iterator it = map.begin(); it != map.end(); it++)
for (std::map<size_t, size_t>::iterator it = map.begin(); it != map.end(); ++it)
{
std::map<size_t, size_t>::iterator pFind = count.find(it->second);
if (pFind != count.end())
@ -215,7 +215,7 @@ private:
size_t found = 0;
for (std::map<size_t, size_t>::iterator it = count.begin() ; it != count.end(); it++)
for (std::map<size_t, size_t>::iterator it = count.begin() ; it != count.end(); ++it)
{
if (it->second == max_size)
{
@ -229,16 +229,16 @@ private:
{
if (it->second != found)
{
std::map<size_t, size_t>::iterator del = it; it++;
std::map<size_t, size_t>::iterator del = it; ++it;
map.erase(del);
}
else it++;
else ++it;
}
return true;
}
void clear_header_map2(std::map<size_t, size_t> & map, std::map<size_t, size_t> & map_by)
{//отсев тех кто во втором
for (std::map<size_t, size_t>::iterator it = map_by.begin() ; it != map_by.end(); it++)
for (std::map<size_t, size_t>::iterator it = map_by.begin() ; it != map_by.end(); ++it)
{
std::map<size_t, size_t>::iterator pFind = map.find(it->second);
if (pFind != map.end())

View File

@ -133,7 +133,8 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_drawing_context_ (Context->get_drawing_context_handle()),
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false)
in_cell(false),
bEndTable(false)
{
memset(&group_row_,0,sizeof(_group_row));

View File

@ -91,6 +91,9 @@ public:
void end_row ();
void add_empty_row(int count);
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
@ -153,6 +156,7 @@ public:
friend class xlsx_table_context;
private:
bool bEndTable;
xlsx_conversion_context * context_;
std::wstring tableName_;

View File

@ -253,7 +253,7 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; it++)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
}
@ -271,7 +271,7 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; it++)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->filter)
{

View File

@ -195,7 +195,14 @@ std::wstring cellType2Str(XlsxCellType::type type)
boost::int64_t convertDate(int Year, int Month, int Day)
{
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
if (Year < 1400 || Year >10000)
return - 1;
if (Month < 1 || Month > 12)
return - 1;
if (Day < 1 || Day > 31)
return - 1;
boost::int64_t daysFrom1900 = boost::gregorian::date_duration(boost::gregorian::date(Year, Month, Day) - boost::gregorian::date(1900, 1, 1)).days() + 1;
if (Year <= 1900 &&
Month <= 2 &&

View File

@ -401,7 +401,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
std::vector<std::wstring> cell_cash;
std::vector<std::wstring> cat_cash;
calc_cache_series (domain_cell_range_adress_, domain_cash);
calc_cache_series (domain_cell_range_adress_, domain_cash);
calc_cache_series (series_[i].cell_range_address_, cell_cash);
if (categories_.size() >0)
@ -462,10 +462,19 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
std::sort(axises_.begin(), axises_.end(), axises_sort());//file_1_ (1).odp
bool x_enabled = false;
bool y_enabled = false;
bool z_enabled = false;
bool x_enabled = false;
bool y_enabled = false;
bool z_enabled = false;
bool is3D = false;
_CP_OPT(bool) boolVal;
odf_reader::GetProperty(plot_area_.properties_, L"three-dimensional", boolVal);
if ((boolVal) && (*boolVal))
{
is3D = true;
}
for (int i = 0; i < axises_.size(); i++)
{
axis & a = axises_[i];
@ -481,6 +490,8 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
if (class_ == chart_stock && a.type_ == 3 )
a.type_ = 4; //шкала дат.
if (is3D) a.type_ = 1; // шкала категорий
x_enabled = true;
}
@ -499,7 +510,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
}
else if (a.dimension_ == L"z")
{
chart_context.set_3D_chart (true);
is3D = true;
continue;
a.type_ = 2;
z_enabled = true;
@ -507,6 +518,18 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context)
chart_context.add_axis(a.type_, a);
}
if (is3D)
{
if (!z_enabled)
{
chart::axis a;
a.type_ = 0; // blank
chart_context.add_axis(a.type_, a);
}
chart_context.set_3D_chart (true);
}
}
//----------------------------------------------------------------------------------------
@ -739,6 +762,28 @@ void process_build_object::visit(const chart_footer& val)
void process_build_object::visit(const chart_legend& val)
{
object_odf_context_.legend_.bEnabled = true;
object_odf_context_.legend_.position = L"r";
if (val.attlist_.chart_legend_position_)
{
std::wstring pos = val.attlist_.chart_legend_position_.get();
if ( pos == L"bottom") object_odf_context_.legend_.position = L"b";
if ( pos == L"start") object_odf_context_.legend_.position = L"l";
if ( pos == L"top") object_odf_context_.legend_.position = L"t";
if ( pos == L"top-end") object_odf_context_.legend_.position = L"tr";
if ( pos == L"top-start") object_odf_context_.legend_.position = L"tl";
if ( pos == L"bottom-start") object_odf_context_.legend_.position = L"bl";
if ( pos == L"bottom-end") object_odf_context_.legend_.position = L"br";
}
if (val.attlist_.chart_legend_align_)
{
std::wstring align = val.attlist_.chart_legend_align_.get();
//if ( pos == L"start") object_odf_context_.legend_.align = L"b";
//if ( pos == L"center") object_odf_context_.legend_.align = L"l";
//if ( pos == L"end") object_odf_context_.legend_.align = L"t";
}
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_);

View File

@ -188,7 +188,7 @@ public:
office_element_ptr_array title_odf_context_;
chart::title sub_title_;
chart::simple legend_;
chart::legend legend_;
chart::plot_area plot_area_;
chart::simple wall_;

View File

@ -76,6 +76,7 @@ namespace chart {
struct simple
{
simple() : bEnabled(false) {}
bool bEnabled;
std::vector<_property> properties_;
std::vector<_property> text_properties_;
@ -92,6 +93,11 @@ namespace chart {
treadline(){bEquation = false; bREquation = false;}
};
struct legend : public simple
{
std::wstring position;
std::wstring align;
};
struct plot_area : public simple
{
std::wstring cell_range_address_;

View File

@ -58,6 +58,9 @@ std::wostream & operator << (std::wostream & _Wostream, const calcext_type & _Va
break;
case calcext_type::Minimum:
_Wostream << L"minimum";
break;
case calcext_type::Percentile:
_Wostream << L"percentile";
break;
default:
break;
@ -84,6 +87,8 @@ calcext_type calcext_type::parse(const std::wstring & Str)
return calcext_type( Minimum );
else if (tmp == L"formula")
return calcext_type( Formula );
else if (tmp == L"percentile")
return calcext_type( Percentile );
else
{
return calcext_type( Number );

View File

@ -49,7 +49,8 @@ public:
Minimum,
AutoMaximum,
AutoMinimum,
Formula
Formula,
Percentile
};
calcext_type() {}

View File

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

View File

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

View File

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

View File

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

View File

@ -36,7 +36,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/odf/odf_document.h>

View File

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

View File

@ -72,7 +72,6 @@ class common_chart_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(std::wstring) chart_style_name_;
};
@ -117,7 +116,6 @@ class chart_title_attlist
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(std::wstring) table_cell_range_;
odf_types::common_draw_position_attlist common_draw_position_attlist_;
common_chart_attlist common_attlist_;
@ -194,13 +192,13 @@ class chart_legend_attlist
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_;
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_;
common_chart_attlist common_attlist_;
odf_types::common_draw_position_attlist common_draw_position_attlist_;
common_chart_attlist common_attlist_;
};

View File

@ -69,8 +69,14 @@ enum ElementType
typeTextTime,
typeTextModificationTime,
typeTextFileName,
typeTextSequence,
typeTextSheetName,
typeTextTemplateName,
typeTextDropDown,
typeTextLabel,
typeTextSequenceDecls,
typeTextSequenceDecl,
typeTextSequence,
typePresentationFooter,
typePresentationDateTime,
@ -78,6 +84,8 @@ enum ElementType
typeDcCreator,
typeDcDate,
typeDrawA,
typeTextH,
typeTextP,
@ -90,28 +98,42 @@ enum ElementType
typeTextSectionSource,
typeTextIndexTitle,
typeTextIndexBody,
typeTextNumberedParagraph,
typeDrawA,
typeTextNumberedParagraph,
typeTextExpression,
typeTextTableOfContent,
typeTextIllustrationIndex,
typeTextTableIndex,
typeTextObjectIndex,
typeTextUserIndex,
typeTextAlphabeticalIndex,
typeTextBibliography,
typeTextBibliographyMark,
typeTextTableOfContentSource,
typeTextIllustrationIndex,
typeTextIllustrationIndexSource,
typeTextTableIndex,
typeTextTableIndexSource,
typeTextObjectIndex,
typeTextObjectIndexSource,
typeTextUserIndex,
typeTextUserIndexSource,
typeTextAlphabeticalIndex,
typeTextAlphabeticalIndexSource,
typeTextBibliographySource,
typeTextBibliography,
typeTextBibliographyMark,
typeTextBibliographySource,
typeTextVariableInput,
typeTextVariableGet,
typeTextVariableSet,
typeTextVariableDecl,
typeTextVariableDecls,
typeTextUserFieldDecls,
typeTextUserFieldDecl,
typeTextUserFieldGet,
typeTextUserFieldSet,
typeTextUserFieldInput,
typeTextTrackedChanges,
typeTextChangedRegion,
@ -125,6 +147,11 @@ enum ElementType
typeTextFormatChange,
typeTextInsertion,
typeTextMeta,
typeTextMetaField,
typeTextTextInput,
typeShape,
typeChangeMarks,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -88,8 +88,8 @@ void style_chart_properties::add_attributes( const xml::attributes_wc_ptr & Attr
_CP_OPT(int) iVal;
//CP_APPLY_ATTR(L"chart:symbol-type", iVal); if (iVal)content_.push_back(_property(L"symbol-type", iVal.get()));
CP_APPLY_ATTR(L"chart:gap-width", iVal); if (iVal)content_.push_back(_property(L"gap-width", iVal.get()));
//CP_APPLY_ATTR(L"chart:symbol-type", iVal); if (iVal)content_.push_back(_property(L"symbol-type", iVal.get()));
CP_APPLY_ATTR(L"chart:gap-width", iVal); if (iVal)content_.push_back(_property(L"gap-width", iVal.get()));
CP_APPLY_ATTR(L"chart:overlap", iVal); if (iVal)content_.push_back(_property(L"overlap", iVal.get()));
CP_APPLY_ATTR(L"chart:spline-order", iVal); if (iVal)content_.push_back(_property(L"spline-order", iVal.get()));
CP_APPLY_ATTR(L"chart:spline-resolution",iVal); if (iVal)content_.push_back(_property(L"spline-resolution", iVal.get()));
@ -100,8 +100,8 @@ void style_chart_properties::add_attributes( const xml::attributes_wc_ptr & Attr
CP_APPLY_ATTR(L"chart:maximum", dVal); if (dVal)content_.push_back(_property(L"maximum", dVal.get()));
CP_APPLY_ATTR(L"chart:minimum", dVal); if (dVal)content_.push_back(_property(L"minimum", dVal.get()));
CP_APPLY_ATTR(L"chart:origin", dVal); if (dVal)content_.push_back(_property(L"origin", dVal.get()));
CP_APPLY_ATTR(L"chart:interval-major", dVal); if (dVal)content_.push_back(_property(L"interval-major", dVal.get()));
CP_APPLY_ATTR(L"chart:origin", dVal); if (dVal)content_.push_back(_property(L"origin", dVal.get()));
CP_APPLY_ATTR(L"chart:interval-major", dVal); if (dVal)content_.push_back(_property(L"interval-major", dVal.get()));
CP_APPLY_ATTR(L"chart:error-percentage",dVal); if (dVal)content_.push_back(_property(L"error-percentage", dVal.get()));
CP_APPLY_ATTR(L"chart:error-margin", dVal); if (dVal)content_.push_back(_property(L"error-margin", dVal.get()));
CP_APPLY_ATTR(L"chart:error-lower-limit",dVal); if (dVal)content_.push_back(_property(L"error-lower-limit", dVal.get()));

View File

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

View File

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

View File

@ -67,10 +67,11 @@ void table_format_properties::add_attributes( const xml::attributes_wc_ptr & Att
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"style:may-break-between-rows", style_may_break_between_rows_);
CP_APPLY_ATTR(L"table:align", table_align_);
CP_APPLY_ATTR(L"table:border-model", table_border_model_);
CP_APPLY_ATTR(L"table:display", table_display_);
CP_APPLY_ATTR(L"tableooo:tab-color", tableooo_tab_color_);
CP_APPLY_ATTR(L"table:align", table_align_);
CP_APPLY_ATTR(L"table:border-model", table_border_model_);
CP_APPLY_ATTR(L"table:display", table_display_);
CP_APPLY_ATTR(L"tableooo:tab-color", tableooo_tab_color_);
CP_APPLY_ATTR(L"style:use-optimal-column-width",style_use_optimal_column_width_);
}
bool table_format_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
@ -94,17 +95,22 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
if (style_rel_width_)
{
int w_w = (int)(0.5 + 50.0 * style_rel_width_->get_value());
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"" << w_w << "\" />";
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"" << w_w << "\"/>";
}
else if (style_width_)
else if (style_use_optimal_column_width_)
{
_tblPr << L"<w:tblW w:type=\"auto\" w:w=\"0\"/>";
}
else if (style_width_)
{
int w_w = (int)(0.5 + 20.0 * style_width_->get_value_unit(length::pt));
if (w_w > 31680)w_w = 31680;
_tblPr << L"<w:tblW w:type=\"dxa\" w:w=\"" << w_w << "\" />";
_tblPr << L"<w:tblW w:type=\"dxa\" w:w=\"" << w_w << "\"/>";
}
else
{
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"5000\" />";
_tblPr << L"<w:tblW w:type=\"pct\" w:w=\"5000\"/>";
}
if (common_break_attlist_.fo_break_before_)
@ -127,23 +133,26 @@ void table_format_properties::docx_convert(oox::docx_conversion_context & Contex
{
odf_types::length indent = common_horizontal_margin_attlist_.fo_margin_left_->get_length();
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\" />";
_tblPr << L"<w:tblInd w:w=\"" << indent.get_value_unit(odf_types::length::pt) * 20 << "\" w:type=\"dxa\"/>";
}
}
else //if (table_align_->get_type() == table_align::Center)
w_val = boost::lexical_cast<std::wstring>(*table_align_);
_tblPr << L"<w:jc w:val=\"" << w_val << "\" />";
_tblPr << L"<w:jc w:val=\"" << w_val << "\"/>";
}
_tblPr << "<w:tblLayout w:type=\"fixed\" />";
if (!style_use_optimal_column_width_)
{
_tblPr << "<w:tblLayout w:type=\"fixed\"/>";
}
if (common_background_color_attlist_.fo_background_color_)
{
const std::wstring w_fill = (common_background_color_attlist_.fo_background_color_->get_type() == background_color::Enabled
? common_background_color_attlist_.fo_background_color_->get_color().get_hex_value() : L"auto");
_tblPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\" />";
_tblPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\"/>";
}
}

View File

@ -79,7 +79,6 @@ public:
_CP_OPT(odf_types::length) style_width_;
_CP_OPT(odf_types::percent) style_rel_width_;
office_element_ptr style_background_image_;
_CP_OPT(bool) style_may_break_between_rows_;
_CP_OPT(odf_types::border_model) table_border_model_;
@ -87,6 +86,8 @@ public:
_CP_OPT(bool) table_display_;
_CP_OPT(odf_types::color) tableooo_tab_color_;
_CP_OPT(odf_types::Bool) style_use_optimal_column_width_; //not specification
office_element_ptr style_background_image_;
};
class style_table_properties : public office_element_impl<style_table_properties>

View File

@ -1236,12 +1236,19 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
{
int fontSize=0;
if (Context.get_drop_cap_context().state()==2)
{
fontSize = process_font_size(fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7);//вместо 1 ДОЛЖНОБЫТЬ коэфф. межстрочного интервала!!!
if (fontSize < 1)
fontSize = Context.get_drop_cap_context().FontSize / 7.52;
}
else
{
fontSize = process_font_size(fo_font_size_, Context.get_styles_context().get_current_processed_style());
}
if (fontSize>0)
if (fontSize > 0)
{
_rPr << L"<w:sz w:val=\"" << fontSize << "\" />";
}

View File

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

View File

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

View File

@ -35,7 +35,6 @@
#include <boost/make_shared.hpp>
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"
@ -337,23 +336,6 @@ void table_columns_and_groups::add_child_element( xml::sax * Reader, const std::
}
else
not_applicable_element(L"table-columns-and-groups", Reader, Ns, Name);
/*
if (CP_CHECK_NAME(L"table", L"table-column-group") && type_ != 1)
{
type_ = 0;
CP_CREATE_ELEMENT_SIMPLE(table_table_column_group_);
}
else if (( CP_CHECK_NAME(L"table", L"table-columns") ||
CP_CHECK_NAME(L"table", L"table-column") ||
CP_CHECK_NAME(L"table", L"table-header-columns") )
&& type_ != 0)
{
type_ = 1;
table_columns_no_group_.add_child_element(Reader, Ns, Name, Context);
}
else
not_applicable_element(L"table-columns-and-groups", Reader, Ns, Name);
*/
}
//////////////////////////////////////////////////////////////////////////////////////////////////

View File

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

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"
#include "odfcontext.h"
@ -164,7 +163,6 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
if (inst && inst->content())
inst->content()->docx_convert(Context);
Context.get_styles_context().docx_serialize_table_style(_Wostream, Context.get_text_tracked_context().dumpTblPr_);
_Wostream << L"<w:tblGrid>";

View File

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

View File

@ -34,7 +34,6 @@
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/simple_xml_writer.h>
@ -78,13 +77,16 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
void table_table_row::xlsx_convert(oox::xlsx_conversion_context & Context)
{
bool bEndTable = Context.get_table_context().state()->get_end_table();
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())
if (attlist_.table_number_rows_repeated_ > 0x0f00 && empty_content_cells() || bEndTable)//0xf000 - conv_KDZO3J3xLIbZ5fC0HR0__xlsx.ods
{
Context.get_table_context().state()->set_end_table();
Context.get_table_context().state()->add_empty_row(attlist_.table_number_rows_repeated_);
return; //conv_hSX8n3lVbhALjt0aafg__xlsx.ods, conv_MA2CauoNfX_7ejKS5eg__xlsx.ods
}
@ -731,7 +733,15 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
int y, m, d;
if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
{
number_val = boost::lexical_cast<std::wstring>(oox::convertDate(y, m, d));
boost::int64_t intDate = oox::convertDate(y, m, d);
if (intDate > 0)
{
number_val = boost::lexical_cast<std::wstring>(intDate);
}
else
{
str_val = attr.office_date_value_.get();
}
}
}
}
@ -742,11 +752,19 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
if (attr.office_time_value_)
{
const std::wstring tv = attr.office_time_value_.get();
int h,m;
int h, m;
double s;
if (oox::parseTime(tv, h, m, s))
{
number_val = boost::lexical_cast<std::wstring>(oox::convertTime(h, m, s));
boost::int64_t intTime = oox::convertTime(h, m, s);
if (intTime > 0)
{
number_val = boost::lexical_cast<std::wstring>(intTime);
}
else
{
str_val = tv;
}
}
}
}
@ -899,34 +917,262 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
{
std::wostream & strm = Context.current_sheet().sheetData();
const int sharedStringId = content_.xlsx_convert(Context, NULL);
const common_value_and_type_attlist & attr = attlist_.common_value_and_type_attlist_;
office_value_type::type odf_value_type = office_value_type::Custom;
oox::XlsxCellType::type t_val = oox::XlsxCellType::s;
std::wstring formula = attlist_.table_formula_.get_value_or(L"");
std::wstring number_val;
_CP_OPT(bool) bool_val;
_CP_OPT(std::wstring) str_val;
std::wstring num_format;
size_t xfId_last_set = 0;
int empty_cell_count = 0;
bool skip_next_cell = false;
bool is_style_visible = true;
bool is_data_visible = false;
// вычислить стиль для ячейки
std::wstring cellStyleName = attlist_.table_style_name_.get_value_or(L"");
std::wstring columnStyleName = Context.get_table_context().default_column_cell_style();
std::wstring rowStyleName = Context.get_table_context().default_row_cell_style();
if (attlist_.table_number_columns_repeated_ > 1)
columnStyleName.clear(); // могут быть разные стили колонок Book 24.ods
odf_read_context & odfContext = Context.root()->odf_context();
style_instance *defaultCellStyle=NULL, *defaultColumnCellStyle = NULL, *defaultRowCellStyle =NULL, *cellStyle = NULL;
try
{
defaultCellStyle = odfContext.styleContainer().style_default_by_type(style_family::TableCell);
defaultColumnCellStyle = odfContext.styleContainer().style_by_name(columnStyleName, style_family::TableCell, false);
defaultRowCellStyle = odfContext.styleContainer().style_by_name(rowStyleName, style_family::TableCell, false);
cellStyle = odfContext.styleContainer().style_by_name(cellStyleName, style_family::TableCell, false);
}
catch(...)
{
_CP_LOG << L"[error]: style wrong\n";
}
std::wstring data_style = CalcCellDataStyle(Context, columnStyleName, rowStyleName, cellStyleName);
// стили не наследуются
std::vector<const style_instance *> instances;
instances.push_back(defaultCellStyle);
if (defaultColumnCellStyle)
instances.push_back(defaultColumnCellStyle);
if (defaultRowCellStyle)
{
if (instances.size() > 1)
instances[1] = defaultRowCellStyle;
else
instances.push_back(defaultRowCellStyle);
}
if (cellStyle)
{
if (instances.size() > 1)
instances[1] = cellStyle;
else
instances.push_back(cellStyle);
}
text_format_properties_content textFormatProperties = calc_text_properties_content (instances);
paragraph_format_properties parFormatProperties = calc_paragraph_properties_content (instances);
style_table_cell_properties_attlist cellFormatProperties = calc_table_cell_properties (instances);
if (attr.office_value_type_)
odf_value_type = attr.office_value_type_->get_type();
if ((odf_value_type == office_value_type::Float) ||
(odf_value_type == office_value_type::Custom && attr.office_value_))
{
t_val = oox::XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (odf_value_type == office_value_type::Percentage)
{
t_val = oox::XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if (odf_value_type == office_value_type::Currency)
{
t_val = oox::XlsxCellType::n;
number_val = attr.office_value_.get_value_or(L"");
}
else if ((odf_value_type == office_value_type::Date) ||
(odf_value_type == office_value_type::Custom && attr.office_date_value_))
{
t_val = oox::XlsxCellType::n;
if (attr.office_date_value_)
{
int y, m, d;
if (oox::parseDate(attr.office_date_value_.get(), y, m, d))
{
boost::int64_t intDate = oox::convertDate(y, m, d);
if (intDate > 0)
{
number_val = boost::lexical_cast<std::wstring>(intDate);
}
else
{
str_val = attr.office_date_value_.get();
}
}
}
}
else if ((odf_value_type == office_value_type::Time) ||
(odf_value_type == office_value_type::Custom && attr.office_time_value_))
{
t_val = oox::XlsxCellType::n;
if (attr.office_time_value_)
{
const std::wstring tv = attr.office_time_value_.get();
int h,m;
double s;
if (oox::parseTime(tv, h, m, s))
{
number_val = boost::lexical_cast<std::wstring>(oox::convertTime(h, m, s));
}
}
}
else if ((odf_value_type == office_value_type::Boolean) ||
(odf_value_type == office_value_type::Custom && attr.office_boolean_value_))
{
t_val = oox::XlsxCellType::b;
if (attr.office_boolean_value_) bool_val = oox::parseBoolVal(attr.office_boolean_value_.get());
}
else if ((odf_value_type == office_value_type::String) ||
(odf_value_type == office_value_type::Custom && attr.office_string_value_))
{
t_val = oox::XlsxCellType::str;
if (attr.office_string_value_) str_val = attr.office_string_value_.get();
}
if (!data_style.empty())
{
office_element_ptr elm = odfContext.numberStyles().find_by_style_name(data_style);
number_style_base *num_style = dynamic_cast<number_style_base*>(elm.get());
if (num_style)
{
Context.get_num_format_context().start_complex_format();
num_style->oox_convert(Context.get_num_format_context());
Context.get_num_format_context().end_complex_format();
num_format = Context.get_num_format_context().get_last_format();
}
}
oox::xlsx_cell_format cellFormat;
cellFormat.set_cell_type(t_val);
cellFormat.set_num_format(oox::odf_string_to_build_in(odf_value_type));
is_style_visible = (!cellStyleName.empty() || defaultColumnCellStyle) ? true : false;
if ( content_.elements_.size() > 0 ||
!formula.empty() ||
( t_val == oox::XlsxCellType::n && !number_val.empty()) ||
( t_val == oox::XlsxCellType::b && bool_val) ||
(( t_val == oox::XlsxCellType::str || oox::XlsxCellType::inlineStr) && str_val)) is_data_visible = true;
if (attlist_.table_number_columns_repeated_ < 199 && last_cell_) last_cell_ = false;
int cell_repeated_max = Context.current_table_column() + attlist_.table_number_columns_repeated_ + 1;
if (cell_repeated_max >= 1024 && cellStyleName.empty() && last_cell_ && !is_data_visible)
{//Book 24.ods
return;
}
if (is_style_visible)
{
xfId_last_set = Context.get_style_manager().xfId(&textFormatProperties, &parFormatProperties, &cellFormatProperties, &cellFormat, num_format, false, is_style_visible);
}
for (unsigned int r = 0; r < attlist_.table_number_columns_repeated_; ++r)
{
Context.start_table_covered_cell();
const int xfId = Context.get_current_cell_style_id();
Context.start_table_covered_cell ();
if (is_style_visible)
Context.set_current_cell_style_id(xfId_last_set);
const int sharedStringId = content_.xlsx_convert(Context, &textFormatProperties);
if (t_val == oox::XlsxCellType::str && sharedStringId >=0)
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
if (skip_next_cell)break;
CP_XML_WRITER(strm)
// пустые ячейки пропускаем.
if ( is_data_visible || ((cellStyle || defaultColumnCellStyle) && is_style_visible))
{
CP_XML_NODE(L"c")
CP_XML_WRITER(strm)
{
CP_XML_ATTR(L"r", Context.current_cell_address());
if (xfId >= 0)
{
CP_XML_ATTR(L"s", xfId);
}
CP_XML_NODE(L"c")
{
CP_XML_ATTR(L"r", oox::getCellAddress(Context.current_table_column(), Context.current_table_row()));
CP_XML_ATTR(L"t", oox::cellType2Str(t_val));
CP_XML_ATTR(L"s", xfId_last_set);
if (sharedStringId >=0)
{
CP_XML_NODE(L"v")
if (!formula.empty())
{
CP_XML_CONTENT(sharedStringId);
const std::wstring xlsxFormula = formulas_converter.convert(formula);
if (!xlsxFormula.empty())
{
CP_XML_NODE(L"f")
{
CP_XML_CONTENT(xlsxFormula);
}
}
}
}
} // c
if (sharedStringId >= 0 && t_val == oox::XlsxCellType::s)
{
CP_XML_NODE(L"v") { CP_XML_CONTENT(sharedStringId); }
}
else if ((t_val == oox::XlsxCellType::str || t_val == oox::XlsxCellType::inlineStr) && str_val)
{
CP_XML_NODE(L"v") { CP_XML_CONTENT(str_val.get()); }
}
else if (t_val == oox::XlsxCellType::n && !number_val.empty())
{
CP_XML_NODE(L"v") { CP_XML_CONTENT(number_val);}
}
else if (t_val == oox::XlsxCellType::b && bool_val)
{
CP_XML_NODE(L"v") { CP_XML_CONTENT((int)(bool_val.get())); }
}
}
if ( is_data_visible || (cellStyle && is_style_visible && !last_cell_))
{
Context.non_empty_row();
empty_cell_count = 0 ;
}
else
{
empty_cell_count++;
//Уведомление_оручении.ods - 13 повторов пустых с cellStyle=NULL - нужные !!!
if (empty_cell_count > 19 && last_cell_&& (attlist_.table_number_columns_repeated_> 299 || cellStyle == NULL))
{//пишем простыню только если задан стиль тока для этих ячеек
skip_next_cell = true;
}
}
}
}
else
{
if (last_cell_) // Vehicle log book.ods (row = 24 and more)
skip_next_cell = true;
}
Context.end_table_covered_cell();

View File

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

View File

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

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