Compare commits

..

9 Commits

Author SHA1 Message Date
5c01b23dee . 2018-01-30 20:09:22 +03:00
db11b75a2e x2t version 2.4.514 2018-01-30 19:37:10 +03:00
2ba4c18cdf bug: initialize m_pWorkbookComments 2018-01-30 17:22:39 +03:00
b264f20f29 . 2018-01-30 15:21:05 +03:00
5e04ea62f7 fix operation priority 2018-01-30 14:44:52 +03:00
3d1db63c0e bug: bug on save onlyoffice extention for comments in xlsx 2018-01-29 19:51:06 +03:00
f124d18256 bug: save nil shading to docx 2018-01-29 18:14:23 +03:00
9bffb65dcb x2t 2.4.512 2018-01-29 15:46:08 +03:00
2fbcc3832f feat: add workbookComments, presentationComments 2018-01-26 20:37:27 +03:00
103 changed files with 1381 additions and 1625 deletions

View File

@ -21,8 +21,6 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -318,20 +318,29 @@ public:
docRGB Color;
CThemeColor ThemeColor;
bool bValue;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bValue = false;
bColor = false;
bThemeColor = false;
}
std::wstring ToString()
{
std::wstring sShd;
if(bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
if(bValue || bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
{
sShd += L"<w:shd w:val=\"clear\" w:color=\"auto\"";
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
}
sShd += L" w:color=\"auto\"";
if(bColor)
sShd += L" w:fill=\"" + Color.ToString() + L"\"";
if(bThemeColor && ThemeColor.IsNoEmpty())

View File

@ -266,7 +266,10 @@ private:
Shd* pShd = static_cast<Shd*>(poResult);
switch(type)
{
case c_oSerShdType::Value: pShd->Value = m_oBufferedStream.GetUChar();break;
case c_oSerShdType::Value:
pShd->bValue = true;
pShd->Value = m_oBufferedStream.GetUChar();
break;
case c_oSerShdType::Color:
pShd->bColor = true;
pShd->Color = ReadColor();
@ -451,11 +454,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
orPr->bShd = true;
orPr->Shd = oShd.ToString();
}
orPr->bShd = true;
orPr->Shd = oShd.ToString();
break;
}
case c_oSerProp_rPrType::RStyle:
@ -801,15 +801,7 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
else
{
std::wstring sShd(L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>");
pCStringWriter->WriteString(sShd);
}
pCStringWriter->WriteString(oShd.ToString());
break;
}
case c_oSerProp_pPrType::WidowControl:
@ -1782,11 +1774,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
else if( c_oSerProp_tblPrType::tblpPr == type )
{
@ -2244,10 +2233,7 @@ public:
bCellShd = true;
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
pCStringWriter->WriteString(oShd.ToString());
}
else if( c_oSerProp_cellPrType::TableCellBorders == type )
{

View File

@ -87,10 +87,14 @@ namespace BinDocxRW
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, pHdrFtr->m_arrShapeTypes);
smart_ptr<OOX::IFileContainer> oldRels = m_pOfficeDrawingConverter->GetRels();
m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_pOfficeDrawingConverter->ClearShapeTypes();
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
m_pOfficeDrawingConverter->SetRels(oldRels);
}
}

View File

@ -3016,25 +3016,13 @@ namespace BinDocxRW
bool m_bWriteSectPr;//Записывать ли свойства верхнего уровня в данном экземпляре BinaryOtherTableWriter
//---------------------------------
BinaryDocumentTableWriter(ParamsWriter& oParamsWriter, ParamsDocumentWriter& oParamsDocumentWriter, std::map<int, bool>* mapIgnoreComments, BinaryHeaderFooterTableWriter* oBinaryHeaderFooterTableWriter):
m_oParamsWriter(oParamsWriter), m_oParamsDocumentWriter(oParamsDocumentWriter),m_oBcw(oParamsWriter),bpPrs(oParamsWriter, oBinaryHeaderFooterTableWriter),brPrs(oParamsWriter),btblPrs(oParamsWriter),m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter),m_mapIgnoreComments(mapIgnoreComments)
m_oParamsWriter(oParamsWriter), m_oParamsDocumentWriter(oParamsDocumentWriter), m_oBcw(oParamsWriter),bpPrs(oParamsWriter, oBinaryHeaderFooterTableWriter),brPrs(oParamsWriter),btblPrs(oParamsWriter),m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter),m_mapIgnoreComments(mapIgnoreComments)
{
pBackground = NULL;
pSectPr = NULL;
poDocument = NULL;
m_bWriteSectPr = false;
}
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, OOX::IFileContainer *rels, std::vector<std::wstring>& aShapeTypes)
{
smart_ptr<OOX::IFileContainer> oldRels = pOfficeDrawingConverter->GetRels();
pOfficeDrawingConverter->SetRels(rels);
for(size_t i = 0, length = aShapeTypes.size(); i < length; ++i)
{
std::wstring& sShapeType = aShapeTypes[i];
pOfficeDrawingConverter->AddShapeType(sShapeType);
}
pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteVbaProject(OOX::VbaProject& oVbaProject)
{
m_oBcw.m_oStream.StartRecord(0);
@ -3131,23 +3119,6 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
}
//Write JsaProject
if (NULL != poDocument)
{
smart_ptr<OOX::File> pFile = poDocument->Get(OOX::FileTypes::JsaProject);
if (pFile.IsInit() && OOX::FileTypes::JsaProject == pFile->type())
{
OOX::JsaProject& jsaProject = pFile.as<OOX::JsaProject>();
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(jsaProject.filename().GetPath(), &pData, nBytesCount))
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
m_oBcw.WriteItemEnd(nCurPos);
}
}
}
}
void WriteBackground (OOX::Logic::CBackground* pBackground)
{
@ -7741,7 +7712,7 @@ namespace BinDocxRW
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter, oFootnotes.m_arrShapeTypes);
WriteNotes(oFootnotes.m_arrFootnote, oParamsDocumentWriter);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteEndnotes(OOX::CEndnotes& oEndnotes)
@ -7750,20 +7721,27 @@ namespace BinDocxRW
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
int nStart = m_oBcw.WriteItemWithLengthStart();
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter, oEndnotes.m_arrShapeTypes);
WriteNotes(oEndnotes.m_arrEndnote, oParamsDocumentWriter);
m_oBcw.WriteItemWithLengthEnd(nStart);
}
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<std::wstring>& arrShapeTypes)
void WriteNotes(const std::vector<OOX::CFtnEdn*>& arrNotes, ParamsDocumentWriter& oParamsDocumentWriter)
{
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
smart_ptr<OOX::IFileContainer> oldRels = m_pOfficeDrawingConverter->GetRels();
m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_pOfficeDrawingConverter->ClearShapeTypes();
int nCurPos = 0;
for(size_t i = 0 ; i < arrNotes.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::Note);
WriteNote(*arrNotes[i], oParamsDocumentWriter, arrShapeTypes);
WriteNote(*arrNotes[i], oBinaryDocumentTableWriter);
m_oBcw.WriteItemEnd(nCurPos);
}
m_pOfficeDrawingConverter->SetRels(oldRels);
}
void WriteNote(const OOX::CFtnEdn& oFtnEdn, ParamsDocumentWriter& oParamsDocumentWriter, std::vector<std::wstring>& arrShapeTypes)
void WriteNote(const OOX::CFtnEdn& oFtnEdn, BinaryDocumentTableWriter & oBinaryDocumentTableWriter)
{
int nCurPos = 0;
if(oFtnEdn.m_oType.IsInit())
@ -7778,10 +7756,6 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteLONG(oFtnEdn.m_oId->GetValue());
m_oBcw.WriteItemEnd(nCurPos);
}
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerNotes::NoteContent);
oBinaryDocumentTableWriter.WriteDocumentContent(oFtnEdn.m_arrItems);
@ -7864,101 +7838,93 @@ namespace BinDocxRW
OOX::CDocx oDocx = OOX::CDocx(OOX::CPath(sDir));
m_oParamsWriter.m_poTheme = oDocx.GetTheme();
m_oParamsWriter.m_oSettings = oDocx.GetSettings();
m_oParamsWriter.m_poTheme = oDocx.m_pTheme;
m_oParamsWriter.m_oSettings = oDocx.m_pSettings;
*oBufferedStream.m_pTheme = smart_ptr<PPTX::Theme>(oDocx.GetTheme());
*oBufferedStream.m_pTheme = smart_ptr<PPTX::Theme>(oDocx.m_pTheme);
oBufferedStream.m_pTheme->AddRef();
OOX::CFontTable* pFontTable = oDocx.GetFontTable();
if(NULL != pFontTable)
m_oParamsWriter.m_pFontProcessor->setFontTable(pFontTable);
if(NULL != oDocx.m_pFontTable)
m_oParamsWriter.m_pFontProcessor->setFontTable(oDocx.m_pFontTable);
//ищем первый SectPr и расставляем pageBreak
OOX::CDocument* poDocument = oDocx.GetDocument();
if (poDocument == NULL) return;
OOX::Logic::CSectionProperty* pFirstSectPr = poDocument->m_oSectPr.GetPointer();
if (oDocx.m_pDocument == NULL) return;
OOX::Logic::CSectionProperty* pFirstSectPr = oDocx.m_pDocument->m_oSectPr.GetPointer();
this->WriteMainTableStart();
int nCurPos = 0;
//Write Settings
OOX::CSettings* pSettings = oDocx.GetSettings();
if(NULL != pSettings)
if(NULL != oDocx.m_pSettings)
{
BinDocxRW::BinarySettingsTableWriter oBinarySettingsTableWriter(m_oParamsWriter);
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Settings);
oBinarySettingsTableWriter.Write(*pSettings);
oBinarySettingsTableWriter.Write(*oDocx.m_pSettings);
this->WriteTableEnd(nCurPos);
}
//Write Comments
OOX::CComments* pComments = oDocx.GetComments();
OOX::CCommentsExt* pCommentsExt = oDocx.GetCommentsExt();
OOX::CPeople* pPeople = oDocx.GetPeople();
if(NULL != pComments)
if(NULL != oDocx.m_pComments)
{
BinDocxRW::BinaryCommentsTableWriter oBinaryCommentsTableWriter(m_oParamsWriter);
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Comments);
oBinaryCommentsTableWriter.Write(*pComments, pCommentsExt, pPeople, m_oParamsWriter.m_mapIgnoreComments);
oBinaryCommentsTableWriter.Write(*oDocx.m_pComments, oDocx.m_pCommentsExt, oDocx.m_pPeople, m_oParamsWriter.m_mapIgnoreComments);
this->WriteTableEnd(nCurPos);
}
//Write StyleTable
OOX::CStyles* pStyles = oDocx.GetStyles();
BinDocxRW::BinaryStyleTableWriter oBinaryStyleTableWriter(m_oParamsWriter);
if(NULL != pStyles)
if(NULL != oDocx.m_pStyles)
{
int nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Style);
oBinaryStyleTableWriter.Write(*pStyles);
oBinaryStyleTableWriter.Write(*oDocx.m_pStyles);
this->WriteTableEnd(nCurPos);
}
//Write Numbering
OOX::CNumbering* pNumbering = oDocx.GetNumbering();
BinDocxRW::BinaryNumberingTableWriter oBinaryNumberingTableWriter(m_oParamsWriter);
if(NULL != pNumbering)
if(NULL != oDocx.m_pNumbering)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Numbering);
oBinaryNumberingTableWriter.Write(*pNumbering);
oBinaryNumberingTableWriter.Write(*oDocx.m_pNumbering);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryNotesTableWriter oBinaryNotesWriter(m_oParamsWriter);
//Write Footnotes
OOX::CFootnotes* pFootnotes = oDocx.GetFootnotes();
if(NULL != pFootnotes)
if(NULL != oDocx.m_pFootnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Footnotes);
oBinaryNotesWriter.WriteFootnotes(*pFootnotes);
oBinaryNotesWriter.WriteFootnotes(*oDocx.m_pFootnotes);
this->WriteTableEnd(nCurPos);
}
//Write Endnotes
OOX::CEndnotes* pEndnotes = oDocx.GetEndnotes();
if(NULL != pEndnotes)
if(NULL != oDocx.m_pEndnotes)
{
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Endnotes);
oBinaryNotesWriter.WriteEndnotes(*pEndnotes);
oBinaryNotesWriter.WriteEndnotes(*oDocx.m_pEndnotes);
this->WriteTableEnd(nCurPos);
}
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, poDocument, &m_oParamsWriter.m_mapIgnoreComments);
BinDocxRW::BinaryHeaderFooterTableWriter oBinaryHeaderFooterTableWriter(m_oParamsWriter, oDocx.m_pDocument, &m_oParamsWriter.m_mapIgnoreComments);
//Write DocumentTable
ParamsDocumentWriter oParamsDocumentWriter(poDocument);
ParamsDocumentWriter oParamsDocumentWriter(oDocx.m_pDocument);
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
//DocumentTable всегда пишем последней, чтобы сначала заполнить все вспомогательные структуры, а при заполении документа, вызывать методы типа Style_Add...
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, &m_oParamsWriter.m_mapIgnoreComments, &oBinaryHeaderFooterTableWriter);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_oParamsWriter.m_pOfficeDrawingConverter, oParamsDocumentWriter.m_pRels, poDocument->m_arrShapeTypes);
m_oParamsWriter.m_pOfficeDrawingConverter->SetRels(oParamsDocumentWriter.m_pRels);
m_oParamsWriter.m_pOfficeDrawingConverter->ClearShapeTypes();
oBinaryDocumentTableWriter.pSectPr = pFirstSectPr;
oBinaryDocumentTableWriter.pBackground = poDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = poDocument;
oBinaryDocumentTableWriter.pBackground = oDocx.m_pDocument->m_oBackground.GetPointer();
oBinaryDocumentTableWriter.poDocument = oDocx.m_pDocument;
oBinaryDocumentTableWriter.m_bWriteSectPr = true;
//Write Vba
if(NULL != oDocx.m_pVbaProject)
{
@ -7966,9 +7932,22 @@ namespace BinDocxRW
oBinaryDocumentTableWriter.WriteVbaProject(*oDocx.m_pVbaProject);
this->WriteTableEnd(nCurPos);
}
//Write JsaProject
if (NULL != oDocx.m_pJsaProject)
{
BYTE* pData = NULL;
DWORD nBytesCount;
if(NSFile::CFileBinary::ReadAllBytes(oDocx.m_pJsaProject->filename().GetPath(), &pData, nBytesCount))
{
nCurPos = m_oBcw.WriteItemStart(c_oSerParType::JsaProject);
m_oBcw.m_oStream.WriteBYTEArray(pData, nBytesCount);
m_oBcw.WriteItemEnd(nCurPos);
}
}
// Write content
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Document);
oBinaryDocumentTableWriter.Write(poDocument->m_arrItems);
oBinaryDocumentTableWriter.Write(oDocx.m_pDocument->m_arrItems);
this->WriteTableEnd(nCurPos);
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::HdrFtr);

View File

@ -16,8 +16,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
USE_AVSOFFICESTUDIO_XMLUTILS \
SOLUTION_ASCOFFICEDOCXFILE2 \
#DISABLE_FILE_DOWNLOADER \

View File

@ -22,8 +22,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -49,7 +49,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4311;4267;4996;4172"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -22,8 +22,6 @@ include($$PWD/../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -141,7 +141,7 @@ odf_writer::odf_conversion_context* DocxConverter::odf_context()
PPTX::Theme* DocxConverter::oox_theme()
{
if (docx_document)
return docx_document->GetTheme();
return docx_document->m_pTheme;
else
return NULL;
}
@ -151,22 +151,17 @@ OOX::IFileContainer* DocxConverter::current_document()
return oox_current_child_document;
else
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
return dynamic_cast<OOX::IFileContainer*>(oox_doc);
return dynamic_cast<OOX::IFileContainer*>(docx_document->m_pDocument);
}
}
NSCommon::smart_ptr<OOX::File> DocxConverter::find_file_by_id(std::wstring sId)
{
OOX::CDocument *oox_doc = docx_document->GetDocument();
smart_ptr<OOX::File> oFile;
if (oox_doc)
{
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else
oFile = oox_doc->Find(sId);
}
if (oox_current_child_document)
oFile = oox_current_child_document->Find(sId);
else if (docx_document->m_pDocument)
oFile = docx_document->m_pDocument->Find(sId);
return oFile;
}
@ -185,10 +180,9 @@ std::wstring DocxConverter::find_link_by_id (std::wstring sId, int type)
}
if (!ref.empty()) return ref;
OOX::CDocument *oox_doc = docx_document->GetDocument();
if (oox_doc == NULL) return L"";
if (docx_document->m_pDocument == NULL) return L"";
oFile = oox_doc->Find(sId);
oFile = docx_document->m_pDocument->Find(sId);
ref = OoxConverter::find_link_by(oFile, type);
return ref;
@ -221,8 +215,7 @@ void DocxConverter::convertDocument()
void DocxConverter::convert_document()
{
const OOX::CDocument* document = docx_document->GetDocument();
if (!document)return;
if (!docx_document->m_pDocument)return;
std::vector<_section> sections;
//----------------------------------------------------------------------------------------------------------
@ -231,13 +224,13 @@ void DocxConverter::convert_document()
OOX::Logic::CSectionProperty* prev = NULL;
for (size_t i = 0; i < document->m_arrItems.size(); ++i)
for (size_t i = 0; i < docx_document->m_pDocument->m_arrItems.size(); ++i)
{
if ((document->m_arrItems[i]) == NULL) continue;
if ((docx_document->m_pDocument->m_arrItems[i]) == NULL) continue;
if (document->m_arrItems[i]->getType() == OOX::et_w_p)
if (docx_document->m_pDocument->m_arrItems[i]->getType() == OOX::et_w_p)
{
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(document->m_arrItems[i]);
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(docx_document->m_pDocument->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty))
{
@ -260,9 +253,9 @@ void DocxConverter::convert_document()
}
_section section;
section.props = document->m_oSectPr.GetPointer();
section.props = docx_document->m_pDocument->m_oSectPr.GetPointer();
section.start_para = last_section_start;
section.end_para = document->m_arrItems.size();
section.end_para = docx_document->m_pDocument->m_arrItems.size();
section.bContinue = compare (prev, section.props);
sections.push_back(section);
@ -277,7 +270,7 @@ void DocxConverter::convert_document()
for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
{
convert(document->m_arrItems[i]);
convert(docx_document->m_pDocument->m_arrItems[i]);
}
}
}
@ -1572,7 +1565,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
//nullable<SimpleTypes::CDecimalNumber<> > m_oCode;
}
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 1);//подложка - вот в таком она месте :(, причём одна на все разделы, не как в оо
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 1);//подложка - вот в таком она месте :(, причём одна на все разделы, не как в оо
//nullable<ComplexTypes::Word::CTextDirection > m_oTextDirection;
//nullable<ComplexTypes::Word::COnOff2<SimpleTypes::onoffTrue> > m_oRtlGutter;
//nullable<ComplexTypes::Word::CVerticalJc > m_oVAlign;
@ -1621,7 +1614,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
if (s->m_arrHeaderReference[i]->m_oId.IsInit())
{
convert_hdr_ftr(s->m_arrHeaderReference[i]->m_oId->GetValue());
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 2);
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 2);
}
odt_context->end_header_footer();
@ -1649,7 +1642,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b
if (s->m_arrFooterReference[i]->m_oId.IsInit())
{
convert_hdr_ftr(s->m_arrFooterReference[i]->m_oId->GetValue());
convert(docx_document->GetDocument()->m_oBackground.GetPointer(), 3);
convert(docx_document->m_pDocument->m_oBackground.GetPointer(), 3);
}
odt_context->end_header_footer();
@ -2335,8 +2328,7 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
if (oox_font_theme == NULL) return;
PPTX::Theme * docx_theme= docx_document->GetTheme();
if (docx_theme == NULL) return;
if (docx_document->m_pTheme == NULL) return;
std::wstring font;
@ -2344,23 +2336,23 @@ void DocxConverter::convert(SimpleTypes::CTheme<>* oox_font_theme, _CP_OPT(std::
{
case SimpleTypes::themeMajorAscii:
case SimpleTypes::themeMajorHAnsi :
font = docx_theme->themeElements.fontScheme.majorFont.latin.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.latin.typeface;
break;
case SimpleTypes::themeMajorBidi:
font = docx_theme->themeElements.fontScheme.majorFont.cs.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.cs.typeface;
break;
case SimpleTypes::themeMajorEastAsia:
font = docx_theme->themeElements.fontScheme.majorFont.ea.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.majorFont.ea.typeface;
break;
case SimpleTypes::themeMinorAscii:
case SimpleTypes::themeMinorHAnsi:
font = docx_theme->themeElements.fontScheme.minorFont.latin.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.latin.typeface;
break;
case SimpleTypes::themeMinorBidi:
font = docx_theme->themeElements.fontScheme.minorFont.cs.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.cs.typeface;
break;
case SimpleTypes::themeMinorEastAsia:
font = docx_theme->themeElements.fontScheme.minorFont.ea.typeface;
font = docx_document->m_pTheme->themeElements.fontScheme.minorFont.ea.typeface;
break;
}
if (!font.empty()) odf_font_name = font;
@ -2867,11 +2859,9 @@ void DocxConverter::convert(SimpleTypes::CHexColor<> *color,
}
if(theme_color && result == false)
{
PPTX::Theme * docx_theme= docx_document->GetTheme();
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_theme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
std::map<std::wstring, PPTX::Logic::UniColor>::iterator pFind = docx_document->m_pTheme->themeElements.clrScheme.Scheme.find(theme_color->ToString());
if (pFind != docx_theme->themeElements.clrScheme.Scheme.end())
if (pFind != docx_document->m_pTheme->themeElements.clrScheme.Scheme.end())
{
PPTX::Logic::UniColor & color = pFind->second;
@ -2890,38 +2880,36 @@ void DocxConverter::convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf_types
PPTX::Logic::ClrMap* DocxConverter::oox_clrMap()
{
//return current_clrMap; todoooo
OOX::CSettings * docx_settings = docx_document->GetSettings();
if (!docx_settings) return NULL;
if (!docx_document->m_pSettings) return NULL;
return docx_settings->m_oClrSchemeMapping.GetPointer();
return docx_document->m_pSettings->m_oClrSchemeMapping.GetPointer();
}
void DocxConverter::convert_settings()
{
if (!odt_context) return;
OOX::CSettings * docx_settings = docx_document->GetSettings();
if (!docx_settings) return;
if (!docx_document->m_pSettings) return;
if (docx_settings->m_oZoom.IsInit())
if (docx_document->m_pSettings->m_oZoom.IsInit())
{
}
if (docx_settings->m_oMirrorMargins.IsInit())
if (docx_document->m_pSettings->m_oMirrorMargins.IsInit())
{
odt_context->page_layout_context()->set_pages_mirrored(true);
}
odt_context->page_layout_context()->even_and_left_headers_ = docx_settings->m_oEvenAndOddHeaders.IsInit();
odt_context->page_layout_context()->even_and_left_headers_ = docx_document->m_pSettings->m_oEvenAndOddHeaders.IsInit();
if (docx_settings->m_oPrintTwoOnOne.IsInit())
if (docx_document->m_pSettings->m_oPrintTwoOnOne.IsInit())
{
if (docx_settings->m_oGutterAtTop.IsInit()){} //portrait
if (docx_document->m_pSettings->m_oGutterAtTop.IsInit()){} //portrait
else {}//landscape
}
if (docx_settings->m_oDefaultTabStop.IsInit())
if (docx_document->m_pSettings->m_oDefaultTabStop.IsInit())
{
_CP_OPT(odf_types::length) length;
convert(docx_settings->m_oDefaultTabStop->m_oVal.GetPointer(), length);
convert(docx_document->m_pSettings->m_oDefaultTabStop->m_oVal.GetPointer(), length);
odf_writer::odf_style_state_ptr state;
if (odt_context->styles_context()->find_odf_default_style_state(odf_types::style_family::Paragraph, state) && state)
@ -2941,7 +2929,7 @@ void DocxConverter::convert_lists_styles()
{
if (!odt_context) return;
OOX::CNumbering * lists_styles = docx_document->GetNumbering();
OOX::CNumbering * lists_styles = docx_document->m_pNumbering;
if (!lists_styles)return;
@ -2979,27 +2967,25 @@ void DocxConverter::convert_lists_styles()
void DocxConverter::convert_styles()
{
if (!odt_context) return;
OOX::CStyles * docx_styles = docx_document->GetStyles();
if (!docx_styles)return;
if (!docx_document->m_pStyles)return;
//nullable<OOX::CLatentStyles > m_oLatentStyles;
convert(docx_styles->m_oDocDefaults.GetPointer());
convert(docx_document->m_pStyles->m_oDocDefaults.GetPointer());
for (size_t i=0; i< docx_styles->m_arrStyle.size(); i++)
for (size_t i=0; i< docx_document->m_pStyles->m_arrStyle.size(); i++)
{
if (docx_styles->m_arrStyle[i] == NULL) continue;
if (docx_document->m_pStyles->m_arrStyle[i] == NULL) continue;
if (!current_font_size.empty())
{
current_font_size.erase(current_font_size.begin() + 1, current_font_size.end());
}
convert(docx_styles->m_arrStyle[i]);
convert(docx_document->m_pStyles->m_arrStyle[i]);
if (i == 0 && docx_styles->m_arrStyle[i]->m_oDefault.IsInit() && docx_styles->m_arrStyle[i]->m_oDefault->ToBool())
if (i == 0 && docx_document->m_pStyles->m_arrStyle[i]->m_oDefault.IsInit() && docx_document->m_pStyles->m_arrStyle[i]->m_oDefault->ToBool())
{
//NADIE_COMO_TU.docx тут дефолтовый стиль не прописан явно, берем тот что Normal
odf_writer::odf_style_state_ptr def_style_state;
@ -3285,7 +3271,7 @@ void DocxConverter::convert(OOX::Numbering::CLvl* oox_num_lvl)
if (oox_num_lvl->m_oLvlPicBulletId.IsInit() && oox_num_lvl->m_oLvlPicBulletId->m_oVal.IsInit())
{
int id = oox_num_lvl->m_oLvlPicBulletId->m_oVal->GetValue();
OOX::CNumbering * lists_styles = docx_document->GetNumbering();
OOX::CNumbering * lists_styles = docx_document->m_pNumbering;
for (size_t i = 0; (lists_styles) && (i < lists_styles->m_arrNumPicBullet.size()); i++)
{
@ -3582,12 +3568,11 @@ void DocxConverter::convert(OOX::Logic::CEndnoteReference* oox_ref)
}
void DocxConverter::convert_comment(int oox_comm_id)
{
OOX::CComments * docx_comments = docx_document->GetComments();
if (!docx_comments)return;
if (!docx_document->m_pComments)return;
for (size_t comm = 0 ; comm < docx_comments->m_arrComments.size(); comm++)
for (size_t comm = 0 ; comm < docx_document->m_pComments->m_arrComments.size(); comm++)
{
OOX::CComment* oox_comment = docx_comments->m_arrComments[comm];
OOX::CComment* oox_comment = docx_document->m_pComments->m_arrComments[comm];
if (oox_comment == NULL) continue;
if (oox_comment->m_oId.IsInit() == false) continue;
@ -3611,14 +3596,13 @@ void DocxConverter::convert_comment(int oox_comm_id)
}
void DocxConverter::convert_footnote(int oox_ref_id)
{
OOX::CFootnotes * footnotes = docx_document->GetFootnotes();
if (!footnotes)return;
if (!docx_document->m_pFootnotes)return;
odt_context->start_note(oox_ref_id, 1);
for (size_t n = 0 ; n < footnotes->m_arrFootnote.size(); n++)
for (size_t n = 0 ; n < docx_document->m_pFootnotes->m_arrFootnote.size(); n++)
{
OOX::CFtnEdn* oox_note = footnotes->m_arrFootnote[n];
OOX::CFtnEdn* oox_note = docx_document->m_pFootnotes->m_arrFootnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;
@ -3639,14 +3623,13 @@ void DocxConverter::convert_footnote(int oox_ref_id)
}
void DocxConverter::convert_endnote(int oox_ref_id)
{
OOX::CEndnotes * endnotes = docx_document->GetEndnotes();
if (!endnotes)return;
if (!docx_document->m_pEndnotes)return;
odt_context->start_note(oox_ref_id, 2);
for (size_t n = 0 ; n < endnotes->m_arrEndnote.size(); n++)
for (size_t n = 0 ; n < docx_document->m_pEndnotes->m_arrEndnote.size(); n++)
{
OOX::CFtnEdn* oox_note = endnotes->m_arrEndnote[n];
OOX::CFtnEdn* oox_note = docx_document->m_pEndnotes->m_arrEndnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;

View File

@ -32,9 +32,10 @@
#include "XlsxConverter.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Xlsx.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Workbook/Workbook.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Comments/Comments.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/SharedStrings/SharedStrings.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Styles/Styles.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/Worksheets/Worksheet.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/CalcChain/CalcChain.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinks.h"
#include "../../../Common/DocxFormat/Source/XlsxFormat/ExternalLinks/ExternalLinkPath.h"

View File

@ -53,7 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4996"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -23,8 +23,6 @@ DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
LIBXML_READER_ENABLED \
USE_LITE_READER \
_USE_XMLLITE_READER_ \
_PRESENTATION_WRITER_ \
_SVG_CONVERT_TO_IMAGE_ \
DONT_WRITE_EMBEDDED_FONTS

View File

@ -959,7 +959,7 @@ public:
case NSOfficeDrawing::adjust10Value:
{
LONG lIndexAdj = pProperty->m_ePID - NSOfficeDrawing::adjustValue;
if (lIndexAdj >= 0 && lIndexAdj < pShape->m_arAdjustments.size())
if (lIndexAdj >= 0 && lIndexAdj < (LONG)pShape->m_arAdjustments.size())
{
pShape->m_oCustomVML.LoadAdjusts(lIndexAdj, (LONG)pProperty->m_lValue);
}
@ -1639,7 +1639,7 @@ public:
}
//------ shape properties ----------------------------------------------------------------------------------------
for (int nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
for (size_t nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
{
CPPTElement oElement;
oElement.SetUpProperties(pElement, pTheme, pSlideWrapper, pSlide, &oArrayOptions[nIndexProp]->m_oProperties);
@ -1756,7 +1756,7 @@ public:
}
else
{//image, audio, video ....
for (int nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
for (size_t nIndexProp = 0; nIndexProp < oArrayOptions.size(); ++nIndexProp)
{
CPPTElement oElement;
oElement.SetUpProperties(pElement, pTheme, pSlideWrapper, pSlide, &oArrayOptions[nIndexProp]->m_oProperties);

View File

@ -70,7 +70,7 @@ public:
int sz = pStream->tell() - m_lOffsetInStream;
if (sz >= m_oHeader.RecLen)
if (sz >= (int)m_oHeader.RecLen)
break;
}
@ -85,7 +85,7 @@ public:
if (m_arrSIs.size() < 1) return;
int pos_text = 0, pos_si = 0;
int ind = 0;
size_t ind = 0;
for (size_t i = 0; i < pText->m_arParagraphs.size(); i++)
{

View File

@ -65,6 +65,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -937,6 +937,12 @@ void CDrawingConverter::SetEmbedDstPath(const std::wstring& sPath)
NSDirectory::CreateDirectory(sPath);
}
void CDrawingConverter::ClearShapeTypes()
{
m_mapShapeTypes.clear();
}
HRESULT CDrawingConverter::AddShapeType(const std::wstring& bsXml)
{
std::wstring strXml = L"<main ";
@ -974,20 +980,24 @@ HRESULT CDrawingConverter::AddShapeType(const std::wstring& bsXml)
if (oNode.IsValid())
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
XmlUtils::CXmlNode oNodeST = oNode.ReadNodeNoNS(L"shapetype");
std::wstring strId = oNodeST.GetAttribute(L"id");
pShape->LoadFromXMLShapeType(oNodeST);
CShapePtr pS = CShapePtr(new CShape(NSBaseShape::unknown, 0));
pS->setBaseShape(CBaseShapePtr(pShape));
LoadCoordSize(oNodeST, pS);
//if (m_mapShapeTypes.find(strId) == m_mapShapeTypes.end())//?? с затиранием ???
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
pShape->LoadFromXMLShapeType(oNodeST);
m_mapShapeTypes.insert(std::pair<std::wstring, CShapePtr>(strId, pS));
CShapePtr pS = CShapePtr(new CShape(NSBaseShape::unknown, 0));
pS->setBaseShape(CBaseShapePtr(pShape));
LoadCoordSize(oNodeST, pS);
m_mapShapeTypes.insert(std::make_pair(strId, pS));
}
}
return S_OK;
@ -1094,6 +1104,12 @@ PPTX::Logic::SpTreeElem CDrawingConverter::ObjectFromXml(const std::wstring& sXm
}
else if (strName == L"pict" || strName == L"object")
{
//сначала shape type
XmlUtils::CXmlNode oNodeST;
if (oParseNode.GetNode(L"v:shapetype", oNodeST))
{
AddShapeType(oNodeST.GetXml());
}
XmlUtils::CXmlNodes oChilds;
if (oParseNode.GetNodes(L"*", oChilds))
{
@ -1148,10 +1164,6 @@ PPTX::Logic::SpTreeElem CDrawingConverter::ObjectFromXml(const std::wstring& sXm
#endif
}
}
else if (L"shapetype" == strNameP)
{
AddShapeType(oNodeP.GetXml());
}
else
{
continue;
@ -1447,6 +1459,13 @@ bool CDrawingConverter::ParceObject(const std::wstring& strXml, std::wstring** p
}
else if (strName == L"pict" || strName == L"object")
{
//сначала shape type
XmlUtils::CXmlNode oNodeST;
if (oParseNode.GetNode(L"v:shapetype", oNodeST))
{
AddShapeType(oNodeST.GetXml());
}
XmlUtils::CXmlNodes oChilds;
if (oParseNode.GetNodes(L"*", oChilds))
{
@ -1487,10 +1506,6 @@ bool CDrawingConverter::ParceObject(const std::wstring& strXml, std::wstring** p
doc_LoadGroup(pElem, oNodeP, pMainProps, true);
}
}
else if (L"shapetype" == strNameP)
{
AddShapeType(oNodeP.GetXml());
}
else
{
continue;
@ -2817,6 +2832,13 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
if (bIsTop) pTree->m_lGroupIndex = 0;
else pTree->m_lGroupIndex = 1;
//сначала shape type
XmlUtils::CXmlNode oNodeST;
if (oNode.GetNode(L"v:shapetype", oNodeST))
{
AddShapeType(oNodeST.GetXml());
}
XmlUtils::CXmlNodes oNodes;
if (oNode.GetNodes(L"*", oNodes))
{
@ -2828,30 +2850,7 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
std::wstring strNameP = XmlUtils::GetNameNoNS(oNodeT.GetName());
if (L"shapetype" == strNameP)
{
//AddShapeType(oNodeT.GetXml());
std::wstring strId = oNodeT.GetAttribute(L"id");
if (strId.length() > 0)
{
if (m_mapShapeTypes.find(strId) == m_mapShapeTypes.end())
{
CPPTShape* pShape = new CPPTShape();
pShape->m_bIsShapeType = true;
pShape->LoadFromXMLShapeType(oNodeT);
CShapePtr pS = CShapePtr(new CShape(NSBaseShape::unknown, 0));
pS->setBaseShape(CBaseShapePtr(pShape));
LoadCoordSize(oNodeT, pS);
m_mapShapeTypes.insert(std::pair<std::wstring, CShapePtr>(strId, pS));
}
}
}
else if (L"shape" == strNameP ||
if (L"shape" == strNameP ||
L"rect" == strNameP ||
L"oval" == strNameP ||
L"line" == strNameP ||
@ -2873,6 +2872,8 @@ void CDrawingConverter::doc_LoadGroup(PPTX::Logic::SpTreeElem *result, XmlUtils:
if (_el.is_init())
pTree->SpTreeElems.push_back(_el);
}
else
continue;
}
}

View File

@ -225,7 +225,8 @@ namespace NSBinPptxRW
void SetMediaDstPath (const std::wstring& sMediaPath);
void SetEmbedDstPath (const std::wstring& sEmbedPath);
HRESULT AddShapeType (const std::wstring& sXml);
void ClearShapeTypes ();
HRESULT AddObject (const std::wstring& sXml, std::wstring** pMainProps);
HRESULT SaveObject (long lStart, long lLength, const std::wstring& sMainProps, std::wstring & sXml);
@ -293,6 +294,7 @@ namespace NSBinPptxRW
void Clear();
HRESULT SetCurrentRelsPath();
HRESULT AddShapeType (const std::wstring& sXml);
};
}
#endif //OOX_IFILE_CONTAINER_INCLUDE_H_

View File

@ -1280,6 +1280,14 @@ namespace NSBinPptxRW
m_pWriter->WriteString(strRels);
}
void CRelsGenerator::WritePresentationComments(int nComment)
{
std::wstring strRels = L"<Relationship Id=\"rId" + std::to_wstring( m_lNextRelsID++ ) +
L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\" Target=\"comments/comment" +
std::to_wstring(nComment) + L".xml\"/>";
m_pWriter->WriteString(strRels);
}
void CRelsGenerator::EndPresentationRels(bool bIsCommentsAuthors, bool bIsNotesMaster, bool bIsVbaProject, bool bIsJsaProject)
{
if (bIsNotesMaster)

View File

@ -424,6 +424,7 @@ namespace NSBinPptxRW
void WriteThemes (int nCount);
void WriteSlides (int nCount);
void WriteSlideComments (int nComment);
void WritePresentationComments (int nComment);
int WriteChart (int nChartNumber, _INT32 lDocType);
int WriteRels (const std::wstring& bsType, const std::wstring& bsTarget, const std::wstring& bsTargetMode);
int WriteHyperlink (const std::wstring& strLink, const bool& bIsActionInit);

View File

@ -822,6 +822,24 @@ namespace NSBinPptxRW
m_oPresentation.notesMasterIdLst[0].rid = (size_t)nCurrentRels;
++nCurrentRels;
}
if (m_oPresentation.comments.is_init())
{
m_oReader.m_pRels->WritePresentationComments(nComment);
OOX::CPath pathFolderCommentDir = m_strDstFolder + FILE_SEPARATOR_STR + _T("ppt") + FILE_SEPARATOR_STR + _T("comments");
if (1 == nComment)
{
NSDirectory::CreateDirectory (pathFolderCommentDir.GetPath());
}
std::wstring strCommentFile = L"comment" + std::to_wstring(nComment) + L".xml";
oXmlWriter.ClearNoAttack();
m_oPresentation.comments->toXmlWriter(&oXmlWriter);
OOX::CPath pathComment = pathFolderCommentDir + FILE_SEPARATOR_STR + strCommentFile;
oXmlWriter.SaveToFile(pathComment.GetPath());
++nComment;
}
m_oReader.m_pRels->EndPresentationRels(m_oPresentation.commentAuthors.is_init(), bNotesMasterPresent, m_oPresentation.m_pVbaProject.is_init(), m_oPresentation.m_pJsaProject.is_init());
m_oReader.m_pRels->CloseRels();

View File

@ -40,10 +40,12 @@
#include "../../Common/DocxFormat/Source/DocxFormat/Rels.h"
#include "../../Common/DocxFormat/Source/DocxFormat/ContentTypes.h"
#include "../../Common/DocxFormat/Source/DocxFormat/External/HyperLink.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Media.h"
#include "../../Common/DocxFormat/Source/DocxFormat/FileTypes.h"
#include "../../DesktopEditor/common/Directory.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/Image.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/OleObject.h"
#include <boost/unordered_map.hpp>
namespace PPTX
@ -87,12 +89,71 @@ namespace PPTX
void FileContainer::read(const OOX::CPath& filename)
{
//OOX::IFileContainer::read(filename);
}
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path)
{
}
const bool FileContainer::IsExist(const OOX::FileType& oType) const
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> pFile = m_arContainer[i];
if (oType == pFile->type())
return true;
}
return false;
}
smart_ptr<OOX::File> FileContainer::Get(const OOX::FileType& oType)
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> &pFile = m_arContainer[i];
if (oType == pFile->type())
return pFile;
}
return smart_ptr<OOX::File>(new OOX::UnknowTypeFile( m_oUnknown ));
}
void FileContainer::Get(const OOX::FileType& oType, std::vector<smart_ptr<OOX::File>> & files)
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> &pFile = m_arContainer[i];
if ( oType == pFile->type() )
files.push_back(pFile);
}
}
std::wstring FileContainer::GetImagePathNameFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::Image> p = IFileContainer::Get<OOX::Image>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
std::wstring FileContainer::GetLinkFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::External> pExt = Find(rid).smart_dynamic_cast<OOX::External>();
if (pExt.IsInit())
return pExt->Uri().m_strFilename;
smart_ptr<OOX::Media> pMedia = Find(rid).smart_dynamic_cast<OOX::Media>();
if (pMedia.IsInit())
return pMedia->filename().m_strFilename;
return _T("");
}
std::wstring FileContainer::GetOleFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::OleObject> p = IFileContainer::Get<OOX::OleObject>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
void FileContainer::read(const OOX::CRels& rels, const OOX::CPath& path, FileMap& map, IPPTXEvent* Event)
{
bool bIsSlide = false;

View File

@ -55,32 +55,14 @@ namespace PPTX
virtual ~FileContainer()
{
}
virtual std::wstring GetImagePathNameFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::Image> p = Get<OOX::Image>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
virtual std::wstring GetLinkFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::External> pExt = Find(rid).smart_dynamic_cast<OOX::External>();
if (pExt.IsInit())
return pExt->Uri().m_strFilename;
const bool IsExist(const OOX::FileType& oType) const;
smart_ptr<OOX::Media> pMedia = Find(rid).smart_dynamic_cast<OOX::Media>();
if (pMedia.IsInit())
return pMedia->filename().m_strFilename;
return _T("");
}
virtual std::wstring GetOleFromRId(const OOX::RId& rid)const
{
smart_ptr<OOX::OleObject> p = Get<OOX::OleObject>(rid);
if (!p.is_init())
return _T("");
return p->filename().m_strFilename;
}
smart_ptr<OOX::File> Get(const OOX::FileType& oType);
void Get(const OOX::FileType& oType, std::vector<smart_ptr<OOX::File>> & files);
virtual std::wstring GetImagePathNameFromRId(const OOX::RId& rid)const;
virtual std::wstring GetLinkFromRId (const OOX::RId& rid)const;
virtual std::wstring GetOleFromRId (const OOX::RId& rid)const;
protected:
void read(const OOX::CPath& filename);
void read(const OOX::CRels& rels, const OOX::CPath& path);

View File

@ -79,12 +79,13 @@ namespace PPTX
if (_presentation->IsExist(OOX::FileTypes::VbaProject))
{
_presentation->m_bMacroEnabled = true;
_presentation->m_pVbaProject = _presentation->Get(OOX::FileTypes::VbaProject).smart_dynamic_cast<OOX::VbaProject>();
_presentation->m_pVbaProject = _presentation->Get(OOX::FileTypes::VbaProject).smart_dynamic_cast<OOX::VbaProject>();
}
if (_presentation->IsExist(OOX::FileTypes::JsaProject))
{
_presentation->m_pJsaProject = _presentation->Get(OOX::FileTypes::JsaProject).smart_dynamic_cast<OOX::JsaProject>();
_presentation->m_pJsaProject = _presentation->Get(OOX::FileTypes::JsaProject).smart_dynamic_cast<OOX::JsaProject>();
}
_presentation->comments = _presentation->Get(OOX::Presentation::FileTypes::SlideComments).smart_dynamic_cast<PPTX::Comments>();
}
for (std::map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = map.m_map.begin(); pPair != map.m_map.end(); ++pPair)
@ -190,17 +191,17 @@ namespace PPTX
return true;//FileContainer::exist(OOX::Presentation::FileTypes::Presentation);
}
void Document::extractPictures(const OOX::CPath& path)
{
OOX::CSystemUtility::CreateDirectories(path);
FileContainer::ExtractPictures(path);
}
//void Document::extractPictures(const OOX::CPath& path)
//{
// OOX::CSystemUtility::CreateDirectories(path);
// FileContainer::ExtractPictures(path);
//}
void Document::extractPictures(const OOX::CPath& source, const OOX::CPath& path)
{
//read(source);
extractPictures(path);
}
//void Document::extractPictures(const OOX::CPath& source, const OOX::CPath& path)
//{
// //read(source);
// extractPictures(path);
//}
long Document::CountFiles(const OOX::CPath& path)
{

View File

@ -50,8 +50,8 @@ namespace PPTX
const bool isValid(const OOX::CPath& path) const;
void extractPictures(const OOX::CPath& path);
void extractPictures(const OOX::CPath& source, const OOX::CPath& path);
//void extractPictures(const OOX::CPath& path);
//void extractPictures(const OOX::CPath& source, const OOX::CPath& path);
private:
long CountFiles(const OOX::CPath& path);
};

View File

@ -135,8 +135,14 @@ namespace PPTX
{
smart_ptr<OOX::OleObject> pOleObject;
if (pRels != NULL) pOleObject = pRels->Get<OOX::OleObject>(oRId);
else if(parentFileIs<FileContainer>()) pOleObject = parentFileAs<FileContainer>().Get<OOX::OleObject>(oRId);
if (pRels != NULL)
pOleObject = pRels->Get<OOX::OleObject>(oRId);
else
{
OOX::IFileContainer* pContainer = dynamic_cast<OOX::IFileContainer*>(const_cast<PPTX::WrapperFile*>(parentFile));
if (pContainer)
pOleObject = pContainer->Get<OOX::OleObject>(oRId);
}
if (pOleObject.IsInit())
return pOleObject->filename().m_strFilename;

View File

@ -503,12 +503,14 @@ namespace PPTX
smart_ptr<OOX::OleObject> ole_file = m_OleObjectFile;
if (ole_file.IsInit() == false)
{
if (pRels != NULL) ole_file = pRels->Get<OOX::OleObject>(oRId);
else if(parentFileIs<Slide>()) ole_file = parentFileAs<Slide>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<SlideLayout>()) ole_file = parentFileAs<SlideLayout>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<SlideMaster>()) ole_file = parentFileAs<SlideMaster>().Get<OOX::OleObject>(oRId);
else if(parentFileIs<Theme>()) ole_file = parentFileAs<Theme>().Get<OOX::OleObject>(oRId);
if (pRels != NULL)
ole_file = pRels->Get<OOX::OleObject>(oRId);
else
{
OOX::IFileContainer* pContainer = dynamic_cast<OOX::IFileContainer*>(const_cast<PPTX::WrapperFile*>(parentFile));
if (pContainer)
ole_file = pContainer->Get<OOX::OleObject>(oRId);
}
}
return ole_file;
}

View File

@ -49,6 +49,7 @@
#include "Logic/ClrMap.h"
#include "Logic/ExtP.h"
#include "Theme/ClrScheme.h"
#include "Comments.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/VbaProject.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Media/JsaProject.h"
@ -72,8 +73,6 @@ namespace PPTX
}
virtual void read(const OOX::CPath& filename, FileMap& map)
{
//FileContainer::read(filename, map);
XmlUtils::CXmlNode oNode;
oNode.FromXmlFile(filename.m_strFilename);
@ -235,6 +234,7 @@ namespace PPTX
pWriter->EndRecord();
}
pWriter->WriteRecord2(9, m_pJsaProject);
pWriter->WriteRecord2(10, comments);
pWriter->EndRecord();
}
@ -362,6 +362,11 @@ namespace PPTX
smart_ptr<OOX::File> file = m_pJsaProject.smart_dynamic_cast<OOX::File>();
FileContainer::Add(file);
}break;
case 10:
{
comments = new PPTX::Comments(OOX::File::m_pMainDocument);
comments->fromPPTY(pReader);
}break;
default:
{
pReader->SkipRecord();
@ -479,6 +484,7 @@ namespace PPTX
bool m_bMacroEnabled;
smart_ptr<OOX::VbaProject> m_pVbaProject;
smart_ptr<OOX::JsaProject> m_pJsaProject;
smart_ptr<PPTX::Comments> comments;
void SetClrMap(Logic::ClrMap map) {m_clrMap = map;}
void SetClrScheme(nsTheme::ClrScheme scheme) {m_clrScheme = scheme;}

View File

@ -26,8 +26,6 @@ include($$PWD/../../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML \
#DISABLE_FILE_DOWNLOADER \
CXIMAGE_DONT_DECLARE_TCHAR \

View File

@ -54,6 +54,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -21,8 +21,6 @@ include($$PWD/../../../Common/3dParty/boost/boost.pri)
DEFINES += UNICODE _UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS \
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML

View File

@ -51,6 +51,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -52,7 +52,7 @@ bool OOXHeaderReader::Parse( ReaderParameter oParam, std::wstring sRID, TextItem
oOOXTextItemReader.Parse(*it, oParam );
}
oParam.oReader->m_currentContainer = dynamic_cast<OOX::IFileContainer*>(oParam.oDocx->GetDocument());
oParam.oReader->m_currentContainer = dynamic_cast<OOX::IFileContainer*>(oParam.oDocx->m_pDocument);
return true;
}

View File

@ -59,75 +59,65 @@ bool OOXReader::Parse()
oReaderParameter.oRtf = &m_oDocument;
oReaderParameter.oReader = this;
OOX::CSettings* settings = inputDocxFile.GetSettings();
if (settings)
if (inputDocxFile.m_pSettings)
{ //важно чтобы первыми читались именно settings (например для footnote)
OOXSettingsReader oSettingsReader( settings );
OOXSettingsReader oSettingsReader( inputDocxFile.m_pSettings );
oSettingsReader.Parse( oReaderParameter );
}
OOX::CFontTable* fontTable = inputDocxFile.GetFontTable();
if (fontTable)
if (inputDocxFile.m_pFontTable)
{
OOXFontTableReader oFontTableReader( fontTable );
OOXFontTableReader oFontTableReader( inputDocxFile.m_pFontTable );
oFontTableReader.Parse( oReaderParameter );
}
PPTX::Theme* theme = inputDocxFile.GetTheme();
if (theme)
if (inputDocxFile.m_pTheme)
{
OOXThemeReader oThemeReader( theme );
OOXThemeReader oThemeReader( inputDocxFile.m_pTheme );
oThemeReader.Parse( oReaderParameter );
}
OOX::CNumbering* numbering = inputDocxFile.GetNumbering();
if (numbering)
if (inputDocxFile.m_pNumbering)
{
OOXNumberingReader oNumberingReader( numbering );
OOXNumberingReader oNumberingReader( inputDocxFile.m_pNumbering );
oNumberingReader.Parse(oReaderParameter );
}
OOX::CStyles* styles = inputDocxFile.GetStyles();
if (styles)
if (inputDocxFile.m_pStyles)
{
OOXStyleTableReader oStyleTableReader( styles );
OOXStyleTableReader oStyleTableReader( inputDocxFile.m_pStyles );
oStyleTableReader.Parse( oReaderParameter );
}
OOX::CApp* app = inputDocxFile.GetApp();
if (app)
if (inputDocxFile.m_pApp)
{
OOXAppReader oDocPropAppReader( app );
OOXAppReader oDocPropAppReader( inputDocxFile.m_pApp );
oDocPropAppReader.Parse( oReaderParameter );
}
OOX::CCore* core = inputDocxFile.GetCore();
if (core)
if (inputDocxFile.m_pCore)
{
OOXCoreReader oDocPropCoreReader( core);
OOXCoreReader oDocPropCoreReader( inputDocxFile.m_pCore );
oDocPropCoreReader.Parse(oReaderParameter );
}
OOX::CFootnotes* footnotes = inputDocxFile.GetFootnotes();
if (footnotes)
if (inputDocxFile.m_pFootnotes)
{
OOXFootnotesReader oFootnotesReader( footnotes );
OOXFootnotesReader oFootnotesReader( inputDocxFile.m_pFootnotes );
oFootnotesReader.Parse( oReaderParameter);
}
OOX::CEndnotes* endnotes = inputDocxFile.GetEndnotes();
if (endnotes)
if (inputDocxFile.m_pEndnotes)
{
OOXFootnotesReader oEndnotesReader( endnotes );
OOXFootnotesReader oEndnotesReader( inputDocxFile.m_pEndnotes );
oEndnotesReader.Parse( oReaderParameter);
}
OOX::CDocument* document = inputDocxFile.GetDocument();
if (document)
if (inputDocxFile.m_pDocument)
{
m_currentContainer = dynamic_cast<OOX::IFileContainer*>(document);
m_currentContainer = dynamic_cast<OOX::IFileContainer*>(inputDocxFile.m_pDocument);
OOXDocumentReader oDocReader( document );
OOXDocumentReader oDocReader( inputDocxFile.m_pDocument );
oDocReader.Parse( oReaderParameter );
}

View File

@ -979,8 +979,7 @@ void OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::
int fmt_index = style_ref->idx.get() -1;
PPTX::Theme *theme = oParam.oDocx->GetTheme();
if (!theme || fmt_index <0) return;
if (!oParam.oDocx->m_pTheme || fmt_index <0) return;
if (style_ref->Color.is<PPTX::Logic::SchemeClr>() == false) return;
@ -990,21 +989,21 @@ void OOXShapeReader::Parse( ReaderParameter oParam, RtfShapePtr& pOutput, PPTX::
if (type == 1)
{
if (fmt_index < 1000 && fmt_index < theme->themeElements.fmtScheme.fillStyleLst.size())
if (fmt_index < 1000 && fmt_index < oParam.oDocx->m_pTheme->themeElements.fmtScheme.fillStyleLst.size())
{
Parse(oParam, pOutput, &theme->themeElements.fmtScheme.fillStyleLst[fmt_index], &color);
Parse(oParam, pOutput, &oParam.oDocx->m_pTheme->themeElements.fmtScheme.fillStyleLst[fmt_index], &color);
}
else if (fmt_index > 1000 && ((fmt_index-1000) < theme->themeElements.fmtScheme.bgFillStyleLst.size()))
else if (fmt_index > 1000 && ((fmt_index-1000) < oParam.oDocx->m_pTheme->themeElements.fmtScheme.bgFillStyleLst.size()))
{
fmt_index -= 1000;
Parse(oParam, pOutput, &theme->themeElements.fmtScheme.bgFillStyleLst[fmt_index], &color);
Parse(oParam, pOutput, &oParam.oDocx->m_pTheme->themeElements.fmtScheme.bgFillStyleLst[fmt_index], &color);
}
}
if (type == 2 && fmt_index < theme->themeElements.fmtScheme.lnStyleLst.size())
if (type == 2 && fmt_index < oParam.oDocx->m_pTheme->themeElements.fmtScheme.lnStyleLst.size())
{
Parse(oParam, pOutput, &theme->themeElements.fmtScheme.lnStyleLst[fmt_index], &color);
Parse(oParam, pOutput, &oParam.oDocx->m_pTheme->themeElements.fmtScheme.lnStyleLst[fmt_index], &color);
}
//if (style_matrix_ref->getType() == OOX::et_a_effectRef && fmt_index < theme->m_oThemeElements.m_oFmtScheme.m_oEffectStyleLst.m_arrEffectStyle.size())

View File

@ -19,8 +19,6 @@ include(../../../Common/base.pri)
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
DONT_WRITE_EMBEDDED_FONTS \
LIBXML_READER_ENABLED

View File

@ -169,58 +169,48 @@ namespace Docx2Txt
void Converter_Impl::convert(TxtXml::ITxtXmlEvent& Event)
{
OOX::CDocument *pDocument = NULL;
OOX::CStyles *pStyles = NULL;
OOX::CNumbering *pNumbering = NULL;
m_lPercent = 100000;
m_bCancelled = Event.Progress(0, m_lPercent);
if(m_bCancelled)
return;
smart_ptr<OOX::File> pFileD = m_inputFile.Find(OOX::FileTypes::Document);
if (pFileD.IsInit() && OOX::FileTypes::Document == pFileD->type())
pDocument = (OOX::CDocument*)pFileD.operator->();
smart_ptr<OOX::File> pFileS = pDocument->Find(OOX::FileTypes::Style);
if (pFileS.IsInit() && OOX::FileTypes::Style == pFileS->type())
pStyles = (OOX::CStyles*)pFileS.operator->();
OOX::CDocument *pDocument = m_inputFile.m_pDocument;
OOX::CStyles *pStyles = m_inputFile.m_pStyles;
OOX::CNumbering *pNumbering = m_inputFile.m_pNumbering;
smart_ptr<OOX::File> pFileN = pDocument->Find(OOX::FileTypes::Numbering);
if (pFileN.IsInit() && OOX::FileTypes::Numbering == pFileN->type())
if (pNumbering)
{
pNumbering = (OOX::CNumbering*)pFileN.operator->();
ListCount = pNumbering->m_arrNum.size();
Lists = new int[9 * ListCount];
if(Lists == NULL)
return;
for(int i = 0; i < 9 * ListCount; i++)
for (int i = 0; i < 9 * ListCount; i++)
Lists[i] = 0;
}
if(pDocument->m_arrItems.size() > 0)
{
m_lAddition = 800000;
Notes.clear();
convert(pDocument->m_arrItems, m_outputFile.m_listContent, Event, true, pDocument, pNumbering, pStyles);
if(NoteCount != 0)
if (!pDocument) return;
if (pDocument->m_arrItems.empty()) return;
m_lAddition = 800000;
Notes.clear();
convert(pDocument->m_arrItems, m_outputFile.m_listContent, Event, true, pDocument, pNumbering, pStyles);
if(NoteCount != 0)
{
m_outputFile.m_listContent.push_back(L"");
m_outputFile.m_listContent.push_back(L"---------------------------");
for(std::map<std::wstring, std::vector<std::wstring>>::const_iterator iter_map = Notes.begin(); iter_map != Notes.end(); iter_map++)
{
m_outputFile.m_listContent.push_back(L"");
m_outputFile.m_listContent.push_back(L"---------------------------");
bool bFirst = true;
for(std::map<std::wstring, std::vector<std::wstring>>::const_iterator iter_map = Notes.begin(); iter_map != Notes.end(); iter_map++)
for(std::vector<std::wstring>::const_iterator iter = iter_map->second.begin(); iter != iter_map->second.end(); iter++)
{
bool bFirst = true;
if (bFirst) m_outputFile.m_listContent.push_back(iter_map->first + L" " + *iter);
else m_outputFile.m_listContent.push_back(*iter);
for(std::vector<std::wstring>::const_iterator iter = iter_map->second.begin(); iter != iter_map->second.end(); iter++)
{
if (bFirst) m_outputFile.m_listContent.push_back(iter_map->first + L" " + *iter);
else m_outputFile.m_listContent.push_back(*iter);
bFirst = false;
}
bFirst = false;
}
}
}
@ -473,22 +463,21 @@ namespace Docx2Txt
bool inField = false;
for (std::vector<OOX::WritingElement*>::iterator it = pParagraph->m_arrItems.begin();
it != pParagraph->m_arrItems.end(); ++it)
for (size_t i = 0; i < pParagraph->m_arrItems.size(); ++i)
{
if (*it== NULL) continue;
if (pParagraph->m_arrItems[i] == NULL) continue;
if ((*it)->getType() == OOX::et_w_r)
if (pParagraph->m_arrItems[i]->getType() == OOX::et_w_r)
{
OOX::Logic::CRun *run = dynamic_cast<OOX::Logic::CRun*>(*it);
OOX::Logic::CRun *run = dynamic_cast<OOX::Logic::CRun*>(pParagraph->m_arrItems[i]);
for (std::vector<OOX::WritingElement*>::iterator jt = run->m_arrItems.begin(); jt != run->m_arrItems.end(); jt++)
for (size_t j = 0; j < run->m_arrItems.size(); ++j)
{
if (*jt== NULL) continue;
if (run->m_arrItems[j] == NULL) continue;
if ((*jt)->getType() == OOX::et_w_fldChar)
if (run->m_arrItems[j]->getType() == OOX::et_w_fldChar)
{
OOX::Logic::CFldChar *fldChar = dynamic_cast<OOX::Logic::CFldChar*>(*jt);
OOX::Logic::CFldChar *fldChar = dynamic_cast<OOX::Logic::CFldChar*>(run->m_arrItems[j]);
if ((fldChar) && (fldChar->m_oFldCharType.IsInit()))
{
@ -503,13 +492,13 @@ namespace Docx2Txt
if ((run->m_oRunProperty) && (run->m_oRunProperty->m_oCaps.Init()) && (run->m_oRunProperty->m_oCaps->m_oVal.ToBool())) caps = true;
std::wstring wstr;
if ((*jt)->getType() == OOX::et_w_tab)
if (run->m_arrItems[j]->getType() == OOX::et_w_tab)
{
wstr = L"\x09";
}
else if ((*jt)->getType() == OOX::et_w_t)
else if (run->m_arrItems[j]->getType() == OOX::et_w_t)
{
OOX::Logic::CText* text = dynamic_cast<OOX::Logic::CText*>(*jt);
OOX::Logic::CText* text = dynamic_cast<OOX::Logic::CText*>(run->m_arrItems[j]);
wstr = text->m_sText;
if(caps)
{
@ -518,49 +507,38 @@ namespace Docx2Txt
}
}
if ((*jt)->getType() == OOX::et_w_footnoteReference || (*it)->getType() == OOX::et_w_endnoteReference)
if (run->m_arrItems[j]->getType() == OOX::et_w_footnoteReference ||
pParagraph->m_arrItems[i]->getType() == OOX::et_w_endnoteReference)
{// todooo Ref ????
std::vector<std::wstring> notes_content;
OOX::Logic::CFootnoteReference* footnote_ref = dynamic_cast<OOX::Logic::CFootnoteReference*>(*jt);
OOX::Logic::CEndnoteReference* endnote_ref = dynamic_cast<OOX::Logic::CEndnoteReference*>(*jt);
OOX::Logic::CFootnoteReference* footnote_ref = dynamic_cast<OOX::Logic::CFootnoteReference*>(run->m_arrItems[j]);
OOX::Logic::CEndnoteReference* endnote_ref = dynamic_cast<OOX::Logic::CEndnoteReference*>(run->m_arrItems[j]);
NoteCount++;
if (footnote_ref)
{
smart_ptr<OOX::File> pFile = pDocument->Find(OOX::FileTypes::FootNote);
if (pFile.IsInit())
if (footnote_ref && m_inputFile.m_pFootnotes)
{
for (size_t r = 0; r < m_inputFile.m_pFootnotes->m_arrFootnote.size(); r++)
{
OOX::CFootnotes *pFootnotes = (OOX::CFootnotes*)pFile.operator->();
for (size_t r = 0; r < pFootnotes->m_arrFootnote.size(); r++)
{
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(pFootnotes->m_arrFootnote[r]);
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(m_inputFile.m_pFootnotes->m_arrFootnote[r]);
if (note && note->m_oId == footnote_ref->m_oId)
{
convert(pFootnotes->m_arrFootnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
if (note && note->m_oId == footnote_ref->m_oId)
{
convert(m_inputFile.m_pFootnotes->m_arrFootnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
}
Notes.insert(std::make_pair(ToWString(NoteCount), notes_content));
}
if (endnote_ref)
if (endnote_ref && m_inputFile.m_pEndnotes)
{
smart_ptr<OOX::File> pFile = pDocument->Find(OOX::FileTypes::EndNote);
if (pFile.IsInit())
for (size_t r =0; r < m_inputFile.m_pEndnotes->m_arrEndnote.size(); r++)
{
OOX::CEndnotes *pEndnotes = (OOX::CEndnotes*)pFile.operator->();
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(m_inputFile.m_pEndnotes->m_arrEndnote[r]);
for (size_t r =0; r < pEndnotes->m_arrEndnote.size(); r++)
if (note && note->m_oId == endnote_ref->m_oId)
{
OOX::CFtnEdn* note = dynamic_cast<OOX::CFtnEdn*>(pEndnotes->m_arrEndnote[r]);
if (note && note->m_oId == endnote_ref->m_oId)
{
convert(pEndnotes->m_arrEndnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
convert(m_inputFile.m_pEndnotes->m_arrEndnote[r]->m_arrItems, notes_content, Event, false, pDocument, pNumbering, pStyles);
}
}
Notes.insert(std::make_pair(ToWString(NoteCount), notes_content));

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,6 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -346,6 +346,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -18,8 +18,6 @@ include(../../../Common/base.pri)
DEFINES += UNICODE _UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
LIBXML_READER_ENABLED \
DONT_WRITE_EMBEDDED_FONTS
@ -52,6 +50,7 @@ SOURCES += \
../Source/DocxFormat/Logic/Table.cpp \
../Source/DocxFormat/Logic/TableProperty.cpp \
../Source/DocxFormat/Logic/Vml.cpp \
../Source/DocxFormat/Media/VbaProject.cpp \
../Source/DocxFormat/Math/oMath.cpp \
../Source/DocxFormat/Math/oMathContent.cpp \
../Source/DocxFormat/Math/oMathPara.cpp \
@ -60,6 +59,7 @@ SOURCES += \
../Source/XlsxFormat/Chart/ChartSerialize.cpp \
../Source/XlsxFormat/Common.cpp \
../Source/XlsxFormat/Xlsx.cpp \
../Source/XlsxFormat/Worksheets/Worksheet.cpp \
../Source/XlsxFormat/Worksheets/SheetData.cpp \
../Source/DocxFormat/FileFactory.cpp \
../Source/DocxFormat/IFileContainer.cpp \
@ -70,7 +70,6 @@ SOURCES += \
../Source/Common/Index.cpp \
../Source/Common/NumFormat.cpp \
../Source/Common/Position.cpp \
../Source/Common/Utils.cpp \
../Source/Common/Wrap.cpp \
../Source/Common/ZIndex.cpp \
../Source/Common/SimpleTypes_Word.cpp \
@ -106,7 +105,6 @@ HEADERS += docxformatlib.h \
../Source/Common/SimpleTypes_Word.h \
../Source/Common/Size.h \
../Source/Common/Unit.h \
../Source/Common/Utils.h \
../Source/Common/Wrap.h \
../Source/Common/ZIndex.h \
../Source/DocxFormat/Drawing/Drawing.h \
@ -231,6 +229,7 @@ HEADERS += docxformatlib.h \
../Source/XlsxFormat/SimpleTypes_Spreadsheet.h \
../Source/XlsxFormat/Workbook.h \
../Source/XlsxFormat/WritingElement.h \
../Source/DocxFormat/WorkbookComments.h \
../Source/XlsxFormat/Xlsx.h \
../Source/XML/Utils.h \
../Source/XML/XmlSimple.h \

View File

@ -48,23 +48,24 @@
#include "../Source/DocxFormat/Math/oMath.cpp"
#include "../Source/DocxFormat/Math/oMathContent.cpp"
#include "../Source/DocxFormat/Math/oMathPara.cpp"
#include "../Source/MathEquation/MathEquation.cpp"
#include "../Source/DocxFormat/Media/VbaProject.cpp"
#include "../Source/DocxFormat/Docx.cpp"
#include "../Source/XlsxFormat/Chart/ChartSerialize.cpp"
#include "../Source/XlsxFormat/Common.cpp"
#include "../Source/DocxFormat/FileFactory.cpp"
#include "../Source/DocxFormat/IFileContainer.cpp"
#include "../Source/XlsxFormat/FileFactory_Spreadsheet.cpp"
#include "../Source/DocxFormat/Drawing/DrawingExt.cpp"
#include "../Source/MathEquation/MathEquation.cpp"
#include "../Source/Common/Align.cpp"
#include "../Source/Common/Color.cpp"
#include "../Source/Common/Index.cpp"
#include "../Source/Common/NumFormat.cpp"
#include "../Source/Common/Position.cpp"
#include "../Source/Common/Utils.cpp"
#include "../Source/Common/Wrap.cpp"
#include "../Source/Common/ZIndex.cpp"
#include "../Source/Common/SimpleTypes_Word.cpp"
#include "../Source/SystemUtility/SystemUtility.cpp"
#include "../Source/XlsxFormat/Chart/ChartSerialize.cpp"
#include "../Source/XlsxFormat/Common.cpp"
#include "../Source/XlsxFormat/FileFactory_Spreadsheet.cpp"
#include "../Source/XlsxFormat/Xlsx.cpp"
#include "../Source/XlsxFormat/Worksheets/SheetData.cpp"
#include "../Source/XlsxFormat/Worksheets/Worksheet.cpp"

View File

@ -44,7 +44,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS"
PreprocessorDefinitions="_USE_LIBXML2_READER_;LIBXML_READER_ENABLED;DONT_WRITE_EMBEDDED_FONTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -52,6 +52,7 @@
ProgramDataBaseFileName="$(IntDir)\DocxFormat.pdb"
WarningLevel="3"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -113,7 +114,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
PreprocessorDefinitions="_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -180,7 +181,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories=".\..\Source\XML\libxml2\XML\include;.\..\Source\Utility;.\..\Source\XML;.\..\Source\Common;..\..\..\..\..\Redist;..\..\ASCOfficeOdtFile\Source\OfficeSvmFile"
PreprocessorDefinitions="USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
PreprocessorDefinitions="_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
ProgramDataBaseFileName="$(IntDir)\DocxFormat.pdb"
@ -245,7 +246,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories=".\..\Source\XML\libxml2\XML\include;.\..\Source\Utility;.\..\Source\XML;.\..\Source\Common;..\..\..\..\..\Redist;..\..\ASCOfficeOdtFile\Source\OfficeSvmFile"
PreprocessorDefinitions="USE_LITE_READER;_USE_XMLLITE_READER_;_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
PreprocessorDefinitions="_USE_LIBXML2_READER_;LIBXML_READER_ENABLED"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
ProgramDataBaseFileName="$(IntDir)\DocxFormat.pdb"
@ -1204,6 +1205,10 @@
RelativePath="..\Source\DocxFormat\Media\OleObject.h"
>
</File>
<File
RelativePath="..\Source\DocxFormat\Media\VbaProject.cpp"
>
</File>
<File
RelativePath="..\Source\DocxFormat\Media\VbaProject.h"
>
@ -1376,14 +1381,6 @@
RelativePath="..\Source\Common\Unit.h"
>
</File>
<File
RelativePath="..\Source\Common\Utils.cpp"
>
</File>
<File
RelativePath="..\Source\Common\Utils.h"
>
</File>
<File
RelativePath="..\Source\Common\Wrap.cpp"
>
@ -1679,6 +1676,10 @@
RelativePath="..\Source\XlsxFormat\Worksheets\SheetData.h"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\Worksheets\Worksheet.cpp"
>
</File>
<File
RelativePath="..\Source\XlsxFormat\Worksheets\Worksheet.h"
>

View File

@ -145,7 +145,6 @@ namespace NSCommon
this->m_pPointer = new Type(oNode);
return *this;
}
#ifdef _USE_XMLLITE_READER_
nullable<Type>& operator=(XmlUtils::CXmlLiteReader& oReader)
{
RELEASEOBJECT(this->m_pPointer);
@ -153,7 +152,6 @@ namespace NSCommon
this->m_pPointer = new Type(oReader);
return *this;
}
#endif
nullable<Type>& operator=(const wchar_t* cwsValue)
{
RELEASEOBJECT(this->m_pPointer);

View File

@ -1,56 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "Utils.h"
#include "../../../DesktopEditor/xml/include/xmlutils.h"
void Common::readAllShapeTypes(const OOX::CPath& oPath, std::vector<std::wstring>& aShapetypes)
{
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
while ( false != oReader.ReadNextNode() )
{
std::wstring sName = oReader.GetName();
if(_T("v:shapetype") == sName)
{
std::wstring sXml = oReader.GetOuterXml();
if(false == sXml.empty())
aShapetypes.push_back(sXml);
}
}
}

View File

@ -1,44 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef COMMON_UTILS_INCLUDE_H_
#define COMMON_UTILS_INCLUDE_H_
#include "../SystemUtility/SystemUtility.h"
#include <vector>
namespace Common
{
void readAllShapeTypes(const OOX::CPath& oPath, std::vector<std::wstring>& aShapetypes);
} // namespace Common
#endif // COMMON_UTILS_INCLUDE_H_

View File

@ -320,8 +320,6 @@ namespace OOX
}
virtual void read(const CPath& oFilePath)
{
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -341,7 +339,6 @@ namespace OOX
m_arrComments.push_back( new CComment(oReader) );
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
@ -436,8 +433,6 @@ namespace OOX
}
virtual void read(const CPath& oFilePath)
{
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -457,7 +452,6 @@ namespace OOX
m_arrComments.push_back( new CCommentExt(oReader) );
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
@ -598,7 +592,6 @@ namespace OOX
}
virtual void read(const CPath& oFilePath)
{
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -618,7 +611,6 @@ namespace OOX
m_arrPeoples.push_back( new CPerson(oReader) );
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const

View File

@ -186,9 +186,8 @@ namespace OOX
virtual void read(const CPath& oRootPath, const CPath& oFilePath)
{
IFileContainer::Read( oRootPath, oFilePath );
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
return;
@ -220,7 +219,6 @@ namespace OOX
}
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const

View File

@ -37,7 +37,6 @@
#include "../Common/SimpleTypes_Word.h"
#include "../Common/SimpleTypes_Shared.h"
#include "../Common/Utils.h"
#include "WritingElement.h"
#include "File.h"
@ -73,8 +72,6 @@ namespace OOX
virtual ~CBackground()
{
}
public:
virtual void fromXML(XmlUtils::CXmlNode& oNode)
{
oNode.ReadAttributeBase( _T("w:color"), m_oColor );
@ -203,14 +200,14 @@ namespace OOX
{
m_bMacroEnabled = false;
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
CDocx* docx = dynamic_cast<CDocx*>(pMain);
if (docx) docx->m_pDocument = this;
}
CDocument(OOX::Document *pMain, const CPath& oRootPath, const CPath& oPath) : File(pMain), IFileContainer(pMain)
{
m_bMacroEnabled = false;
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
CDocx* docx = dynamic_cast<CDocx*>(pMain);
if (docx) docx->m_pDocument = this;
read( oRootPath, oPath );
@ -320,12 +317,11 @@ namespace OOX
m_oReadPath = oPath;
IFileContainer::Read( oRootPath, oPath );
if (IFileContainer::IsExist(OOX::FileTypes::VbaProject))
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if ( (docx ) && (docx->m_pVbaProject) )
{
m_bMacroEnabled = true;
}
#ifdef USE_LITE_READER
Common::readAllShapeTypes(oPath, m_arrShapeTypes);
}
XmlUtils::CXmlLiteReader oReader;
@ -358,104 +354,6 @@ namespace OOX
}
}
}
#else
XmlUtils::CXmlNode oDocument;
oDocument.FromXmlFile2( oPath.GetPath() );
if ( _T("w:document") == oDocument.GetName() )
{
oDocument.ReadAttributeBase( _T("w:conformance"), m_oConformance );
XmlUtils::CXmlNode oBackground;
if ( oDocument.GetNode( _T("w:background"), oBackground ) )
m_oBackground = oBackground;
XmlUtils::CXmlNode oBody;
if ( oDocument.GetNode( _T("w:body"), oBody ) )
{
XmlUtils::CXmlNodes oBodyChilds;
if ( oBody.GetNodes( _T("*"), oBodyChilds ) )
{
XmlUtils::CXmlNode oItem;
for (unsigned int nIndex = 0; nIndex < oBodyChilds.GetCount(); nIndex++ )
{
if ( oBodyChilds.GetAt( nIndex, oItem ) )
{
std::wstring sName = oItem.GetName();
WritingElement *pItem = NULL;
/*if ( _T("w:altChunk") == sName )
pItem = new Logic::CAltChunk( oItem );
else*/ if ( _T("w:bookmarkEnd") == sName )
pItem = new Logic::CBookmarkEnd( oItem );
else if ( _T("w:bookmarkStart") == sName )
pItem = new Logic::CBookmarkStart( oItem );
else if ( _T("w:commentRangeEnd") == sName )
pItem = new Logic::CCommentRangeEnd( oItem );
else if ( _T("w:commentRangeStart") == sName )
pItem = new Logic::CCommentRangeStart( oItem );
//else if ( _T("w:customXml") == sName )
// pItem = new Logic::CCustomXml( oItem );
else if ( _T("w:customXmlDelRangeEnd") == sName )
pItem = new Logic::CCustomXmlDelRangeEnd( oItem );
else if ( _T("w:customXmlDelRangeStart") == sName )
pItem = new Logic::CCustomXmlDelRangeStart( oItem );
else if ( _T("w:customXmlInsRangeEnd") == sName )
pItem = new Logic::CCustomXmlInsRangeEnd( oItem );
else if ( _T("w:customXmlInsRangeStart") == sName )
pItem = new Logic::CCustomXmlInsRangeStart( oItem );
else if ( _T("w:customXmlMoveFromRangeEnd") == sName )
pItem = new Logic::CCustomXmlMoveFromRangeEnd( oItem );
else if ( _T("w:customXmlMoveFromRangeStart") == sName )
pItem = new Logic::CCustomXmlMoveFromRangeStart( oItem );
else if ( _T("w:customXmlMoveToRangeEnd") == sName )
pItem = new Logic::CCustomXmlMoveToRangeEnd( oItem );
else if ( _T("w:customXmlMoveToRangeStart") == sName )
pItem = new Logic::CCustomXmlMoveToRangeStart( oItem );
//else if ( _T("w:del") == sName )
// pItem = new Logic::CDel( oItem );
//else if ( _T("w:ins") == sName )
// pItem = new Logic::CIns( oItem );
//else if ( _T("w:moveFrom") == sName )
// pItem = new Logic::CMoveFrom( oItem );
else if ( _T("w:moveFromRangeEnd") == sName )
pItem = new Logic::CMoveFromRangeEnd( oItem );
else if ( _T("w:moveFromRangeStart") == sName )
pItem = new Logic::CMoveFromRangeStart( oItem );
//else if ( _T("w:moveTo") == sName )
// pItem = new Logic::CMoveTo( oItem );
else if ( _T("w:moveToRangeEnd") == sName )
pItem = new Logic::CMoveToRangeEnd( oItem );
else if ( _T("w:moveToRangeStart") == sName )
pItem = new Logic::CMoveToRangeStart( oItem );
else if ( _T("m:oMath") == sName )
pItem = new Logic::COMath( oItem );
else if ( _T("m:oMathPara") == sName )
pItem = new Logic::COMathPara( oItem );
else if ( _T("w:p") == sName )
pItem = new Logic::CParagraph( oItem );
else if ( _T("w:permEnd") == sName )
pItem = new Logic::CPermEnd( oItem );
else if ( _T("w:permStart") == sName )
pItem = new Logic::CPermStart( oItem );
else if ( _T("w:proofErr") == sName )
pItem = new Logic::CProofErr( oItem );
else if ( _T("w:sdt") == sName )
pItem = new Logic::CSdt( oItem );
else if ( _T("w:sectPr") == sName )
m_oSectPr = oItem;
else if ( _T("w:tbl") == sName )
pItem = new Logic::CTbl( oItem );
if ( pItem )
m_arrItems.push_back( pItem );
}
}
}
}
}
#endif
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
@ -662,8 +560,6 @@ mc:Ignorable=\"w14 wp14\">";
nullable<OOX::Logic::CBackground > m_oBackground;
std::vector<WritingElement *> m_arrItems;
std::vector<std::wstring> m_arrShapeTypes;
};
} // namespace OOX

View File

@ -61,6 +61,7 @@ namespace OOX
class CCommentsExt;
class CPeople;
class VbaProject;
class JsaProject;
class CHdrFtr;
class CDocx : public OOX::Document, public OOX::IFileContainer
@ -69,41 +70,13 @@ namespace OOX
CDocx() : OOX::IFileContainer(dynamic_cast<OOX::Document*>(this))
{
m_pDocument = NULL;
m_pFontTable = NULL;
m_pNumbering = NULL;
m_pStyles = NULL;
m_pApp = NULL;
m_pCore = NULL;
m_pEndnotes = NULL;
m_pFootnotes = NULL;
m_pSettings = NULL;
m_pTheme = NULL;
m_pComments = NULL;
m_pCommentsExt = NULL;
m_pPeople = NULL;
m_pVbaProject = NULL;
init();
}
CDocx(const CPath& oFilePath) : OOX::IFileContainer(this)
{
m_pDocument = NULL;
m_pFontTable = NULL;
m_pNumbering = NULL;
m_pStyles = NULL;
m_pApp = NULL;
m_pCore = NULL;
m_pEndnotes = NULL;
m_pFootnotes = NULL;
m_pSettings = NULL;
m_pTheme = NULL;
m_pComments = NULL;
m_pCommentsExt = NULL;
m_pPeople = NULL;
m_pVbaProject = NULL;
init();
Read( oFilePath );
}
bool Read(const CPath& oFilePath);
bool Write(const CPath& oFilePath)
{
@ -130,62 +103,7 @@ namespace OOX
return true;
}
OOX::CDocument *GetDocument () const
{
return m_pDocument;
}
OOX::CFontTable *GetFontTable() const
{
return m_pFontTable;
}
OOX::CNumbering *GetNumbering() const
{
return m_pNumbering;
}
OOX::CStyles *GetStyles () const
{
return m_pStyles;
}
OOX::CEndnotes *GetEndnotes () const
{
return m_pEndnotes;
}
OOX::CFootnotes *GetFootnotes() const
{
return m_pFootnotes;
}
OOX::CApp *GetApp () const
{
return m_pApp;
}
OOX::CCore *GetCore () const
{
return m_pCore;
}
OOX::CSettings *GetSettings () const
{
return m_pSettings;
}
OOX::CComments *GetComments () const
{
return m_pComments;
}
OOX::CCommentsExt *GetCommentsExt () const
{
return m_pCommentsExt;
}
OOX::CPeople *GetPeople () const
{
return m_pPeople;
}
PPTX::Theme *GetTheme () const
{
return m_pTheme;
}
OOX::CHdrFtr *GetHeaderOrFooter(const OOX::RId& rId) const;
OOX::CApp *m_pApp;
OOX::CCore *m_pCore;
@ -200,10 +118,31 @@ namespace OOX
OOX::CComments *m_pComments; // word/comments.xml
OOX::CCommentsExt *m_pCommentsExt;// word/commentsExtended.xml
OOX::CPeople *m_pPeople; // word/people.xml
OOX::VbaProject *m_pVbaProject;
OOX::JsaProject *m_pJsaProject;
PPTX::Theme *m_pTheme;
private:
void init()
{
m_pDocument = NULL;
m_pFontTable = NULL;
m_pNumbering = NULL;
m_pStyles = NULL;
m_pApp = NULL;
m_pCore = NULL;
m_pEndnotes = NULL;
m_pFootnotes = NULL;
m_pSettings = NULL;
m_pTheme = NULL;
m_pComments = NULL;
m_pCommentsExt = NULL;
m_pPeople = NULL;
m_pVbaProject = NULL;
m_pJsaProject = NULL;
}
};
} // OOX

View File

@ -80,8 +80,6 @@ namespace OOX
m_oReadPath = oFilePath;
IFileContainer::Read( oRootPath, oFilePath );
Common::readAllShapeTypes(oFilePath, m_arrShapeTypes);
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -158,7 +156,6 @@ namespace OOX
CPath m_oReadPath;
std::vector<OOX::CFtnEdn*> m_arrEndnote;
std::vector<std::wstring> m_arrShapeTypes;
};
} // namespace OOX
#endif // OOX_ENDNOTE_INCLUDE_H_

View File

@ -80,8 +80,6 @@ namespace OOX
m_oReadPath = oFilePath;
IFileContainer::Read( oRootPath, oFilePath );
Common::readAllShapeTypes(oFilePath, m_arrShapeTypes);
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -158,7 +156,6 @@ namespace OOX
CPath m_oReadPath;
std::vector<OOX::CFtnEdn*> m_arrFootnote;
std::vector<std::wstring> m_arrShapeTypes;
};
} // namespace OOX

View File

@ -78,8 +78,6 @@ namespace OOX
m_arrItems.clear();
}
public:
virtual void read(const CPath& oFilePath)
{
//don't use this. use read(const CPath& oRootPath, const CPath& oFilePath)
@ -90,8 +88,6 @@ namespace OOX
{
m_oReadPath = oFilePath;
IFileContainer::Read( oRootPath, oFilePath );
#ifdef USE_LITE_READER
Common::readAllShapeTypes(oFilePath, m_arrShapeTypes);
XmlUtils::CXmlLiteReader oReader;
@ -183,95 +179,6 @@ namespace OOX
m_arrItems.push_back( pItem );
}
}
#else
XmlUtils::CXmlNode oMainNode;
oMainNode.FromXmlFile( oFilePath.GetPath(), true );
if ( _T("w:ftr") == oMainNode.GetName() )
m_eType = et_w_ftr;
else if ( _T("w:hdr") == oMainNode.GetName() )
m_eType = et_w_hdr;
else
return;
XmlUtils::CXmlNodes oChilds;
if ( oMainNode.GetNodes( _T("*"), oChilds ) )
{
XmlUtils::CXmlNode oItem;
for ( int nIndex = 0; nIndex < oChilds.GetCount(); nIndex++ )
{
if ( oChilds.GetAt( nIndex, oItem ) )
{
std::wstring sName = oItem.GetName();
WritingElement *pItem = NULL;
/*if ( _T("w:altChunk") == sName )
pItem = new Logic::AltChunk( oItem );
else */if ( _T("w:bookmarkEnd") == sName )
pItem = new Logic::CBookmarkEnd( oItem );
else if ( _T("w:bookmarkStart") == sName )
pItem = new Logic::CBookmarkStart( oItem );
else if ( _T("w:commentRangeEnd") == sName )
pItem = new Logic::CCommentRangeEnd( oItem );
else if ( _T("w:commentRangeStart") == sName )
pItem = new Logic::CCommentRangeStart( oItem );
//else if ( _T("w:customXml") == sName )
// pItem = new Logic::CCustomXml( oItem );
else if ( _T("w:customXmlDelRangeEnd") == sName )
pItem = new Logic::CCustomXmlDelRangeEnd( oItem );
else if ( _T("w:customXmlDelRangeStart") == sName )
pItem = new Logic::CCustomXmlDelRangeStart( oItem );
else if ( _T("w:customXmlInsRangeEnd") == sName )
pItem = new Logic::CCustomXmlInsRangeEnd( oItem );
else if ( _T("w:customXmlInsRangeStart") == sName )
pItem = new Logic::CCustomXmlInsRangeStart( oItem );
else if ( _T("w:customXmlMoveFromRangeEnd") == sName )
pItem = new Logic::CCustomXmlMoveFromRangeEnd( oItem );
else if ( _T("w:customXmlMoveFromRangeStart") == sName )
pItem = new Logic::CCustomXmlMoveFromRangeStart( oItem );
else if ( _T("w:customXmlMoveToRangeEnd") == sName )
pItem = new Logic::CCustomXmlMoveToRangeEnd( oItem );
else if ( _T("w:customXmlMoveToRangeStart") == sName )
pItem = new Logic::CCustomXmlMoveToRangeStart( oItem );
//else if ( _T("w:del") == sName )
// pItem = new Logic::CDel( oItem );
//else if ( _T("w:ins") == sName )
// pItem = new Logic::CIns( oItem );
//else if ( _T("w:moveFrom") == sName )
// pItem = new Logic::CMoveFrom( oItem );
else if ( _T("w:moveFromRangeEnd") == sName )
pItem = new Logic::CMoveFromRangeEnd( oItem );
else if ( _T("w:moveFromRangeStart") == sName )
pItem = new Logic::CMoveFromRangeStart( oItem );
//else if ( _T("w:moveTo") == sName )
// pItem = new Logic::CMoveTo( oItem );
else if ( _T("w:moveToRangeEnd") == sName )
pItem = new Logic::CMoveToRangeEnd( oItem );
else if ( _T("w:moveToRangeStart") == sName )
pItem = new Logic::CMoveToRangeStart( oItem );
else if ( _T("m:oMath") == sName )
pItem = new Logic::COMath( oItem );
else if ( _T("m:oMathPara") == sName )
pItem = new Logic::COMathPara( oItem );
else if ( _T("w:p") == sName )
pItem = new Logic::CParagraph( oItem );
else if ( _T("w:permEnd") == sName )
pItem = new Logic::CPermEnd( oItem );
else if ( _T("w:permStart") == sName )
pItem = new Logic::CPermStart( oItem );
else if ( _T("w:proofErr") == sName )
pItem = new Logic::CProofErr( oItem );
else if ( _T("w:sdt") == sName )
pItem = new Logic::CSdt( oItem );
else if ( _T("w:tbl") == sName )
pItem = new Logic::CTbl( oItem );
if ( pItem )
m_arrItems.push_back( pItem );
}
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
{
@ -371,7 +278,6 @@ mc:Ignorable=\"w14 wp14\">");
OOX::EElementType m_eType;
std::vector<WritingElement* > m_arrItems;
std::vector<std::wstring> m_arrShapeTypes;
};
} // namespace OOX

View File

@ -50,7 +50,7 @@ namespace OOX
{
boost::unordered_map<std::wstring, size_t> IFileContainer::m_mapEnumeratedGlobal;
UnknowTypeFile IFileContainer::Unknown(NULL);
UnknowTypeFile IFileContainer::m_oUnknown(NULL);
IFileContainer::IFileContainer(OOX::Document* pMain) : m_pMainDocument(pMain)
{
@ -238,39 +238,7 @@ namespace OOX
}
}
void IFileContainer::ExtractPictures (const OOX::CPath& oPath) const
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> pFile = m_arContainer[i];
smart_ptr<Image> pImage = pFile.smart_dynamic_cast<Image>();
if ( pImage.is_init() )
{
pImage->copy_to( oPath );
continue;
}
smart_ptr<IFileContainer> pExt = pFile.smart_dynamic_cast<IFileContainer>();
if ( pExt.is_init() )
{
pExt->ExtractPictures( oPath );
continue;
}
}
}
const bool IFileContainer::IsExist(const FileType& oType) const
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> pFile = m_arContainer[i];
if (oType == pFile->type())
return true;
}
return false;
}
const bool IFileContainer::IsExist(const RId& rId) const
{
boost::unordered_map<std::wstring, smart_ptr<OOX::File>>::const_iterator pFind = m_mapContainer.find(rId.get());
@ -283,17 +251,15 @@ namespace OOX
T oFile;
return IsExist( oFile.type() );
}
std::wstring IFileContainer::IsExistHyperlink(smart_ptr<OOX::HyperLink>& pHyperLink)
std::wstring IFileContainer::IsExistHyperlink(const std::wstring & href)
{
for ( boost::unordered_map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mapContainer.begin(); pPair != m_mapContainer.end(); ++pPair)
boost::unordered_map<std::wstring, std::wstring>::const_iterator pFind = m_mapHyperlinks.find(href);
if (pFind != m_mapHyperlinks.end())
{
if(OOX::FileTypes::HyperLink == pPair->second->type())
{
smart_ptr<OOX::HyperLink> pCurHyperlink = pPair->second.smart_dynamic_cast<OOX::HyperLink>();
if(pCurHyperlink->Uri().GetPath() == pHyperLink->Uri().GetPath())
return pPair->first;
}
return pFind->second;
}
return std::wstring();
}
const bool IFileContainer::IsExternal(const OOX::RId& rId) const
@ -316,28 +282,7 @@ namespace OOX
return true;
}
smart_ptr<OOX::File> IFileContainer::Get(const FileType& oType)
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> &pFile = m_arContainer[i];
if (oType == pFile->type())
return pFile;
}
return smart_ptr<OOX::File>(new UnknowTypeFile( Unknown ));
}
void IFileContainer::Get(const FileType& oType, std::vector<smart_ptr<OOX::File>> & files)
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
smart_ptr<OOX::File> &pFile = m_arContainer[i];
if ( oType == pFile->type() )
files.push_back(pFile);
}
}
const RId IFileContainer::Add(smart_ptr<OOX::File>& pFile)
{
const RId rId = GetMaxRId().next();
@ -347,8 +292,8 @@ namespace OOX
void IFileContainer::Add (const OOX::RId& rId, smart_ptr<OOX::File>& pFile)
{
bool bEnumerated = pFile->type().Enumerated();
bool bEnumeratedGlobal = pFile->type().EnumeratedGlobal();
bool bEnumerated = pFile->type().Enumerated();
bool bEnumeratedGlobal = pFile->type().EnumeratedGlobal();
if(true == bEnumeratedGlobal || true == bEnumerated)
{
@ -396,6 +341,12 @@ namespace OOX
m_arContainer.push_back(pFile);
m_mapContainer [rId.get()] = pFile;
smart_ptr<OOX::HyperLink> oHyperlinkFile = pFile.smart_dynamic_cast<OOX::HyperLink>();
if (oHyperlinkFile.IsInit())
{
m_mapHyperlinks.insert(std::make_pair( oHyperlinkFile->Uri().GetPath(), rId.get() ));
}
}
const RId IFileContainer::AddNoWrite(const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir)
@ -415,16 +366,6 @@ namespace OOX
m_mNoWriteContainer[rId.get()] = oDefDir;
}
smart_ptr<OOX::File> IFileContainer::Find(const FileType& oType) const
{
for (size_t i = 0; i < m_arContainer.size(); ++i)
{
if ( oType == m_arContainer[i]->type() )
return m_arContainer[i];
}
return smart_ptr<OOX::File>( (OOX::File*)new UnknowTypeFile(m_pMainDocument) );
}
smart_ptr<OOX::File> IFileContainer::Find(const OOX::RId& rId) const
{
boost::unordered_map<std::wstring, smart_ptr<OOX::File>>::const_iterator pPair = m_mapContainer.find(rId.get());
@ -449,12 +390,6 @@ namespace OOX
return smart_ptr<OOX::File>( (OOX::File*)new UnknowTypeFile(m_pMainDocument) );
}
smart_ptr<OOX::File> IFileContainer::operator [](const FileType& oType)
{
return Find( oType );
}
const RId IFileContainer::GetMaxRId()
{
return RId( m_lMaxRid );

View File

@ -65,6 +65,7 @@ namespace OOX
OOX::Document* m_pMainDocument;
smart_ptr<OOX::CRels> m_pCurRels;
protected:
static UnknowTypeFile m_oUnknown;
std::vector<smart_ptr<OOX::File>> m_arContainer;
boost::unordered_map<std::wstring, smart_ptr<OOX::File>> m_mapContainer;
@ -81,7 +82,6 @@ namespace OOX
public:
void Read (const OOX::CPath& oRootPath, const OOX::CPath& oPath);
void ExtractPictures(const OOX::CPath& oPath) const;
template<class TypeOut>
smart_ptr<TypeOut> Get (const RId& rId) const
@ -91,40 +91,36 @@ namespace OOX
return smart_ptr<TypeOut>();
return pFind->second.smart_dynamic_cast<TypeOut>();
}
std::vector<smart_ptr<OOX::File>>& GetContainer() {return m_arContainer;}
template<typename T>
const bool IsExist() const;
const bool IsExist(const FileType& oType) const;
const bool IsExist(const OOX::RId& rId) const;
const bool IsExternal(const OOX::RId& rId) const;
std::wstring IsExistHyperlink(smart_ptr<OOX::HyperLink>& pHyperLink);
smart_ptr<OOX::File> Get(const FileType& oType);
void Get(const FileType& oType, std::vector<smart_ptr<OOX::File>> & files);
std::wstring IsExistHyperlink(const std::wstring & href);
const RId Add(smart_ptr<OOX::File>& pFile);
void Add(const OOX::RId& rId, smart_ptr<OOX::File>& pFile);
const RId AddNoWrite(const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir);
void AddNoWrite(const OOX::RId& rId, const smart_ptr<OOX::File>& pFile, const std::wstring& oDefDir);
template<typename T>
T& Find();
smart_ptr<OOX::File> Find(const FileType& type) const;
smart_ptr<OOX::File> Find(const OOX::RId& type) const;
void FindAllByType(const FileType& oType, boost::unordered_map<std::wstring, smart_ptr<OOX::File>>& aOutput) const;
smart_ptr<OOX::File> operator [](const OOX::RId rId);
smart_ptr<OOX::File> operator [](const FileType& oType);
void SetGlobalNumberByType(const std::wstring& sOverrideType, int val);
int GetGlobalNumberByType(const std::wstring& sOverrideType);
protected:
static UnknowTypeFile Unknown;
private:
boost::unordered_map<std::wstring, size_t> m_mapAddNamePair;
const RId GetMaxRId();
const RId GetMaxRId();
boost::unordered_map<std::wstring, size_t> m_mapAddNamePair;
boost::unordered_map<std::wstring, std::wstring> m_mapHyperlinks;
};
} // namespace OOX

View File

@ -0,0 +1,132 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "VbaProject.h"
#include "../Docx.h"
#include "../../XlsxFormat/Xlsx.h"
#include "Media.h"
#include "../../../../../ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h"
#include "../../../../../ASCOfficePPTXFile/Editor/imagemanager.h"
#include "../IFileContainer.h"
#include "../../XlsxFormat/FileTypes_Spreadsheet.h"
namespace OOX
{
VbaProject::VbaProject( OOX::Document *pMain ) : Media(pMain), OOX::IFileContainer(pMain)
{
OOX::CDocx* docx = dynamic_cast<OOX::CDocx*>(pMain);
if (docx)
{
docx->m_pVbaProject = this;
}
else
{
OOX::Spreadsheet::CXlsx* xlsx = dynamic_cast<OOX::Spreadsheet::CXlsx*>(pMain);
if (xlsx)
{
xlsx->m_pVbaProject = this;
}
}
}
VbaProject::VbaProject(OOX::Document *pMain, const CPath& oRootPath, const CPath& filename) : Media(pMain), OOX::IFileContainer(pMain)
{
OOX::CDocx* docx = dynamic_cast<OOX::CDocx*>(pMain);
if (docx)
{
docx->m_pVbaProject = this;
}
else
{
OOX::Spreadsheet::CXlsx* xlsx = dynamic_cast<OOX::Spreadsheet::CXlsx*>(pMain);
if (xlsx)
{
xlsx->m_pVbaProject = this;
}
}
read( oRootPath, filename );
}
void VbaProject::read(const CPath& oRootPath, const CPath& oPath)
{
IFileContainer::Read( oRootPath, oPath );
Media::read(oPath);
}
void VbaProject::write(const OOX::CPath& filename, const OOX::CPath& directory, CContentTypes& content) const
{
content.Registration( type().OverrideType(), directory, filename.GetFilename() );
IFileContainer::Write( filename, directory, content );
}
void VbaProject::toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, m_filename.GetFilename());
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
copy_to(pWriter->m_pCommon->m_pMediaManager->m_strDstMedia);
}
void VbaProject::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
std::wstring file_name = pReader->GetString2();
OOX::CPath inputPath = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + file_name;
OOX::CPath outputPath = pReader->m_pRels->m_pManager->GetDstFolder() + FILE_SEPARATOR_STR + _T("vbaProject.bin");
NSFile::CFileBinary::Copy(inputPath.GetPath(), outputPath.GetPath());
set_filename(outputPath.GetPath(), false);
}break;
default:
break;
}
}
pReader->Seek(_end_rec);
}
} // namespace OOX

View File

@ -33,7 +33,7 @@
#ifndef OOX_VBA_PROJECT_INCLUDE_H_
#define OOX_VBA_PROJECT_INCLUDE_H_
#include "../Docx.h"
#include "Media.h"
#include "../../../../../ASCOfficePPTXFile/Editor/BinaryFileReaderWriter.h"
#include "../../../../../ASCOfficePPTXFile/Editor/imagemanager.h"
@ -46,29 +46,11 @@ namespace OOX
class VbaProject : public Media, public OOX::IFileContainer
{
public:
VbaProject( OOX::Document *pMain ) : Media(pMain), OOX::IFileContainer(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pVbaProject = this;
}
VbaProject(OOX::Document *pMain, const CPath& oRootPath, const CPath& filename) : Media(pMain), OOX::IFileContainer(pMain)
{
CDocx* docx = dynamic_cast<CDocx*>(File::m_pMainDocument);
if (docx) docx->m_pVbaProject = this;
VbaProject( OOX::Document *pMain );
VbaProject(OOX::Document *pMain, const CPath& oRootPath, const CPath& filename);
virtual void read(const CPath& oRootPath, const CPath& oPath);
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, CContentTypes& content) const ;
read( oRootPath, filename );
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
IFileContainer::Read( oRootPath, oPath );
Media::read(oPath);
}
virtual void write(const OOX::CPath& filename, const OOX::CPath& directory, CContentTypes& content) const
{
content.Registration( type().OverrideType(), directory, filename.GetFilename() );
IFileContainer::Write( filename, directory, content );
}
virtual const FileType type() const
{
return OOX::FileTypes::VbaProject;
@ -81,50 +63,8 @@ namespace OOX
{
return m_filename.GetFilename();
}
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeStart);
pWriter->WriteString1(0, m_filename.GetFilename());
pWriter->WriteBYTE(NSBinPptxRW::g_nodeAttributeEnd);
copy_to(pWriter->m_pCommon->m_pMediaManager->m_strDstMedia);
}
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{
LONG _end_rec = pReader->GetPos() + pReader->GetLong() + 4;
pReader->Skip(1); // start attributes
while (true)
{
BYTE _at = pReader->GetUChar_TypeNode();
if (_at == NSBinPptxRW::g_nodeAttributeEnd)
break;
switch (_at)
{
case 0:
{
std::wstring file_name = pReader->GetString2();
OOX::CPath inputPath = pReader->m_strFolder + FILE_SEPARATOR_STR + _T("media") + FILE_SEPARATOR_STR + file_name;
OOX::CPath outputPath = pReader->m_pRels->m_pManager->GetDstFolder() + FILE_SEPARATOR_STR + _T("vbaProject.bin");
NSFile::CFileBinary::Copy(inputPath.GetPath(), outputPath.GetPath());
set_filename(outputPath.GetPath(), false);
}break;
default:
break;
}
}
pReader->Seek(_end_rec);
}
protected:
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
};
} // namespace OOX

View File

@ -854,7 +854,6 @@ namespace OOX
virtual void read(const CPath& oRootPath, const CPath& oFilePath)
{
IFileContainer::Read( oRootPath, oFilePath );
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
@ -890,59 +889,6 @@ namespace OOX
}
}
}
#else
XmlUtils::CXmlNode oNumbering;
oNumbering.FromXmlFile( oFilePath.GetPath(), true );
if ( _T("w:numbering") == oNumbering.GetName() )
{
XmlUtils::CXmlNodes oAbstractNumList;
oNumbering.GetNodes( _T("w:abstractNum"), oAbstractNumList );
for ( int nIndex = 0; nIndex < oAbstractNumList.GetCount(); nIndex++ )
{
XmlUtils::CXmlNode oAbstractNumNode;
if ( oAbstractNumList.GetAt( nIndex, oAbstractNumNode ) )
{
//OOX::Numbering::CAbstractNum oAbstractNum = oAbstractNumNode;
m_arrAbstractNum.push_back( /*oAbstractNum*/ new OOX::Numbering::CAbstractNum (oAbstractNumNode) );
}
}
XmlUtils::CXmlNodes oNumList;
oNumbering.GetNodes( _T("w:num"), oNumList );
for ( int nIndex = 0; nIndex < oNumList.GetCount(); nIndex++ )
{
XmlUtils::CXmlNode oNumNode;
if ( oNumList.GetAt( nIndex, oNumNode ) )
{
//OOX::Numbering::CNum oNum = oNumNode;
m_arrNum.push_back( /*oNum*/ new OOX::Numbering::CNum (oNumNode) );
}
}
XmlUtils::CXmlNode oNumIdPicBulletNode;
if ( oNumbering.GetNode( _T("w:numIdMacAtCleanup"), oNumIdPicBulletNode ) )
m_oNumIdMacAtCleanup = oNumIdPicBulletNode;
// TO DO: ак будут сделаны классы CDrawing, нужно будет сделать чтение
// w:numPicBullet
XmlUtils::CXmlNodes oNumPicList;
oNumbering.GetNodes( _T("w:numPicBullet"), oNumPicList );
for ( int nIndex = 0; nIndex < oNumPicList.GetCount(); nIndex++ )
{
XmlUtils::CXmlNode oNumNode;
if ( oNumPicList.GetAt( nIndex, oNumNode ) )
{
//OOX::Numbering::CNumPicBullet oNum = oNumNode;
m_arrNumPicBullet.push_back( /*oNum*/ new OOX::Numbering::CNumPicBullet (oNumNode) );
}
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const

View File

@ -184,8 +184,6 @@ namespace OOX
{
CPath oRelsPath = CreateFileName( oFilePath );
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oRelsPath.GetPath() ) )
@ -217,33 +215,6 @@ namespace OOX
}
}
}
#else
XmlUtils::CXmlNode oNode;
if ( oNode.FromXmlFile( oRelsPath.GetPath() ) && _T("Relationships") == oNode.GetName() )
{
XmlUtils::CXmlNodes oNodes;
if ( oNode.GetNodes( _T("Relationship"), oNodes ) )
{
XmlUtils::CXmlNode oRelNode;
for ( int nIndex = 0; nIndex < oNodes.GetCount(); nIndex++ )
{
if ( oNodes.GetAt( nIndex, oRelNode ) )
{
Rels::CRelationShip *pRel = new Rels::CRelationShip (oRelNode);
if (pRel)
{
std::wstring rid = pRel->rId().get();
m_arRelations.push_back(pRel);
m_mapRelations.insert(std::make_pair( rid, pRel) );
}
}
}
}
}
#endif
}
void Write(const CPath& oFilePath) const
{

View File

@ -2847,7 +2847,6 @@ namespace OOX
public:
virtual void read(const CPath& oFilePath)
{
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -3024,16 +3023,6 @@ namespace OOX
}
}
}
#else
XmlUtils::CXmlNode oWebSettings;
oWebSettings.FromXmlFile( oFilePath.GetPath(), true );
if ( _T("w:settings") == oWebSettings.GetName() )
{
XmlUtils::CXmlNode oNode;
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
{

View File

@ -160,7 +160,6 @@ namespace OOX
public:
virtual void read(const CPath& oFilePath)
{
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -182,22 +181,6 @@ namespace OOX
m_oOptimizeForBrowser = oReader;
}
}
#else
XmlUtils::CXmlNode oWebSettings;
oWebSettings.FromXmlFile( oFilePath.GetPath(), true );
if ( _T("w:webSettings") == oWebSettings.GetName() )
{
XmlUtils::CXmlNode oNode;
if ( oWebSettings.GetNode( _T("w:allowPNG"), oNode ) )
m_oAllowPNG = oNode;
if ( oWebSettings.GetNode( _T("w:optimizeForBrowser"), oNode ) )
m_oOptimizeForBrowser = oNode;
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
{

View File

@ -799,8 +799,6 @@ namespace OOX
public:
virtual void read(const CPath& oFilePath)
{
#ifdef USE_LITE_READER
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oFilePath.GetPath() ) )
@ -835,41 +833,6 @@ namespace OOX
m_oLatentStyles = oReader;
}
}
#else
XmlUtils::CXmlNode oStyles;
oStyles.FromXmlFile( oFilePath.GetPath(), true );
if ( _T("w:styles") == oStyles.GetName() )
{
XmlUtils::CXmlNode oChild;
if ( oStyles.GetNode( _T("w:docDefaults"), oChild ) )
m_oDocDefaults = oChild;
if ( oStyles.GetNode( _T("w:latentStyles"), oChild ) )
m_oLatentStyles = oChild;
XmlUtils::CXmlNodes oStyleList;
oStyles.GetNodes( _T("w:style"), oStyleList );
for ( int nStlyeIndex = 0; nStlyeIndex < oStyleList.GetCount(); nStlyeIndex++ )
{
XmlUtils::CXmlNode oStyleNode;
if ( oStyleList.GetAt( nStlyeIndex, oStyleNode ) )
{
OOX::CStyle *oStyle = new OOX::CStyle (oStyleNode);
if (oStyle)
{
if (oStyle->m_oName.IsInit())
{
m_arrStyleNamesMap[oStyle->m_oName->ToString()] = m_arrStyle.size();
}
m_arrStyle.push_back( oStyle );
}
}
}
}
#endif
}
virtual void write(const CPath& oFilePath, const CPath& oDirectory, CContentTypes& oContent) const
{

View File

@ -33,13 +33,10 @@
#ifndef OOX_XLSXCOMMENTS_FILE_INCLUDE_H_
#define OOX_XLSXCOMMENTS_FILE_INCLUDE_H_
#include "../CommonInclude.h"
#include "../Xlsx.h"
#include "../Worksheets/Worksheet.h"
#include "../SharedStrings/Si.h"
#include "../../DocxFormat/IFileContainer.h"
#include <boost/unordered_map.hpp>
namespace OOX
{
namespace Spreadsheet
@ -271,10 +268,22 @@ namespace OOX
CComments(OOX::Document* pMain) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if ((xlsx) && (!xlsx->m_arWorksheets.empty()))
{
xlsx->m_arWorksheets.back()->m_pComments = this;
}
}
CComments(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::FileGlobalEnumerated(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if ((xlsx) && (!xlsx->m_arWorksheets.empty()))
{
xlsx->m_arWorksheets.back()->m_pComments = this;
}
read( oRootPath, oPath );
}
virtual ~CComments()

View File

@ -32,6 +32,7 @@
#include "CommonInclude.h"
#include "FileTypes_Spreadsheet.h"
#include "Xlsx.h"
#include "../../../../ASCOfficePPTXFile/PPTXFormat/Theme.h"
#include "../DocxFormat/VmlDrawing.h"
@ -44,6 +45,7 @@
#include "Workbook/Workbook.h"
#include "Worksheets/Worksheet.h"
#include "CalcChain/CalcChain.h"
#include "WorkbookComments.h"
#include "Table/Table.h"
#include "ExternalLinks/ExternalLinks.h"
@ -90,6 +92,8 @@ namespace OOX
return smart_ptr<OOX::File>(new CChartSpace( pMain, oRootPath, oFileName ));
else if ( oRelation.Type() == OOX::FileTypes::ExternalLinkPath)
return smart_ptr<OOX::File>(new ExternalLinkPath( pMain, oRelation.Target()));
else if ( oRelation.Type() == FileTypes::WorkbookComments)
return smart_ptr<OOX::File>(new WorkbookComments( pMain, oRootPath, oFileName));
//common
//else if ( oRelation.Type() == OOX::FileTypes::VmlDrawing )
// return smart_ptr<OOX::File>(new CVmlDrawing( oRootPath, oFileName ));
@ -132,14 +136,21 @@ namespace OOX
return smart_ptr<OOX::File>(new CWorksheet( pMain, oRootPath, oFileName, pRelation->rId().ToString() ));
else if ( pRelation->Type() == OOX::FileTypes::Theme )
{
smart_ptr<OOX::File> pFile;
if(NSFile::CFileBinary::Exists(oFileName.GetPath()))
{
return smart_ptr<OOX::File>(new PPTX::Theme( pMain, oFileName ));
pFile = smart_ptr<OOX::File>(new PPTX::Theme( pMain, oFileName ));
}
else
{
return smart_ptr<OOX::File>( new UnknowTypeFile(pMain) );
pFile = smart_ptr<OOX::File>( new UnknowTypeFile(pMain) );
}
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if (xlsx)
{
xlsx->m_pTheme = pFile.smart_dynamic_cast<PPTX::Theme>();
}
return pFile;
}
else if ( pRelation->Type() == OOX::FileTypes::ThemeOverride )
return smart_ptr<OOX::File>(new PPTX::Theme( pMain, oFileName ));
@ -184,6 +195,8 @@ namespace OOX
return smart_ptr<OOX::File>(new OOX::ActiveX_xml( pMain, oRootPath, oFileName ));
else if ( pRelation->Type() == OOX::FileTypes::ActiveX_bin)
return smart_ptr<OOX::File>(new OOX::ActiveX_bin( pMain, oFileName ));
else if ( pRelation->Type() == FileTypes::WorkbookComments)
return smart_ptr<OOX::File>(new WorkbookComments( pMain, oRootPath, oFileName));
return smart_ptr<OOX::File>( new UnknowTypeFile(pMain) );
}

View File

@ -97,6 +97,11 @@ namespace OOX
const FileType PivotCacheRecords(L"", L"pivotCacheRecords.xml",
_T("application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml"),
_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords"), true, true);
//onlyoffice workbook comments
const FileType WorkbookComments(L"", L"workbookComments.bin",
_T(""),
_T("http://schemas.onlyoffice.com/workbookComments"));
} // namespace FileTypes

View File

@ -70,7 +70,7 @@ namespace OOX
m_bMacroEnabled = false;
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if ((xlsx) && (!xlsx->m_pWorkbook))
{
xlsx->m_pWorkbook = this;
@ -103,7 +103,8 @@ namespace OOX
m_oReadPath = oPath;
IFileContainer::Read( oRootPath, oPath );
if (IFileContainer::IsExist(OOX::FileTypes::VbaProject))
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if ( (xlsx ) && (xlsx->m_pVbaProject) )
{
m_bMacroEnabled = true;
}
@ -235,6 +236,7 @@ namespace OOX
nullable<OOX::Spreadsheet::CWorkbookPr> m_oWorkbookPr;
nullable<OOX::Spreadsheet::CExternalReferences> m_oExternalReferences;
nullable<std::wstring> m_oPivotCachesXml;
bool m_bMacroEnabled;
};
} //Spreadsheet

View File

@ -0,0 +1,98 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#ifndef OOX_ONLY_WORKBOOK_COMMENTS_INCLUDE_H_
#define OOX_ONLY_WORKBOOK_COMMENTS_INCLUDE_H_
#include "CommonInclude.h"
#include "Xlsx.h"
namespace OOX
{
namespace Spreadsheet
{
class WorkbookComments : public OOX::File, public IFileContainer
{
public:
WorkbookComments(OOX::Document* pMain) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if (xlsx)
{
xlsx->m_pWorkbookComments = this;
}
}
WorkbookComments(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if (xlsx)
{
xlsx->m_pWorkbookComments = this;
}
read( oRootPath, oPath );
}
virtual ~WorkbookComments()
{
}
virtual void read(const CPath& oPath)
{
//don't use this. use read(const CPath& oRootPath, const CPath& oFilePath)
CPath oRootPath;
read(oRootPath, oPath);
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oRootPath, oPath );
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
}
virtual const FileType type() const
{
return Spreadsheet::FileTypes::WorkbookComments;
}
virtual const CPath DefaultDirectory() const
{
return type().DefaultDirectory();
}
virtual const CPath DefaultFileName() const
{
return type().DefaultFileName();
}
CPath m_oReadPath;
};
}
} // namespace OOX
#endif // OOX_ONLY_WORKBOOK_COMMENTS_INCLUDE_H_

View File

@ -0,0 +1,430 @@
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "../Xlsx.h"
#include "Worksheet.h"
#include "../Comments/Comments.h"
#include "../../DocxFormat/External/HyperLink.h"
#include "../../DocxFormat/Media/Image.h"
#include "../../DocxFormat/VmlDrawing.h"
namespace OOX
{
namespace Spreadsheet
{
CWorksheet::CWorksheet(OOX::Document* pMain) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
m_pComments = NULL;
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if (xlsx)
{
m_bPrepareForBinaryWriter = true; // подготовка для бинарника при чтении
xlsx->m_arWorksheets.push_back( this );
//xlsx->m_mapWorksheets.insert( std::make_pair(rId, this) );
}
else
m_bPrepareForBinaryWriter = false;
}
CWorksheet::CWorksheet(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath, const std::wstring & rId) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
m_pComments = NULL;
CXlsx* xlsx = dynamic_cast<CXlsx*>(pMain);
if (xlsx)
{
m_bPrepareForBinaryWriter = true;
xlsx->m_arWorksheets.push_back( this );
xlsx->m_mapWorksheets.insert( std::make_pair(rId, this) );
}
else
m_bPrepareForBinaryWriter = false;
read( oRootPath, oPath );
}
CWorksheet::~CWorksheet()
{
ClearItems();
}
void CWorksheet::read(const CPath& oRootPath, const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oRootPath, oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("worksheet") == sName || _T("chartsheet") == sName)
{
if ( !oReader.IsEmptyNode() )
{
int nDocumentDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nDocumentDepth ) )
{
sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("cols") == sName )
m_oCols = oReader;
else if ( _T("dimension") == sName )
m_oDimension = oReader;
else if ( _T("drawing") == sName )
m_oDrawing = oReader;
else if ( _T("hyperlinks") == sName )
m_oHyperlinks = oReader;
else if ( _T("mergeCells") == sName )
m_oMergeCells = oReader;
else if ( _T("pageMargins") == sName )
m_oPageMargins = oReader;
else if ( _T("pageSetup") == sName )
m_oPageSetup = oReader;
else if ( _T("printOptions") == sName )
m_oPrintOptions = oReader;
else if ( _T("sheetData") == sName )
{
m_oSheetData.Init();
m_oSheetData->m_pMainDocument = OOX::File::m_pMainDocument; //todooo передалать на неявное
m_oSheetData->fromXML(oReader);
}
else if (_T("conditionalFormatting") == sName)
m_arrConditionalFormatting.push_back(new CConditionalFormatting(oReader));
else if ( _T("sheetFormatPr") == sName )
m_oSheetFormatPr = oReader;
else if ( _T("sheetViews") == sName )
m_oSheetViews = oReader;
else if ( _T("autoFilter") == sName )
m_oAutofilter = oReader;
else if ( _T("tableParts") == sName )
m_oTableParts = oReader;
else if ( _T("legacyDrawing") == sName )
m_oLegacyDrawing = oReader;
else if ( _T("legacyDrawingHF") == sName )
m_oLegacyDrawingHF = oReader;
else if ( _T("oleObjects") == sName )
m_oOleObjects = oReader;
else if ( _T("controls") == sName )
m_oControls = oReader;
else if ( _T("headerFooter") == sName )
m_oHeaderFooter = oReader;
else if (_T("sheetPr") == sName)
m_oSheetPr = oReader;
else if (_T("extLst") == sName)
m_oExtLst = oReader;
else if (_T("picture") == sName)
m_oPicture = oReader;
}
}
if(m_oLegacyDrawing.IsInit() && m_oLegacyDrawing->m_oId.IsInit())
{
OOX::RId oRId(m_oLegacyDrawing->m_oId->GetValue());
smart_ptr<OOX::File> oVmlDrawing = IFileContainer::Find(oRId);
if (m_pComments && oVmlDrawing.IsInit() && OOX::FileTypes::VmlDrawing == oVmlDrawing->type())
{
OOX::CVmlDrawing* pVmlDrawing = static_cast<OOX::CVmlDrawing*>(oVmlDrawing.operator->());
PrepareComments(m_pComments, pVmlDrawing);
}
}
if (m_oHeaderFooter.IsInit() && m_oLegacyDrawing.IsInit() && m_oLegacyDrawing.IsInit())
{
}
}
}
void CWorksheet::PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::CVmlDrawing* pVmlDrawing)
{
std::vector<std::wstring> & arAuthors = pComments->m_oAuthors->m_arrItems;
if(pComments->m_oCommentList.IsInit())
{
std::vector<OOX::Spreadsheet::CComment*> & aComments = pComments->m_oCommentList->m_arrItems;
for ( size_t i = 0; i < aComments.size(); ++i)
{
OOX::Spreadsheet::CComment* pComment = aComments[i];
if (!pComment) continue;
if(pComment->m_oRef.IsInit() && pComment->m_oAuthorId.IsInit())
{
int nRow, nCol;
if(CCell::parseRef(pComment->m_oRef->GetValue(), nRow, nCol))
{
CCommentItem* pCommentItem = new CCommentItem();
pCommentItem->m_nRow = nRow - 1;
pCommentItem->m_nCol = nCol - 1;
unsigned int nAuthorId = pComment->m_oAuthorId->GetValue();
if (nAuthorId >= 0 && nAuthorId < arAuthors.size())
{
pCommentItem->m_sAuthor = arAuthors[nAuthorId];
}
OOX::Spreadsheet::CSi* pSi = pComment->m_oText.GetPointerEmptyNullable();
if(NULL != pSi)
pCommentItem->m_oText.reset(pSi);
std::wstring sNewId = std::to_wstring(pCommentItem->m_nRow.get()) + L"-" + std::to_wstring(pCommentItem->m_nCol.get());
m_mapComments [sNewId] = pCommentItem;
}
}
}
}
for ( size_t i = 0; i < pVmlDrawing->m_arrItems.size(); ++i)
{
OOX::Vml::CShape* pShape = dynamic_cast<OOX::Vml::CShape*>(pVmlDrawing->m_arrItems[i]);
if (pShape == NULL) continue;
if (pShape->m_sId.IsInit())
{//mark shape as used
boost::unordered_map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pFind = pVmlDrawing->m_mapShapes.find(pShape->m_sId.get());
if (pFind != pVmlDrawing->m_mapShapes.end())
{
pFind->second.bUsed = true;
}
}
for ( size_t j = 0; j < pShape->m_arrItems.size(); ++j)
{
OOX::WritingElement* pElem = pShape->m_arrItems[j];
if ( !pElem ) continue;
if( OOX::et_v_ClientData == pElem->getType())
{
OOX::Vml::CClientData* pClientData = static_cast<OOX::Vml::CClientData*>(pElem);
if(pClientData->m_oRow.IsInit() && pClientData->m_oColumn.IsInit())
{
int nRow = pClientData->m_oRow->GetValue();
int nCol = pClientData->m_oColumn->GetValue();
std::wstring sId = std::to_wstring(nRow) + L"-" + std::to_wstring(nCol);
boost::unordered_map<std::wstring, CCommentItem*>::const_iterator pPair = m_mapComments.find(sId);
if(pPair != m_mapComments.end())
{
CCommentItem* pCommentItem = pPair->second;
if(pShape->m_sGfxData.IsInit())
pCommentItem->m_sGfxdata = pShape->m_sGfxData.get2();
std::vector<int> m_aAnchor;
pClientData->getAnchorArray(m_aAnchor);
if(8 == m_aAnchor.size())
{
pCommentItem->m_nLeft = m_aAnchor[0];
pCommentItem->m_nLeftOffset = m_aAnchor[1];
pCommentItem->m_nTop = m_aAnchor[2];
pCommentItem->m_nTopOffset = m_aAnchor[3];
pCommentItem->m_nRight = m_aAnchor[4];
pCommentItem->m_nRightOffset = m_aAnchor[5];
pCommentItem->m_nBottom = m_aAnchor[6];
pCommentItem->m_nBottomOffset = m_aAnchor[7];
}
if(pClientData->m_oMoveWithCells.IsInit())
pCommentItem->m_bMove = pClientData->m_oMoveWithCells->ToBool();
if(pClientData->m_oSizeWithCells.IsInit())
pCommentItem->m_bSize = pClientData->m_oSizeWithCells->ToBool();
for(size_t k = 0 ,length3 = pShape->m_oStyle->m_arrProperties.size(); k < length3; ++k)
{
if (pShape->m_oStyle->m_arrProperties[k] == NULL) continue;
SimpleTypes::Vml::CCssProperty *oProperty = pShape->m_oStyle->m_arrProperties[k].get();
if(SimpleTypes::Vml::cssptMarginLeft == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dLeftMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptMarginTop == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dTopMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptWidth == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dWidthMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptHeight == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dHeightMM = oPoint.ToMm();
}
}
}
}
}
}
}
}
}
void CWorksheet::PrepareToWrite()
{
if(false == m_oSheetFormatPr.IsInit())
m_oSheetFormatPr.Init();
if(false == m_oSheetFormatPr->m_oDefaultRowHeight.IsInit())
{
m_oSheetFormatPr->m_oDefaultRowHeight.Init();
m_oSheetFormatPr->m_oDefaultRowHeight->SetValue(15);
}
if(false == m_oSheetViews.IsInit())
m_oSheetViews.Init();
if(m_oSheetViews->m_arrItems.empty())
m_oSheetViews->m_arrItems.push_back(new CSheetView());
CSheetView* pSheetView = m_oSheetViews->m_arrItems.front();
if(false == pSheetView->m_oWorkbookViewId.IsInit())
{
pSheetView->m_oWorkbookViewId.Init();
pSheetView->m_oWorkbookViewId->SetValue(0);
}
}
void CWorksheet::write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
NSStringUtils::CStringBuilder sXml;
sXml.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" mc:Ignorable=\"x14ac\">"));
if(m_oSheetPr.IsInit())
m_oSheetPr->toXML(sXml);
if(m_oSheetViews.IsInit())
m_oSheetViews->toXML(sXml);
if(m_oSheetFormatPr.IsInit())
m_oSheetFormatPr->toXML(sXml);
if(m_oCols.IsInit())
m_oCols->toXML(sXml);
if(m_oSheetData.IsInit())
m_oSheetData->toXML(sXml);
if(m_oAutofilter.IsInit())
m_oAutofilter->toXML(sXml);
if(m_oMergeCells.IsInit())
m_oMergeCells->toXML(sXml);
for (size_t nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex)
m_arrConditionalFormatting[nIndex]->toXML(sXml);
if(m_oHyperlinks.IsInit())
m_oHyperlinks->toXML(sXml);
if(m_oPrintOptions.IsInit())
m_oPrintOptions->toXML(sXml);
if(m_oPageMargins.IsInit())
m_oPageMargins->toXML(sXml);
if(m_oPageSetup.IsInit())
m_oPageSetup->toXML(sXml);
if(m_oDrawing.IsInit())
m_oDrawing->toXML(sXml);
if(m_oLegacyDrawing.IsInit())
m_oLegacyDrawing->toXML(sXml);
if(m_oLegacyDrawingHF.IsInit())
m_oLegacyDrawingHF->toXML(sXml);
if(m_oOleObjects.IsInit())
m_oOleObjects->toXML(sXml);
if (m_oControls.IsInit())
m_oControls->toXML(sXml);
if(m_oTableParts.IsInit())
m_oTableParts->toXML(sXml);
if(m_oExtLst.IsInit())
{
sXml.WriteString(m_oExtLst->toXMLWithNS(_T("")));
}
sXml.WriteString(_T("</worksheet>"));
NSFile::CFileBinary::SaveToFile(oPath.GetPath(), sXml.GetData());
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
const OOX::RId CWorksheet::AddHyperlink (std::wstring& sHref)
{
std::wstring sExistRId = IsExistHyperlink(sHref);
if(sExistRId.empty())
{
smart_ptr<OOX::File> oHyperlinkFile = smart_ptr<OOX::File>( new OOX::HyperLink( File::m_pMainDocument, OOX::CPath(sHref, false) ) );
const OOX::RId rId = Add( oHyperlinkFile );
return rId;
}
else
{
const OOX::RId rId(sExistRId);
return rId;
}
}
void CWorksheet::ClearItems()
{
for (boost::unordered_map<std::wstring, CCommentItem*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
delete it->second;
}
m_mapComments.clear();
// delete Conditional Formatting
for (size_t nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex)
{
delete m_arrConditionalFormatting[nIndex];
}
m_arrConditionalFormatting.clear();
}
}
}

View File

@ -35,10 +35,6 @@
#include "../CommonInclude.h"
#include "../../DocxFormat/External/HyperLink.h"
#include "../../DocxFormat/Media/Image.h"
#include "../../DocxFormat/VmlDrawing.h"
#include "SheetData.h"
#include "Cols.h"
#include "Hyperlinks.h"
@ -49,16 +45,18 @@
#include "../Drawing/Drawing.h"
#include "../Chart/Chart.h"
#include "../Table/Table.h"
#include "../Comments/Comments.h"
#include "../Ole/OleObjects.h"
#include "../Controls/Controls.h"
#include "../../../../../DesktopEditor/common/String.h"
namespace OOX
{
class CVmlDrawing;
namespace Spreadsheet
{
class CComments;
class CCommentItem;
class CLegacyDrawingWorksheet;
//необработанные child:
//<cellWatches>
//<colBreaks>
@ -79,361 +77,19 @@ namespace OOX
class CWorksheet : public OOX::File, public OOX::IFileContainer
{
public:
CWorksheet(OOX::Document* pMain) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx)
{
m_bPrepareForBinaryWriter = true; // подготовка для бинарника при чтении
xlsx->m_arWorksheets.push_back( this );
//xlsx->m_mapWorksheets.insert( std::make_pair(rId, this) );
}
else
m_bPrepareForBinaryWriter = false;
}
CWorksheet(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath, const std::wstring & rId) : OOX::File(pMain), OOX::IFileContainer(pMain)
{
m_bSpreadsheets = true;
CXlsx* xlsx = dynamic_cast<CXlsx*>(File::m_pMainDocument);
if (xlsx)
{
m_bPrepareForBinaryWriter = true;
xlsx->m_arWorksheets.push_back( this );
xlsx->m_mapWorksheets.insert( std::make_pair(rId, this) );
}
else
m_bPrepareForBinaryWriter = false;
read( oRootPath, oPath );
}
virtual ~CWorksheet()
{
ClearItems();
}
CWorksheet(OOX::Document* pMain);
CWorksheet(OOX::Document* pMain, const CPath& oRootPath, const CPath& oPath, const std::wstring & rId);
virtual ~CWorksheet();
virtual void read(const CPath& oPath)
{
//don't use this. instead use read(const CPath& oRootPath, const CPath& oFilePath)
CPath oRootPath;
read(oRootPath, oPath);
}
virtual void read(const CPath& oRootPath, const CPath& oPath)
{
m_oReadPath = oPath;
IFileContainer::Read( oRootPath, oPath );
XmlUtils::CXmlLiteReader oReader;
if ( !oReader.FromFile( oPath.GetPath() ) )
return;
if ( !oReader.ReadNextNode() )
return;
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("worksheet") == sName || _T("chartsheet") == sName)
{
if ( !oReader.IsEmptyNode() )
{
int nDocumentDepth = oReader.GetDepth();
while ( oReader.ReadNextSiblingNode( nDocumentDepth ) )
{
sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("cols") == sName )
m_oCols = oReader;
else if ( _T("dimension") == sName )
m_oDimension = oReader;
else if ( _T("drawing") == sName )
m_oDrawing = oReader;
else if ( _T("hyperlinks") == sName )
m_oHyperlinks = oReader;
else if ( _T("mergeCells") == sName )
m_oMergeCells = oReader;
else if ( _T("pageMargins") == sName )
m_oPageMargins = oReader;
else if ( _T("pageSetup") == sName )
m_oPageSetup = oReader;
else if ( _T("printOptions") == sName )
m_oPrintOptions = oReader;
else if ( _T("sheetData") == sName )
{
m_oSheetData.Init();
m_oSheetData->m_pMainDocument = OOX::File::m_pMainDocument; //todooo передалать на неявное
m_oSheetData->fromXML(oReader);
}
else if (_T("conditionalFormatting") == sName)
m_arrConditionalFormatting.push_back(new CConditionalFormatting(oReader));
else if ( _T("sheetFormatPr") == sName )
m_oSheetFormatPr = oReader;
else if ( _T("sheetViews") == sName )
m_oSheetViews = oReader;
else if ( _T("autoFilter") == sName )
m_oAutofilter = oReader;
else if ( _T("tableParts") == sName )
m_oTableParts = oReader;
else if ( _T("legacyDrawing") == sName )
m_oLegacyDrawing = oReader;
else if ( _T("legacyDrawingHF") == sName )
m_oLegacyDrawingHF = oReader;
else if ( _T("oleObjects") == sName )
m_oOleObjects = oReader;
else if ( _T("controls") == sName )
m_oControls = oReader;
else if ( _T("headerFooter") == sName )
m_oHeaderFooter = oReader;
else if (_T("sheetPr") == sName)
m_oSheetPr = oReader;
else if (_T("extLst") == sName)
m_oExtLst = oReader;
else if (_T("picture") == sName)
m_oPicture = oReader;
}
}
if(m_oLegacyDrawing.IsInit() && m_oLegacyDrawing->m_oId.IsInit())
{
OOX::RId oRId(m_oLegacyDrawing->m_oId->GetValue());
smart_ptr<OOX::File> oVmlDrawing = IFileContainer::Find(oRId);
smart_ptr<OOX::File> oComments = IFileContainer::Get(FileTypes::Comments);
if (oComments.IsInit() && FileTypes::Comments == oComments->type() && oVmlDrawing.IsInit() && OOX::FileTypes::VmlDrawing == oVmlDrawing->type())
{
OOX::Spreadsheet::CComments* pComments = static_cast<OOX::Spreadsheet::CComments*>(oComments.operator->());
OOX::CVmlDrawing* pVmlDrawing = static_cast<OOX::CVmlDrawing*>(oVmlDrawing.operator->());
PrepareComments(pComments, pVmlDrawing);
}
}
if (m_oHeaderFooter.IsInit() && m_oLegacyDrawing.IsInit() && m_oLegacyDrawing.IsInit())
{
}
}
}
void PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::CVmlDrawing* pVmlDrawing)
{
std::vector<std::wstring> & arAuthors = pComments->m_oAuthors->m_arrItems;
if(pComments->m_oCommentList.IsInit())
{
std::vector<OOX::Spreadsheet::CComment*> & aComments = pComments->m_oCommentList->m_arrItems;
for ( size_t i = 0; i < aComments.size(); ++i)
{
OOX::Spreadsheet::CComment* pComment = aComments[i];
if (!pComment) continue;
if(pComment->m_oRef.IsInit() && pComment->m_oAuthorId.IsInit())
{
int nRow, nCol;
if(CCell::parseRef(pComment->m_oRef->GetValue(), nRow, nCol))
{
CCommentItem* pCommentItem = new CCommentItem();
pCommentItem->m_nRow = nRow - 1;
pCommentItem->m_nCol = nCol - 1;
unsigned int nAuthorId = pComment->m_oAuthorId->GetValue();
if (nAuthorId >= 0 && nAuthorId < arAuthors.size())
{
pCommentItem->m_sAuthor = arAuthors[nAuthorId];
}
OOX::Spreadsheet::CSi* pSi = pComment->m_oText.GetPointerEmptyNullable();
if(NULL != pSi)
pCommentItem->m_oText.reset(pSi);
std::wstring sNewId = std::to_wstring(pCommentItem->m_nRow.get()) + L"-" + std::to_wstring(pCommentItem->m_nCol.get());
m_mapComments [sNewId] = pCommentItem;
}
}
}
}
for ( size_t i = 0; i < pVmlDrawing->m_arrItems.size(); ++i)
{
OOX::Vml::CShape* pShape = dynamic_cast<OOX::Vml::CShape*>(pVmlDrawing->m_arrItems[i]);
if (pShape == NULL) continue;
if (pShape->m_sId.IsInit())
{//mark shape as used
boost::unordered_map<std::wstring, OOX::CVmlDrawing::_vml_shape>::iterator pFind = pVmlDrawing->m_mapShapes.find(pShape->m_sId.get());
if (pFind != pVmlDrawing->m_mapShapes.end())
{
pFind->second.bUsed = true;
}
}
for ( size_t j = 0; j < pShape->m_arrItems.size(); ++j)
{
OOX::WritingElement* pElem = pShape->m_arrItems[j];
if ( !pElem ) continue;
if( OOX::et_v_ClientData == pElem->getType())
{
OOX::Vml::CClientData* pClientData = static_cast<OOX::Vml::CClientData*>(pElem);
if(pClientData->m_oRow.IsInit() && pClientData->m_oColumn.IsInit())
{
int nRow = pClientData->m_oRow->GetValue();
int nCol = pClientData->m_oColumn->GetValue();
std::wstring sId = std::to_wstring(nRow) + L"-" + std::to_wstring(nCol);
boost::unordered_map<std::wstring, CCommentItem*>::const_iterator pPair = m_mapComments.find(sId);
if(pPair != m_mapComments.end())
{
CCommentItem* pCommentItem = pPair->second;
if(pShape->m_sGfxData.IsInit())
pCommentItem->m_sGfxdata = pShape->m_sGfxData.get2();
std::vector<int> m_aAnchor;
pClientData->getAnchorArray(m_aAnchor);
if(8 == m_aAnchor.size())
{
pCommentItem->m_nLeft = m_aAnchor[0];
pCommentItem->m_nLeftOffset = m_aAnchor[1];
pCommentItem->m_nTop = m_aAnchor[2];
pCommentItem->m_nTopOffset = m_aAnchor[3];
pCommentItem->m_nRight = m_aAnchor[4];
pCommentItem->m_nRightOffset = m_aAnchor[5];
pCommentItem->m_nBottom = m_aAnchor[6];
pCommentItem->m_nBottomOffset = m_aAnchor[7];
}
if(pClientData->m_oMoveWithCells.IsInit())
pCommentItem->m_bMove = pClientData->m_oMoveWithCells->ToBool();
if(pClientData->m_oSizeWithCells.IsInit())
pCommentItem->m_bSize = pClientData->m_oSizeWithCells->ToBool();
for(size_t k = 0 ,length3 = pShape->m_oStyle->m_arrProperties.size(); k < length3; ++k)
{
if (pShape->m_oStyle->m_arrProperties[k] == NULL) continue;
SimpleTypes::Vml::CCssProperty *oProperty = pShape->m_oStyle->m_arrProperties[k].get();
if(SimpleTypes::Vml::cssptMarginLeft == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dLeftMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptMarginTop == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dTopMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptWidth == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dWidthMM = oPoint.ToMm();
}
}
else if(SimpleTypes::Vml::cssptHeight == oProperty->get_Type())
{
SimpleTypes::Vml::UCssValue oUCssValue= oProperty->get_Value();
if(SimpleTypes::Vml::cssunitstypeUnits == oUCssValue.oValue.eType)
{
SimpleTypes::CPoint oPoint;
oPoint.FromPoints(oUCssValue.oValue.dValue);
pCommentItem->m_dHeightMM = oPoint.ToMm();
}
}
}
}
}
}
}
}
}
void PrepareToWrite()
{
if(false == m_oSheetFormatPr.IsInit())
m_oSheetFormatPr.Init();
if(false == m_oSheetFormatPr->m_oDefaultRowHeight.IsInit())
{
m_oSheetFormatPr->m_oDefaultRowHeight.Init();
m_oSheetFormatPr->m_oDefaultRowHeight->SetValue(15);
}
if(false == m_oSheetViews.IsInit())
m_oSheetViews.Init();
if(m_oSheetViews->m_arrItems.empty())
m_oSheetViews->m_arrItems.push_back(new CSheetView());
CSheetView* pSheetView = m_oSheetViews->m_arrItems.front();
if(false == pSheetView->m_oWorkbookViewId.IsInit())
{
pSheetView->m_oWorkbookViewId.Init();
pSheetView->m_oWorkbookViewId->SetValue(0);
}
}
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const
{
NSStringUtils::CStringBuilder sXml;
sXml.WriteString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\" xmlns:x14=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:x14ac=\"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac\" mc:Ignorable=\"x14ac\">"));
if(m_oSheetPr.IsInit())
m_oSheetPr->toXML(sXml);
if(m_oSheetViews.IsInit())
m_oSheetViews->toXML(sXml);
if(m_oSheetFormatPr.IsInit())
m_oSheetFormatPr->toXML(sXml);
if(m_oCols.IsInit())
m_oCols->toXML(sXml);
if(m_oSheetData.IsInit())
m_oSheetData->toXML(sXml);
if(m_oAutofilter.IsInit())
m_oAutofilter->toXML(sXml);
if(m_oMergeCells.IsInit())
m_oMergeCells->toXML(sXml);
for (size_t nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex)
m_arrConditionalFormatting[nIndex]->toXML(sXml);
if(m_oHyperlinks.IsInit())
m_oHyperlinks->toXML(sXml);
if(m_oPrintOptions.IsInit())
m_oPrintOptions->toXML(sXml);
if(m_oPageMargins.IsInit())
m_oPageMargins->toXML(sXml);
if(m_oPageSetup.IsInit())
m_oPageSetup->toXML(sXml);
if(m_oDrawing.IsInit())
m_oDrawing->toXML(sXml);
if(m_oLegacyDrawing.IsInit())
m_oLegacyDrawing->toXML(sXml);
if(m_oLegacyDrawingHF.IsInit())
m_oLegacyDrawingHF->toXML(sXml);
if(m_oOleObjects.IsInit())
m_oOleObjects->toXML(sXml);
if (m_oControls.IsInit())
m_oControls->toXML(sXml);
if(m_oTableParts.IsInit())
m_oTableParts->toXML(sXml);
if(m_oExtLst.IsInit())
{
sXml.WriteString(m_oExtLst->toXMLWithNS(_T("")));
}
sXml.WriteString(_T("</worksheet>"));
NSFile::CFileBinary::SaveToFile(oPath.GetPath(), sXml.GetData());
oContent.Registration( type().OverrideType(), oDirectory, oPath.GetFilename() );
IFileContainer::Write( oPath, oDirectory, oContent );
}
virtual void read(const CPath& oRootPath, const CPath& oPath);
void PrepareComments(OOX::Spreadsheet::CComments* pComments, OOX::CVmlDrawing* pVmlDrawing);
void PrepareToWrite();
virtual void write(const CPath& oPath, const CPath& oDirectory, CContentTypes& oContent) const;
virtual const OOX::FileType type() const
{
return OOX::Spreadsheet::FileTypes::Worksheet;
@ -450,38 +106,8 @@ namespace OOX
{
return m_oReadPath;
}
const OOX::RId AddHyperlink (std::wstring& sHref)
{
smart_ptr<OOX::HyperLink> oHyperlink = smart_ptr<OOX::HyperLink>( new OOX::HyperLink( File::m_pMainDocument, OOX::CPath(sHref, false) ) );
std::wstring sExistRId = IsExistHyperlink(oHyperlink);
if(sExistRId.empty())
{
smart_ptr<OOX::File> oHyperlinkFile = oHyperlink.smart_dynamic_cast<OOX::File>();
const OOX::RId rId = Add( oHyperlinkFile );
return rId;
}
else
{
const OOX::RId rId(sExistRId);
return rId;
}
}
void ClearItems()
{
for (boost::unordered_map<std::wstring, CCommentItem*>::const_iterator it = m_mapComments.begin(); it != m_mapComments.end(); ++it)
{
delete it->second;
}
m_mapComments.clear();
// delete Conditional Formatting
for (size_t nIndex = 0, nLength = m_arrConditionalFormatting.size(); nIndex < nLength; ++nIndex)
{
delete m_arrConditionalFormatting[nIndex];
}
m_arrConditionalFormatting.clear();
}
const OOX::RId AddHyperlink (std::wstring& sHref);
void ClearItems();
CPath m_oReadPath;
public:
@ -511,6 +137,9 @@ namespace OOX
nullable<OOX::Spreadsheet::CPictureWorksheet> m_oPicture;
nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;
//--------------------------------------------------------------------------------------------
CComments *m_pComments;
};
} //Spreadsheet
} // namespace OOX

View File

@ -47,7 +47,12 @@
OOX::Spreadsheet::CXlsx::~CXlsx()
{
for (size_t i = 0; i < m_arWorksheets.size(); ++i)
if(bDeleteWorkbook) RELEASEOBJECT(m_pWorkbook);
if(bDeleteSharedStrings) RELEASEOBJECT(m_pSharedStrings);
if(bDeleteStyles) RELEASEOBJECT(m_pStyles);
if(bDeleteCalcChain) RELEASEOBJECT(m_pCalcChain);
for (size_t i = 0; i < m_arWorksheets.size(); ++i)
{
if (bDeleteWorksheets && m_arWorksheets[i])
{
@ -66,8 +71,8 @@ bool OOX::Spreadsheet::CXlsx::Read(const CPath& oFilePath)
if (!m_pWorkbook) return false;
//Theme
smart_ptr<OOX::File> pFile = m_pWorkbook->Find(OOX::FileTypes::Theme);
m_pTheme = pFile.smart_dynamic_cast<PPTX::Theme>();
//smart_ptr<OOX::File> pFile = m_pWorkbook->Find(OOX::FileTypes::Theme);
//m_pTheme = pFile.smart_dynamic_cast<PPTX::Theme>();
for (size_t i = 0; i < m_arWorksheets.size(); i++)
{

View File

@ -49,6 +49,7 @@ namespace OOX
class CSharedStrings;
class CStyles;
class CCalcChain;
class WorkbookComments;
class CXlsx : public OOX::Document, public OOX::IFileContainer
{
@ -82,12 +83,16 @@ namespace OOX
{
return (PPTX::Theme *)(m_pTheme.operator->());
}
smart_ptr<PPTX::Theme> m_pTheme;
CWorkbook* m_pWorkbook;
CSharedStrings* m_pSharedStrings;
CStyles* m_pStyles;
CCalcChain* m_pCalcChain;
smart_ptr<PPTX::Theme> m_pTheme;
OOX::VbaProject* m_pVbaProject;
OOX::JsaProject* m_pJsaProject;
WorkbookComments* m_pWorkbookComments;
std::vector<CWorksheet*> m_arWorksheets; //order as is
std::map<std::wstring, OOX::Spreadsheet::CWorksheet*> m_mapWorksheets; //copy, for fast find - order by rId(name)
@ -101,12 +106,17 @@ namespace OOX
m_pSharedStrings = NULL;
m_pStyles = NULL;
m_pCalcChain = NULL;
m_pVbaProject = NULL;
m_pJsaProject = NULL;
m_pWorkbookComments = NULL;
bDeleteWorkbook = false;
bDeleteSharedStrings = false;
bDeleteStyles = false;
bDeleteCalcChain = false;
bDeleteWorksheets = false;
bDeleteVbaProject = false;
bDeleteJsaProject = false;
}
boost::unordered_map<std::wstring, size_t> m_mapXlsxEnumeratedGlobal;
@ -116,6 +126,8 @@ namespace OOX
bool bDeleteStyles;
bool bDeleteCalcChain;
bool bDeleteWorksheets;
bool bDeleteVbaProject;
bool bDeleteJsaProject;
};
} //Spreadsheet

View File

@ -1,4 +1,4 @@
VERSION = 2.4.511.0
VERSION = 2.4.514.0
DEFINES += INTVER=$$VERSION
# CONFIGURATION

View File

@ -62,6 +62,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -510,6 +510,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -58,6 +58,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -348,6 +348,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -353,6 +353,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -58,6 +58,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -59,6 +59,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -204,6 +204,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -59,6 +59,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -1406,7 +1406,7 @@ void CFontList::LoadFromArrayFiles(std::vector<std::wstring>& oArray, int nFlag)
BYTE* pDataFontFile = new BYTE[nMaxFontSize];
for (int nIndex = 0; nIndex < nCount; ++nIndex)
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
{
if ((nFlag & 2) != 0)
{

View File

@ -207,6 +207,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -511,6 +511,7 @@
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="0"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -226,6 +226,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -54,6 +54,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -504,6 +504,7 @@
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -43,9 +43,9 @@
#include "../../DesktopEditor/raster/Metafile/MetaFile.h"
#include "../../DesktopEditor/raster/BgraFrame.h"
#define RASTER_TEST
//#define RASTER_TEST
//#define METAFILE_TEST
//#define ONLINE_WORD_TO_PDF
#define ONLINE_WORD_TO_PDF
//#define TO_PDF//#define TO_HTML_RENDERER
//#define ONLY_TEXT
@ -92,7 +92,7 @@ int main(int argc, char *argv[])
#ifdef ONLINE_WORD_TO_PDF
CPdfRenderer oPdfW(&oFonts);
oPdfW.SetTempFolder(sDst);
oPdfW.SetTempFolder(L"D:\\test\\Document");
oPdfW.OnlineWordToPdf(L"D:\\test\\123.txt", L"D:\\test\\123.pdf");
return 0;
#endif

View File

@ -52,6 +52,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -53,6 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -113,7 +113,7 @@ static unsigned int* WStringToUtf32(const std::wstring& wsUnicodeText, unsigned
}
else
{
pUnicodes[unLen++] = (unCode | (wTrailing & 0x3FF) + 0x10000);
pUnicodes[unLen++] = ((unCode | (wTrailing & 0x3FF)) + 0x10000);
}
}
}

View File

@ -41,8 +41,6 @@ core_linux_64 {
DEFINES += UNICODE \
_UNICODE \
_USE_LIBXML2_READER_ \
_USE_XMLLITE_READER_ \
USE_LITE_READER \
#DISABLE_FILE_DOWNLOADER \
FILTER_FLATE_DECODE_ENABLED \
CXIMAGE_DONT_DECLARE_TCHAR \

View File

@ -53,6 +53,7 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
DisableSpecificWarnings="4005;4311;4312"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -193,7 +193,8 @@ namespace BinXlsxRW
OleLink = 10,
DdeLink = 11,
VbaProject = 12,
JsaProject = 13
JsaProject = 13,
Comments = 14
};}
namespace c_oSerWorkbookVbaProjectTypes{enum c_oSerWorkbookVbaProjectTypes
{

Some files were not shown because too many files have changed in this diff Show More