Commit d0b4fc4b authored by ElenaSubbotina's avatar ElenaSubbotina

RtfFormatReader/Writer - fix bugs, add new convertation elements

parent 987839a6
......@@ -386,10 +386,14 @@ namespace DocFileFormat
GroupShapeBooleanProperties groupShapeBooleans(iter->op);
if (groupShapeBooleans.fUsefBehindDocument && groupShapeBooleans.fBehindDocument)
{//m_isInlineShape ???
{
//The shape is behind the text, so the z-index must be negative.
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)
{
......
......@@ -1438,6 +1438,8 @@ namespace DocFileFormat
bool bPosH = false;
bool bPosV = false;
bool bZIndex = false;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
{
......@@ -1469,14 +1471,16 @@ namespace DocFileFormat
{
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.
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));
bZIndex = true;
}
if (groupShapeBooleans.fHidden && groupShapeBooleans.fUsefHidden)
......
......@@ -63,6 +63,7 @@ bool ShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CStr
{
if( PROP_DEF == m_oShape.m_nShapeType )
m_oShape.m_nShapeType = 202;//Text box
ParagraphReader oParagraphReader(_T("shptxt"), oReader);
StartSubReader( oParagraphReader, oDocument, oReader );
m_oShape.m_aTextItems = oParagraphReader.m_oParPropDest.m_oTextItems;
......@@ -170,13 +171,17 @@ bool PictureReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CS
else if( _T("picw") == sCommand )
{
if( true == hasParameter )
{
m_oShape.m_oPicture->m_nWidth = parameter;
}
}
else if( _T("pich") == sCommand )
{
if( true == hasParameter )
{
m_oShape.m_oPicture->m_nHeight = parameter;
}
}
else if( _T("picwgoal") == sCommand )
{
if( true == hasParameter )
......
......@@ -1245,8 +1245,10 @@ public:
RtfUtility::WriteDataToFileBinary( sTempFile, m_pbBin, m_nBinLength );
else
RtfUtility::WriteDataToFile( sTempFile, m_sData );
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_sPicFilename = sTempFile;
}
......@@ -1280,7 +1282,7 @@ class ShapeReader : public RtfAbstractReader
{
if( _T("sv") == sCommand )
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() );
PictureReader oPictureReader( oReader, m_oShape );
......@@ -1464,20 +1466,12 @@ class ShapeReader : public RtfAbstractReader
m_oShape.m_nRelZOrder = nValue;
//Fill
else if( _T("fFilled") == m_sPropName )
{
if( 0 == nValue )
m_oShape.m_bFilled = false;
else
m_oShape.m_bFilled = false;
}
m_oShape.m_bFilled = (0 == nValue ? false : true );
else if( _T("fillType") == m_sPropName )
m_oShape.m_nFillType = nValue;
//Line
else if( _T("fLine") == m_sPropName )
{
if( 0 == nValue )
m_oShape.m_bLine = false;
else
m_oShape.m_bLine = false;
}
m_oShape.m_bLine = ( 0 == nValue ? false : true );
else if( _T("lineStartArrowhead") == m_sPropName )
m_oShape.m_nLineStartArrow = nValue;
else if( _T("lineStartArrowWidth") == m_sPropName )
......@@ -1492,6 +1486,11 @@ class ShapeReader : public RtfAbstractReader
m_oShape.m_nLineEndArrowLength = nValue;
else if( _T("lineWidth") == m_sPropName )
m_oShape.m_nLineWidth = nValue;
else
{
int val = nValue;
std::wstring name = m_sPropName.GetBuffer();
}
}
void ExecuteText( RtfDocument& oDocument, RtfReader& oReader, CString oText )
{
......@@ -3394,6 +3393,8 @@ public:
}
}
else if( _T("sect") == sCommand )
{
//if (oParagraphReaderDestination.m_oTextItems->GetCount() > 0)
{
RtfSectionPtr oCurSection;
if(true == oDocument.GetItem( oCurSection ) )
......@@ -3406,11 +3407,13 @@ public:
oReader.m_oCurSectionProp.m_oFooterFirst = TextItemContainerPtr();
oReader.m_oCurSectionProp.m_oFooterRight = TextItemContainerPtr();
RtfSectionPtr oNewSection = RtfSectionPtr( new RtfSection() );
oParagraphReaderDestination.Finalize( oReader );
RtfSectionPtr oNewSection = RtfSectionPtr( new RtfSection() );
oParagraphReaderDestination.m_oTextItems = oNewSection;
oDocument.AddItem( oNewSection );
}
}
else if( _T("sectd") == sCommand )
{
SectDef( oDocument, oReader );
......
......@@ -347,37 +347,15 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
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;
RtfCharProperty oNewProperty;
oNewProperty.SetDefaultOOX();
//применяем default
oNewProperty = oParam.oRtf->m_oDefaultCharProp;
//применяем внешний стиль
oNewProperty.Merge( oOutputParagraph.m_oProperty.m_oCharProperty );
if (!ooxItem) return false;
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++)
{
switch(m_ooxRun->m_arrItems[i]->getType())
switch(ooxItem->getType())
{
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)
{
CString sValue;
......@@ -396,7 +374,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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()))
{
switch(ooxFldChar->m_oFldCharType->GetValue())
......@@ -426,7 +404,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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() );
RtfCharPtr oNewChar( new RtfChar() );
if (ooxInstrText)
......@@ -436,7 +414,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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()))
{
int nID = ooxFootnoteReference->m_oId->GetValue();
......@@ -452,7 +430,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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()))
{
int nID = ooxEndnoteReference->m_oId->GetValue();
......@@ -469,7 +447,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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)
{
long nOleWidth = PROP_DEF;
......@@ -606,7 +584,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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() );
OOXPictureReader oPictureReader(ooxDrawing);
......@@ -617,13 +595,26 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
case OOX::et_w_pict:
{
OOX::Logic::CPicture *ooxPicture = dynamic_cast<OOX::Logic::CPicture*>(m_ooxRun->m_arrItems[i]);
if( (ooxPicture) && (ooxPicture->m_oShape.IsInit())) //??? todooo ваще то могут быть и др элементы/инициализции
OOX::Logic::CPicture *ooxPicture = dynamic_cast<OOX::Logic::CPicture*>(ooxItem);
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() );
OOXShapeReader oShapeReader(ooxPicture->m_oShape.GetPointer());
if( true == oShapeReader.Parse( oParam, oNewPicture ) )
oOutputParagraph.AddItem( oNewPicture );
if( true == pShapeReader->Parse( oParam, oNewShape ) )
oOutputParagraph.AddItem( oNewShape );
delete pShapeReader;
}
}
}break;
case OOX::et_w_nonBreakHyphen:
......@@ -684,7 +675,7 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}break;
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() );
oNewChar->m_oProperty = oNewProperty;
......@@ -711,24 +702,26 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
oOutputParagraph.AddItem( oNewChar );
}break;
case OOX::et_mc_alternateContent:
{//???? todooo
//XmlUtils::IXMLDOMNodePtr oNode;
//oXmlReader.GetNode( i , oNode );
//XmlUtils::CXmlLiteReader oSubReader;
//if( TRUE == oSubReader.OpenFromXmlNode( oNode ) )
// if( TRUE == oSubReader.ReadNode( _T("mc:Fallback") ) )
// {
// XmlUtils::IXMLDOMNodePtr oSubNode;
// oSubReader.GetNode( oSubNode );
// ReaderParameter oParam = oParam;
// oParam.oNode = oSubNode;
// OOXRunReader oSubReader;
// oSubReader.Parse( oParam, oOutputParagraph, poStyle );
// }
{//выбираем всегда более старую версию
OOX::Logic::CAlternateContent *ooxAlt = dynamic_cast<OOX::Logic::CAlternateContent* >(ooxItem);
if (ooxAlt->m_arrChoiceItems.size() > 0)
{
for (int i = 0; i < ooxAlt->m_arrFallbackItems.size(); i++)
{
Parse(oParam , oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrFallbackItems[i]);
}
}
else
{
for (int i = 0; i < ooxAlt->m_arrChoiceItems.size(); i++)
{
Parse(oParam , oOutputParagraph, poStyle, oNewProperty, ooxAlt->m_arrChoiceItems[i]);
}
}
}break;
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() )
{
......@@ -771,6 +764,35 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
}
}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;
}
......
......@@ -52,4 +52,5 @@ public:
}
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
......@@ -68,17 +68,41 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
switch(m_arrElement->m_arrItems[i]->getType())
{
case OOX::et_v_imagedata:
case OOX::et_v_fill:
{
OOX::Vml::CImageData* image_data = dynamic_cast<OOX::Vml::CImageData*>(m_arrElement->m_arrItems[i]);
OOX::Vml::CFill* fill_ = dynamic_cast<OOX::Vml::CFill*>(m_arrElement->m_arrItems[i]);
OOX::VmlOffice::CFill * fill = fill_ ? dynamic_cast<OOX::VmlOffice::CFill*>(fill_->m_oFill.GetPointer()) : NULL;
CString srId = fill_->m_sId.IsInit() ? fill_->m_sId.get2() : _T("") ;
if (srId.IsEmpty())
srId = fill_->m_rId.IsInit() ? fill_->m_rId->GetValue() : _T("") ;
if (!srId.IsEmpty() && oParam.oReader->m_currentContainer)
{
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(srId);
if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type()))
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
CString sImagePath = pImage->filename().GetPath();
oOutput->m_oPicture = RtfPicturePtr( new RtfPicture() );
oOutput->m_eShapeType = RtfShape::st_none;
oOutput->m_nShapeType = 75;
//todooo проверить что за путь тут выставляется
OOXPictureGraphicReader::WriteDataToPicture( sImagePath, *oOutput->m_oPicture, oParam.oReader->m_sPath );
}
}
else
{
}
}break;
case OOX::et_v_imagedata:
{
OOX::Vml::CImageData* image_data = dynamic_cast<OOX::Vml::CImageData*>(m_arrElement->m_arrItems[i]);
CString srId = image_data->m_oId.IsInit() ? image_data->m_oId.get2() : _T("") ;
if (srId.GetLength() < 1)
if (srId.IsEmpty())
srId = image_data->m_rId.IsInit() ? image_data->m_rId->GetValue() : _T("") ;
if (oParam.oReader->m_currentContainer)
......@@ -87,6 +111,10 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type()))
{
oOutput->m_oPicture = RtfPicturePtr( new RtfPicture() );
oOutput->m_eShapeType = RtfShape::st_none;
oOutput->m_nShapeType = 75;
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
CString sImagePath = pImage->filename().GetPath();
......@@ -149,11 +177,6 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
double dNewScale = 100 * ( 1.0 * nHeight / nCropedHeightGoal );
oOutput->m_oPicture->m_dScaleY = dNewScale;
}
//проверяем на inline
if( (PROP_DEF == oOutput->m_nLeft || 0 == oOutput->m_nLeft ) && ( PROP_DEF == oOutput->m_nTop || 0 == oOutput->m_nTop ) && PROP_DEF == oOutput->m_nPositionH && PROP_DEF == oOutput->m_nPositionV )
oOutput->m_eShapeType = RtfShape::st_inline;
}break;
case OOX::et_wd_wrap:
{
......@@ -200,6 +223,10 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
}break;
}
}
//проверяем на inline
if((PROP_DEF == oOutput->m_nLeft/* || 0 == oOutput->m_nLeft */) && ( PROP_DEF == oOutput->m_nTop/* || 0 == oOutput->m_nTop */) &&
PROP_DEF == oOutput->m_nPositionH && PROP_DEF == oOutput->m_nPositionV )
oOutput->m_eShapeType = RtfShape::st_inline;
//если ничего не задали делаем inline
if( (PROP_DEF == oOutput->m_nLeft || 0 == oOutput->m_nLeft ) && ( PROP_DEF == oOutput->m_nTop || 0 == oOutput->m_nTop ) && PROP_DEF == oOutput->m_nPositionH && PROP_DEF == oOutput->m_nPositionV )
{
......@@ -208,6 +235,7 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
oOutput->m_nPositionHRelative = 3;
oOutput->m_nPositionVRelative = 3;
}
return true;
}
bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
{
......@@ -221,10 +249,13 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
//if( -1 != nType )
// oOutput->m_nShapeType = nType;
if( m_vmlElement->m_sId.IsInit())
{
oOutput->m_nID = oParam.oReader->m_oOOXIdGenerator.GetId( m_vmlElement->m_sId.get());
}
oOutput->m_nLeft = 0; //стили только с widht height (например в Numbering)
oOutput->m_nTop = 0;
//oOutput->m_nLeft = 0; //стили только с widht height (например в Numbering)
//oOutput->m_nTop = 0;
oOutput->m_eShapeType = RtfShape::st_none; //inline or anchor
if ( m_vmlElement->m_oStyle.IsInit())
{
......@@ -235,6 +266,19 @@ bool OOXShapeReader::Parse( ReaderParameter oParam , RtfShapePtr& oOutput)
{
if (shape->m_oAdj.IsInit())
ParseAdjustment( *oOutput, shape->m_oAdj.get() );
if (shape->m_sType.IsInit())
{
int pos = shape->m_sType->Find(_T("#_x0000_t"));
if (pos >= 0)
{
oOutput->m_nShapeType = _wtoi(shape->m_sType->Mid(pos + 9, shape->m_sType->GetLength() - pos - 9).GetString());
}
}
}
if (OOX::Vml::CRect* rect = dynamic_cast<OOX::Vml::CRect*>(m_vmlElement))
{
oOutput->m_nShapeType = 1;
}
//CString sConnectionType = oXmlReader.ReadNodeAttribute( _T("o:connecttype"), _T("") );
//if( _T("custom") == sConnectionType )
......@@ -305,66 +349,105 @@ bool OOXShapeReader::ParseStyle(RtfShape& oShape, SimpleTypes::Vml::CCssProperty
case SimpleTypes::Vml::cssflipYX : oShape.m_bFlipH = true; oShape.m_bFlipV = true; break;
}
break;
case SimpleTypes::Vml::cssptWidth :
{
//OOX::SimpleTypes::CPoint oPoint;
//oPoint.FromPoints(prop->get_Value().dValue);
oShape.m_nRight = oShape.m_nRelRight = (int)(20 * prop->get_Value().oValue.dValue);
if( PROP_DEF != oShape.m_nLeft )
oShape.m_nRight += oShape.m_nLeft;
if( PROP_DEF != oShape.m_nRelLeft)
oShape.m_nRelRight += oShape.m_nRelLeft;
}break;
case SimpleTypes::Vml::cssptHeight :
{
int nHeight = (int)(20 * prop->get_Value().dValue);
if( PROP_DEF != oShape.m_nTop )//todooo переделать !!!
oShape.m_nBottom = oShape.m_nTop + nHeight;
if( PROP_DEF != oShape.m_nRelTop)//todooo переделать !!!
oShape.m_nRelBottom = oShape.m_nRelTop + nHeight;
oShape.m_nBottom = oShape.m_nRelBottom = (int)(20 * prop->get_Value().oValue.dValue);
if( PROP_DEF != oShape.m_nTop )
oShape.m_nBottom += oShape.m_nTop;
if( PROP_DEF != oShape.m_nRelTop)
oShape.m_nRelBottom += oShape.m_nRelTop;
}break;
case SimpleTypes::Vml::cssptLeft :
oShape.m_nRelLeft = prop->get_Value().dValue; break;
{
oShape.m_nRelLeft = prop->get_Value().oValue.dValue;
if( PROP_DEF != oShape.m_nRelRight)
oShape.m_nRelRight += oShape.m_nRelLeft;
}break;
case SimpleTypes::Vml::cssptTop :
{
oShape.m_nRelTop = prop->get_Value().oValue.dValue;
if( PROP_DEF != oShape.m_nRelBottom)
oShape.m_nRelBottom += oShape.m_nRelTop;
}break;
case SimpleTypes::Vml::cssptMarginBottom:
oShape.m_nBottom = (int)(20 * prop->get_Value().dValue ); break;
{
oShape.m_nBottom = (int)(20 * prop->get_Value().oValue.dValue );
}break;
case SimpleTypes::Vml::cssptMarginLeft :
oShape.m_nLeft = (int)(20 * prop->get_Value().dValue ); break;//pt tp twips
{
oShape.m_nLeft = (int)(20 * prop->get_Value().oValue.dValue );
}break;//pt tp twips
case SimpleTypes::Vml::cssptMarginRight :
oShape.m_nRight = (int)(20 * prop->get_Value().dValue ); break;
case SimpleTypes::Vml::cssptMarginTop :
oShape.m_nTop = (int)(20 * prop->get_Value().dValue ); break;
case SimpleTypes::Vml::cssptMsoPositionHorizontal :
oShape.m_nPositionH = prop->get_Value().eMsoPosHor; break;
{
oShape.m_nRight = (int)(20 * prop->get_Value().oValue.dValue );
}break;
case SimpleTypes::Vml::cssptMarginTop:
{
oShape.m_nTop = (int)(20 * prop->get_Value().oValue.dValue );
}break;
case SimpleTypes::Vml::cssptMsoPositionHorizontal:
{
oShape.m_nPositionH = prop->get_Value().eMsoPosHor;
}break;
case SimpleTypes::Vml::cssptMsoPositionHorizontalRelative :
oShape.m_nPositionHRelative = prop->get_Value().eMsoPosHorRel; break;
case SimpleTypes::Vml::cssptMsoPositionVertical :
oShape.m_nPositionV = prop->get_Value().eMsoPosVer; break;
{
oShape.m_nPositionHRelative = prop->get_Value().eMsoPosHorRel;
}break;
case SimpleTypes::Vml::cssptMsoPositionVertical:
{
oShape.m_nPositionV = prop->get_Value().eMsoPosVer;
}break;
case SimpleTypes::Vml::cssptMsoPositionVerticalRelative :
oShape.m_nPositionVRelative = prop->get_Value().eMsoPosVerRel; break;
case SimpleTypes::Vml::cssptMsoWrapDistanceBottom :
oShape.m_nWrapDistBottom = (int)(20 * prop->get_Value().dValue ); break;
{
oShape.m_nPositionVRelative = prop->get_Value().eMsoPosVerRel;
}break;
case SimpleTypes::Vml::cssptMsoWrapDistanceBottom:
{
oShape.m_nWrapDistBottom = (int)(20 * prop->get_Value().dValue );
}break;
case SimpleTypes::Vml::cssptMsoWrapDistanceLeft :
oShape.m_nWrapDistLeft = (int)(20 * prop->get_Value().dValue ); break;
case SimpleTypes::Vml::cssptMsoWrapDistanceRight :
oShape.m_nWrapDistRight = (int)(20 * prop->get_Value().dValue ); break;
{
oShape.m_nWrapDistLeft = (int)(20 * prop->get_Value().dValue );
}break;
case SimpleTypes::Vml::cssptMsoWrapDistanceRight:
{
oShape.m_nWrapDistRight = (int)(20 * prop->get_Value().dValue );
}break;
case SimpleTypes::Vml::cssptMsoWrapDistanceTop :
oShape.m_nWrapDistTop = (int)(20 * prop->get_Value().dValue ); break;
break;
case SimpleTypes::Vml::cssptMsoWrapEdited :
{
oShape.m_nWrapDistTop = (int)(20 * prop->get_Value().dValue );
}break;
case SimpleTypes::Vml::cssptMsoWrapEdited:
break;
case SimpleTypes::Vml::cssptMsoWrapStyle :
case SimpleTypes::Vml::cssptMsoWrapStyle:
break;
case SimpleTypes::Vml::cssptPosition :
case SimpleTypes::Vml::cssptPosition:
break;
case SimpleTypes::Vml::cssptRotation :
case SimpleTypes::Vml::cssptRotation:
{
oShape.m_nRotation = 65536 * prop->get_Value().dValue;
if( PROP_DEF != oShape.m_nRelRight || PROP_DEF != oShape.m_nRelLeft || PROP_DEF != oShape.m_nRelTop || PROP_DEF != oShape.m_nRelBottom )
oShape.m_nRelRotation = oShape.m_nRotation;
break;
case SimpleTypes::Vml::cssptTop :
oShape.m_nRelTop = prop->get_Value().dValue; break;
}break;
case SimpleTypes::Vml::cssptVisibility :
break;
case SimpleTypes::Vml::cssptWidth :
{
int nWidth = (int)(20 * prop->get_Value().dValue);
if( PROP_DEF != oShape.m_nLeft )
oShape.m_nRight = oShape.m_nLeft + nWidth;
if( PROP_DEF != oShape.m_nRelLeft)
oShape.m_nRelRight = oShape.m_nRelLeft + nWidth;
}break;
case SimpleTypes::Vml::cssptZIndex :
{
oShape.m_eShapeType = RtfShape::st_anchor;
int nValue = prop->get_Value().oZIndex.nOrder;
oShape.m_nZOrder = nValue;
if( nValue > 0 )
......
......@@ -103,6 +103,15 @@ public:
Parse( pSdt->m_oSdtContent.GetPointer(), oParam );
}
}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;
}
......
......@@ -153,7 +153,7 @@ public:
oBorderReader.Parse( oParam,oOutputProperty.m_oBorderBottom );
}
}
else if (m_ooxTableProps)
else if ((m_ooxTableProps) && (m_ooxTableProps->m_oTblBorders.IsInit()))
{
//from table props
//todoo last, first !!!!
......
......@@ -61,17 +61,23 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter)
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 )
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
else
{
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( _T("}") );
sResult.Append( _T("{\\nonshppict") );
......@@ -80,45 +86,104 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter)
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
{
sResult.Append(_T("{\\shp{\\*\\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_nZOrder, sResult, _T("shpz") );
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") );
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_nZOrder , sResult, _T("shpz") );
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") );
switch(m_eXAnchor)
{
case ax_page: sResult.Append( _T("\\shpbxpage") );break;
case ax_margin: sResult.Append( _T("\\shpbxmargin") );break;
case ax_column: sResult.Append( _T("\\shpbxcolumn") );break;
case ax_page: sResult.Append( _T("\\shpbxpage") ); break;
case ax_margin: sResult.Append( _T("\\shpbxmargin") ); break;
case ax_column: sResult.Append( _T("\\shpbxcolumn") ); break;
}
sResult.Append( _T("\\shpbxignore") );
switch(m_eYAnchor)
{
case ay_page: sResult.Append( _T("\\shpbypage") );break;
case ay_margin: sResult.Append( _T("\\shpbymargin") );break;
case ay_Para: sResult.Append( _T("\\shpbypara") );break;
case ay_page: sResult.Append( _T("\\shpbypage") ); break;
case ay_margin: sResult.Append( _T("\\shpbymargin") ); break;
case ay_Para: sResult.Append( _T("\\shpbypara") ); break;
}
sResult.Append( _T("\\shpbyignore") );
RENDER_RTF_INT( m_nZOrderRelative, sResult, _T("shpfblwtxt") );
sResult.Append( RenderToRtfShapeProperty( oRenderParameter ) );
//picture
if( 0 != m_oPicture )
if( 0 != m_oPicture)
{
if (m_nShapeType == 75)
{
sResult.Append( _T("{\\sp{\\sn pib}{\\sv ") );
sResult.Append( m_oPicture->RenderToRtf( oRenderParameter ) );
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
if( 0 != m_aTextItems )
{
......@@ -127,7 +192,7 @@ CString RtfShape::RenderToRtf(RenderParameter oRenderParameter)
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( m_oPicture->GenerateWMF( oRenderParameter ) );
......@@ -160,11 +225,12 @@ CString RtfShape::RenderToRtfShapeProperty(RenderParameter oRenderParameter)
if( PROP_DEF != m_nPositionHRelative )
sResult.AppendFormat( _T("{\\sp{\\sn posrelh}{\\sv %d}}"),m_nPositionHRelative);
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 )
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 )
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 )
sResult.AppendFormat( _T("{\\sp{\\sn fAllowOverlap}{\\sv %d}}"),m_bAllowOverlap);
......@@ -1142,8 +1208,15 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sResult.Append( _T("</w:txbxContent>") );
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 nCropTop = PROP_DEF;
int nCropRight = PROP_DEF;
......@@ -1166,9 +1239,6 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
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) );
CString sPicture = m_oPicture->RenderToOOX(oRenderParameter);
if( _T("") == sPicture )//если не сохранилась картинка, то весь shape будет бесполезным
return _T("");
sResult.AppendFormat( _T("<v:imagedata r:id=\"%ls\""), sPicture.GetBuffer() );
if( PROP_DEF != nCropLeft )
sResult.AppendFormat( _T(" cropleft=\"%df\""), nCropLeft );
......@@ -1180,6 +1250,17 @@ CString RtfShape::RenderToOOXBegin(RenderParameter oRenderParameter)
sResult.AppendFormat( _T(" cropbottom=\"%df\""), nCropBottom );
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;
}
CString RtfShape::RenderToOOXEnd(RenderParameter oRenderParameter)
......
......@@ -145,6 +145,7 @@ public:
//Fill
int m_bFilled; //fFilled The shape is filled.
int m_nFillType;
//Line
int m_bLine; //fLine Has a line
int m_nLineStartArrow; //lineStartArrowhead Start arrow type:
......@@ -276,6 +277,7 @@ public:
//Fill
DEFAULT_PROPERTY_DEF( m_bFilled, true )
DEFAULT_PROPERTY( m_nFillType )
//Line
DEFAULT_PROPERTY_DEF( m_bLine, true )
DEFAULT_PROPERTY( m_nLineStartArrow )
......
......@@ -98,8 +98,8 @@ namespace OOX
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oHrNoShade;
SimpleTypes::CDouble m_oHrPct;
SimpleTypes::CHrAlign<SimpleTypes::hralignLeft> m_oHrAlign;
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oAllowInCell;
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oAllowOverlap;
SimpleTypes::CTrueFalse<SimpleTypes::booleanTrue> m_oAllowInCell;
SimpleTypes::CTrueFalse<SimpleTypes::booleanTrue> m_oAllowOverlap;
SimpleTypes::CTrueFalse<SimpleTypes::booleanFalse> m_oUserDrawn;
nullable<SimpleTypes::CColorType<>> m_oBorderTopColor;
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