Commit 9671e7ae authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

RtfFile

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62090 954022d7-b5bf-4e40-9824-e11837661b57
parent 643cf683
......@@ -554,62 +554,6 @@
<Filter
Name="OOXWriter"
>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\DefaultThemeWriterWin.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\fontTableWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXContentTypesWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXDocPropAppWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXDocPropCoreWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXDocumentWriter.cpp"
>
</File>
<File
RelativePath="..\source\Writer\OOXDocumentWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXFontTableWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXFootnoteWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXNumberingWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXRelsWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXSettingsWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXStylesWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXThemeWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXWriter.cpp"
>
......@@ -618,18 +562,70 @@
RelativePath="..\source\Writer\OOXWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\SettingWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\StylesWriter.h"
<Filter
Name="___"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\webSettingsWriter.h"
<File
RelativePath="..\source\Writer\OOXContentTypesWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXDocumentWriter.cpp"
>
</File>
<File
RelativePath="..\source\Writer\OOXDocumentWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXFontTableWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXFootnoteWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXNumberingWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXRelsWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXSettingsWriter.h"
>
</File>
<File
RelativePath="..\source\Writer\OOXStylesWriter.h"
>
</File>
</Filter>
<Filter
Name="DocxFile2"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\DefaultThemeWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\fontTableWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\SettingWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\StylesWriter.h"
>
</File>
<File
RelativePath="..\..\..\ASCOfficeDocxFile2\BinReader\webSettingsWriter.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter
......
......@@ -32,31 +32,30 @@ public:
RtfReader oReader( oDocument, sSrcFileName );
OOXWriter oWriter( oDocument, sDstPath );
oReader.m_sTempFolder = sDstPath;
oWriter.m_sTempFolder = sDstPath;
oReader.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
oWriter.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
m_poRtfReader = &oReader;
m_poOOXWriter = &oWriter;
m_poRtfReader->m_convertationManager = this;
bool succes = oReader.Load( );
//ATLASSERT( true == succes );
#ifdef MEMORY_SAFE_CONVERTATION
// OnCompleteItemRtfReader
// OnCompleteItemRtf
//
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
oWriter.SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
oWriter.SaveByItemEnd( );
#else
if( true == succes)
{
succes = oWriter.Save( );
//ATLASSERT( true == succes );
}
#endif
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
oWriter.SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
oWriter.SaveByItemEnd( );
FileSystem::Directory::DeleteDirectory(oReader.m_sTempFolder);
FileSystem::Directory::DeleteDirectory(oWriter.m_sTempFolder);
if( true == succes )
return S_OK;
else
......@@ -72,38 +71,44 @@ public:
OOXReader oReader( oDocument, sSrcPath );
RtfWriter oWriter( oDocument, sDstFileName, sSrcPath );
oReader.m_sTempFolder = m_sTempFolder;
oWriter.m_sTempFolder = m_sTempFolder;
oReader.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
oWriter.m_sTempFolder = FileSystem::Directory::CreateDirectoryWithUniqueName(m_sTempFolder);
m_poOOXReader = &oReader;
m_poRtfWriter = &oWriter;
m_poOOXReader->m_convertationManager = this;
bool succes = oReader.Parse( );
//ATLASSERT( true == succes );
#ifdef MEMORY_SAFE_CONVERTATION
// OnCompleteItemRtfReader
//
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
oWriter.SaveByItemStart( );
}
oWriter.SaveByItemEnd( );
#else
if( true == succes && true)
{
succes = oWriter.Save( );
//ATLASSERT( true == succes );
//succes = oWriter.Save( oDocument, CString("d:\\testOOX") );
////ATLASSERT( true == succes );
}
#endif
return S_OK;
}
if( true == succes)
{
succes = oWriter.Save( );
}
FileSystem::Directory::DeleteDirectory(oReader.m_sTempFolder);
FileSystem::Directory::DeleteDirectory(oWriter.m_sTempFolder);
if( true == succes) return S_OK;
return S_FALSE;
}
void OnCompleteItemRtf()
{
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
m_poOOXWriter->SaveByItemStart( );
}
m_poOOXWriter->SaveByItem();
}
void OnCompleteItemOOX()
{
if( true == m_bParseFirstItem )
{
m_bParseFirstItem = false;
m_poRtfWriter->SaveByItemStart( );
}
m_poRtfWriter->SaveByItem( );
}
private:
OOXWriter* m_poOOXWriter;
OOXReader* m_poOOXReader;
......@@ -113,4 +118,5 @@ private:
bool m_bParseFirstItem;
};
\ No newline at end of file
......@@ -2,6 +2,8 @@
#include "DestinationCommand.h"
#include "RtfOle.h"
#include "ConvertationManager.h"
bool ShapeReader::ExecuteCommand(RtfDocument& oDocument, RtfReader& oReader,CString sCommand, bool hasParameter, int parameter)
{
if( _T("shp") == sCommand )
......@@ -1175,3 +1177,134 @@ bool ParagraphPropDestination::ExecuteCommand(RtfDocument& oDocument, RtfReader&
}
return true;
}
void ParagraphPropDestination::AddItem( RtfParagraphPtr oItem, RtfReader& oReader, bool bEndCell, bool bEndRow )
{
// 1 != oItem->m_oProperty.m_bInTable -
// PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap - , - nTargetItap - ( )
if( 1 != oItem->m_oProperty.m_bInTable || ( PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap ) )
{
if( nCurItap > 0 ) // -
{
RtfTablePtr oNewTable( new RtfTable() );
oNewTable->m_oProperty = oCurRowProperty;
for( int k = (int)aRows.size() - 1; k >= 0 ; k-- )
{
if( aRowItaps[k] == nCurItap )
{
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
else
break;
}
// OOX
oNewTable->CalculateGridProp();
//
aCellRenderables.clear();
aItaps.clear();
aCells.clear();
aCellItaps.clear();
aRows.clear();
aRowItaps.clear();
//
m_oTextItems->AddItem( oNewTable );
if (oReader.m_convertationManager)
{
oReader.m_convertationManager->OnCompleteItemRtf();
}
}
//
m_oTextItems->AddItem( oItem );
if (oReader.m_convertationManager)
{
oReader.m_convertationManager->OnCompleteItemRtf();
}
// nCurItap
nCurItap = oItem->m_oProperty.m_nItap;
}
else
{
// -
if( nCurItap > oItem->m_oProperty.m_nItap )
{
RtfTablePtr oNewTable( new RtfTable() );
oNewTable->m_oProperty = oCurRowProperty;
for( int k = (int)aRows.size() - 1; k >= 0 ; k-- )
{
if( aRowItaps[k] == nCurItap )
{
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
else
break;
}
// OOX
oNewTable->CalculateGridProp();
//
aCellRenderables.push_back( oNewTable );
aItaps.push_back( oItem->m_oProperty.m_nItap );
}
nCurItap = oItem->m_oProperty.m_nItap;
//
if( true == bEndRow )
{
RtfTableRowPtr oNewTableRow( new RtfTableRow() );
oNewTableRow->m_oProperty = oReader.m_oState->m_oRowProperty;
for( int k = (int)aCells.size() - 1; k >= 0 ; k-- )
{
if( aCellItaps[k] == nCurItap )
{
oNewTableRow->InsertItem( aCells[k], 0 );
aCells.erase(aCells.begin() + k);
aCellItaps.erase(aCellItaps.begin() + k);
}
else
break;
}
// cell row
for( int i = 0; i < (int)oNewTableRow->GetCount() && i < oNewTableRow->m_oProperty.GetCount() ; i++ )
oNewTableRow->operator [](i)->m_oProperty = oNewTableRow->m_oProperty[i];
// row
aRows.push_back( oNewTableRow );
aRowItaps.push_back( nCurItap );
}
else
{
// cell
aCellRenderables.push_back( oItem ); // , cell
aItaps.push_back( nCurItap ); //
if( true == bEndCell )
{
RtfTableCellPtr oNewTableCell( new RtfTableCell() );
for( int k = (int)aCellRenderables.size() - 1; k >= 0 ; k-- )
{
if( aItaps[k] == nCurItap )
{
oNewTableCell->InsertItem(aCellRenderables[k], 0 );
aCellRenderables.erase(aCellRenderables.begin() + k);
aItaps.erase(aItaps.begin() + k);
}
else
break;
}
aCells.push_back( oNewTableCell );
aCellItaps.push_back( nCurItap );
}
}
oCurRowProperty = oReader.m_oState->m_oRowProperty;
}
}
......@@ -1959,127 +1959,7 @@ public:
oNewChar->setText( sText );
m_oCurParagraph->AddItem( oNewChar );
}
void AddItem( RtfParagraphPtr oItem, RtfReader& oReader, bool bEndCell, bool bEndRow )
{
// 1 != oItem->m_oProperty.m_bInTable -
// PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap - , - nTargetItap - ( )
if( 1 != oItem->m_oProperty.m_bInTable || ( PROP_DEF != nTargetItap && oItem->m_oProperty.m_nItap <= nTargetItap ) )
{
if( nCurItap > 0 ) // -
{
RtfTablePtr oNewTable( new RtfTable() );
oNewTable->m_oProperty = oCurRowProperty;
for( int k = (int)aRows.size() - 1; k >= 0 ; k-- )
{
if( aRowItaps[k] == nCurItap )
{
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
else
break;
}
// OOX
oNewTable->CalculateGridProp();
//
aCellRenderables.clear();
aItaps.clear();
aCells.clear();
aCellItaps.clear();
aRows.clear();
aRowItaps.clear();
//
m_oTextItems->AddItem( oNewTable );
}
//
m_oTextItems->AddItem( oItem );
// nCurItap
nCurItap = oItem->m_oProperty.m_nItap;
}
else
{
// -
if( nCurItap > oItem->m_oProperty.m_nItap )
{
RtfTablePtr oNewTable( new RtfTable() );
oNewTable->m_oProperty = oCurRowProperty;
for( int k = (int)aRows.size() - 1; k >= 0 ; k-- )
{
if( aRowItaps[k] == nCurItap )
{
oNewTable->InsertItem( aRows[k], 0 );
aRows.erase(aRows.begin() + k);
aRowItaps.erase(aRowItaps.begin() + k);
}
else
break;
}
// OOX
oNewTable->CalculateGridProp();
//
aCellRenderables.push_back( oNewTable );
aItaps.push_back( oItem->m_oProperty.m_nItap );
}
nCurItap = oItem->m_oProperty.m_nItap;
//
if( true == bEndRow )
{
RtfTableRowPtr oNewTableRow( new RtfTableRow() );
oNewTableRow->m_oProperty = oReader.m_oState->m_oRowProperty;
for( int k = (int)aCells.size() - 1; k >= 0 ; k-- )
{
if( aCellItaps[k] == nCurItap )
{
oNewTableRow->InsertItem( aCells[k], 0 );
aCells.erase(aCells.begin() + k);
aCellItaps.erase(aCellItaps.begin() + k);
}
else
break;
}
// cell row
for( int i = 0; i < (int)oNewTableRow->GetCount() && i < oNewTableRow->m_oProperty.GetCount() ; i++ )
oNewTableRow->operator [](i)->m_oProperty = oNewTableRow->m_oProperty[i];
// row
aRows.push_back( oNewTableRow );
aRowItaps.push_back( nCurItap );
}
else
{
// cell
aCellRenderables.push_back( oItem ); // , cell
aItaps.push_back( nCurItap ); //
if( true == bEndCell )
{
RtfTableCellPtr oNewTableCell( new RtfTableCell() );
for( int k = (int)aCellRenderables.size() - 1; k >= 0 ; k-- )
{
if( aItaps[k] == nCurItap )
{
oNewTableCell->InsertItem(aCellRenderables[k], 0 );
aCellRenderables.erase(aCellRenderables.begin() + k);
aItaps.erase(aItaps.begin() + k);
}
else
break;
}
aCells.push_back( oNewTableCell );
aCellItaps.push_back( nCurItap );
}
}
oCurRowProperty = oReader.m_oState->m_oRowProperty;
}
}
void AddItem( RtfParagraphPtr oItem, RtfReader& oReader, bool bEndCell, bool bEndRow );
void Finalize( RtfReader& oReader ) // reader -
{
if( false == m_bPar )
......
......@@ -32,7 +32,7 @@ public:
int nDistRight = m_ooxAnchor->m_oDistR.IsInit() ? m_ooxAnchor->m_oDistR->ToTwips() : PROP_DEF;
int nDistBottom = m_ooxAnchor->m_oDistB.IsInit() ? m_ooxAnchor->m_oDistB->ToTwips() : PROP_DEF;
BOOL bSimplePos = m_ooxAnchor->m_oSimplePos.IsInit() ? true : false;
bool bSimplePos = m_ooxAnchor->m_oSimplePos.IsInit() ? true : false;
int nWidth = PROP_DEF;
int nHeight = PROP_DEF;
......
......@@ -13,6 +13,8 @@ OOXReader::OOXReader( RtfDocument& oDocument,CString path ): m_oDocument(oDocume
{
m_sPath = path;
m_nCurItap = 0;
m_convertationManager = NULL;
}
bool OOXReader::Parse()
{
......
......@@ -3,23 +3,20 @@
#include "../RtfField.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
//#include "OOXRelsReader.h"
class ConvertationManager;
class OOXReader
{
public:
ConvertationManager * m_convertationManager;
CString m_sPath;
//CString m_sDocumentPath;
int m_nCurItap; //
int m_nCurFittextId;
std::map<int, CString> m_aBookmarks;
//OOXRelsReader m_oRelsReader;
//OOXRelsReaderPtr m_oDocRelsReader;
//OOXRelsReader m_oNumRelsReader;
std::map<int, int> m_mapPictureBullet;
std::map<int, TextItemContainerPtr> m_mapFootnotes;
std::map<int, TextItemContainerPtr> m_mapEndnotes;
......
......@@ -6,9 +6,6 @@
#include "Writer/OOXFontTableWriter.h"
#include "Writer/OOXStylesWriter.h"
#include "Writer/OOXSettingsWriter.h"
#include "Writer/OOXThemeWriter.h"
#include "Writer/OOXDocPropAppWriter.h"
#include "Writer/OOXDocPropCoreWriter.h"
#include "Writer/OOXFootnoteWriter.h"
RtfDocument::RtfDocument()
......
......@@ -35,9 +35,9 @@ CString RtfOle::RenderToOOXOnlyOle(RenderParameter oRenderParameter)
{
CString sResult;
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>(oRenderParameter.poRels);
RtfDocument* poDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>(oRenderParameter.poRels);
RtfDocument* poDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
sResult.Append( _T("<o:OLEObject") );
switch ( m_eOleType )
......@@ -52,11 +52,14 @@ CString RtfOle::RenderToOOXOnlyOle(RenderParameter oRenderParameter)
CString sExtension = _T("bin");
CString sMime = _T("application/vnd.openxmlformats-officedocument.oleObject");
CString sFilenameFull;
CString sFilenameRels;
sFilenameRels.AppendFormat( _T("embeddings/oleObject%d.%ls"), poDocument->m_oIdGenerator.Generate_OleIndex(), sExtension);
sFilenameFull = poOOXWriter->m_sTargetFolder + _T("/") + poOOXWriter->m_sDocumentFolder + _T("/") +sFilenameRels;
CreateDirectory( poOOXWriter->m_sTargetFolder + _T("/") + poOOXWriter->m_sDocumentFolder + _T("/embeddings"), NULL);
sFilenameRels.AppendFormat( _T("oleObject%d.%ls"), poDocument->m_oIdGenerator.Generate_OleIndex(), sExtension);
CString sFilenameFull = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("embeddings");
FileSystem::Directory::CreateDirectory( sFilenameFull );
sFilenameFull += FILE_SEPARATOR_STR + sFilenameRels;
Utils::CopyDirOrFile( m_sOleFilename, sFilenameFull );
......
......@@ -92,12 +92,11 @@ CString RtfPicture::RenderToOOX(RenderParameter oRenderParameter)
if( false == IsValid() )
return _T("");
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>(oRenderParameter.poRels);
RtfDocument* poRtfDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
CString sFilenameFull;
CString sFilenameRels;
CString sExtension;
OOXWriter* poOOXWriter = static_cast<OOXWriter*>(oRenderParameter.poWriter);
OOXRelsWriter* poRelsWriter = static_cast<OOXRelsWriter*>(oRenderParameter.poRels);
RtfDocument* poRtfDocument = static_cast<RtfDocument*>(oRenderParameter.poDocument);
CString sExtension;
CString sMime;
switch( eDataType )
{
......@@ -106,9 +105,13 @@ CString RtfPicture::RenderToOOX(RenderParameter oRenderParameter)
case dt_wmf: sExtension = _T("wmf"); sMime = _T("image/x-wmf");break;
case dt_emf: sExtension = _T("emf"); sMime = _T("image/x-emf");break;
}
sFilenameRels.AppendFormat( _T("media/Image%d.%ls"), poRtfDocument->m_oIdGenerator.Generate_ImageIndex(), sExtension);
sFilenameFull = poOOXWriter->m_sTargetFolder + _T("/") + poOOXWriter->m_sDocumentFolder + _T("/") +sFilenameRels;
CreateDirectory( poOOXWriter->m_sTargetFolder + _T("/") + poOOXWriter->m_sDocumentFolder + _T("/media"), NULL);
CString sFilenameRels;
sFilenameRels.AppendFormat( _T("Image%d.%ls"), poRtfDocument->m_oIdGenerator.Generate_ImageIndex(), sExtension);
CString sFilenameFull = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR +_T("media");
FileSystem::Directory::CreateDirectory( sFilenameFull );
sFilenameFull += FILE_SEPARATOR_STR + sFilenameRels;
if( m_sPicFilename != sFilenameFull )
Utils::CopyDirOrFile( m_sPicFilename, sFilenameFull );
......
......@@ -3,6 +3,10 @@
#include "Writer/OOXWriter.h"
#include "RtfProperty.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/FileTypes.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/App.h"
#include "../../../Common/DocxFormat/Source/DocxFormat/Core.h"
CString RtfFont::RenderToRtf(RenderParameter oRenderParameter)
{
//ATLASSERT( IsValid() );
......@@ -2526,26 +2530,22 @@ CString RtfInformation::RenderToRtf(RenderParameter oRenderParameter)
}
CString RtfInformation::RenderToOOX(RenderParameter oRenderParameter)
{
CString sResult;
if( RENDER_TO_OOX_PARAM_CORE == oRenderParameter.nType )
{
if( _T("") != m_sTitle )
sResult.AppendFormat( _T("<dc:title>%ls</dc:title>"), Utils::PrepareToXML( m_sTitle ) );
if( _T("") != m_sSubject )
sResult.AppendFormat( _T("<dc:subject>%ls</dc:subject>"), Utils::PrepareToXML( m_sSubject ) );
if( _T("") != m_sAuthor )
sResult.AppendFormat( _T("<dc:creator>%ls</dc:creator>"), Utils::PrepareToXML( m_sAuthor ) );
if( _T("") != m_sKeywords )
sResult.AppendFormat( _T("<cp:keywords>%ls</cp:keywords>"), Utils::PrepareToXML( m_sKeywords ) );
if( _T("") != m_sComment )
sResult.AppendFormat( _T("<dc:description>%ls</dc:description>"), Utils::PrepareToXML( m_sComment ) );
//CString sCreateTime = m_oCreateTime.RenderToOOX( oRenderParameter );
//if( false == sCreateTime.IsEmpty() )
// sResult.AppendFormat( _T("<dcterms:created xsi:type=\"dcterms:W3CDTF\">%ls</dcterms:created>"), sCreateTime );
//CString sRevTime = m_oRevTime.RenderToOOX( oRenderParameter );
//if( false == sRevTime.IsEmpty() )
// sResult.AppendFormat( _T("<dcterms:modified xsi:type=\"dcterms:W3CDTF\">%ls</dcterms:modified>"), sCreateTime );
OOX::CCore *pCore = static_cast<OOX::CCore*>( oRenderParameter.poWriter );
if( m_sTitle.GetLength() > 0 ) pCore->m_sTitle = m_sTitle;
if( m_sSubject.GetLength() > 0 ) pCore->m_sSubject = m_sSubject;
if( m_sAuthor.GetLength() > 0 ) pCore->m_sCreator = m_sAuthor;
if( m_sKeywords.GetLength() > 0 ) pCore->m_sKeywords = m_sKeywords;
if( m_sComment.GetLength() > 0 ) pCore->m_sDescription = m_sComment;
CString sCreateTime = m_oCreateTime.RenderToOOX( oRenderParameter );
if( false == sCreateTime.IsEmpty() ) pCore->m_sCreated = sCreateTime;
CString sRevTime = m_oRevTime.RenderToOOX( oRenderParameter );
if( false == sRevTime.IsEmpty() ) pCore->m_sModified = sRevTime;
//CString sPrintTime = m_oPrintTime.RenderToOOX( oRenderParameter );
//if( _T("") != sPrintTime )
// sResult.AppendFormat( _T("<dcterms:created xsi:type=\"dcterms:W3CDTF\">%ls</dcterms:created>"), sCreateTime );
......@@ -2555,20 +2555,17 @@ CString RtfInformation::RenderToOOX(RenderParameter oRenderParameter)
}
else if( RENDER_TO_OOX_PARAM_APP == oRenderParameter.nType )
{
if( PROP_DEF != m_nEndingTime )
sResult.AppendFormat(_T("<TotalTime>%d</TotalTime>"), m_nEndingTime );
if( PROP_DEF != m_nNumberOfPages )
sResult.AppendFormat( _T("<Pages>%d</Pages>"),m_nNumberOfPages );
if( PROP_DEF != m_nNumberOfWords )
sResult.AppendFormat( _T("<Words>%d</Words>"),m_nNumberOfWords );
if( PROP_DEF != m_nNumberOfCharactersWithSpace )
sResult.AppendFormat( _T("<Characters>%d</Characters>"),m_nNumberOfCharactersWithSpace );
if( PROP_DEF != m_nNumberOfCharactersWithoutSpace )
sResult.AppendFormat( _T("<CharactersWithSpaces>%d</CharactersWithSpaces>"),m_nNumberOfCharactersWithoutSpace );
//if( PROP_DEF != m_nVersion )
// sResult.AppendFormat( _T("<AppVersion>%f</AppVersion>"),m_nVersion );
OOX::CApp *pApp = static_cast<OOX::CApp*>( oRenderParameter.poWriter );
if( PROP_DEF != m_nEndingTime) pApp->m_nTotalTime = m_nEndingTime;
if( PROP_DEF != m_nNumberOfPages ) pApp->m_nPages = m_nNumberOfPages;
if( PROP_DEF != m_nNumberOfWords ) pApp->m_nWords = m_nNumberOfWords;
if( PROP_DEF != m_nNumberOfCharactersWithSpace ) pApp->m_nCharactersWithSpaces = m_nNumberOfCharactersWithSpace;
//if( PROP_DEF != m_nNumberOfCharactersWithoutSpace )
// sResult.AppendFormat( _T("<CharactersWithSpaces>%d</CharactersWithSpaces>"),m_nNumberOfCharactersWithoutSpace );
}
return sResult;
return _T("");
}
CString RtfTime::RenderToRtf(RenderParameter oRenderParameter)
{
......
......@@ -3,38 +3,39 @@
#include "DestinationCommand.h"
RtfReader::RtfReader(RtfDocument& oDocument, CString sFilename ):m_oDocument(oDocument),m_sFilename(sFilename)
{
m_oState = ReaderStatePtr(new ReaderState());
m_nFootnote = PROP_DEF;
m_nDefFont = PROP_DEF;
}
{
m_oState = ReaderStatePtr(new ReaderState());
m_nFootnote = PROP_DEF;
m_nDefFont = PROP_DEF;
m_convertationManager = NULL;
}
bool RtfReader::Load()
{
m_oLex.SetSource( m_sFilename );
RtfNormalReader oNormalReader( m_oDocument, (*this) );
oNormalReader.Parse( m_oDocument, (*this) );
m_oLex.CloseSource();
return true;
}
{
m_oLex.SetSource( m_sFilename );
RtfNormalReader oNormalReader( m_oDocument, (*this) );
oNormalReader.Parse( m_oDocument, (*this) );
m_oLex.CloseSource();
return true;
}
void RtfReader::PushState()
{
ReaderStatePtr psaveNew = ReaderStatePtr(new ReaderState());
psaveNew -> m_nUD = m_oState->m_nUD;
psaveNew -> m_oCharProp = m_oState->m_oCharProp;
psaveNew -> m_oParagraphProp = m_oState->m_oParagraphProp;
psaveNew -> m_oRowProperty = m_oState->m_oRowProperty;
psaveNew -> m_oCellProperty = m_oState->m_oCellProperty;
psaveNew -> m_oCurOldList = m_oState->m_oCurOldList;
//psaveNew -> m_oSectionProp = m_oState->m_oSectionProp;
psaveNew -> psave = m_oState;
m_oState = psaveNew;
{
ReaderStatePtr psaveNew = ReaderStatePtr(new ReaderState());
psaveNew -> m_nUD = m_oState->m_nUD;
psaveNew -> m_oCharProp = m_oState->m_oCharProp;
psaveNew -> m_oParagraphProp = m_oState->m_oParagraphProp;
psaveNew -> m_oRowProperty = m_oState->m_oRowProperty;
psaveNew -> m_oCellProperty = m_oState->m_oCellProperty;
psaveNew -> m_oCurOldList = m_oState->m_oCurOldList;
//psaveNew -> m_oSectionProp = m_oState->m_oSectionProp;
psaveNew -> psave = m_oState;
m_oState = psaveNew;
if( PROP_DEF == m_oState->m_oCharProp.m_nFont )
m_oState->m_oCharProp.m_nFont = m_nDefFont;
}
if( PROP_DEF == m_oState->m_oCharProp.m_nFont )
m_oState->m_oCharProp.m_nFont = m_nDefFont;
}
void RtfReader::PopState()
{
if( 0 != m_oState->psave )
m_oState = m_oState->psave;
//delete psaveOld;
}
\ No newline at end of file
{
if( 0 != m_oState->psave )
m_oState = m_oState->psave;
//delete psaveOld;
}
\ No newline at end of file
......@@ -3,12 +3,16 @@
#include "RtfProperty.h"
#include "RtfDocument.h"
class ConvertationManager;
class RtfReader
{
public:
class ReaderState;
typedef boost::shared_ptr<ReaderState> ReaderStatePtr;
ConvertationManager *m_convertationManager;
class ReaderState
{
public:
......@@ -21,6 +25,7 @@ public:
// RtfSectionProperty m_oSectionProp;
ReaderStatePtr psave;
CStringA m_sCurText;
ReaderState()
{
m_nUD = 1;
......@@ -60,6 +65,7 @@ private:
RtfDocument& m_oDocument;
CString m_sFilename;
};
class RtfAbstractReader
{
public:
......@@ -72,6 +78,7 @@ public:
m_nSkipChars = 0;
m_nCurGroups = 1;
m_oFileWriter = NULL;
m_bStopReader = false;
}
bool Parse(RtfDocument& oDocument, RtfReader& oReader )
{
......@@ -83,7 +90,7 @@ public:
if( m_oTok.Type == m_oTok.None )
m_oTok = oReader.m_oLex.NextToken();
while (m_oTok.Type != RtfToken::Eof)
while (m_oTok.Type != RtfToken::Eof && false == m_bStopReader)
{
switch (m_oTok.Type)
{
......@@ -126,7 +133,8 @@ public:
oReader.m_oState->m_sCurText.Append( m_oTok.Key );
break;
}
m_oTok = oReader.m_oLex.NextToken();
if( false == m_bStopReader)
m_oTok = oReader.m_oLex.NextToken();
}
oReader.m_oLex.m_oFileWriter = poOldWriter;
......@@ -147,6 +155,7 @@ public:
;//ATLASSERT(false);
if( m_nCurGroups == 0 )
{
m_bStopReader = true;
ExitReader( oDocument, oReader );
}
oReader.PopState();
......@@ -301,11 +310,12 @@ public:
return sResult;
}
private:
RtfToken m_oTok;
bool m_bCanStartNewReader;
RtfToken m_oTok;
bool m_bCanStartNewReader;
int m_nSkipChars;
bool m_bSkip;
int m_nSkipChars;
bool m_bSkip;
bool m_bStopReader;
protected:
int m_nCurGroups;
};
......
......@@ -745,8 +745,8 @@ CString RtfSectionProperty::RenderToOOX(RenderParameter oRenderParameter)
}
CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParameter oRenderParameter, bool bHeader)
{
OOXWriter* poOOXWriter = static_cast<OOXWriter*>( oRenderParameter.poWriter );
RtfDocument* poRtfDocument = static_cast<RtfDocument*>( oRenderParameter.poDocument );
OOXWriter* poOOXWriter = static_cast<OOXWriter*> ( oRenderParameter.poWriter );
RtfDocument* poRtfDocument = static_cast<RtfDocument*> ( oRenderParameter.poDocument );
CString sFilename;
if( true == bHeader )
......@@ -773,7 +773,7 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame
CStringA sContentUTF = Convert::UnicodeToUtf8( sContent );
CString sFilePath = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + poOOXWriter->m_sDocumentFolder+ FILE_SEPARATOR_STR + sFilename;
CString sFilePath = poOOXWriter->m_sTargetFolder + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + sFilename;
DWORD dwBytesWritten = 0;
CFile file;
......@@ -784,7 +784,7 @@ CString RtfSectionProperty::SaveFile( TextItemContainerPtr oTarget, RenderParame
file.CloseFile();
}
CString sContentTarget = _T("/") + poOOXWriter->m_sDocumentFolder + _T("/") + sFilename;
CString sContentTarget = _T("/word/") + sFilename;
CString srID;
if( true == bHeader )
{
......
......@@ -60,7 +60,7 @@ namespace Strings
nG = 16*ToDigit(color[4]) + ToDigit(color[5]);
nB = 16*ToDigit(color[6]) + ToDigit(color[7]);
}
static BOOL ToBoolean(const CString& strValue)
static bool ToBoolean(const CString& strValue)
{
CString s = strValue;
......@@ -97,7 +97,7 @@ namespace Strings
return str;
}
static CString FromBoolean(BOOL Value)
static CString FromBoolean(bool Value)
{
if (Value)
return _T("true");
......
#pragma once
#include "OOXRelsWriter.h"
class OOXDocPropAppWriter
{
private:
CString m_sContent;
OOXWriter& m_oWriter;
CString CreateXml()
{
CString sResult;
sResult.Append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
sResult.Append( _T("\n") );
sResult.Append( _T("<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\" >") );
sResult.Append( m_sContent );
sResult.Append( _T("</Properties>") );
return sResult;
}
public:
OOXRelsWriter* m_oRelsWriter;
OOXDocPropAppWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter( oWriter )
{
m_oRelsWriter = &oWriter.m_oRels;
}
void AddContent( CString sText )
{
m_sContent.Append( sText );
}
bool Save( CString sFolder)
{
CString pathDocProps = sFolder + FILE_SEPARATOR_STR + _T("docProps");
FileSystem::Directory::CreateDirectoryW(pathDocProps) ;
if( false == m_sContent.IsEmpty() )
{
m_oWriter.m_oRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"), _T("docProps/app.xml") );
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.extended-properties+xml"), _T("/docProps/app.xml") );
CFile file;
if (file.CreateFileW(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"))) return false;
CString sXml = CreateXml();
CStringA sXmlUTF = Convert::UnicodeToUtf8( sXml );
file.WriteFile(sXmlUTF.GetBuffer(), sXmlUTF.GetLength());
file.CloseFile();
return true;
}
else
{
//todooo - default app !!!
}
return false;
}
bool IsEmpty()
{
return m_sContent.IsEmpty();
}
};
\ No newline at end of file
#pragma once
#include "OOXRelsWriter.h"
class OOXDocPropCoreWriter
{
private:
CString m_sFileXml;
OOXWriter& m_oWriter;
CString CreateXml()
{
CString sResult;
sResult.Append( _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>") );
sResult.Append( _T("\n") );
sResult.Append( _T("<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:dcmitype=\"http://purl.org/dc/dcmitype/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">") );
sResult.Append( m_sFileXml );
sResult.Append( _T("</cp:coreProperties>") );
return sResult;
}
public:
OOXRelsWriter* m_oRelsWriter;
OOXDocPropCoreWriter(OOXWriter& oWriter,RtfDocument& oDocument ):m_oWriter(oWriter)
{
m_oRelsWriter = &oWriter.m_oRels;
}
void AddContent( CString sText )
{
m_sFileXml.Append( sText );
}
bool Save( CString sFolder)
{
CString pathDocProps = sFolder + FILE_SEPARATOR_STR + _T("docProps");
FileSystem::Directory::CreateDirectoryW(pathDocProps) ;
if( false == m_sFileXml.IsEmpty() )
{
m_oWriter.m_oRels.AddRelationship( _T("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"), _T("docProps/core.xml") );
m_oWriter.m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-package.core-properties+xml"), _T("/docProps/core.xml") );
CFile file;
if (file.CreateFileW(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"))) return false;
CString sXml = CreateXml();
CStringA sXmlUTF = Convert::UnicodeToUtf8( sXml );
file.WriteFile(sXmlUTF.GetBuffer(), sXmlUTF.GetLength());
file.CloseFile();
return true;
}
else
{
//todooo - default core !!!
}
return false;
}
bool IsEmpty()
{
return m_sFileXml.IsEmpty();
}
};
\ No newline at end of file
......@@ -7,8 +7,6 @@
#include "OOXStylesWriter.h"
#include "OOXSettingsWriter.h"
#include "OOXThemeWriter.h"
#include "OOXDocPropAppWriter.h"
#include "OOXDocPropCoreWriter.h"
#include "OOXFootnoteWriter.h"
//#include "../../../../ASCOfficeDocxFile2/BinReader/ContentTypesWriter.h"
......@@ -94,67 +92,23 @@ CString OOXDocumentWriter::CreateXmlEnd( )
//numbering.xml
OOXNumberingWriter* poNumberingWriter = static_cast<OOXNumberingWriter*>( m_oWriter.m_poNumberingWriter );
oNewParam.poRels = poNumberingWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_NUMBERING;
oNewParam.poRels = poNumberingWriter->m_oRelsWriter.get();
oNewParam.nType = RENDER_TO_OOX_PARAM_NUMBERING;
poNumberingWriter->AddNumbering( m_oDocument.m_oListTabel.RenderToOOX(oNewParam) );
poNumberingWriter->AddNumbering( m_oDocument.m_oListOverrideTabel.RenderToOOX(oNewParam) );
//core.xml
OOXDocPropCoreWriter* poDocPropCoreWriter = static_cast<OOXDocPropCoreWriter*>( m_oWriter.m_poDocPropCoreWriter );
oNewParam.poRels = poDocPropCoreWriter->m_oRelsWriter;
oNewParam.nType = RENDER_TO_OOX_PARAM_CORE;
poDocPropCoreWriter->AddContent( m_oDocument.m_oInformation.RenderToOOX(oNewParam) );
oNewParam.poRels = NULL;
oNewParam.nType = RENDER_TO_OOX_PARAM_CORE;
oNewParam.poWriter = m_oWriter.m_poDocPropsCore;
m_oDocument.m_oInformation.RenderToOOX(oNewParam);
//app.xml
OOXDocPropAppWriter* poDocPropAppWriter = static_cast<OOXDocPropAppWriter*>( m_oWriter.m_poDocPropAppWriter );
oNewParam.poRels = poDocPropAppWriter->m_oRelsWriter;
oNewParam.nType = RENDER_TO_OOX_PARAM_APP;
poDocPropAppWriter->AddContent( m_oDocument.m_oInformation.RenderToOOX(oNewParam) );
////styles.xml
//OOXStylesWriter* poStylesWriter = static_cast<OOXStylesWriter*>( m_oWriter.m_poStylesWriter );
//oNewParam.poRels = poStylesWriter->m_oRelsWriter.get();
//oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
//CString sTempParaDef = m_oDocument.m_oDefaultParagraphProp.RenderToOOX(oNewParam);
//CString sTempCharDef = m_oDocument.m_oDefaultCharProp.RenderToOOX(oNewParam);
////CString sTempStyle = m_oDocument.m_oLatentStyleTable.RenderToOOX(oNewParam);
//sTempStyle.Append( m_oDocument.m_oStyleTable.RenderToOOX(oNewParam) );
//CString sStyles;
//if( false == sTempParaDef.IsEmpty() || false == sTempCharDef.IsEmpty() )
//{
// sStyles.Append(_T("<w:docDefaults>"));
// if( false == sTempParaDef.IsEmpty() )
// {
// sStyles.Append(_T("<w:pPrDefault><w:pPr>"));
// sStyles.Append( sTempParaDef );
// sStyles.Append(_T("</w:pPr></w:pPrDefault>"));
// }
// if( false == sTempCharDef.IsEmpty() )
// {
// sStyles.Append(_T("<w:rPrDefault><w:rPr>"));
// sStyles.Append( sTempCharDef );
// sStyles.Append(_T("</w:rPr></w:rPrDefault>"));
// }
// sStyles.Append(_T("</w:docDefaults>"));
//}
//sStyles.Append( sTempStyle );
//poStylesWriter->AddContent( sStyles );
////"theme.xml"
//OOXStylesWriter* poStylesWriter = static_cast<OOXStylesWriter*>( m_oWriter. );
//CString sTempColorTbl = m_oColorTable.RenderToOOX(poWriter, poDocument, "theme.xml",_T("") );
//CString sTempFontTbl = m_oFontTable.RenderToOOX(poWriter, poDocument, "theme.xml",_T("") );
//if( false == sTempColorTbl.IsEmpty() || false == sTempFontTbl.IsEmpty() )
//{
// sResult.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>");
// sResult.Append("<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" >");
// sResult.Append("<a:themeElements>");
// sResult.Append( sTempColorTbl );
// sResult.Append( sTempFontTbl );
// sResult.Append( "<a:fmtScheme name=\"Office\"><a:fillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"50000\"/><a:satMod val=\"300000\"/></a:schemeClr></a:gs><a:gs pos=\"35000\"><a:schemeClr val=\"phClr\"><a:tint val=\"37000\"/><a:satMod val=\"300000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:tint val=\"15000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"16200000\" scaled=\"1\"/></a:gradFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:shade val=\"51000\"/><a:satMod val=\"130000\"/></a:schemeClr></a:gs><a:gs pos=\"80000\"><a:schemeClr val=\"phClr\"><a:shade val=\"93000\"/><a:satMod val=\"130000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"94000\"/><a:satMod val=\"135000\"/></a:schemeClr></a:gs></a:gsLst><a:lin ang=\"16200000\" scaled=\"0\"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w=\"9525\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"><a:shade val=\"95000\"/><a:satMod val=\"105000\"/></a:schemeClr></a:solidFill><a:prstDash val=\"solid\"/></a:ln><a:ln w=\"25400\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/></a:ln><a:ln w=\"38100\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\"><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:prstDash val=\"solid\"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad=\"40000\" dist=\"20000\" dir=\"5400000\" rotWithShape=\"0\"><a:srgbClr val=\"000000\"><a:alpha val=\"38000\"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\"><a:srgbClr val=\"000000\"><a:alpha val=\"35000\"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad=\"40000\" dist=\"23000\" dir=\"5400000\" rotWithShape=\"0\"><a:srgbClr val=\"000000\"><a:alpha val=\"35000\"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst=\"orthographicFront\"><a:rot lat=\"0\" lon=\"0\" rev=\"0\"/></a:camera><a:lightRig rig=\"threePt\" dir=\"t\"><a:rot lat=\"0\" lon=\"0\" rev=\"1200000\"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w=\"63500\" h=\"25400\"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val=\"phClr\"/></a:solidFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"40000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs><a:gs pos=\"40000\"><a:schemeClr val=\"phClr\"><a:tint val=\"45000\"/><a:shade val=\"99000\"/><a:satMod val=\"350000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"20000\"/><a:satMod val=\"255000\"/></a:schemeClr></a:gs></a:gsLst><a:path path=\"circle\"><a:fillToRect l=\"50000\" t=\"-80000\" r=\"50000\" b=\"180000\"/></a:path></a:gradFill><a:gradFill rotWithShape=\"1\"><a:gsLst><a:gs pos=\"0\"><a:schemeClr val=\"phClr\"><a:tint val=\"80000\"/><a:satMod val=\"300000\"/></a:schemeClr></a:gs><a:gs pos=\"100000\"><a:schemeClr val=\"phClr\"><a:shade val=\"30000\"/><a:satMod val=\"200000\"/></a:schemeClr></a:gs></a:gsLst><a:path path=\"circle\"><a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme>" );
// sResult.Append("</a:themeElements>");
// sResult.Append("</a:theme>");
//}
oNewParam.poRels = NULL;
oNewParam.nType = RENDER_TO_OOX_PARAM_APP;
oNewParam.poWriter = m_oWriter.m_poDocPropsApp;
m_oDocument.m_oInformation.RenderToOOX(oNewParam);
//
oNewParam.poDocument = &m_oDocument;
......
......@@ -19,7 +19,6 @@ public:
bool Save( CString sFolder )
{
CString pathWord = sFolder + FILE_SEPARATOR_STR + _T("word");
FileSystem::Directory::CreateDirectoryW(pathWord) ;
if( false == m_sFileXml.IsEmpty() )
{
......
#include "OOXWriter.h"
#include "../RtfDocument.h"
//#include "OOXContentTypesWriter.h"
#include "OOXRelsWriter.h"
#include "OOXDocumentWriter.h"
#include "OOXNumberingWriter.h"
......@@ -9,43 +9,60 @@
#include "OOXStylesWriter.h"
#include "OOXSettingsWriter.h"
#include "OOXThemeWriter.h"
#include "OOXDocPropAppWriter.h"
#include "OOXDocPropCoreWriter.h"
#include "OOXFootnoteWriter.h"
#include "../../../../Common/DocxFormat/Source/DocxFormat/Docx.h"
#include "../../../../ASCOfficeDocxFile2/BinReader/DefaultThemeWriter.h"
OOXWriter::OOXWriter( RtfDocument& oDocument, CString sPath ) :
m_oDocument(oDocument),
m_sTargetFolder(sPath),
m_oRels( _T(""), oDocument ),
m_oDocRels( _T("document.xml"), oDocument )
{
nCurFitWidth = PROP_DEF;
m_poFootnoteWriter = NULL;
m_poEndnoteWriter = NULL;
m_sDocumentFolder = _T("word");
nCurFitWidth = PROP_DEF;
m_poFootnoteWriter = NULL;
m_poEndnoteWriter = NULL;
m_poDocumentWriter = new OOXDocumentWriter( *this, m_oDocument );
m_poFootnoteWriter = new OOXFootnoteWriter( *this, m_oDocument );
m_poEndnoteWriter = new OOXEndnoteWriter( *this, m_oDocument );
m_poDocPropAppWriter = new OOXDocPropAppWriter( *this, m_oDocument );
m_poDocPropCoreWriter = new OOXDocPropCoreWriter( *this, m_oDocument );
m_poDocumentWriter = new OOXDocumentWriter( *this, m_oDocument );
m_poFootnoteWriter = new OOXFootnoteWriter( *this, m_oDocument );
m_poEndnoteWriter = new OOXEndnoteWriter( *this, m_oDocument );
m_poFontTableWriter = new OOXFontTableWriter( *this, m_oDocument );
m_poNumberingWriter = new OOXNumberingWriter( *this, m_oDocument );
m_poSettingsWriter = new OOXSettingsWriter( *this, m_oDocument );
m_poStylesWriter = new OOXStylesWriter( *this, m_oDocument );
m_poSettingsWriter = new OOXSettingsWriter( *this, m_oDocument );
m_poStylesWriter = new OOXStylesWriter( *this, m_oDocument );
m_poDocPropsApp = new OOX::CApp();
m_poDocPropsCore = new OOX::CCore();
//default properties
if (m_poDocPropsApp)
{
((OOX::CApp*)m_poDocPropsApp)->SetDocSecurity(0);
((OOX::CApp*)m_poDocPropsApp)->SetScaleCrop(false);
((OOX::CApp*)m_poDocPropsApp)->SetLinksUpToDate(false);
((OOX::CApp*)m_poDocPropsApp)->SetSharedDoc(false);
((OOX::CApp*)m_poDocPropsApp)->SetHyperlinksChanged(false);
}
if (m_poDocPropsCore)
{
((OOX::CCore*)m_poDocPropsCore)->SetCreator(_T(""));
((OOX::CCore*)m_poDocPropsCore)->SetLastModifiedBy(_T(""));
}
}
OOXWriter::~OOXWriter()
{
delete ((OOXDocumentWriter*)m_poDocumentWriter);
delete ((OOXFootnoteWriter*)m_poFootnoteWriter);
delete ((OOXEndnoteWriter*)m_poEndnoteWriter);
delete ((OOXDocPropAppWriter*)m_poDocPropAppWriter);
delete ((OOXDocPropCoreWriter*)m_poDocPropCoreWriter);
delete ((OOXFontTableWriter*)m_poFontTableWriter);
delete ((OOXNumberingWriter*)m_poNumberingWriter);
delete ((OOXSettingsWriter*)m_poSettingsWriter);
delete ((OOXStylesWriter*)m_poStylesWriter);
delete ((OOX::CApp*)m_poDocPropsApp);
delete ((OOX::CCore*)m_poDocPropsCore);
}
bool OOXWriter::Save()
{
......@@ -59,38 +76,6 @@ bool OOXWriter::Save()
}
bool OOXWriter::SaveByItemStart()
{
((OOXFootnoteWriter*)m_poFootnoteWriter)->Save(m_sTargetFolder + FILE_SEPARATOR_STR + m_sDocumentFolder);
((OOXEndnoteWriter*)m_poEndnoteWriter)->Save(m_sTargetFolder + FILE_SEPARATOR_STR + m_sDocumentFolder);
if( m_oFootnoteSep->GetCount() )
{
oNewParam = oRenderParameter;
oNewParam.poRels = &poFootnoteWriter->m_oRelsWriter;
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poFootnoteWriter->AddFootnote( _T("separator"), -1, m_oFootnoteSep->RenderToOOX(oNewParam) );
}
if( m_oFootnoteCon->GetCount() )
{
oNewParam = oRenderParameter;
oNewParam.poRels = &poFootnoteWriter->m_oRelsWriter;
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poFootnoteWriter->AddFootnote( _T("continuationSeparator"), 0, m_oFootnoteCon->RenderToOOX( oNewParam ) );
}
if( m_oEndnoteSep->GetCount() )
{
oNewParam = oRenderParameter;
oNewParam.poRels = &poEndnoteWriter->m_oRelsWriter;
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poEndnoteWriter->AddEndnote( _T("separator"), -1, m_oEndnoteSep->RenderToOOX(oNewParam) );
}
if( m_oEndnoteCon->GetCount() )
{
oNewParam = oRenderParameter;
oNewParam.poRels = &poEndnoteWriter->m_oRelsWriter;
oNewParam.nType = RENDER_TO_OOX_PARAM_UNKNOWN;
poEndnoteWriter->AddEndnote( _T("continuationSeparator"), 0, m_oEndnoteSep->RenderToOOX(oNewParam) );
}
return ((OOXDocumentWriter*)m_poDocumentWriter)->SaveByItemStart( m_sTargetFolder );
}
bool OOXWriter::SaveByItem()
......@@ -99,58 +84,57 @@ bool OOXWriter::SaveByItem()
}
bool OOXWriter::SaveByItemEnd()
{
//OOX::CContentTypes oContentTypes;
//
////docProps
// OOX::CPath pathDocProps = sDstPath + FILE_SEPARATOR_STR + _T("docProps");
// FileSystem::Directory::CreateDirectory(pathDocProps.GetPath());
//
// OOX::CPath DocProps = CString(_T("docProps"));
//OOX::CApp* pApp = new OOX::CApp();
//if (pApp)
//{
// pApp->SetApplication(_T("OnlyOffice"));
// pApp->SetAppVersion(_T("3.0000"));
// pApp->SetDocSecurity(0);
// pApp->SetScaleCrop(false);
// pApp->SetLinksUpToDate(false);
// pApp->SetSharedDoc(false);
// pApp->SetHyperlinksChanged(false);
//
// pApp->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), DocProps, oContentTypes);
// delete pApp;
//}
//OOX::CCore* pCore = new OOX::CCore();
//if (pCore)
//{
// pCore->SetCreator(_T(""));
// pCore->SetLastModifiedBy(_T(""));
// pCore->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), DocProps, oContentTypes);
// delete pCore;
//}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
OOX::CContentTypes oContentTypes;
OOXThemeWriter oThemeWr(*this, m_oDocument);
oThemeWr.Save(m_sTargetFolder);
OOX::CPath pathWord = m_sTargetFolder + FILE_SEPARATOR_STR + _T("word");
FileSystem::Directory::CreateDirectory(pathWord.GetPath());
//-------------------------------------------------------------------------------------
OOX::CPath pathDocProps = m_sTargetFolder + FILE_SEPARATOR_STR + _T("docProps");
FileSystem::Directory::CreateDirectory(pathDocProps.GetPath());
if (m_poDocPropsApp)
{
((OOX::CApp*)m_poDocPropsApp)->SetApplication(_T("OnlyOffice"));
((OOX::CApp*)m_poDocPropsApp)->SetAppVersion(_T("3.0000"));
((OOX::CApp*)m_poDocPropsApp)->write(pathDocProps + FILE_SEPARATOR_STR + _T("app.xml"), pathDocProps.GetDirectory(), oContentTypes);
m_oRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"), _T("docProps/app.xml") );
m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.extended-properties+xml"), _T("/docProps/app.xml") );
}
if (m_poDocPropsCore)
{
((OOX::CCore*)m_poDocPropsCore)->write(pathDocProps + FILE_SEPARATOR_STR + _T("core.xml"), pathDocProps.GetDirectory(), oContentTypes);
m_oRels.AddRelationship( _T("http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"), _T("docProps/core.xml") );
m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-package.core-properties+xml"), _T("/docProps/core.xml") );
}
//-----------------------------------------------------------------------------------------------------
OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme");
FileSystem::Directory::CreateDirectoryW(pathTheme.GetPath()) ;
Writers::DefaultThemeWriter themeWriter;
themeWriter.Write(pathTheme.GetPath() + FILE_SEPARATOR_STR + _T("theme1.xml"));
m_oDocRels.AddRelationship( _T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"), _T("theme/theme1.xml") );
m_oContentTypes.AddContent( _T("application/vnd.openxmlformats-officedocument.theme+xml"), _T("/word/theme/theme1.xml") );
//-----------------------------------------------------------------------------------------------------
((OOXDocumentWriter*)m_poDocumentWriter)->SaveByItemEnd();
((OOXFootnoteWriter*)m_poFootnoteWriter)->Save(m_sTargetFolder + FILE_SEPARATOR_STR + m_sDocumentFolder);
((OOXEndnoteWriter*)m_poEndnoteWriter)->Save(m_sTargetFolder + FILE_SEPARATOR_STR + m_sDocumentFolder);
((OOXFootnoteWriter*)m_poFootnoteWriter)->Save(pathWord.GetPath());
((OOXEndnoteWriter*)m_poEndnoteWriter)->Save(pathWord.GetPath());
((OOXNumberingWriter*)m_poNumberingWriter)->Save(m_sTargetFolder);
((OOXStylesWriter*)m_poStylesWriter)->Save(m_sTargetFolder);
((OOXFontTableWriter*)m_poFontTableWriter)->Save(m_sTargetFolder);
((OOXDocPropAppWriter*)m_poDocPropAppWriter)->Save(m_sTargetFolder);
((OOXDocPropCoreWriter*)m_poDocPropCoreWriter)->Save(m_sTargetFolder);
((OOXSettingsWriter*)m_poSettingsWriter)->Save(m_sTargetFolder); //setting
bool nResult = true;
nResult &= m_oContentTypes.Save(m_sTargetFolder);
nResult &= m_oRels.Save(m_sTargetFolder);
nResult &= m_oDocRels.Save(m_sTargetFolder + FILE_SEPARATOR_STR + m_sDocumentFolder);
nResult &= m_oDocRels.Save(pathWord.GetPath());
for( int i = 0; i < (int)m_oCustomRelsWriter.size(); i++ )
m_oCustomRelsWriter[i]->Save(m_sTargetFolder + FILE_SEPARATOR_STR + m_sDocumentFolder);
m_oCustomRelsWriter[i]->Save(pathWord.GetPath());
return nResult;
}
\ No newline at end of file
......@@ -8,8 +8,7 @@
class OOXWriter
{
public:
__event void OnProgress( long nProgress, short* shCancel );
CString nCurFitId;
int nCurFitWidth;
......@@ -22,18 +21,18 @@ public:
void* m_poDocumentWriter;
void* m_poFootnoteWriter;
void* m_poEndnoteWriter;
void* m_poDocPropAppWriter;
void* m_poDocPropCoreWriter;
void* m_poFontTableWriter;
void* m_poNumberingWriter;
void* m_poSettingsWriter;
void* m_poStylesWriter;
void* m_poDocPropsApp;
void* m_poDocPropsCore;
//TempFolder
CString m_sTempFolder;
CString m_sTargetFolder;
CString m_sDocumentFolder;
std::map<CString, int> m_aBookmarksId;
OOXWriter( RtfDocument& oDocument, CString sPath );
......
B// RtfFile.cpp : Implementation of CRtfFile
......
......@@ -54,8 +54,7 @@ public:
}
private:
long m_nLastProgress;
void RaiseOnProcess( long nValue, short* nCancel );
BOOL IsRtfFile(CString sFilename, long& nError );
bool IsRtfFile(CString sFilename, long& nError );
public:
STDMETHOD(LoadFromFile)(BSTR sSrcFileName, BSTR sDstPath, BSTR sXMLOptions);
STDMETHOD(SaveToFile)(BSTR sDstFileName, BSTR sSrcPath, BSTR sXMLOptions);
......
......@@ -2,6 +2,6 @@
//1
//0
//1
//47
#define INTVER 1,0,1,47
#define STRVER "1,0,1,47\0"
//51
#define INTVER 1,0,1,51
#define STRVER "1,0,1,51\0"
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