Commit d0b4fc4b authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatReader/Writer - fix bugs, add new convertation elements

parent 987839a6
...@@ -386,10 +386,14 @@ namespace DocFileFormat ...@@ -386,10 +386,14 @@ namespace DocFileFormat
GroupShapeBooleanProperties groupShapeBooleans(iter->op); GroupShapeBooleanProperties groupShapeBooleans(iter->op);
if (groupShapeBooleans.fUsefBehindDocument && groupShapeBooleans.fBehindDocument) if (groupShapeBooleans.fUsefBehindDocument && groupShapeBooleans.fBehindDocument)
{//m_isInlineShape ??? {
//The shape is behind the text, so the z-index must be negative. //The shape is behind the text, so the z-index must be negative.
appendStyleProperty(&strStyle, _T( "z-index" ), _T( "-1" ) ); appendStyleProperty(&strStyle, _T( "z-index" ), _T( "-1" ) );
} }
//else if (!m_isInlinePicture)
//{
// appendStyleProperty( &strStyle, _T( "z-index" ), FormatUtils::IntToWideString(zIndex + 0x7ffff));
//}
if (groupShapeBooleans.fHidden && groupShapeBooleans.fUsefHidden) if (groupShapeBooleans.fHidden && groupShapeBooleans.fUsefHidden)
{ {
......
...@@ -1438,6 +1438,8 @@ namespace DocFileFormat ...@@ -1438,6 +1438,8 @@ namespace DocFileFormat
bool bPosH = false; bool bPosH = false;
bool bPosV = false; bool bPosV = false;
bool bZIndex = false;
std::list<OptionEntry>::const_iterator end = options.end(); std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter) for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
{ {
...@@ -1469,14 +1471,16 @@ namespace DocFileFormat ...@@ -1469,14 +1471,16 @@ namespace DocFileFormat
{ {
GroupShapeBooleanProperties groupShapeBooleans(iter->op); GroupShapeBooleanProperties groupShapeBooleans(iter->op);
if (groupShapeBooleans.fUsefBehindDocument && groupShapeBooleans.fBehindDocument) if (groupShapeBooleans.fUsefBehindDocument && groupShapeBooleans.fBehindDocument && !bZIndex)
{ {
//The shape is behind the text, so the z-index must be negative. //The shape is behind the text, so the z-index must be negative.
appendStyleProperty(oStyle, _T( "z-index" ), _T( "-1" ) ); appendStyleProperty(oStyle, _T( "z-index" ), _T( "-1" ) );
bZIndex = true;
} }
else if (!m_isInlineShape) else if (!m_isInlineShape && !bZIndex)
{ {
appendStyleProperty( oStyle, _T( "z-index" ), FormatUtils::IntToWideString(zIndex + 0x7ffff)); appendStyleProperty( oStyle, _T( "z-index" ), FormatUtils::IntToWideString(zIndex + 0x7ffff));
bZIndex = true;
} }
if (groupShapeBooleans.fHidden && groupShapeBooleans.fUsefHidden) if (groupShapeBooleans.fHidden && groupShapeBooleans.fUsefHidden)
......
...@@ -63,6 +63,7 @@ bool ShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CStr ...@@ -63,6 +63,7 @@ bool ShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CStr
{ {
if( PROP_DEF == m_oShape.m_nShapeType ) if( PROP_DEF == m_oShape.m_nShapeType )
m_oShape.m_nShapeType = 202;//Text box m_oShape.m_nShapeType = 202;//Text box
ParagraphReader oParagraphReader(_T("shptxt"), oReader); ParagraphReader oParagraphReader(_T("shptxt"), oReader);
StartSubReader( oParagraphReader, oDocument, oReader ); StartSubReader( oParagraphReader, oDocument, oReader );
m_oShape.m_aTextItems = oParagraphReader.m_oParPropDest.m_oTextItems; m_oShape.m_aTextItems = oParagraphReader.m_oParPropDest.m_oTextItems;
...@@ -170,13 +171,17 @@ bool PictureReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CS ...@@ -170,13 +171,17 @@ bool PictureReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CS
else if( _T("picw") == sCommand ) else if( _T("picw") == sCommand )
{ {
if( true == hasParameter ) if( true == hasParameter )
{
m_oShape.m_oPicture->m_nWidth = parameter; m_oShape.m_oPicture->m_nWidth = parameter;
} }
}
else if( _T("pich") == sCommand ) else if( _T("pich") == sCommand )
{ {
if( true == hasParameter ) if( true == hasParameter )
{
m_oShape.m_oPicture->m_nHeight = parameter; m_oShape.m_oPicture->m_nHeight = parameter;
} }
}
else if( _T("picwgoal") == sCommand ) else if( _T("picwgoal") == sCommand )
{ {
if( true == hasParameter ) if( true == hasParameter )
......
...@@ -1245,8 +1245,10 @@ public: ...@@ -1245,8 +1245,10 @@ public:
RtfUtility::WriteDataToFileBinary( sTempFile, m_pbBin, m_nBinLength ); RtfUtility::WriteDataToFileBinary( sTempFile, m_pbBin, m_nBinLength );
else else
RtfUtility::WriteDataToFile( sTempFile, m_sData ); RtfUtility::WriteDataToFile( sTempFile, m_sData );
if( RtfPicture::dt_none == m_oShape.m_oPicture->eDataType ) if( RtfPicture::dt_none == m_oShape.m_oPicture->eDataType )
RtfPicture::DataType eDataType = RtfPicture::GetPictureType( sTempFile ); m_oShape.m_oPicture->eDataType = RtfPicture::GetPictureType( sTempFile );
m_oShape.m_oPicture->m_bIsCopy = true; m_oShape.m_oPicture->m_bIsCopy = true;
m_oShape.m_oPicture->m_sPicFilename = sTempFile; m_oShape.m_oPicture->m_sPicFilename = sTempFile;
} }
...@@ -1280,7 +1282,7 @@ class ShapeReader : public RtfAbstractReader ...@@ -1280,7 +1282,7 @@ class ShapeReader : public RtfAbstractReader
{ {
if( _T("sv") == sCommand ) if( _T("sv") == sCommand )
return true; return true;
else if( _T("pict") == sCommand && _T("pib") == m_sPropName ) else if( _T("pict") == sCommand && ( _T("pib") == m_sPropName || _T("fillBlip") == m_sPropName))
{ {
m_oShape.m_oPicture = RtfPicturePtr( new RtfPicture() ); m_oShape.m_oPicture = RtfPicturePtr( new RtfPicture() );
PictureReader oPictureReader( oReader, m_oShape ); PictureReader oPictureReader( oReader, m_oShape );
...@@ -1464,20 +1466,12 @@ class ShapeReader : public RtfAbstractReader ...@@ -1464,20 +1466,12 @@ class ShapeReader : public RtfAbstractReader
m_oShape.m_nRelZOrder = nValue; m_oShape.m_nRelZOrder = nValue;
//Fill //Fill
else if( _T("fFilled") == m_sPropName ) else if( _T("fFilled") == m_sPropName )
{ m_oShape.m_bFilled = (0 == nValue ? false : true );
if( 0 == nValue ) else if( _T("fillType") == m_sPropName )
m_oShape.m_bFilled = false; m_oShape.m_nFillType = nValue;
else
m_oShape.m_bFilled = false;
}
//Line //Line
else if( _T("fLine") == m_sPropName ) else if( _T("fLine") == m_sPropName )
{ m_oShape.m_bLine = ( 0 == nValue ? false : true );
if( 0 == nValue )
m_oShape.m_bLine = false;
else
m_oShape.m_bLine = false;
}
else if( _T("lineStartArrowhead") == m_sPropName ) else if( _T("lineStartArrowhead") == m_sPropName )
m_oShape.m_nLineStartArrow = nValue; m_oShape.m_nLineStartArrow = nValue;
else if( _T("lineStartArrowWidth") == m_sPropName ) else if( _T("lineStartArrowWidth") == m_sPropName )
...@@ -1492,6 +1486,11 @@ class ShapeReader : public RtfAbstractReader ...@@ -1492,6 +1486,11 @@ class ShapeReader : public RtfAbstractReader
m_oShape.m_nLineEndArrowLength = nValue; m_oShape.m_nLineEndArrowLength = nValue;
else if( _T("lineWidth") == m_sPropName ) else if( _T("lineWidth") == m_sPropName )
m_oShape.m_nLineWidth = nValue; m_oShape.m_nLineWidth = nValue;
else
{
int val = nValue;
std::wstring name = m_sPropName.GetBuffer();
}
} }
void ExecuteText( RtfDocument& oDocument, RtfReader& oReader, CString oText ) void ExecuteText( RtfDocument& oDocument, RtfReader& oReader, CString oText )
{ {
...@@ -3394,6 +3393,8 @@ public: ...@@ -3394,6 +3393,8 @@ public:
} }
} }
else if( _T("sect") == sCommand ) else if( _T("sect") == sCommand )
{
//if (oParagraphReaderDestination.m_oTextItems->GetCount() > 0)
{ {
RtfSectionPtr oCurSection; RtfSectionPtr oCurSection;
if(true == oDocument.GetItem( oCurSection ) ) if(true == oDocument.GetItem( oCurSection ) )
...@@ -3406,11 +3407,13 @@ public: ...@@ -3406,11 +3407,13 @@ public:
oReader.m_oCurSectionProp.m_oFooterFirst = TextItemContainerPtr(); oReader.m_oCurSectionProp.m_oFooterFirst = TextItemContainerPtr();
oReader.m_oCurSectionProp.m_oFooterRight = TextItemContainerPtr(); oReader.m_oCurSectionProp.m_oFooterRight = TextItemContainerPtr();
RtfSectionPtr oNewSection = RtfSectionPtr( new RtfSection() );
oParagraphReaderDestination.Finalize( oReader ); oParagraphReaderDestination.Finalize( oReader );
RtfSectionPtr oNewSection = RtfSectionPtr( new RtfSection() );
oParagraphReaderDestination.m_oTextItems = oNewSection; oParagraphReaderDestination.m_oTextItems = oNewSection;
oDocument.AddItem( oNewSection ); oDocument.AddItem( oNewSection );
} }
}
else if( _T("sectd") == sCommand ) else if( _T("sectd") == sCommand )
{ {
SectDef( oDocument, oReader ); SectDef( oDocument, oReader );
......
...@@ -347,37 +347,15 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP ...@@ -347,37 +347,15 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
return true; return true;
} }
bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, RtfStylePtr poStyle ) bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, RtfStylePtr poStyle, RtfCharProperty& oNewProperty, OOX::WritingElement* ooxItem )
{ {
if (m_ooxRun == NULL) return false; if (!ooxItem) return false;
RtfCharProperty oNewProperty;
oNewProperty.SetDefaultOOX();
//применяем default
oNewProperty = oParam.oRtf->m_oDefaultCharProp;
//применяем внешний стиль
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty );
if( NULL != poStyle && TYPE_RTF_PROPERTY_STYLE_CHAR == poStyle->GetType() ) switch(ooxItem->getType())
{
RtfCharStylePtr oCharStyle = boost::static_pointer_cast<RtfCharStyle, RtfStyle>( poStyle );
oNewProperty.Merge( oCharStyle->m_oCharProp );
}
if (m_ooxRun->m_oRunProperty)
{
OOXrPrReader orPrReader(m_ooxRun->m_oRunProperty);
orPrReader.Parse( oParam, oNewProperty );
}
for (long i =0 ; i < m_ooxRun->m_arrItems.size(); i++)
{
switch(m_ooxRun->m_arrItems[i]->getType())
{ {
case OOX::et_w_t: case OOX::et_w_t:
{ {
OOX::Logic::CText * ooxText = dynamic_cast<OOX::Logic::CText*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CText * ooxText = dynamic_cast<OOX::Logic::CText*>(ooxItem);
if (ooxText) if (ooxText)
{ {
CString sValue; CString sValue;
...@@ -396,7 +374,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -396,7 +374,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_fldChar: case OOX::et_w_fldChar:
{ {
OOX::Logic::CFldChar * ooxFldChar = dynamic_cast<OOX::Logic::CFldChar*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CFldChar * ooxFldChar = dynamic_cast<OOX::Logic::CFldChar*>(ooxItem);
if ((ooxFldChar) && (ooxFldChar->m_oFldCharType.IsInit())) if ((ooxFldChar) && (ooxFldChar->m_oFldCharType.IsInit()))
{ {
switch(ooxFldChar->m_oFldCharType->GetValue()) switch(ooxFldChar->m_oFldCharType->GetValue())
...@@ -426,7 +404,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -426,7 +404,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_instrText: case OOX::et_w_instrText:
{ {
OOX::Logic::CInstrText * ooxInstrText = dynamic_cast<OOX::Logic::CInstrText*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CInstrText * ooxInstrText = dynamic_cast<OOX::Logic::CInstrText*>(ooxItem);
OOXFieldInsertTextPtr oNewField( new OOXFieldInsertText() ); OOXFieldInsertTextPtr oNewField( new OOXFieldInsertText() );
RtfCharPtr oNewChar( new RtfChar() ); RtfCharPtr oNewChar( new RtfChar() );
if (ooxInstrText) if (ooxInstrText)
...@@ -436,7 +414,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -436,7 +414,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_footnoteReference: case OOX::et_w_footnoteReference:
{ {
OOX::Logic::CFootnoteReference * ooxFootnoteReference = dynamic_cast<OOX::Logic::CFootnoteReference*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CFootnoteReference * ooxFootnoteReference = dynamic_cast<OOX::Logic::CFootnoteReference*>(ooxItem);
if ((ooxFootnoteReference) && (ooxFootnoteReference->m_oId.IsInit())) if ((ooxFootnoteReference) && (ooxFootnoteReference->m_oId.IsInit()))
{ {
int nID = ooxFootnoteReference->m_oId->GetValue(); int nID = ooxFootnoteReference->m_oId->GetValue();
...@@ -452,7 +430,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -452,7 +430,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_endnoteReference: case OOX::et_w_endnoteReference:
{ {
OOX::Logic::CEndnoteReference * ooxEndnoteReference = dynamic_cast<OOX::Logic::CEndnoteReference*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CEndnoteReference * ooxEndnoteReference = dynamic_cast<OOX::Logic::CEndnoteReference*>(ooxItem);
if ((ooxEndnoteReference) && (ooxEndnoteReference->m_oId.IsInit())) if ((ooxEndnoteReference) && (ooxEndnoteReference->m_oId.IsInit()))
{ {
int nID = ooxEndnoteReference->m_oId->GetValue(); int nID = ooxEndnoteReference->m_oId->GetValue();
...@@ -469,7 +447,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -469,7 +447,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_object: case OOX::et_w_object:
{ {
OOX::Logic::CObject * ooxObject = dynamic_cast<OOX::Logic::CObject*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CObject * ooxObject = dynamic_cast<OOX::Logic::CObject*>(ooxItem);
if (ooxObject) if (ooxObject)
{ {
long nOleWidth = PROP_DEF; long nOleWidth = PROP_DEF;
...@@ -606,7 +584,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -606,7 +584,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_drawing: case OOX::et_w_drawing:
{ {
OOX::Logic::CDrawing* ooxDrawing = dynamic_cast<OOX::Logic::CDrawing*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CDrawing* ooxDrawing = dynamic_cast<OOX::Logic::CDrawing*>(ooxItem);
RtfShapePtr oNewPicture( new RtfShape() ); RtfShapePtr oNewPicture( new RtfShape() );
OOXPictureReader oPictureReader(ooxDrawing); OOXPictureReader oPictureReader(ooxDrawing);
...@@ -617,13 +595,26 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -617,13 +595,26 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_pict: case OOX::et_w_pict:
{ {
OOX::Logic::CPicture *ooxPicture = dynamic_cast<OOX::Logic::CPicture*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CPicture *ooxPicture = dynamic_cast<OOX::Logic::CPicture*>(ooxItem);
if( (ooxPicture) && (ooxPicture->m_oShape.IsInit())) //??? todooo ваще то могут быть и др элементы/инициализции if( ooxPicture)
{//todooo - groups & custom
RtfShapePtr oNewShape( new RtfShape() );
OOXShapeReader *pShapeReader = NULL;
if (ooxPicture->m_oShape.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShape.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_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_oShapePolyLine.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapePolyLine.GetPointer());
else if (ooxPicture->m_oShapeCurve.IsInit()) pShapeReader = new OOXShapeReader(ooxPicture->m_oShapeCurve.GetPointer());
if (pShapeReader)
{ {
RtfShapePtr oNewPicture( new RtfShape() ); if( true == pShapeReader->Parse( oParam, oNewShape ) )
OOXShapeReader oShapeReader(ooxPicture->m_oShape.GetPointer()); oOutputParagraph.AddItem( oNewShape );
if( true == oShapeReader.Parse( oParam, oNewPicture ) ) delete pShapeReader;
oOutputParagraph.AddItem( oNewPicture ); }
} }
}break; }break;
case OOX::et_w_nonBreakHyphen: case OOX::et_w_nonBreakHyphen:
...@@ -684,7 +675,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -684,7 +675,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break; }break;
case OOX::et_w_br: case OOX::et_w_br:
{ {
OOX::Logic::CBr *ooxBr = dynamic_cast<OOX::Logic::CBr*>(m_ooxRun->m_arrItems[i]); OOX::Logic::CBr *ooxBr = dynamic_cast<OOX::Logic::CBr*>(ooxItem);
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() ); RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_oProperty = oNewProperty; oNewChar->m_oProperty = oNewProperty;
...@@ -711,24 +702,26 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -711,24 +702,26 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
oOutputParagraph.AddItem( oNewChar ); oOutputParagraph.AddItem( oNewChar );
}break; }break;
case OOX::et_mc_alternateContent: case OOX::et_mc_alternateContent:
{//???? todooo {//выбираем всегда более старую версию
//XmlUtils::IXMLDOMNodePtr oNode; OOX::Logic::CAlternateContent *ooxAlt = dynamic_cast<OOX::Logic::CAlternateContent* >(ooxItem);
//oXmlReader.GetNode( i , oNode ); if (ooxAlt->m_arrChoiceItems.size() > 0)
//XmlUtils::CXmlLiteReader oSubReader; {
//if( TRUE == oSubReader.OpenFromXmlNode( oNode ) ) for (int i = 0; i < ooxAlt->m_arrFallbackItems.size(); i++)
// if( TRUE == oSubReader.ReadNode( _T("mc:Fallback") ) ) {
// { Parse(oParam , oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrFallbackItems[i]);
// XmlUtils::IXMLDOMNodePtr oSubNode; }
// oSubReader.GetNode( oSubNode ); }
// ReaderParameter oParam = oParam; else
// oParam.oNode = oSubNode; {
// OOXRunReader oSubReader; for (int i = 0; i < ooxAlt->m_arrChoiceItems.size(); i++)
// oSubReader.Parse( oParam, oOutputParagraph, poStyle ); {
// } Parse(oParam , oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrChoiceItems[i]);
}
}
}break; }break;
case OOX::et_w_sym: case OOX::et_w_sym:
{ {
OOX::Logic::CSym *ooxSym = dynamic_cast<OOX::Logic::CSym* >(m_ooxRun->m_arrItems[i]); OOX::Logic::CSym *ooxSym = dynamic_cast<OOX::Logic::CSym* >(ooxItem);
if(ooxSym->m_oFont.IsInit() && ooxSym->m_oChar.IsInit() ) if(ooxSym->m_oFont.IsInit() && ooxSym->m_oChar.IsInit() )
{ {
...@@ -771,6 +764,35 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap ...@@ -771,6 +764,35 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
} }
}break; }break;
} }
return true;
}
bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, RtfStylePtr poStyle )
{
if (m_ooxRun == NULL) return false;
RtfCharProperty oNewProperty;
oNewProperty.SetDefaultOOX();
//применяем default
oNewProperty = oParam.oRtf->m_oDefaultCharProp;
//применяем внешний стиль
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty );
if( NULL != poStyle && TYPE_RTF_PROPERTY_STYLE_CHAR == poStyle->GetType() )
{
RtfCharStylePtr oCharStyle = boost::static_pointer_cast<RtfCharStyle, RtfStyle>( poStyle );
oNewProperty.Merge( oCharStyle->m_oCharProp );
}
if (m_ooxRun->m_oRunProperty)
{
OOXrPrReader orPrReader(m_ooxRun->m_oRunProperty);
orPrReader.Parse( oParam, oNewProperty );
}
for (long i =0 ; i < m_ooxRun->m_arrItems.size(); i++)
{
Parse(oParam, oOutputParagraph, poStyle, oNewProperty, m_ooxRun->m_arrItems[i]);
} }
return true; return true;
} }
......
...@@ -52,4 +52,5 @@ public: ...@@ -52,4 +52,5 @@ public:
} }
bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, RtfStylePtr poStyle ); bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, RtfStylePtr poStyle );
bool Parse( ReaderParameter oParam , RtfParagraph& oOutputParagraph, RtfStylePtr poStyle, RtfCharProperty& oNewProperty, OOX::WritingElement* ooxItem );
}; };
\ No newline at end of file
...@@ -103,6 +103,15 @@ public: ...@@ -103,6 +103,15 @@ public:
Parse( pSdt->m_oSdtContent.GetPointer(), oParam ); Parse( pSdt->m_oSdtContent.GetPointer(), oParam );
} }
}break; }break;
case OOX::et_w_sdtContent:
{
OOX::Logic::CSdtContent * pSdt = dynamic_cast<OOX::Logic::CSdtContent*>(ooxElement);
for (int i = 0; i < pSdt->m_arrItems.size(); i++)
{
Parse( pSdt->m_arrItems[i], oParam );
}
}break;
} }
return true; return true;
} }
......
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
oBorderReader.Parse( oParam,oOutputProperty.m_oBorderBottom ); oBorderReader.Parse( oParam,oOutputProperty.m_oBorderBottom );
} }
} }
else if (m_ooxTableProps) else if ((m_ooxTableProps) && (m_ooxTableProps->m_oTblBorders.IsInit()))
{ {
//from table props //from table props
//todoo last, first !!!! //todoo last, first !!!!
......
...@@ -61,17 +61,23 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -61,17 +61,23 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter)
if( st_inline == m_eShapeType ) if( st_inline == m_eShapeType )
{ {
if( NULL != m_oPicture ) if( NULL != m_oPicture && m_nShapeType == 75)
{ {
if (m_oPicture->m_nWidth == PROP_DEF)
{
m_oPicture->m_nWidth = m_nRight;
m_oPicture->m_nHeight = m_nBottom;
}
if (m_oPicture->m_nWidthGoal == PROP_DEF)
{
m_oPicture->m_nWidthGoal = m_oPicture->m_nWidth;
m_oPicture->m_nHeightGoal = m_oPicture->m_nHeight;
}
if( RtfPicture::dt_wmf == m_oPicture->eDataType ) if( RtfPicture::dt_wmf == m_oPicture->eDataType )
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) ); sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
else else
{ {
sResult.Append( _T("{\\*\\shppict") ); sResult.Append( _T("{\\*\\shppict") );
//CString sPictProp = RenderToRtfShapeProperty( oRenderParameter );
//if( false == sPictProp.IsEmpty() )
// sResult.AppendFormat( _T("{\\*\\picprop %ls}"), sPictProp );
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) ); sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
sResult.Append( _T("}") ); sResult.Append( _T("}") );
sResult.Append( _T("{\\nonshppict") ); sResult.Append( _T("{\\nonshppict") );
...@@ -80,45 +86,104 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -80,45 +86,104 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter)
sResult.Append( _T("}") ); sResult.Append( _T("}") );
} }
} }
else
{
sResult.Append(_T("{\\shp"));
sResult.Append(_T("{\\*\\shpinst"));
RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") );
RENDER_RTF_INT( m_nTop , sResult, _T("shptop") );
RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") );
RENDER_RTF_INT( m_nRight , sResult, _T("shpright") );
RENDER_RTF_INT( m_nID , sResult, _T("shplid") );
RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") );
RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") );
RENDER_RTF_INT( m_nWrapSideType , sResult, _T("shpwrk") );
RENDER_RTF_BOOL( m_bLockAnchor , sResult, _T("shplockanchor") );
//RENDER_RTF_BOOL( false , sResult, _T("fUseShapeAnchor") );
//RENDER_RTF_BOOL( true , sResult, _T("fPseudoInline") );
sResult.Append( _T("\\shpbxignore") );
sResult.Append( _T("\\shpbyignore") );
sResult.AppendFormat( _T("{\\sp{\\sn fUseShapeAnchor}{\\sv %d}}"), false);
sResult.AppendFormat( _T("{\\sp{\\sn fPseudoInline}{\\sv %d}}"), true);
sResult.Append( RenderToRtfShapeProperty( oRenderParameter ) );
//picture
if( 0 != m_oPicture )
{
sResult.Append( _T("{\\sp{\\sn fillType}{\\sv 2}}"));
sResult.Append( _T("{\\sp{\\sn fillBlip}{\\sv "));
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
sResult.Append( _T("}}") );
}
//textbox
if( 0 != m_aTextItems )
{
sResult.Append( _T("{\\shptxt ") );
sResult.Append( m_aTextItems->RenderToRtf( oRenderParameter ) );
sResult.Append( _T("}") );
}
sResult.Append(_T("}"));
if( 0 != m_oPicture )
{
sResult.Append(_T("{\\shprslt\\par\\plain"));
sResult.Append( m_oPicture->GenerateWMF( oRenderParameter ) );
sResult.Append(_T("\\par}"));
}
sResult.Append(_T("}"));
}
} }
else else
{ {
sResult.Append(_T("{\\shp{\\*\\shpinst")); sResult.Append(_T("{\\shp"));
RENDER_RTF_INT( m_nLeft, sResult, _T("shpleft") ); sResult.Append(_T("{\\*\\shpinst"));
RENDER_RTF_INT( m_nTop, sResult, _T("shptop") ); RENDER_RTF_INT( m_nLeft , sResult, _T("shpleft") );
RENDER_RTF_INT( m_nBottom, sResult, _T("shpbottom") ); RENDER_RTF_INT( m_nTop , sResult, _T("shptop") );
RENDER_RTF_INT( m_nRight, sResult, _T("shpright") ); RENDER_RTF_INT( m_nBottom , sResult, _T("shpbottom") );
RENDER_RTF_INT( m_nID, sResult, _T("shplid") ); RENDER_RTF_INT( m_nRight , sResult, _T("shpright") );
RENDER_RTF_INT( m_nZOrder, sResult, _T("shpz") ); RENDER_RTF_INT( m_nID , sResult, _T("shplid") );
RENDER_RTF_INT( m_nHeader, sResult, _T("shpfhdr") ); RENDER_RTF_INT( m_nZOrder , sResult, _T("shpz") );
RENDER_RTF_INT( m_nWrapType, sResult, _T("shpwr") ); RENDER_RTF_INT( m_nHeader , sResult, _T("shpfhdr") );
RENDER_RTF_INT( m_nWrapSideType, sResult, _T("shpwrk") ); RENDER_RTF_INT( m_nWrapType , sResult, _T("shpwr") );
RENDER_RTF_BOOL( m_bLockAnchor, sResult, _T("shplockanchor") ); RENDER_RTF_INT( m_nWrapSideType , sResult, _T("shpwrk") );
RENDER_RTF_BOOL( m_bLockAnchor , sResult, _T("shplockanchor") );
switch(m_eXAnchor) switch(m_eXAnchor)
{ {
case ax_page: sResult.Append( _T("\\shpbxpage") );break; case ax_page: sResult.Append( _T("\\shpbxpage") ); break;
case ax_margin: sResult.Append( _T("\\shpbxmargin") );break; case ax_margin: sResult.Append( _T("\\shpbxmargin") ); break;
case ax_column: sResult.Append( _T("\\shpbxcolumn") );break; case ax_column: sResult.Append( _T("\\shpbxcolumn") ); break;
} }
sResult.Append( _T("\\shpbxignore") ); sResult.Append( _T("\\shpbxignore") );
switch(m_eYAnchor) switch(m_eYAnchor)
{ {
case ay_page: sResult.Append( _T("\\shpbypage") );break; case ay_page: sResult.Append( _T("\\shpbypage") ); break;
case ay_margin: sResult.Append( _T("\\shpbymargin") );break; case ay_margin: sResult.Append( _T("\\shpbymargin") ); break;
case ay_Para: sResult.Append( _T("\\shpbypara") );break; case ay_Para: sResult.Append( _T("\\shpbypara") ); break;
} }
sResult.Append( _T("\\shpbyignore") ); sResult.Append( _T("\\shpbyignore") );
RENDER_RTF_INT( m_nZOrderRelative, sResult, _T("shpfblwtxt") ); RENDER_RTF_INT( m_nZOrderRelative, sResult, _T("shpfblwtxt") );
sResult.Append( RenderToRtfShapeProperty( oRenderParameter ) ); sResult.Append( RenderToRtfShapeProperty( oRenderParameter ) );
//picture //picture
if( 0 != m_oPicture ) if( 0 != m_oPicture)
{
if (m_nShapeType == 75)
{ {
sResult.Append( _T("{\\sp{\\sn pib}{\\sv ") ); sResult.Append( _T("{\\sp{\\sn pib}{\\sv ") );
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) ); sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
sResult.Append( _T("}}") ); sResult.Append( _T("}}") );
} }
else
{
sResult.Append( _T("{\\sp{\\sn fillType}{\\sv 2}}"));
sResult.Append( _T("{\\sp{\\sn fillBlip}{\\sv "));
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
sResult.Append( _T("}}") );
}
}
//textbox //textbox
if( 0 != m_aTextItems ) if( 0 != m_aTextItems )
{ {
...@@ -127,7 +192,7 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter) ...@@ -127,7 +192,7 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter)
sResult.Append( _T("}") ); sResult.Append( _T("}") );
} }
sResult.Append(_T("}")); sResult.Append(_T("}"));
if( 0 != m_oPicture ) if( 0 != m_oPicture && m_nShapeType == 75 )
{ {
sResult.Append(_T("{\\shprslt\\par\\plain")); sResult.Append(_T("{\\shprslt\\par\\plain"));
sResult.Append( m_oPicture->GenerateWMF( oRenderParameter ) ); sResult.Append( m_oPicture->GenerateWMF( oRenderParameter ) );
...@@ -160,11 +225,12 @@ CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter) ...@@ -160,11 +225,12 @@ CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter)
if( PROP_DEF != m_nPositionHRelative ) if( PROP_DEF != m_nPositionHRelative )
sResult.AppendFormat( _T("{\\sp{\\sn posrelh}{\\sv %d}}"),m_nPositionHRelative); sResult.AppendFormat( _T("{\\sp{\\sn posrelh}{\\sv %d}}"),m_nPositionHRelative);
if( PROP_DEF != m_nPositionV ) if( PROP_DEF != m_nPositionV )
sResult.AppendFormat( _T("{\\sp{\\sn posv}{\\sv %d}}"),m_nPositionV); sResult.AppendFormat( _T("{\\sp{\\sn posv}{\\sv %d}}"), m_nPositionV);
if( PROP_DEF != m_nPositionVRelative ) if( PROP_DEF != m_nPositionVRelative )
sResult.AppendFormat( _T("{\\sp{\\sn posrelv}{\\sv %d}}"),m_nPositionVRelative); sResult.AppendFormat( _T("{\\sp{\\sn posrelv}{\\sv %d}}"), m_nPositionVRelative);
if( PROP_DEF != m_bLayoutInCell ) if( PROP_DEF != m_bLayoutInCell )
sResult.AppendFormat( _T("{\\sp{\\sn fLayoutInCell}{\\sv %d}}"),m_bLayoutInCell); sResult.AppendFormat( _T("{\\sp{\\sn fLayoutInCell}{\\sv %d}}"), m_bLayoutInCell);
if( PROP_DEF != m_bAllowOverlap ) if( PROP_DEF != m_bAllowOverlap )
sResult.AppendFormat( _T("{\\sp{\\sn fAllowOverlap}{\\sv %d}}"),m_bAllowOverlap); sResult.AppendFormat( _T("{\\sp{\\sn fAllowOverlap}{\\sv %d}}"),m_bAllowOverlap);
...@@ -1142,8 +1208,15 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) ...@@ -1142,8 +1208,15 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sResult.Append( _T("</w:txbxContent>") ); sResult.Append( _T("</w:txbxContent>") );
sResult.Append( _T("</v:textbox>") ); sResult.Append( _T("</v:textbox>") );
} }
if( m_oPicture != 0 ) if( m_oPicture != 0)
{
CString sPicture = m_oPicture->RenderToOOX(oRenderParameter);
if (m_nShapeType == PROP_DEF || m_nShapeType == 75)
{ {
if( sPicture.IsEmpty() )//если не сохранилась картинка, то весь shape-picture будет бесполезным
return _T("");
int nCropLeft = PROP_DEF; int nCropLeft = PROP_DEF;
int nCropTop = PROP_DEF; int nCropTop = PROP_DEF;
int nCropRight = PROP_DEF; int nCropRight = PROP_DEF;
...@@ -1166,9 +1239,6 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) ...@@ -1166,9 +1239,6 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
else if( PROP_DEF != m_oPicture->m_nHeightGoal && PROP_DEF != m_oPicture->m_nCropB ) else if( PROP_DEF != m_oPicture->m_nHeightGoal && PROP_DEF != m_oPicture->m_nCropB )
nCropBottom = (int)( 65536 * ( 1.0 * m_oPicture->m_nCropB / m_oPicture->m_nHeightGoal) ); nCropBottom = (int)( 65536 * ( 1.0 * m_oPicture->m_nCropB / m_oPicture->m_nHeightGoal) );
CString sPicture = m_oPicture->RenderToOOX(oRenderParameter);
if( _T("") == sPicture )//если не сохранилась картинка, то весь shape будет бесполезным
return _T("");
sResult.AppendFormat( _T("<v:imagedata r:id=\"%ls\""), sPicture.GetBuffer() ); sResult.AppendFormat( _T("<v:imagedata r:id=\"%ls\""), sPicture.GetBuffer() );
if( PROP_DEF != nCropLeft ) if( PROP_DEF != nCropLeft )
sResult.AppendFormat( _T(" cropleft=\"%df\""), nCropLeft ); sResult.AppendFormat( _T(" cropleft=\"%df\""), nCropLeft );
...@@ -1180,6 +1250,17 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter) ...@@ -1180,6 +1250,17 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sResult.AppendFormat( _T(" cropbottom=\"%df\""), nCropBottom ); sResult.AppendFormat( _T(" cropbottom=\"%df\""), nCropBottom );
sResult.Append( _T(" o:title=\"\"/>") ); sResult.Append( _T(" o:title=\"\"/>") );
} }
else if (!sPicture.IsEmpty())
{
sResult.AppendFormat( _T("<v:fill r:id=\"%ls\""), sPicture.GetBuffer() );
if (m_nFillType == 2 )
sResult.Append( _T(" type=\"tile\""));
else
sResult.Append( _T(" type=\"frame\""));
sResult.Append( _T("/>") );
}
}
return sResult; return sResult;
} }
CString RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter) CString RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter)
......
...@@ -145,6 +145,7 @@ public: ...@@ -145,6 +145,7 @@ public:
//Fill //Fill
int m_bFilled; //fFilled The shape is filled. int m_bFilled; //fFilled The shape is filled.
int m_nFillType;
//Line //Line
int m_bLine; //fLine Has a line int m_bLine; //fLine Has a line
int m_nLineStartArrow; //lineStartArrowhead Start arrow type: int m_nLineStartArrow; //lineStartArrowhead Start arrow type:
...@@ -276,6 +277,7 @@ public: ...@@ -276,6 +277,7 @@ public:
//Fill //Fill
DEFAULT_PROPERTY_DEF( m_bFilled, true ) DEFAULT_PROPERTY_DEF( m_bFilled, true )
DEFAULT_PROPERTY( m_nFillType )
//Line //Line
DEFAULT_PROPERTY_DEF( m_bLine, true ) DEFAULT_PROPERTY_DEF( m_bLine, true )
DEFAULT_PROPERTY( m_nLineStartArrow ) DEFAULT_PROPERTY( m_nLineStartArrow )
......
...@@ -98,8 +98,8 @@ namespace OOX ...@@ -98,8 +98,8 @@ namespace OOX
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oHrNoShade; SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oHrNoShade;
SimpleTypes::CDouble m_oHrPct; SimpleTypes::CDouble m_oHrPct;
SimpleTypes::CHrAlign<SimpleTypes::hralignLeft> m_oHrAlign; SimpleTypes::CHrAlign<SimpleTypes::hralignLeft> m_oHrAlign;
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oAllowInCell; SimpleTypes::CTrueFalse<SimpleTypes::booleanTrue> m_oAllowInCell;
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oAllowOverlap; SimpleTypes::CTrueFalse<SimpleTypes::booleanTrue> m_oAllowOverlap;
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oUserDrawn; SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oUserDrawn;
nullable<SimpleTypes::CColorType<>> m_oBorderTopColor; nullable<SimpleTypes::CColorType<>> m_oBorderTopColor;
nullable<SimpleTypes::CColorType<>> m_oBorderLeftColor; nullable<SimpleTypes::CColorType<>> m_oBorderLeftColor;
......
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