Compare commits

..

65 Commits

Author SHA1 Message Date
4c930e716b Merge remote-tracking branch 'origin/hotfix/v5.2.3' into develop 2018-10-17 15:38:13 +03:00
595ecae254 x2t - binary - native convert locked canvas - bix bug #28246 2018-10-17 13:29:55 +03:00
d34b850c52 [ios][pe] events 2018-10-12 19:15:18 +03:00
24332cca42 [ios][x2t] fixed build 2018-10-12 12:39:04 +03:00
55e7777abb [zlib] Remove zlib-1.2.3 2018-10-10 18:46:27 +03:00
b7c8bc2769 [zlib] Update zlib to 1.2.11
Fix opening of xlsx created by NPOI(bad-zip.xlsx)
2018-10-10 18:42:45 +03:00
13900daf08 [zlib] Repeat local changes from zlib-1.2.3 2018-10-10 18:39:00 +03:00
2feb1ac8e8 Add zlib-1.2.11 2018-10-10 17:52:04 +03:00
d872f4220c Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-09 18:14:42 +03:00
e859821647 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-09 17:02:46 +03:00
18cbd41c84 Add GetImage method to IImageCache 2018-10-08 18:16:06 +03:00
8985395ef1 [x2t] Move from mm to twips in Editor.bin 2018-10-04 17:58:29 +03:00
f4d72572c0 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-10-04 13:04:52 +03:00
bc319bddbf Gost algorithms 2018-10-03 19:18:01 +03:00
8625e93ac5 [x2t] Rename READ2_DEF -> READ2_DEF_SPREADSHEET 2018-10-01 18:14:04 +03:00
1493e4a949 [ios][x2t] fixed build 2018-09-28 16:36:12 +03:00
85bf4b8fac Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 15:57:47 +03:00
b1b911b538 Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 14:51:13 +03:00
2192bff46b Merge remote-tracking branch 'origin/hotfix/v5.2.1' into develop 2018-09-28 14:39:43 +03:00
e4e6acd1bc [android][x2t] added doctrenderer file stub 2018-09-27 15:03:47 +03:00
7418b2327a Merge remote-tracking branch 'origin/develop' into develop 2018-09-27 14:10:28 +03:00
18d610e3e0 [android][x2t] added example of converter 2018-09-27 14:09:12 +03:00
4e81420eed [ios][x2t] fixed build 2018-09-26 16:18:50 +03:00
e26f836da7 Merge commit '69d2b12f5315e96442fc5a0620d4f4c2070c4e77' into develop 2018-09-24 18:34:51 +03:00
538e477818 Revert "[test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32"
This reverts commit 05694d13f3.
2018-09-24 13:19:18 +03:00
b212e878c6 Merge pull request #114 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-24 01:13:01 +03:00
05694d13f3 [test] Define AVS_ERROR_FIRST as 0 to avoid issues with assignment and comparison uint64, int64, int32 2018-09-24 01:04:14 +03:00
1dd72c99a2 Remove define GetCharWidth 2018-09-21 16:43:39 +02:00
4b73e58693 [bug] Fix missing function name 2018-09-21 17:36:32 +03:00
bee4f57dd3 [bug] Fix opening encrypted odf files 2018-09-21 17:36:32 +03:00
142f9f57a3 OdfFormatReader&Writer - refactoring converting wordarts from/to ooxml 2018-09-20 18:59:51 +03:00
28346c4571 Fix bug with squares in combobox fonts (& empty rects) 2018-09-20 14:53:10 +03:00
9810087ee1 Merge pull request #108 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-09-20 14:38:32 +03:00
2b8e1456c2 . 2018-09-20 11:41:42 +03:00
49723e648a . 2018-09-19 11:29:43 +03:00
b0a2104b21 Merge commit 'de51052f6ae59ac36665fb3f85804081a888c7c5' into develop 2018-09-18 20:03:33 +03:00
e4986f4202 . 2018-09-18 19:35:06 +03:00
bd1dc5a7b6 . 2018-09-17 17:28:46 +03:00
1ccbe323f4 . 2018-09-14 19:21:12 +03:00
3811169415 Merge commit '185dc3064f731e4adb04040e116dc53110c6d866' into develop 2018-09-14 11:36:36 +03:00
2871769479 . 2018-09-14 11:34:07 +03:00
acdce1edb9 . 2018-09-12 17:53:40 +03:00
67a40a5fc4 Constructor of __ox_drawing doesn't receive parameters 2018-09-12 15:41:37 +03:00
67cd654785 OdfFormatReader - convert form controls in spreadsheets 2018-09-11 14:59:10 +03:00
3816162555 Merge commit '3fb166f99a211e85474c121009019d06710722f8' into develop 2018-09-10 18:43:15 +03:00
d8121d1a12 [ios][x2t] fixed array check 2018-09-06 19:11:47 +03:00
a76bf57051 fix bug #38817 2018-09-06 13:46:47 +03:00
97b92cf75c . 2018-09-05 18:39:32 +03:00
506de8e9e1 fix bug #38678 2018-09-05 18:38:55 +03:00
677e3e49e0 . 2018-08-31 17:38:17 +03:00
02c84d107b Merge commit 'b59908e4c25b265641e77b2167826f236b3b9d64' into develop 2018-08-31 17:27:06 +03:00
49cd76d0f3 Ooxml encrypt files - add support compatibility with Office 2003-2007(+ add rc4 method to encrtypt); add des method in agile encryption 2018-08-30 17:47:17 +03:00
26f32dd511 [ios][pe] chart events 2018-08-29 18:25:08 +03:00
395e54cf76 [ios][x2t] fixed build 2018-08-24 15:11:04 +03:00
40476e7555 [ios][x2t] use system libxml2 2018-08-24 14:59:54 +03:00
04f06c23a1 DocxFormat - extend shading pPr 2018-08-24 13:22:45 +03:00
a9a635747a [ios][x2t] fixed build 2018-08-24 12:50:05 +03:00
4027a0de25 Merge commit 'a232fcd9e1042811d624ff8934dc689f57ac2f57' into develop 2018-08-24 11:10:03 +03:00
f4fa754ce4 Merge pull request #96 from ONLYOFFICE/release/v5.2.0
Release/v5.2.0
2018-08-08 15:04:56 +02:00
7d88a91fcc up 2018-08-03 10:39:59 +03:00
069b12839f Merge commit 'c23ff4c8cd5bb2040f75a3a9845fc41d9d496216' into develop 2018-07-30 10:45:09 +03:00
aa609336ca [ios][x2t] fixed build 2018-07-23 19:48:36 +03:00
452917f213 [pe][ios] Apply timing to all 2018-07-19 11:13:28 +03:00
5b5ccdc9be [pe][ios] Events 2018-07-18 19:19:13 +03:00
adf7ca65ea [ios][pe] events 2018-07-18 16:48:45 +03:00
654 changed files with 60523 additions and 39330 deletions

2
.gitignore vendored
View File

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

View File

@ -52,6 +52,7 @@
#include <string.h>
#endif
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../DesktopEditor/common/Types.h"
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"

View File

@ -1071,9 +1071,7 @@ namespace DocFileFormat
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
bool bStartField = _fieldLevels.empty() ? false : (_fieldLevels.back().bBegin && !_fieldLevels.back().bSeparate);
if (cpFieldStart < cpPic && cpPic < cpFieldEnd && !bStartField)
if (cpFieldStart < cpPic && cpPic < cpFieldEnd)
{
writeField(text, cpFieldStart, cpFieldEnd);
text.clear();

View File

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

View File

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

View File

@ -101,24 +101,6 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
OptionEntryPtr ExtractOption(const PropertyId & prop) const
{
OptionEntryPtr ret;
for ( size_t i = 0; i < this->Children.size(); ++i )
{
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
if ( opt == NULL ) continue;
std::map<PropertyId, OptionEntryPtr>::iterator pFind = opt->OptionsByID.find(prop);
if (pFind != opt->OptionsByID.end())
{
ret = pFind->second;
}
}
return ret;
}
std::vector<OptionEntryPtr> ExtractOptions() const
{
std::vector<OptionEntryPtr> ret;

View File

@ -42,15 +42,15 @@ class SectPr
{
public:
std::wstring sHeaderFooterReference;
double W;
double H;
long W;
long H;
BYTE cOrientation;
double Left;
double Top;
double Right;
double Bottom;
double Header;
double Footer;
long Left;
long Top;
long Right;
long Bottom;
long Header;
long Footer;
bool TitlePg;
bool EvenAndOddHeaders;
BYTE SectionType;
@ -61,6 +61,13 @@ public:
std::wstring footnotePr;
std::wstring endnotePr;
bool bW;
bool bH;
bool bOrientation;
bool bLeft;
bool bTop;
bool bRight;
bool bBottom;
bool bHeader;
bool bFooter;
bool bTitlePg;
@ -69,18 +76,16 @@ public:
bool bPageNumStart;
SectPr()
{
W = Page_Width;
H = Page_Height;
cOrientation = orientation_Portrait;
Left = 30;
Top = 20;
Right = 15;
Bottom = 20;
Header = 12.5;
Footer = 12.5;
sHeaderFooterReference = _T("");
cols = _T("<w:cols w:space=\"708\"/>");
bW = false;
bH = false;
bOrientation = false;
bLeft = false;
bTop = false;
bRight = false;
bBottom = false;
bHeader = false;
bFooter = false;
bTitlePg = false;
@ -91,14 +96,6 @@ public:
std::wstring Write()
{
std::wstring sRes = _T("");
long nWidth = SerializeCommon::Round(W * g_dKoef_mm_to_twips);
long nHeight = SerializeCommon::Round(H * g_dKoef_mm_to_twips);
long nMLeft = SerializeCommon::Round(Left * g_dKoef_mm_to_twips);
long nMTop = SerializeCommon::Round(Top * g_dKoef_mm_to_twips);
long nMRight = SerializeCommon::Round(Right * g_dKoef_mm_to_twips);
long nMBottom = SerializeCommon::Round(Bottom * g_dKoef_mm_to_twips);
long nMHeader = SerializeCommon::Round(Header * g_dKoef_mm_to_twips);
long nMFooter = SerializeCommon::Round(Footer * g_dKoef_mm_to_twips);
if(!sHeaderFooterReference.empty())
sRes += sHeaderFooterReference;
@ -120,19 +117,41 @@ public:
}
sRes += L"<w:type w:val=\"" + sType + L"\"/>";
}
sRes += L"<w:pgSz w:w=\"" + std::to_wstring(nWidth) + L"\" w:h=\"" + std::to_wstring(nHeight) + L"\"";
if(orientation_Portrait != cOrientation)
sRes += L" w:orient=\"landscape\"";
sRes += L"/>";
if((bW && bH) || bOrientation)
{
sRes += L"<w:pgSz";
if(bW && bH)
{
sRes += L" w:w=\"" + std::to_wstring(W) + L"\" w:h=\"" + std::to_wstring(H) + L"\"";
}
if(bOrientation)
{
if(orientation_Portrait != cOrientation)
sRes += L" w:orient=\"landscape\"";
else
sRes += L" w:orient=\"portrait\"";
}
sRes += L"<w:pgMar w:top=\"" + std::to_wstring(nMTop) + L"\" w:right=\"" + std::to_wstring(nMRight) +
L"\" w:bottom=\"" + std::to_wstring(nMBottom) + L"\" w:left=\"" + std::to_wstring(nMLeft) + L"\" w:gutter=\"0\"";
sRes += L"/>";
}
if(bHeader)
sRes += L" w:header=\"" + std::to_wstring(nMHeader) + L"\"";
if(bFooter)
sRes += L" w:footer=\"" + std::to_wstring(nMFooter) + L"\"";
sRes += L"/>";
if(bLeft || bTop || bRight || bBottom || bHeader || bFooter)
{
sRes += L"<w:pgMar";
if(bTop)
sRes += L" w:top=\"" + std::to_wstring(Top) + L"\"";
if(bRight)
sRes += L" w:right=\"" + std::to_wstring(Right) + L"\"";
if(bBottom)
sRes += L" w:bottom=\"" + std::to_wstring(Bottom) + L"\"";
if(bLeft)
sRes += L" w:left=\"" + std::to_wstring(Left) + L"\"";
if(bHeader)
sRes += L" w:header=\"" + std::to_wstring(Header) + L"\"";
if(bFooter)
sRes += L" w:footer=\"" + std::to_wstring(Footer) + L"\"";
sRes += L" w:gutter=\"0\"/>";
}
if(!pgBorders.empty())
sRes += pgBorders;
@ -245,6 +264,7 @@ class Spacing
public:
bool bLineRule;
bool bLine;
bool bLineTwips;
bool bAfter;
bool bBefore;
bool bAfterAuto;
@ -252,14 +272,16 @@ public:
BYTE LineRule;
double Line;
double After;
double Before;
long LineTwips;
long After;
long Before;
bool AfterAuto;
bool BeforeAuto;
Spacing()
{
bLineRule = false;
bLine = false;
bLineTwips = false;
bAfter = false;
bBefore = false;
bAfterAuto = false;
@ -335,10 +357,48 @@ public:
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
switch(Value)
{
case SimpleTypes::shdClear : sShd += L" w:val=\"clear\""; break;
case SimpleTypes::shdDiagCross : sShd += L" w:val=\"diagCross\""; break;
case SimpleTypes::shdDiagStripe : sShd += L" w:val=\"diagStripe\""; break;
case SimpleTypes::shdHorzCross : sShd += L" w:val=\"horzCross\""; break;
case SimpleTypes::shdHorzStripe : sShd += L" w:val=\"horzStripe\""; break;
case SimpleTypes::shdNil : sShd += L" w:val=\"nil\""; break;
case SimpleTypes::shdPct10 : sShd += L" w:val=\"pct10\""; break;
case SimpleTypes::shdPct12 : sShd += L" w:val=\"pct12\""; break;
case SimpleTypes::shdPct15 : sShd += L" w:val=\"pct15\""; break;
case SimpleTypes::shdPct20 : sShd += L" w:val=\"pct20\""; break;
case SimpleTypes::shdPct25 : sShd += L" w:val=\"pct25\""; break;
case SimpleTypes::shdPct30 : sShd += L" w:val=\"pct30\""; break;
case SimpleTypes::shdPct35 : sShd += L" w:val=\"pct35\""; break;
case SimpleTypes::shdPct37 : sShd += L" w:val=\"pct37\""; break;
case SimpleTypes::shdPct40 : sShd += L" w:val=\"pct40\""; break;
case SimpleTypes::shdPct45 : sShd += L" w:val=\"pct45\""; break;
case SimpleTypes::shdPct5 : sShd += L" w:val=\"pct5\""; break;
case SimpleTypes::shdPct50 : sShd += L" w:val=\"pct50\""; break;
case SimpleTypes::shdPct55 : sShd += L" w:val=\"pct55\""; break;
case SimpleTypes::shdPct60 : sShd += L" w:val=\"pct60\""; break;
case SimpleTypes::shdPct62 : sShd += L" w:val=\"pct62\""; break;
case SimpleTypes::shdPct65 : sShd += L" w:val=\"pct65\""; break;
case SimpleTypes::shdPct70 : sShd += L" w:val=\"pct70\""; break;
case SimpleTypes::shdPct75 : sShd += L" w:val=\"pct75\""; break;
case SimpleTypes::shdPct80 : sShd += L" w:val=\"pct80\""; break;
case SimpleTypes::shdPct85 : sShd += L" w:val=\"pct85\""; break;
case SimpleTypes::shdPct87 : sShd += L" w:val=\"pct87\""; break;
case SimpleTypes::shdPct90 : sShd += L" w:val=\"pct90\""; break;
case SimpleTypes::shdPct95 : sShd += L" w:val=\"pct95\""; break;
case SimpleTypes::shdReverseDiagStripe : sShd += L" w:val=\"reverseDiagStripe\""; break;
case SimpleTypes::shdSolid : sShd += L" w:val=\"solid\""; break;
case SimpleTypes::shdThinDiagCross : sShd += L" w:val=\"thinDiagCross\""; break;
case SimpleTypes::shdThinDiagStripe : sShd += L" w:val=\"thinDiagStripe\""; break;
case SimpleTypes::shdThinHorzCross : sShd += L" w:val=\"thinHorzCross\""; break;
case SimpleTypes::shdThinHorzStripe : sShd += L" w:val=\"thinHorzStripe\""; break;
case SimpleTypes::shdThinReverseDiagStripe : sShd += L" w:val=\"thinReverseDiagStripe\""; break;
case SimpleTypes::shdThinVertStripe : sShd += L" w:val=\"thinVertStripe\""; break;
case SimpleTypes::shdVertStripe : sShd += L" w:val=\"vertStripe\""; break;
default : sShd += L" w:val=\"solid\""; break;
}
}
sShd += L" w:color=\"auto\"";
if(bColor)
@ -363,7 +423,7 @@ class Tab
{
public:
BYTE Val;
double Pos;
long Pos;
BYTE Leader;
bool bLeader;
Tab()
@ -397,11 +457,11 @@ public:
docRGB HighLight;
std::wstring Shd;
std::wstring RStyle;
double Spacing;
long Spacing;
bool DStrikeout;
bool Caps;
bool SmallCaps;
double Position;
long Position;
BYTE FontHint;
bool BoldCs;
bool ItalicCs;
@ -642,13 +702,11 @@ public:
}
if(bSpacing)
{
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * Spacing);
pCStringWriter->WriteString(L"<w:spacing w:val=\"" + std::to_wstring(nSpacing) + L"\"/>");
pCStringWriter->WriteString(L"<w:spacing w:val=\"" + std::to_wstring(Spacing) + L"\"/>");
}
if(bPosition)
{
long nPosition = SerializeCommon::Round( g_dKoef_mm_to_hps * Position);
std::wstring sPosition = L"<w:position w:val=\"" + std::to_wstring(nPosition) + L"\"/>";
std::wstring sPosition = L"<w:position w:val=\"" + std::to_wstring(Position) + L"\"/>";
pCStringWriter->WriteString(sPosition);
}
if(bFontSize)
@ -1001,6 +1059,26 @@ public:
};
class PaddingsToWrite
{
public:
long Left;
long Top;
long Right;
long Bottom;
bool bLeft;
bool bTop;
bool bRight;
bool bBottom;
public: PaddingsToWrite()
{
bLeft = false;
bTop = false;
bRight = false;
bBottom = false;
}
};
class PaddingsToWriteMM
{
public:
double Left;
double Top;
@ -1011,7 +1089,7 @@ public:
bool bTop;
bool bRight;
bool bBottom;
public: PaddingsToWrite()
public: PaddingsToWriteMM()
{
bLeft = false;
bTop = false;
@ -1028,7 +1106,7 @@ public:
double Y;
double Width;
double Height;
PaddingsToWrite Paddings;
PaddingsToWriteMM Paddings;
int m_nDocPr;
bool bMediaId;
@ -1167,8 +1245,8 @@ class docBorder
{
public:
docRGB Color;
double Space;
double Size;
long Space;
long Size;
BYTE Value;
CThemeColor ThemeColor;
@ -1201,13 +1279,11 @@ public:
}
if(bSize)
{
long nSize = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * Size);
pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(nSize) + L"\"");
pCStringWriter->WriteString(L" w:sz=\"" + std::to_wstring(Size) + L"\"");
}
if(bSpace)
{
long nSpace = SerializeCommon::Round(g_dKoef_mm_to_pt * Space);
pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(nSpace) + L"\"");
pCStringWriter->WriteString(L" w:space=\"" + std::to_wstring(Space) + L"\"");
}
if(bThemeColor && ThemeColor.IsNoEmpty())
{
@ -2074,8 +2150,8 @@ public:
class CDrawingPropertyWrapPoint
{
public:
double X;
double Y;
__int64 X;
__int64 Y;
bool bX;
bool bY;
@ -2122,29 +2198,29 @@ public:
long DataLength;
BYTE Type;
bool BehindDoc;
double DistL;
double DistT;
double DistR;
double DistB;
__int64 DistL;
__int64 DistT;
__int64 DistR;
__int64 DistB;
bool LayoutInCell;
unsigned long RelativeHeight;
bool BSimplePos;
double EffectExtentL;
double EffectExtentT;
double EffectExtentR;
double EffectExtentB;
double Width;
double Height;
__int64 EffectExtentL;
__int64 EffectExtentT;
__int64 EffectExtentR;
__int64 EffectExtentB;
__int64 Width;
__int64 Height;
BYTE PositionHRelativeFrom;
BYTE PositionHAlign;
double PositionHPosOffset;
double PositionHPctOffset;
__int64 PositionHPosOffset;
double PositionHPctOffset;
BYTE PositionVRelativeFrom;
BYTE PositionVAlign;
double PositionVPosOffset;
__int64 PositionVPosOffset;
double PositionVPctOffset;
double SimplePosX;
double SimplePosY;
__int64 SimplePosX;
__int64 SimplePosY;
std::wstring sChartRels;
std::wstring sSizeRelH;
std::wstring sSizeRelV;
@ -2234,24 +2310,17 @@ public:
{
if(bWidth && bHeight)
{
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
if(false == bChart)
sXml += L"<wp:inline xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight) + L"\"/>";
distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height) + L"\"/>";
else
sXml += L"<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\">\
<wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight) + L"\"/>";
<wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height) + L"\"/>";
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(emuEffectExtentL) + L"\" t=\"" + std::to_wstring(emuEffectExtentT) +
L"\" r=\"" + std::to_wstring(emuEffectExtentR) + L"\" b=\"" + std::to_wstring(emuEffectExtentB) + L"\"/>";
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(EffectExtentL) + L"\" t=\"" + std::to_wstring(EffectExtentT) +
L"\" r=\"" + std::to_wstring(EffectExtentR) + L"\" b=\"" + std::to_wstring(EffectExtentB) + L"\"/>";
}
if(!sDocPr.empty())
@ -2293,13 +2362,13 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
__int64 emuDistB = 0;
if(bDistL)
emuDistL = (__int64)(g_dKoef_mm_to_emu * DistL);
emuDistL = DistL;
if(bDistT)
emuDistT = (__int64)(g_dKoef_mm_to_emu * DistT);
emuDistT = DistT;
if(bDistR)
emuDistR = (__int64)(g_dKoef_mm_to_emu * DistR);
emuDistR = DistR;
if(bDistB)
emuDistB = (__int64)(g_dKoef_mm_to_emu * DistB);
emuDistB = DistB;
int nSimplePos = 0;
if(bBSimplePos && BSimplePos)
nSimplePos = 1;
@ -2328,10 +2397,10 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
__int64 emuX = 0;
if(bSimplePosX)
emuX = (__int64)(g_dKoef_mm_to_emu * SimplePosX);
emuX = SimplePosX;
__int64 emuY = 0;
if(bSimplePosY)
emuY = (__int64)(g_dKoef_mm_to_emu * SimplePosY);
emuY = SimplePosY;
sXml += L"<wp:simplePos x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
if(bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset))
@ -2362,8 +2431,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
else if(bPositionHPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionHPosOffset);
sContent = L"<wp:posOffset>" + std::to_wstring(emuPosOffset) + L"</wp:posOffset>";
sContent = L"<wp:posOffset>" + std::to_wstring(PositionHPosOffset) + L"</wp:posOffset>";
}
else if(bPositionHPctOffset)
{
@ -2400,8 +2468,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
else if(bPositionVPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionVPosOffset);
sContent = L"<wp:posOffset>" + std::to_wstring(emuPosOffset) + L"</wp:posOffset>";
sContent = L"<wp:posOffset>" + std::to_wstring(PositionVPosOffset) + L"</wp:posOffset>";
}
else if(bPositionVPctOffset)
{
@ -2410,20 +2477,13 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
}
sXml += L"<wp:positionV relativeFrom=\"" + sRelativeFrom + L"\">" + sContent + L"</wp:positionV>";
}
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
sXml += L"<wp:extent cx=\"" + std::to_wstring(emuWidth) + L"\" cy=\"" + std::to_wstring(emuHeight)+ L"\"/>";
sXml += L"<wp:extent cx=\"" + std::to_wstring(Width) + L"\" cy=\"" + std::to_wstring(Height)+ L"\"/>";
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(emuEffectExtentL) +
L"\" t=\"" + std::to_wstring(emuEffectExtentT) + L"\" r=\"" + std::to_wstring(emuEffectExtentR) +
L"\" b=\"" + std::to_wstring(emuEffectExtentB) + L"\"/>";
sXml += L"<wp:effectExtent l=\"" + std::to_wstring(EffectExtentL) +
L"\" t=\"" + std::to_wstring(EffectExtentT) + L"\" r=\"" + std::to_wstring(EffectExtentR) +
L"\" b=\"" + std::to_wstring(EffectExtentB) + L"\"/>";
}
if(bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType)
{
@ -2454,9 +2514,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.Y);
sXml += L"<wp:start x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
sXml += L"<wp:start x=\"" + std::to_wstring(DrawingPropertyWrap.Start.X) + L"\" y=\"" + std::to_wstring(DrawingPropertyWrap.Start.Y) + L"\"/>";
}
for(size_t i = 0; i < DrawingPropertyWrap.Points.size(); ++i)
@ -2464,9 +2522,7 @@ distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"" + std::to_wstr
CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i];
if(pWrapPoint->bX && pWrapPoint->bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->Y);
sXml += L"<wp:lineTo x=\"" + std::to_wstring(emuX) + L"\" y=\"" + std::to_wstring(emuY) + L"\"/>";
sXml += L"<wp:lineTo x=\"" + std::to_wstring(pWrapPoint->X) + L"\" y=\"" + std::to_wstring(pWrapPoint->Y) + L"\"/>";
}
}
sXml += L"</wp:wrapPolygon>";

View File

@ -455,7 +455,13 @@ public:
case c_oSerProp_rPrType::Spacing:
{
orPr->bSpacing = true;
orPr->Spacing = m_oBufferedStream.GetDouble();
orPr->Spacing = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
break;
case c_oSerProp_rPrType::SpacingTwips:
{
orPr->bSpacing = true;
orPr->Spacing = m_oBufferedStream.GetLong();
}
break;
case c_oSerProp_rPrType::DStrikeout:
@ -479,7 +485,13 @@ public:
case c_oSerProp_rPrType::Position:
{
orPr->bPosition = true;
orPr->Position = m_oBufferedStream.GetDouble();
orPr->Position = SerializeCommon::Round( g_dKoef_mm_to_hps * m_oBufferedStream.GetDouble());
}
break;
case c_oSerProp_rPrType::PositionHps:
{
orPr->bPosition = true;
orPr->Position = m_oBufferedStream.GetLong();
}
break;
case c_oSerProp_rPrType::FontHint:
@ -723,12 +735,12 @@ public:
{
Spacing oSpacing;
READ2_DEF(length, res, this->ReadSpacing, &oSpacing);
if(oSpacing.bLine || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
if(oSpacing.bLine || oSpacing.bLineTwips || oSpacing.bAfter || oSpacing.bAfterAuto || oSpacing.bBefore || oSpacing.bBeforeAuto)
{
pCStringWriter->WriteString(std::wstring(L"<w:spacing"));
BYTE bLineRule = linerule_Auto;
//проверяется bLine, а не bLineRule чтобы всегда писать LineRule, если есть w:line
if(oSpacing.bLine)
if(oSpacing.bLine || oSpacing.bLineTwips)
{
if(oSpacing.bLineRule)
bLineRule = oSpacing.LineRule;
@ -756,10 +768,13 @@ public:
}
pCStringWriter->WriteString(sLine);
}
else if(oSpacing.bLineTwips)
{
pCStringWriter->WriteString(L" w:line=\"" + std::to_wstring(oSpacing.LineTwips) + L"\"");
}
if(oSpacing.bAfter)
{
long After = SerializeCommon::Round( g_dKoef_mm_to_twips * oSpacing.After);
std::wstring sAfter = L" w:after=\"" + std::to_wstring(After) + L"\"";
std::wstring sAfter = L" w:after=\"" + std::to_wstring(oSpacing.After) + L"\"";
pCStringWriter->WriteString(sAfter);
}
if(oSpacing.bAfterAuto)
@ -771,8 +786,7 @@ public:
}
if(oSpacing.bBefore)
{
long Before = SerializeCommon::Round( g_dKoef_mm_to_twips * oSpacing.Before);
std::wstring sBefore = L" w:before=\"" + std::to_wstring(Before) + L"\"";
std::wstring sBefore = L" w:before=\"" + std::to_wstring(oSpacing.Before) + L"\"";
pCStringWriter->WriteString(sBefore);
}
if(oSpacing.bBeforeAuto)
@ -816,7 +830,6 @@ public:
for(size_t i = 0; i < nLen; ++i)
{
Tab& oTab = oTabs.m_aTabs[i];
long nTab = SerializeCommon::Round( g_dKoef_mm_to_twips * oTab.Pos);
std::wstring sVal;
switch(oTab.Val)
{
@ -825,7 +838,7 @@ 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(oTab.Pos) + L"\"");
if (oTab.bLeader)
{
std::wstring sLeader;
@ -937,6 +950,11 @@ public:
pCStringWriter->WriteString(L" w:left=\"" + std::to_wstring(nIndLeft) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_LeftTwips:
{
pCStringWriter->WriteString(L" w:left=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_Right:
{
double dIndRight = m_oBufferedStream.GetDouble();
@ -945,18 +963,34 @@ public:
pCStringWriter->WriteString(L" w:right=\"" + std::to_wstring(nIndRight) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_RightTwips:
{
pCStringWriter->WriteString(L" w:right=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
break;
}
case c_oSerProp_pPrType::Ind_FirstLine:
{
double dIndFirstLine = m_oBufferedStream.GetDouble();
long nIndFirstLine = SerializeCommon::Round(dIndFirstLine * g_dKoef_mm_to_twips);
std::wstring sIndFirstLine;
if(nIndFirstLine > 0)
if(nIndFirstLine >= 0)
sIndFirstLine = L" w:firstLine =\"" + std::to_wstring(nIndFirstLine) + L"\"";
else
sIndFirstLine = L" w:hanging=\"" + std::to_wstring(-nIndFirstLine) + L"\"";
pCStringWriter->WriteString(sIndFirstLine);
break;
}
case c_oSerProp_pPrType::Ind_FirstLineTwips:
{
long nIndFirstLine = m_oBufferedStream.GetLong();
std::wstring sIndFirstLine;
if(nIndFirstLine >= 0)
sIndFirstLine = L" w:firstLine =\"" + std::to_wstring(nIndFirstLine) + L"\"";
else
sIndFirstLine = L" w:hanging=\"" + std::to_wstring(-nIndFirstLine) + L"\"";
pCStringWriter->WriteString(sIndFirstLine);
break;
}
default:
res = c_oSerConstants::ReadUnknown;
break;
@ -973,17 +1007,29 @@ public:
pSpacing->bLine = true;
pSpacing->Line = m_oBufferedStream.GetDouble();
break;
case c_oSerProp_pPrType::Spacing_LineTwips:
pSpacing->bLineTwips = true;
pSpacing->LineTwips = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_LineRule:
pSpacing->bLineRule = true;
pSpacing->LineRule = m_oBufferedStream.GetUChar();
break;
case c_oSerProp_pPrType::Spacing_Before:
pSpacing->bBefore = true;
pSpacing->Before = m_oBufferedStream.GetDouble();
pSpacing->Before = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
break;
case c_oSerProp_pPrType::Spacing_BeforeTwips:
pSpacing->bBefore = true;
pSpacing->Before = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_After:
pSpacing->bAfter = true;
pSpacing->After = m_oBufferedStream.GetDouble();
pSpacing->After = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
break;
case c_oSerProp_pPrType::Spacing_AfterTwips:
pSpacing->bAfter = true;
pSpacing->After = m_oBufferedStream.GetLong();
break;
case c_oSerProp_pPrType::Spacing_BeforeAuto:
pSpacing->bBeforeAuto = true;
@ -1020,7 +1066,9 @@ public:
if(c_oSerProp_pPrType::Tab_Item_Val == type)
poTabItem->Val = m_oBufferedStream.GetUChar();
else if(c_oSerProp_pPrType::Tab_Item_Pos == type)
poTabItem->Pos = m_oBufferedStream.GetDouble();
poTabItem->Pos = SerializeCommon::Round( g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
else if(c_oSerProp_pPrType::Tab_Item_PosTwips == type)
poTabItem->Pos = m_oBufferedStream.GetLong();
else if(c_oSerProp_pPrType::Tab_Item_Leader == type)
{
poTabItem->bLeader = true;
@ -1113,12 +1161,22 @@ public:
else if( c_oSerBorderType::Space == type )
{
odocBorder->bSpace = true;
odocBorder->Space = m_oBufferedStream.GetDouble();
odocBorder->Space = SerializeCommon::Round(g_dKoef_mm_to_pt * m_oBufferedStream.GetDouble());
}
else if( c_oSerBorderType::SpacePoint == type )
{
odocBorder->bSpace = true;
odocBorder->Space = m_oBufferedStream.GetLong();
}
else if( c_oSerBorderType::Size == type )
{
odocBorder->bSize = true;
odocBorder->Size = m_oBufferedStream.GetDouble();
odocBorder->Size = SerializeCommon::Round(g_dKoef_mm_to_eightpoint * m_oBufferedStream.GetDouble());
}
else if( c_oSerBorderType::Size8Point == type )
{
odocBorder->bSize = true;
odocBorder->Size = m_oBufferedStream.GetLong();
}
else if( c_oSerBorderType::Value == type )
{
@ -1374,15 +1432,28 @@ public:
int res = c_oSerConstants::ReadOk;
if( c_oSer_pgSzType::Orientation == type )
{
pSectPr->bOrientation = true;
pSectPr->cOrientation = m_oBufferedStream.GetUChar();
}
else if( c_oSer_pgSzType::W == type )
{
pSectPr->W = m_oBufferedStream.GetDouble();
pSectPr->bW = true;
pSectPr->W = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgSzType::WTwips == type )
{
pSectPr->bW = true;
pSectPr->W = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgSzType::H == type )
{
pSectPr->H = m_oBufferedStream.GetDouble();
pSectPr->bH = true;
pSectPr->H = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgSzType::HTwips == type )
{
pSectPr->bH = true;
pSectPr->H = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -1394,29 +1465,63 @@ public:
int res = c_oSerConstants::ReadOk;
if( c_oSer_pgMarType::Left == type )
{
pSectPr->Left = m_oBufferedStream.GetDouble();
pSectPr->bLeft = true;
pSectPr->Left = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::LeftTwips == type )
{
pSectPr->bLeft = true;
pSectPr->Left = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Top == type )
{
pSectPr->Top = m_oBufferedStream.GetDouble();
pSectPr->bTop = true;
pSectPr->Top = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::TopTwips == type )
{
pSectPr->bTop = true;
pSectPr->Top = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Right == type )
{
pSectPr->Right = m_oBufferedStream.GetDouble();
pSectPr->bRight = true;
pSectPr->Right = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::RightTwips == type )
{
pSectPr->bRight = true;
pSectPr->Right = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Bottom == type )
{
pSectPr->Bottom = m_oBufferedStream.GetDouble();
pSectPr->bBottom = true;
pSectPr->Bottom = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::BottomTwips == type )
{
pSectPr->bBottom = true;
pSectPr->Bottom = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Header == type )
{
pSectPr->bHeader = true;
pSectPr->Header = m_oBufferedStream.GetDouble();
pSectPr->Header = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::HeaderTwips == type )
{
pSectPr->bHeader = true;
pSectPr->Header = m_oBufferedStream.GetLong();
}
else if( c_oSer_pgMarType::Footer == type )
{
pSectPr->bFooter = true;
pSectPr->Footer = m_oBufferedStream.GetDouble();
pSectPr->Footer = SerializeCommon::Round(g_dKoef_mm_to_twips * m_oBufferedStream.GetDouble());
}
else if( c_oSer_pgMarType::FooterTwips == type )
{
pSectPr->bFooter = true;
pSectPr->Footer = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -1716,6 +1821,10 @@ public:
long nInd = SerializeCommon::Round( g_dKoef_mm_to_twips * dInd);
pWiterTblPr->TableInd = L"<w:tblInd w:w=\"" + std::to_wstring(nInd) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableIndTwips == type )
{
pWiterTblPr->TableInd = L"<w:tblInd w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableW == type )
{
docW odocW;
@ -1815,6 +1924,10 @@ public:
long nSpacing = SerializeCommon::Round( g_dKoef_mm_to_twips * dSpacing);
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::TableCellSpacingTwips == type )
{
pWiterTblPr->TableCellSpacing = L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>";
}
else if( c_oSerProp_tblPrType::tblCaption == type )
{
pWiterTblPr->Caption = m_oBufferedStream.GetString3(length);
@ -1959,6 +2072,10 @@ public:
pCStringWriter->WriteString(L" w:tblpX=\"" + std::to_wstring(nX) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpXTwips == type )
{
pCStringWriter->WriteString(L" w:tblpX=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpXSpec == type )
{
std::wstring sXml;
@ -1992,6 +2109,10 @@ public:
pCStringWriter->WriteString(L" w:tblpY=\"" + std::to_wstring(nY) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpYTwips == type )
{
pCStringWriter->WriteString(L" w:tblpY=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if( c_oSer_tblpPrType2::TblpYSpec == type )
{
std::wstring sXml;
@ -2087,6 +2208,10 @@ public:
pCStringWriter->WriteString(L"<w:tblCellSpacing w:w=\"" + std::to_wstring(nSpacing) + L"\" w:type=\"dxa\"/>");
}
else if( c_oSerProp_rowPrType::TableCellSpacingTwips == type )
{
pCStringWriter->WriteString(L"<w:tblCellSpacing w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\" w:type=\"dxa\"/>");
}
else if( c_oSerProp_rowPrType::Height == type )
{
RowHeight val;
@ -2180,6 +2305,10 @@ public:
double dHeight = m_oBufferedStream.GetDouble();
pHeight->nHeight = SerializeCommon::Round( g_dKoef_mm_to_twips * dHeight);
}
else if( c_oSerProp_rowPrType::Height_ValueTwips == type )
{
pHeight->nHeight = m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -2358,6 +2487,10 @@ public:
pCStringWriter->WriteString(L" w:leftFromText=\"" + std::to_wstring(nLeft) + L"\"");
}
else if (c_oSerPaddingType::leftTwips == type)
{
pCStringWriter->WriteString(L" w:leftFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::top == type)
{
double dTop = m_oBufferedStream.GetDouble();
@ -2365,6 +2498,10 @@ public:
pCStringWriter->WriteString(L" w:topFromText=\"" + std::to_wstring(nTop) + L"\"");
}
else if (c_oSerPaddingType::topTwips == type)
{
pCStringWriter->WriteString(L" w:topFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::right == type)
{
double dRight = m_oBufferedStream.GetDouble();
@ -2372,6 +2509,10 @@ public:
pCStringWriter->WriteString(L" w:rightFromText=\"" + std::to_wstring(nRight) + L"\"");
}
else if (c_oSerPaddingType::rightTwips == type)
{
pCStringWriter->WriteString(L" w:rightFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else if (c_oSerPaddingType::bottom == type)
{
double dBottom = m_oBufferedStream.GetDouble();
@ -2379,6 +2520,10 @@ public:
pCStringWriter->WriteString(L" w:bottomFromText=\"" + std::to_wstring(nBottom) + L"\"");
}
else if (c_oSerPaddingType::bottomTwips == type)
{
pCStringWriter->WriteString(L" w:bottomFromText=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3295,10 +3440,12 @@ public:
{
double dDefTabStop = m_oBufferedStream.GetDouble();
long nDefTabStop = SerializeCommon::Round(dDefTabStop * g_dKoef_mm_to_twips);
std::wstring sXml;
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"" + std::to_wstring(nDefTabStop) + L"\"/>");
}
else if ( c_oSer_SettingsType::DefaultTabStopTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<w:defaultTabStop w:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else if ( c_oSer_SettingsType::MathPr == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<m:mathPr>"));
@ -3583,6 +3730,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:interSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:interSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3615,6 +3766,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:intraSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:intraSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3628,6 +3783,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:lMargin m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:lMargin m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3679,6 +3838,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:postSp m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:postSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3692,6 +3855,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:preSp m:val=\"" + std::to_wstring(lVal)+ L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:preSp m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3705,6 +3872,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:rMargin m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:rMargin m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -3735,6 +3906,10 @@ public:
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:wrapIndent m:val=\"" + std::to_wstring(lVal) + L"\"/>");
}
else if ( c_oSer_OMathBottomNodesValType::ValTwips == type )
{
m_oFileWriter.m_oSettingWriter.AddSetting(L"<m:wrapIndent m:val=\"" + std::to_wstring(m_oBufferedStream.GetLong()) + L"\"/>");
}
else
res = c_oSerConstants::ReadUnknown;
return res;
@ -7150,6 +7325,10 @@ public:
pCStringWriter->WriteString(L"<w:gridCol w:w=\"" + std::to_wstring(ngridCol)+ L"\"/>");
}
else if( c_oSerDocTableType::tblGrid_ItemTwips == type )
{
pCStringWriter->WriteString(L"<w:gridCol w:w=\"" + std::to_wstring(m_oBufferedStream.GetLong())+ L"\"/>");
}
else if( c_oSerDocTableType::tblGridChange == type )
{
TrackRevision oTrackRevision;
@ -7490,22 +7669,42 @@ public:
else if ( c_oSerImageType2::DistL == type )
{
pDrawingProperty->bDistL = true;
pDrawingProperty->DistL = m_oBufferedStream.GetDouble();
pDrawingProperty->DistL = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistLEmu == type )
{
pDrawingProperty->bDistL = true;
pDrawingProperty->DistL = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistT == type )
{
pDrawingProperty->bDistT = true;
pDrawingProperty->DistT = m_oBufferedStream.GetDouble();
pDrawingProperty->DistT = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistTEmu == type )
{
pDrawingProperty->bDistT = true;
pDrawingProperty->DistT = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistR == type )
{
pDrawingProperty->bDistR = true;
pDrawingProperty->DistR = m_oBufferedStream.GetDouble();
pDrawingProperty->DistR = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistREmu == type )
{
pDrawingProperty->bDistR = true;
pDrawingProperty->DistR = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::DistB == type )
{
pDrawingProperty->bDistB = true;
pDrawingProperty->DistB = m_oBufferedStream.GetDouble();
pDrawingProperty->DistB = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerImageType2::DistBEmu == type )
{
pDrawingProperty->bDistB = true;
pDrawingProperty->DistB = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerImageType2::LayoutInCell == type )
{
@ -7745,22 +7944,42 @@ public:
if ( c_oSerEffectExtent::Left == type )
{
pDrawingProperty->bEffectExtentL = true;
pDrawingProperty->EffectExtentL = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentL = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::LeftEmu == type )
{
pDrawingProperty->bEffectExtentL = true;
pDrawingProperty->EffectExtentL = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Top == type )
{
pDrawingProperty->bEffectExtentT = true;
pDrawingProperty->EffectExtentT = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentT = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::TopEmu == type )
{
pDrawingProperty->bEffectExtentT = true;
pDrawingProperty->EffectExtentT = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Right == type )
{
pDrawingProperty->bEffectExtentR = true;
pDrawingProperty->EffectExtentR = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentR = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::RightEmu == type )
{
pDrawingProperty->bEffectExtentR = true;
pDrawingProperty->EffectExtentR = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerEffectExtent::Bottom == type )
{
pDrawingProperty->bEffectExtentB = true;
pDrawingProperty->EffectExtentB = m_oBufferedStream.GetDouble();
pDrawingProperty->EffectExtentB = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerEffectExtent::BottomEmu == type )
{
pDrawingProperty->bEffectExtentB = true;
pDrawingProperty->EffectExtentB = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7773,12 +7992,22 @@ public:
if ( c_oSerExtent::Cx == type )
{
pDrawingProperty->bWidth = true;
pDrawingProperty->Width = m_oBufferedStream.GetDouble();
pDrawingProperty->Width = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerExtent::CxEmu == type )
{
pDrawingProperty->bWidth = true;
pDrawingProperty->Width = (__int64)m_oBufferedStream.GetULong();
}
else if ( c_oSerExtent::Cy == type )
{
pDrawingProperty->bHeight = true;
pDrawingProperty->Height = m_oBufferedStream.GetDouble();
pDrawingProperty->Height = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerExtent::CyEmu == type )
{
pDrawingProperty->bHeight = true;
pDrawingProperty->Height = (__int64)m_oBufferedStream.GetULong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7801,7 +8030,12 @@ public:
else if ( c_oSerPosHV::PosOffset == type )
{
pDrawingProperty->bPositionHPosOffset = true;
pDrawingProperty->PositionHPosOffset = m_oBufferedStream.GetDouble();
pDrawingProperty->PositionHPosOffset = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPosHV::PosOffsetEmu == type )
{
pDrawingProperty->bPositionHPosOffset = true;
pDrawingProperty->PositionHPosOffset = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPosHV::PctOffset == type )
{
@ -7829,7 +8063,12 @@ public:
else if ( c_oSerPosHV::PosOffset == type )
{
pDrawingProperty->bPositionVPosOffset = true;
pDrawingProperty->PositionVPosOffset = m_oBufferedStream.GetDouble();
pDrawingProperty->PositionVPosOffset = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPosHV::PosOffsetEmu == type )
{
pDrawingProperty->bPositionVPosOffset = true;
pDrawingProperty->PositionVPosOffset = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPosHV::PctOffset == type )
{
@ -7847,12 +8086,22 @@ public:
if ( c_oSerSimplePos::X == type )
{
pDrawingProperty->bSimplePosX = true;
pDrawingProperty->SimplePosX = m_oBufferedStream.GetDouble();
pDrawingProperty->SimplePosX = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerSimplePos::XEmu == type )
{
pDrawingProperty->bSimplePosX = true;
pDrawingProperty->SimplePosX = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerSimplePos::Y == type )
{
pDrawingProperty->bSimplePosY = true;
pDrawingProperty->SimplePosY = m_oBufferedStream.GetDouble();
pDrawingProperty->SimplePosY = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerSimplePos::YEmu == type )
{
pDrawingProperty->bSimplePosY = true;
pDrawingProperty->SimplePosY = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;
@ -7948,12 +8197,22 @@ public:
if ( c_oSerPoint2D::X == type )
{
pWrapPoint->bX = true;
pWrapPoint->X = m_oBufferedStream.GetDouble();
pWrapPoint->X = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPoint2D::XEmu == type )
{
pWrapPoint->bX = true;
pWrapPoint->X = (__int64)m_oBufferedStream.GetLong();
}
else if ( c_oSerPoint2D::Y == type )
{
pWrapPoint->bY = true;
pWrapPoint->Y = m_oBufferedStream.GetDouble();
pWrapPoint->Y = (__int64)(g_dKoef_mm_to_emu * m_oBufferedStream.GetDouble());
}
else if ( c_oSerPoint2D::YEmu == type )
{
pWrapPoint->bY = true;
pWrapPoint->Y = (__int64)m_oBufferedStream.GetLong();
}
else
res = c_oSerConstants::ReadUnknown;

View File

@ -36,17 +36,6 @@ namespace BinDocxRW
{
const double eps = 0.001;
const int Page_Width = 210;
const int Page_Height = 297;
const int X_Left_Margin = 30; // 3 cm
const int X_Right_Margin = 15; // 1.5 cm
const int Y_Bottom_Margin = 20; // 2 cm
const int Y_Top_Margin = 20; // 2 cm
const double Y_Default_Header = 12.5; // 1.25 cm расстояние от верха страницы до верха верхнего колонтитула
const double Y_Default_Footer = 12.5; // 1.25 cm расстояние от низа страницы до низа нижнего колонтитула
const int shd_Clear = 0;
const int shd_Nil = 1;
@ -311,7 +300,9 @@ extern int g_nCurFormatVersion;
RowBandSize = 15,
ColBandSize = 16,
tblCaption = 17,
tblDescription = 18
tblDescription = 18,
TableIndTwips = 19,
TableCellSpacingTwips = 20
};}
namespace c_oSer_tblpPrType{enum c_oSer_tblpPrType
{
@ -328,7 +319,9 @@ extern int g_nCurFormatVersion;
VertAnchor = 3,
TblpY = 4,
TblpYSpec = 5,
Paddings = 6
Paddings = 6,
TblpXTwips = 7,
TblpYTwips = 8
};}
namespace c_oSerProp_pPrType{enum c_oSerProp_pPrType
{
@ -365,7 +358,14 @@ extern int g_nCurFormatVersion;
numPr_Ins = 32,
pPrChange = 33,
outlineLvl = 34,
Tab_Item_Leader = 35
Tab_Item_Leader = 35,
Ind_LeftTwips = 36,
Ind_RightTwips = 37,
Ind_FirstLineTwips = 38,
Spacing_LineTwips = 39,
Spacing_BeforeTwips = 40,
Spacing_AfterTwips = 41,
Tab_Item_PosTwips = 42
};}
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
{
@ -406,7 +406,9 @@ extern int g_nCurFormatVersion;
Ins = 34,
rPrChange = 35,
MoveFrom = 36,
MoveTo = 37
MoveTo = 37,
SpacingTwips = 38,
PositionHps = 39
};}
namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType
{
@ -427,7 +429,9 @@ extern int g_nCurFormatVersion;
TableHeader = 14,
Del = 15,
Ins = 16,
trPrChange = 17
trPrChange = 17,
TableCellSpacingTwips = 18,
Height_ValueTwips = 19
};}
namespace c_oSerProp_cellPrType{enum c_oSerProp_cellPrType
{
@ -517,7 +521,8 @@ extern int g_nCurFormatVersion;
tblGridChange = 9,
Sdt = 10,
BookmarkStart = 11,
BookmarkEnd = 12
BookmarkEnd = 12,
tblGrid_ItemTwips = 13
};}
namespace c_oSerRunType{enum c_oSerRunType
{
@ -607,26 +612,37 @@ extern int g_nCurFormatVersion;
SizeRelV = 28,
Embedded = 29,
GraphicFramePr = 30,
DocPr = 31
DocPr = 31,
DistBEmu = 32,
DistLEmu = 33,
DistREmu = 34,
DistTEmu = 35
};}
namespace c_oSerEffectExtent{enum c_oSerEffectExtent
{
Left = 0,
Top = 1,
Right = 2,
Bottom = 3
Bottom = 3,
LeftEmu = 4,
TopEmu = 5,
RightEmu = 6,
BottomEmu = 7
};}
namespace c_oSerExtent{enum c_oSerExtent
{
Cx = 0,
Cy = 1
Cy = 1,
CxEmu = 2,
CyEmu = 3
};}
namespace c_oSerPosHV{enum c_oSerPosHV
{
RelativeFrom = 0,
Align = 1,
PosOffset = 2,
PctOffset = 3
PctOffset = 3,
PosOffsetEmu = 4
};}
namespace c_oSerSizeRelHV{enum c_oSerSizeRelHV
{
@ -636,7 +652,9 @@ extern int g_nCurFormatVersion;
namespace c_oSerSimplePos{enum c_oSerSimplePos
{
X = 0,
Y = 1
Y = 1,
XEmu = 2,
YEmu = 3
};}
namespace c_oSerWrapSquare{enum c_oSerWrapSquare
{
@ -645,20 +663,28 @@ extern int g_nCurFormatVersion;
DistR = 2,
DistB = 3,
WrapText = 4,
EffectExtent = 5
EffectExtent = 5,
DistLEmu = 6,
DistTEmu = 7,
DistREmu = 8,
DistBEmu = 9
};}
namespace c_oSerWrapThroughTight{enum c_oSerWrapThroughTight
{
DistL = 0,
DistR = 1,
WrapText = 2,
WrapPolygon = 3
WrapPolygon = 3,
DistLEmu = 4,
DistREmu = 5
};}
namespace c_oSerWrapTopBottom{enum c_oSerWrapTopBottom
{
DistT = 0,
DistB = 1,
EffectExtent = 2
EffectExtent = 2,
DistTEmu = 3,
DistBEmu = 4
};}
namespace c_oSerWrapPolygon{enum c_oSerWrapPolygon
{
@ -670,7 +696,9 @@ extern int g_nCurFormatVersion;
namespace c_oSerPoint2D{enum c_oSerPoint2D
{
X = 0,
Y = 1
Y = 1,
XEmu = 2,
YEmu = 3
};}
namespace c_oSerBorderType{enum c_oSerBorderType
{
@ -678,7 +706,9 @@ extern int g_nCurFormatVersion;
Space = 1,
Size = 2,
Value = 3,
ColorTheme = 4
ColorTheme = 4,
SpacePoint = 5,
Size8Point = 6
};}
namespace c_oSerShdType{enum c_oSerShdType
{
@ -691,7 +721,11 @@ extern int g_nCurFormatVersion;
left = 0,
top = 1,
right = 2,
bottom = 3
bottom = 3,
leftTwips = 4,
topTwips = 5,
rightTwips = 6,
bottomTwips = 7
};}
namespace c_oSerMarginsType{enum c_oSerMarginsType
{
@ -725,7 +759,9 @@ extern int g_nCurFormatVersion;
{
W = 0,
H = 1,
Orientation = 2
Orientation = 2,
WTwips = 3,
HTwips = 4
};}
namespace c_oSer_pgMarType{enum c_oSer_pgMarType
{
@ -734,7 +770,13 @@ extern int g_nCurFormatVersion;
Right = 2,
Bottom = 3,
Header = 4,
Footer = 5
Footer = 5,
LeftTwips = 6,
TopTwips = 7,
RightTwips = 8,
BottomTwips = 9,
HeaderTwips = 10,
FooterTwips = 11
};}
namespace c_oSer_ColorType{enum c_oSer_ColorType
{
@ -765,7 +807,8 @@ extern int g_nCurFormatVersion;
EndnotePr = 5,
SdtGlobalColor = 6,
SdtGlobalShowHighlight = 7,
Compat = 8
Compat = 8,
DefaultTabStopTwips = 9
};}
namespace c_oSer_MathPrType{enum c_oSer_SettingsType
{
@ -860,7 +903,8 @@ extern int g_nCurFormatVersion;
namespace c_oSer_OMathBottomNodesValType{enum c_oSer_OMathBottomNodesValType
{
Val = 0,
AlnAt = 1
AlnAt = 1,
ValTwips = 2
};}
namespace c_oSer_OMathContentType{enum c_oSer_OMathContentType
{

View File

@ -148,15 +148,15 @@ namespace BinDocxRW
WriteThemeColor(c_oSerBorderType::ColorTheme, border.m_oColor, border.m_oThemeColor, border.m_oThemeTint, border.m_oThemeShade);
if(border.m_oSpace.IsInit())
{
m_oStream.WriteBYTE(c_oSerBorderType::Space);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(border.m_oSpace->ToMM());
m_oStream.WriteBYTE(c_oSerBorderType::SpacePoint);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(border.m_oSpace->GetValue());
}
if(border.m_oSz.IsInit())
{
m_oStream.WriteBYTE(c_oSerBorderType::Size);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(border.m_oSz->ToMM());
m_oStream.WriteBYTE(c_oSerBorderType::Size8Point);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(border.m_oSz->GetValue());
}
//Val
m_oStream.WriteBYTE(c_oSerBorderType::Value);
@ -315,85 +315,51 @@ namespace BinDocxRW
void WriteShd(const ComplexTypes::Word::CShading& Shd)
{
//Type
if(false != Shd.m_oVal.IsInit())
if (false != Shd.m_oVal.IsInit())
{
m_oStream.WriteBYTE(c_oSerShdType::Value);
m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
switch(Shd.m_oVal.get().GetValue())
{
case SimpleTypes::shdNil: m_oStream.WriteBYTE(shd_Nil);break;
default: m_oStream.WriteBYTE(shd_Clear);break;
}
m_oStream.WriteBYTE(Shd.m_oVal.get().GetValue()); //Misalignment-footer.doc
}
//Value
if(false != Shd.m_oFill.IsInit())
if (false != Shd.m_oFill.IsInit())
WriteColor(c_oSerShdType::Color, Shd.m_oFill.get());
else if (false != Shd.m_oColor.IsInit())
WriteColor(c_oSerShdType::Color, Shd.m_oColor.get());
WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade);
}
void WriteDistance(const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistL,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistT,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistR,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistB)
{
//left
if(false != m_oDistL.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::left);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistL.get().ToMM());
}
//top
if(false != m_oDistT.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::top);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistT.get().ToMM());
}
//Right
if(false != m_oDistR.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::right);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistR.get().ToMM());
}
//bottom
if(false != m_oDistB.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::bottom);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(m_oDistB.get().ToMM());
}
}
void WritePaddings(const nullable<SimpleTypes::CTwipsMeasure>& left, const nullable<SimpleTypes::CTwipsMeasure>& top,
const nullable<SimpleTypes::CTwipsMeasure>& right, const nullable<SimpleTypes::CTwipsMeasure>& bottom)
{
//left
if(left.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::left);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(left.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::leftTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(left->ToTwips());
}
//top
if(top.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::top);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(top.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::topTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(top->ToTwips());
}
//Right
if(right.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::right);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(right.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::rightTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(right->ToTwips());
}
//bottom
if(bottom.IsInit())
{
m_oStream.WriteBYTE(c_oSerPaddingType::bottom);
m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oStream.WriteDouble(bottom.get().ToMm());
m_oStream.WriteBYTE(c_oSerPaddingType::bottomTwips);
m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oStream.WriteLONG(bottom->ToTwips());
}
}
void WriteFont(std::wstring& sFontName, BYTE bType, DocWrapper::FontProcessor& m_oFontProcessor)
@ -701,9 +667,9 @@ namespace BinDocxRW
//Spacing
if(false != rPr->m_oSpacing.IsInit() && false != rPr->m_oSpacing->m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::Spacing);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(rPr->m_oSpacing->m_oVal->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::SpacingTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(rPr->m_oSpacing->m_oVal->ToTwips());
}
//DStrikeout
if(false != rPr->m_oDStrike.IsInit())
@ -729,9 +695,9 @@ namespace BinDocxRW
//Position
if(false != rPr->m_oPosition.IsInit() && false != rPr->m_oPosition->m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::Position);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(rPr->m_oPosition->m_oVal->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rPrType::PositionHps);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(rPr->m_oPosition->m_oVal->ToHps());
}
//BoldCs
if(rPr->m_oBoldCs.IsInit())
@ -1066,29 +1032,29 @@ namespace BinDocxRW
//Left
if(false != Ind.m_oStart.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_Left);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Ind.m_oStart.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_LeftTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Ind.m_oStart.get().ToTwips());
}
//Right
if(false != Ind.m_oEnd.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_Right);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Ind.m_oEnd.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_RightTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Ind.m_oEnd.get().ToTwips());
}
//FirstLine
if(false != Ind.m_oFirstLine.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLine);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Ind.m_oFirstLine.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLineTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Ind.m_oFirstLine.get().ToTwips());
}
else if(false != Ind.m_oHanging.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLine);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble( -1 * Ind.m_oHanging.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Ind_FirstLineTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG( -1 * Ind.m_oHanging.get().ToTwips());
}
}
void WriteSpacing(const ComplexTypes::Word::CSpacing& Spacing)
@ -1101,24 +1067,9 @@ namespace BinDocxRW
//Line
if(false != Spacing.m_oLine.IsInit())
{
const SimpleTypes::CSignedTwipsMeasure& oLine = Spacing.m_oLine.get();
double dLineMm = oLine.ToMm();
if(dLineMm < 0)
{
dLineMm = -dLineMm;
eLineSpacingRule = SimpleTypes::linespacingruleExact;
}
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_Line);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
if(SimpleTypes::linespacingruleAuto == eLineSpacingRule)
{
SimpleTypes::CSignedTwipsMeasure oTmp;oTmp.FromPoints(12);//240 twips
m_oBcw.m_oStream.WriteDouble(dLineMm / oTmp.ToMm());
}
else
{
m_oBcw.m_oStream.WriteDouble(dLineMm);
}
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_LineTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Spacing.m_oLine->ToTwips());
//Write LineRule
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_LineRule);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
@ -1138,9 +1089,9 @@ namespace BinDocxRW
}
if(false != Spacing.m_oBefore.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_Before);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Spacing.m_oBefore.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_BeforeTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Spacing.m_oBefore.get().ToTwips());
}
//After
if(Spacing.m_oAfterAutospacing.IsInit())
@ -1151,9 +1102,9 @@ namespace BinDocxRW
}
if(false != Spacing.m_oAfter.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_After);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Spacing.m_oAfter.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Spacing_AfterTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(Spacing.m_oAfter.get().ToTwips());
}
}
void WriteTabs(const OOX::Logic::CTabs& Tab, const nullable<ComplexTypes::Word::CInd>& oInd)
@ -1197,9 +1148,9 @@ namespace BinDocxRW
//pos
if(false != TabItem.m_oPos.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Tab_Item_Pos);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(TabItem.m_oPos.get().ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::Tab_Item_PosTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(TabItem.m_oPos.get().ToTwips());
}
if(false != TabItem.m_oLeader.IsInit())
{
@ -1425,93 +1376,78 @@ namespace BinDocxRW
}
void WritePageSize(OOX::Logic::CSectionProperty* pSectPr)
{
double W = Page_Width;
double H = Page_Height;
BYTE Orientation = orientation_Portrait;
if(NULL != pSectPr && pSectPr->m_oPgSz.IsInit())
{
const ComplexTypes::Word::CPageSz& pSz = pSectPr->m_oPgSz.get();
if(pSz.m_oW.IsInit())
W = pSz.m_oW.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::WTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pSz.m_oW->ToTwips());
}
if(pSz.m_oH.IsInit())
H = pSz.m_oH.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::HTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pSz.m_oH->ToTwips());
}
if(pSz.m_oOrient.IsInit())
{
BYTE Orientation = orientation_Portrait;
switch(pSz.m_oOrient.get().GetValue())
{
case SimpleTypes::pageorientPortrait: Orientation = orientation_Portrait;break;
case SimpleTypes::pageorientLandscape: Orientation = orientation_Landscape;break;
default: break;
}
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::Orientation);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE(Orientation);
}
}
//W
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::W);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(W);
//H
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::H);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(H);
//Orientation
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgSzType::Orientation);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBYTE(Orientation);
}
void WritePageMargin(OOX::Logic::CSectionProperty* pSectPr)
{
double H = Page_Height;
double L = X_Left_Margin;
double T = Y_Top_Margin;
double R = X_Right_Margin;
double B = Y_Bottom_Margin;
double Header = Y_Default_Header;
double Footer = Y_Default_Footer;
if(NULL != pSectPr && pSectPr->m_oPgSz.IsInit() && pSectPr->m_oPgMar.IsInit())
{
const ComplexTypes::Word::CPageSz& pSz = pSectPr->m_oPgSz.get();
if(pSz.m_oH.IsInit())
H = pSz.m_oH.get().ToMm();
const ComplexTypes::Word::CPageMar& pMar = pSectPr->m_oPgMar.get();
if(pMar.m_oLeft.IsInit())
L = pMar.m_oLeft.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::LeftTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oLeft->ToTwips());
}
if(pMar.m_oTop.IsInit())
T = pMar.m_oTop.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::TopTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oTop->ToTwips());
}
if(pMar.m_oRight.IsInit())
R = pMar.m_oRight.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::RightTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oRight->ToTwips());
}
if(pMar.m_oBottom.IsInit())
B = pMar.m_oBottom.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::BottomTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oBottom->ToTwips());
}
if(pMar.m_oHeader.IsInit())
Header = pMar.m_oHeader.get().ToMm();
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::HeaderTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oHeader->ToTwips());
}
if(pMar.m_oFooter.IsInit())
Footer = pMar.m_oFooter.get().ToMm();
}
//Left
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Left);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(L);
//Top
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Top);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(T);
//Right
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Right);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(R);
//Bottom
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Bottom);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(B);
//Header
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Header);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Header);
//Footer
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::Footer);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(Footer);
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_pgMarType::FooterTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pMar.m_oFooter->ToTwips());
}
}
}
void WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr, std::vector<ComplexTypes::Word::CHdrFtrRef*>& aRefs, bool bHdr)
{
@ -1816,11 +1752,8 @@ namespace BinDocxRW
if(tblPr.m_oTblInd->m_oW.IsInit() && false == tblPr.m_oTblInd->m_oW->IsPercent() &&
tblPr.m_oTblInd->m_oType.IsInit() && SimpleTypes::tblwidthDxa == tblPr.m_oTblInd->m_oType->GetValue())
{
SimpleTypes::CPoint oPoint;
oPoint.FromTwips(tblPr.m_oTblInd->m_oW->GetValue());
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableInd);
m_oBcw.m_oStream.WriteDouble(oPoint.ToMm());
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableIndTwips);
m_oBcw.m_oStream.WriteLONG(tblPr.m_oTblInd->m_oW->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
}
@ -1886,11 +1819,8 @@ namespace BinDocxRW
if(cs.m_oW.IsInit() && false == cs.m_oW->IsPercent() &&
cs.m_oType.IsInit() && SimpleTypes::tblwidthDxa == cs.m_oType->GetValue())
{
SimpleTypes::CPoint oPoint;
oPoint.FromTwips(cs.m_oW->GetValue());
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableCellSpacing);
m_oBcw.m_oStream.WriteDouble(oPoint.ToMm() * 2);//Умножаем на 2 из-за разного понимания cellSpacing
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblPrType::TableCellSpacingTwips);
m_oBcw.m_oStream.WriteLONG(cs.m_oW->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
}
@ -1948,9 +1878,9 @@ namespace BinDocxRW
}
if(pr.m_oTblpX.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpX);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pr.m_oTblpX->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpXTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pr.m_oTblpX->ToTwips());
}
if(pr.m_oTblpXSpec.IsInit())
{
@ -1966,9 +1896,9 @@ namespace BinDocxRW
}
if(pr.m_oTblpY.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpY);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pr.m_oTblpY->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_tblpPrType2::TblpYTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pr.m_oTblpY->ToTwips());
}
if(pr.m_oTblpYSpec.IsInit())
{
@ -2035,12 +1965,9 @@ namespace BinDocxRW
if(cs.m_oW.IsInit() && false == cs.m_oW->IsPercent() &&
cs.m_oType.IsInit() && SimpleTypes::tblwidthDxa == cs.m_oType->GetValue())
{
SimpleTypes::CPoint oPoint;
oPoint.FromTwips(cs.m_oW->GetValue());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::TableCellSpacing);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPoint.ToMm() * 2);//Умножаем на 2 из-за разного понимания cellSpacing
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::TableCellSpacingTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(cs.m_oW->GetValue());
}
}
//Height
@ -2133,9 +2060,9 @@ namespace BinDocxRW
//Value
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::Height_Value);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(rowHeight.m_oVal->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_rowPrType::Height_ValueTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(rowHeight.m_oVal->ToTwips());
}
}
void WriteW(int nType, const ComplexTypes::Word::CTblWidth& tableW, bool bWrite2 = false)
@ -6141,27 +6068,28 @@ namespace BinDocxRW
}
if(pAnchor.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistL->GetValue());
}
if(pAnchor.m_oDistT.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistT);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistT->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistTEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistT->GetValue());
}
if(pAnchor.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistR->GetValue());
}
if(pAnchor.m_oDistB.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistB);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pAnchor.m_oDistB->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::DistBEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)pAnchor.m_oDistB->GetValue());
}
if(pAnchor.m_oHidden.IsInit())
{
@ -6380,34 +6308,39 @@ namespace BinDocxRW
}
void WriteEffectExtent(const OOX::Drawing::CEffectExtent& oEffectExtent)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Left);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oL.ToMm());
int nCurPos = 0;
//document is corrupted if the value is greater INT32
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::LeftEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oL.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Top);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oT.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::TopEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oT.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Right);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oR.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::RightEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oR.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::Bottom);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oEffectExtent.m_oB.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerEffectExtent::BottomEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oEffectExtent.m_oB.ToEmu());
}
void WriteExtent(const ComplexTypes::Drawing::CPositiveSize2D& oExtent)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::Cx);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oExtent.m_oCx.ToMM());
int nCurPos = 0;
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::CxEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oExtent.m_oCx.GetValue());
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::Cy);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oExtent.m_oCy.ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerExtent::CyEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oExtent.m_oCy.GetValue());
}
void WritePositionH(const OOX::Drawing::CPosH& oPosH)
{
int nCurPos = 0;
if(oPosH.m_oRelativeFrom.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::RelativeFrom);
@ -6422,9 +6355,10 @@ namespace BinDocxRW
}
if(oPosH.m_oPosOffset.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffset);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPosH.m_oPosOffset->ToMM());
//document is corrupted if the value is greater INT32
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffsetEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPosH.m_oPosOffset->GetValue());
}
if(oPosH.m_oPctOffset.IsInit())
{
@ -6435,6 +6369,7 @@ namespace BinDocxRW
}
void WritePositionV(const OOX::Drawing::CPosV& oPosV)
{
int nCurPos = 0;
if(oPosV.m_oRelativeFrom.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::RelativeFrom);
@ -6449,9 +6384,9 @@ namespace BinDocxRW
}
if(oPosV.m_oPosOffset.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffset);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPosV.m_oPosOffset->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerPosHV::PosOffsetEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPosV.m_oPosOffset->GetValue());
}
if(oPosV.m_oPctOffset.IsInit())
{
@ -6492,40 +6427,43 @@ namespace BinDocxRW
}
void WriteSimplePos(const ComplexTypes::Drawing::CPoint2D& oSimplePos)
{
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::X);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oSimplePos.m_oX.ToMm());
int nCurPos = 0;
//document is corrupted if the value is greater INT32
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::XEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oSimplePos.m_oX.GetValue());
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::Y);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oSimplePos.m_oY.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerSimplePos::YEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oSimplePos.m_oY.GetValue());
}
void WriteWrapSquare(const OOX::Drawing::CWrapSquare& oWrapSquare)
{
int nCurPos = 0;
if(oWrapSquare.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistL->GetValue());
}
if(oWrapSquare.m_oDistT.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistT);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistT->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistTEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistT->GetValue());
}
if(oWrapSquare.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistR->GetValue());
}
if(oWrapSquare.m_oDistB.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistB);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapSquare.m_oDistB->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapSquare::DistBEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapSquare.m_oDistB->GetValue());
}
if(oWrapSquare.m_oWrapText.IsInit())
{
@ -6548,15 +6486,16 @@ namespace BinDocxRW
int nCurPos = 0;
if(oWrapThrough.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapThrough.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapThrough.m_oDistL->GetValue());
}
if(oWrapThrough.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapThrough.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapThrough.m_oDistR->GetValue());
}
if(oWrapThrough.m_oWrapText.IsInit())
{
@ -6579,15 +6518,16 @@ namespace BinDocxRW
int nCurPos = 0;
if(oWrapTight.m_oDistL.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistL);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTight.m_oDistL->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistLEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTight.m_oDistL->GetValue());
}
if(oWrapTight.m_oDistR.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistR);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTight.m_oDistR->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapThroughTight::DistREmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTight.m_oDistR->GetValue());
}
if(oWrapTight.m_oWrapText.IsInit())
{
@ -6610,23 +6550,23 @@ namespace BinDocxRW
int nCurPos = 0;
if(oWrapTopBottom.m_oDistT.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistT);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTopBottom.m_oDistT->ToMM());
//document is corrupted if the value is greater UINT32
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistTEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTopBottom.m_oDistT->GetValue());
}
if(oWrapTopBottom.m_oDistB.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistB);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oWrapTopBottom.m_oDistB->ToMM());
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::DistBEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG((_UINT32)oWrapTopBottom.m_oDistB->GetValue());
}
if(oWrapTopBottom.m_oEffectExtent.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapTopBottom::EffectExtent);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WriteEffectExtent(oWrapTopBottom.m_oEffectExtent.get());
WriteEffectExtent(oWrapTopBottom.m_oEffectExtent.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
@ -6643,9 +6583,8 @@ namespace BinDocxRW
{
m_oBcw.m_oStream.WriteBYTE(c_oSerWrapPolygon::Start);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WritePoint2D(oWrapPath.m_oStart.get());
WritePoint2D(oWrapPath.m_oStart.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(oWrapPath.m_arrLineTo.size() > 0)
@ -6672,14 +6611,15 @@ namespace BinDocxRW
}
void WritePoint2D(const ComplexTypes::Drawing::CPoint2D& oPoint2D)
{
//document is corrupted if the value is greater INT32
int nCurPos = 0;
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::X);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPoint2D.m_oX.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::XEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPoint2D.m_oX.ToEmu());
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::Y);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(oPoint2D.m_oY.ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerPoint2D::YEmu);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG((_INT32)oPoint2D.m_oY.ToEmu());
}
void WriteDocTable(OOX::Logic::CTbl* tbl)
{
@ -6880,9 +6820,9 @@ namespace BinDocxRW
const ComplexTypes::Word::CTblGridCol& item = *grid.m_arrGridCol[i];
if(item.m_oW.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerDocTableType::tblGrid_Item);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(item.m_oW->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSerDocTableType::tblGrid_ItemTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(item.m_oW->ToTwips());
}
}
if(grid.m_oTblGridChange.IsInit())
@ -7557,8 +7497,8 @@ namespace BinDocxRW
}
if(oSettings.m_oDefaultTabStop.IsInit() && oSettings.m_oDefaultTabStop->m_oVal.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::DefaultTabStop);
m_oBcw.m_oStream.WriteDouble(oSettings.m_oDefaultTabStop->m_oVal->ToMm());
nCurPos = m_oBcw.WriteItemStart(c_oSer_SettingsType::DefaultTabStopTwips);
m_oBcw.m_oStream.WriteLONG(oSettings.m_oDefaultTabStop->m_oVal->ToTwips());
m_oBcw.WriteItemEnd(nCurPos);
}
if(oSettings.m_oMathPr.IsInit())
@ -7675,9 +7615,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::InterSp);
if (pInterSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pInterSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pInterSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7701,9 +7641,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::IntraSp);
if (pIntraSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pIntraSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pIntraSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7714,9 +7654,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::LMargin);
if (pLMargin->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pLMargin->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pLMargin->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7753,9 +7693,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::PostSp);
if (pPostSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pPostSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pPostSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7766,9 +7706,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::PreSp);
if (pPreSp->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pPreSp->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pPreSp->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7779,9 +7719,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::RMargin);
if (pRMargin->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pRMargin->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pRMargin->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;
@ -7805,9 +7745,9 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemStart(c_oSer_MathPrType::WrapIndent);
if (pWrapIndent->m_val.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Double);
m_oBcw.m_oStream.WriteDouble(pWrapIndent->m_val->ToMm());
m_oBcw.m_oStream.WriteBYTE(c_oSer_OMathBottomNodesValType::ValTwips);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pWrapIndent->m_val->ToTwips());
}
m_oBcw.WriteItemEnd(nCurPos);
break;

View File

@ -53,6 +53,8 @@
69F181AF1C77274E00B2952B /* FileDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F181AD1C77274E00B2952B /* FileDownloader.h */; };
8A404FD3208A01AF00F2D5CF /* FileDownloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A404FD2208A01AF00F2D5CF /* FileDownloader.cpp */; };
8A404FD5208A01CE00F2D5CF /* FileDownloader_private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */; };
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */; };
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -103,6 +105,8 @@
69F181AD1C77274E00B2952B /* FileDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader.h; path = ../../../Common/FileDownloader/FileDownloader.h; sourceTree = "<group>"; };
8A404FD2208A01AF00F2D5CF /* FileDownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileDownloader.cpp; path = ../../../Common/FileDownloader/FileDownloader.cpp; sourceTree = "<group>"; };
8A404FD4208A01CE00F2D5CF /* FileDownloader_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileDownloader_private.h; path = ../../../Common/FileDownloader/FileDownloader_private.h; sourceTree = "<group>"; };
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustormXmlWriter.cpp; sourceTree = "<group>"; };
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustormXmlWriter.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -149,6 +153,8 @@
children = (
17E17EEB1AC4544900BEA2EA /* ChartWriter.h */,
17E17EEC1AC4544900BEA2EA /* CommentsWriter.h */,
8AB24BFB213004E300E80DDD /* CustormXmlWriter.cpp */,
8AB24BFC213004E300E80DDD /* CustormXmlWriter.h */,
17A765271B0F3DC30046BC0B /* DefaultThemeWriter.h */,
17E17EF01AC4544900BEA2EA /* DocumentRelsWriter.h */,
17E17EF11AC4544900BEA2EA /* DocumentWriter.h */,
@ -292,6 +298,7 @@
17C1FEBC1ACC42C4006B99B3 /* DocxSerializer.h in Headers */,
17C1FEBD1ACC42C4006B99B3 /* FileWriter.h in Headers */,
17C1FEBE1ACC42C4006B99B3 /* CSVWriter.h in Headers */,
8AB24BFE213004E400E80DDD /* CustormXmlWriter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -346,6 +353,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8AB24BFD213004E400E80DDD /* CustormXmlWriter.cpp in Sources */,
17C1FE961ACC42C4006B99B3 /* Common.cpp in Sources */,
17C1FE971ACC42C4006B99B3 /* ChartFromToBinary.cpp in Sources */,
17C1FE981ACC42C4006B99B3 /* CSVReader.cpp in Sources */,
@ -375,18 +383,11 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
NODOCX,
_USE_XMLLITE_READER_,
USE_LITE_READER,
USE_ATL_CSTRING,
USE_AVSOFFICESTUDIO_XMLUTILS,
SOLUTION_ASCOFFICEDOCXFILE2,
_USE_LIBXML2_READER_,
LIBXML_READER_ENABLED,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
@ -414,18 +415,11 @@
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,
NODOCX,
_USE_XMLLITE_READER_,
USE_LITE_READER,
USE_ATL_CSTRING,
USE_AVSOFFICESTUDIO_XMLUTILS,
SOLUTION_ASCOFFICEDOCXFILE2,
_USE_LIBXML2_READER_,
LIBXML_READER_ENABLED,
DONT_WRITE_EMBEDDED_FONTS,
MAC,
unix,
_IOS,
DONT_WRITE_EMBEDDED_FONTS,
_XCODE,
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,12 +33,7 @@
#include "oox_rels.h"
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
namespace NSFonts
{
class IApplicationFonts;
}
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
namespace cpdoccore {
namespace oox {
@ -46,8 +41,20 @@ namespace oox {
class mediaitems
{
public:
mediaitems(const std::wstring & odfPacket);
virtual ~mediaitems();
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
count_charts = 0;
count_shape = 0;
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
count_audio = 0;
count_video = 0;
count_slide = 0;
count_activeX = 0;
count_control = 0;
}
struct item
{
@ -80,9 +87,6 @@ public:
size_t count_activeX;
size_t count_control;
void set_font_directory(std::wstring pathFonts);
NSFonts::IApplicationFonts *applicationFonts() {return applicationFonts_;}
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
@ -113,9 +117,9 @@ public:
}
static RelsType detectMediaType(const std::wstring & fileName)
{
size_t pos = fileName.rfind(L".");
int pos = fileName.rfind(L".");
std::wstring sExt = (pos != std::wstring::npos ? fileName.substr(pos + 1) : L"");
std::wstring sExt = (pos >=0 ? fileName.substr(pos + 1) : L"");
if (sExt.empty()) return typeMedia;
@ -143,7 +147,6 @@ private:
items_array items_;
std::wstring odf_packet_;
NSFonts::IApplicationFonts *applicationFonts_;
};
}

View File

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

View File

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

View File

@ -37,9 +37,9 @@
namespace cpdoccore {
namespace oox {
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true), bGrayscale(false)
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
{
memset(cropRect, 0, sizeof(double)*4);
memset(cropRect,0,sizeof(double)*4);
}
oox_bitmap_fill_ptr oox_bitmap_fill::create(){return boost::make_shared<oox_bitmap_fill>();}
@ -189,19 +189,7 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons
{
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
}
}
if (val.bitmap->bGrayscale)
{
CP_XML_NODE(ns + L":grayscl");
}
if (val.bitmap->luminance || val.bitmap->contrast)
{
CP_XML_NODE(ns + L":lum")
{
if (val.bitmap->luminance) CP_XML_ATTR2(L"bright", (int)(*val.bitmap->luminance * 1000));
if (val.bitmap->contrast) CP_XML_ATTR2(L"contrast", (int)(*val.bitmap->contrast * 1000));
}
}
}
}
if (val.bitmap->bCrop)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -302,24 +302,12 @@ void xlsx_pivots_context::Impl::calc_headers()
std::map<size_t, size_t>::iterator pFind;
//current_.bAxisCol = false;
//current_.bAxisRow = false;
size_t min_col = 0xffffff, min_row = 0xffffff;
size_t prev_col, prev_row;
for (size_t i = 0; i < current_.headers.size(); i++)//("F18","F19","F23","G21","H21")
{
size_t row = 0, col = 0;
oox::getCellAddressInv(current_.headers[i], col, row);
//if (i > 0)
//{
// if (col != prev_col)current_.bAxisCol = true;
// if (row != prev_row)current_.bAxisRow = true;
//}
prev_col = col;
prev_row = row;
if (col < min_col) min_col = col;
if (row < min_row) min_row = row;
@ -590,17 +578,11 @@ void xlsx_pivots_context::Impl::sort_fields()
i--;
}
}
bool data_col_repeate = false;
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow)) && (current_.grand_total == 1 || current_.grand_total == 3 || current_.data_on_row))/* && bShowEmptyRow*/
{
current_.row_fields.push_back(-2);
data_col_repeate = true;
}
if (!data_col_repeate && (bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol)) && (current_.grand_total == 1 || current_.grand_total == 2 || current_.data_fields.size() > 1 ))/* && bShowEmptyCol*/ ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
if ((bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol))/* && bShowEmptyCol*/) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
current_.col_fields.push_back(-2);
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))/* && bShowEmptyRow*/)
current_.row_fields.push_back(-2);
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{

View File

@ -44,7 +44,6 @@
#include "../formulasconvert/formulasconvert.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
namespace cpdoccore {
namespace oox {
@ -82,8 +81,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
std::wstring ref1, ref2;
size_t col_1, row_1, col_2, row_2;
size_t pos = ref.find(L":");
if (pos != std::wstring::npos)
int pos = ref.find(L":");
if (pos >= 0)
{
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
@ -135,29 +134,10 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false),
bEndTable(false),
bRTL(false),
bHidden(false),
bProtected(false)
{
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = context_->root()->odf_context().styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
if ((tableStyle) && (tableStyle->content()))
table_prop = tableStyle->content()->get_style_table_properties();
bEndTable(false)
if (table_prop)
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_)
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
bRTL = true;
}
if ((table_prop->content().table_display_) && (false == table_prop->content().table_display_))
{
bHidden = true;
}
}
{
memset(&group_row_,0,sizeof(_group_row));
}
void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
@ -169,31 +149,6 @@ void xlsx_table_state::start_column(unsigned int repeated, const std::wstring &
columns_.push_back(repeated);
}
void xlsx_table_state::set_rtl(bool val)
{
bRTL = val;
}
void xlsx_table_state::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
bProtected = val;
protect_key = key;
size_t pos = algorithm.find(L"#");
if (pos != std::wstring::npos)
{
protect_key_algorithm = algorithm.substr(pos + 1);
}
//test
//CRYPT::odfWriteProtect protect;
//protect.SetProtectKey(DecodeBase64(protect_key));
//protect.SetPassword(L"123");
//bool res = protect.Verify();
}
unsigned int xlsx_table_state::columns_count() const
{
return columns_count_;
@ -269,10 +224,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
xlsx_merge_cells_.add_merge(current_table_column_, current_table_row_, columnsSpanned, rowsSpanned);
}
//if ( current_columns_spaned() > 0 )
//{
// _CP_LOG << L"[warning] current columns spanned > 0\n";
//}
if ( current_columns_spaned() > 0 )
{
_CP_LOG << L"[warning] current columns spanned > 0\n";
}
columns_spanned_num_ = static_cast<int>(columnsSpanned);
@ -292,10 +247,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
}
else
{
//if (rows_spanned_[current_table_column_].num() > 0)
//{
// _CP_LOG << L"[warning] current rows spanned > 0\n";
//}
if (rows_spanned_[current_table_column_].num() > 0)
{
_CP_LOG << L"[warning] current rows spanned > 0\n";
}
rows_spanned_[current_table_column_].num(static_cast<unsigned int>(rowsSpanned));
rows_spanned_[current_table_column_].column_spanned(static_cast<unsigned int>(columnsSpanned));
for (size_t i = 0; i <= columns_spanned_num_; ++i)
@ -418,21 +373,6 @@ void xlsx_table_state::serialize_background (std::wostream & strm)
}
}
}
void xlsx_table_state::serialize_protection (std::wostream & strm)
{
if (!bProtected) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"sheetProtection")
{
CP_XML_ATTR(L"sheet", 1);
CP_XML_ATTR(L"objects", 1);
CP_XML_ATTR(L"scenarios", 1);
//convert protection odf->ooxml impossible without password !!!
}
}
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
@ -481,9 +421,6 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
CP_XML_ATTR(L"workbookViewId", 0);
if (bRTL)
CP_XML_ATTR(L"rightToLeft", 1);
std::wstring s_col, s_row;
for (int i = 0; i < odfContext.Settings().get_table_view_count(0, tableName_); i++)
{
@ -521,6 +458,7 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
}
}
// -showRowColHeaders
// -rightToLeft
}
double default_height = (2 * context_->getMaxDigitSize().second * 72. / 96. * 100.) /100.;//in point size.

View File

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

View File

@ -60,20 +60,23 @@ xlsx_table_state_ptr xlsx_table_context::state()
return xlsx_table_state_ptr();
}
bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref)
void xlsx_table_context::start_database_range(std::wstring tableName, std::wstring ref)
{
formulasconvert::odf2oox_converter convert;
std::wstring oox_ref = convert.convert_named_ref(ref);
ref = convert.convert_named_ref(ref);
std::wstring ref1, ref2;
size_t pos = oox_ref.find(L":");
int pos = ref.find(L":");
std::wstring xlsx_table_name;
if (pos != std::wstring::npos)
if (pos >= 0)
{
ref1 = oox_ref.substr(0, pos );
ref2 = oox_ref.substr(pos + 1);
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
xlsx_data_ranges_.back()->table_name = tableName;
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
pos = ref1.find(L"!");
if (pos > 0)
@ -85,33 +88,23 @@ bool xlsx_table_context::start_database_range(const std::wstring & name, const s
pos = ref2.find(L"!");
if (pos > 0) ref2 = ref2.substr(pos + 1);
size_t col1, col2, row1, row2;
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
getCellAddressInv(ref1, col1, row1);
getCellAddressInv(ref2, col2, row2);
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2)
{//check range in pivots
xlsx_data_ranges_.back()->bTablePart = false;
}
xlsx_data_ranges_.back()->name = name;
xlsx_data_ranges_.back()->table_name = xlsx_table_name;
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col1, row1);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col2, row2);
xlsx_data_ranges_.back()->set_header(row1, col1, col2);
size_t col, row;
getCellAddressInv(ref1, col, row);
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col,row);
getCellAddressInv(ref2, col, row);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col,row);
}
if (!xlsx_table_name.empty())
{
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
xlsx_data_ranges_map_.insert(std::pair<std::wstring, int> (xlsx_table_name, xlsx_data_ranges_.size() - 1));
}
return true;
}
void xlsx_table_context::set_database_orientation (bool val)
{
@ -135,63 +128,6 @@ void xlsx_table_context::end_database_range()
{
}
void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
{
if (index < 0 || index > xlsx_data_ranges_.size()) return;
size_t col = state()->current_column();
size_t row = state()->current_row();
xlsx_data_ranges_[index]->set_header_value(col, row, value);
}
void xlsx_table_context::check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref)
{
std::wstring ref1, ref2;
size_t col_1, row_1, col_2, row_2;
size_t pos = ref.find(L":");
if (pos != std::wstring::npos)
{
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
}
getCellAddressInv(ref1, col_1, row_1);
getCellAddressInv(ref2, col_2, row_2);
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
{
if (xlsx_data_ranges_[i]->table_name != table_name) continue;
//if ( xlsx_data_ranges_[i]->cell_start.second < row_2 || xlsx_data_ranges_[i]->cell_end.second > row_1
// || xlsx_data_ranges_[i]->cell_end.first < col_1 || xlsx_data_ranges_[i]->cell_start.first > col_2 )
if (((col_1 <= xlsx_data_ranges_[i]->cell_start.first && xlsx_data_ranges_[i]->cell_start.first <= col_2) ||
(xlsx_data_ranges_[i]->cell_start.first <= col_1 && col_1 <= xlsx_data_ranges_[i]->cell_end.first))
&&
(( row_1 <= xlsx_data_ranges_[i]->cell_start.second && xlsx_data_ranges_[i]->cell_start.second <= row_2) ||
(xlsx_data_ranges_[i]->cell_start.second <= row_1 && row_1 <= xlsx_data_ranges_[i]->cell_end.second )))
{
xlsx_data_ranges_[i]->bTablePart = false;
}
}
}
int xlsx_table_context::in_database_range()
{
int col = state()->current_column();
int row = state()->current_row();
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
{
if (xlsx_data_ranges_[i]->table_name != state()->get_table_name()) continue;
if (/*(xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)&& */
xlsx_data_ranges_[i]->in_header(col, row))
{
return (int)i;
}
}
return -1;
}
void xlsx_table_context::add_database_sort(int field_number, int order)
{
xlsx_data_ranges_.back()->bySort.push_back(std::pair<int, bool>(field_number, order == 1 ? false : true ));
@ -204,19 +140,17 @@ xlsx_text_context_(textContext)
{
}
void xlsx_table_context::start_table(const std::wstring & tableName, const std::wstring & tableStyleName, int id)
void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName, int id)
{
xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName, id);
xlsx_table_states_.push_back( state);
}
void xlsx_table_context::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
xlsx_table_states_.back()->set_protection(val, key, algorithm);
}
void xlsx_table_context::end_table()
{
//xlsx_table_states_.pop_back();
}
}
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
{
state()->start_cell(columnsSpanned, rowsSpanned);
@ -321,122 +255,9 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
}
}
void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels & Rels)
{
if (xlsx_data_ranges_.empty()) return;
std::pair<std::multimap<std::wstring, int>::iterator, std::multimap<std::wstring, int>::iterator> range;
range = xlsx_data_ranges_map_.equal_range(state()->get_table_name());
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
// из за дебелизма мсофис которому ОБЯЗАТЕЛЬНО нужно прописывать имена колонок таблицы (и они должны быть еще
// прописаны и в самих данных таблицы !!
int i = xlsx_data_ranges_[it->second]->header_values.size() - 1;
for (; i >= 0; i--)
{
if (false == xlsx_data_ranges_[it->second]->header_values[i].empty())
{
break;
}
}
if (i == -1)
{
xlsx_data_ranges_[it->second]->bTablePart = false;
continue;
}
else
{
size_t erase = xlsx_data_ranges_[it->second]->header_values.size() - 1 - i;
if (erase > 0)
{
xlsx_data_ranges_[it->second]->header_values.erase(xlsx_data_ranges_[it->second]->header_values.begin() + i + 1, xlsx_data_ranges_[it->second]->header_values.end());
xlsx_data_ranges_[it->second]->cell_end.first -= erase;
std::wstring ref1 = getCellAddress(xlsx_data_ranges_[it->second]->cell_start.first, xlsx_data_ranges_[it->second]->cell_start.second);
std::wstring ref2 = getCellAddress(xlsx_data_ranges_[it->second]->cell_end.first, xlsx_data_ranges_[it->second]->cell_end.second);
xlsx_data_ranges_[it->second]->ref = ref1 + L":" + ref2;
}
}
//--------------------------------------------------------
size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
std::wstring rId = L"tprtId" + std::to_wstring(id);
std::wstring ref = L"../tables/table" + std::to_wstring(id) + L".xml";
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"tablePart")
{
CP_XML_ATTR(L"r:id", rId);
}
}
Rels.add( relationship(rId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", ref));
//--------------------------------------------------------
std::wstringstream strm;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"table")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"id", id);
CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->name);
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->name);
CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
if (xlsx_data_ranges_[it->second]->withHeader == false &&
xlsx_data_ranges_[it->second]->filter == false)
CP_XML_ATTR(L"headerRowCount", 0);
//CP_XML_ATTR(L"totalsRowCount", 0);
CP_XML_ATTR(L"totalsRowShown", 0);
xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
xlsx_data_ranges_[it->second]->serialize_sort(CP_XML_STREAM());
CP_XML_NODE(L"tableColumns")
{
CP_XML_ATTR(L"count", xlsx_data_ranges_[it->second]->cell_end.first -
xlsx_data_ranges_[it->second]->cell_start.first + 1);
for (int id = 0, i = xlsx_data_ranges_[it->second]->cell_start.first; i <= xlsx_data_ranges_[it->second]->cell_end.first; i++, id++)
{
CP_XML_NODE(L"tableColumn")
{
std::wstring column_name = xlsx_data_ranges_[it->second]->header_values[id];
if (column_name.empty())
{
column_name = L"Column_" + std::to_wstring(id + 1);
}
CP_XML_ATTR(L"id", id + 1);
CP_XML_ATTR(L"name", column_name);
}
}
}
CP_XML_NODE(L"tableStyleInfo")
{
CP_XML_ATTR(L"showFirstColumn", 0);
CP_XML_ATTR(L"showLastColumn", 0);
CP_XML_ATTR(L"showRowStripes", 1);
CP_XML_ATTR(L"showColumnStripes", 0);
}
}
}
xlsx_conversion_context_->add_table_part(strm.str());
}
}
void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
{
if (xlsx_data_ranges_.empty()) return;
@ -452,8 +273,6 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
if (xlsx_data_ranges_[it->second]->filter)
{
if (cell_start.first < 0 || xlsx_data_ranges_[it->second]->cell_start.first < cell_start.first )
@ -479,16 +298,12 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
{
CP_XML_NODE(L"autoFilter")
{
//в автофильтре тока простые диапазоны .. для сложных - tablePart
//в автофильтре тока простые диапазоны .. для сложных нужно выделять tablePart - todooo
CP_XML_ATTR(L"ref", getCellAddress(cell_start.first, cell_start.second) + L":" + getCellAddress(cell_end.first, cell_end.second));
//CP_XML_ATTR(L"ref", ref);
}
}
}
void xlsx_table_context::serialize_protection(std::wostream & _Wostream)
{
return state()->serialize_protection(_Wostream);
}
void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
{
return state()->serialize_conditionalFormatting(_Wostream);

View File

@ -48,8 +48,7 @@ class xlsx_table_context
public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
void start_table(const std::wstring &tableName, const std::wstring & tableStyleName, int id);
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void end_table();
void start_cell(const std::wstring & formula,
@ -83,7 +82,6 @@ public:
unsigned int columns_count();
void serialize_tableParts (std::wostream & _Wostream, rels & Rels);
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
@ -95,7 +93,6 @@ public:
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_data_validation (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();
@ -114,25 +111,23 @@ public:
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
bool start_database_range(const std::wstring &table_name, const std::wstring &ref);
void start_database_range(std::wstring table_name, std::wstring ref);
void set_database_orientation (bool val);
void set_database_header (bool val);
void set_database_filter (bool val);
void add_database_sort (int field_number, int order);
void end_database_range();
int in_database_range();
void set_database_range_value(int index, const std::wstring& value);
void check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref);
void add_database_sort (int field_number, int order);
void end_database_range();
private:
xlsx_conversion_context *xlsx_conversion_context_;
xlsx_text_context &xlsx_text_context_;
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
};

View File

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

View File

@ -34,8 +34,6 @@
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/regex.hpp>
#include <unordered_map>
#include "oox_conversion_context.h"
@ -56,6 +54,11 @@
#include "mediaitems.h"
namespace NSFonts
{
class IApplicationFonts;
}
namespace cpdoccore {
namespace odf_reader
@ -157,12 +160,6 @@ public:
void add_jsaProject (const std::string &content);
void add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props);
//int add_external_link(const std::wstring & external);
void add_table_part(const std::wstring & table) {table_parts_.push_back(table);}
size_t get_table_parts_size() {return table_parts_.size();}
//------------------------------------------------------------------------------------
odf_reader::odf_document * root()
@ -195,9 +192,9 @@ public:
mediaitems & get_mediaitems() { return mediaitems_; }
static std::unordered_map<std::wstring, int> mapExternalLink_;
std::map<std::wstring, int> mapUsedNames_;
private:
void create_new_sheet (std::wstring const & name);
void serialize_bookViews(std::wostream & strm);
void serialize_calcPr (std::wostream & strm);
@ -205,18 +202,19 @@ private:
const odf_reader::office_element *spreadsheet_;
odf_reader::odf_document *odf_document_;
NSFonts::IApplicationFonts *applicationFonts_;
std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_;
std::vector<std::wstring> table_parts_;
std::wstringstream defaultOutput_;
std::pair<float,float> maxDigitSize_;
num_format_context num_format_context_;
size_t default_style_;
mediaitems mediaitems_;
std::multimap<std::wstring, int> mapPivotsTableView_;
std::map<std::wstring, std::wstring> control_props_;
std::map<std::wstring, std::wstring>control_props_;
xlsx_style_manager xlsx_style_;
xlsx_defined_names xlsx_defined_names_;
@ -229,8 +227,6 @@ private:
math_context math_context_;
forms_context forms_context_;
static std::wstring change_external(boost::wsmatch const & what);
};
}

View File

@ -744,9 +744,6 @@ void process_build_object::visit(chart_title& val)
if (val.attlist_.common_draw_position_attlist_.svg_x_)
{
t.pos_x = val.attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
}
if (val.attlist_.common_draw_position_attlist_.svg_y_)
{
t.pos_y = val.attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
}
t.bEnabled = true;
@ -1057,7 +1054,7 @@ void process_build_object::visit(table_table_cell& val)
if (cell_cash.empty())
cell_cash = cell_val;
object_odf_context::_cell cell_= {(size_t)object_odf_context_.current_table_column_, (size_t)object_odf_context_.current_table_row_, cell_cash};
object_odf_context::_cell cell_= {object_odf_context_.current_table_column_, object_odf_context_.current_table_row_, cell_cash};
object_odf_context_.cash_values.push_back(cell_);

View File

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

View File

@ -111,14 +111,6 @@ public:
_CP_OPT(length_or_percent) draw_fill_image_width_;
_CP_OPT(length_or_percent) draw_fill_image_height_;
_CP_OPT(std::wstring) draw_color_mode_;
_CP_OPT(odf_types::percent) draw_contrast_;
_CP_OPT(odf_types::percent) draw_luminance_;
_CP_OPT(odf_types::percent) draw_gamma_;
_CP_OPT(odf_types::percent) draw_red_;
_CP_OPT(odf_types::percent) draw_green_;
_CP_OPT(odf_types::percent) draw_blue_;
};
// common-horizontal-margin-attlist
@ -510,7 +502,7 @@ public:
_CP_OPT(std::wstring) draw_id_;
_CP_OPT(std::wstring) draw_layer_;
_CP_OPT(std::wstring) draw_transform_;
_CP_OPT(unsigned int) draw_z_index_;
_CP_OPT(int) draw_z_index_;
_CP_OPT(std::wstring) drawooo_display_;
};

View File

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

View File

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

View File

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

View File

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

View File

@ -30,6 +30,8 @@
*
*/
#include "draw_frame.h"
#include <ostream>
#include <sstream>
#include <string>
@ -40,8 +42,6 @@
#include <xml/attributes.h>
#include <odf/odf_document.h>
#include "draw_common.h"
#include "serialize_elements.h"
#include "style_graphic_properties.h"
#include "odfcontext.h"
@ -54,7 +54,6 @@
#include "datatypes/borderstyle.h"
#include "../../../OfficeUtils/src/OfficeUtils.h"
#include "../../../Common/OfficeFileFormatChecker.h"
#include "../../../Common/3dParty/pole/pole.h"
namespace cpdoccore {
@ -154,75 +153,6 @@ void draw_g::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_g::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
if (content_.empty()) return;
draw_g *group = dynamic_cast<draw_g*> (content_.back().get());
draw_frame *frame = dynamic_cast<draw_frame*> (content_.back().get());
draw_shape *shape = dynamic_cast<draw_shape*> (content_.back().get());
if (group)
{
int x = 0, y = 0, cx = 0, cy = 0;
if (group->common_draw_attlists_.position_.svg_x_ && group->common_draw_attlists_.position_.svg_y_)
{
x = get_value_emu(group->common_draw_attlists_.position_.svg_x_);
y = get_value_emu(group->common_draw_attlists_.position_.svg_y_);
}
else
{
x = group->position_child_x1;
y = group->position_child_y1;
}
if (group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ &&
group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
{
cx = get_value_emu(group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
cy = get_value_emu(group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
}
else
{
cx = group->position_child_x2 - group->position_child_x1;
cy = group->position_child_y2 - group->position_child_y1;
}
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
}
else if (frame)
{
int x = 0, y = 0, cx = 0, cy = 0;
x = get_value_emu(frame->common_draw_attlists_.position_.svg_x_);
y = get_value_emu(frame->common_draw_attlists_.position_.svg_y_);
cx = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
cy = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
}
else if (shape)
{
int x = 0, y = 0, cx = 0, cy = 0;
x = get_value_emu(shape->common_draw_attlists_.position_.svg_x_);
y = get_value_emu(shape->common_draw_attlists_.position_.svg_y_);
cx = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
cy = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
}
}
std::wostream & draw_g::text_to_stream(std::wostream & _Wostream) const
@ -365,65 +295,50 @@ void draw_object_ole::add_child_element( xml::sax * Reader, const std::wstring &
CP_NOT_APPLICABLE_ELM();
}
void draw_object_ole::detectObject(const std::wstring &fileName, std::wstring &prog, std::wstring &extension, oox::RelsType &rels)
std::wstring draw_object_ole::detectObject(const std::wstring &fileName)
{
extension = L".bin";
POLE::Storage *storage = new POLE::Storage(fileName.c_str());
if ((storage) && (storage->open(false, false) == true))
if (storage == NULL) return L"";
if (storage->open(false, false) == false)
{
rels = oox::typeOleObject;
std::wstring prog;
POLE::Stream* pStream = new POLE::Stream(storage, L"CompObj");
if ((pStream) && (pStream->size() > 28))
{
//skip the CompObjHeader
pStream->seek(28);
int sz_obj = (int)pStream->size() - 28;
std::vector<std::string> str;
while (sz_obj > 0)
{
_UINT32 sz = 0;
pStream->read((unsigned char*)&sz, 4); sz_obj-= 4;
if (sz > sz_obj)
break;
unsigned char *data = new unsigned char[sz];
pStream->read(data, sz);
str.push_back(std::string((char*)data, sz));
delete []data;
sz_obj-= sz;
}
if (!str.empty())
{
prog = std::wstring (str.back().begin(), str.back().end());
}
delete pStream;
}
delete storage;
return L"";
}
else
std::wstring prog;
POLE::Stream* pStream = new POLE::Stream(storage, L"CompObj");
if ((pStream) && (pStream->size() > 28))
{
COfficeFileFormatChecker checker(fileName);
switch(checker.nFileType)
//skip the CompObjHeader
pStream->seek(28);
int sz_obj = (int)pStream->size() - 28;
std::vector<std::string> str;
while (sz_obj > 0)
{
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC: extension = L".doc"; prog = L"Word"; rels = oox::typeOleObject; break;
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX: extension = L".docx"; prog = L"Word"; rels = oox::typeMsObject; break;
_UINT32 sz = 0;
pStream->read((unsigned char*)&sz, 4); sz_obj-= 4;
if (sz > sz_obj)
break;
unsigned char *data = new unsigned char[sz];
pStream->read(data, sz);
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS: extension = L".xls"; prog = L"Excel"; rels = oox::typeOleObject; break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX: extension = L".xlsx"; prog = L"Excel"; rels = oox::typeMsObject; break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT: extension = L".ppt"; prog = L"PowerPoint"; rels = oox::typeOleObject; break;
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX: extension = L".pptx"; prog = L"PowerPoint"; rels = oox::typeMsObject; break;
str.push_back(std::string((char*)data, sz));
delete []data;
sz_obj-= sz;
}
if (!str.empty())
{
prog = std::wstring (str.back().begin(), str.back().end());
}
delete pStream;
}
delete storage;
return prog;
}

View File

@ -209,8 +209,6 @@ public:
static const ElementType type = typeDrawG;
CPDOCCORE_DEFINE_VISITABLE();
draw_g() : position_child_x1(0x7fffffff), position_child_y1(0x7fffffff), position_child_x2(0x7fffffff), position_child_y2(0x7fffffff) {}
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void docx_convert(oox::docx_conversion_context & Context);
@ -222,12 +220,6 @@ public:
office_element_ptr_array content_;
int position_child_x1;
int position_child_y1;
int position_child_x2;
int position_child_y2;
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);
@ -335,7 +327,7 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
void detectObject(const std::wstring &fileName, std::wstring &prog, std::wstring &extension, oox::RelsType &rels);
std::wstring detectObject(const std::wstring &fileName);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole);

View File

@ -574,7 +574,11 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
const graphic_format_properties & graphicProperties,
const std::vector<odf_reader::_property> & additional)
{
const _CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
// TODO : recursive result!!!
const _CP_OPT(anchor_type) anchor =
attlists_.shape_with_text_and_styles_.
common_text_anchor_attlist_.
type_;
//todooo пока не ясно как привязать к определеной странице в документе ...
//const _CP_OPT(unsigned int) anchor_page_number =
@ -585,15 +589,6 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
_CP_OPT(vertical_rel) styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
_CP_OPT(vertical_pos) styleVerticallPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
if (!styleVerticalRel && anchor)
{
switch(anchor->get_type())
{
case anchor_type::Paragraph: styleVerticalRel = vertical_rel::Paragraph; break;
case anchor_type::Page: styleVerticalRel = vertical_rel::Page; break;
}
}
_CP_OPT(double) dVal;
GetProperty(additional, L"svg:translate_y", dVal);
@ -822,31 +817,14 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
}
_CP_OPT(run_through) styleRunThrough = graphicProperties.style_run_through_;
_CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
drawing->styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
drawing->styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
drawing->styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
drawing->styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
if (!drawing->styleVerticalRel && anchor)
{
switch(anchor->get_type())
{
case anchor_type::Paragraph: drawing->styleVerticalRel = vertical_rel::Paragraph; break;
case anchor_type::Page: drawing->styleVerticalRel = vertical_rel::Page; break;
case anchor_type::Char: drawing->styleVerticalRel = vertical_rel::Char; break;
}
}
if (!drawing->styleHorizontalRel && anchor)
{
switch(anchor->get_type())
{
case anchor_type::Paragraph: drawing->styleHorizontalRel = horizontal_rel::Paragraph; break;
case anchor_type::Page: drawing->styleHorizontalRel = horizontal_rel::Page; break;
case anchor_type::Char: drawing->styleHorizontalRel = horizontal_rel::Char; break;
}
}
_CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
int level_drawing = Context.get_drawing_context().get_current_level();
if (drawing->parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
@ -856,7 +834,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
if (attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_)
{
std::wstring transformStr = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_.get();
docx_convert_transforms(transformStr, drawing->additional);
oox_convert_transforms(transformStr, drawing->additional);
}
if (!drawing->isInline)
{
@ -874,7 +852,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
if (!drawing->styleWrap)
drawing->styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
_CP_OPT(unsigned int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
_CP_OPT(int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
if (zIndex)//порядок отрисовки объектов
{
@ -896,20 +874,20 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
int type = attlists_.rel_size_.style_rel_width_->get_type();
if (type == odf_types::percent_or_scale::Percent)
drawing->pctWidth = (int)attlists_.rel_size_.style_rel_width_->get_percent().get_value();
drawing->pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value();
}
if (attlists_.rel_size_.style_rel_height_ )
{
int type = attlists_.rel_size_.style_rel_height_->get_type();
if (type == odf_types::percent_or_scale::Percent)
drawing->pctHeight = (int)attlists_.rel_size_.style_rel_height_->get_percent().get_value();
drawing->pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
}
}
drawing->number_wrapped_paragraphs = graphicProperties.style_number_wrapped_paragraphs_.
get_value_or( integer_or_nolimit( integer_or_nolimit::NoLimit) ).get_value();
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV < 0)
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV< 0)
{
drawing->posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
}
@ -958,41 +936,14 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
drawing->cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
drawing->cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
_CP_OPT(double) dVal;
GetProperty(drawing->additional, L"svg:rotate", dVal);
if (dVal)
{
double new_x = (drawing->cx / 2 * cos(-(*dVal)) - drawing->cy / 2 * sin(-(*dVal)) ) - drawing->cx / 2;
double new_y = (drawing->cx / 2 * sin(-(*dVal)) + drawing->cy / 2 * cos(-(*dVal)) ) - drawing->cy / 2;
drawing->x += new_x;
drawing->y += new_y;
}
GetProperty(drawing->additional, L"svg:scale_x",dVal);
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
GetProperty(drawing->additional, L"svg:scale_y",dVal);
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
GetProperty(drawing->additional, L"svg:translate_x", dVal);
if (dVal)
{
drawing->x += get_value_emu(dVal.get());
}
GetProperty(drawing->additional, L"svg:translate_y", dVal);
if (dVal)
{
drawing->y += get_value_emu(dVal.get());
}
if (drawing->cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
{
drawing->cx = -drawing->cx;
drawing->additional.push_back(_property(L"fit-to-size", true));
}
if (drawing->cy < 0)
drawing->cy = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////
if ((drawing->styleWrap) && (drawing->styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
{
@ -1037,13 +988,40 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
//}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
_CP_OPT(double) dVal;
GetProperty(drawing->additional, L"svg:scale_x",dVal);
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
GetProperty(drawing->additional, L"svg:scale_y",dVal);
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
GetProperty(drawing->additional, L"svg:translate_x", dVal);
if (dVal)
{
int val = get_value_emu(dVal.get());
drawing->x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
}
GetProperty(drawing->additional,L"svg:translate_y", dVal);
if (dVal)
{
int val = get_value_emu(dVal.get());
drawing->y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
}
if (drawing->inGroup && drawing->type != oox::typeGroupShape)
{
Context.get_drawing_context().set_position_child_group (drawing->x, drawing->y);
Context.get_drawing_context().set_size_child_group (drawing->cx + drawing->x, drawing->cy + drawing->y);
// ваще то тут "несовсем" всерно ... нужно сначала все стартовые позиции добавить ..
_INT32 x_group_offset, y_group_offset;
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
drawing->x -= x_group_offset;
drawing->y -= y_group_offset;
}
}
@ -1052,17 +1030,15 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
//--------------------------------------------------------------------------------------------------
oox::_docx_drawing drawing = oox::_docx_drawing();
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
drawing.lined = lined_shape_;
drawing.connector = connector_;
drawing.type = oox::typeShape;
drawing.id = Context.get_drawing_context().get_current_shape_id();
drawing.name = Context.get_drawing_context().get_current_object_name();
drawing.inGroup = Context.get_drawing_context().in_group();
drawing.sub_type = sub_type_;
drawing.additional = additional_;//сюда могут добавиться свойства ...
if (drawing.lined == false)
if (drawing.sub_type !=5 )//line
{
drawing.additional.push_back(_property(L"text-content", Context.get_drawing_context().get_text_stream_shape()));
}
@ -1143,7 +1119,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
return;
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
size_t pos_replaicement = href.find(L"ObjectReplacements");
int pos_replaicement = href.find(L"ObjectReplacements");
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
if (!frame)
@ -1152,7 +1128,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
if (pos_replaicement != std::wstring::npos)
if (pos_replaicement >= 0)
{
if (!Context.get_drawing_context().get_use_image_replace())
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
@ -1214,18 +1190,10 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
std::wstring strRectClip = properties->fo_clip_.get();
strRectClip = strRectClip.substr(5, strRectClip.length() - 6);
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + xlink_attlist_.href_.get_value_or(L"");
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + href;
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, Context.get_mediaitems().applicationFonts());
}
if (properties->common_draw_fill_attlist_.draw_luminance_)
{
drawing->fill.bitmap->luminance = properties->common_draw_fill_attlist_.draw_luminance_->get_value();
}
if (properties->common_draw_fill_attlist_.draw_contrast_)
{
drawing->fill.bitmap->contrast = properties->common_draw_fill_attlist_.draw_contrast_->get_value();
}
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
}
}
}
@ -1379,18 +1347,9 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
Context.reset_context_state();
if (position_child_x1 != 0x7fffffff && position_child_y1 != 0x7fffffff )
{
Context.get_drawing_context().set_position_child_group (position_child_x1, position_child_y1);
if (position_child_x2 != 0x7fffffff && position_child_y2 != 0x7fffffff )
{
Context.get_drawing_context().set_size_child_group (position_child_x2 - position_child_x1, position_child_y2 - position_child_y1);
}
}
for (size_t i = 0; i < content_.size(); i++)
{
ElementType type = content_[i]->get_type();
content_[i]->docx_convert(Context);
}
drawing.content_group_ = temp_stream.str();
@ -1401,11 +1360,18 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
//--------------------------------------------------
Context.get_drawing_context().get_size_group (drawing.cx , drawing.cy);
Context.get_drawing_context().get_position_group(drawing.x , drawing.y);
drawing.cx -= drawing.x;
drawing.cy -= drawing.y;
Context.get_drawing_context().stop_group();
if (drawing.inGroup)
{
Context.get_drawing_context().set_position_child_group (drawing.x, drawing.y);
Context.get_drawing_context().set_size_child_group (drawing.cx + drawing.x, drawing.cy + drawing.y);
// ваще то тут "несовсем" верно ... нужно сначала все стартовые позиции добавить ..
_INT32 x_group_offset, y_group_offset;
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
@ -1670,20 +1636,18 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
if (href.empty()) return;
draw_frame* frame = Context.get_drawing_context().get_current_frame(); //owner
draw_frame* frame = Context.get_drawing_context().get_current_frame(); //owner
if (!frame) return;
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
if (!drawing) return;
std::wstring extension;
detectObject(objectPath, drawing->objectProgId, extension, drawing->type);
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
bool isMediaInternal = true;
drawing->objectId = Context.get_mediaitems().add_or_find(href + extension, drawing->type, isMediaInternal, href);
drawing->type = oox::typeOleObject;
bool isMediaInternal = true;
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
drawing->objectProgId = detectObject(objectPath);
}
void draw_control::docx_convert(oox::docx_conversion_context & Context)
{

View File

@ -88,7 +88,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
common_shape_draw_attlist &common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_;
common_presentation_attlist &common_presentation_attlist_= common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
const unsigned int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -115,7 +115,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
if (common_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.draw_transform_.get();
pptx_convert_transforms(transformStr, Context);
pptx_convert_transforms(transformStr,Context);
}
////////////////////////////////////////
std::wstring Anchor;
@ -125,7 +125,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
const double a_x_pt = common_draw_attlists_.shape_with_text_and_styles_.common_shape_table_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double a_y_pt = common_draw_attlists_.shape_with_text_and_styles_.common_shape_table_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt);
Context.get_slide_context().set_anchor(Anchor, a_x_pt, a_y_pt);
Context.get_slide_context().set_anchor(Anchor,a_x_pt,a_y_pt);
}
//////////////////////////////////////////////
std::vector<const odf_reader::style_instance *> instances;
@ -162,13 +162,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
if (properties.fo_clip_)
{
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_slide_context().set_clipping(strRectClip.substr(5, strRectClip.length() - 6));
}
Context.root()->odf_context().drawStyles() ,fill);
Context.get_slide_context().set_fill(fill);
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_left", Compute_BorderWidth(properties, sideLeft)));
@ -176,6 +170,11 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight)));
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom)));
if (properties.fo_clip_)
{
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_slide_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
}
if (common_presentation_attlist_.presentation_class_)
{
Context.get_slide_context().set_placeHolder_type(common_presentation_attlist_.presentation_class_->get_type_ms());
@ -222,7 +221,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
}
std::wstring text_content_ = Context.get_text_context().end_object();
if (!text_content_.empty())
if (text_content_.length()>0)
{
Context.get_slide_context().set_property(_property(L"text-content", text_content_));
}
@ -385,18 +384,7 @@ void draw_object_ole::pptx_convert(oox::pptx_conversion_context & Context)
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
if (!href.empty())
{
std::wstring prog, extension;
oox::RelsType relsType;
detectObject(objectPath, prog, extension, relsType);
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
if (relsType == oox::typeMsObject)
Context.get_slide_context().set_ms_object(href + extension, prog);
else
Context.get_slide_context().set_ole_object(href + extension, prog);
}
Context.get_slide_context().set_ole_object(href, detectObject(objectPath));
}
void draw_param::pptx_convert(oox::pptx_conversion_context & Context)

View File

@ -73,8 +73,8 @@ void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context)
{
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
//////////////////////////////////////////////////////////////////////////
Context.get_drawing_context().start_group( name);
@ -118,7 +118,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
{
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring styleName = common_draw_attlist_.common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -144,7 +144,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
if (common_draw_attlist_.common_shape_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.common_shape_draw_attlist_.draw_transform_.get();
xlsx_convert_transforms(transformStr, Context);
xlsx_convert_transforms(transformStr,Context);
}
////////////////////////////////////////
std::wstring Anchor;
@ -179,14 +179,14 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight)));
Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom)));
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles(), fill);
if (properties.fo_clip_)
{
std::wstring strRectClip = properties.fo_clip_.get();
Context.get_drawing_context().set_clipping(strRectClip.substr(5, strRectClip.length() - 6));
Context.get_drawing_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
}
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
Context.get_drawing_context().set_fill(fill);
oox_drawing_ = oox_drawing_ptr(new oox::_xlsx_drawing());
@ -228,7 +228,7 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
}
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
if (!text_content_.empty())
if (text_content_.length()>0)
{
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
}
@ -359,18 +359,8 @@ void draw_object_ole::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
if (!href.empty())
{
std::wstring prog, extension;
oox::RelsType relsType;
detectObject(objectPath, prog, extension, relsType);
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
if (relsType == oox::typeMsObject)
Context.get_drawing_context().set_ms_object(href + extension, prog);
else
Context.get_drawing_context().set_ole_object(href + extension, prog);
}
Context.get_drawing_context().set_ole_object(href, detectObject(objectPath));
}
}

View File

@ -174,7 +174,6 @@ void draw_line::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_shape::add_attributes(Attributes);
sub_type_ = 5;
lined_shape_ = true;
}
void draw_line::reset_svg_attributes()
{
@ -257,11 +256,8 @@ void draw_path::reset_svg_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool bClosed = false;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false, bClosed);
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false);
if (!bClosed) lined_shape_ = true;
for (size_t i = 0; i < o_Polyline_cm.size(); i++)
{
::svg_path::_polyline & poly = o_Polyline_cm[i];
@ -279,7 +275,7 @@ void draw_path::reset_svg_path()
}
o_Polyline_pt.push_back(poly);
}
if (false == o_Polyline_pt.empty())
if (o_Polyline_pt.size()>0)
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
@ -295,24 +291,18 @@ void draw_polygon_attlist::add_attributes( const xml::attributes_wc_ptr & Attrib
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
//-------------------------------------------------------------------------------------------
// draw:contour-polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_contour_polygon::ns = L"draw";
const wchar_t * draw_contour_polygon::name = L"contour-polygon";
//-------------------------------------------------------------------------------------------
// draw:contour-path
//-------------------------------------------------------------------------------------------
const wchar_t * draw_contour_path::ns = L"draw";
const wchar_t * draw_contour_path::name = L"contour-path";
//-------------------------------------------------------------------------------------------
// draw:polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_polygon::ns = L"draw";
const wchar_t * draw_polygon::name = L"polygon";
//-------------------------------------------------------------------------------------------
// draw:contour-polygon
//-------------------------------------------------------------------------------------------
const wchar_t * draw_contour_polygon::ns = L"draw";
const wchar_t * draw_contour_polygon::name = L"contour-polygon";
void draw_polygon::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_polygon_attlist_.add_attributes(Attributes);
@ -332,7 +322,7 @@ void draw_polygon::reset_polygon_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polygon_attlist_.draw_points_.get(), false, true);
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polygon_attlist_.draw_points_.get(),false, true);
for (size_t ind = 0 ; ind < o_Polyline_cm.size(); ind++)
{
@ -351,12 +341,12 @@ void draw_polygon::reset_polygon_path()
}
o_Polyline_pt.push_back(poly);
}
if (false == o_Polyline_pt.empty())
if (o_Polyline_pt.size()>0)
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
::svg_path::oox_serialize(output_, o_Polyline_pt);
additional_.push_back(odf_reader::_property(L"custom_path", output_.str()));
additional_.push_back(odf_reader::_property(L"custom_path",output_.str()));
}
}
}
@ -378,8 +368,7 @@ void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_polyline_attlist_.add_attributes(Attributes);
draw_shape::add_attributes(Attributes);
sub_type_ = 14;
lined_shape_ = true;
sub_type_ = 8;
}
void draw_polyline::reset_polyline_path()
@ -393,7 +382,7 @@ void draw_polyline::reset_polyline_path()
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, false);
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, true);
_CP_OPT(double) start_x, start_y;
@ -418,7 +407,7 @@ void draw_polyline::reset_polyline_path()
}
o_Polyline_pt.push_back(poly);
}
if (false == o_Polyline_pt.empty())
if (o_Polyline_pt.size()>0)
{
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
std::wstringstream output_;
@ -492,8 +481,6 @@ void draw_enhanced_geometry_attlist::add_attributes( const xml::attributes_wc_pt
CP_APPLY_ATTR(L"draw:enhanced-path" , draw_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:enhanced-path" , drawooo_enhanced_path_);
CP_APPLY_ATTR(L"drawooo:sub-view-size" , drawooo_sub_view_size_);
CP_APPLY_ATTR(L"draw:mirror-horizontal" , draw_mirror_horizontal_);
CP_APPLY_ATTR(L"draw:mirror-vertical" , draw_mirror_vertical_);
}
//-------------------------------------------------------------------------------------------
// draw:enhanced_geometry
@ -503,7 +490,7 @@ const wchar_t * draw_enhanced_geometry::name = L"enhanced-geometry";
void draw_enhanced_geometry::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
attlist_.add_attributes(Attributes);
draw_enhanced_geometry_attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
@ -527,20 +514,20 @@ void draw_enhanced_geometry::add_child_element( xml::sax * Reader, const std::ws
}
void draw_enhanced_geometry::find_draw_type_oox()
{
word_art_ = false;
bOoxType_ = false;
word_art_ = false;
bOoxType_ = false;
if (attlist_.draw_text_path_ &&
*attlist_.draw_text_path_ == true)
if (draw_enhanced_geometry_attlist_.draw_text_path_ &&
*draw_enhanced_geometry_attlist_.draw_text_path_ == true)
{
draw_type_oox_index_ = 0;
word_art_ = true;
sub_type_ = 1;
}
if (attlist_.draw_type_)
if (draw_enhanced_geometry_attlist_.draw_type_)
{
std::wstring odf_type = attlist_.draw_type_.get();
std::wstring odf_type = draw_enhanced_geometry_attlist_.draw_type_.get();
if (word_art_)
{
@ -559,11 +546,11 @@ void draw_enhanced_geometry::find_draw_type_oox()
if (!draw_type_oox_index_)
{
int count = sizeof(_OO_OOX_custom_shapes) / sizeof(_shape_converter);
size_t pos = odf_type.find(L"ooxml-");
int pos = odf_type.find(L"ooxml-");
if (pos == std::wstring::npos)
if (pos < 0)
{
for (long i = 0; i < count; i++)
for (long i = 0; i< count; i++)
{
if (_OO_OOX_custom_shapes[i].odf_reader == odf_type)
{
@ -575,7 +562,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
else
{
std::wstring oox_type = odf_type.substr(pos + 6);
for (long i = 0; i < count; i++)
for (long i = 0; i< count; i++)
{
if (_OO_OOX_custom_shapes[i].oox == oox_type)
{
@ -585,7 +572,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
}
}
}
if ((draw_type_oox_index_) && (*draw_type_oox_index_== 96))//L"textBox" "mso-spt24"
if ((draw_type_oox_index_) && (*draw_type_oox_index_== 179))//L"textBox"
{
sub_type_ = 1;//textBox
}
@ -662,23 +649,21 @@ void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_line_attlist_.add_attributes(Attributes);
draw_shape::add_attributes(Attributes);
sub_type_ = 10; //коннектор - линия, если ломаная (ниже определяется) - то путь
lined_shape_ = true;
connector_ = true;
sub_type_ = 5; //коннектор - линия, если ломаная (ниже определяется) - то путь
}
void draw_connector::reset_svg_path()
{
if (draw_connector_attlist_.svg_d_)
if (!draw_connector_attlist_.svg_d_)
{
bad_shape_ = true;
}
else
{
sub_type_ = 8;
std::vector<::svg_path::_polyline> o_Polyline_pt;
std::vector<::svg_path::_polyline> o_Polyline_cm;
bool bClosed = false;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false, bClosed);
if (!bClosed) lined_shape_ = true;
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false);
double x1=common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::emu);
double y1=common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::emu);
@ -722,7 +707,7 @@ void dr3d_scene::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_shape::add_attributes(Attributes);
sub_type_ = 12;
sub_type_ = 10;
}
//-------------------------------------------------------------------------------------------
@ -733,22 +718,13 @@ const wchar_t * dr3d_extrude::name = L"extrude";
void dr3d_extrude::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_path::add_attributes(Attributes);
//sub_type_ = ??
CP_APPLY_ATTR(L"svg:d", svg_d_);
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
}
//-------------------------------------------------------------------------------------------
// dr3d:rotate
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_rotate::ns = L"dr3d";
const wchar_t * dr3d_rotate::name = L"rotate";
void dr3d_rotate::add_attributes( const xml::attributes_wc_ptr & Attributes )
void dr3d_extrude::reset_svg_path()
{
draw_path::add_attributes(Attributes);
//sub_type_ = ??
if (!svg_d_) return;
}
//-------------------------------------------------------------------------------------------
// dr3d:light
@ -764,38 +740,6 @@ void dr3d_light::add_attributes( const xml::attributes_wc_ptr & Attributes )
CP_APPLY_ATTR(L"dr3d:enabled", dr3d_enabled_);
}
//-------------------------------------------------------------------------------------------
// dr3d:cube
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_cube::ns = L"dr3d";
const wchar_t * dr3d_cube::name = L"cube";
void dr3d_cube::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_shape::add_attributes(Attributes);
CP_APPLY_ATTR(L"dr3d:max-edge", dr3d_max_edge_);
CP_APPLY_ATTR(L"dr3d:min-edge", dr3d_min_edge_);
CP_APPLY_ATTR(L"dr3d:transform", dr3d_transform_);
sub_type_ = 15;
}
//-------------------------------------------------------------------------------------------
// dr3d:sphere
//-------------------------------------------------------------------------------------------
const wchar_t * dr3d_sphere::ns = L"dr3d";
const wchar_t * dr3d_sphere::name = L"sphere";
void dr3d_sphere::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_shape::add_attributes(Attributes);
CP_APPLY_ATTR(L"dr3d:size", dr3d_size_); //vector3D
CP_APPLY_ATTR(L"dr3d:center", dr3d_center_); //vector3D
CP_APPLY_ATTR(L"dr3d:transform",dr3d_transform_);
sub_type_ = 16;
}
//-------------------------------------------------------------------------------------------
// draw:control
//-------------------------------------------------------------------------------------------
const wchar_t * draw_control::ns = L"draw";

View File

@ -63,7 +63,7 @@ public:
static const ElementType type = typeDrawShape;
static const xml::NodeType xml_type = xml::typeElement;
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1), lined_shape_(false), connector_(false){}
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1) {}
CPDOCCORE_DEFINE_VISITABLE();
friend class odf_document;
@ -93,8 +93,6 @@ public:
int sub_type_;
std::vector<odf_reader::_property> additional_;
int idx_in_owner;
bool lined_shape_;
bool connector_;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -287,7 +285,7 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_polygon);
//-----------------------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//draw:contour-polygon
class draw_contour_polygon : public draw_polygon
{
@ -299,21 +297,9 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_polygon);
//-----------------------------------------------------------------------------------------------------
//draw:contour-path
class draw_contour_path : public draw_path
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDrawContourPath;
static const xml::NodeType xml_type = xml::typeElement;
};
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_path);
//-----------------------------------------------------------------------------------------------------
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_polygon);
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class draw_polyline_attlist
{
public:
@ -455,8 +441,6 @@ public:
_CP_OPT(std::wstring) draw_enhanced_path_;
_CP_OPT(std::wstring) drawooo_enhanced_path_;
_CP_OPT(std::wstring) drawooo_sub_view_size_;
_CP_OPT(bool) draw_mirror_horizontal_;
_CP_OPT(bool) draw_mirror_vertical_;
};
/////////////////////////////////////////////////////////////////////////
class draw_enhanced_geometry : public office_element_impl<draw_enhanced_geometry>
@ -478,7 +462,7 @@ public:
void find_draw_type_oox();
draw_enhanced_geometry_attlist attlist_;
draw_enhanced_geometry_attlist draw_enhanced_geometry_attlist_;
_CP_OPT(int) sub_type_;
_CP_OPT(int) draw_type_oox_index_;
@ -588,9 +572,9 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_scene);
//------------------------------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class dr3d_extrude : public draw_path
class dr3d_extrude : public office_element_impl<dr3d_extrude>
{
public:
static const wchar_t * ns;
@ -602,31 +586,19 @@ public:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
//virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
//virtual void docx_convert(oox::docx_conversion_context & Context);
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) svg_d_;
_CP_OPT(std::wstring) svg_viewbox_;
void reset_svg_path();
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_extrude);
//------------------------------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class dr3d_rotate : public draw_path
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dRotate;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
//virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
//virtual void docx_convert(oox::docx_conversion_context & Context);
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_rotate);
//------------------------------------------------------------------------------------------------------------
class dr3d_light : public office_element_impl<dr3d_light>
{
public:
@ -643,61 +615,13 @@ public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_diffuse_color_;
_CP_OPT(std::wstring) dr3d_direction_;
_CP_OPT(odf_types::Bool) dr3d_specular_;
_CP_OPT(odf_types::Bool) dr3d_enabled_;
_CP_OPT(std::wstring) dr3d_diffuse_color_;
_CP_OPT(std::wstring) dr3d_direction_;
_CP_OPT(std::wstring) dr3d_specular_;
_CP_OPT(odf_types::Bool)dr3d_enabled_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_light);
//------------------------------------------------------------------------------------------------------------
class dr3d_cube : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dCube;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_max_edge_;
_CP_OPT(std::wstring) dr3d_min_edge_;
_CP_OPT(std::wstring) dr3d_transform_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_cube);
//------------------------------------------------------------------------------------------------------------
class dr3d_sphere : public draw_shape
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const ElementType type = typeDr3dSphere;
static const xml::NodeType xml_type = xml::typeElement;
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) dr3d_size_; //vector3D
_CP_OPT(std::wstring) dr3d_center_; //vector3D
_CP_OPT(std::wstring) dr3d_transform_;
};
CP_REGISTER_OFFICE_ELEMENT2(dr3d_sphere);
//----------------------------------------------------------------------------------------------
class draw_control : public draw_shape
{

View File

@ -215,18 +215,10 @@ void draw_path::docx_convert(oox::docx_conversion_context & Context)
void draw_connector::docx_convert(oox::docx_conversion_context & Context)
{
//if (Context.get_drawing_context().get_current_level() >0 )return;
if (draw_connector_attlist_.draw_type_)
{
if (*draw_connector_attlist_.draw_type_ == L"curve")
{
sub_type_ = 11;
}
}
reset_svg_attributes();
common_docx_convert(Context);
//...
reset_svg_path();
draw_shape::docx_convert(Context);
}
void draw_polygon::docx_convert(oox::docx_conversion_context & Context)
@ -288,14 +280,6 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
bool set_shape = false;
if (attlist_.draw_mirror_horizontal_)
{
shape->additional_.push_back(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
}
if (attlist_.draw_mirror_vertical_)
{
shape->additional_.push_back(_property(L"flipV", *attlist_.draw_mirror_vertical_));
}
if (draw_type_oox_index_)
{
shape->additional_.push_back(_property(L"oox-geom-index", draw_type_oox_index_.get()));
@ -313,27 +297,25 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
set_shape = true;
}
std::wstring odf_path; //общая часть - объединить ...
if (attlist_.drawooo_enhanced_path_)
odf_path = attlist_.drawooo_enhanced_path_.get();
else if (attlist_.draw_enhanced_path_)
odf_path = attlist_.draw_enhanced_path_.get();
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
bool res = false;
bool bClosed = false;
try
{
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
}
catch(...)
{
res = false;
}
//if (!bClosed) lined_shape_ = true;
if (!o_Polyline.empty() && res )
{
@ -347,10 +329,10 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
int w = 0;
int h = 0;
if (attlist_.drawooo_sub_view_size_)
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
@ -383,10 +365,10 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
}
}
if (attlist_.draw_modifiers_)
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
{
if (bOoxType_)
shape->additional_.push_back(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
shape->additional_.push_back(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
else
{
}
@ -411,17 +393,14 @@ void dr3d_scene::docx_convert(oox::docx_conversion_context & Context)
//...
draw_shape::docx_convert(Context);
}
void dr3d_extrude::docx_convert(oox::docx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::docx_convert(oox::docx_conversion_context & Context)
{
}
void dr3d_cube::docx_convert(oox::docx_conversion_context & Context)
{
}
void dr3d_sphere::docx_convert(oox::docx_conversion_context & Context)
{
}
}
}

View File

@ -68,7 +68,7 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
common_shape_draw_attlist &common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_;
common_presentation_attlist &common_presentation_attlist_= common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
const unsigned int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -92,7 +92,8 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
if (common_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.draw_transform_.get();
pptx_convert_transforms(transformStr, Context);
pptx_convert_transforms(transformStr,Context);
//oox_convert_transforms(transformStr, additional_);
}
////////////////////////////////////////
std::wstring Anchor;
@ -147,9 +148,6 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
paragraph_format_properties paragraph_properties = calc_paragraph_properties_content(textStyleInst);
}
///////////////////////////////////////////////////////////////////////////////////////
Context.get_slide_context().set_is_line_shape(lined_shape_);
Context.get_slide_context().set_is_connector_shape(connector_);
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
Context.root()->odf_context().drawStyles() ,fill);
@ -232,7 +230,6 @@ void draw_path::pptx_convert(oox::pptx_conversion_context & Context)
}
void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
{
//closed shape
reset_polygon_path();
///////////////////////////////////////////////////////////////////////
Context.get_slide_context().start_shape(sub_type_);
@ -241,9 +238,9 @@ void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
{
//line
reset_polyline_path();
///////////////////////////////////////////////////////////////////////
Context.get_slide_context().start_shape(sub_type_);
@ -252,17 +249,6 @@ void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
//void dr3d_rotate::pptx_convert(oox::pptx_conversion_context & Context)
//{
// //closed shape
// reset_polygon_path();
/////////////////////////////////////////////////////////////////////////
// Context.get_slide_context().start_shape(sub_type_);
//
// common_pptx_convert(Context);
//
// Context.get_slide_context().end_shape();
//}
void draw_custom_shape::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_);
@ -312,13 +298,6 @@ void draw_connector::reset_svg_attributes()
}
void draw_connector::pptx_convert(oox::pptx_conversion_context & Context)
{
if (draw_connector_attlist_.draw_type_)
{
if (*draw_connector_attlist_.draw_type_ == L"curve")
{
sub_type_ = 11;
}
}
reset_svg_attributes();
reset_svg_path();
///////////////////////////////////////////////////////////////////////
@ -340,14 +319,6 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
bool set_shape = false;
if (attlist_.draw_mirror_horizontal_)
{
Context.get_slide_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
}
if (attlist_.draw_mirror_vertical_)
{
Context.get_slide_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
}
if (draw_type_oox_index_)
{
Context.get_slide_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));
@ -365,27 +336,25 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
}
std::wstring odf_path;
if (attlist_.drawooo_enhanced_path_)
odf_path = attlist_.drawooo_enhanced_path_.get();
else if (attlist_.draw_enhanced_path_)
odf_path = attlist_.draw_enhanced_path_.get();
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
bool res = false;
bool bClosed =false;
try
{
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
}
catch(...)
{
res = false;
}
//if (!bClosed) lined_shape_ = true;
if (o_Polyline.size() > 1 && res )
{
@ -396,10 +365,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
set_shape = true;
if (attlist_.drawooo_sub_view_size_)
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
@ -420,10 +389,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
}
}
}
if (attlist_.draw_modifiers_)
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
{
if (bOoxType_)
Context.get_slide_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
Context.get_slide_context().set_property(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
else
{
}
@ -450,18 +419,15 @@ void dr3d_scene::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
void dr3d_extrude::pptx_convert(oox::pptx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_light::pptx_convert(oox::pptx_conversion_context & Context)
{
}
void dr3d_cube::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_); //reset type
}
void dr3d_sphere::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(sub_type_); //reset type
}
}
}

View File

@ -71,7 +71,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
const std::wstring styleName = common_draw_attlist_.common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
const std::wstring textStyleName = common_draw_attlist_.common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
@ -96,7 +96,8 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
if (common_draw_attlist_.common_shape_draw_attlist_.draw_transform_)
{
std::wstring transformStr = common_draw_attlist_.common_shape_draw_attlist_.draw_transform_.get();
xlsx_convert_transforms(transformStr, Context);
xlsx_convert_transforms(transformStr,Context);
//oox_convert_transforms(transformStr, additional_);
}
////////////////////////////////////////
std::wstring Anchor;
@ -129,8 +130,6 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().set_property(additional_[i]);
}
Context.get_drawing_context().set_is_line_shape(lined_shape_);
Context.get_drawing_context().set_is_connector_shape(connector_);
oox::_oox_fill fill;
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
@ -212,15 +211,6 @@ void draw_path::xlsx_convert(oox::xlsx_conversion_context & Context)
void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (draw_connector_attlist_.draw_type_)
{
if (*draw_connector_attlist_.draw_type_ == L"curve")
{
sub_type_ = 11;
}
}
reset_svg_attributes();
reset_svg_path();
///////////////////////////////////////////////////////////////////////
Context.get_drawing_context().start_shape(6);
@ -276,14 +266,6 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
{
find_draw_type_oox();
if (attlist_.draw_mirror_horizontal_)
{
Context.get_drawing_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
}
if (attlist_.draw_mirror_vertical_)
{
Context.get_drawing_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
}
if (draw_type_oox_index_)
{
Context.get_drawing_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));
@ -299,27 +281,25 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
}
std::wstring odf_path;
if (attlist_.drawooo_enhanced_path_)
odf_path = attlist_.drawooo_enhanced_path_.get();
else if (attlist_.draw_enhanced_path_)
odf_path = attlist_.draw_enhanced_path_.get();
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
if (!odf_path.empty())
{
std::vector<::svg_path::_polyline> o_Polyline;
bool res = false;
bool bClosed = false;
try
{
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
}
catch(...)
{
res = false;
}
//if (!bClosed) lined_shape_ = true;
if (o_Polyline.size() > 1 && res )
{
@ -328,10 +308,10 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
::svg_path::oox_serialize(output_, o_Polyline);
Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path", output_.str()));
if (attlist_.drawooo_sub_view_size_)
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
{
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
if (splitted.size() == 2)
{
@ -356,10 +336,10 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
draw_type_oox_index_ = 0;
}
}
if (attlist_.draw_modifiers_)
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
{
if (bOoxType_)
Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
else
{
}
@ -376,17 +356,13 @@ void dr3d_scene::xlsx_convert(oox::xlsx_conversion_context & Context)
Context.get_drawing_context().end_shape();
Context.get_drawing_context().clear();
}
void dr3d_light::xlsx_convert(oox::xlsx_conversion_context & Context)
void dr3d_extrude::xlsx_convert(oox::xlsx_conversion_context & Context)
{
reset_svg_path();
}
void dr3d_cube::xlsx_convert(oox::xlsx_conversion_context & Context)
void dr3d_light::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().start_shape(sub_type_); //reset type
}
void dr3d_sphere::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_drawing_context().start_shape(sub_type_); //reset type
}
void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)

View File

@ -332,6 +332,22 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
}
return result;
}
std::string DecodeBase64(const std::wstring & value1)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
std::string value(value1.begin(), value1.end());
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
bool odf_document::Impl::decrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, office_element_ptr element, int file_size )
{
manifest_encryption_data* encryption_data = dynamic_cast<manifest_encryption_data*>(element.get());
@ -972,28 +988,6 @@ void odf_document::Impl::parse_styles(office_element *element)
continue;
context_->Templates().add(L"table:" + style->get_text_style_name(), elm);
}
for (size_t i = 0; i < docStyles->draw_styles_.draw_marker_.size(); i++)
{
office_element_ptr & elm = docStyles->draw_styles_.draw_marker_[i];
draw_marker * style = dynamic_cast<draw_marker *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"marker:" + style->get_style_name(), elm);
}
for (size_t i = 0; i < docStyles->draw_styles_.draw_stroke_dash_.size(); i++)
{
office_element_ptr & elm = docStyles->draw_styles_.draw_stroke_dash_[i];
draw_stroke_dash * style = dynamic_cast<draw_stroke_dash *>(elm.get());
if (!style)
continue;
context_->drawStyles().add(L"stroke_dash:" + style->get_style_name(), elm);
}
}
while(0); // end parse styles

View File

@ -35,23 +35,7 @@
namespace cpdoccore {
using namespace odf_types;
std::string DecodeBase64(const std::wstring & value1)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
std::string value(value1.begin(), value1.end());
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
namespace odf_reader {
style_instance::style_instance(

View File

@ -44,9 +44,6 @@
#include <iosfwd>
namespace cpdoccore {
std::string DecodeBase64(const std::wstring & value);
namespace odf_reader {
class styles_container;

View File

@ -268,7 +268,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
}
id_idx = Context.add_author_comments(author);
Context.get_comments_context().start_comment(x, y, id_idx.first, id_idx.second);//author & idx (uniq number for author
Context.get_comments_context().start_comment(x, y,id_idx.first,id_idx.second);//author & idx (uniq number for author
Context.get_text_context().start_comment_content();
for (size_t i = 0; i < content_.size(); i++)//текст + текстовый стиль

View File

@ -151,10 +151,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
{
if (page_layout_instance *lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{
if (Context.is_last_dump_page_properties())
{
Context.next_dump_page_properties(true);
}
Context.next_dump_page_properties(true);
lastPageLayout->docx_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();

View File

@ -284,7 +284,6 @@ void form_button::docx_convert(oox::docx_conversion_context & Context)
void form_button::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(1);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}

View File

@ -129,16 +129,6 @@ void office_text::add_child_element( xml::sax * Reader, const std::wstring & Ns,
else if (is_text_content(Ns, Name))
{
CP_CREATE_ELEMENT(content_);
if (!first_element_style_name && (content_.back()->get_type() == typeTextP ||
content_.back()->get_type() == typeTextH))
{//bus-modern_l.ott
if (content_.back()->element_style_name)
first_element_style_name = content_.back()->element_style_name;
else
first_element_style_name = L""; //default
}
}
else
CP_NOT_APPLICABLE_ELM();
@ -165,26 +155,6 @@ void office_text::docx_convert(oox::docx_conversion_context & Context)
//forms_->docx_convert(Context);
Context.start_office_text();
if ((first_element_style_name) && (!first_element_style_name->empty()))
{
std::wstring text___ = *first_element_style_name;
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(text___);
if (masterPageName)
{
std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(*masterPageName);
if (false == masterPageNameLayout.empty())
{
Context.set_master_page_name(*masterPageName); //проверка на то что тема действительно существует????
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
}
}
}
for (size_t i = 0; i < content_.size(); i++)
{
if (content_[i]->element_style_name)

View File

@ -70,8 +70,6 @@ private:
//office_element_ptr forms_; -> content
office_element_ptr_array content_;
_CP_OPT(std::wstring) first_element_style_name;
};
CP_REGISTER_OFFICE_ELEMENT2(office_text);
//----------------------------------------------------------------------------------------------------

View File

@ -169,7 +169,7 @@ public:
virtual void visit(const table_table& val)
{
if (visit_table(val.attlist_.table_name_.get_value_or(L"")))
if (visit_table(val.table_table_attlist_.table_name_.get_value_or(L"")))
{
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_, stop_);
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_, stop_);

View File

@ -108,26 +108,11 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
if (draw_stroke_) properties.push_back(_property(L"stroke", draw_stroke_->get_type() ));
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_->get_hex_value() ));
if (draw_stroke_dash_)
{
if (!draw_stroke_dash_->empty())
properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
}
if (draw_stroke_dash_) properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
if (svg_stroke_width_) properties.push_back(_property(L"stroke-width", svg_stroke_width_->get_length().get_value_unit(odf_types::length::pt) ));
if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_->get_percent().get_value()));
if (draw_marker_start_)
{
properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
}
if (draw_marker_end_)
{
//const std::wstring style_name = draw_marker_end_->get();
//if (!style_name.empty())
////if (office_element_ptr style = styles.find_by_style_name(style_name))
//{
properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
//}
}
if (draw_marker_start_) properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
if (draw_marker_end_) properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
if (draw_textarea_horizontal_align_)properties.push_back(_property(L"textarea-horizontal_align",draw_textarea_horizontal_align_->get_type() ));
if (draw_textarea_vertical_align_) properties.push_back(_property(L"textarea-vertical_align", draw_textarea_vertical_align_->get_type() ));
@ -137,18 +122,6 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
if (draw_fit_to_size_) properties.push_back(_property(L"fit-to-size", *draw_fit_to_size_));
if (draw_fit_to_contour_) properties.push_back(_property(L"fit-to-contour", *draw_fit_to_contour_));
if (common_draw_fill_attlist_.draw_color_mode_)
{
properties.push_back(_property(L"color-mode", *common_draw_fill_attlist_.draw_color_mode_));
}
if (common_draw_fill_attlist_.draw_luminance_)
{
properties.push_back(_property(L"luminance", common_draw_fill_attlist_.draw_luminance_->get_value()));
}
if (common_draw_fill_attlist_.draw_contrast_)
{
properties.push_back(_property(L"contrast", common_draw_fill_attlist_.draw_contrast_->get_value()));
}
if (common_padding_attlist_.fo_padding_)
{
properties.push_back(_property(L"text-padding-left", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));

View File

@ -529,18 +529,7 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_cs));}
}
}
if ((fo_background_color_) && (fo_background_color_->get_type() == odf_types::background_color::Enabled ))
{
std::wstring strRGB = fo_background_color_->get_color().get_hex_value(); //auto ... не нужно
if (!strRGB.empty())
{
CP_XML_NODE(L"a:highlight")
{
CP_XML_NODE(L"a:srgbClr") {CP_XML_ATTR(L"val", strRGB);}
}
}
}
if (!hlink.empty())
{
CP_XML_NODE(L"a:hlinkClick")

View File

@ -329,44 +329,7 @@ void draw_fill_image::add_child_element( xml::sax * Reader, const std::wstring &
{
CP_NOT_APPLICABLE_ELM();
}
//----------------------------------------------------------------------------------------
const wchar_t * draw_marker::ns = L"draw";
const wchar_t * draw_marker::name = L"marker";
void draw_marker::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name" , draw_name_);
CP_APPLY_ATTR(L"draw:display-name" , draw_display_name_);
CP_APPLY_ATTR(L"svg:d" , svg_d_);
CP_APPLY_ATTR(L"svg:viewBox" , svg_viewBox_);
}
void draw_marker::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
//----------------------------------------------------------------------------------------
const wchar_t * draw_stroke_dash::ns = L"draw";
const wchar_t * draw_stroke_dash::name = L"stroke-dash";
void draw_stroke_dash::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:name" , draw_name_);
CP_APPLY_ATTR(L"draw:display-name" , draw_display_name_);
CP_APPLY_ATTR(L"draw:distance" , draw_distance_);
CP_APPLY_ATTR(L"draw:dots1-length" , draw_dots1_length_);
CP_APPLY_ATTR(L"draw:dots2-length" , draw_dots2_length_);
CP_APPLY_ATTR(L"draw:dots1" , draw_dots1_);
CP_APPLY_ATTR(L"draw:dots2" , draw_dots2_);
CP_APPLY_ATTR(L"draw:style" , draw_style_);//"square"
}
void draw_stroke_dash::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
//----------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_gradient::ns = L"draw";
const wchar_t * draw_gradient::name = L"gradient";

View File

@ -119,7 +119,8 @@ private:
};
// style:default-style
// default_style
/// style:default-style
class default_style : public office_element_impl<default_style>
{
public:
@ -146,69 +147,10 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(default_style);
//-------------------------------------------------------------------------------------------------
// draw:marker
class draw_marker : public office_element_impl<draw_marker>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawMarker;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(std::wstring) svg_d_;
_CP_OPT(std::wstring) svg_viewBox_;
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
friend class odf_document;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_marker);
//-------------------------------------------------------------------------------------------------
// draw:stroke-dash
class draw_stroke_dash : public office_element_impl<draw_stroke_dash>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeStyleDrawStrokeDash;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
_CP_OPT(odf_types::length_or_percent) draw_distance_;
_CP_OPT(odf_types::length_or_percent) draw_dots1_length_;
_CP_OPT(odf_types::length_or_percent) draw_dots2_length_;
_CP_OPT(int) draw_dots1_;
_CP_OPT(int) draw_dots2_;
_CP_OPT(std::wstring) draw_style_; //rect or round:
_CP_OPT(std::wstring) draw_name_;
_CP_OPT(std::wstring) draw_display_name_;
friend class odf_document;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
};
CP_REGISTER_OFFICE_ELEMENT2(draw_stroke_dash);
//-------------------------------------------------------------------------------------------------
// draw:gradient
/////////////////////////////////////////////////////////////////////////////////////////////////
// style_draw_gradient
class draw_gradient : public office_element_impl<draw_gradient>
{
public:
@ -247,7 +189,7 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_gradient);
/////////////////////////////////////////////////////////////////////////////////////////////////
// draw:hatch
// style_draw_hatch
class draw_hatch : public office_element_impl<draw_hatch>
{
public:
@ -413,8 +355,8 @@ public:
office_element_ptr_array draw_opacity_;
office_element_ptr_array draw_hatch_;
office_element_ptr_array draw_marker_;
office_element_ptr_array draw_stroke_dash_;
office_element_ptr_array draw_marker_; // < TODO
office_element_ptr_array draw_stroke_dash_; // < TODO
office_element_ptr_array svg_linearGradient_; // < TODO
office_element_ptr_array svg_radialGradient_; // < TODO

View File

@ -185,11 +185,12 @@ namespace svg_path
return bUseRelativeCoordinates ? cLowerCaseCommand : cUpperCaseCommand;
}
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ, bool & bIsClosed)
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ)
{
Polyline.clear();
const int nLen(rSvgDStatement.length());
int nPos(0);
bool bIsClosed(false);
double nLastX( 0.0 );
double nLastY( 0.0 );
@ -199,8 +200,6 @@ namespace svg_path
_polyline aCurrPoly;
bIsClosed = false;
// skip initial whitespace
skipSpaces(nPos, rSvgDStatement, nLen);

View File

@ -58,7 +58,7 @@ namespace svg_path
};
bool parseVml(std::vector<_polyline> & Polyline, const std::wstring & path);
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool & bIsClosed);
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ);
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool closed);
}

View File

@ -57,8 +57,6 @@ void table_table_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
CP_APPLY_ATTR(L"table:protected", table_protected_, false);
CP_APPLY_ATTR(L"table:protection-key", table_protection_key_);
CP_APPLY_ATTR(L"table:protection-key-digest-algorithm", table_protection_key_digest_algorithm_);
CP_APPLY_ATTR(L"table:print", table_print_, true);
CP_APPLY_ATTR(L"table:print-ranges", table_print_ranges_);
@ -136,23 +134,7 @@ void table_table_source::add_child_element( xml::sax * Reader, const std::wstrin
{
CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:table-protection
const wchar_t * table_table_protection::ns = L"loext"; //?? table odf 1.3
const wchar_t * table_table_protection::name = L"table-protection";
void table_table_protection::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"loext:select-protected-cells", select_protected_cells);
CP_APPLY_ATTR(L"loext:select-unprotected-cells",select_unprotected_cells);
CP_APPLY_ATTR(L"loext:insert-columns", insert_columns);
CP_APPLY_ATTR(L"loext:insert-rows", insert_rows);
CP_APPLY_ATTR(L"loext:delete-columns", delete_columns);
CP_APPLY_ATTR(L"loext:delete-rows", delete_rows);
//CP_APPLY_ATTR(L"loext:format-columns", format_columns);
//CP_APPLY_ATTR(L"loext:format-rows", format_rows);
//CP_APPLY_ATTR(L"loext:format-cells", format_cells);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:table
const wchar_t * table_table::ns = L"table";
@ -162,7 +144,7 @@ void table_table::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"table:style-name", element_style_name);
attlist_.add_attributes(Attributes);
table_table_attlist_.add_attributes(Attributes);
}
void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -190,13 +172,9 @@ void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns,
else if CP_CHECK_NAME(L"table", L"shapes")
{
CP_CREATE_ELEMENT(table_shapes_);
}
else if ( L"table-protection" == Name) //ns = loext or table
{
CP_CREATE_ELEMENT(table_protection_);
}
else if ( CP_CHECK_NAME(L"table", L"named-expressions") ||
CP_CHECK_NAME(L"table", L"named-range") )
CP_CHECK_NAME(L"table", L"named-range") ) //???
{
CP_CREATE_ELEMENT(table_named_);
}

View File

@ -61,17 +61,15 @@ public:
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
bool table_protected_; // default false
bool table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
_CP_OPT(std::wstring) table_protection_key_digest_algorithm_;
bool table_print_; // default true
bool table_print_; // default true
_CP_OPT(std::wstring) table_print_ranges_;
bool table_use_first_row_styles_; // default false;
bool table_use_banding_rows_styles_; // defualt false;
bool table_use_first_column_styles_; // defualt false;
bool table_use_banding_columns_styles_; // defualt false;
bool table_use_banding_rows_styles_; //defualt false;
bool table_use_first_column_styles_; //defualt false;
bool table_use_banding_columns_styles_; //defualt false;
friend class table_table;
};
@ -619,38 +617,6 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_row_group);
class table_table_protection : public office_element_impl<table_table_protection>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableTableProtection;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) {}
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
virtual void pptx_convert(oox::pptx_conversion_context & Context) {}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
public:
_CP_OPT(bool) select_protected_cells;
_CP_OPT(bool) select_unprotected_cells;
_CP_OPT(bool) insert_columns;
_CP_OPT(bool) insert_rows;
_CP_OPT(bool) delete_columns;
_CP_OPT(bool) delete_rows;
//_CP_OPT(bool) format_columns; //???
//_CP_OPT(bool) format_rows;
//_CP_OPT(bool) format_cells;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_protection);
class table_table : public office_element_impl<table_table>
{
public:
@ -670,9 +636,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
table_table_attlist attlist_;
office_element_ptr table_protection_;
table_table_attlist table_table_attlist_;
table_columns_and_groups table_columns_and_groups_;
table_rows_and_groups table_rows_and_groups_;

View File

@ -87,7 +87,6 @@ void table_data_pilot_table::add_child_element( xml::sax * Reader, const std::ws
CP_CREATE_ELEMENT (source_);
}
void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (!source_) return;
@ -106,8 +105,6 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
std::wstring ref = formulas_converter.convert_named_ref(*table_target_range_address_, false);
sheet_name = formulas_converter.get_table_name();
Context.get_table_context().check_database_range_intersection(sheet_name, ref);
Context.get_pivots_context().set_view_target_range(ref);
Context.get_pivots_context().set_view_target_table_name(sheet_name);
}
@ -198,12 +195,10 @@ void table_data_pilot_field::xlsx_convert(oox::xlsx_conversion_context & Context
if (type == table_function::String)
{
std::wstring formula = table_function_->get_string();
formulasconvert::odf2oox_converter formulas_converter;
std::wstring oox_formula = formulas_converter.convert(formula);
Context.get_pivots_context().set_field_user_function(oox_formula);
std::wstring user_funtion = formulas_converter.convert(table_function_->get_string());
Context.get_pivots_context().set_field_user_function(user_funtion);
}
else
{

View File

@ -88,43 +88,24 @@ void table_database_range::add_child_element( xml::sax * Reader, const std::wstr
void table_database_range::xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (!table_target_range_address_) return;
if (!table_name_) return;
std::wstring name = table_name_.get();
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
if (pFind == Context.mapUsedNames_.end())
{
Context.mapUsedNames_.insert(std::make_pair(name, 1));
}
else
{
name += L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
Context.get_table_context().start_database_range(table_name_.get_value_or(L""), *table_target_range_address_);
if (Context.get_table_context().start_database_range(name, *table_target_range_address_))
{
if (table_display_filter_buttons_)
Context.get_table_context().set_database_filter(table_display_filter_buttons_->get());
if (table_display_filter_buttons_)
Context.get_table_context().set_database_filter(table_display_filter_buttons_->get());
if (table_orientation_)
Context.get_table_context().set_database_orientation(table_orientation_->get_type() == table_orientation::row ? true : false);
if (table_orientation_)
Context.get_table_context().set_database_orientation(table_orientation_->get_type() == table_orientation::row ? true : false);
if (table_contains_header_)
Context.get_table_context().set_database_header(table_contains_header_->get());
if (table_contains_header_)
Context.get_table_context().set_database_header(table_contains_header_->get());
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.get_table_context().end_database_range();
}
else
for (size_t i = 0; i < content_.size(); i++)
{
Context.get_xlsx_defined_names().add(name, table_target_range_address_.get(), false, -1);
content_[i]->xlsx_convert(Context);
}
Context.get_table_context().end_database_range();
}
//--------------------------------------------------------------------------------------------------

View File

@ -171,10 +171,10 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
}
}
bool sub_table = attlist_.table_is_sub_table_.get_value_or(false);
bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false);
//todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло)
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
_Wostream << L"<w:tbl>";

View File

@ -94,19 +94,8 @@ void table_named_range::xlsx_convert(oox::xlsx_conversion_context & Context)
{
tableId = Context.get_table_context().state()->get_table_id();
}
std::wstring name = table_name_.get();
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
if (pFind == Context.mapUsedNames_.end())
{
Context.mapUsedNames_.insert(std::make_pair(name, 1));
}
else
{
name += L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
Context.get_xlsx_defined_names().add(name, table_cell_range_address_.get(), false, tableId);
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
ctx.add(table_name_.get(), table_cell_range_address_.get(), false, tableId);
}
}
@ -141,18 +130,8 @@ void table_named_expression::xlsx_convert(oox::xlsx_conversion_context & Context
{
tableId = Context.get_table_context().state()->get_table_id();
}
std::wstring name = table_name_.get();
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
if (pFind == Context.mapUsedNames_.end())
{
Context.mapUsedNames_.insert(std::make_pair(name, 1));
}
else
{
name += L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
Context.get_xlsx_defined_names().add(name, table_expression_.get(), true, tableId);
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
ctx.add(table_name_.get(), table_expression_.get(), true, tableId);
}
}

View File

@ -159,13 +159,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_table();
//////////////////////////////////////////////////////////////////
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
Context.get_table_context().start_table(tableStyleName);
if (attlist_.table_template_name_)
if (table_table_attlist_.table_template_name_)
{
std::wstring name = L"table:" + attlist_.table_template_name_.get() ;
std::wstring name = L"table:" + table_table_attlist_.table_template_name_.get() ;
if (office_element_ptr style = Context.root()->odf_context().Templates().find_by_style_name(name))
{
if (table_table_template* template_ = dynamic_cast<table_table_template *>(style.get()))
@ -184,13 +184,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
_Wostream << L"<a:tbl>";
_Wostream << L"<a:tblPr";
if (attlist_.table_use_banding_rows_styles_)
if (table_table_attlist_.table_use_banding_rows_styles_)
_Wostream << L" bandRow=\"1\"";
if (attlist_.table_use_first_row_styles_)
if (table_table_attlist_.table_use_first_row_styles_)
_Wostream << L" firstRow=\"1\"";
if (attlist_.table_use_banding_columns_styles_)
if (table_table_attlist_.table_use_banding_columns_styles_)
_Wostream << L" bandCol=\"1\"";
if (attlist_.table_use_first_column_styles_)
if (table_table_attlist_.table_use_first_column_styles_)
_Wostream << L" firstCol=\"1\"";
_Wostream << ">";

View File

@ -69,10 +69,9 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
for (size_t i = 0 ; i < elements_.size(); i++)
{
elements_[i]->xlsx_convert(Context);
}
}
const int sharedStrId = Context.get_table_context().end_cell_content();
return sharedStrId;
}
@ -319,8 +318,8 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context)
void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = attlist_.table_name_.get_value_or(L"");
const std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = table_table_attlist_.table_name_.get_value_or(L"");
_CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl;
@ -340,16 +339,6 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
}
Context.start_table(tableName, tableStyleName);
if (attlist_.table_protected_)
{
Context.get_table_context().set_protection(true, attlist_.table_protection_key_.get_value_or(L""),
attlist_.table_protection_key_digest_algorithm_.get_value_or(L""));
table_table_protection* prot = dynamic_cast<table_table_protection*>( table_protection_.get() );
if (prot)
{
}
}
table_columns_and_groups_.xlsx_convert(Context);
// check last rows for equal style and empties - collapsed
@ -442,10 +431,8 @@ namespace {
// see ECMA-376 page 1768
double pixToSize(double pixels, double maxDigitSize)
{
if (pixels < 8) pixels = 8; //УВЕДОМЛЕНИЕ О ПРИБЫТИИ ИНОСТРАННОГО ГРАЖДАНИНА.ods
return (int(( pixels /*/ 0.75*/ - 5)/ maxDigitSize * 100. + 0.5)) /100. * 0.9; // * 9525. * 72.0 / (360000.0 * 2.54);
{
return (int(( pixels - 5)/ maxDigitSize * 100. + 0.5)) /100. * 0.9;
}
double cmToChars (double cm)
{
@ -774,10 +761,10 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
double s;
if (oox::parseTime(tv, h, m, s))
{
double dTime = oox::convertTime(h, m, s);
if (dTime >= 0)
boost::int64_t intTime = (boost::int64_t)oox::convertTime(h, m, s);
if (intTime > 0)
{
number_val = boost::lexical_cast<std::wstring>(dTime);
number_val = boost::lexical_cast<std::wstring>(intTime);
}
else
{
@ -853,31 +840,9 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
const int sharedStringId = content_.xlsx_convert(Context, &textFormatProperties);
//---------------------------------------------------------------------------------------------------------
if (t_val == oox::XlsxCellType::str || t_val == oox::XlsxCellType::inlineStr)
{
int index = Context.get_table_context().in_database_range();
if (index >= 0)
{
if (sharedStringId >= 0)
{
std::wstringstream strm;
content_.text_to_stream(strm);
Context.get_table_context().set_database_range_value(index, strm.str());
}
else if (str_val)
{
Context.get_table_context().set_database_range_value(index, str_val.get());
}
}
}
if (t_val == oox::XlsxCellType::str && sharedStringId >= 0)
{
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
}
//---------------------------------------------------------------------------------------------------------
if (skip_next_cell)break;
// пустые ячейки пропускаем.
@ -1160,7 +1125,7 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
const int sharedStringId = content_.xlsx_convert(Context, &textFormatProperties);
if (t_val == oox::XlsxCellType::str && sharedStringId >= 0)
if (t_val == oox::XlsxCellType::str && sharedStringId >=0)
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
if (skip_next_cell)break;
@ -1178,7 +1143,7 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
if (!formula.empty())
{
const std::wstring xlsxFormula = formulas_converter.convert(formula);
const std::wstring xlsxFormula = formulas_converter.convert(formula);
if (!xlsxFormula.empty())
{
CP_XML_NODE(L"f")

View File

@ -125,7 +125,7 @@ void process_paragraph_index(const paragraph_attrs & Attr, oox::docx_conversion_
std::wostream & paragraph::text_to_stream(std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(content_);
//_Wostream << L"\n";
_Wostream << L"\n";
return _Wostream;
}
@ -308,7 +308,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
}
}
}
if (next_section_/* || next_end_section_*/)//remove in text::section
if (next_section_/* || next_end_section_*/)
{
Context.get_section_context().get().is_dump_ = true;
is_empty = false;
@ -675,7 +675,6 @@ void section::add_child_element( xml::sax * Reader, const std::wstring & Ns, con
void section::docx_convert(oox::docx_conversion_context & Context)
{
bool bAddSection = false;
if ( false == Context.get_drawing_state_content())
{
std::wstring current_page_properties = Context.get_page_properties();
@ -683,8 +682,6 @@ void section::docx_convert(oox::docx_conversion_context & Context)
Context.get_section_context().add_section (section_attr_.name_, section_attr_.style_name_.get_value_or(L""), current_page_properties);
Context.add_page_properties(current_page_properties);
bAddSection = true;
}
else
{
@ -732,11 +729,6 @@ void section::docx_convert(oox::docx_conversion_context & Context)
}
content_[i]->docx_convert(Context);
}
if (bAddSection)
{
Context.get_section_context().get().is_dump_ = true;
Context.last_dump_page_properties(false);
}
}
// text-section-source-attr

View File

@ -42,7 +42,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\include"
AdditionalIncludeDirectories=""
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"

View File

@ -42,9 +42,9 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeAccentBorderCallout1 = 0,
{ L"" , 7}, // shapetypeAccentBorderCallout2,
{ L"" , 7}, // shapetypeAccentBorderCallout3,
{ L"" , 7}, // shapetypeAccentCallout1,
{ L"" , 7}, // shapetypeAccentCallout2,
{ L"" , 7}, // shapetypeAccentCallout3,
{ L"mso-spt44" , 7}, // shapetypeAccentCallout1,
{ L"mso-spt45" , 7}, // shapetypeAccentCallout2,
{ L"mso-spt46" , 7}, // shapetypeAccentCallout3,
{ L"actionButtonBackPrevious" , 7}, // shapetypeActionButtonBackPrevious, //mso-spt194
{ L"mso-spt196" , 7}, // shapetypeActionButtonBeginning,
{ L"mso-spt189" , 7}, // shapetypeActionButtonBlank,
@ -58,23 +58,23 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"mso-spt197" , 7}, // shapetypeActionButtonReturn,
{ L"mso-spt199" , 7}, // shapetypeActionButtonSound,
{ L"" , 7}, // shapetypeArc,
{ L"" , 7}, // shapetypeBentArrow,
{ L"" , 9}, // shapetypeBentConnector2,
{ L"" , 9}, // shapetypeBentConnector3,
{ L"" , 9}, // shapetypeBentConnector4,
{ L"" , 9}, // shapetypeBentConnector5,
{ L"mso-spt91" , 7}, // shapetypeBentArrow,
{ L"mso-spt33" , 7}, // shapetypeBentConnector2,
{ L"mso-spt34" , 7}, // shapetypeBentConnector3,
{ L"mso-spt35" , 7}, // shapetypeBentConnector4,
{ L"mso-spt36" , 7}, // shapetypeBentConnector5,
{ L"" , 7}, // shapetypeBentUpArrow,
{ L"" , 7}, // shapetypeBevel,
{ L"quad-bevel" , 7}, // shapetypeBevel,
{ L"" , 7}, // shapetypeBlockArc,
{ L"" , 7}, // shapetypeBorderCallout1,
{ L"" , 7}, // shapetypeBorderCallout2,
{ L"" , 7}, // shapetypeBorderCallout3,
{ L"" , 7}, // shapetypeBracePair,
{ L"mso-spt49" , 7}, // shapetypeBorderCallout1,
{ L"mso-spt50" , 7}, // shapetypeBorderCallout2,
{ L"mso-spt51" , 7}, // shapetypeBorderCallout3,
{ L"brace-pair" , 7}, // shapetypeBracePair,
{ L"" , 7}, // shapetypeBracketPair,
{ L"" , 7}, // shapetypeCallout1,
{ L"" , 7}, // shapetypeCallout2,
{ L"" , 7}, // shapetypeCallout3,
{ L"" , 7}, // shapetypeCan,
{ L"mso-spt41" , 7}, // shapetypeCallout1,
{ L"mso-spt42" , 7}, // shapetypeCallout2,
{ L"mso-spt43" , 7}, // shapetypeCallout3,
{ L"can" , 7}, // shapetypeCan,
{ L"" , 7}, // shapetypeChartPlus,
{ L"" , 7}, // shapetypeChartStar,
{ L"" , 7}, // shapetypeChartX,
@ -82,18 +82,18 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeChord,
{ L"" , 7}, // shapetypeCircularArrow,
{ L"cloud" , 7}, // shapetypeCloud,
{ L"" , 7}, // shapetypeCloudCallout,
{ L"cloud-callout" , 7}, // shapetypeCloudCallout,
{ L"" , 7}, // shapetypeCorner,
{ L"" , 7}, // shapetypeCornerTabs,
{ L"" , 7}, // shapetypeCube,
{ L"" , 10}, // shapetypeCurvedConnector2,
{ L"" , 10}, // shapetypeCurvedConnector3,
{ L"" , 10}, // shapetypeCurvedConnector4,
{ L"" , 10}, // shapetypeCurvedConnector5,
{ L"cube" , 7}, // shapetypeCube,
{ L"mso-spt37" , 7}, // shapetypeCurvedConnector2,
{ L"mso-spt38" , 7}, // shapetypeCurvedConnector3,
{ L"mso-spt39" , 7}, // shapetypeCurvedConnector4,
{ L"mso-spt40" , 7}, // shapetypeCurvedConnector5,
{ L"" , 7}, // shapetypeCurvedDownArrow,
{ L"" , 7}, // shapetypeCurvedLeftArrow,
{ L"" , 7}, // shapetypeCurvedRightArrow,
{ L"" , 7}, // shapetypeCurvedUpArrow,
{ L"mso-spt104" , 7}, // shapetypeCurvedUpArrow,
{ L"" , 7}, // shapetypeDecagon,
{ L"" , 7}, // shapetypeDiagStripe,
{ L"" , 7}, // shapetypeDiamond,
@ -103,8 +103,8 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeDownArrow,
{ L"" , 7}, // shapetypeDownArrowCallout,
{ L"ellipse" , 3}, // shapetypeEllipse,
{ L"" , 7}, // shapetypeEllipseRibbon,
{ L"" , 7}, // shapetypeEllipseRibbon2,
{ L"mso-spt107" , 7}, // shapetypeEllipseRibbon,
{ L"mso-spt108" , 7}, // shapetypeEllipseRibbon2,
{ L"flowchart-alternate-process" , 7}, // shapetypeFlowChartAlternateProcess,
{ L"flowchart-collate" , 7}, // shapetypeFlowChartCollate,
{ L"flowchart-connector" , 7}, // shapetypeFlowChartConnector,
@ -134,23 +134,23 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"flowchart-sort" , 7}, // shapetypeFlowChartSort,
{ L"flowchart-summing-junction" , 7}, // shapetypeFlowChartSummingJunction,
{ L"flowchart-terminator" , 7}, // shapetypeFlowChartTerminator,
{ L"" , 7}, // shapetypeFoldedCorner,
{ L"paper" , 7}, // shapetypeFoldedCorner,
{ L"" , 7}, // shapetypeFrame,
{ L"" , 7}, // shapetypeFunnel,
{ L"" , 7}, // shapetypeGear6,
{ L"" , 7}, // shapetypeGear9,
{ L"" , 7}, // shapetypeHalfFrame,
{ L"" , 7}, // shapetypeHeart,
{ L"heart" , 7}, // shapetypeHeart,
{ L"" , 7}, // shapetypeHeptagon,
{ L"" , 7}, // shapetypeHexagon,
{ L"hexagon" , 7}, // shapetypeHexagon,
{ L"" , 7}, // shapetypeHomePlate,
{ L"horizontal-scroll" , 7}, // shapetypeHorizontalScroll,
{ L"" , 7}, // shapetypeIrregularSeal1,
{ L"" , 7}, // shapetypeIrregularSeal2,
{ L"" , 7}, // shapetypeLeftArrow,
{ L"" , 7}, // shapetypeLeftArrowCallout,
{ L"" , 7}, // shapetypeLeftBrace,
{ L"" , 7}, // shapetypeLeftBracket,
{ L"left-brace" , 7}, // shapetypeLeftBrace,
{ L"left-bracket" , 7}, // shapetypeLeftBracket,
{ L"" , 7}, // shapetypeLeftCircularArrow,
{ L"" , 7}, // shapetypeLeftRightArrow,
{ L"left-right-arrow-callout" , 7}, // shapetypeLeftRightArrowCallout,
@ -158,7 +158,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeLeftRightRibbon,
{ L"" , 7}, // shapetypeLeftRightUpArrow,
{ L"" , 7}, // shapetypeLeftUpArrow,
{ L"" , 7}, // shapetypeLightningBolt,
{ L"lightning" , 7}, // shapetypeLightningBolt,
{ L"" , 5}, // shapetypeLine,
{ L"" , 7}, // shapetypeLineInv,
{ L"" , 7}, // shapetypeMathDivide,
@ -167,27 +167,27 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeMathMultiply,
{ L"" , 7}, // shapetypeMathNotEqual,
{ L"" , 7}, // shapetypeMathPlus,
{ L"" , 7}, // shapetypeMoon,
{ L"moon" , 7}, // shapetypeMoon,
{ L"" , 7}, // shapetypeNonIsoscelesTrapezoid,
{ L"forbidden" , 7}, // shapetypeNoSmoking,
{ L"" , 7}, // shapetypeNotchedRightArrow,
{ L"" , 7}, // shapetypeOctagon,
{ L"octagon" , 7}, // shapetypeOctagon,
{ L"" , 7}, // shapetypeParallelogram,
{ L"" , 7}, // shapetypePentagon,
{ L"pentagon" , 7}, // shapetypePentagon,
{ L"" , 7}, // shapetypePie,
{ L"" , 7}, // shapetypePieWedge,
{ L"" , 7}, // shapetypePlaque,
{ L"" , 7}, // shapetypePlaqueTabs,
{ L"" , 7}, // shapetypePlus,
{ L"quad-arrow" , 7}, // shapetypeQuadArrow,
{ L"" , 7}, // shapetypeQuadArrowCallout,
{ L"quad-arrow-callout" , 7}, // shapetypeQuadArrowCallout,
{ L"rectangle" , 2}, // shapetypeRect,
{ L"" , 7}, // shapetypeRibbon,
{ L"" , 7}, // shapetypeRibbon2,
{ L"mso-spt53" , 7}, // shapetypeRibbon,
{ L"mso-spt54" , 7}, // shapetypeRibbon2,
{ L"" , 7}, // shapetypeRightArrow,
{ L"" , 7}, // shapetypeRightArrowCallout,
{ L"" , 7}, // shapetypeRightBrace,
{ L"" , 7}, // shapetypeRightBracket,
{ L"right-brace" , 7}, // shapetypeRightBrace,
{ L"right-bracket" , 7}, // shapetypeRightBracket,
{ L"" , 7}, // shapetypeRound1Rect,
{ L"" , 7}, // shapetypeRound2DiagRect,
{ L"" , 7}, // shapetypeRound2SameRect,
@ -209,7 +209,7 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"" , 7}, // shapetypeStar6,
{ L"" , 7}, // shapetypeStar7,
{ L"star8" , 7}, // shapetypeStar8,
{ L"" , 5}, // shapetypeStraightConnector1,
{ L"mso-spt32" , 9}, // shapetypeStraightConnector1,
{ L"striped-right-arrow" , 7}, // shapetypeStripedRightArrow,
{ L"" , 7}, // shapetypeSun,
{ L"" , 7}, // shapetypeSwooshArrow,
@ -223,9 +223,9 @@ static const _sh_typ Shape_Types_Mapping[] = // index === OOX::Drawing::EShapeTy
{ L"mso-spt101" , 7}, // shapetypeUturnArrow,
{ L"vertical-scroll" , 7}, // shapetypeVerticalScroll,
{ L"" , 7}, // shapetypeWave,
{ L"" , 7}, // shapetypeWedgeEllipseCallout,
{ L"" , 7}, // shapetypeWedgeRectCallout,
{ L"" , 7}, // shapetypeWedgeRoundRectCallout,
{ L"round-callout" , 7}, // shapetypeWedgeEllipseCallout,
{ L"rectangular-callout" , 7}, // shapetypeWedgeRectCallout,
{ L"round-rectangular-callout" , 7}, // shapetypeWedgeRoundRectCallout,
{ L"mso-spt17" , 7}, // shapetypeBallon,
{ L"up-right-arrow" , 7}, // shapetypeRightUpArrow,
{ L"fontwork-arch-down-pour" , 7}, // shapetypeTextArchDownPour,

View File

@ -31,336 +31,11 @@
*/
#include "../oox_shape_defines.h"
//+ shapetypeAccentBorderCallout1,
//+ shapetypeAccentBorderCallout2,
//+ shapetypeAccentBorderCallout3,
//+ shapetypeAccentCallout1
//+ shapetypeAccentCallout2
//+ shapetypeAccentCallout3
//+ shapetypeBorderCallout1
//+ shapetypeBorderCallout2
//+ shapetypeBorderCallout3
// shapetypeAccentBorderCallout1,
// shapetypeAccentBorderCallout2,
// shapetypeAccentBorderCallout3,
namespace cpdoccore
{
class oox_shape_AccentCallout1 : public oox_shape
{
public:
oox_shape_AccentCallout1()
{
odf_type_name =L"ooxml-accentCallout1";
enhanced_path = L"S M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f2 L ?f9 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 112500 -38333";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f13 / 100000");
add(L"f9", L"?f5 * ?f12 / 100000");
add(L"f10", L"?f4 * ?f15 / 100000");
add(L"f11", L"?f5 * ?f14 / 100000");
add(L"f12", L"$1 / ?f7");
add(L"f13", L"$0 / ?f7");
add(L"f14", L"$3 / ?f7");
add(L"f15", L"$2 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_AccentCallout2 : public oox_shape
{
public:
oox_shape_AccentCallout2()
{
odf_type_name =L"ooxml-accentCallout2";
enhanced_path = L"S M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f2 L ?f9 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 ?f13 ?f12 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 18750 -16667 112500 -46667";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f15 / 100000");
add(L"f9", L"?f5 * ?f14 / 100000");
add(L"f10", L"?f4 * ?f17 / 100000");
add(L"f11", L"?f5 * ?f16 / 100000");
add(L"f12", L"?f4 * ?f19 / 100000");
add(L"f13", L"?f5 * ?f18 / 100000");
add(L"f14", L"$1 / ?f7");
add(L"f15", L"$0 / ?f7");
add(L"f16", L"$3 / ?f7");
add(L"f17", L"$2 / ?f7");
add(L"f18", L"$5 / ?f7");
add(L"f19", L"$4 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_AccentCallout3 : public oox_shape
{
public:
oox_shape_AccentCallout3()
{
odf_type_name =L"ooxml-accentCallout3";
enhanced_path = L"S M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f2 L ?f9 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 ?f13 ?f12 ?f15 ?f14 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 18750 -16667 100000 -16667 112963 -8333";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f17 / 100000");
add(L"f9", L"?f5 * ?f16 / 100000");
add(L"f10", L"?f4 * ?f19 / 100000");
add(L"f11", L"?f5 * ?f18 / 100000");
add(L"f12", L"?f4 * ?f21 / 100000");
add(L"f13", L"?f5 * ?f20 / 100000");
add(L"f14", L"?f4 * ?f23 / 100000");
add(L"f15", L"?f5 * ?f22 / 100000");
add(L"f16", L"$1 / ?f7");
add(L"f17", L"$0 / ?f7");
add(L"f18", L"$3 / ?f7");
add(L"f19", L"$2 / ?f7");
add(L"f20", L"$5 / ?f7");
add(L"f21", L"$4 / ?f7");
add(L"f22", L"$7 / ?f7");
add(L"f23", L"$6 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_BorderCallout1 : public oox_shape
{
public:
oox_shape_BorderCallout1()
{
odf_type_name =L"ooxml-borderCallout1";
enhanced_path = L"M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 112500 -38333";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f13 / 100000");
add(L"f9", L"?f5 * ?f12 / 100000");
add(L"f10", L"?f4 * ?f15 / 100000");
add(L"f11", L"?f5 * ?f14 / 100000");
add(L"f12", L"$1 / ?f7");
add(L"f13", L"$0 / ?f7");
add(L"f14", L"$3 / ?f7");
add(L"f15", L"$2 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_BorderCallout2 : public oox_shape
{
public:
oox_shape_BorderCallout2()
{
odf_type_name =L"ooxml-borderCallout2";
enhanced_path = L"M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 ?f13 ?f12 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 18750 -16667 112500 -46667";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f15 / 100000");
add(L"f9", L"?f5 * ?f14 / 100000");
add(L"f10", L"?f4 * ?f17 / 100000");
add(L"f11", L"?f5 * ?f16 / 100000");
add(L"f12", L"?f4 * ?f19 / 100000");
add(L"f13", L"?f5 * ?f18 / 100000");
add(L"f14", L"$1 / ?f7");
add(L"f15", L"$0 / ?f7");
add(L"f16", L"$3 / ?f7");
add(L"f17", L"$2 / ?f7");
add(L"f18", L"$5 / ?f7");
add(L"f19", L"$4 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_BorderCallout3 : public oox_shape
{
public:
oox_shape_BorderCallout3()
{
odf_type_name =L"ooxml-borderCallout3";
enhanced_path = L"M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 ?f13 ?f12 ?f15 ?f14 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 18750 -16667 100000 -16667 112963 -8333";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f17 / 100000");
add(L"f9", L"?f5 * ?f16 / 100000");
add(L"f10", L"?f4 * ?f19 / 100000");
add(L"f11", L"?f5 * ?f18 / 100000");
add(L"f12", L"?f4 * ?f21 / 100000");
add(L"f13", L"?f5 * ?f20 / 100000");
add(L"f14", L"?f4 * ?f23 / 100000");
add(L"f15", L"?f5 * ?f22 / 100000");
add(L"f16", L"$1 / ?f7");
add(L"f17", L"$0 / ?f7");
add(L"f18", L"$3 / ?f7");
add(L"f19", L"$2 / ?f7");
add(L"f20", L"$5 / ?f7");
add(L"f21", L"$4 / ?f7");
add(L"f22", L"$7 / ?f7");
add(L"f23", L"$6 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_AccentBorderCallout1 : public oox_shape
{
public:
oox_shape_AccentBorderCallout1()
{
odf_type_name =L"ooxml-accentBorderCallout1";
enhanced_path = L"M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f2 L ?f9 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 112500 -38333";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f13 / 100000");
add(L"f9", L"?f5 * ?f12 / 100000");
add(L"f10", L"?f4 * ?f15 / 100000");
add(L"f11", L"?f5 * ?f14 / 100000");
add(L"f12", L"$1 / ?f7");
add(L"f13", L"$0 / ?f7");
add(L"f14", L"$3 / ?f7");
add(L"f15", L"$2 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_AccentBorderCallout2 : public oox_shape
{
public:
oox_shape_AccentBorderCallout2()
{
odf_type_name =L"ooxml-accentBorderCallout2";
enhanced_path = L"M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f2 L ?f9 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 ?f13 ?f12 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 18750 -16667 112500 -46667";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f15 / 100000");
add(L"f9", L"?f5 * ?f14 / 100000");
add(L"f10", L"?f4 * ?f17 / 100000");
add(L"f11", L"?f5 * ?f16 / 100000");
add(L"f12", L"?f4 * ?f19 / 100000");
add(L"f13", L"?f5 * ?f18 / 100000");
add(L"f14", L"$1 / ?f7");
add(L"f15", L"$0 / ?f7");
add(L"f16", L"$3 / ?f7");
add(L"f17", L"$2 / ?f7");
add(L"f18", L"$5 / ?f7");
add(L"f19", L"$4 / ?f7");
/////////////////////////////////////////////////////////
}
};
class oox_shape_AccentBorderCallout3 : public oox_shape
{
public:
oox_shape_AccentBorderCallout3()
{
odf_type_name =L"ooxml-accentBorderCallout3";
enhanced_path = L"M ?f0 ?f2 L ?f1 ?f2 ?f1 ?f3 ?f0 ?f3 Z N F M ?f9 ?f2 L ?f9 ?f3 Z N F M ?f9 ?f8 L ?f11 ?f10 ?f13 ?f12 ?f15 ?f14 N";
text_areas = L"?f0 ?f2 ?f1 ?f3";
view_box = L"0 0 21600 21600";
modifiers = L"18750 -8333 18750 -16667 100000 -16667 112963 -8333";
add(L"f0", L"left");
add(L"f1", L"right");
add(L"f2", L"top");
add(L"f3", L"bottom");
add(L"f4", L"?f3 - ?f2");
add(L"f5", L"?f1 - ?f0");
add(L"f6", L"min(?f5, ?f4)");
add(L"f7", L"?f6 / 21600");
add(L"f8", L"?f4 * ?f17 / 100000");
add(L"f9", L"?f5 * ?f16 / 100000");
add(L"f10", L"?f4 * ?f19 / 100000");
add(L"f11", L"?f5 * ?f18 / 100000");
add(L"f12", L"?f4 * ?f21 / 100000");
add(L"f13", L"?f5 * ?f20 / 100000");
add(L"f14", L"?f4 * ?f23 / 100000");
add(L"f15", L"?f5 * ?f22 / 100000");
add(L"f16", L"$1 / ?f7");
add(L"f17", L"$0 / ?f7");
add(L"f18", L"$3 / ?f7");
add(L"f19", L"$2 / ?f7");
add(L"f20", L"$5 / ?f7");
add(L"f21", L"$4 / ?f7");
add(L"f22", L"$7 / ?f7");
add(L"f23", L"$6 / ?f7");
/////////////////////////////////////////////////////////
}
};
}

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