Commit 2577365e authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatWriter - small refactoring + fix users file

parent 00df0261
...@@ -588,7 +588,7 @@ namespace NSPresentationEditor ...@@ -588,7 +588,7 @@ namespace NSPresentationEditor
#else #else
std::wstring ConvertPPTtoPPTX(CPPTShape* pPPTShape, const NSGuidesVML::CFormParam& pCoef, bool bIsNamespace = false) std::wstring ConvertPPTtoPPTX(CPPTShape* pPPTShape, const NSGuidesVML::CFormParam& pCoef, bool bIsNamespace = false)
{ {
if (pPPTShape->m_eType == PPTShapes::sptCRect) if (pPPTShape->m_eType == PPTShapes::sptCRect || pPPTShape->m_eType == PPTShapes::sptCFrame)
{ {
if (bIsNamespace) if (bIsNamespace)
{ {
...@@ -604,7 +604,14 @@ namespace NSPresentationEditor ...@@ -604,7 +604,14 @@ namespace NSPresentationEditor
} }
return _T("<a:prstGeom prst=\"line\"><a:avLst/></a:prstGeom>"); return _T("<a:prstGeom prst=\"line\"><a:avLst/></a:prstGeom>");
} }
else if (pPPTShape->m_eType == PPTShapes::sptCEllipse)
{
if (bIsNamespace)
{
return _T("<a:prstGeom xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" prst=\"line\"><a:avLst/></a:prstGeom>");
}
return _T("<a:prstGeom prst=\"ellipse\"><a:avLst/></a:prstGeom>");
}
std::wstring strXmlPPTX = bIsNamespace ? _T("<a:custGeom xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">") : _T("<a:custGeom>"); std::wstring strXmlPPTX = bIsNamespace ? _T("<a:custGeom xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">") : _T("<a:custGeom>");
CFormulaConverter pFormulaConverter; CFormulaConverter pFormulaConverter;
......
...@@ -44,13 +44,13 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput) ...@@ -44,13 +44,13 @@ int OOXGraphicReader::Parse( ReaderParameter oParam , RtfShapePtr & pOutput)
{ {
if (m_ooxGraphic->element.getType() == OOX::et_p_ShapeTree) if (m_ooxGraphic->element.getType() == OOX::et_p_ShapeTree)
{ {
OOXShapeReader shapeReader(m_ooxGraphic->element.GetElem().operator->()); OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->element.GetElem().operator->()));
return (shapeReader.Parse(oParam, pOutput) ? 1 : 0); return (groupReader.Parse(oParam, pOutput) ? 1 : 0);
} }
else else
{ {
OOXShapeGroupReader groupReader(dynamic_cast<PPTX::Logic::SpTree*>(m_ooxGraphic->element.GetElem().operator->())); OOXShapeReader shapeReader(m_ooxGraphic->element.GetElem().operator->());
return (groupReader.Parse(oParam, pOutput) ? 1 : 0); return (shapeReader.Parse(oParam, pOutput) ? 1 : 0);
} }
} }
if (m_ooxGraphic->olePic.IsInit()) if (m_ooxGraphic->olePic.IsInit())
......
...@@ -49,6 +49,15 @@ public: ...@@ -49,6 +49,15 @@ public:
pOutput->m_eAnchorTypeShape = RtfShape::st_anchor; pOutput->m_eAnchorTypeShape = RtfShape::st_anchor;
if ( m_ooxAnchor->m_oDocPr.IsInit() )
{
pOutput->m_nID = m_ooxAnchor->m_oDocPr->id + 1025;
pOutput->m_sName = m_ooxAnchor->m_oDocPr->name;
if (m_ooxAnchor->m_oDocPr->descr.IsInit())
pOutput->m_sDescription = m_ooxAnchor->m_oDocPr->descr.get();
}
pOutput->m_bAllowOverlap = m_ooxAnchor->m_oAllowOverlap.IsInit() ? m_ooxAnchor->m_oAllowOverlap->ToBool() : false; pOutput->m_bAllowOverlap = m_ooxAnchor->m_oAllowOverlap.IsInit() ? m_ooxAnchor->m_oAllowOverlap->ToBool() : false;
pOutput->m_nZOrderRelative = m_ooxAnchor->m_oBehindDoc.IsInit() ? m_ooxAnchor->m_oBehindDoc->ToBool() : false; pOutput->m_nZOrderRelative = m_ooxAnchor->m_oBehindDoc.IsInit() ? m_ooxAnchor->m_oBehindDoc->ToBool() : false;
pOutput->m_bHidden = m_ooxAnchor->m_oHidden.IsInit() ? m_ooxAnchor->m_oHidden->ToBool() : false; pOutput->m_bHidden = m_ooxAnchor->m_oHidden.IsInit() ? m_ooxAnchor->m_oHidden->ToBool() : false;
......
...@@ -77,6 +77,15 @@ public: ...@@ -77,6 +77,15 @@ public:
} }
} }
} }
if ( m_ooxInline->m_oDocPr.IsInit() )
{
pOutput->m_nID = m_ooxInline->m_oDocPr->id + 1025;
pOutput->m_sName = m_ooxInline->m_oDocPr->name;
if (m_ooxInline->m_oDocPr->descr.IsInit())
pOutput->m_sDescription = m_ooxInline->m_oDocPr->descr.get();
}
OOXGraphicReader oGraphicReader(&m_ooxInline->m_oGraphic); OOXGraphicReader oGraphicReader(&m_ooxInline->m_oGraphic);
......
...@@ -67,6 +67,12 @@ public: ...@@ -67,6 +67,12 @@ public:
static bool Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::BlipFill *oox_bitmap_fill); static bool Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::BlipFill *oox_bitmap_fill);
private: private:
bool ParseShape( ReaderParameter oParam , RtfShapePtr& oOutput);
bool ParsePic( ReaderParameter oParam , RtfShapePtr& oOutput);
void Parse(ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::Logic::Xfrm *xfrm);
void Parse(ReaderParameter oParam, PPTX::Logic::ColorBase *oox_color, unsigned int & nColor, _CP_OPT(double) &opacity); void Parse(ReaderParameter oParam, PPTX::Logic::ColorBase *oox_color, unsigned int & nColor, _CP_OPT(double) &opacity);
void Parse(ReaderParameter oParam, PPTX::Logic::SolidFill *oox_solid_fill, unsigned int & nColor, _CP_OPT(double) &opacity); void Parse(ReaderParameter oParam, PPTX::Logic::SolidFill *oox_solid_fill, unsigned int & nColor, _CP_OPT(double) &opacity);
......
...@@ -256,8 +256,6 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -256,8 +256,6 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
sResult += L"{\\shp"; sResult += L"{\\shp";
sResult += L"{\\*\\shpinst"; sResult += L"{\\*\\shpinst";
RENDER_RTF_INT( m_nID , sResult, L"shplid" );
if (!m_bInGroup) if (!m_bInGroup)
{ {
m_bAllowOverlap = 1; m_bAllowOverlap = 1;
...@@ -265,8 +263,8 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -265,8 +263,8 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
m_nWrapType = 3; m_nWrapType = 3;
m_nWrapSideType = 0; m_nWrapSideType = 0;
m_bLockAnchor = 0; m_bLockAnchor = 0;
m_nZOrder = PROP_DEF; m_nZOrder = 0;//PROP_DEF;
m_nZOrderRelative = PROP_DEF; m_nZOrderRelative = 0;//PROP_DEF;
m_nLeft = m_nTop = 0; m_nLeft = m_nTop = 0;
m_nRelBottom = m_nRelRight = PROP_DEF; m_nRelBottom = m_nRelRight = PROP_DEF;
m_nPositionV = m_nPositionH = PROP_DEF; m_nPositionV = m_nPositionH = PROP_DEF;
...@@ -278,26 +276,29 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -278,26 +276,29 @@ std::wstring RtfShape::RenderToRtf(RenderParameter oRenderParameter)
RENDER_RTF_INT ( m_nHeader , sResult, L"shpfhdr" ); RENDER_RTF_INT ( m_nHeader , sResult, L"shpfhdr" );
//sResult += L"\\shpbxcolumn"; sResult += L"\\shpbxcolumn";
sResult += L"\\shpbxignore"; sResult += L"\\shpbxignore";
//sResult += L"\\shpbypara"; sResult += L"\\shpbypara";
sResult += L"\\shpbyignore"; sResult += L"\\shpbyignore";
RENDER_RTF_INT ( m_nWrapType , sResult, L"shpwr" ); RENDER_RTF_INT ( m_nWrapType , sResult, L"shpwr" );
RENDER_RTF_INT ( m_nWrapSideType , sResult, L"shpwrk" ); RENDER_RTF_INT ( m_nWrapSideType , sResult, L"shpwrk" );
//sResult += L"\\shpfblwtxt0";
sResult += L"\\shplockanchor";
RENDER_RTF_INT ( m_nZOrder , sResult, L"shpz" );
sResult += L"{\\sp{\\sn fUseShapeAnchor}{\\sv 0}}"; //if (st_none == m_eAnchorTypeShape)
sResult += L"{\\sp{\\sn fPseudoInline}{\\sv 1}}"; {
RENDER_RTF_INT ( m_nZOrder, sResult, L"shpz" );
}
sResult += L"\\shplockanchor";
//sResult += L"{\\sp{\\sn fUseShapeAnchor}{\\sv 0}}";
//sResult += L"{\\sp{\\sn fPseudoInline}{\\sv 1}}";
RENDER_RTF_INT( m_nID, sResult, L"shplid" );
} }
sResult += RenderToRtfShapeProperty( oRenderParameter ); sResult += RenderToRtfShapeProperty( oRenderParameter );
sResult += L"{\\sp{\\sn fLockPosition}{\\sv 1}}"; //sResult += L"{\\sp{\\sn fLockPosition}{\\sv 1}}";
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 == 3 || m_nFillType == 9) if( 0 != m_oPicture && m_nFillType == 1 || m_nFillType == 2 || m_nFillType == 3 || m_nFillType == 9)
...@@ -421,11 +422,14 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -421,11 +422,14 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
std::wstring sResult; std::wstring sResult;
//Position absolute //Position absolute
RENDER_RTF_SHAPE_PROP(L"posh", sResult, m_nPositionH); //if( st_inline != m_eAnchorTypeShape)
RENDER_RTF_SHAPE_PROP(L"posrelh", sResult, m_nPositionHRelative); {
RENDER_RTF_SHAPE_PROP(L"posv", sResult, m_nPositionV); RENDER_RTF_SHAPE_PROP(L"posh", sResult, m_nPositionH);
RENDER_RTF_SHAPE_PROP(L"posrelh", sResult, m_nPositionHRelative);
RENDER_RTF_SHAPE_PROP(L"posv", sResult, m_nPositionV);
RENDER_RTF_SHAPE_PROP(L"posrelv", sResult, m_nPositionVRelative);
}
RENDER_RTF_SHAPE_PROP(L"posrelv", sResult, m_nPositionVRelative);
RENDER_RTF_SHAPE_PROP(L"fLayoutInCell", sResult, m_bLayoutInCell); RENDER_RTF_SHAPE_PROP(L"fLayoutInCell", sResult, m_bLayoutInCell);
RENDER_RTF_SHAPE_PROP(L"fAllowOverlap", sResult, m_bAllowOverlap); RENDER_RTF_SHAPE_PROP(L"fAllowOverlap", sResult, m_bAllowOverlap);
...@@ -438,6 +442,17 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -438,6 +442,17 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
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);
if (m_sName.empty() == false)
{
sResult += L"{\\sp{\\sn wzName}{\\sv ";
sResult += m_sName + L"}}";
}
if (m_sDescription.empty() == false)
{
sResult += L"{\\sp{\\sn wzDescription}{\\sv ";
sResult += m_sDescription + L"}}";
}
//Rehydration //Rehydration
//RENDER_RTF_SHAPE_PROP(L"metroBlob", sResult, m_sMetroBlob); //RENDER_RTF_SHAPE_PROP(L"metroBlob", sResult, m_sMetroBlob);
...@@ -449,7 +464,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -449,7 +464,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); //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}}";
...@@ -586,7 +601,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter ...@@ -586,7 +601,7 @@ std::wstring RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter
int nCodePage = -1; int nCodePage = -1;
if( !m_sGtextFont.empty() ) if( m_sGtextFont.empty() == false)
{ {
sResult += L"{\\sp{\\sn gtextFont}{\\sv "; sResult += L"{\\sp{\\sn gtextFont}{\\sv ";
sResult += m_sGtextFont + L"}}"; sResult += m_sGtextFont + L"}}";
...@@ -1487,8 +1502,8 @@ std::wstring RtfShape::GroupRenderToRtf(RenderParameter oRenderParameter) ...@@ -1487,8 +1502,8 @@ std::wstring RtfShape::GroupRenderToRtf(RenderParameter oRenderParameter)
RENDER_RTF_INT( m_nWrapSideType , sResult, L"shpwrk" ); RENDER_RTF_INT( m_nWrapSideType , sResult, L"shpwrk" );
RENDER_RTF_BOOL( m_bLockAnchor , sResult, L"shplockanchor" ); RENDER_RTF_BOOL( m_bLockAnchor , sResult, L"shplockanchor" );
//sResult += L"{\\sp{\\sn fUseShapeAnchor}{\\sv 0}}"; sResult += L"{\\sp{\\sn fUseShapeAnchor}{\\sv 0}}";
//sResult += L"{\\sp{\\sn fPseudoInline}{\\sv 1}}"; sResult += L"{\\sp{\\sn fPseudoInline}{\\sv 1}}";
} }
......
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8,00"
Name="RtfFormatTest" Name="RtfFormatTest"
ProjectGUID="{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}" ProjectGUID="{0F49D5D1-A8D3-4F97-8BC1-E2F65BB00C10}"
RootNamespace="RtfFormatTest" RootNamespace="RtfFormatTest"
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..\Common\OfficeDrawing;&quot;..\..\DesktopEditor\freetype-2.5.2\include&quot;;..\..\..\..\..\Common\OfficeDrawing\Shapes" AdditionalIncludeDirectories="../../DesktopEditor/xml/libxml2/include;../../DesktopEditor/xml/build/vs2005"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;USE_LITE_READER;_USE_XMLLITE_READER_;PPTX_DEF;PPT_DEF;ENABLE_PPT_TO_PPTX_CONVERT;AVS_USE_CONVERT_PPTX_TOCUSTOM_VML;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="false" MinimalRebuild="false"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
......
...@@ -2106,21 +2106,6 @@ namespace BinXlsxRW { ...@@ -2106,21 +2106,6 @@ namespace BinXlsxRW {
res = c_oSerConstants::ReadUnknown; res = c_oSerConstants::ReadUnknown;
return res; return res;
} }
int ReadVbaProject(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
smart_ptr<OOX::VbaProject> oFileVbaProject(new OOX::VbaProject());
oFileVbaProject->fromPPTY(&m_oBufferedStream);
smart_ptr<OOX::File> oFile = oFileVbaProject.smart_dynamic_cast<OOX::File>();
const OOX::RId oRId = m_oWorkbook.Add(oFile);
m_oWorkbook.m_bMacroEnabled = true;
return res;
}
}; };
class BinaryCommentReader : public Binary_CommonReader<BinaryCommentReader> class BinaryCommentReader : public Binary_CommonReader<BinaryCommentReader>
{ {
......
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