Commit 48185ed4 authored by ElenaSubbotina's avatar ElenaSubbotina

DocxFormat - fix vml single geom position

RtfFormat - read/write background page (solid, pattern, gradient, image)
parent 7bea0867
...@@ -63,8 +63,7 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type) ...@@ -63,8 +63,7 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
if (odf_context()->drawing_context()->m_mapVmlShapeTypes.find( sId ) == if (odf_context()->drawing_context()->m_mapVmlShapeTypes.find( sId ) ==
odf_context()->drawing_context()->m_mapVmlShapeTypes.end()) odf_context()->drawing_context()->m_mapVmlShapeTypes.end())
{ {
odf_context()->drawing_context()->m_mapVmlShapeTypes.insert(odf_context()->drawing_context()->m_mapVmlShapeTypes.begin(), odf_context()->drawing_context()->m_mapVmlShapeTypes.insert(std::make_pair(sId, vml_shape_type));
std::pair<std::wstring, OOX::Vml::CShapeType*>(sId, vml_shape_type));
} }
} }
...@@ -80,9 +79,9 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type) ...@@ -80,9 +79,9 @@ void OoxConverter::convert(OOX::Vml::CShapeType *vml_shape_type)
} }
//o:spt //o:spt
//nullable<std::wstring> m_oAdj; //nullable<std::wstring> m_oAdj;
//nullable<SimpleTypes::Vml::CVmlPath> m_oPath; //nullable<SimpleTypes::Vml::CVmlPath> m_oPath;
//SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oMaster; //SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oMaster;
//m_arrItems //m_arrItems
//CVmlCommonElements //CVmlCommonElements
} }
......
...@@ -1676,20 +1676,21 @@ void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type) ...@@ -1676,20 +1676,21 @@ void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type)
{ {
if (oox_background == NULL) return; if (oox_background == NULL) return;
_CP_OPT(odf_types::color) color;
convert ( oox_background->m_oColor.GetPointer(),
oox_background->m_oThemeColor.GetPointer(),
oox_background->m_oThemeTint.GetPointer(),
oox_background->m_oThemeShade.GetPointer(), color);
odt_context->set_background(color, type);
if (oox_background->m_oDrawing.IsInit()) if (oox_background->m_oDrawing.IsInit())
{ {
//подложка convert(oox_background->m_oDrawing.GetPointer());
} }
else else if (oox_background->m_oBackground.IsInit())
{ {
//цветовая подложка convert(oox_background->m_oBackground.GetPointer());
_CP_OPT(odf_types::color) color;
convert ( oox_background->m_oColor.GetPointer(),
oox_background->m_oThemeColor.GetPointer(),
oox_background->m_oThemeTint.GetPointer(),
oox_background->m_oThemeShade.GetPointer(), color);
odt_context->set_background(color, type);
} }
} }
......
...@@ -38,6 +38,8 @@ class OOXReader; ...@@ -38,6 +38,8 @@ class OOXReader;
class RtfWriter; class RtfWriter;
class RtfReader; class RtfReader;
namespace OOX { namespace Vml { class CShapeType; } }
class RtfConvertationManager class RtfConvertationManager
{ {
public: public:
...@@ -58,6 +60,7 @@ public: ...@@ -58,6 +60,7 @@ public:
void OnCompleteItemRtf(); void OnCompleteItemRtf();
void OnCompleteItemOOX(); void OnCompleteItemOOX();
private: private:
OOXWriter* m_poOOXWriter; OOXWriter* m_poOOXWriter;
OOXReader* m_poOOXReader; OOXReader* m_poOOXReader;
......
...@@ -155,7 +155,7 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead ...@@ -155,7 +155,7 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead
oReader.m_oCurSectionProp.m_bSwitchMargin = 1; oReader.m_oCurSectionProp.m_bSwitchMargin = 1;
} }
} }
else if ( "gutter" == sCommand ) else if ( "gutter" == sCommand )
{ {
if ( hasParameter ) if ( hasParameter )
{ {
...@@ -163,12 +163,12 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead ...@@ -163,12 +163,12 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead
oReader.m_oCurSectionProp.m_nGutterMarginWidth = parameter; oReader.m_oCurSectionProp.m_nGutterMarginWidth = parameter;
} }
} }
else if ( "ogutter" == sCommand ) else if ( "ogutter" == sCommand )
{ {
if ( hasParameter ) if ( hasParameter )
oDocument.m_oProperty.m_nGutterWidthOutside = parameter; oDocument.m_oProperty.m_nGutterWidthOutside = parameter;
} }
else if ( "margmirror" == sCommand ) else if ( "margmirror" == sCommand )
{ {
if ( hasParameter && 0 == parameter ) if ( hasParameter && 0 == parameter )
{ {
...@@ -194,7 +194,7 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead ...@@ -194,7 +194,7 @@ bool RtfDocumentCommand::ExecuteCommand(RtfDocument& oDocument, RtfReader& oRead
COMMAND_RTF_BOOL( "useltbaln", oDocument.m_oProperty.m_bUseTabAlignment, sCommand, hasParameter, parameter ) COMMAND_RTF_BOOL( "useltbaln", oDocument.m_oProperty.m_bUseTabAlignment, sCommand, hasParameter, parameter )
//Footnotes and Endnotes //Footnotes and Endnotes
COMMAND_RTF_INT ( "endnotes", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_EndSection ) COMMAND_RTF_INT ( "endnotes", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_EndSection )
COMMAND_RTF_INT ( "enddoc", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_EndDocument ) COMMAND_RTF_INT ( "enddoc", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_EndDocument )
COMMAND_RTF_INT ( "ftntj", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_BeneathText ) COMMAND_RTF_INT ( "ftntj", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_BeneathText )
COMMAND_RTF_INT ( "ftnbj", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_BottomPage ) COMMAND_RTF_INT ( "ftnbj", oDocument.m_oProperty.m_eFootnotePlacement, sCommand, true, RtfDocumentProperty::fp_BottomPage )
...@@ -309,6 +309,15 @@ bool RtfNormalReader::ExecuteCommand( RtfDocument& oDocument, RtfReader& oReader ...@@ -309,6 +309,15 @@ bool RtfNormalReader::ExecuteCommand( RtfDocument& oDocument, RtfReader& oReader
RtfInfoReader oInfoReader; RtfInfoReader oInfoReader;
return StartSubReader( oInfoReader, oDocument, oReader ); return StartSubReader( oInfoReader, oDocument, oReader );
} }
else if ( "background" == sCommand )
{
oDocument.m_pBackground = RtfShapePtr( new RtfShape() );
oDocument.m_pBackground->m_bBackground = true;
RtfBackgroundReader oBackgroundReader( *oDocument.m_pBackground );
return StartSubReader( oBackgroundReader, oDocument, oReader );
}
//else if ( "colorschememapping" == sCommand ) //else if ( "colorschememapping" == sCommand )
//{ //{
// RtfColorSchemeReader oSchemeReader; // RtfColorSchemeReader oSchemeReader;
......
...@@ -509,9 +509,9 @@ public: ...@@ -509,9 +509,9 @@ public:
else if( "author" == sCommand ) m_eInternalState = is_author; else if( "author" == sCommand ) m_eInternalState = is_author;
else if( "manager" == sCommand ) m_eInternalState = is_manager; else if( "manager" == sCommand ) m_eInternalState = is_manager;
else if( "company" == sCommand ) m_eInternalState = is_company; else if( "company" == sCommand ) m_eInternalState = is_company;
else if( "operator" == sCommand ) m_eInternalState = is_operator; else if( "operator" == sCommand ) m_eInternalState = is_operator;
else if( "category" == sCommand ) m_eInternalState = is_category; else if( "category" == sCommand ) m_eInternalState = is_category;
else if( "keywords" == sCommand ) m_eInternalState = is_keywords; else if( "keywords" == sCommand ) m_eInternalState = is_keywords;
else if( "comment" == sCommand ) m_eInternalState = is_comment; else if( "comment" == sCommand ) m_eInternalState = is_comment;
else if( "doccomm" == sCommand ) m_eInternalState = is_doccomm; else if( "doccomm" == sCommand ) m_eInternalState = is_doccomm;
else if( "hlinkbase" == sCommand ) m_eInternalState = is_hlinkbase; else if( "hlinkbase" == sCommand ) m_eInternalState = is_hlinkbase;
...@@ -720,12 +720,12 @@ class RtfPictureReader : public RtfAbstractReader ...@@ -720,12 +720,12 @@ class RtfPictureReader : public RtfAbstractReader
}; };
private: private:
RtfShape& m_oShape; RtfShape& m_oShape;
std::wstring m_sFile; std::wstring m_sFile;
std::wstring m_sData; std::wstring m_sData;
bool m_bBin; bool m_bBin;
BYTE* m_pbBin; BYTE* m_pbBin;
int m_nBinLength; int m_nBinLength;
public: public:
RtfPictureReader( RtfReader& oReader, RtfShape& oShape ) : m_oShape(oShape) RtfPictureReader( RtfReader& oReader, RtfShape& oShape ) : m_oShape(oShape)
...@@ -983,7 +983,31 @@ public: ...@@ -983,7 +983,31 @@ public:
return true; return true;
} }
}; };
class RtfBackgroundReader : public RtfShapeReader
{
public:
RtfShape& m_oShape;
RtfBackgroundReader( RtfShape& oShape ) : RtfShapeReader(oShape), m_oShape(oShape)
{
}
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, std::string sCommand, bool hasParameter, int parameter)
{
if( "background" == sCommand )
{
return true;
}
else if( "shp" == sCommand )
{
RtfShapeReader oShapeReader( m_oShape );
StartSubReader( oShapeReader, oDocument, oReader );
}
else
return RtfShapeReader::ExecuteCommand( oDocument, oReader, sCommand, hasParameter, parameter);
return true;
}
};
class RtfOldShapeReader : public RtfAbstractReader class RtfOldShapeReader : public RtfAbstractReader
{ {
private: private:
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
*/ */
#pragma once #pragma once
#include "OOXShapeReader.h"
#include "OOXTextItemReader.h" #include "OOXTextItemReader.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Document.h" #include "../../../../Common/DocxFormat/Source/DocxFormat/Document.h"
class OOXDocumentReader class OOXDocumentReader
...@@ -58,6 +60,13 @@ public: ...@@ -58,6 +60,13 @@ public:
m_poReader = oParam.oReader; m_poReader = oParam.oReader;
m_poDocument = oParam.oRtf; m_poDocument = oParam.oRtf;
if ( m_ooxDocument->m_oBackground.IsInit())
{
m_poDocument->m_pBackground = RtfShapePtr(new RtfShape());
OOXBackgroundReader oBackgroundReader(m_ooxDocument->m_oBackground.GetPointer());
oBackgroundReader.Parse( oParam, m_poDocument->m_pBackground);
}
int last_section_start = 0; int last_section_start = 0;
......
...@@ -745,17 +745,24 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -745,17 +745,24 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
RtfShapePtr pNewShape ( new RtfShape() ); RtfShapePtr pNewShape ( new RtfShape() );
pNewShape->m_oCharProperty = oNewProperty; pNewShape->m_oCharProperty = oNewProperty;
OOXShapeReader *pShapeReader = NULL; OOXShapeReader* pShapeReader = NULL;
if (ooxPicture->m_oShapeType.IsInit())
if (ooxPicture->m_oShape.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShape.GetPointer()); {
else if (ooxPicture->m_oShapeType.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeType.GetPointer()); pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeType.GetPointer());
else if (ooxPicture->m_oShapeArc.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeArc.GetPointer()); if(pShapeReader)
{
pShapeReader->Parse( oParam, pNewShape );
delete pShapeReader; pShapeReader = NULL;
}
}
if (ooxPicture->m_oShapeArc.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeArc.GetPointer());
else if (ooxPicture->m_oShapeRect.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRect.GetPointer()); else if (ooxPicture->m_oShapeRect.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRect.GetPointer());
else if (ooxPicture->m_oShapeRoundRect.IsInit())pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRoundRect.GetPointer()); else if (ooxPicture->m_oShapeRoundRect.IsInit())pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeRoundRect.GetPointer());
else if (ooxPicture->m_oShapeOval.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeOval.GetPointer()); else if (ooxPicture->m_oShapeOval.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeOval.GetPointer());
else if (ooxPicture->m_oShapeLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeLine.GetPointer()); else if (ooxPicture->m_oShapeLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeLine.GetPointer());
else if (ooxPicture->m_oShapePolyLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapePolyLine.GetPointer()); else if (ooxPicture->m_oShapePolyLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapePolyLine.GetPointer());
else if (ooxPicture->m_oShapeCurve.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeCurve.GetPointer()); else if (ooxPicture->m_oShapeCurve.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeCurve.GetPointer());
else if (ooxPicture->m_oShape.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShape.GetPointer());
if (pShapeReader) if (pShapeReader)
{ {
......
...@@ -41,7 +41,7 @@ class OOXReader ...@@ -41,7 +41,7 @@ class OOXReader
public: public:
RtfConvertationManager* m_convertationManager; RtfConvertationManager* m_convertationManager;
std::wstring m_sPath; std::wstring m_sPath;
int m_nCurItap; //для определение вложенности таблицы int m_nCurItap; //для определение вложенности таблицы
......
...@@ -249,7 +249,7 @@ bool ParseStyle(RtfShape* pShape, SimpleTypes::Vml::CCssProperty* prop) ...@@ -249,7 +249,7 @@ bool ParseStyle(RtfShape* pShape, SimpleTypes::Vml::CCssProperty* prop)
} }
OOXShapeReader::OOXShapeReader(OOX::WritingElementWithChilds<OOX::WritingElement> * elem) OOXShapeReader::OOXShapeReader(OOX::WritingElementWithChilds<OOX::WritingElement> * elem)
{ {
m_arrElement = elem; m_arrElement = elem;
...@@ -328,7 +328,7 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput) ...@@ -328,7 +328,7 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
case SimpleTypes::filltypeFrame : oOutput->m_nFillType = 3; break; case SimpleTypes::filltypeFrame : oOutput->m_nFillType = 3; break;
case SimpleTypes::filltypeGradient: oOutput->m_nFillType = 4; break; case SimpleTypes::filltypeGradient: oOutput->m_nFillType = 4; break;
case SimpleTypes::filltypeGradientCenter: oOutput->m_nFillType = 4; break; case SimpleTypes::filltypeGradientCenter: oOutput->m_nFillType = 4; break;
case SimpleTypes::filltypeGradientRadial: oOutput->m_nFillType = 4; break; case SimpleTypes::filltypeGradientRadial: oOutput->m_nFillType = 6; break;
case SimpleTypes::filltypeGradientUnscaled: oOutput->m_nFillType = 4; break; case SimpleTypes::filltypeGradientUnscaled: oOutput->m_nFillType = 4; break;
case SimpleTypes::filltypePattern: oOutput->m_nFillType = 1; break; case SimpleTypes::filltypePattern: oOutput->m_nFillType = 1; break;
case SimpleTypes::filltypeTile: oOutput->m_nFillType = 2; break; case SimpleTypes::filltypeTile: oOutput->m_nFillType = 2; break;
...@@ -346,6 +346,21 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput) ...@@ -346,6 +346,21 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
{ {
oOutput->m_nFillFocus = fill->m_oFocus->GetValue(); oOutput->m_nFillFocus = fill->m_oFocus->GetValue();
} }
if (fill->m_oFocusPosition.IsInit())
{
if (fill->m_oFocusPosition->GetY() > 0.99 || fill->m_oFocusPosition->GetX() > 0.99)
oOutput->m_nFillType = 5;
int toBottom = (1. - fill->m_oFocusPosition->GetY()) * 65535;
int toTop = (fill->m_oFocusPosition->GetY()) * 65535;
int toRight = (1. - fill->m_oFocusPosition->GetX()) * 65535;
int toLeft = (fill->m_oFocusPosition->GetX()) * 65535;
if (toBottom > 0) oOutput->m_nFillToBottom = toBottom;
if (toTop > 0) oOutput->m_nFillToTop = toTop;
if (toRight > 0) oOutput->m_nFillToRight = toRight;
if (toLeft > 0) oOutput->m_nFillToLeft = toLeft;
}
}break; }break;
case OOX::et_v_stroke: case OOX::et_v_stroke:
{ {
...@@ -825,3 +840,58 @@ void OOXShapeReader::ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment) ...@@ -825,3 +840,58 @@ void OOXShapeReader::ParseAdjustment(RtfShape& oShape, std::wstring sAdjustment)
} }
} }
} }
bool OOXBackgroundReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
{
if (!m_ooxBackground) return false;
oOutput->m_nShapeType = 1;
oOutput->m_bBackground = true;
oOutput->m_bFilled = true;
if (m_ooxBackground->m_oColor.IsInit() && m_ooxBackground->m_oColor->GetValue() == SimpleTypes::hexcolorRGB)
{
unsigned char ucR = m_ooxBackground->m_oColor->Get_R();
unsigned char ucB = m_ooxBackground->m_oColor->Get_B();
unsigned char ucG = m_ooxBackground->m_oColor->Get_G();
unsigned char ucA = m_ooxBackground->m_oColor->Get_A();
oOutput->m_nFillColor = RGB(ucR, ucG , ucB);
if (ucA != 0xff)
oOutput->m_nFillOpacity = ucA / 255. * 100;
}
else if (m_ooxBackground->m_oThemeColor.IsInit())
{
//nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeShade;
//nullable<SimpleTypes::CUcharHexNumber<> > m_oThemeTint;
}
if (m_ooxBackground->m_oBackground.IsInit())
{
OOXShapeReader sub_reader(m_ooxBackground->m_oBackground.GetPointer());
sub_reader.Parse(oParam, oOutput);
}
else if (m_ooxBackground->m_oDrawing.IsInit())
{
OOXDrawingReader oDrawingReader(m_ooxBackground->m_oDrawing.GetPointer());
if( false == oDrawingReader.Parse( oParam, *oOutput ) )
{
if (!m_ooxBackground->m_oDrawing->m_sXml.IsInit())
{
OOXDrawingGraphicReader oGraphiceReader(*m_ooxBackground->m_oDrawing->m_sXml);
OOX::Logic::CPicture *ooxPicture = oGraphiceReader.Parse( oParam, *oOutput );
if (ooxPicture)
{
OOXShapeReader sub_reader(ooxPicture);
sub_reader.Parse(oParam, oOutput);
delete ooxPicture;
}
}
}
}
return true;
}
...@@ -69,7 +69,6 @@ private: ...@@ -69,7 +69,6 @@ private:
} }
}; };
class OOXShapeGroupReader class OOXShapeGroupReader
{ {
private: private:
...@@ -91,3 +90,16 @@ public: ...@@ -91,3 +90,16 @@ public:
bool Parse( ReaderParameter oParam , RtfShapeGroupPtr& oOutput); bool Parse( ReaderParameter oParam , RtfShapeGroupPtr& oOutput);
}; };
class OOXBackgroundReader
{
private:
OOX::Logic::CBackground *m_ooxBackground;
public:
OOXBackgroundReader(OOX::Logic::CBackground *oox_background)
{
m_ooxBackground = oox_background;
}
bool Parse( ReaderParameter oParam , RtfShapePtr& oOutput);
};
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "RtfGlobalTables.h" #include "RtfGlobalTables.h"
#include "RtfSection.h" #include "RtfSection.h"
#include "RtfMath.h" #include "RtfMath.h"
#include "RtfShape.h"
struct _section struct _section
{ {
...@@ -56,6 +57,7 @@ public: ...@@ -56,6 +57,7 @@ public:
RtfStyleTable m_oStyleTable; RtfStyleTable m_oStyleTable;
RtfRevisionTable m_oRevisionTable; RtfRevisionTable m_oRevisionTable;
RtfInformation m_oInformation; RtfInformation m_oInformation;
RtfShapePtr m_pBackground;
RtfListTable m_oListTable; RtfListTable m_oListTable;
RtfListOverrideTable m_oListOverrideTable; RtfListOverrideTable m_oListOverrideTable;
...@@ -80,8 +82,10 @@ public: ...@@ -80,8 +82,10 @@ public:
void SetShapeId( int nShapeId ) void SetShapeId( int nShapeId )
{ {
for( int i = 0; i < (int)m_aShapeId.size(); i++ ) for( int i = 0; i < (int)m_aShapeId.size(); i++ )
{
if( nShapeId == m_aShapeId[i] ) if( nShapeId == m_aShapeId[i] )
return; return;
}
m_aShapeId.push_back( nShapeId ); m_aShapeId.push_back( nShapeId );
} }
int GetShapeId( int& nShapeId ) int GetShapeId( int& nShapeId )
......
...@@ -146,6 +146,10 @@ void RtfShape::SetDefault() ...@@ -146,6 +146,10 @@ void RtfShape::SetDefault()
DEFAULT_PROPERTY( m_nFillOpacity ) DEFAULT_PROPERTY( m_nFillOpacity )
DEFAULT_PROPERTY( m_nFillFocus ) DEFAULT_PROPERTY( m_nFillFocus )
DEFAULT_PROPERTY( m_nFillAngle ) DEFAULT_PROPERTY( m_nFillAngle )
DEFAULT_PROPERTY( m_nFillToBottom )
DEFAULT_PROPERTY( m_nFillToTop )
DEFAULT_PROPERTY( m_nFillToRight )
DEFAULT_PROPERTY( m_nFillToLeft )
//Line //Line
DEFAULT_PROPERTY_DEF( m_bLine, true ) DEFAULT_PROPERTY_DEF( m_bLine, true )
DEFAULT_PROPERTY( m_nLineColor ) DEFAULT_PROPERTY( m_nLineColor )
...@@ -168,7 +172,7 @@ void RtfShape::SetDefault() ...@@ -168,7 +172,7 @@ void RtfShape::SetDefault()
m_aTextItems = TextItemContainerPtr(); m_aTextItems = TextItemContainerPtr();
m_oPicture = RtfPicturePtr(); m_oPicture = RtfPicturePtr();
m_bBackground = false;
m_bIsOle = false; m_bIsOle = false;
m_bInGroup = false; m_bInGroup = false;
...@@ -234,6 +238,9 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -234,6 +238,9 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
} }
else else
{ {
if (m_bBackground)
sResult += L"{\\*\\background";
sResult += L"{\\shp"; sResult += L"{\\shp";
sResult += L"{\\*\\shpinst"; sResult += L"{\\*\\shpinst";
...@@ -281,7 +288,7 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -281,7 +288,7 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
sResult += L"{\\sp{\\sn fLockRotation}{\\sv 1}}"; sResult += L"{\\sp{\\sn fLockRotation}{\\sv 1}}";
//picture //picture
if( 0 != m_oPicture && m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 9) if( 0 != m_oPicture && m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 3 || m_nFillType == 9)
{ {
sResult += L"{\\sp{\\sn fillBlip}{\\sv "; sResult += L"{\\sp{\\sn fillBlip}{\\sv ";
sResult += m_oPicture->RenderToRtf( oRenderParameter ); sResult += m_oPicture->RenderToRtf( oRenderParameter );
...@@ -296,6 +303,9 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -296,6 +303,9 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
} }
sResult += L"}"; sResult += L"}";
sResult += L"}"; sResult += L"}";
if (m_bBackground)
sResult += L"}";
} }
} }
else // anchor else // anchor
...@@ -400,14 +410,14 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -400,14 +410,14 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
RENDER_RTF_SHAPE_PROP(L"fAllowOverlap", sResult, m_bAllowOverlap); RENDER_RTF_SHAPE_PROP(L"fAllowOverlap", sResult, m_bAllowOverlap);
//Position relative //Position relative
RENDER_RTF_SHAPE_PROP(L"pctHorizPos", sResult, m_nPositionHPct); RENDER_RTF_SHAPE_PROP(L"pctHorizPos", sResult, m_nPositionHPct);
RENDER_RTF_SHAPE_PROP(L"pctVertPos", sResult, m_nPositionVPct); RENDER_RTF_SHAPE_PROP(L"pctVertPos", sResult, m_nPositionVPct);
RENDER_RTF_SHAPE_PROP(L"pctHoriz", sResult, m_nPctWidth); RENDER_RTF_SHAPE_PROP(L"pctHoriz", sResult, m_nPctWidth);
RENDER_RTF_SHAPE_PROP(L"pctVert", sResult, m_nPctHeight); RENDER_RTF_SHAPE_PROP(L"pctVert", sResult, m_nPctHeight);
RENDER_RTF_SHAPE_PROP(L"sizerelh", sResult, m_nPctWidthRelative); RENDER_RTF_SHAPE_PROP(L"sizerelh", sResult, m_nPctWidthRelative);
RENDER_RTF_SHAPE_PROP(L"sizerelv", sResult, m_nPctHeightRelative); RENDER_RTF_SHAPE_PROP(L"sizerelv", sResult, m_nPctHeightRelative);
RENDER_RTF_SHAPE_PROP(L"colStart", sResult, m_nColStart); RENDER_RTF_SHAPE_PROP(L"colStart", sResult, m_nColStart);
RENDER_RTF_SHAPE_PROP(L"colSpan", sResult, m_nColSpan); RENDER_RTF_SHAPE_PROP(L"colSpan", sResult, m_nColSpan);
//Rehydration //Rehydration
//RENDER_RTF_SHAPE_PROP(L"metroBlob", sResult, m_sMetroBlob); //RENDER_RTF_SHAPE_PROP(L"metroBlob", sResult, m_sMetroBlob);
...@@ -419,6 +429,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -419,6 +429,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
RENDER_RTF_SHAPE_PROP(L"shapeType", sResult, m_nShapeType); RENDER_RTF_SHAPE_PROP(L"shapeType", sResult, m_nShapeType);
RENDER_RTF_SHAPE_PROP(L"fBehindDocument",sResult, m_nZOrderRelative); RENDER_RTF_SHAPE_PROP(L"fBehindDocument",sResult, m_nZOrderRelative);
RENDER_RTF_SHAPE_PROP(L"fHidden", sResult, m_bHidden); RENDER_RTF_SHAPE_PROP(L"fHidden", sResult, m_bHidden);
RENDER_RTF_SHAPE_PROP(L"fBackground", sResult, m_bBackground);
//Text //Text
//sResult += L"{\\sp{\\sn fLockText}{\\sv 0}}"; //sResult += L"{\\sp{\\sn fLockText}{\\sv 0}}";
...@@ -430,10 +441,10 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -430,10 +441,10 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
RENDER_RTF_SHAPE_PROP(L"anchorText", sResult, m_nAnchorText); RENDER_RTF_SHAPE_PROP(L"anchorText", sResult, m_nAnchorText);
//else //else
{ {
RENDER_RTF_SHAPE_PROP(L"dxWrapDistLeft", sResult, RtfUtility::Twips2Emu( m_nWrapDistLeft )); RENDER_RTF_SHAPE_PROP(L"dxWrapDistLeft", sResult, RtfUtility::Twips2Emu( m_nWrapDistLeft ));
RENDER_RTF_SHAPE_PROP(L"dyWrapDistTop", sResult, RtfUtility::Twips2Emu( m_nWrapDistTop )); RENDER_RTF_SHAPE_PROP(L"dyWrapDistTop", sResult, RtfUtility::Twips2Emu( m_nWrapDistTop ));
RENDER_RTF_SHAPE_PROP(L"dxWrapDistRight", sResult, RtfUtility::Twips2Emu( m_nWrapDistRight )); RENDER_RTF_SHAPE_PROP(L"dxWrapDistRight", sResult, RtfUtility::Twips2Emu( m_nWrapDistRight ));
RENDER_RTF_SHAPE_PROP(L"dyWrapDistBottom", sResult, RtfUtility::Twips2Emu( m_nWrapDistBottom )); RENDER_RTF_SHAPE_PROP(L"dyWrapDistBottom", sResult, RtfUtility::Twips2Emu( m_nWrapDistBottom ));
} }
RENDER_RTF_SHAPE_PROP(L"fFitShapeToText", sResult, m_bFitShapeToText); RENDER_RTF_SHAPE_PROP(L"fFitShapeToText", sResult, m_bFitShapeToText);
RENDER_RTF_SHAPE_PROP(L"fFitTextToShape", sResult, m_bFitTextToShape); RENDER_RTF_SHAPE_PROP(L"fFitTextToShape", sResult, m_bFitTextToShape);
...@@ -503,11 +514,16 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -503,11 +514,16 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
if (PROP_DEF != m_nFillOpacity) if (PROP_DEF != m_nFillOpacity)
RENDER_RTF_SHAPE_PROP(L"fillOpacity", sResult, ( m_nFillOpacity * 65536 /100 ) ); RENDER_RTF_SHAPE_PROP(L"fillOpacity", sResult, ( m_nFillOpacity * 65536 /100 ) );
RENDER_RTF_SHAPE_PROP(L"fillFocus", sResult, m_nFillFocus ); RENDER_RTF_SHAPE_PROP(L"fillFocus", sResult, m_nFillFocus );
if (PROP_DEF != m_nFillAngle) if (PROP_DEF != m_nFillAngle)
RENDER_RTF_SHAPE_PROP(L"fillAngle", sResult, m_nFillAngle * 65536 ); RENDER_RTF_SHAPE_PROP(L"fillAngle", sResult, m_nFillAngle * 65536 );
//Line
RENDER_RTF_SHAPE_PROP(L"fillToBottom", sResult, m_nFillToBottom )
RENDER_RTF_SHAPE_PROP(L"fillToTop", sResult, m_nFillToTop )
RENDER_RTF_SHAPE_PROP(L"fillToRight", sResult, m_nFillToRight )
RENDER_RTF_SHAPE_PROP(L"fillToLeft", sResult, m_nFillToLeft )
//Line
if( 0 == m_bLine ) if( 0 == m_bLine )
sResult += L"{\\sp{\\sn fLine}{\\sv 0}}"; sResult += L"{\\sp{\\sn fLine}{\\sv 0}}";
RENDER_RTF_SHAPE_PROP(L"lineColor", sResult, m_nLineColor ); RENDER_RTF_SHAPE_PROP(L"lineColor", sResult, m_nLineColor );
...@@ -642,9 +658,11 @@ std::wstring RtfShape::RenderToOOX(RenderParameter oRenderParameter) ...@@ -642,9 +658,11 @@ std::wstring RtfShape::RenderToOOX(RenderParameter oRenderParameter)
return sResult; return sResult;
} }
std::wstring RtfShape::GetShapeNodeName(int type) std::wstring RtfShape::GetShapeNodeName()
{ {
switch(type) if (m_bBackground) return L"v:background";
switch(m_nShapeType)
{ {
case NSOfficeDrawing::sptRectangle: return L"v:rect"; case NSOfficeDrawing::sptRectangle: return L"v:rect";
case NSOfficeDrawing::sptEllipse: return L"v:oval"; case NSOfficeDrawing::sptEllipse: return L"v:oval";
...@@ -707,7 +725,9 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) ...@@ -707,7 +725,9 @@ std::wstring RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
} }
if (oRenderParameter.sValue.empty()) if (oRenderParameter.sValue.empty())
oRenderParameter.sValue = GetShapeNodeName(m_nShapeType); {
oRenderParameter.sValue = GetShapeNodeName();
}
sResult += L"<" + oRenderParameter.sValue; sResult += L"<" + oRenderParameter.sValue;
...@@ -1285,7 +1305,9 @@ std::wstring RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter) ...@@ -1285,7 +1305,9 @@ std::wstring RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter)
std::wstring sResult; std::wstring sResult;
if (oRenderParameter.sValue.empty()) if (oRenderParameter.sValue.empty())
oRenderParameter.sValue = GetShapeNodeName(m_nShapeType); {
oRenderParameter.sValue = GetShapeNodeName();
}
sResult += L"</" + oRenderParameter.sValue + L">"; sResult += L"</" + oRenderParameter.sValue + L">";
......
...@@ -39,6 +39,7 @@ private: ...@@ -39,6 +39,7 @@ private:
bool m_bDelete; bool m_bDelete;
public: public:
bool m_bBackground;
bool m_bIsOle; bool m_bIsOle;
bool m_bInGroup; //local anchor bool m_bInGroup; //local anchor
...@@ -166,6 +167,10 @@ public: ...@@ -166,6 +167,10 @@ public:
int m_nFillOpacity; int m_nFillOpacity;
int m_nFillFocus; int m_nFillFocus;
int m_nFillAngle; int m_nFillAngle;
int m_nFillToBottom;
int m_nFillToTop;
int m_nFillToRight;
int m_nFillToLeft;
//int m_bFillShape; //есть копия заливки картинкой //int m_bFillShape; //есть копия заливки картинкой
//Line //Line
int m_bLine; //fLine Has a line int m_bLine; //fLine Has a line
...@@ -251,7 +256,7 @@ public: ...@@ -251,7 +256,7 @@ public:
} }
} }
std::wstring RenderToRtfShapeProperty(RenderParameter oRenderParameter); std::wstring RenderToRtfShapeProperty(RenderParameter oRenderParameter);
std::wstring GetShapeNodeName(int type); std::wstring GetShapeNodeName();
}; };
......
...@@ -274,28 +274,37 @@ int RtfWriter::GetCount() ...@@ -274,28 +274,37 @@ int RtfWriter::GetCount()
std::wstring RtfWriter::CreateRtfStart() std::wstring RtfWriter::CreateRtfStart()
{ {
RenderParameter oRenderParameter; RenderParameter oRenderParameter;
oRenderParameter.poDocument = &m_oDocument; oRenderParameter.poDocument = &m_oDocument;
oRenderParameter.poWriter = this; oRenderParameter.poWriter = this;
oRenderParameter.nType = RENDER_TO_RTF_PARAM_UNKNOWN; oRenderParameter.nType = RENDER_TO_RTF_PARAM_UNKNOWN;
std::wstring sResult; std::wstring sResult;
sResult += L"{\\rtf1\\ulc1"; sResult += L"{\\rtf1\\ulc1";
sResult += m_oDocument.m_oProperty.RenderToRtf( oRenderParameter ); sResult += m_oDocument.m_oProperty.RenderToRtf( oRenderParameter );
sResult += m_oDocument.m_oFontTable.RenderToRtf( oRenderParameter ); sResult += m_oDocument.m_oFontTable.RenderToRtf( oRenderParameter );
sResult += m_oDocument.m_oColorTable.RenderToRtf( oRenderParameter ); sResult += m_oDocument.m_oColorTable.RenderToRtf( oRenderParameter );
//---------- test
std::wstring sDefCharProp = m_oDocument.m_oDefaultCharProp.RenderToRtf( oRenderParameter ); std::wstring sDefCharProp = m_oDocument.m_oDefaultCharProp.RenderToRtf( oRenderParameter );
if( false == sDefCharProp.empty() )
if( false == sDefCharProp.empty() )
sResult += L"{\\*\\defchp " + sDefCharProp + L"}"; sResult += L"{\\*\\defchp " + sDefCharProp + L"}";
std::wstring sDefParProp = m_oDocument.m_oDefaultParagraphProp.RenderToRtf( oRenderParameter ); std::wstring sDefParProp = m_oDocument.m_oDefaultParagraphProp.RenderToRtf( oRenderParameter );
if( false == sDefParProp.empty() )
if( false == sDefParProp.empty() )
sResult += L"{\\*\\defpap " + sDefParProp+ L"}"; sResult += L"{\\*\\defpap " + sDefParProp+ L"}";
sResult += m_oDocument.m_oStyleTable.RenderToRtf( oRenderParameter ); sResult += m_oDocument.m_oStyleTable.RenderToRtf( oRenderParameter );
//---------- test
sResult += m_oDocument.m_oListTable.RenderToRtf ( oRenderParameter ); sResult += m_oDocument.m_oListTable.RenderToRtf ( oRenderParameter );
sResult += m_oDocument.m_oListOverrideTable.RenderToRtf ( oRenderParameter ); sResult += m_oDocument.m_oListOverrideTable.RenderToRtf ( oRenderParameter );
sResult += m_oDocument.m_oRevisionTable.RenderToRtf ( oRenderParameter ); sResult += m_oDocument.m_oRevisionTable.RenderToRtf ( oRenderParameter );
sResult += m_oDocument.m_oInformation.RenderToRtf ( oRenderParameter ); sResult += m_oDocument.m_oInformation.RenderToRtf ( oRenderParameter );
if (m_oDocument.m_pBackground)
{
sResult += m_oDocument.m_pBackground->RenderToRtf ( oRenderParameter );
}
sResult += L"\\fet2";//0 Footnotes only or nothing at all (the default). 1 Endnotes only. 2 Both footnotes and endnotes sResult += L"\\fet2";//0 Footnotes only or nothing at all (the default). 1 Endnotes only. 2 Both footnotes and endnotes
std::wstring sFootnote; std::wstring sFootnote;
...@@ -323,7 +332,6 @@ std::wstring RtfWriter::CreateRtfStart() ...@@ -323,7 +332,6 @@ std::wstring RtfWriter::CreateRtfStart()
if( !sFootnote.empty() ) if( !sFootnote.empty() )
sResult += L"{\\*\\aftnsepc " + sFootnote + L"}"; sResult += L"{\\*\\aftnsepc " + sFootnote + L"}";
} }
sResult += L"\n\n"; sResult += L"\n\n";
return sResult; return sResult;
} }
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
* *
*/ */
#include "OOXDocumentWriter.h" #include "OOXDocumentWriter.h"
//#include "OOXContentTypesWriter.h"
#include "OOXRelsWriter.h" #include "OOXRelsWriter.h"
#include "OOXDocumentWriter.h" #include "OOXDocumentWriter.h"
#include "OOXNumberingWriter.h" #include "OOXNumberingWriter.h"
...@@ -41,33 +40,42 @@ ...@@ -41,33 +40,42 @@
#include "OOXFootnoteWriter.h" #include "OOXFootnoteWriter.h"
#include "OOXStylesWriter.h" #include "OOXStylesWriter.h"
//#include "../../../../ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h"
std::wstring OOXDocumentWriter::CreateXmlStart() std::wstring OOXDocumentWriter::CreateXmlStart()
{ {
//пишем Footnotes //пишем Footnotes
RenderParameter oNewParam; RenderParameter oNewParam;
oNewParam.poDocument = &m_oDocument; oNewParam.poDocument = &m_oDocument;
oNewParam.poWriter = &m_oWriter; oNewParam.poWriter = &m_oWriter;
oNewParam.poRels = &m_oWriter.m_oDocRels; oNewParam.poRels = &m_oWriter.m_oDocRels;
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
//пишем document.xml
std::wstring sResult = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n";
sResult += L"<w:document";
sResult += L" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"";
sResult += L" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"";
sResult += L" xmlns:v=\"urn:schemas-microsoft-com:vml\"";
sResult += L" xmlns:o=\"urn:schemas-microsoft-com:office:office\"";
sResult += L" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\"";
sResult += L" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"";
sResult += L" xmlns:w10=\"urn:schemas-microsoft-com:office:word\"";
sResult += L" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"";
sResult += L">";
if (m_oDocument.m_pBackground)
{
RtfColor color(m_oDocument.m_pBackground->m_nFillColor);
sResult += L"<w:background w:color=\"" + color.ToHexColor() + L"\">";
{
oNewParam.nType = RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2;
sResult += m_oDocument.m_pBackground->RenderToOOX(oNewParam);
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
}
sResult += L"</w:background>";
}
//пишем document.xml sResult += L"<w:body>";
std::wstring sResult = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
sResult += _T("<w:document");
sResult += _T(" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"");
sResult += _T(" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
sResult += _T(" xmlns:v=\"urn:schemas-microsoft-com:vml\"");
sResult += _T(" xmlns:o=\"urn:schemas-microsoft-com:office:office\"");
sResult += _T(" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\"");
sResult += _T(" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"");
sResult += _T(" xmlns:w10=\"urn:schemas-microsoft-com:office:word\"");
sResult += _T(" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"");
sResult += _T(">");
sResult += _T("<w:body>");
return sResult; return sResult;
} }
std::wstring OOXDocumentWriter::CreateXmlEnd( ) std::wstring OOXDocumentWriter::CreateXmlEnd( )
...@@ -88,25 +96,25 @@ std::wstring OOXDocumentWriter::CreateXmlEnd( ) ...@@ -88,25 +96,25 @@ std::wstring OOXDocumentWriter::CreateXmlEnd( )
{ {
oNewParam.poRels = poFootnoteWriter->m_oRelsWriter.get(); oNewParam.poRels = poFootnoteWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poFootnoteWriter->AddFootnoteBegin( _T("continuationSeparator"), 1, m_oDocument.m_oFootnoteCon->RenderToOOX( oNewParam ) ); poFootnoteWriter->AddFootnoteBegin( L"continuationSeparator", 1, m_oDocument.m_oFootnoteCon->RenderToOOX( oNewParam ) );
} }
if( NULL != m_oDocument.m_oFootnoteSep ) if( NULL != m_oDocument.m_oFootnoteSep )
{ {
oNewParam.poRels = poFootnoteWriter->m_oRelsWriter.get(); oNewParam.poRels = poFootnoteWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poFootnoteWriter->AddFootnoteBegin( _T("separator"), 0, m_oDocument.m_oFootnoteSep->RenderToOOX(oNewParam) ); poFootnoteWriter->AddFootnoteBegin( L"separator", 0, m_oDocument.m_oFootnoteSep->RenderToOOX(oNewParam) );
} }
if( NULL != m_oDocument.m_oEndnoteCon ) if( NULL != m_oDocument.m_oEndnoteCon )
{ {
oNewParam.poRels = poEndnoteWriter->m_oRelsWriter.get(); oNewParam.poRels = poEndnoteWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poEndnoteWriter->AddEndnoteBegin( _T("continuationSeparator"), 1, m_oDocument.m_oEndnoteSep->RenderToOOX(oNewParam) ); poEndnoteWriter->AddEndnoteBegin( L"continuationSeparator", 1, m_oDocument.m_oEndnoteSep->RenderToOOX(oNewParam) );
} }
if( NULL != m_oDocument.m_oEndnoteSep ) if( NULL != m_oDocument.m_oEndnoteSep )
{ {
oNewParam.poRels = poEndnoteWriter->m_oRelsWriter.get(); oNewParam.poRels = poEndnoteWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN; oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poEndnoteWriter->AddEndnoteBegin( _T("separator"), 0, m_oDocument.m_oEndnoteSep->RenderToOOX(oNewParam) ); poEndnoteWriter->AddEndnoteBegin( L"separator", 0, m_oDocument.m_oEndnoteSep->RenderToOOX(oNewParam) );
} }
//fontTable.xml //fontTable.xml
...@@ -142,20 +150,20 @@ std::wstring OOXDocumentWriter::CreateXmlEnd( ) ...@@ -142,20 +150,20 @@ std::wstring OOXDocumentWriter::CreateXmlEnd( )
if( false == sTempParaDef.empty() || false == sTempCharDef.empty() ) if( false == sTempParaDef.empty() || false == sTempCharDef.empty() )
{ {
sStyles += _T("<w:docDefaults>"); sStyles += L"<w:docDefaults>";
if( false == sTempCharDef.empty() ) if( false == sTempCharDef.empty() )
{ {
sStyles += _T("<w:rPrDefault><w:rPr>"); sStyles += L"<w:rPrDefault><w:rPr>";
sStyles += sTempCharDef ; sStyles += sTempCharDef ;
sStyles += _T("</w:rPr></w:rPrDefault>"); sStyles += L"</w:rPr></w:rPrDefault>";
} }
if( false == sTempParaDef.empty() ) if( false == sTempParaDef.empty() )
{ {
sStyles += _T("<w:pPrDefault><w:pPr>"); sStyles += L"<w:pPrDefault><w:pPr>";
sStyles += sTempParaDef; sStyles += sTempParaDef;
sStyles += _T("</w:pPr></w:pPrDefault>"); sStyles += L"</w:pPr></w:pPrDefault>";
} }
sStyles += _T("</w:docDefaults>"); sStyles += L"</w:docDefaults>";
} }
sStyles += m_oDocument.m_oStyleTable.RenderToOOX(oNewParam); sStyles += m_oDocument.m_oStyleTable.RenderToOOX(oNewParam);
...@@ -182,28 +190,28 @@ std::wstring OOXDocumentWriter::CreateXmlEnd( ) ...@@ -182,28 +190,28 @@ std::wstring OOXDocumentWriter::CreateXmlEnd( )
sResult += m_oDocument[0].props->m_oProperty.RenderToOOX(oNewParam); sResult += m_oDocument[0].props->m_oProperty.RenderToOOX(oNewParam);
sResult += _T("</w:body>"); sResult += L"</w:body>";
sResult += _T("</w:document>"); sResult += L"</w:document>";
return sResult; return sResult;
} }
bool OOXDocumentWriter::SaveByItemStart( std::wstring sFolder ) bool OOXDocumentWriter::SaveByItemStart( std::wstring sFolder )
{ {
std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + _T("word"); std::wstring pathWord = sFolder + FILE_SEPARATOR_STR + L"word";
NSDirectory::CreateDirectory(pathWord) ; NSDirectory::CreateDirectory(pathWord) ;
try try
{ {
std::wstring sFilename = pathWord + FILE_SEPARATOR_STR + _T("document.xml"); std::wstring sFilename = pathWord + FILE_SEPARATOR_STR + L"document.xml";
m_oFileWriter = new NFileWriter::CBufferedFileWriter( sFilename ); m_oFileWriter = new NFileWriter::CBufferedFileWriter( sFilename );
} }
catch(...) catch(...)
{ {
return false; return false;
} }
m_oWriter.m_oRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"), _T("word/document.xml") ); m_oWriter.m_oRels.AddRelationship( L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"word/document.xml" );
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"), _T("/word/document.xml") ); m_oWriter.m_oContentTypes.AddContent( L"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", L"/word/document.xml" );
std::wstring sXml = CreateXmlStart( ); std::wstring sXml = CreateXmlStart( );
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml); std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
...@@ -261,7 +269,7 @@ bool OOXDocumentWriter::SaveByItem() ...@@ -261,7 +269,7 @@ bool OOXDocumentWriter::SaveByItem()
else else
{ {
//генерация ??? //генерация ???
sXml = _T("<w:p><w:pPr>") + sectPr + _T("</w:pPr></w:p>"); sXml = L"<w:p><w:pPr>" + sectPr + L"</w:pPr></w:p>";
} }
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml); std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
class OOXDocumentWriter class OOXDocumentWriter
{ {
private: private:
OOXWriter& m_oWriter; OOXWriter& m_oWriter;
RtfDocument& m_oDocument; RtfDocument& m_oDocument;
NFileWriter::CBufferedFileWriter* m_oFileWriter; NFileWriter::CBufferedFileWriter* m_oFileWriter;
bool m_bFirst; //один параграф пишем другой храним в памяти bool m_bFirst; //один параграф пишем другой храним в памяти
public: public:
OOXDocumentWriter( OOXWriter& oWriter,RtfDocument& oDocument ): m_oWriter(oWriter), m_oDocument(oDocument) OOXDocumentWriter( OOXWriter& oWriter,RtfDocument& oDocument ): m_oWriter(oWriter), m_oDocument(oDocument)
{ {
...@@ -64,7 +64,9 @@ public: ...@@ -64,7 +64,9 @@ public:
{ {
int nCount = 0; int nCount = 0;
for( int i = 0; i < m_oDocument.GetCount(); i++ ) for( int i = 0; i < m_oDocument.GetCount(); i++ )
{
nCount += m_oDocument[i].props->GetCount(); nCount += m_oDocument[i].props->GetCount();
}
return nCount; return nCount;
} }
}; };
...@@ -643,7 +643,7 @@ namespace OOX ...@@ -643,7 +643,7 @@ namespace OOX
nullable<OOX::Logic::CBackground > m_oBackground; nullable<OOX::Logic::CBackground > m_oBackground;
std::vector<WritingElement *> m_arrItems; std::vector<WritingElement *> m_arrItems;
std::vector<std::wstring> m_arrShapeTypes; std::vector<std::wstring> m_arrShapeTypes;
}; };
......
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