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

RtfFormat - документы скаченные с hh + изображения в колонтитулах

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67828 954022d7-b5bf-4e40-9824-e11837661b57
parent f118b76b
......@@ -3277,7 +3277,9 @@ public: RtfSectionCommand()
{
ParagraphReader oParagraphReader(sCommand, oReader);
oAbstrReader.StartSubReader( oParagraphReader, oDocument, oReader );
oParagraphReader.m_oParPropDest.Finalize(oReader);
TextItemContainerPtr oNewFooterHeader = oParagraphReader.m_oParPropDest.m_oTextItems;
if( _T("header") == sCommand )
......@@ -3294,7 +3296,7 @@ public: RtfSectionCommand()
oReader.m_oCurSectionProp.m_oFooterLeft = oNewFooterHeader;
else if( _T("footerr") == sCommand )
oReader.m_oCurSectionProp.m_oFooterRight = oNewFooterHeader;
else if( _T("footerr") == sCommand )
else if( _T("footerf") == sCommand )
oReader.m_oCurSectionProp.m_oFooterFirst = oNewFooterHeader;
}
else
......
......@@ -10,6 +10,8 @@ bool OOXHeaderReader::Parse( ReaderParameter oParam, CString sRID, TextItemConta
OOX::CHdrFtr *pHdrFtr = oParam.oDocx->GetHeaderOrFooter(m_ref->m_oId->GetValue());
if (pHdrFtr == NULL) return false;
oParam.oReader->m_currentContainer = dynamic_cast<OOX::IFileContainer*>(pHdrFtr);
OOXTextItemReader oOOXTextItemReader;
oOutput = TextItemContainerPtr( new TextItemContainer() );
oOOXTextItemReader.m_oTextItems = oOutput;
......@@ -19,5 +21,7 @@ bool OOXHeaderReader::Parse( ReaderParameter oParam, CString sRID, TextItemConta
oOOXTextItemReader.Parse(pHdrFtr->m_arrItems[i], oParam );
}
oParam.oReader->m_currentContainer = dynamic_cast<OOX::IFileContainer*>(oParam.oDocx->GetDocument());
return true;
}
......@@ -136,11 +136,15 @@ bool OOXParagraphReader::Parse2( ReaderParameter oParam , RtfParagraph& oOutputP
if( pHyperlink->m_oId.IsInit() )
{
CString sTarget;
smart_ptr<OOX::File> oFile = oParam.oDocx->GetDocument()->Find(pHyperlink->m_oId->GetValue());
if ((oFile.IsInit()) && (OOX::FileTypes::HyperLink == oFile->type()))
{
OOX::HyperLink* pH = (OOX::HyperLink*)oFile.operator->();
sTarget = pH->Uri().GetPath();
if (oParam.oReader->m_currentContainer)
{
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(pHyperlink->m_oId->GetValue());
if ((oFile.IsInit()) && (OOX::FileTypes::HyperLink == oFile->type()))
{
OOX::HyperLink* pH = (OOX::HyperLink*)oFile.operator->();
sTarget = pH->Uri().GetPath();
}
}
if( _T("") != sTarget )
{
......@@ -489,12 +493,16 @@ bool OOXRunReader::Parse( ReaderParameter oParam , RtfParagraph& oOutputParagrap
if(ooxObject->m_oOleObject->m_oId.IsInit())
{
CString sRelativePath;
smart_ptr<OOX::File> oFile = oParam.oDocx->GetDocument()->Find(ooxObject->m_oOleObject->m_oId->GetValue());
if ((oFile.IsInit() && (OOX::FileTypes::OleObject == oFile->type())))
{
OOX::OleObject* pO = (OOX::OleObject*)oFile.operator->();
sRelativePath = pO->m_sFilename;
if (oParam.oReader->m_currentContainer)
{
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(ooxObject->m_oOleObject->m_oId->GetValue());
if ((oFile.IsInit() && (OOX::FileTypes::OleObject == oFile->type())))
{
OOX::OleObject* pO = (OOX::OleObject*)oFile.operator->();
sRelativePath = pO->m_sFilename;
}
}
//todooo проверить что тут за путь ..
CString sOlePath = oParam.oReader->m_sPath + FILE_SEPARATOR_STR + sRelativePath;
......
......@@ -49,14 +49,17 @@ public:
{
CString sImageId = picture->m_oBlipFill.m_oBlip->m_oEmbed.GetValue();
//todooo ... вынести отдельно (для встроенных документов)
smart_ptr<OOX::File> oFile = oParam.oDocx->GetDocument()->Find(sImageId);
if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type()))
if (oParam.oReader->m_currentContainer)
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
smart_ptr<OOX::File> oFile = oParam.oReader->m_currentContainer->Find(sImageId);
if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type()))
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
CString sImagePath = pImage->filename().GetPath();
WriteDataToPicture( sImagePath, oOutput, _T("") );
CString sImagePath = pImage->filename().GetPath();
WriteDataToPicture( sImagePath, oOutput, _T("") );
}
}
}
}
......
......@@ -15,6 +15,7 @@ OOXReader::OOXReader( RtfDocument& oDocument, std::wstring path ): m_oDocument(
m_nCurItap = 0;
m_convertationManager = NULL;
m_currentContainer = NULL;
}
bool OOXReader::Parse()
{
......@@ -93,10 +94,13 @@ bool OOXReader::Parse()
OOX::CDocument* document = inputDocxFile.GetDocument();
if (document)
{
m_currentContainer = dynamic_cast<OOX::IFileContainer*>(document);
OOXDocumentReader oDocReader( document );
oDocReader.Parse( oReaderParameter );
}
return true;
}
CString OOXReader::GetFolder( CString sDocPath )
......
......@@ -43,6 +43,8 @@ public:
OOXReader( RtfDocument& oDocument, std::wstring path );
bool Parse();
OOX::IFileContainer *m_currentContainer;
private:
void ParseColorTable( RtfDocument& oDocument );
CString GetFolder ( CString sDocPath );
......
......@@ -50,16 +50,19 @@ bool OOXShapeReader::Parse2( ReaderParameter oParam , RtfShapePtr& oOutput)
if (srId.GetLength() < 1)
srId = image_data->m_rId.IsInit() ? image_data->m_rId->GetValue() : _T("") ;
smart_ptr<OOX::File> oFile = oParam.oDocx->GetDocument()->Find(srId);
if (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->();
if ( oFile.IsInit() && (OOX::FileTypes::Image == oFile->type()))
{
OOX::Image* pImage = (OOX::Image*)oFile.operator->();
CString sImagePath = pImage->filename().GetPath();
//todooo проверить что за путь тут выставляется
OOXPictureGraphicReader::WriteDataToPicture( sImagePath, *oOutput->m_oPicture, oParam.oReader->m_sPath );
CString sImagePath = pImage->filename().GetPath();
//todooo проверить что за путь тут выставляется
OOXPictureGraphicReader::WriteDataToPicture( sImagePath, *oOutput->m_oPicture, oParam.oReader->m_sPath );
}
}
int nCropedWidthGoal = oOutput->m_oPicture->m_nWidthGoal;
if( PROP_DEF != nCropedWidthGoal )
......
......@@ -42,7 +42,8 @@ public:
{
RtfStylePtr oResultStyle = oParam.oRtf->m_oStyleTable.GetStyleResulting( oStyle );
RtfTableStylePtr oTableStyle = boost::static_pointer_cast<RtfTableStyle, RtfStyle>( oResultStyle );
oOutputProperty = oTableStyle->m_oTableProp;
oOutputProperty.Merge( oTableStyle->m_oTableProp );
oOutputProperty.m_nStyle = oTableStyle->m_nID;
}
}
......@@ -190,14 +191,20 @@ public:
if( m_ooxTableProps->m_oTblW.IsInit() && m_ooxTableProps->m_oTblW->m_oW.IsInit())
{
oOutputProperty.m_nWidth = m_ooxTableProps->m_oTblW->m_oW->GetValue();
if( m_ooxTableProps->m_oTblW->m_oType.IsInit())
{
switch(m_ooxTableProps->m_oTblW->m_oType->GetValue())
{
case SimpleTypes::tblwidthDxa: oOutputProperty.m_eMUWidth = mu_Twips; break;
case SimpleTypes::tblwidthPct: oOutputProperty.m_eMUWidth = mu_Percent; break;
case SimpleTypes::tblwidthDxa:
{
oOutputProperty.m_nWidth = m_ooxTableProps->m_oTblW->m_oW->GetValue();
oOutputProperty.m_eMUWidth = mu_Twips;
}break;
case SimpleTypes::tblwidthPct:
{
oOutputProperty.m_nWidth = m_ooxTableProps->m_oTblW->m_oW->GetValue();
oOutputProperty.m_eMUWidth = mu_Percent;
}break;
}
}
}
......
......@@ -75,10 +75,10 @@ public:
{
//в проекте используется ungetcб только после getc
//поэтому проблем с выходом в 0 нет
if( m_nPosAbs + 1 < m_nSizeAbs )
//if( m_nPosAbs + 2 < m_nSizeAbs )
{
m_nPosAbs--;
}//взять любой txt переименовать в rtf - зацикливание
m_nPosAbs--; //взять любой txt переименовать в rtf - зацикливание
}
}
void putString( CStringA sText )
{
......
......@@ -73,13 +73,13 @@ CString RtfPicture::RenderToRtf(RenderParameter oRenderParameter)
RENDER_RTF_INT( m_nHeightGoal, sResult, _T("pichgoal") )
switch( eDataType )
{
case dt_emf: sResult.Append(_T("\\emfblip"));break;
case dt_wmf: sResult.Append(_T("\\wmetafile8"));break;
case dt_png: sResult.Append(_T("\\pngblip"));break;
case dt_jpg: sResult.Append(_T("\\jpegblip"));break;
//case dt_bmp: sResult.Append(_T("wbitmap8"));break;
}
{
case dt_emf: sResult.Append(_T("\\emfblip"));break;
case dt_wmf: sResult.Append(_T("\\wmetafile8"));break;
case dt_png: sResult.Append(_T("\\pngblip"));break;
case dt_jpg: sResult.Append(_T("\\jpegblip"));break;
//case dt_bmp: sResult.Append(_T("wbitmap8"));break;
}
sResult.Append( _T(" "));
sResult.Append( RtfUtility::RtfInternalEncoder::Encode( m_sPicFilename ) );
......
......@@ -17,7 +17,7 @@ bool RtfReader::Load()
oNormalReader.Parse( m_oDocument, (*this) );
m_oLex.CloseSource();
return true;
}
}
void RtfReader::PushState()
{
ReaderStatePtr psaveNew = ReaderStatePtr(new ReaderState());
......
......@@ -481,7 +481,7 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
case sb_sbkodd: sResult.Append(_T("<w:type w:val=\"oddPage\"/>") );break;
}
//Columns
if( PROP_DEF != m_nColumnNumber )
if( PROP_DEF != m_nColumnNumber )
{
CString sCollumnFormating;
bool bEqualWidth = false;
......
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