Commit 8f45da5a authored by ElenaSubbotina's avatar ElenaSubbotina

RtfWriter - fix read section with fields

parent 84fb75ab
......@@ -246,7 +246,7 @@ public:
CString RenderToRtf(RenderParameter oRenderParameter)
{
CString sResult;
for( int i = 0; i < (int)m_aArray.size(); i++ )
for( int i = 0; i < (int)m_aArray.size(); i++ )//идем с конца - из за св-в секций
{
sResult += m_aArray[i]->RenderToRtf( oRenderParameter );
......@@ -260,8 +260,10 @@ public:
CString RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
for( int i = 0; i < (int)m_aArray.size(); i++ )
sResult += m_aArray[i]->RenderToOOX(oRenderParameter);
for( int i = (int)m_aArray.size() - 1; i >= 0; i-- )
{
sResult = m_aArray[i]->RenderToOOX(oRenderParameter) + sResult;
}
return sResult;
}
bool IsValid()
......
......@@ -1705,9 +1705,10 @@ public:
}
void ExitReader( RtfDocument& oDocument, RtfReader& oReader )
{
m_oParPropDest.Finalize( oReader/*, RtfSectionPtr()*/);
m_oRtfFootnote.m_oContent = m_oParPropDest.m_oTextItems;
oReader.m_nFootnote = PROP_DEF;
m_oParPropDest.Finalize( oReader );
m_oRtfFootnote.m_oContent = m_oParPropDest.m_oTextItems;
oReader.m_nFootnote = PROP_DEF;
}
};
class RtfDefParPropReader: public RtfAbstractReader
......@@ -2409,7 +2410,7 @@ public:
}
void ExitReader( RtfDocument& oDocument, RtfReader& oReader )
{
m_oParPropDest.Finalize( oReader /*, RtfSectionPtr()*/ );
m_oParPropDest.Finalize( oReader );
}
};
......@@ -2422,21 +2423,22 @@ class RtfSectionCommand
{
private:
typedef enum{ is_none, is_border_left, is_border_top, is_border_right, is_border_bottom }InternalState;
InternalState m_eInternalState;
int nCurCollumnNumber;
public:
RtfSectionCommand()
{
m_eInternalState = is_none;
nCurCollumnNumber = PROP_DEF;
m_eInternalState = is_none;
nCurCollumnNumber = PROP_DEF;
}
bool ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader, RtfAbstractReader& oAbstrReader, CString sCommand, bool hasParameter, int parameter);
};
class RtfNormalReader : public RtfAbstractReader
{
public:
ParagraphPropDestination oParagraphReaderDestination;
RtfSectionCommand oRtfSectionCommand;
ParagraphPropDestination oParagraphReaderDestination;
RtfSectionCommand oRtfSectionCommand;
RtfNormalReader( RtfDocument& oDocument, RtfReader& oReader )
{
......@@ -2457,7 +2459,7 @@ public:
}
void ExitReader(RtfDocument& oDocument, RtfReader& oReader)
{
oParagraphReaderDestination.Finalize(oReader/*, RtfSectionPtr()*/);
oParagraphReaderDestination.Finalize( oReader );
_section section;
if(true == oDocument.GetItem( section) )
......@@ -2467,10 +2469,10 @@ public:
if( NULL == oDocument.m_oFootnoteCon )
{
oDocument.m_oFootnoteCon = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsepc;
oDocument.m_oFootnoteCon = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsepc;
oNewPar->AddItem( oNewChar );
oDocument.m_oFootnoteCon->AddItem( oNewPar );
......@@ -2478,10 +2480,10 @@ public:
}
if( NULL == oDocument.m_oFootnoteSep )
{
oDocument.m_oFootnoteSep = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsep;
oDocument.m_oFootnoteSep = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsep;
oNewPar->AddItem( oNewChar );
oDocument.m_oFootnoteSep->AddItem( oNewPar );
......@@ -2489,10 +2491,10 @@ public:
}
if( NULL == oDocument.m_oEndnoteCon )
{
oDocument.m_oEndnoteCon = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsepc;
oDocument.m_oEndnoteCon = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsepc;
oNewPar->AddItem( oNewChar );
oDocument.m_oEndnoteCon->AddItem( oNewPar );
......@@ -2500,10 +2502,10 @@ public:
}
if( NULL == oDocument.m_oEndnoteSep )
{
oDocument.m_oEndnoteSep = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsep;
oDocument.m_oEndnoteSep = TextItemContainerPtr( new TextItemContainer() );
RtfParagraphPtr oNewPar = RtfParagraphPtr( new RtfParagraph() );
RtfCharSpecialPtr oNewChar = RtfCharSpecialPtr( new RtfCharSpecial() );
oNewChar->m_eType = RtfCharSpecial::rsc_chftnsep;
oNewPar->AddItem( oNewChar );
oDocument.m_oEndnoteSep->AddItem( oNewPar );
......@@ -2514,15 +2516,16 @@ private:
void SectDef( RtfDocument& oDocument, RtfReader& oReader )
{
oReader.m_oCurSectionProp.SetDefaultRtf();
//в соответствии с документацией ставим Page Information свойства как у документа
oReader.m_oCurSectionProp.m_nPageWidth = oDocument.m_oProperty.m_nPaperWidth;
oReader.m_oCurSectionProp.m_nPageHeight = oDocument.m_oProperty.m_nPaperHeight;
oReader.m_oCurSectionProp.m_nMarginLeft = oDocument.m_oProperty.m_nMarginLeft;
oReader.m_oCurSectionProp.m_nMarginRight = oDocument.m_oProperty.m_nMarginRight;
oReader.m_oCurSectionProp.m_nMarginTop = oDocument.m_oProperty.m_nMarginTop;
oReader.m_oCurSectionProp.m_nMarginBottom = oDocument.m_oProperty.m_nMarginBottom;
oReader.m_oCurSectionProp.m_nGutterMarginWidth = oDocument.m_oProperty.m_nGutterWidth;
oReader.m_oCurSectionProp.m_bSwitchMargin = oDocument.m_oProperty.m_bFacingPage;
oReader.m_oCurSectionProp.m_bLandscapeFormat = oDocument.m_oProperty.m_bLandScape;
oReader.m_oCurSectionProp.m_nPageWidth = oDocument.m_oProperty.m_nPaperWidth;
oReader.m_oCurSectionProp.m_nPageHeight = oDocument.m_oProperty.m_nPaperHeight;
oReader.m_oCurSectionProp.m_nMarginLeft = oDocument.m_oProperty.m_nMarginLeft;
oReader.m_oCurSectionProp.m_nMarginRight = oDocument.m_oProperty.m_nMarginRight;
oReader.m_oCurSectionProp.m_nMarginTop = oDocument.m_oProperty.m_nMarginTop;
oReader.m_oCurSectionProp.m_nMarginBottom = oDocument.m_oProperty.m_nMarginBottom;
oReader.m_oCurSectionProp.m_nGutterMarginWidth = oDocument.m_oProperty.m_nGutterWidth;
oReader.m_oCurSectionProp.m_bSwitchMargin = oDocument.m_oProperty.m_bFacingPage;
oReader.m_oCurSectionProp.m_bLandscapeFormat = oDocument.m_oProperty.m_bLandScape;
}
};
......@@ -90,7 +90,6 @@ public:
}
}
}
m_poDocument->RemoveItem(0);
_section last_section;
m_poDocument->GetItem(last_section);
......@@ -112,6 +111,8 @@ public:
m_poDocument->AddItem( section );
}
m_poDocument->RemoveItem(0);
for (int sect = 0 ; sect < m_poDocument->GetCount(); sect++)
{
m_oTextItemReader.m_oTextItems = m_poDocument->m_aArray[sect].props;
......
......@@ -163,9 +163,11 @@ CString RtfFootnote::RenderToOOX(RenderParameter oRenderParameter)
{
int nID = poDocument->m_oIdGenerator.Generate_FootnoteNumber();
OOXFootnoteWriter* poFootnoteWriter = static_cast<OOXFootnoteWriter*>( poOOXWriter->m_poFootnoteWriter );
RenderParameter oNewParameter = oRenderParameter;
oNewParameter.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
oNewParameter.poRels = poFootnoteWriter->m_oRelsWriter.get();
oNewParameter.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
oNewParameter.poRels = poFootnoteWriter->m_oRelsWriter.get();
poFootnoteWriter->AddFootnote( _T(""), nID, m_oContent->RenderToOOX(oNewParameter) );
sResult += _T("<w:r>");
......
......@@ -45,80 +45,79 @@ const long g_cdMaxPercent = 1000000;
//#define RTF_MATH_OOX
#define ELEMENT_UNDEFINED 0x001;
#define ELEMENT_OOXFIELD 0x010;
#define TYPE_UNKNOWN 0
#define TYPE_RTF_DOCUMENT 1
#define TYPE_RTF_PARAGRAPH 2
#define TYPE_RTF_BOOKMARKSTART 3
#define TYPE_RTF_BOOKMARKEND 4
#define TYPE_RTF_CHAR 5
#define TYPE_RTF_FIELD 6
#define TYPE_RTF_MATH 7
#define TYPE_RTF_PICTURE 8
#define TYPE_RTF_PROPERTY_DOCUMENT 9
#define TYPE_RTF_PROPERTY_SECTION 10
#define TYPE_RTF_FONT 11
#define TYPE_RTF_PROPERTY_SHADING 13
#define ELEMENT_UNDEFINED 0x001;
#define ELEMENT_OOXFIELD 0x010;
#define TYPE_UNKNOWN 0
#define TYPE_RTF_DOCUMENT 1
#define TYPE_RTF_PARAGRAPH 2
#define TYPE_RTF_BOOKMARKSTART 3
#define TYPE_RTF_BOOKMARKEND 4
#define TYPE_RTF_CHAR 5
#define TYPE_RTF_FIELD 6
#define TYPE_RTF_MATH 7
#define TYPE_RTF_PICTURE 8
#define TYPE_RTF_PROPERTY_DOCUMENT 9
#define TYPE_RTF_PROPERTY_SECTION 10
#define TYPE_RTF_FONT 11
#define TYPE_RTF_PROPERTY_SHADING 13
#define TYPE_RTF_PROPERTY_SHADING_PARAGRAPH 14
#define TYPE_RTF_PROPERTY_SHADING_CHAR 15
#define TYPE_RTF_PROPERTY_SHADING_CELL 16
#define TYPE_RTF_PROPERTY_SHADING_ROW 17
#define TYPE_RTF_PROPERTY_SHADING_TABLESTYLE 18
#define TYPE_RTF_PROPERTY_BORDER 19
#define TYPE_RTF_PROPERTY_STYLE_CHAR 21
#define TYPE_RTF_PROPERTY_SHADING_CHAR 15
#define TYPE_RTF_PROPERTY_SHADING_CELL 16
#define TYPE_RTF_PROPERTY_SHADING_ROW 17
#define TYPE_RTF_PROPERTY_SHADING_TABLESTYLE 18
#define TYPE_RTF_PROPERTY_BORDER 19
#define TYPE_RTF_PROPERTY_STYLE_CHAR 21
#define TYPE_RTF_PROPERTY_STYLE_PARAGRAPH 22
#define TYPE_RTF_PROPERTY_STYLE_TABLE 22
#define TYPE_RTF_SECTION 23
#define TYPE_RTF_TABLE 24
#define TYPE_RTF_TABLE_CELL 25
#define TYPE_RTF_PROPERTY_CHAR 26
#define TYPE_RTF_PROPERTY_STYLE 27
#define TYPE_RTF_TABLE_ROW 28
#define TYPE_RTF_OLE 29
#define TYPE_OOX_FIELD 29
#define TYPE_RTF_FOOTNOTE 30
#define RENDER_TO_OOX_PARAM_UNKNOWN 0
#define RENDER_TO_OOX_PARAM_LAST 1
#define RENDER_TO_OOX_PARAM_RUN 2
#define RENDER_TO_OOX_PARAM_PLAIN 3
#define RENDER_TO_OOX_PARAM_TEXT 4
#define RENDER_TO_OOX_PARAM_MATH 5
#define RENDER_TO_OOX_PARAM_NESTED 6
#define RENDER_TO_OOX_PARAM_FONTTABLE 7
#define RENDER_TO_OOX_PARAM_MAJOR_FONT 10
#define RENDER_TO_OOX_PARAM_MINOR_FONT 11
#define RENDER_TO_OOX_PARAM_CORE 12
#define RENDER_TO_OOX_PARAM_APP 13
#define RENDER_TO_OOX_PARAM_COLOR_VALUE 14
#define RENDER_TO_OOX_PARAM_COLOR_ATTRIBUTE 15
#define RENDER_TO_OOX_PARAM_COLOR_TAG 16
#define RENDER_TO_OOX_PARAM_NUMBERING 17
#define RENDER_TO_OOX_PARAM_STYLES 18
#define RENDER_TO_OOX_PARAM_BORDER_ATTRIBUTE 19
#define RENDER_TO_OOX_PARAM_BORDER_TAG 20
#define RENDER_TO_OOX_PARAM_SHAPE_WSHAPE 22
#define RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2 23
#define RENDER_TO_OOX_PARAM_FIRST_SECTION 24
#define RENDER_TO_OOX_PARAM_OLE_ONLY 25
#define RENDER_TO_OOX_PARAM_OLDLIST_ABS 26
#define RENDER_TO_OOX_PARAM_OLDLIST_OVR 27
#define RENDER_TO_RTF_PARAM_UNKNOWN 0
#define RENDER_TO_RTF_PARAM_CHAR 1
#define RENDER_TO_RTF_PARAM_NO_PAR 2
#define RENDER_TO_RTF_PARAM_PAR 3
#define RENDER_TO_RTF_PARAM_NESTED 4
#define RENDER_TO_RTF_PARAM_PLAIN 5
#define RENDER_TO_RTF_PARAM_NO_SECT 6
#define RENDER_TO_RTF_PARAM_FONT_TBL 7
#define RENDER_TO_RTF_PARAM_COLOR_TBL 8
#define RENDER_TO_RTF_PARAM_NO_WROWD 9
#define TYPE_RTF_PROPERTY_STYLE_TABLE 22
#define TYPE_RTF_SECTION 23
#define TYPE_RTF_TABLE 24
#define TYPE_RTF_TABLE_CELL 25
#define TYPE_RTF_PROPERTY_CHAR 26
#define TYPE_RTF_PROPERTY_STYLE 27
#define TYPE_RTF_TABLE_ROW 28
#define TYPE_RTF_OLE 29
#define TYPE_OOX_FIELD 29
#define TYPE_RTF_FOOTNOTE 30
#define RENDER_TO_OOX_PARAM_UNKNOWN 0
#define RENDER_TO_OOX_PARAM_LAST 1
#define RENDER_TO_OOX_PARAM_RUN 2
#define RENDER_TO_OOX_PARAM_PLAIN 3
#define RENDER_TO_OOX_PARAM_TEXT 4
#define RENDER_TO_OOX_PARAM_MATH 5
#define RENDER_TO_OOX_PARAM_NESTED 6
#define RENDER_TO_OOX_PARAM_FONTTABLE 7
#define RENDER_TO_OOX_PARAM_MAJOR_FONT 10
#define RENDER_TO_OOX_PARAM_MINOR_FONT 11
#define RENDER_TO_OOX_PARAM_CORE 12
#define RENDER_TO_OOX_PARAM_APP 13
#define RENDER_TO_OOX_PARAM_COLOR_VALUE 14
#define RENDER_TO_OOX_PARAM_COLOR_ATTRIBUTE 15
#define RENDER_TO_OOX_PARAM_COLOR_TAG 16
#define RENDER_TO_OOX_PARAM_NUMBERING 17
#define RENDER_TO_OOX_PARAM_STYLES 18
#define RENDER_TO_OOX_PARAM_BORDER_ATTRIBUTE 19
#define RENDER_TO_OOX_PARAM_BORDER_TAG 20
#define RENDER_TO_OOX_PARAM_SHAPE_WSHAPE 22
#define RENDER_TO_OOX_PARAM_SHAPE_WSHAPE2 23
#define RENDER_TO_OOX_PARAM_FIRST_SECTION 24
#define RENDER_TO_OOX_PARAM_OLE_ONLY 25
#define RENDER_TO_OOX_PARAM_OLDLIST_ABS 26
#define RENDER_TO_OOX_PARAM_OLDLIST_OVR 27
#define RENDER_TO_RTF_PARAM_UNKNOWN 0
#define RENDER_TO_RTF_PARAM_CHAR 1
#define RENDER_TO_RTF_PARAM_NO_PAR 2
#define RENDER_TO_RTF_PARAM_PAR 3
#define RENDER_TO_RTF_PARAM_NESTED 4
#define RENDER_TO_RTF_PARAM_PLAIN 5
#define RENDER_TO_RTF_PARAM_NO_SECT 6
#define RENDER_TO_RTF_PARAM_FONT_TBL 7
#define RENDER_TO_RTF_PARAM_COLOR_TBL 8
#define RENDER_TO_RTF_PARAM_NO_WROWD 9
......
......@@ -43,6 +43,7 @@ RtfDocument::RtfDocument()
{
RtfSectionPtr s(new RtfSection());
_section section(s, 0, 0);
m_aArray.push_back( section );
m_oProperty.SetDefaultOOX();
......
......@@ -68,8 +68,8 @@ typedef boost::shared_ptr<RtfOldList> RtfOldListPtr;
class RtfParagraph : public ITextItem, public ItemContainer< IDocumentElementPtr >
{
public:
RtfParagraphProperty m_oProperty;
RtfOldListPtr m_oOldList;
RtfParagraphProperty m_oProperty;
RtfOldListPtr m_oOldList;
int GetType( )
{
......@@ -163,6 +163,17 @@ public:
}
else
{
CString ParagraphContent;// todooo проследить за вложенными объектами (inset fields) - св-ва секций
// нужно чтобы были в последнем параграфе!!! - так что и начнем с него - Australia Electronic Transactions Act 1999.rtf
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
for( int i = m_aArray.size() - 1; i >= 0; i-- )
{
ParagraphContent = m_aArray[i]->RenderToOOX(oNewParam) + ParagraphContent;
}
bool bCanConvertToNumbering = false;
if( NULL != m_oOldList )
bCanConvertToNumbering = m_oOldList->CanConvertToNumbering();
......@@ -190,7 +201,7 @@ public:
if( NULL != m_oOldList->m_oText )
oCharProp.m_nFont = m_oOldList->m_oText->m_oProperty.m_oCharProperty.m_nFont;
RenderParameter oNewParam = oRenderParameter;
oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_TEXT;
for( int i = 0; i < m_oOldList->m_oText->GetCount(); i++ )
......@@ -206,13 +217,8 @@ public:
}
}
RenderParameter oNewParam = oRenderParameter;
oNewParam.nType = RENDER_TO_OOX_PARAM_RUN;
for( int i = 0; i < (int)m_aArray.size(); i++ )
{
sResult += m_aArray[i]->RenderToOOX(oNewParam);
}
sResult += ParagraphContent;
sResult += _T("</w:p>");
}
return sResult;
......
......@@ -1202,14 +1202,14 @@ CString RtfParagraphStyle::RenderToOOX(RenderParameter oRenderParameter)
if( false == sParProp.IsEmpty() )
{
sResult += _T("<w:pPr>");
sResult += sParProp;
sResult += sParProp;
sResult += _T("</w:pPr>");
}
CString sCharProp = m_oCharProp.RenderToOOX(oRenderParameter);
if( false == sCharProp.IsEmpty() )
{
sResult += _T("<w:rPr>");
sResult += sCharProp;
sResult += sCharProp;
sResult += _T("</w:rPr>");
}
sResult += RenderToOOXEnd( oRenderParameter ) ;
......@@ -1321,35 +1321,35 @@ CString RtfTableStyle::RenderToOOX(RenderParameter oRenderParameter)
if( false == sTablProp.IsEmpty() )
{
sResult += _T("<w:tblPr>");
sResult += sTablProp;
sResult += sTablProp;
sResult += _T("</w:tblPr>");
}
CString sRowProp = m_oRowProp.RenderToOOX(oRenderParameter);
if( false == sRowProp.IsEmpty() )
{
sResult += _T("<w:trPr>");
sResult += sRowProp;
sResult += sRowProp;
sResult += _T("</w:trPr>");
}
CString sCellProp = m_oCellProp.RenderToOOX(oRenderParameter);
if( false == sCellProp.IsEmpty() )
{
sResult += _T("<w:tcPr>");
sResult += sCellProp;
sResult += sCellProp;
sResult += _T("</w:tcPr>");
}
CString sParProp = m_oParProp.RenderToOOX(oRenderParameter);
if( false == sParProp.IsEmpty() )
{
sResult += _T("<w:pPr>");
sResult += sParProp;
sResult += sParProp;
sResult += _T("</w:pPr>");
}
CString sCharProp = m_oCharProp.RenderToOOX(oRenderParameter);
if( false == sCharProp.IsEmpty() )
{
sResult += _T("<w:rPr>");
sResult += sCharProp;
sResult += sCharProp;
sResult += _T("</w:rPr>");
}
......@@ -1447,14 +1447,14 @@ CString RtfTableStyle::RenderToOOX(RenderParameter oRenderParameter)
if( false == sParProp.IsEmpty() )
{
sResult += _T("<w:pPr>");
sResult += sParProp;
sResult += sParProp;
sResult += _T("</w:pPr>");
}
CString sCharProp = m_oCharProp.RenderToOOX(oRenderParameter);
if( false == sCharProp.IsEmpty() )
{
sResult += _T("<w:rPr>");
sResult += sCharProp;
sResult += sCharProp;
sResult += _T("</w:rPr>");
}
sResult += _T("</w:tblStylePr>") ;
......@@ -1868,8 +1868,8 @@ CString RtfParagraphProperty::RenderToRtf(RenderParameter oRenderParameter)
}
CString RtfParagraphProperty::RenderToOOX(RenderParameter oRenderParameter)
{
RtfDocument* poRtfDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
RtfDocument* poRtfDocument = static_cast<RtfDocument*> (oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*> (oRenderParameter.poWriter);
CString sResult;
if( PROP_DEF != m_nStyle )
......@@ -1882,21 +1882,13 @@ CString RtfParagraphProperty::RenderToOOX(RenderParameter oRenderParameter)
sResult += _T("\"/>") ;
}
}
if ( 0 == m_bAutoHyphenation ) sResult += _T("<w:suppressAutoHyphens/>");
else if ( 1 == m_bAutoHyphenation ) sResult += _T("<w:suppressAutoHyphens w:val=\"false\"/>");
_section section;
if(true == poRtfDocument->GetItem( section ) )
{
sResult += section.props->RenderToOOX(oRenderParameter);
section.props->m_bFinalize = false;
}
if( 0 == m_bAutoHyphenation ) sResult += _T("<w:suppressAutoHyphens/>");
else if( 1 == m_bAutoHyphenation ) sResult += _T("<w:suppressAutoHyphens w:val=\"false\"/>");
RENDER_OOX_BOOL( m_bKeep, sResult, _T("w:keepLines") );
RENDER_OOX_BOOL( m_bKeepNext, sResult, _T("w:keepNext") );
RENDER_OOX_INT( m_nOutlinelevel, sResult, _T("w:outlineLvl") );
RENDER_OOX_BOOL( m_bPageBB, sResult, _T("w:pageBreakBefore") );
RENDER_OOX_BOOL ( m_bKeep , sResult, _T("w:keepLines") );
RENDER_OOX_BOOL ( m_bKeepNext , sResult, _T("w:keepNext") );
RENDER_OOX_INT ( m_nOutlinelevel , sResult, _T("w:outlineLvl") );
RENDER_OOX_BOOL ( m_bPageBB , sResult, _T("w:pageBreakBefore") );
switch(m_eAlign)
......@@ -1947,12 +1939,12 @@ CString RtfParagraphProperty::RenderToOOX(RenderParameter oRenderParameter)
if( PROP_DEF == m_nSpaceAfter ) m_nSpaceAfter = 0;
//if( PROP_DEF == m_nSpaceBefore ) m_nSpaceBefore = 0;
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceBefore, sSpacing, _T("w:before") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceAfter, sSpacing, _T("w:after") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceBeforeAuto, sSpacing, _T("w:beforeAutospacing") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceAfterAuto, sSpacing, _T("w:afterAutospacing") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceBeforeLine, sSpacing, _T("w:beforeLines") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceAfterLine, sSpacing, _T("w:afterLines") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceBefore, sSpacing, _T("w:before") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceAfter, sSpacing, _T("w:after") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceBeforeAuto, sSpacing, _T("w:beforeAutospacing") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceAfterAuto, sSpacing, _T("w:afterAutospacing") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceBeforeLine, sSpacing, _T("w:beforeLines") );
RENDER_OOX_INT_ATTRIBUTE( m_nSpaceAfterLine, sSpacing, _T("w:afterLines") );
if( PROP_DEF != m_nSpaceBetween && 0 != m_nSpaceBetween )
{
......@@ -2024,7 +2016,7 @@ CString RtfParagraphProperty::RenderToOOX(RenderParameter oRenderParameter)
}
if( true == m_oBorderRight.IsValid() )
{
sBorder += _T("<w:right "); sBorder += m_oBorderRight.RenderToOOX(oNewParam); sBorder += _T(" />");
sBorder += _T("<w:right "); sBorder += m_oBorderRight.RenderToOOX(oNewParam); sBorder += _T(" />");
}
}
......
......@@ -508,108 +508,114 @@ public:
SetDefault();
//footer - header
m_oHeaderLeft = TextItemContainerPtr();
m_oHeaderFirst = TextItemContainerPtr();
m_oHeaderRight = TextItemContainerPtr();
m_oFooterLeft = TextItemContainerPtr();
m_oFooterFirst = TextItemContainerPtr();
m_oFooterRight = TextItemContainerPtr();
m_oHeaderLeft = TextItemContainerPtr();
m_oHeaderFirst = TextItemContainerPtr();
m_oHeaderRight = TextItemContainerPtr();
m_oFooterLeft = TextItemContainerPtr();
m_oFooterFirst = TextItemContainerPtr();
m_oFooterRight = TextItemContainerPtr();
}
int GetType()
{
return TYPE_RTF_PROPERTY_SECTION;
}
void SetDefaultRtf()
{
SetDefault();
m_nColumnSpace = 720;
DEFAULT_PROPERTY_DEF( m_eSectionBreak, sb_sbkpage )
DEFAULT_PROPERTY_DEF( m_nColumnSpace, 720);
}
void SetDefaultOOX()
{
SetDefault();
m_nPageWidth = 11906;
m_nPageHeight = 16838;
m_nMarginLeft = 210;
m_nMarginRight = 215;
m_nMarginTop = 204;
m_nMarginBottom = 204;
m_nPageWidth = 11906;
m_nPageHeight = 16838;
m_nHeaderTop = 709;
m_nFooterBottom = 709;
m_nGutterMarginWidth = 0;
m_nMarginLeft = 210;
m_nMarginRight = 215;
m_nMarginTop = 204;
m_nMarginBottom = 204;
m_nColumnSpace = 708;
m_nHeaderTop = 709;
m_nFooterBottom = 709;
m_nGutterMarginWidth = 0;
m_nColumnSpace = 708;
}
void SetDefault()
{
DEFAULT_PROPERTY( m_bBidi )
DEFAULT_PROPERTY( m_nPaperSourceFirst )
DEFAULT_PROPERTY( m_nPaperSourceOther )
DEFAULT_PROPERTY( m_bRtlGutter )
DEFAULT_PROPERTY( m_bEndnotes )
DEFAULT_PROPERTY( m_nStyle )
DEFAULT_PROPERTY ( m_bBidi )
DEFAULT_PROPERTY ( m_nPaperSourceFirst )
DEFAULT_PROPERTY ( m_nPaperSourceOther )
DEFAULT_PROPERTY ( m_bRtlGutter )
DEFAULT_PROPERTY ( m_bEndnotes )
DEFAULT_PROPERTY ( m_nStyle )
DEFAULT_PROPERTY_DEF( m_eSectionBreak, sb_none )
//Columns
m_nColumnNumber = 1;
DEFAULT_PROPERTY( m_nColumnSpace )
DEFAULT_PROPERTY( m_bColumnLineBetween )
DEFAULT_PROPERTY ( m_nColumnSpace )
DEFAULT_PROPERTY ( m_bColumnLineBetween )
m_oCollumnProperty.m_aCollumnProperty.resize( m_nColumnNumber );
//Footnotes and Endnotes
DEFAULT_PROPERTY_DEF( m_eFootnotesJust, fj_none )
DEFAULT_PROPERTY( m_nFootnotesStart )
DEFAULT_PROPERTY_DEF( m_eFootnotesRestart, fr_none )
DEFAULT_PROPERTY_DEF( m_eFootnotesFormat, ff_none )
DEFAULT_PROPERTY( m_nEndnotesStart )
DEFAULT_PROPERTY_DEF( m_eEndnotesRestart, er_none )
DEFAULT_PROPERTY_DEF( m_eEndnotesFormat, ef_none )
DEFAULT_PROPERTY_DEF( m_eFootnotesJust, fj_none )
DEFAULT_PROPERTY ( m_nFootnotesStart )
DEFAULT_PROPERTY_DEF( m_eFootnotesRestart, fr_none )
DEFAULT_PROPERTY_DEF( m_eFootnotesFormat, ff_none )
DEFAULT_PROPERTY ( m_nEndnotesStart )
DEFAULT_PROPERTY_DEF( m_eEndnotesRestart, er_none )
DEFAULT_PROPERTY_DEF( m_eEndnotesFormat, ef_none )
//Line Numbering
DEFAULT_PROPERTY( m_nLineModulus )
DEFAULT_PROPERTY( m_nLineX )
DEFAULT_PROPERTY( m_nLineStart )
DEFAULT_PROPERTY ( m_nLineModulus )
DEFAULT_PROPERTY ( m_nLineX )
DEFAULT_PROPERTY ( m_nLineStart )
DEFAULT_PROPERTY_DEF( m_eLineNumberRestart, lnr_none )
//Page Information
DEFAULT_PROPERTY( m_nPageWidth )
DEFAULT_PROPERTY( m_nPageHeight )
DEFAULT_PROPERTY( m_nMarginLeft )
DEFAULT_PROPERTY( m_nMarginRight )
DEFAULT_PROPERTY( m_nMarginTop )
DEFAULT_PROPERTY( m_nMarginBottom )
DEFAULT_PROPERTY( m_nGutterMarginWidth )
DEFAULT_PROPERTY( m_bSwitchMargin )
DEFAULT_PROPERTY( m_bLandscapeFormat )
DEFAULT_PROPERTY( m_bTitlePage )
DEFAULT_PROPERTY ( m_nPageWidth )
DEFAULT_PROPERTY ( m_nPageHeight )
DEFAULT_PROPERTY ( m_nMarginLeft )
DEFAULT_PROPERTY ( m_nMarginRight )
DEFAULT_PROPERTY ( m_nMarginTop )
DEFAULT_PROPERTY ( m_nMarginBottom )
DEFAULT_PROPERTY ( m_nGutterMarginWidth )
DEFAULT_PROPERTY ( m_bSwitchMargin )
DEFAULT_PROPERTY ( m_bLandscapeFormat )
DEFAULT_PROPERTY ( m_bTitlePage )
DEFAULT_PROPERTY_DEF( m_nHeaderTop, 720 )
DEFAULT_PROPERTY_DEF( m_nFooterBottom, 720 )
//Page Numbers
DEFAULT_PROPERTY( m_nPageNumberStart )
DEFAULT_PROPERTY( m_bPageNumberContinuos )
DEFAULT_PROPERTY( m_bPageNumberRestart )
DEFAULT_PROPERTY( m_nPageNumberX )
DEFAULT_PROPERTY( m_nPageNumberY )
DEFAULT_PROPERTY ( m_nPageNumberStart )
DEFAULT_PROPERTY ( m_bPageNumberContinuos )
DEFAULT_PROPERTY ( m_bPageNumberRestart )
DEFAULT_PROPERTY ( m_nPageNumberX )
DEFAULT_PROPERTY ( m_nPageNumberY )
DEFAULT_PROPERTY_DEF( m_ePageNumberFormat, pnf_none )
//Vertical Alignment
DEFAULT_PROPERTY_DEF( m_eVerticalAlignment, va_none )
//Text Flow
DEFAULT_PROPERTY( m_nTextFollow )
DEFAULT_PROPERTY ( m_nTextFollow )
//Page Borders
m_oBorderLeft.SetDefault();
m_oBorderTop.SetDefault();
m_oBorderRight.SetDefault();
m_oBorderBottom.SetDefault();
DEFAULT_PROPERTY( m_nBorderArt )
DEFAULT_PROPERTY( m_nBorderMeasure )
DEFAULT_PROPERTY( m_nBorderAlign )
DEFAULT_PROPERTY ( m_nBorderArt )
DEFAULT_PROPERTY ( m_nBorderMeasure )
DEFAULT_PROPERTY ( m_nBorderAlign )
//footer - header надо обнулять вручную
//m_oHeaderLeft = TextItemContainerPtr();
......@@ -660,6 +666,7 @@ public:
CString RenderToOOX(RenderParameter oRenderParameter)
{
if (!m_bFinalize) return L"";
m_bFinalize = false; // тут .. чтобы не повторилось при конвертации колонтитулов
RenderParameter oNewParam = oRenderParameter;
......
......@@ -225,40 +225,42 @@ bool OOXDocumentWriter::SaveByItem()
if( m_oDocument.GetCount() > 1)//если что-то есть в следующей секции значит предыдущая закончилась
{
if( m_oDocument[1].props->GetCount() > 0 )
std::wstring sXml, sectPr;
_section section;
if (m_oDocument.GetItem(section, 0))
{
CString sSectPr = m_oDocument[0].props->m_oProperty.RenderToOOX(oNewParam);
CString sXml = m_oDocument[1].props->operator[](0)->RenderToOOX(oNewParam);
int nIndexP = sXml.Find( _T("<w:p>") );
sectPr = section.props->RenderToOOX(oNewParam).GetBuffer();
}
if (nIndexP == 0) //элемент параграф
if( m_oDocument[0].props->GetCount() > 0 )
{
sXml = m_oDocument[0].props->operator[](0)->RenderToOOX(oNewParam).GetBuffer();
int nFind = sXml.rfind(L"</w:pPr>");
if( -1 != nFind )
{
int nIndexpPr = sXml.Find( _T("</w:pPr>") );
if( -1 != nIndexpPr )
{
sXml.Insert( nIndexpPr, sSectPr );
}
else
{
sSectPr = _T("<w:pPr>") + sSectPr + _T("</w:pPr>");
sXml.Insert( 5, sSectPr );
}
sXml.insert( nFind, sectPr );
}
else
{
sXml = _T("<w:p><w:pPr>") + sSectPr + _T("</w:pPr></w:p>") + sXml;
int Find = sXml.rfind( L"<w:p>" );
if( -1 != nFind )
sXml.insert( nFind + 5, L"<w:pPr>" + sectPr + L"</w:pPr>" );
}
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml.GetBuffer());
m_oFileWriter->Write((BYTE*)sXmlUTF.c_str(), sXmlUTF.length());
m_oDocument[1].props->RemoveItem( 0 ); //удаляем первый параграф
m_oDocument.RemoveItem( 0 ); //удаляем секцию
}
}
else
{
//генерация ???
sXml = _T("<w:p><w:pPr>") + sectPr + _T("</w:pPr></w:p>");
}
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml);
m_oFileWriter->Write((BYTE*)sXmlUTF.c_str(), sXmlUTF.length());
m_oDocument.RemoveItem( 0 ); //удаляем секцию
}
else if( m_oDocument.GetCount() > 0 && m_oDocument[0].props->GetCount() > 0 )//пишем параграф
else if( m_oDocument.GetCount() > 0 && m_oDocument[0].props->GetCount() > 1 )//пишем параграф - один всегда "прозапас для секций"
{
CString sXml = m_oDocument[0].props->operator[](0)->RenderToOOX(oNewParam);
std::string sXmlUTF = NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sXml.GetBuffer());
......
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