Commit 20680954 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

сделана конвертация WordArt из doc в docx

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63207 954022d7-b5bf-4e40-9824-e11837661b57
parent b4ca8fe3
......@@ -14,7 +14,19 @@ using namespace std;
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
inline static std::wstring ReplaceString(std::wstring subject, const std::wstring& search, const std::wstring& replace)
{
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos)
{
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
return subject;
}
//----------------------------------------------------------------
namespace XMLTools
{
/*========================================================================================================
......
......@@ -614,7 +614,7 @@ namespace DocFileFormat
if (pShape)
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_pXmlWriter, pSpa, NULL, m_context, _caller);
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
......@@ -625,16 +625,19 @@ namespace DocFileFormat
PictureDescriptor oPicture (chpx, m_document->DataStream);
if ((oPicture.mfp.mm > 98) && (NULL != oPicture.shapeContainer))
{
VMLPictureMapping* pVMLPicture = new VMLPictureMapping(m_context, m_pXmlWriter, false, _caller);
if (pVMLPicture)
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
oPicture.Convert (pVMLPicture);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
RELEASEOBJECT(pVMLPicture);
if (oPicture.blipStoreEntry)
{
VMLPictureMapping oVMLPicture(m_context, m_pXmlWriter, false, _caller);
oPicture.Convert (&oVMLPicture);
}
else
{
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, &oPicture, _caller);
oPicture.shapeContainer->Convert(&oVmlWriter);
}
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
}
else if ((TextMark::AutoNumberedFootnoteReference == c) && fSpec)
......
......@@ -462,7 +462,7 @@ namespace DocFileFormat
}
else
{
VMLShapeMapping oShape (m_pXmlWriter, NULL, &pict, m_context,this,true);
VMLShapeMapping oShape (m_context, m_pXmlWriter, NULL, &pict, this,true);
pict.shapeContainer->Convert(&oShape);
}
......
......@@ -73,7 +73,13 @@ namespace DocFileFormat
fHaveAnchor = FormatUtils::BitmaskToBool( flag, 0x200 );
fBackground = FormatUtils::BitmaskToBool( flag, 0x400 );
fHaveSpt = FormatUtils::BitmaskToBool( flag, 0x800 );
if (Instance > 0)
shapeType = ShapeTypeFactory::NewShapeType((MSOSPT)Instance);
else if (!fHaveSpt)
{
shapeType = ShapeTypeFactory::NewShapeType(msosptNotPrimitive);
}
}
virtual Record* NewObject( IBinaryReader* _reader, unsigned int bodySize, unsigned int typeCode, unsigned int version, unsigned int instance )
......
......@@ -315,6 +315,9 @@ namespace DocFileFormat
/// By default nothing is locked.
ProtectionBooleanProperties Lock;
///
std::wstring Textpath;
protected:
unsigned int TypeCode;
};
......
......@@ -37,6 +37,7 @@
#include "Shapetypes/BracketsType.h"
#include "Shapetypes/CalloutsType.h"
#include "Shapetypes/Connector.h"
#include "Shapetypes/WordArtText.h"
namespace DocFileFormat
{
......@@ -81,7 +82,6 @@ namespace DocFileFormat
case msosptDonut : { pShape = new DonutType(); } break;
case msosptPictureFrame : { pShape = new PictureFrameType(); } break;
case msosptTextBox : { pShape = new TextboxType(); } break;
case msosptTextStop : { pShape = new TextStop(); } break;
case msosptBevel : { pShape = new BevelType(); } break;
case msosptPentagon : { pShape = new PentagonType(); } break;
case msosptFoldedCorner : { pShape = new FoldedCornerlType(); } break;
......@@ -182,6 +182,50 @@ namespace DocFileFormat
case msosptCurvedConnector3 : { pShape = new CurvedConnector3(); } break;
case msosptCurvedConnector4 : { pShape = new CurvedConnector4(); } break;
case msosptCurvedConnector5 : { pShape = new CurvedConnector5(); } break;
//wordArt
case msosptTextStop : { pShape = new WordArtTextStop(); } break;
case msosptTextArchUpCurve : { pShape = new WordArtTextArchUpCurve(); } break;
case msosptTextPlainText :
//без детализаций - todooo прописать формулы
case msosptTextTriangle :
case msosptTextTriangleInverted :
case msosptTextChevron :
case msosptTextChevronInverted :
case msosptTextRingInside :
case msosptTextRingOutside :
case msosptTextArchDownCurve :
case msosptTextCircleCurve :
case msosptTextButtonCurve :
case msosptTextArchUpPour :
case msosptTextArchDownPour :
case msosptTextCirclePour :
case msosptTextButtonPour :
case msosptTextCurveUp :
case msosptTextCurveDown :
case msosptTextCascadeUp :
case msosptTextCascadeDown :
case msosptTextWave1 :
case msosptTextWave2 :
case msosptTextWave3 :
case msosptTextWave4 :
case msosptTextInflate :
case msosptTextDeflate :
case msosptTextInflateBottom :
case msosptTextDeflateBottom :
case msosptTextInflateTop :
case msosptTextDeflateTop :
case msosptTextDeflateInflate :
case msosptTextDeflateInflateDeflate :
case msosptTextFadeRight :
case msosptTextFadeLeft :
case msosptTextFadeUp :
case msosptTextFadeDown :
case msosptTextSlantUp :
case msosptTextSlantDown :
case msosptTextCanUp :
case msosptTextCanDown :
{ pShape = new WordArtTextType(TypeCode); } break;
default : { pShape = NULL; } break;
}
......
......@@ -12,36 +12,10 @@ namespace DocFileFormat
ShapeConcentricFill = true;
Joins = miter;
Path = _T("m,l,21600r21600,l21600,xe");
}
virtual ~TextboxType()
{
}
};
class TextStop : public ShapeType
{
public:
TextStop () : ShapeType(msosptTextStop)
{
Joins = miter;
Path = _T("m0@4l@2,l@3,l21600@4em0@5l@2,21600l@3,21600l21600@5e");
Formulas.push_back(_T("val #0"));
Formulas.push_back(_T("prod width 1 3"));
Formulas.push_back(_T("sum 0 @1 0"));
Formulas.push_back(_T("sum width 0 @1"));
Formulas.push_back(_T("sum 0 @0 0"));
Formulas.push_back(_T("sum height 0 @0"));
AdjustmentValues = _T("5400");
Handle one;
one.position = _T("0,@0");
Handles.push_back (one);
}
virtual ~TextStop ()
virtual ~TextboxType()
{
}
......
#pragma once
#include "../ShapeType.h"
namespace DocFileFormat
{
class WordArtTextType: public ShapeType
{
public:
WordArtTextType(int txStyle):
ShapeType((MSOSPT)txStyle)
{
this->Path = _T( "m@7,l@8,m@5,21600l@6,21600e" );
this->Textpath = _T(" on=\"t\" style=\"v-text-kern:t\" fitpath=\"t\"");
AdjustmentValues = _T("10800");
}
virtual ~WordArtTextType()
{
}
};
class WordArtTextStop : public WordArtTextType
{
public:
WordArtTextStop () : WordArtTextType(msosptTextStop)
{
this->Joins = miter;
this->Path = _T("m0@4l@2,l@3,l21600@4em0@5l@2,21600l@3,21600l21600@5e");
Formulas.push_back(_T("val #0"));
Formulas.push_back(_T("prod width 1 3"));
Formulas.push_back(_T("sum 0 @1 0"));
Formulas.push_back(_T("sum width 0 @1"));
Formulas.push_back(_T("sum 0 @0 0"));
Formulas.push_back(_T("sum height 0 @0"));
AdjustmentValues = _T("5400");
Handle one;
one.position = _T("0,@0");
Handles.push_back (one);
}
virtual ~WordArtTextStop ()
{
}
};
class WordArtTextArchUpCurve : public WordArtTextType
{
public:
WordArtTextArchUpCurve () : WordArtTextType(msosptTextArchUpCurve)
{
Path = _T("al10800,10800,10800,10800@2@14e");
Formulas.push_back(_T("val #1"));
Formulas.push_back(_T("val #0"));
Formulas.push_back(_T("sum 0 0 #0"));
Formulas.push_back(_T("sumangle #0 0 180"));
Formulas.push_back(_T("sumangle #0 0 90"));
Formulas.push_back(_T("prod @4 2 1"));
Formulas.push_back(_T("sumangle #0 90 0"));
Formulas.push_back(_T("prod @6 2 1"));
Formulas.push_back(_T("abs #0"));
Formulas.push_back(_T("sumangle @8 0 90"));
Formulas.push_back(_T("if @9 @7 @5"));
Formulas.push_back(_T("sumangle @10 0 360"));
Formulas.push_back(_T("if @10 @11 @10"));
Formulas.push_back(_T("sumangle @12 0 360"));
Formulas.push_back(_T("if @12 @13 @12"));
Formulas.push_back(_T("sum 0 0 @14"));
Formulas.push_back(_T("val 10800"));
Formulas.push_back(_T("cos 10800 #0"));
Formulas.push_back(_T("sin 10800 #0"));
Formulas.push_back(_T("sum @17 10800 0"));
Formulas.push_back(_T("sum @18 10800 0"));
Formulas.push_back(_T("sum 10800 0 @17"));
Formulas.push_back(_T("if @9 0 21600"));
Formulas.push_back(_T("sum 10800 0 @18"));
AdjustmentValues = _T("11796480");
Handle one;
one.position = _T("@16,#0");
one.polar = _T("10800,10800");
Handles.push_back (one);
}
virtual ~WordArtTextArchUpCurve ()
{
}
};
}
......@@ -12,18 +12,7 @@
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../DesktopEditor/common/File.h"
inline static std::wstring ReplaceString(std::wstring subject, const std::wstring& search, const std::wstring& replace)
{
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos)
{
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
return subject;
}
namespace DocFileFormat
{
......

#include "VMLPictureMapping.h"
#include "OfficeDrawing/GeometryBooleanProperties.h"
#include "OfficeDrawing/GeometryTextBooleanProperties.h"
#include "../../DesktopEditor/common/String.h"
namespace DocFileFormat
{
void VMLPictureMapping::appendStyleProperty(std::wstring* b, const std::wstring& propName, const std::wstring& propValue) const
{
if ( b != NULL )
{
b->operator += ( propName );
b->operator += ( _T( ":" ) );
b->operator += ( propValue );
b->operator +=( _T( ";" ) );
}
}
VMLPictureMapping::VMLPictureMapping(ConversionContext* ctx, XmlUtils::CXmlWriter* writer, bool olePreview, IMapping* caller, bool isBulletPicture) : PropertiesMapping(writer)
{
m_ctx = ctx;
......@@ -37,7 +54,7 @@ namespace DocFileFormat
{
PictureDescriptor* pict = static_cast<PictureDescriptor*>(visited);
if (CopyPicture(pict->blipStoreEntry))
if (pict->shapeContainer || pict->blipStoreEntry)
{
Shape* shape = static_cast<Shape*>(*(pict->shapeContainer->Children.begin()));
list<OptionEntry> options = pict->shapeContainer->ExtractOptions();
......@@ -148,10 +165,13 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
if (CopyPicture(pict->blipStoreEntry))
{
//v:imageData
appendValueAttribute(m_imageData, _T( "r:id" ), ( wstring( _T( "rId" ) ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
appendValueAttribute(m_imageData, _T( "o:title" ) , _T( "" ));
m_pXmlWriter->WriteString(m_imageData->GetXMLString().c_str());
}
//borders
writePictureBorder( _T( "bordertop" ), pict->brcTop );
......@@ -175,7 +195,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeBegin( ( wstring( _T( "w10:" ) ) + wstring( name ) ).c_str(), true );
m_pXmlWriter->WriteAttribute( _T( "type" ), getBorderType( brc->brcType ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "width" ), FormatUtils::IntToWideString( brc->dptLineWidth ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
m_pXmlWriter->WriteNodeEnd ( _T( "" ), true );
}
/// Copies the picture from the binary stream to the zip archive
......
......@@ -24,6 +24,7 @@ namespace DocFileFormat
private:
/// Writes a border element
void writePictureBorder (const wchar_t* name, const BorderCode* brc);
void appendStyleProperty( wstring* b, const wstring& propName, const wstring& propValue ) const;
protected:
/// Copies the picture from the binary stream to the zip archive
......
......@@ -21,9 +21,11 @@
#include "OfficeDrawing/GroupShapeBooleanProperties.h"
#include "OfficeDrawing/ProtectionBooleanProperties.h"
#include "../../DesktopEditor/common/String.h"
namespace DocFileFormat
{
VMLShapeMapping::VMLShapeMapping (XmlUtils::CXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, ConversionContext* pConv, IMapping* pCaller, bool bullet) : PropertiesMapping(pWriter)
VMLShapeMapping::VMLShapeMapping (ConversionContext* pConv, XmlUtils::CXmlWriter* pWriter, Spa* pSpa, PictureDescriptor* pPicture, IMapping* pCaller, bool bullet) : PropertiesMapping(pWriter)
{
m_bBullet = bullet;
......@@ -126,7 +128,7 @@ namespace DocFileFormat
ShapeContainer* pChildShape = static_cast<ShapeContainer*>(container->Children[i]);
if (pChildShape)
{
VMLShapeMapping vmlShapeMapping(m_pXmlWriter, m_pSpa, NULL, m_ctx, m_pCaller);
VMLShapeMapping vmlShapeMapping(m_ctx, m_pXmlWriter, m_pSpa, NULL, m_pCaller);
pChildShape->Convert(&vmlShapeMapping);
}
}
......@@ -148,7 +150,7 @@ namespace DocFileFormat
{
m_pXmlWriter->WriteNodeBegin( _T( "w10:wrap" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "type" ), wrap.c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "w10:wrap" ), TRUE );
m_pXmlWriter->WriteNodeEnd ( _T( "w10:wrap" ), TRUE );
}
}
......@@ -231,7 +233,6 @@ namespace DocFileFormat
switch (iter->pid)
{
//BOOLEANS
case geometryBooleans:
{
GeometryBooleanProperties booleans(iter->op);
......@@ -676,49 +677,54 @@ namespace DocFileFormat
case dyTextTop:{ndyTextTop = (int)iter->op;break;}
case dxTextRight:{ndxTextRight = (int)iter->op;break;}
case dyTextBottom:{ndyTextBottom = (int)iter->op;break;}
/*// TEXT PATH (Word Art)
case ShapeOptions.PropertyId.gtextUNICODE:
String text = Encoding.Unicode.GetString(entry.opComplex);
text = text.Replace("\n", "");
text = text.Replace("\0", "");
appendValueAttribute(_textpath, "", "string", text, "");
break;
// TEXT PATH (Word Art)
case ShapeOptions.PropertyId.gtextFont:
String font = Encoding.Unicode.GetString(entry.opComplex);
font = font.Replace("\0", "");
appendStyleProperty(_textPathStyle, "font-family", "\""+font+"\"");
break;
case gtextUNICODE:
{
std::wstring text = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op-2)/2);
text = FormatUtils::XmlEncode(text);
text = ReplaceString(text, _T("\n"), _T("&#xA;"));
appendValueAttribute(&m_textpath, L"string", text.c_str());
}break;
case ShapeOptions.PropertyId.GeometryTextBooleanProperties:
GeometryTextBooleanProperties props = new GeometryTextBooleanProperties(entry.op);
case gtextFont:
{
std::wstring font = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op-8)/2);
font = std::wstring(_T("\"")) + font + std::wstring(_T("\""));
appendStyleProperty(&m_textPathStyle, L"font-family", font);
}break;
case geometryTextBooleanProperties:
{
GeometryTextBooleanProperties props(iter->op);
if (props.fUsegtextFBestFit && props.gtextFBestFit)
{
appendValueAttribute(_textpath, "", "fitshape", "t", "");
appendValueAttribute(&m_textpath, L"fitshape", _T("t"));
}
if (props.fUsegtextFShrinkFit && props.gtextFShrinkFit)
{
appendValueAttribute(_textpath, "", "trim", "t", "");
appendValueAttribute(&m_textpath, L"trim", _T("t"));
}
if (props.fUsegtextFVertical && props.gtextFVertical)
{
appendStyleProperty(_textPathStyle, "v-rotate-letters", "t");
appendStyleProperty(&m_textPathStyle, L"v-rotate-letters", L"t");
//_twistDimension = true;
}
if (props.fUsegtextFKern && props.gtextFKern)
{
appendStyleProperty(_textPathStyle, "v-text-kern", "t");
appendStyleProperty(&m_textPathStyle, L"v-text-kern", L"t");
}
if (props.fUsegtextFItalic && props.gtextFItalic)
{
appendStyleProperty(_textPathStyle, "font-style", "italic");
appendStyleProperty(&m_textPathStyle, L"font-style", L"italic");
}
if (props.fUsegtextFBold && props.gtextFBold)
{
appendStyleProperty(_textPathStyle, "font-weight", "bold");
appendStyleProperty(&m_textPathStyle, L"font-weight", L"bold");
}
break;*/
}break;
// PATH
case shapePath :
......@@ -729,8 +735,7 @@ namespace DocFileFormat
if (false == path.empty())
m_pXmlWriter->WriteAttribute (_T( "path" ), path.c_str());
}
break;
}break;
}
}
......@@ -912,7 +917,7 @@ namespace DocFileFormat
{
m_pXmlWriter->WriteNodeBegin( _T( "w10:wrap" ), TRUE );
m_pXmlWriter->WriteAttribute( _T( "type" ), wrap.c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "w10:wrap" ), TRUE );
m_pXmlWriter->WriteNodeEnd ( _T( "w10:wrap" ), TRUE );
}
}
......@@ -931,7 +936,7 @@ namespace DocFileFormat
// text path
if (m_textpath.GetAttributeCount())
{
appendValueAttribute(&m_textpath, _T( "style" ), m_textPathStyle.c_str());
appendValueAttribute(&m_textpath, _T( "style" ), FormatUtils::XmlEncode(m_textPathStyle).c_str());
m_pXmlWriter->WriteString(m_textpath.GetXMLString().c_str());
}
......@@ -992,6 +997,13 @@ namespace DocFileFormat
}
WriteEndShapeNode(pShape);
//ShapeType
if (NULL != pShape->GetShapeType() && !m_bBullet)
{
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter);
pShape->GetShapeType()->Convert(&oXmlMapper);
}
}
}
}
......@@ -1023,13 +1035,6 @@ namespace DocFileFormat
}
else
{
//SHAPE
if (NULL != pShape->GetShapeType() && !m_bBullet)
{
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter);
pShape->GetShapeType()->Convert(&oXmlMapper);
}
m_pXmlWriter->WriteNodeBegin(_T( "v:shape" ), TRUE);
}
}
......
......@@ -28,7 +28,7 @@ namespace DocFileFormat
{
public:
VMLShapeMapping (XmlUtils::CXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, ConversionContext* ctx , IMapping* caller, bool bullet = false);
VMLShapeMapping (ConversionContext* ctx ,XmlUtils::CXmlWriter* writer, Spa* pSpa, PictureDescriptor* pict, IMapping* caller, bool bullet = false);
virtual ~VMLShapeMapping();
virtual void Apply(IVisitable* visited);
......
......@@ -39,9 +39,10 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T("adj"), pShape->AdjustmentValues.c_str() );
// Path
if (pShape->Path.length())
if (!pShape->Path.empty())
m_pXmlWriter->WriteAttribute( _T("path"), pShape->Path.c_str() );
//Default fill / stroke
if ( !pShape->Filled )
{
......@@ -58,8 +59,15 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "o:preferrelative" ), _T( "t" ) );
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );//закрытие атрибутов
//Textpath
if (!pShape->Textpath.empty())
{
m_pXmlWriter->WriteNodeBegin( _T( "v:textpath" ), true );
m_pXmlWriter->WriteString( pShape->Textpath.c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
// Stroke
m_pXmlWriter->WriteNodeBegin( _T( "v:stroke" ), true );
m_pXmlWriter->WriteAttribute( _T( "joinstyle" ), FormatUtils::MapValueToWideString( pShape->Joins, &JoinStyleMap[0][0], 3, 6 ).c_str() );
......
......@@ -268,6 +268,7 @@
<ClInclude Include="..\..\DocDocxConverter\OfficeDrawing\Shapetypes\SunType.h" />
<ClInclude Include="..\..\DocDocxConverter\OfficeDrawing\Shapetypes\TextboxType.h" />
<ClInclude Include="..\..\DocDocxConverter\OfficeDrawing\Shapetypes\TrapezoidType.h" />
<ClInclude Include="..\..\DocDocxConverter\OfficeDrawing\Shapetypes\WordArtText.h" />
<ClInclude Include="..\..\DocDocxConverter\OfficeDrawing\SplitMenuColorContainer.h" />
<ClInclude Include="..\..\DocDocxConverter\OfficeDrawing\UnknownRecord.h" />
<ClInclude Include="..\..\DocDocxConverter\OleObject.h" />
......
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