Commit 2f6c564e authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatReader - custom vml shape

parent 17047e6d
......@@ -72,7 +72,6 @@ namespace NSPresentationEditor
public:
std::vector<long> m_arAdjustments;
std::vector<double> m_arGuides;
public:
LONG m_eJoin;
bool m_bConcentricFill;
bool m_bCustomShape;
......@@ -93,7 +92,6 @@ namespace NSPresentationEditor
CPath m_oPath;
public:
CBaseShape()
{
m_bCustomShape = false;
......
......@@ -71,11 +71,60 @@ namespace NSCustomVML
~CSegment()
{
}
int Read(WORD value)
{
int repeate = 0;
if (value >= 0x2000 && value < 0x20FF)
{
repeate = value & 0x0FFF;
value &= 0xFF00;
}
m_nCount = 0;
switch (value)
{
case 0x0001: // lineto
m_eRuler = rtLineTo;
m_nCount = 1;
break;
case 0x4000: // moveto
m_eRuler = rtMoveTo;
m_nCount = 1;
break;
case 0x2000: // curveto
m_eRuler = rtCurveTo;
m_nCount = 3;
break;
case 0xb300: // arcto
m_eRuler = rtArc;
m_nCount = 2;
break;
case 0xac00:
case 0xaa00: // nofill
case 0xad00:
m_eRuler = rtNoFill;
break;
case 0xab00: // nostroke
m_eRuler = rtNoStroke;
break;
case 0x6001: // close
m_eRuler = rtClose;
break;
case 0x8000: // end
m_eRuler = rtEnd;
break;
default: // given number of lineto elements
m_eRuler = rtLineTo;
m_nCount = value;
break;
}
return max(1, repeate);
}
void Read(POLE::Stream* pStream)
{
WORD mem = StreamUtils::ReadWORD(pStream);
BYTE type = mem & 0x07;
if (type <= 4)
{
m_eRuler = (RulesType)type;
......@@ -489,18 +538,48 @@ namespace NSCustomVML
{
}
public:
bool IsCustom()
{
return (m_bIsVerticesPresent && m_bIsPathPresent);
}
public:
void SetPath(RulesType ePath)
{
m_ePath = ePath;
m_bIsPathPresent = true;
}
void LoadVertices(std::vector<std::pair<int,int>> values)
{
if (!values.empty())
m_bIsVerticesPresent = true;
m_arVertices.clear();
for (int ind = 0; ind < values.size(); ++ind)
{
Aggplus::POINT oPoint;
oPoint.x = values[ind].first;
oPoint.y = values[ind].second;
LONG lMinF = (LONG)0x80000000;
LONG lMaxF = (LONG)0x8000007F;
if (lMinF <= (DWORD)oPoint.x)
{
int nGuideIndex = (DWORD)oPoint.x - 0x80000000;
bool b = false;
}
if (lMinF <= (DWORD)oPoint.y)
{
int nGuideIndex = (DWORD)oPoint.y - 0x80000000;
bool b = false;
}
m_arVertices.push_back(oPoint);
}
}
void LoadVertices(CProperty* pProperty)
{
NSOfficeDrawing::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
......@@ -554,6 +633,32 @@ namespace NSCustomVML
void LoadAHs(CProperty* pProperty)
{
}
void LoadSegments(std::vector<int> values)
{
m_arSegments.clear();
if (!values.empty())
m_bIsPathPresent = true;
for (int ind = 0; ind < values.size(); ++ind)
{
CSegment oInfo;
int count = oInfo.Read(values[ind]);
if (0 == oInfo.m_nCount)
{
if ((rtEnd != oInfo.m_eRuler) &&
(rtNoFill != oInfo.m_eRuler) &&
(rtNoStroke != oInfo.m_eRuler) &&
(rtClose != oInfo.m_eRuler))
{
continue;
}
}
for (int i = 0 ; i < count; i++)
m_arSegments.push_back(oInfo);
}
}
void LoadSegments(CProperty* pProperty)
{
NSOfficeDrawing::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
......@@ -561,10 +666,7 @@ namespace NSCustomVML
WORD lCount = (WORD)(pProperty->m_lValue / 2);
if (lCount > 0)
{
m_bIsPathPresent = true;
}
if (lCount > 0) m_bIsPathPresent = true;
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
{
......
......@@ -43,7 +43,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;PPT_DEF"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
......
......@@ -2428,16 +2428,16 @@ void ParagraphPropDestination::Finalize( RtfReader& oReader/*, RtfSectionPtr pSe
else if( _T("anchorText") == m_sPropName ) m_oShape.m_nAnchorText = nValue;
//Geometry
else if( _T("adjustValue") == m_sPropName ) m_oShape.m_nAdjustValue = nValue;
else if( _T("adjust2Value") == m_sPropName ) m_oShape.m_nAdjustValue2 = nValue;
else if( _T("adjust3Value") == m_sPropName ) m_oShape.m_nAdjustValue3 = nValue;
else if( _T("adjust4Value") == m_sPropName ) m_oShape.m_nAdjustValue4 = nValue;
else if( _T("adjust5Value") == m_sPropName ) m_oShape.m_nAdjustValue5 = nValue;
else if( _T("adjust6Value") == m_sPropName ) m_oShape.m_nAdjustValue6 = nValue;
else if( _T("adjust7Value") == m_sPropName ) m_oShape.m_nAdjustValue7 = nValue;
else if( _T("adjust8Value") == m_sPropName ) m_oShape.m_nAdjustValue8 = nValue;
else if( _T("adjust9Value") == m_sPropName ) m_oShape.m_nAdjustValue9 = nValue;
else if( _T("adjust10Value") == m_sPropName ) m_oShape.m_nAdjustValue10 = nValue;
else if( _T("adjustValue") == m_sPropName ) m_oShape.m_nAdjustValue[0] = nValue;
else if( _T("adjust2Value") == m_sPropName ) m_oShape.m_nAdjustValue[1] = nValue;
else if( _T("adjust3Value") == m_sPropName ) m_oShape.m_nAdjustValue[2] = nValue;
else if( _T("adjust4Value") == m_sPropName ) m_oShape.m_nAdjustValue[3] = nValue;
else if( _T("adjust5Value") == m_sPropName ) m_oShape.m_nAdjustValue[4] = nValue;
else if( _T("adjust6Value") == m_sPropName ) m_oShape.m_nAdjustValue[5] = nValue;
else if( _T("adjust7Value") == m_sPropName ) m_oShape.m_nAdjustValue[6] = nValue;
else if( _T("adjust8Value") == m_sPropName ) m_oShape.m_nAdjustValue[7] = nValue;
else if( _T("adjust9Value") == m_sPropName ) m_oShape.m_nAdjustValue[8] = nValue;
else if( _T("adjust10Value") == m_sPropName ) m_oShape.m_nAdjustValue[9] = nValue;
//WordArt Effects
else if( _T("cropFromTop") == m_sPropName ) m_oShape.m_nCropFromTop = nValue;
else if( _T("cropFromBottom") == m_sPropName ) m_oShape.m_nCropFromBottom = nValue;
......
......@@ -32,6 +32,10 @@
#include "OOXShapeReader.h"
#include "OOXTextItemReader.h"
#include "../../../ASCOfficePPTXFile/Editor/Drawing/Shapes/BaseShape/PPTShape/PPTShape.h"
#include <boost/algorithm/string.hpp>
bool ParseStyle(RtfShape* pShape, SimpleTypes::Vml::CCssProperty* prop)
{
if (pShape == NULL) return false;
......@@ -512,8 +516,13 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
if (OOX::Vml::CShapeType* shape_type = dynamic_cast<OOX::Vml::CShapeType*>(m_vmlElement))
{
if (oOutput->m_nShapeType == PROP_DEF)
oOutput->m_nShapeType = NSOfficeDrawing::sptNotPrimitive;
if (shape_type->m_oSpt.IsInit())
{
oOutput->m_nShapeType = shape_type->m_oSpt->GetValue();
}
if (shape_type->m_sId.IsInit())
{
if (oParam.oReader->m_mapShapeTypes.find(shape_type->m_sId.get()) ==
......@@ -532,6 +541,10 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
if (shape->m_oAdj.IsInit())
ParseAdjustment( *oOutput, shape->m_oAdj.get() );
if (shape->m_oSpt.IsInit())
{
oOutput->m_nShapeType = shape->m_oSpt->GetValue();
}
if (shape->m_sType.IsInit())
{
CString type = shape->m_sType.get().Mid(1);//without #
......@@ -542,17 +555,20 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
OOXShapeReader sub_reader(it->second);
sub_reader.Parse(oParam, oOutput);
}
if (oOutput->m_nShapeType == PROP_DEF)
{
int pos = shape->m_sType->Find(_T("#_x0000_t"));
if (pos >= 0)
{
oOutput->m_nShapeType = _wtoi(shape->m_sType->Mid(pos + 9, shape->m_sType->GetLength() - pos - 9).GetString());
}
}
else
}
else if (oOutput->m_nShapeType == PROP_DEF)
{
oOutput->m_nShapeType = NSOfficeDrawing::sptNotPrimitive;
custom_path = shape->m_oPath.GetPointer();
}
custom_path = shape->m_oPath.GetPointer();
}
else if (OOX::Vml::CRect* rect = dynamic_cast<OOX::Vml::CRect*>(m_vmlElement))
{
......@@ -758,3 +774,26 @@ bool OOXShapeGroupReader::Parse( ReaderParameter oParam , RtfShapeGroupPtr& oOut
}
return true;
}
void OOXShapeReader::ParseAdjustment(RtfShape& oShape, CString sAdjustment)
{
std::wstring sValue_(sAdjustment.GetBuffer());
std::vector< std::wstring > splitted;
boost::algorithm::split(splitted, sValue_, boost::algorithm::is_any_of(L","), boost::algorithm::token_compress_on);
for (int i = 0; i < splitted.size(); i++)
{
if (!splitted[i].empty())
{
try
{
oShape.m_nAdjustValue[i] = _wtoi(splitted[i].c_str());
}
catch(...)
{
oShape.m_nAdjustValue[i] = 0;
}
}
}
}
\ No newline at end of file
......@@ -53,50 +53,7 @@ public:
bool Parse( ReaderParameter oParam , RtfShapePtr& oOutput);
bool Parse2( ReaderParameter oParam , RtfShapePtr& oOutput);
void ParseAdjustment(RtfShape& oShape, CString sAdjustment)
{
int nPosition = 0;
CString sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue2 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue3 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue4 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue5 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue6 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue7 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue8 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue9 = Strings::ToInteger( sAdj );
sAdj = sAdjustment.Tokenize(_T(","), nPosition);
if( _T("") == sAdj )
return;
oShape.m_nAdjustValue10 = Strings::ToInteger( sAdj );
}
void ParseAdjustment(RtfShape& oShape, CString sAdjustment);
private:
OOX::Vml::CVmlCommonElements *m_vmlElement;
......
......@@ -31,7 +31,6 @@
*/
#pragma once
#include "RtfPicture.h"
#include "../../../ASCOfficePPTXFile/Editor/Drawing/Enums.h"
class RtfShape: public IRenderableProperty
{
......@@ -101,20 +100,20 @@ public:
CString m_sMetroBlobData;
//Object Type
int m_bIsBullet; //fIsBullet Indicates whether a picture was inserted as a picture bullet.
int m_nRotation; //rotation Rotation of the shape. Angle 0
int m_bFlipV; //fFlipV Vertical flip, applied after the rotation. Boolean FALSE
int m_bFlipH; //fFlipH Horizontal flip, applied after the rotation. Boolean FALSE
int m_nShapeType; //shapeType See below for values. 0 indicates user-drawn freeforms and polygons. Not applicable Not applicable
int m_nRotation;
int m_bFlipV;
int m_bFlipH;
int m_nShapeType; // 0 indicates user-drawn freeforms and polygons
int m_nWrapDistLeft; //dxWrapDistLeft Left wrapping distance from text.
int m_nWrapDistLeft;
int m_nWrapDistTop;
int m_nWrapDistRight;
int m_nWrapDistBottom;
int m_bHidden; //Do not display or print (only set through Visual Basic for Applications). Boolean FALSE
int m_bHidden; //Do not display or print
//Text box
int m_nAnchorText;
int m_nTexpLeft; //dxTextLeft Left internal margin of the text box. EMU 91,440
int m_nTexpLeft; //in EMU
int m_nTexpTop;
int m_nTexpRight;
int m_nTexpBottom;
......@@ -124,16 +123,7 @@ public:
int m_nTxdir; //bidi
int m_nWrapText;
//Geometry
int m_nAdjustValue; //adjustValue First adjust value from an adjust handle. The interpretation varies with the shape type. Adjust values alter the geometry of the shape in smart ways. Integer 0
int m_nAdjustValue2;
int m_nAdjustValue3;
int m_nAdjustValue4;
int m_nAdjustValue5;
int m_nAdjustValue6;
int m_nAdjustValue7;
int m_nAdjustValue8;
int m_nAdjustValue9;
int m_nAdjustValue10;
int m_nAdjustValue[10];
//Custom
int m_nGeoLeft;
int m_nGeoTop;
......
......@@ -343,6 +343,42 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\ChartFromToBinary.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\DocWrapper\ChartWriter.cpp"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Common\Common.cpp"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\CommonWriter.cpp"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Reader\CSVReader.cpp"
>
</File>
<File
RelativePath="..\..\..\XlsxSerializerCom\Writer\CSVWriter.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\DocWrapper\DocxSerializer.cpp"
>
</File>
<File
RelativePath="..\..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\DocWrapper\FontProcessor.cpp"
>
</File>
<File
RelativePath="..\..\..\Common\DocxFormat\Source\XML\libxml2\libxml2.cpp"
>
......@@ -391,6 +427,14 @@
RelativePath="..\RtfFormatTest.cpp"
>
</File>
<File
RelativePath="..\..\..\UnicodeConverter\UnicodeConverter.cpp"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\DocWrapper\XlsxSerializer.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
......@@ -398,6 +442,14 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<File
RelativePath="..\..\..\build\bin\icu\win_32\icudt.lib"
>
</File>
<File
RelativePath="..\..\..\build\bin\icu\win_32\icuuc.lib"
>
</File>
</Files>
<Globals>
</Globals>
......
This diff is collapsed.
......@@ -312,7 +312,6 @@ namespace OOX
{
// Выставляем значения по умолчанию
m_oHrPct.SetValue( 0 );
m_oSpt.SetValue( 0 );
// Читаем атрибуты
if ( oReader.GetAttributesCount() <= 0 )
......@@ -548,8 +547,8 @@ namespace OOX
ComplexTypes_WriteAttribute ( _T("insetpen=\""), m_oInsetPen );
if ( 0 != m_oSpt.GetValue() )
sResult += _T("o:spt=\"") + m_oSpt.ToString() + _T("\" ");
if ( m_oSpt.IsInit() )
sResult += _T("o:spt=\"") + m_oSpt->ToString() + _T("\" ");
if (m_oConnectorType.IsInit())
{
......
......@@ -120,7 +120,7 @@ namespace OOX
nullable<SimpleTypes::CEmu> m_oStrokeWeight;
nullable<SimpleTypes::CTrueFalse<>> m_oInsetPen;
// 2.2 AG_OfficeShapeAttributes
SimpleTypes::CDecimalNumber<> m_oSpt;
nullable<SimpleTypes::CDecimalNumber<>> m_oSpt;
nullable<SimpleTypes::CConnectorType<>> m_oConnectorType;
nullable<SimpleTypes::CBWMode<>> m_oBwMode;
nullable<SimpleTypes::CBWMode<>> m_oBwPure;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment