Compare commits

..

12 Commits

50 changed files with 4354 additions and 1127 deletions

View File

@ -1321,6 +1321,12 @@ public:
NSStringUtils::CStringBuilder ParaPr;
NSStringUtils::CStringBuilder TextPr;
std::wstring PStyle;
bool Tentative;
unsigned long Tplc;
bool IsLgl;
bool Legacy;
long LegacyIndent;
unsigned long LegacySpace;
bool bILvl;
bool bFormat;
@ -1332,6 +1338,14 @@ public:
bool bParaPr;
bool bTextPr;
bool bPStyle;
bool bTentative;
bool bTplc;
bool bIsLgl;
bool bLvlLegacy;
bool bLegacy;
bool bLegacyIndent;
bool bLegacySpace;
docLvl()
{
bILvl = false;
@ -1344,6 +1358,13 @@ public:
bParaPr = false;
bTextPr = false;
bPStyle = false;
bTentative = false;
bTplc = false;
bIsLgl = false;
bLvlLegacy = false;
bLegacy = false;
bLegacyIndent = false;
bLegacySpace = false;
}
~docLvl()
{
@ -1359,6 +1380,19 @@ public:
{
oWriter.WriteString(L" w:ilvl=\"" + std::to_wstring(ILvl) + L"\"");
}
if(bTentative)
{
if(Tentative)
oWriter.WriteString(L" w:tentative=\"1\"");
else
oWriter.WriteString(L" w:tentative=\"0\"");
}
if(bTplc)
{
oWriter.WriteString(L" w:tplc=\"");
oWriter.WriteString(XmlUtils::IntToString(Tplc, L"%08X"));
oWriter.WriteString(L"\"");
}
oWriter.WriteString(L">");
if(bStart)
{
@ -1392,6 +1426,13 @@ public:
std::wstring sStyleName = XmlUtils::EncodeXmlString(PStyle);
oWriter.WriteString(L"<w:pStyle w:val=\"" + sStyleName + L"\"/>");
}
if(bIsLgl)
{
if(IsLgl)
oWriter.WriteString(L"<w:isLgl/>");
else
oWriter.WriteString(L"<w:isLgl w:val=\"false\"/>");
}
if(bSuff)
{
std::wstring sSuff;
@ -1430,6 +1471,30 @@ public:
oWriter.WriteString(sTextXml);
}
if(bLvlLegacy)
{
oWriter.WriteString(L"<w:legacy");
if(bLegacy)
{
if(Legacy)
oWriter.WriteString(L" w:legacy=\"1\"");
else
oWriter.WriteString(L" w:legacy=\"0\"");
}
if(bLegacyIndent)
{
oWriter.WriteString(L" w:legacyIndent=\"");
oWriter.WriteString(std::to_wstring(LegacyIndent));
oWriter.WriteString(L"\"");
}
if(bLegacySpace)
{
oWriter.WriteString(L" w:legacySpace=\"");
oWriter.WriteString(std::to_wstring(LegacySpace));
oWriter.WriteString(L"\"");
}
oWriter.WriteString(L"/>");
}
if(bJc)
{
std::wstring sJc;

View File

@ -2654,6 +2654,49 @@ public:
odocLvl->bILvl = true;
odocLvl->ILvl = m_oBufferedStream.GetLong();
}
else if ( c_oSerNumTypes::Tentative == type )
{
odocLvl->bTentative = true;
odocLvl->Tentative = m_oBufferedStream.GetBool();
}
else if ( c_oSerNumTypes::Tplc == type )
{
odocLvl->bTplc = true;
odocLvl->Tplc = m_oBufferedStream.GetULong();
}
else if ( c_oSerNumTypes::IsLgl == type )
{
odocLvl->bIsLgl = true;
odocLvl->IsLgl = m_oBufferedStream.GetBool();
}
else if ( c_oSerNumTypes::LvlLegacy == type )
{
odocLvl->bLvlLegacy = true;
READ1_DEF(length, res, this->ReadLvlLegacy, odocLvl);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadLvlLegacy(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
docLvl* odocLvl = static_cast<docLvl*>(poResult);
if ( c_oSerNumTypes::Legacy == type )
{
odocLvl->bLegacy = true;
odocLvl->Legacy = m_oBufferedStream.GetBool();
}
else if ( c_oSerNumTypes::LegacyIndent == type )
{
odocLvl->bLegacyIndent = true;
odocLvl->LegacyIndent = m_oBufferedStream.GetLong();
}
else if ( c_oSerNumTypes::LegacySpace == type )
{
odocLvl->bLegacySpace = true;
odocLvl->LegacySpace = m_oBufferedStream.GetULong();
}
else
res = c_oSerConstants::ReadUnknown;
return res;

View File

@ -204,7 +204,14 @@ extern int g_nCurFormatVersion;
NumFmtFormat = 26,
Num_LvlOverride = 27,
StartOverride = 28,
ILvl = 29
ILvl = 29,
Tentative = 30,
Tplc = 31,
IsLgl = 32,
LvlLegacy = 33,
Legacy = 34,
LegacyIndent = 35,
LegacySpace = 36
};}
namespace c_oSerOtherTableTypes{enum c_oSerOtherTableTypes
{

View File

@ -2987,6 +2987,54 @@ namespace BinDocxRW
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(lvl.m_oIlvl->GetValue());
}
if(lvl.m_oTentative.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerNumTypes::Tentative);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(lvl.m_oTentative->ToBool());
}
if(lvl.m_oTplc.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerNumTypes::Tplc);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteULONG(lvl.m_oTplc->GetValue());
}
if(lvl.m_oIsLgl.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerNumTypes::IsLgl);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(lvl.m_oIsLgl->m_oVal.ToBool());
}
if(lvl.m_oLegacy.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerNumTypes::LvlLegacy);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
WriteLvlLegacy(lvl.m_oLegacy.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteLvlLegacy(const ComplexTypes::Word::CLvlLegacy& lvlLegacy)
{
int nCurPos = 0;
if (lvlLegacy.m_oLegacy.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNumTypes::Legacy);
m_oBcw.m_oStream.WriteBOOL(lvlLegacy.m_oLegacy->ToBool());
m_oBcw.WriteItemEnd(nCurPos);
}
if (lvlLegacy.m_oLegacyIndent.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNumTypes::LegacyIndent);
m_oBcw.m_oStream.WriteLONG(lvlLegacy.m_oLegacyIndent->ToTwips());
m_oBcw.WriteItemEnd(nCurPos);
}
if (lvlLegacy.m_oLegacySpace.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerNumTypes::LegacySpace);
m_oBcw.m_oStream.WriteULONG(lvlLegacy.m_oLegacySpace->ToUnsignedTwips());
m_oBcw.WriteItemEnd(nCurPos);
}
}
void WriteLevelText(const std::wstring& text)
{

View File

@ -19,9 +19,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormulasConvert", "..\wi
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFileReaderTest", "OdfFileTest.vcproj", "{C2882DDD-07E6-4314-AD4B-48F43F38D722}"
ProjectSection(ProjectDependencies) = postProject
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
{50E20601-4A8D-4AFB-8870-63828D328429} = {50E20601-4A8D-4AFB-8870-63828D328429}
{609ED938-3CA8-4BED-B363-25096D4C4812} = {609ED938-3CA8-4BED-B363-25096D4C4812}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeFileCrypt", "..\..\OfficeCryptReader\win32\ECMACryptReader.vcproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}"

View File

@ -77,6 +77,7 @@ SOURCES += \
../src/odf/office_settings.cpp \
../src/odf/office_spreadsheet.cpp \
../src/odf/office_text.cpp \
../src/odf/office_meta.cpp \
../src/odf/paragraph_elements.cpp \
../src/odf/ruby.cpp \
../src/odf/search_table_cell.cpp \
@ -213,6 +214,7 @@ SOURCES += \
../src/odf/datatypes/tablefunction.cpp \
../src/odf/datatypes/tableorder.cpp \
../src/odf/datatypes/dategroup.cpp \
../src/odf/datatypes/bibliography \
../src/odfcommandtype.cpp \
../src/docx/xlsx_conditionalFormatting.cpp \
../src/docx/xlsx_dxfs.cpp \
@ -342,6 +344,7 @@ HEADERS += \
../src/odf/office_settings.h \
../src/odf/office_spreadsheet.h \
../src/odf/office_text.h \
../src/odf/office_meta.h \
../src/odf/paragraph_elements.h \
../src/odf/ruby.h \
../src/odf/search_table_cell.h \

View File

@ -67,6 +67,7 @@
#include "../src/odf/office_settings.cpp"
#include "../src/odf/office_spreadsheet.cpp"
#include "../src/odf/office_text.cpp"
#include "../src/odf/office_meta.cpp"
#include "../src/odf/paragraph_elements.cpp"
#include "../src/odf/ruby.cpp"
#include "../src/odf/search_table_cell.cpp"

View File

@ -129,3 +129,4 @@
#include "../src/odf/datatypes/dategroup.cpp"
#include "../src/odf/datatypes/commandtype.cpp"
#include "../src/odf/datatypes/stylenumformat.cpp"
#include "../src/odf/datatypes/bibliography.cpp"

View File

@ -334,37 +334,121 @@ void docx_conversion_context::end_math_formula()
output_stream() << L"<m:oMath>" << math_content << L"</m:oMath>";
}
}
void docx_conversion_context::start_table_content(int type)
void docx_conversion_context::start_sdt(int type)
{
in_table_content_ = true;
std::wstring sType;
table_content_context_.type_table_content = type;
switch(type)
if (table_content_context_.type_table_content < 4)
{
case 1: sType = L"Table of Contents"; break;
case 2: sType = L"List od Illustrations"; break;
output_stream() << L"<w:sdt><w:sdtPr>";
if (table_content_context_.type_table_content == 3)
{
output_stream() << L"<w:bibliography/>";
}
else
{
output_stream() << L"<w:docPartObj><w:docPartGallery w:val=\"";
if (table_content_context_.type_table_content == 1) output_stream() << L"Table of Contents";
if (table_content_context_.type_table_content == 2) output_stream() << L"List od Illustrations";
output_stream() << L"\"/><w:docPartUnique/></w:docPartObj>";
}
output_stream() << L"</w:sdtPr><w:sdtContent>";
}
output_stream() << L"<w:sdt>";
output_stream() << L"<w:sdtPr>";
//output_stream() << L"<w:id w:val=\"-505364165\"/>";
output_stream() << L"<w:docPartObj>";
output_stream() << L"<w:docPartGallery w:val=\"" << sType << L"\"/>";
output_stream() << L"<w:docPartUnique/>";
output_stream() << L"</w:docPartObj>";
output_stream() << L"</w:sdtPr>";
output_stream() << L"<w:sdtContent>";
}
void docx_conversion_context::end_table_content()
void docx_conversion_context::start_index_content()
{
if (!in_table_content_) return;
output_stream() << L"</w:sdtContent>";
output_stream() << L"</w:sdt>";
start_paragraph(false);
std::wstring sInstrText;
switch(table_content_context_.type_table_content)
{
case 1: sInstrText += L" TOC \\f \\h \\u"; break;
case 2:
case 4:
case 6:
case 7: sInstrText += L" TOC \\h \\z"; break;
case 5: sInstrText += L" INDEX \\z"; break;
case 3: sInstrText += L" BIBLIOGRAPHY"; break;
}
if (table_content_context_.min_outline_level > 0)
{
if (table_content_context_.max_outline_level > 9)
table_content_context_.max_outline_level = 9;
sInstrText += L" \\o \"" + std::to_wstring(table_content_context_.min_outline_level) + L"-" +
std::to_wstring(table_content_context_.max_outline_level) + L"\" ";
}
/*\\l 1-3*/
if (!table_content_context_.caption_sequence_name.empty())
{
sInstrText += L" \\c \"" + table_content_context_.caption_sequence_name + L"\"";
}
output_stream() << L"<w:r>";
output_stream() << L"<w:fldChar w:fldCharType=\"begin\"/>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
output_stream() << L"<w:instrText xml:space=\"preserve\">" << sInstrText << L" </w:instrText>";
output_stream() << L"</w:r>";
output_stream() << L"<w:r>";
//output_stream() << L"<w:rPr>
//output_stream() << L"<w:rFonts w:ascii="Minion Pro" w:eastAsia="DejaVuSans" w:hAnsi="Minion Pro"/>
//output_stream() << L"<w:bCs w:val="0"/>
//output_stream() << L"<w:sz w:val="21"/>
//output_stream() << L"<w:szCs w:val="24"/>
//output_stream() << L"</w:rPr>
output_stream() << L"<w:fldChar w:fldCharType=\"separate\"/>";
output_stream() << L"</w:r>";
finish_paragraph();
}
void docx_conversion_context::end_index_content()
{
if (!in_table_content_) return;
start_paragraph(false);
output_stream() << L"<w:r>";
//output_stream() << L"<w:rPr>";
//output_stream() << L"<w:rFonts w:ascii="Minion Pro" w:hAnsi="Minion Pro"/>";
//output_stream() << L"<w:sz w:val="20"/>
//output_stream() << L"</w:rPr>";
output_stream() << L"<w:fldChar w:fldCharType=\"end\"/>";
output_stream() << L"</w:r>";
finish_paragraph();
}
void docx_conversion_context::end_sdt()
{
if (!in_table_content_) return;
if (table_content_context_.type_table_content < 4)
{
output_stream() << L"</w:sdtContent></w:sdt>";
}
in_table_content_ = false;
table_content_context_.clear_all();
}
void docx_conversion_context::start_index_element()
{
table_content_context_.clear_current_content_template_index();
}
void docx_conversion_context::end_index_element()
{
table_content_context_.clear_current_content_template_index();
}
void docx_conversion_context::add_bibliography_item (const std::wstring & item)
{
arBibliography.push_back(item);
}
void docx_conversion_context::start_bookmark (const std::wstring &name)
{
@ -402,6 +486,64 @@ void docx_conversion_context::end_bookmark (const std::wstring &name)
output_stream() << L"<w:bookmarkEnd w:id=\"" << std::to_wstring(id) << L"\"/>";
}
void docx_conversion_context::start_alphabetical_index (const std::wstring &id)
{
std::map<std::wstring, std::vector<odf_reader::office_element_ptr>>::iterator pFind = mapAlphabeticals.find(id);
if (pFind != mapAlphabeticals.end()) return;
std::vector<odf_reader::office_element_ptr> texts;
mapAlphabeticals.insert(std::make_pair(id, texts));
current_alphabetic_index_ = id;
}
void docx_conversion_context::add_alphabetical_index_text (odf_reader::office_element_ptr & elem)
{
std::map<std::wstring, std::vector<odf_reader::office_element_ptr>>::iterator pFind = mapAlphabeticals.find(current_alphabetic_index_);
if (pFind == mapAlphabeticals.end())
{
return;
}
pFind->second.push_back(elem);
}
void docx_conversion_context::end_alphabetical_index (const std::wstring &id)
{
std::map<std::wstring, std::vector<odf_reader::office_element_ptr>>::iterator pFind = mapAlphabeticals.find(id);
if (pFind == mapAlphabeticals.end())
{
return;
}
finish_run();
output_stream() << L"<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>";
output_stream() << L"<w:r><w:instrText>XE \"";
odf_reader::ElementType type;
for (size_t i = 0; i < pFind->second.size(); i++)
{
type = pFind->second[i]->get_type();
pFind->second[i]->text_to_stream(output_stream());
}
output_stream() << L"\"</w:instrText></w:r>";
output_stream() << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
for (size_t i = 0; i < pFind->second.size(); i++)
{
pFind->second[i]->docx_convert(*this);
}
mapAlphabeticals.erase(pFind);
if (mapAlphabeticals.empty())
current_alphabetic_index_.clear();
else
current_alphabetic_index_ = mapAlphabeticals.begin()->first; // todooo vector+map+level
}
void docx_conversion_context::start_chart(std::wstring name)
{
charts_.push_back(oox_chart_context_ptr(new oox_chart_context(mediaitems_, name)));
@ -504,7 +646,7 @@ void docx_conversion_context::end_document()
output_stream() << L"</w:document>";
output_document_->get_word_files().set_document ( package::simple_element::create(L"document.xml", document_xml_.str()) );
output_document_->get_word_files().set_settings ( package::simple_element::create(L"settings.xml",dump_settings_document()));
output_document_->get_word_files().set_settings ( package::simple_element::create(L"settings.xml", dump_settings_document()));
output_document_->get_word_files().set_media ( mediaitems_, applicationFonts_);
output_document_->get_word_files().set_comments ( comments_context_);
output_document_->get_word_files().set_headers_footers( headers_footers_);
@ -513,6 +655,7 @@ void docx_conversion_context::end_document()
content_file_.set_media( mediaitems_);
////////////////////////////////////////////////////////////////////////////
dump_bibliography();
dump_hyperlinks (notes_context_.footnotesRels(), hyperlinks::footnote_place);
dump_hyperlinks (notes_context_.endnotesRels(), hyperlinks::endnote_place);
@ -529,13 +672,66 @@ void docx_conversion_context::end_document()
}
////////////////////////////////
//content->add_rel(relationship(dId, kType, dName));
output_document_->get_word_files().update_rels(*this);
/////////////////////////////////////
}
void docx_conversion_context::dump_bibliography()
{
if (arBibliography.empty()) return;
std::wstringstream output(L"");
CP_XML_WRITER(output)
{
CP_XML_NODE(L"b:Sources")
{
CP_XML_ATTR(L"Version", 6);
CP_XML_ATTR(L"StyleName", L"APA");
CP_XML_ATTR(L"SelectedStyle", L"\\APASixthEditionOfficeOnline.xsl");
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/officeDocument/2006/bibliography");
CP_XML_ATTR(L"xmlns:b", L"http://schemas.openxmlformats.org/officeDocument/2006/bibliography");
for (size_t i = 0; i < arBibliography.size(); i++)
{
CP_XML_NODE(L"b:Source")
{
CP_XML_STREAM() << arBibliography[i];
CP_XML_NODE(L"b:RefOrder")
{
CP_XML_STREAM() << std::to_wstring(i + 1);
}
}
}
}
}
std::wstringstream output_props(L"");
CP_XML_WRITER(output_props)
{
CP_XML_NODE(L"ds:datastoreItem")
{
CP_XML_ATTR(L"xmlns:ds", L"http://schemas.openxmlformats.org/officeDocument/2006/customXml");
CP_XML_ATTR(L"ds:itemID", L"{28C8D49A-D84A-4837-A0AC-8E2C3AE46B82}");
CP_XML_NODE(L"ds:schemaRefs")
{
CP_XML_NODE(L"ds:schemaRef")
{
CP_XML_ATTR(L"ds:uri", L"http://schemas.openxmlformats.org/officeDocument/2006/bibliography");
}
}
}
}
package::customXml_content_ptr content = package::customXml_content::create(output.str(), output_props.str());
int id = output_document_->add_customXml(content);
const std::wstring sRId = std::wstring(L"cstId") + std::to_wstring(id);
const std::wstring sRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
const std::wstring sFileRef = std::wstring(L"../customXml/item") + std::to_wstring(id) + L".xml";
output_document_->get_word_files().add_rels(relationship(sRId, sRel, sFileRef));
}
std::wstring docx_conversion_context::dump_settings_document()
{
@ -559,21 +755,25 @@ std::wstring docx_conversion_context::dump_settings_document()
_CP_OPT(std::wstring) strVal;
_CP_OPT(int) intVal;
if (odf_reader::GetProperty(settings_properties_,L"evenAndOddHeaders",boolVal))
if (odf_reader::GetProperty(settings_properties_,L"evenAndOddHeaders", boolVal))
{
CP_XML_NODE(L"w:evenAndOddHeaders");
}
if (odf_reader::GetProperty(settings_properties_,L"displayBackgroundShape",boolVal))
if (odf_reader::GetProperty(settings_properties_,L"displayBackgroundShape", boolVal))
{
CP_XML_NODE(L"w:displayBackgroundShape");
}
if (odf_reader::GetProperty(settings_properties_,L"zoom",intVal))
if (odf_reader::GetProperty(settings_properties_,L"zoom", intVal))
{
CP_XML_NODE(L"w:zoom")
{
CP_XML_ATTR(L"w:percent",intVal.get());
}
}
if (odf_reader::GetProperty(settings_properties_,L"mirrorMargins", boolVal))
{
CP_XML_NODE(L"w:mirrorMargins");
}
}
}
return output.str();
@ -953,7 +1153,7 @@ bool docx_conversion_context::process_page_properties(std::wostream & strm)
if (page_layout_instance_)
{
page_layout_instance_->docx_serialize(strm, *this);
page_layout_instance_->docx_serialize(strm, *this);
}
else
{
@ -1062,7 +1262,8 @@ void docx_conversion_context::start_automatic_style(const std::wstring & ParentI
void docx_conversion_context::end_automatic_style()
{
in_automatic_style_ = false;
automatic_parent_style_ = L"";
automatic_parent_style_.clear();
tabs_context_.clear();
}
bool docx_conversion_context::in_automatic_style()
@ -1266,7 +1467,11 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
if (false == Attr->text_style_name_.empty())
{
if (odf_reader::style_instance * styleInst =
if (in_table_content_ && Attr->text_style_name_.empty())
{
table_content_context_.set_current_level(Attr->text_style_name_);
}
if (odf_reader::style_instance * styleInst =
root()->odf_context().styleContainer().style_by_name(Attr->text_style_name_, odf_types::style_family::Paragraph, process_headers_footers_)
)
{
@ -1276,33 +1481,39 @@ int docx_conversion_context::process_paragraph_attr(odf_reader::text::paragraph_
if (odf_reader::style_content * styleContent = styleInst->content())
{
std::wstring id;
//office_element_ptr parent_tab_stops_;
if (const odf_reader::style_instance * parentStyleContent = styleInst->parent())
{
id = styles_map_.get( parentStyleContent->name(), parentStyleContent->type() );
std::wstring parent_name = parentStyleContent->name();
id = styles_map_.get( parent_name, parentStyleContent->type() );
if (in_table_content_ && table_content_context_.empty_current_table_content_level_index())
{
table_content_context_.set_current_level(parent_name);
}
}
start_automatic_style(id);
{//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
if (properties.style_writing_mode_)
odf_reader::calc_tab_stops(styleInst, get_tabs_context());
//вытаскивает rtl c цепочки стилей !! - просто прописать в наследуемом НЕЛЬЗЯ !!
odf_reader::paragraph_format_properties properties = odf_reader::calc_paragraph_properties_content(styleInst);
if (properties.style_writing_mode_)
{
odf_types::writing_mode::type type = properties.style_writing_mode_->get_type();
switch(type)
{
odf_types::writing_mode::type type = properties.style_writing_mode_->get_type();
switch(type)
{
case odf_types::writing_mode::RlTb:
case odf_types::writing_mode::TbRl:
case odf_types::writing_mode::Rl:
set_rtl(true);
break;
default:
set_rtl(false);
}
case odf_types::writing_mode::RlTb:
case odf_types::writing_mode::TbRl:
case odf_types::writing_mode::Rl:
set_rtl(true);
break;
default:
set_rtl(false);
}
set_margin_left(properties.fo_margin_left_? 20.0 * properties.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt) : 0);
//for calculate tabs
}
set_margin_left(properties.fo_margin_left_? 20.0 * properties.fo_margin_left_->get_length().get_value_unit(odf_types::length::pt) : 0);
styleContent->docx_convert(*this);
@ -1415,7 +1626,7 @@ void docx_conversion_context::process_page_break_after(const odf_reader::style_i
{
if (inst->content() && inst->content()->get_style_paragraph_properties())
{
_CP_OPT(odf_types::fo_break) fo_break_val = inst->content()->get_style_paragraph_properties()->content().fo_break_after_;
_CP_OPT(odf_types::fo_break) fo_break_val = inst->content()->get_style_paragraph_properties()->content_.fo_break_after_;
if (fo_break_val)
{
if (fo_break_val->get_type() == odf_types::fo_break::Page)
@ -1619,7 +1830,7 @@ void docx_conversion_context::add_note_reference ()
typedef std::map<std::wstring, text_tracked_context::_state>::iterator map_changes_iterator;
void docx_conversion_context::start_text_changes (std::wstring id)
void docx_conversion_context::start_text_changes (const std::wstring &id)
{
text_tracked_context::_state &state_add = text_tracked_context_.get_tracked_change(id);
if (state_add.id != id) return;
@ -1786,7 +1997,7 @@ void docx_conversion_context::end_changes()
text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear();
}
void docx_conversion_context::end_text_changes (std::wstring id)
void docx_conversion_context::end_text_changes (const std::wstring &id)
{
if (map_current_changes_.empty()) return;
@ -1811,6 +2022,7 @@ void docx_conversion_context::add_user_field(const std::wstring & name, const st
{
map_user_fields.insert(std::make_pair(name, value));
}
std::wstring docx_conversion_context::get_user_field(const std::wstring & name)
{
std::map<std::wstring, std::wstring>::iterator pFind = map_user_fields.find(name);

View File

@ -613,6 +613,152 @@ private:
_state current_state_;
std::map<std::wstring, _state> mapElements_;
};
class table_content_context
{
public:
table_content_context()
{
clear_all();
}
enum template_type
{
TableContent = 1,
Illustrations = 2,
Bibliography = 3,
Tables = 4
};
enum level_type
{
Span = 1,
Text = 2,
LinkStart = 3,
LinkEnd = 4,
TabStop = 5,
PageNumber = 6,
Chapter = 7
};
struct _state
{
std::wstring name;
int outline_level = -1;
std::vector<int> content;
void clear()
{
name.clear();
content.clear();
outline_level = -1;
}
};
void start_template(int type)
{
current_template.clear();
type_table_content = type;
}
void end_template()
{
}
void start_level(const std::wstring& style_name)
{
current_state.name = style_name;
}
void add_level_content(int type)
{
current_state.content.push_back(type);
}
void set_outline_level(int level)
{
if (min_outline_level == -1 || min_outline_level > level)
min_outline_level = level;
if (max_outline_level == -1 || max_outline_level < level)
max_outline_level = level;
current_state.outline_level = level;
}
void end_level()
{
current_template.insert(std::make_pair(current_state.name, current_state));
current_state.clear();
}
void set_current_level(const std::wstring &name)
{
std::map<std::wstring, _state>::iterator pFind = current_template.find(name);
if (pFind == current_template.end())
{
current_content_template_.clear();
}
current_content_template_ = pFind->second.content;
current_content_template_index_ = 0;
}
void next_level_index()
{
current_content_template_index_++;
}
int get_type_current_content_template_index()
{
if (current_content_template_index_ < (int)current_content_template_.size() && current_content_template_index_ >= 0)
return current_content_template_[current_content_template_index_];
return 0;
}
void clear_current_content_template_index()
{
current_content_template_index_ = 0;
current_content_template_.clear();
}
bool empty_current_table_content_level_index()
{
return current_content_template_.empty();
}
void clear_all()
{
type_table_content = 0;
current_content_template_index_ = 0;
current_content_template_.clear();
current_template.clear();
current_state.clear();
caption_sequence_name.clear();
min_outline_level = -1;
max_outline_level = -1;
}
void add_sequence(const std::wstring & name, int outline_level)
{
//sequences.insert(std::make_pair(name, outline_level));
sequences.push_back(name);
}
std::wstring get_sequence (const std::wstring & ref)
{
for (size_t i = 0; i < sequences.size(); i++)
{
if (std::wstring:: npos != ref.find(sequences[i]))
{
return sequences[i];
}
}
return L"";
}
std::wstring caption_sequence_name;
int type_table_content;
int min_outline_level;
int max_outline_level;
private:
std::vector<int> current_content_template_;
int current_content_template_index_;
std::map<std::wstring, _state> current_template;
_state current_state;
//std::map<std::wstring, int> sequences;
std::vector<std::wstring> sequences;
};
//---------------------------------------------------------------------------------------------------------
class docx_conversion_context : boost::noncopyable
{
@ -633,10 +779,11 @@ public:
return temp_stream_;
}
void add_bibliography_item (const std::wstring & item);
void add_user_field (const std::wstring & name, const std::wstring & value);
std::wstring get_user_field (const std::wstring & name);
void add_element_to_run (std::wstring parenStyleId = _T(""));
void add_element_to_run (std::wstring parenStyleId = _T(""));
void finish_run ();
void add_new_run (std::wstring parentStyleId = _T(""));
bool get_run_state () { return in_run_; }
@ -645,6 +792,7 @@ public:
void start_paragraph (bool is_header = false);
void finish_paragraph ();
bool is_alphabetical_index () { return false == mapAlphabeticals.empty();}
bool is_table_content () { return in_table_content_; }
bool is_paragraph_header () { return in_header_; }
bool get_paragraph_state () { return in_paragraph_; }
@ -665,6 +813,7 @@ public:
void dump_headers_footers (rels & Rels) const;
void dump_notes (rels & Rels) const;
void dump_bibliography();
std::wstring dump_settings_document();
bool next_dump_page_properties_;
@ -684,8 +833,14 @@ public:
void start_office_text ();
void end_office_text ();
void start_table_content (int type);
void end_table_content ();
void start_sdt (int type);
void end_sdt ();
void start_index_content();
void end_index_content();
void start_index_element();
void end_index_element();
void process_styles ();
void process_fonts ();
@ -761,6 +916,9 @@ public:
notes_context & get_notes_context() { return notes_context_; }
text_tracked_context& get_text_tracked_context(){ return text_tracked_context_; }
text_forms_context & get_forms_context() { return text_forms_context_; }
tabs_context & get_tabs_context() { return tabs_context_;}
table_content_context & get_table_content_context() { return table_content_context_;}
void docx_convert_delayed ();
void add_delayed_element (odf_reader::office_element * Elm);
@ -791,12 +949,16 @@ public:
void start_math_formula ();
void end_math_formula ();
void start_text_changes (std::wstring id);
void end_text_changes (std::wstring id);
void start_text_changes (const std::wstring &id);
void end_text_changes (const std::wstring &id);
void start_bookmark (const std::wstring &name);
void end_bookmark (const std::wstring &name);
void start_alphabetical_index (const std::wstring &id);
void end_alphabetical_index (const std::wstring &id);
void add_alphabetical_index_text (odf_reader::office_element_ptr & elem);
void set_process_headers_footers(bool Val) { process_headers_footers_ = Val; }
headers_footers & get_headers_footers() { return headers_footers_; }
header_footer_context & get_header_footer_context() { return header_footer_context_; }
@ -822,6 +984,7 @@ private:
std::wstringstream footer_xml_;
std::wstringstream header_xml_;
std::wstringstream settings_xml_;
std::wstringstream meta_xml_;
styles_context styles_context_;
math_context math_context_;
@ -834,6 +997,8 @@ private:
notes_context notes_context_;
text_tracked_context text_tracked_context_;
text_forms_context text_forms_context_;
tabs_context tabs_context_;
table_content_context table_content_context_;
boost::shared_ptr<streams_man> streams_man_;
@ -868,18 +1033,23 @@ private:
bool is_rtl_; // right-to-left
bool is_paragraph_keep_;
std::wstring current_alphabetic_index_;
int current_margin_left_;
int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
NoteType process_note_;
std::vector<odf_reader::office_element*> delayed_elements_;
std::vector<odf_reader::office_element*> delayed_elements_;
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций
std::vector< const odf_reader::style_text_properties*> text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций
std::map<std::wstring, std::wstring> map_user_fields;
std::map<std::wstring, int> mapBookmarks;
std::map<std::wstring, std::wstring> map_user_fields;
std::map<std::wstring, int> mapBookmarks;
std::map<std::wstring, std::vector<odf_reader::office_element_ptr>> mapAlphabeticals;
std::vector<std::wstring> arBibliography;
};
}

View File

@ -209,8 +209,8 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"pic:cNvPr")
{
//CP_XML_ATTR(L"desc text",L"");
CP_XML_ATTR(L"id",val.id);
CP_XML_ATTR(L"name",val.name);
CP_XML_ATTR(L"id", val.id + 1);
CP_XML_ATTR(L"name", val.name);
}
CP_XML_NODE(L"pic:cNvPicPr")
{
@ -316,7 +316,7 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"wp:docPr")
{
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id + 1);
CP_XML_ATTR(L"id", 0xf000 + val.id + 1);
oox_serialize_action(CP_XML_STREAM(), val.action);
}
@ -398,8 +398,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"cy", val.cy);
}
serialize_null_extent(CP_XML_STREAM());
}
serialize_null_extent(CP_XML_STREAM());
}
else//anchor
{

View File

@ -124,7 +124,7 @@ void word_files::write(const std::wstring & RootPath)
charts_files_.set_main_document(get_main_document());
charts_files_.write(path);
}
if (notes_)
{
notes_->write( path );
@ -207,7 +207,50 @@ void word_files::set_comments(comments_context & commentsContext)
elm->set_main_document( get_main_document() );
comments_ = element_ptr( elm );
}
///////////////////
void word_files::add_rels(relationship const & r)
{
rels_files_.add(r);
}
//----------------------------------------------------------
int customXml_files::add_customXml(customXml_content_ptr customXml)
{
customXmls_.push_back(customXml);
return customXmls_.size();
}
void customXml_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"customXml";
NSDirectory::CreateDirectory(path.c_str());
std::wstring path_rels = path + FILE_SEPARATOR_STR + L"_rels";
NSDirectory::CreateDirectory(path_rels.c_str());
for (size_t i = 0 ; i < customXmls_.size(); i++)
{
if (!customXmls_[i]) continue;
const std::wstring fileNameItem = std::wstring(L"item") + std::to_wstring(i+1) + L".xml";
const std::wstring fileNameProps = std::wstring(L"itemProps") + std::to_wstring(i+1) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/customXml/") + fileNameProps,
L"application/vnd.openxmlformats-officedocument.customXmlProperties+xml");
package::simple_element(fileNameItem, customXmls_[i]->item()).write(path);
package::simple_element(fileNameProps, customXmls_[i]->props()).write(path);
rels_file_ptr rels_file = rels_file::create(fileNameItem + L".rels");
rels_file->get_rels().add(relationship(L"rId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps",
fileNameProps));
rels_file->write(path_rels);
}
}
//----------------------------------------------------------
void docx_charts_files::add_chart(chart_content_ptr chart)
{
charts_.push_back(chart);
@ -220,7 +263,7 @@ void docx_charts_files::write(const std::wstring & RootPath)
size_t count = 0;
for (int i = 0 ; i < charts_.size(); i++)
for (size_t i = 0 ; i < charts_.size(); i++)
{
if (!charts_[i]) continue;
@ -434,8 +477,10 @@ void comments_elements::write(const std::wstring & RootPath)
docx_document::docx_document()
{
this->set_main_document(this);
word_files_.set_main_document(this);
word_files_.set_main_document(this);
customXml_files_.set_main_document(this);
rels_file_ptr relFile = rels_file_ptr( new rels_file(L".rels") );
relFile->get_rels().relationships().push_back(
relationship(L"rId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", L"docProps/app.xml" )
@ -450,16 +495,18 @@ docx_document::docx_document()
rels_files_.add_rel_file( relFile );
}
int docx_document::add_customXml(customXml_content_ptr customXml)
{
return customXml_files_.add_customXml(customXml);
}
void docx_document::write(const std::wstring & RootPath)
{
if (word_files_.has_numbering())
{
content_type_file_.content()->get_override().push_back( override_content_type(L"/word/numbering.xml",
L"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml") );
}
customXml_files_.write (RootPath);
word_files_.write (RootPath);
rels_files_.write (RootPath);
docProps_files_.write (RootPath);

View File

@ -103,8 +103,17 @@ private:
};
// xl_charts_files
class docx_charts_files : public element
class customXml_files : public element
{
public:
customXml_files(){}
int add_customXml(customXml_content_ptr customXml);
virtual void write(const std::wstring & RootPath);
std::vector<customXml_content_ptr> customXmls_;
};
class docx_charts_files : public element
{
public:
docx_charts_files(){}
@ -137,6 +146,8 @@ public:
void add_charts(chart_content_ptr chart);
void add_rels(relationship const & r);
private:
docx_charts_files charts_files_;
rels_files rels_files_;
@ -165,11 +176,13 @@ public:
word_files & get_word_files() { return word_files_; }
virtual content_types_file & get_content_types_file() { return content_type_file_; }
virtual void write(const std::wstring & RootPath);
void write(const std::wstring & RootPath);
int add_customXml(customXml_content_ptr customXml);
private:
docx_content_types_file content_type_file_;
word_files word_files_;
customXml_files customXml_files_;
rels_files rels_files_;
docProps_files docProps_files_;
};

View File

@ -39,9 +39,58 @@
#include "../odf/odfcontext.h"
#include "../odf/style_text_properties.h"
#include "../odf/style_paragraph_properties.h"
namespace cpdoccore {
void tabs_context::reset()
{
for (size_t i = 0; i < tabs.size(); i++)
{
odf_reader::style_tab_stop *tab_stop = dynamic_cast<odf_reader::style_tab_stop*>(tabs[i].get());
if (tab_stop)
{
clear_tabs.insert(std::make_pair(tab_stop->style_position_.get_value(), tabs[i]));
}
}
tabs.clear();
}
void tabs_context::add(const odf_reader::office_element_ptr & element)
{
odf_reader::style_tab_stop *tab_stop = dynamic_cast<odf_reader::style_tab_stop*>(element.get());
if (tab_stop)
{
std::map<double, odf_reader::office_element_ptr>::iterator pFind = clear_tabs.find(tab_stop->style_position_.get_value());
if (pFind != clear_tabs.end())
{
clear_tabs.erase(pFind);
}
tabs.push_back(element);
}
}
void tabs_context::docx_convert(oox::docx_conversion_context & Context)
{
if (clear_tabs.empty() && tabs.empty()) return;
std::wstringstream & _pPr = Context.get_styles_context().paragraph_nodes();
_pPr << L"<w:tabs>";
for (std::map<double, odf_reader::office_element_ptr>::iterator it = clear_tabs.begin(); it != clear_tabs.end(); ++it)
{
odf_reader::style_tab_stop * tab_stop = dynamic_cast<odf_reader::style_tab_stop*>(it->second.get());
tab_stop->docx_convert(Context, true);
}
for (size_t i = 0; i < tabs.size(); i++)
{
odf_reader::style_tab_stop * tab_stop = dynamic_cast<odf_reader::style_tab_stop*>(tabs[i].get());
tab_stop->docx_convert(Context, false);
}
_pPr << L"</w:tabs>";
}
void styles_context::start_process_style(const odf_reader::style_instance * Instance)
{
current_processed_style_ = Instance;

View File

@ -33,6 +33,8 @@
#include <sstream>
#include <iosfwd>
#include <map>
#include <vector>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
@ -40,14 +42,41 @@
namespace cpdoccore {
namespace oox{
class docx_conversion_context;
class pptx_conversion_context;
};
namespace odf_reader
{
class style_instance;
class style_text_properties;
class fonts_container;
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
class office_element;
typedef boost::shared_ptr<office_element> office_element_ptr;
};
class tabs_context : boost::noncopyable
{
public:
std::vector<odf_reader::office_element_ptr> tabs;
std::map<double, odf_reader::office_element_ptr> clear_tabs;
void clear()
{
tabs.clear();
clear_tabs.clear();
}
void reset();
void add(const odf_reader::office_element_ptr & element);
void docx_convert(oox::docx_conversion_context & Context);
};
class styles_context : boost::noncopyable
{
public:

View File

@ -254,30 +254,31 @@ void rels_files::add(std::wstring const & Id,
{
return add(relationship(Id, Type, Target, TargetMode));
}
///////////////////////////////////////////
//-----------------------------------------------------------------------------------------------
chart_content::chart_content() : rels_(rels_file::create(L""))
{
}
_CP_PTR(chart_content) chart_content::create()
{
return boost::make_shared<chart_content>();
}
void chart_content::add_rel(relationship const & r)
{
rels_->get_rels().add(r);
}
///////////////////////////////////////////
//-----------------------------------------------------------------------------------------------
_CP_PTR(customXml_content) customXml_content::create(const std::wstring &item, const std::wstring &props)
{
return boost::make_shared<customXml_content>(item, props);
}
//-----------------------------------------------------------------------------------------------
element_ptr simple_element::create(const std::wstring & FileName, const std::wstring & Content)
{
return boost::make_shared<simple_element>(FileName, Content);
}
////////////
//-----------------------------------------------------------------------------------------------
void core_file::write(const std::wstring & RootPath)
{

View File

@ -61,7 +61,7 @@ typedef std::vector<element_ptr> element_ptr_array;
class document;
// element
//------------------------------------------------------------------------
class element
{
public:
@ -108,10 +108,10 @@ private:
};
//------------------------------------------------------------------------
class rels_file;
typedef boost::shared_ptr<rels_file> rels_file_ptr;
// rels_file
class rels_file : public element
{
public:
@ -132,7 +132,7 @@ private:
rels rels_;
};
// rels_files
//------------------------------------------------------------------------
class rels_files : public element
{
public:
@ -150,13 +150,29 @@ private:
rels_file_ptr rels_file_;
};
//------------------------------------------------------------------------
class customXml_content;
typedef _CP_PTR(customXml_content) customXml_content_ptr;
////////////////////////////////////////
///\class chart_files
class customXml_content : boost::noncopyable
{
public:
customXml_content(const std::wstring &item, const std::wstring &props) : content_item(item), content_props(props) {}
static _CP_PTR(customXml_content) create(const std::wstring &item, const std::wstring &props);
std::wstring item() { return content_item; }
std::wstring props() { return content_props; }
friend class customXml_files;
private:
std::wstring content_item;
std::wstring content_props;
};
///------------------------------------------------------------------------
class chart_content;
typedef _CP_PTR(chart_content) chart_content_ptr;
class chart_content : noncopyable
class chart_content : boost::noncopyable
{
public:
chart_content();
@ -169,7 +185,7 @@ private:
std::wstringstream content_;
rels_file_ptr rels_;
};
/////////////////////////////////
//------------------------------------------------------------------------
class document : public element
{
public:

View File

@ -31,8 +31,6 @@
*/
#include "calcs_styles.h"
#include <boost/foreach.hpp>
#include <vector>
#include <algorithm>
namespace cpdoccore {
@ -44,10 +42,10 @@ namespace odf_reader {
text_format_properties_content calc_text_properties_content(const std::vector<const style_text_properties*> & textProps)
{
text_format_properties_content result;
BOOST_FOREACH(const style_text_properties* v, textProps)
for (size_t i = 0; i < textProps.size(); i++)
{
if (v)
result.apply_from(v->content());
if (textProps[i])
result.apply_from(textProps[i]->content());
}
return result;
}
@ -60,20 +58,21 @@ text_format_properties_content calc_text_properties_content(const style_instance
{
if (const style_content * content = styleInstance->content())
if (const style_text_properties * textProp = content->get_style_text_properties())
textProps.push_back(textProp);
{
textProps.insert(textProps.begin(), textProp);
}
styleInstance = styleInstance->parent();
}
reverse(textProps.begin(), textProps.end());
return calc_text_properties_content(textProps);
}
text_format_properties_content calc_text_properties_content(const std::vector<const style_instance *> & styleInstances)
{
text_format_properties_content result;
BOOST_FOREACH(const style_instance * inst, styleInstances)
for (size_t i = 0; i < styleInstances.size(); i++)
{
result.apply_from(calc_text_properties_content(inst));
result.apply_from(calc_text_properties_content(styleInstances[i]));
}
return result;
}
@ -82,10 +81,10 @@ text_format_properties_content calc_text_properties_content(const std::vector<co
graphic_format_properties calc_graphic_properties_content(const std::vector<const graphic_format_properties*> & graphicProps)
{
graphic_format_properties result;
BOOST_FOREACH(const graphic_format_properties* v, graphicProps)
for (size_t i = 0; i < graphicProps.size(); i++)
{
if (v)
result.apply_from(v);
if (graphicProps[i])
result.apply_from(graphicProps[i]);
}
return result;
}
@ -97,20 +96,22 @@ graphic_format_properties calc_graphic_properties_content(const style_instance *
{
if (const style_content * content = styleInstance->content())
if (const graphic_format_properties * graphicProp = content->get_graphic_properties())
graphicProps.push_back(graphicProp);
{
graphicProps.insert(graphicProps.begin(), graphicProp);
}
styleInstance = styleInstance->parent();
}
reverse(graphicProps.begin(), graphicProps.end());
return calc_graphic_properties_content(graphicProps);
}
graphic_format_properties calc_graphic_properties_content(const std::vector<const style_instance *> & styleInstances)
{
graphic_format_properties result;
BOOST_FOREACH(const style_instance * inst, styleInstances)
{
graphic_format_properties f = calc_graphic_properties_content(inst);
for (size_t i = 0; i < styleInstances.size(); i++)
{
graphic_format_properties f = calc_graphic_properties_content(styleInstances[i]);
result.apply_from(&f);
}
return result;
@ -121,10 +122,11 @@ graphic_format_properties calc_graphic_properties_content(const std::vector<cons
paragraph_format_properties calc_paragraph_properties_content(const std::vector<const style_paragraph_properties*> & parProps)
{
paragraph_format_properties result;
BOOST_FOREACH(const style_paragraph_properties* v, parProps)
for (size_t i = 0; i < parProps.size(); i++)
{
if (v)
result.apply_from(v->content());
if (parProps[i])
result.apply_from(parProps[i]->content_);
}
return result;
}
@ -136,32 +138,60 @@ paragraph_format_properties calc_paragraph_properties_content(const style_instan
{
if (const style_content * content = styleInstance->content())
if (const style_paragraph_properties * parProp = content->get_style_paragraph_properties())
parProps.push_back(parProp);
{
parProps.insert(parProps.begin(), parProp);
}
styleInstance = styleInstance->parent();
}
reverse(parProps.begin(), parProps.end());
return calc_paragraph_properties_content(parProps);
}
paragraph_format_properties calc_paragraph_properties_content(const std::vector<const style_instance *> & styleInstances)
{
paragraph_format_properties result;
BOOST_FOREACH(const style_instance * inst, styleInstances)
for (size_t i = 0; i < styleInstances.size(); i++)
{
result.apply_from(calc_paragraph_properties_content(inst));
result.apply_from(calc_paragraph_properties_content(styleInstances[i]));
}
return result;
}
void calc_tab_stops(const style_instance * styleInstance, tabs_context & context)
{
std::vector<const style_paragraph_properties*> parProps;
while (styleInstance)
{
if (const style_content * content = styleInstance->content())
if (const style_paragraph_properties * parProp = content->get_style_paragraph_properties())
{
parProps.insert(parProps.begin(), parProp);
}
styleInstance = styleInstance->parent();
}
for (size_t i = 0; i < parProps.size(); i++)
{
if (parProps[i]->content_.style_tab_stops_)
{
style_tab_stops *tab_stops = dynamic_cast<style_tab_stops*>(parProps[i]->content_.style_tab_stops_.get());
context.reset();
for (size_t j = 0; j < tab_stops->content_.size(); j++)
{
context.add(tab_stops->content_[j]);
}
}
}
}
//////
style_table_cell_properties_attlist calc_table_cell_properties(const std::vector<const style_table_cell_properties*> & props)
{
style_table_cell_properties_attlist result;
BOOST_FOREACH(const style_table_cell_properties* v, props)
for (size_t i = 0; i < props.size(); i++)
{
if (v)
result.apply_from(v->attlist_);
if (props[i])
result.apply_from(props[i]->attlist_);
}
return result;
}
@ -173,19 +203,20 @@ style_table_cell_properties_attlist calc_table_cell_properties(const style_insta
{
if (const style_content * content = styleInstance->content())
if (const style_table_cell_properties * prop = content->get_style_table_cell_properties())
props.push_back(prop);
{
props.insert(props.begin(), prop);
}
styleInstance = styleInstance->parent();
}
reverse(props.begin(), props.end());
return calc_table_cell_properties(props);
}
style_table_cell_properties_attlist calc_table_cell_properties(const std::vector<const style_instance *> & styleInstances)
{
style_table_cell_properties_attlist result;
BOOST_FOREACH(const style_instance * inst, styleInstances)
for (size_t i = 0; i < styleInstances.size(); i++)
{
result.apply_from(calc_table_cell_properties(inst));
result.apply_from(calc_table_cell_properties(styleInstances[i]));
}
return result;
}

View File

@ -41,6 +41,7 @@
#include <vector>
namespace cpdoccore {
class tabs_context;
namespace odf_reader {
graphic_format_properties calc_graphic_properties_content(const style_instance * styleInstance);
@ -55,5 +56,6 @@ paragraph_format_properties calc_paragraph_properties_content(const std::vector<
style_table_cell_properties_attlist calc_table_cell_properties(const style_instance * styleInstance);
style_table_cell_properties_attlist calc_table_cell_properties(const std::vector<const style_instance *> & styleInstances);
void calc_tab_stops(const style_instance * styleInstance, tabs_context & context);
}
}

View File

@ -0,0 +1,146 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* 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 <boost/algorithm/string.hpp>
#include "bibliography.h"
#include <ostream>
namespace cpdoccore { namespace odf_types {
std::wostream & operator << (std::wostream & _Wostream, const bibliography & _Val)
{
switch(_Val.get_type())
{
case bibliography::article:
_Wostream << L"article";
break;
case bibliography::book:
_Wostream << L"book";
break;
case bibliography::booklet:
_Wostream << L"booklet";
break;
case bibliography::conference:
_Wostream << L"conference";
break;
case bibliography::email:
_Wostream << L"email";
break;
case bibliography::inbook:
_Wostream << L"inbook";
break;
case bibliography::incollection:
_Wostream << L"incollection";
break;
case bibliography::inproceedings:
_Wostream << L"inproceedings";
break;
case bibliography::journal:
_Wostream << L"journal";
break;
case bibliography::manual:
_Wostream << L"manual";
break;
case bibliography::mastersthesis:
_Wostream << L"mastersthesis";
break;
case bibliography::misc:
_Wostream << L"misc";
break;
case bibliography::phdthesis:
_Wostream << L"phdthesis";
break;
case bibliography::proceedings:
_Wostream << L"proceedings";
break;
case bibliography::techreport:
_Wostream << L"techreport";
break;
case bibliography::unpublished:
_Wostream << L"unpublished";
break;
case bibliography::www:
_Wostream << L"www";
break;
default:
break;
}
return _Wostream;
}
bibliography bibliography::parse(const std::wstring & Str)
{
std::wstring tmp = Str;
boost::algorithm::to_lower(tmp);
if (tmp == L"article")
return bibliography( article );
if (tmp == L"book")
return bibliography( book );
if (tmp == L"booklet")
return bibliography( booklet );
if (tmp == L"conference")
return bibliography( conference );
if (tmp == L"email")
return bibliography( email );
if (tmp == L"inbook")
return bibliography( inbook );
if (tmp == L"incollection")
return bibliography( incollection );
if (tmp == L"inproceedings")
return bibliography( inproceedings );
if (tmp == L"journal")
return bibliography( journal );
if (tmp == L"manual")
return bibliography( manual );
if (tmp == L"mastersthesis")
return bibliography( mastersthesis );
if (tmp == L"misc")
return bibliography( misc );
if (tmp == L"phdthesis")
return bibliography( phdthesis );
if (tmp == L"proceedings")
return bibliography( proceedings );
if (tmp == L"techreport")
return bibliography( techreport );
if (tmp == L"unpublished")
return bibliography( unpublished );
if (tmp == L"www")
return bibliography( www );
else
{
return bibliography( book );
}
}
} }

View File

@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* 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
#include <iosfwd>
#include <string>
#include "odfattributes.h"
namespace cpdoccore { namespace odf_types {
class bibliography
{
public:
enum type
{
article,
book,
booklet,
conference,
email,
inbook,
incollection,
inproceedings,
journal,
manual,
mastersthesis,
misc,
phdthesis,
proceedings,
techreport,
unpublished,
www
};
bibliography() : type_(book) {}
bibliography(type _Type) : type_(_Type)
{}
type get_type() const
{
return type_;
};
static bibliography parse(const std::wstring & Str);
private:
type type_;
};
std::wostream & operator << (std::wostream & _Wostream, const bibliography & _Val);
}
APPLY_PARSE_XML_ATTRIBUTES(odf_types::bibliography);
}

View File

@ -58,6 +58,8 @@ namespace _image_file_
{
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts* appFonts)
{
if (!appFonts) return false;
CBgraFrame image;
MetaFile::IMetaFile* meta_file = MetaFile::Create(appFonts);

View File

@ -77,6 +77,10 @@ void content_xml_t::add_child_element( xml::sax * Reader, const std::wstring & N
create_element_and_read(Reader, Ns, Name, content_, &context_, true);
}
else if CP_CHECK_NAME(L"office", L"document-settings")
{
create_element_and_read(Reader, Ns, Name, content_, &context_, true);
}
else if CP_CHECK_NAME(L"office", L"document-meta")
{
create_element_and_read(Reader, Ns, Name, content_, &context_, true);
}
@ -88,6 +92,7 @@ void content_xml_t::add_child_element( xml::sax * Reader, const std::wstring & N
{
create_element_and_read(Reader, Ns, Name, content_, &context_, true);
}
}
void content_xml_t::add_text(const std::wstring & Text)

View File

@ -56,6 +56,7 @@
#include "office_scripts.h"
#include "office_forms.h"
#include "office_event_listeners.h"
#include "office_meta.h"
#include "styles.h"
#include "style_regions.h"
@ -142,6 +143,9 @@ odf_document::Impl::Impl(xml::sax * Reader, const std::wstring & tempPath):
_CP_LOG << L"[info] parse manifest" << std::endl;
parse_manifests(content_xml_->get_content());
_CP_LOG << L"[info] parse meta" << std::endl;
parse_meta(content_xml_->get_content());
_CP_LOG << L"[info] parse settings" << std::endl;
parse_settings(content_xml_->get_content());
@ -207,6 +211,8 @@ odf_document::Impl::Impl(const std::wstring & srcPath, const std::wstring & temp
_CP_LOG << L"[info] read styles.xml" << std::endl;
styles_xml_ = read_file_content(styles_xml);
_CP_LOG << L"[info] read meta.xml" << std::endl;
meta_xml_ = read_file_content(meta_xml);
//----------------------------------------------------------------------------------------
_CP_LOG << L"[info] parse fonts" << std::endl;
parse_fonts(content_xml_ ? content_xml_->get_content() : NULL);
@ -217,6 +223,8 @@ odf_document::Impl::Impl(const std::wstring & srcPath, const std::wstring & temp
_CP_LOG << L"[info] parse settings" << std::endl;
parse_settings(settings_xml_ ? settings_xml_->get_content() : NULL);
_CP_LOG << L"[info] parse meta" << std::endl;
parse_meta(meta_xml_ ? meta_xml_->get_content() : NULL);
}
else
{
@ -636,7 +644,26 @@ void odf_document::Impl::parse_settings(office_element *element)
}
}
}
}
}
void odf_document::Impl::parse_meta(office_element *element)
{
office_document_base * document = dynamic_cast<office_document_base *>( element );
if (!document) return;
office_meta * meta = dynamic_cast<office_meta*>(document->office_meta_.get());
if (!meta) return;
for (size_t i = 0; i < meta->meta_user_defined_.size(); i++)
{
meta_user_defined * user_defined = dynamic_cast<meta_user_defined*>(meta->meta_user_defined_[i].get());
if (!user_defined) continue;
if (user_defined->meta_name_.empty()) continue;
context_->Settings().add_user_defined(user_defined->meta_name_, user_defined->content_);
}
}
void odf_document::Impl::parse_styles(office_element *element)

View File

@ -96,6 +96,7 @@ private:
void parse_fonts (office_element *elemen);
void parse_manifests(office_element *element);
void parse_settings (office_element *element);
void parse_meta (office_element *element);
bool decrypt_folder (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath);
bool decrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, office_element_ptr data, int size );

View File

@ -333,7 +333,7 @@ page_layout_instance::page_layout_instance(const style_page_layout * StylePageLa
const std::wstring & page_layout_instance::name() const
{
return style_page_layout_->attlist_.get_style_name();
return style_page_layout_->style_name_;
}
style_page_layout_properties * page_layout_instance::properties() const
@ -371,6 +371,11 @@ void page_layout_instance::docx_serialize(std::wostream & strm, oox::docx_conver
_CP_OPT(length) bottom = attr.fo_min_height_ ? attr.fo_min_height_ : attr.svg_height_;
Context.get_header_footer_context().set_footer(bottom);
}
if ( style_page_layout_->style_page_usage_.get_type() == page_usage::Mirrored )
{
Context.set_settings_property(odf_reader::_property(L"mirrorMargins",true));
}
style_page_layout_properties * props = properties();
if (props)

View File

@ -74,7 +74,9 @@ void office_document_base::add_child_element( xml::sax * Reader, const std::wstr
CP_CREATE_ELEMENT(office_scripts_);
else if CP_CHECK_NAME(L"office", L"settings")
CP_CREATE_ELEMENT(office_settings_);
else if CP_CHECK_NAME(L"manifest", L"file-entry")
else if CP_CHECK_NAME(L"office", L"meta")
CP_CREATE_ELEMENT(office_meta_);
else if CP_CHECK_NAME(L"manifest", L"file-entry")
CP_CREATE_ELEMENT(manifests_);
else
CP_NOT_APPLICABLE_ELM();

View File

@ -50,6 +50,7 @@ enum ElementType
typeTextReferenceMark,
typeTextReferenceMarkStart,
typeTextReferenceMarkEnd,
typeTextReferenceRef,
typeTextFieldFieldmarkStart,
typeTextFieldFieldmarkEnd,
@ -98,12 +99,19 @@ enum ElementType
typeTextSequenceDecls,
typeTextSequenceDecl,
typeTextSequence,
typeTextSequenceRef,
typeTextHiddenParagraph,
typeTextHiddenText,
typePresentationFooter,
typePresentationDateTime,
typeDcCreator,
typeDcDate,
typeDcDescription,
typeDcSubject,
typeDcTitle,
typeDrawA,
@ -122,27 +130,62 @@ enum ElementType
typeTextNumberedParagraph,
typeTextExpression,
typeTextCommonEntryTemplate,
typeTextTableOfContent,
typeTextTableOfContentSource,
typeTextTableOfContentEntryTemplate,
typeTextIndexEntryText,
typeTextIndexEntryTabStop,
typeTextIndexEntrySpan,
typeTextIndexEntryPageNumber,
typeTextIndexEntryLinkStart,
typeTextIndexEntryLinkEnd,
typeTextIndexEntryChapter,
typeTextIndexEntryBibliography,
typeTextIllustrationIndex,
typeTextIllustrationIndexSource,
typeTextIllustrationIndexEntryTemplate,
typeTextTableIndex,
typeTextTableIndexSource,
typeTextTableIndexEntryTemplate,
typeTextObjectIndex,
typeTextObjectIndexSource,
typeTextObjectIndexEntryTemplate,
typeTextUserIndex,
typeTextUserIndexSource,
typeTextUserIndexEntryTemplate,
typeTextAlphabeticalIndex,
typeTextAlphabeticalIndexSource,
typeTextAlphabeticalIndexEntryTemplate,
typeTextBibliography,
typeTextBibliographySource,
typeTextBibliographyEntryTemplate,
typeTextBibliographyMark,
typeTextBibliographySource,
typeTextAlphabeticalIndexAutoMarkFile,
typeTextAlphabeticalIndexMarkStart,
typeTextAlphabeticalIndexMarkEnd,
typeTextAlphabeticalIndexMark,
typeTextTocMarkStart,
typeTextTocMarkEnd,
typeTextTocMark,
typeTextUserIndexMarkStart,
typeTextUserIndexMarkEnd,
typeTextUserIndexMark,
typeTextIndexSourceStyles,
typeTextIndexSourceStyle,
typeTextVariableInput,
typeTextVariableGet,
@ -156,6 +199,8 @@ enum ElementType
typeTextUserFieldSet,
typeTextUserFieldInput,
typeTextUserDefined,
typeTextTrackedChanges,
typeTextChangedRegion,
typeTextChangeStart,
@ -234,6 +279,8 @@ enum ElementType
typeTableOddColumnsTemplate,
typeTableOddRowsTemplate,
typeTextIndexTitleTemplate,
typeTextNotesConfiguration,
typeStyleFontFace,
@ -374,6 +421,15 @@ enum ElementType
typeOfficeSettingsConfigItemMapNamed,
typeOfficeSettingsConfigItemMapEntry,
typeOfficeMeta,
typeOfficeMetaUserDefined,
typeOfficeMetaDocumentStatistic,
typeOfficeMetaGenerator,
typeOfficeMetaCreationDate,
typeOfficeMetaKeyword,
typeOfficeMetaEditingCycles,
typeOfficeMetaEditingDuration,
typeDrawG,
typeDrawFrame,
typeDrawImage,

View File

@ -0,0 +1,111 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* 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 "office_meta.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/attributes.h>
#include "serialize_elements.h"
namespace cpdoccore {
namespace odf_reader {
// office:meta
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * office_meta::ns = L"office";
const wchar_t * office_meta::name = L"meta";
void office_meta::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}
void office_meta::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if (Ns==L"meta" && Name == L"generator")
{
CP_CREATE_ELEMENT(meta_generator_);
}
else if (Ns==L"meta" && Name == L"document-statistic")
{
CP_CREATE_ELEMENT(meta_document_statistic_);
}
else if (Ns==L"meta" && Name == L"user-defined")
{
CP_CREATE_ELEMENT(meta_user_defined_);
}
else
{
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * meta_generator::ns = L"meta";
const wchar_t * meta_generator::name = L"generator";
void meta_generator::add_text(const std::wstring & text)
{
content_ = text;
}
// config_item
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * meta_document_statistic::ns = L"meta";
const wchar_t * meta_document_statistic::name = L"document-statistic";
void meta_document_statistic::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"meta:table-count", meta_table_count_);
CP_APPLY_ATTR(L"meta:image-count", meta_image_count_);
CP_APPLY_ATTR(L"meta:object-count", meta_object_count_);
CP_APPLY_ATTR(L"meta:page-count", meta_page_count_);
CP_APPLY_ATTR(L"meta:paragraph-count", meta_paragraph_count_);
CP_APPLY_ATTR(L"meta:word-count", meta_word_count_);
CP_APPLY_ATTR(L"meta:character-count", meta_character_count_);
}
// meta_user_defined
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * meta_user_defined::ns = L"meta";
const wchar_t * meta_user_defined::name = L"user-defined";
void meta_user_defined::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"meta:name", meta_name_, std::wstring(L""));
}
void meta_user_defined::add_text(const std::wstring & text)
{
content_ = text;
}
}
}

View File

@ -0,0 +1,132 @@
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
* 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
#include <iosfwd>
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/xml/xmlelement.h>
#include <cpdoccore/xml/nodetype.h>
#include "office_elements.h"
#include "office_elements_create.h"
namespace cpdoccore {
namespace odf_reader {
// office:meta
class office_meta : public office_element_impl<office_meta>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficeMeta;
CPDOCCORE_DEFINE_VISITABLE();
office_element_ptr_array meta_user_defined_;
office_element_ptr meta_generator_;
office_element_ptr meta_document_statistic_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text){}
};
CP_REGISTER_OFFICE_ELEMENT2(office_meta);
// meta:generator
class meta_generator : public office_element_impl<meta_generator>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficeMetaGenerator;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(meta_generator);
// meta:document-statistic
class meta_document_statistic : public office_element_impl<meta_document_statistic>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficeMetaDocumentStatistic;
CPDOCCORE_DEFINE_VISITABLE();
_CP_OPT(int) meta_table_count_;
_CP_OPT(int) meta_image_count_;
_CP_OPT(int) meta_object_count_;
_CP_OPT(int) meta_page_count_;
_CP_OPT(int) meta_paragraph_count_;
_CP_OPT(int) meta_word_count_;
_CP_OPT(int) meta_character_count_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text){}
};
CP_REGISTER_OFFICE_ELEMENT2(meta_document_statistic);
// meta:user-defined
class meta_user_defined : public office_element_impl<meta_user_defined>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficeMetaUserDefined;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring meta_name_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(meta_user_defined);
}
}

View File

@ -134,6 +134,9 @@ void office_text::add_child_element( xml::sax * Reader, const std::wstring & Ns,
void office_text::docx_convert(oox::docx_conversion_context & Context)
{
if (sequences_)
sequences_->docx_convert(Context);
if (user_fields_)
user_fields_->docx_convert(Context);

View File

@ -91,7 +91,7 @@ void paragraph_content_element<ElementT>::docx_serialize_field(const std::wstrin
}
}
template <class ElementT>
void paragraph_content_element<ElementT>::docx_serialize_sdt(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context)
void paragraph_content_element<ElementT>::docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context)
{
std::wostream & strm = Context.output_stream();
Context.finish_run();
@ -101,11 +101,6 @@ void paragraph_content_element<ElementT>::docx_serialize_sdt(const std::wstring
strm << L"\"/><w:temporary/>";
strm << L"<w:showingPlcHdr/><w:text/></w:sdtPr><w:sdtContent>";
//if (!text)
//{
// text = text::create(L"Enter your text here") ;
//}
docx_serialize_run(text, Context);
strm << L"</w:sdtContent></w:sdt>";
@ -153,7 +148,13 @@ void text::docx_convert(oox::docx_conversion_context & Context)
Context.output_stream() << L"<w:del>";
}
}
if (Context.is_table_content())
{
int type = Context.get_table_content_context().get_type_current_content_template_index();
if (type == 6)
{
}
}
Context.add_element_to_run();
std::wstring textNode = L"w:t";
@ -319,23 +320,18 @@ void line_break::pptx_convert(oox::pptx_conversion_context & Context)
const wchar_t * bookmark::ns = L"text";
const wchar_t * bookmark::name = L"bookmark";
std::wostream & bookmark::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void bookmark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", text_name_, std::wstring(L""));
}
std::wostream & bookmark::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * bookmark_start::ns = L"text";
const wchar_t * bookmark_start::name = L"bookmark-start";
std::wostream & bookmark_start::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void bookmark_start::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", name_, std::wstring(L""));
@ -344,14 +340,14 @@ void bookmark_start::docx_convert(oox::docx_conversion_context & Context)
{
Context.start_bookmark(name_);
}
std::wostream & bookmark_start::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * bookmark_end::ns = L"text";
const wchar_t * bookmark_end::name = L"bookmark-end";
std::wostream & bookmark_end::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void bookmark_end::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", name_, std::wstring(L""));
@ -360,34 +356,42 @@ void bookmark_end::docx_convert(oox::docx_conversion_context & Context)
{
Context.end_bookmark(name_);
}
std::wostream & bookmark_end::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * bookmark_ref::ns = L"text";
const wchar_t * bookmark_ref::name = L"bookmark-ref";
std::wostream & bookmark_ref::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void bookmark_ref::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:ref-name", text_ref_name_, std::wstring(L""));
CP_APPLY_ATTR(L"text:reference-format", text_reference_format_);
CP_APPLY_ATTR(L"text:ref-name", ref_name_, std::wstring(L""));
CP_APPLY_ATTR(L"text:reference-format", reference_format_);
}
void bookmark_ref::add_text(const std::wstring & Text)
{
content_ = Text;
}
// text:reference-ref
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * reference_ref::ns = L"text";
const wchar_t * reference_ref::name = L"reference-ref";
void reference_ref::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:ref-name", ref_name_, std::wstring(L""));
CP_APPLY_ATTR(L"text:reference-format", reference_format_);
}
void reference_ref::add_text(const std::wstring & Text)
{
content_ = Text;
}
// text:reference-mark
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * reference_mark::ns = L"text";
const wchar_t * reference_mark::name = L"reference-mark";
std::wostream & reference_mark::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void reference_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", text_name_, std::wstring(L""));
@ -398,11 +402,6 @@ void reference_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
const wchar_t * reference_mark_start::ns = L"text";
const wchar_t * reference_mark_start::name = L"reference-mark-start";
std::wostream & reference_mark_start::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void reference_mark_start::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", text_name_, std::wstring(L""));
@ -413,16 +412,43 @@ void reference_mark_start::add_attributes( const xml::attributes_wc_ptr & Attrib
const wchar_t * reference_mark_end::ns = L"text";
const wchar_t * reference_mark_end::name = L"reference-mark-end";
std::wostream & reference_mark_end::text_to_stream(std::wostream & _Wostream) const
{
return _Wostream;
}
void reference_mark_end::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:name", text_name_, std::wstring(L""));
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * hidden_paragraph::ns = L"text";
const wchar_t * hidden_paragraph::name = L"hidden-paragraph";
void hidden_paragraph::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:is-hidden", is_hidden_);
CP_APPLY_ATTR(L"text:condition", condition_);
}
void hidden_paragraph::add_text(const std::wstring & Text)
{
content_ = Text;
}
void hidden_paragraph::docx_convert(oox::docx_conversion_context & Context)
{
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * hidden_text::ns = L"text";
const wchar_t * hidden_text::name = L"hidden-text";
void hidden_text::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:is-hidden", is_hidden_);
CP_APPLY_ATTR(L"text:condition", condition_);
CP_APPLY_ATTR(L"text:string-value", string_value_);
}
void hidden_text::add_text(const std::wstring & Text)
{
content_ = Text;
}
void hidden_text::docx_convert(oox::docx_conversion_context & Context)
{
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * span::ns = L"text";
const wchar_t * span::name = L"span";
@ -584,6 +610,9 @@ void a::docx_convert(oox::docx_conversion_context & Context)
if (Context.is_table_content())
{
_Wostream << L"<w:hyperlink w:anchor=\"" << ref.substr(1) << L"\" w:history=\"1\">"; //без #
int type = Context.get_table_content_context().get_type_current_content_template_index();
//type == 3 (LinkStart)
Context.get_table_content_context().next_level_index();
}
else
{
@ -633,7 +662,11 @@ void a::docx_convert(oox::docx_conversion_context & Context)
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->docx_convert(Context);
}
if (Context.is_table_content())
{
Context.get_table_content_context().next_level_index();
}
}
Context.finish_run();
@ -930,7 +963,7 @@ void text_placeholder::add_text(const std::wstring & Text)
void text_placeholder::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Click placeholder and overwrite", text_, Context);
docx_serialize_sdt_placeholder(L"Click placeholder and overwrite", text_, Context);
}
void text_placeholder::pptx_convert(oox::pptx_conversion_context & Context)
@ -1166,24 +1199,38 @@ void text_file_name::pptx_convert(oox::pptx_conversion_context & Context)
// Context.get_text_context().end_field();
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sequence_ref::ns = L"text";
const wchar_t * sequence_ref::name = L"sequence-ref";
void sequence_ref::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:ref-name", ref_name_);
CP_APPLY_ATTR(L"text:reference-format", reference_format_);
}
void sequence_ref::add_text(const std::wstring & Text)
{
content_ = Text;
}
void sequence_ref::docx_convert(oox::docx_conversion_context & Context)
{
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sequence::ns = L"text";
const wchar_t * sequence::name = L"sequence";
void sequence::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:num-format", style_num_format_);
CP_APPLY_ATTR(L"style:num-letter-sync", style_num_letter_sync_);
CP_APPLY_ATTR(L"text:formula", formula_);
CP_APPLY_ATTR(L"text:ref-name", ref_name_);
CP_APPLY_ATTR(L"text:name", name_);
}
std::wostream & sequence::text_to_stream(std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(text_);
return _Wostream;
}
void sequence::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:num-format", style_num_format_);
CP_APPLY_ATTR(L"style:num-letter-sync", style_num_letter_sync_);
CP_APPLY_ATTR(L"text:formula", text_formula_);
CP_APPLY_ATTR(L"text:ref-name", text_ref_name_);
CP_APPLY_ATTR(L"text:name", text_name_);
}
void sequence::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
@ -1197,19 +1244,20 @@ void sequence::add_text(const std::wstring & Text)
void sequence::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring ref;
if (text_ref_name_ && text_name_)
std::wstring ref, sequence;
if (ref_name_)
{
size_t pos = text_ref_name_->find(L"ref" + *text_name_);
sequence = Context.get_table_content_context().get_sequence(*ref_name_);
size_t pos = ref_name_->find(L"ref" + ref);
if (pos != std::wstring::npos)
{
ref = *text_name_ + L"!" + text_ref_name_->substr(pos + 3 + text_name_->length()) + L"|sequence";
ref = sequence + L"!" + ref_name_->substr(pos + 3 + sequence.length()) + L"|sequence";
}
}
if (!ref.empty())
{
Context.start_bookmark(ref);
}
//if (!ref.empty())
//{
// Context.start_bookmark(ref);
//}
Context.add_new_run();
Context.output_stream() << L"<w:t>" << template_ << L"</w:t>";
@ -1230,7 +1278,7 @@ void sequence::docx_convert(oox::docx_conversion_context & Context)
}
}
Context.output_stream() << L"<w:fldSimple w:instr=\" SEQ " << template_ << L" \\* " << num_format << L" \">";
Context.output_stream() << L"<w:fldSimple w:instr=\" SEQ " << sequence << L" \\* " << num_format << L" \">";
Context.add_new_run();
for (size_t i = 0; i < text_.size(); i++)
{
@ -1238,34 +1286,11 @@ void sequence::docx_convert(oox::docx_conversion_context & Context)
}
Context.finish_run();
if (!ref.empty())
{
Context.end_bookmark(ref);
}
Context.output_stream() << L"</w:fldSimple>";
//Context.add_new_run();
// Context.output_stream() << L"<w:fldChar w:fldCharType=\"begin\"/>";
//Context.finish_run();
//
//Context.add_new_run();
//Context.output_stream() << L"<w:instrText xml:space=\"preserve\"> SEQ " << template_ << L" \\* ARABIC </w:instrText>";
// Context.finish_run();
//Context.add_new_run();
// Context.output_stream() << L"<w:fldChar w:fldCharType=\"separate\"/>";
//Context.finish_run();
//
//for (size_t i = 0; i < text_.size(); i++)
//if (!ref.empty())
//{
// text_[i]->docx_convert(Context);
// Context.end_bookmark(ref);
//}
//Context.end_bookmark();
//
//Context.add_new_run();
// Context.output_stream() << L"<w:fldChar w:fldCharType=\"end\"/>";
//Context.finish_run();
Context.output_stream() << L"</w:fldSimple>";
}
void sequence::pptx_convert(oox::pptx_conversion_context & Context)
{
@ -1351,7 +1376,7 @@ void sheet_name::add_text(const std::wstring & Text)
}
void sheet_name::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"sheet name", text_, Context);
docx_serialize_sdt_placeholder(L"sheet name", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * author_name::ns = L"text";
@ -1397,7 +1422,7 @@ void sender_city::add_text(const std::wstring & Text)
}
void sender_city::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender city", text_, Context);
docx_serialize_sdt_placeholder(L"Sender city", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sender_email::ns = L"text";
@ -1412,7 +1437,7 @@ void sender_email::add_text(const std::wstring & Text)
}
void sender_email::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender email", text_, Context);
docx_serialize_sdt_placeholder(L"Sender email", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sender_lastname::ns = L"text";
@ -1427,7 +1452,7 @@ void sender_lastname::add_text(const std::wstring & Text)
}
void sender_lastname::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender last name", text_, Context);
docx_serialize_sdt_placeholder(L"Sender last name", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sender_firstname::ns = L"text";
@ -1442,7 +1467,7 @@ void sender_firstname::add_text(const std::wstring & Text)
}
void sender_firstname::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender first name", text_, Context);
docx_serialize_sdt_placeholder(L"Sender first name", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sender_company::ns = L"text";
@ -1457,7 +1482,7 @@ void sender_company::add_text(const std::wstring & Text)
}
void sender_company::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender company", text_, Context);
docx_serialize_sdt_placeholder(L"Sender company", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sender_postal_code::ns = L"text";
@ -1479,7 +1504,7 @@ void sender_postal_code::add_text(const std::wstring & Text)
}
void sender_postal_code::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender postal code", text_, Context);
docx_serialize_sdt_placeholder(L"Sender postal code", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
const wchar_t * sender_street::ns = L"text";
@ -1494,7 +1519,7 @@ void sender_street::add_text(const std::wstring & Text)
}
void sender_street::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender street", text_, Context);
docx_serialize_sdt_placeholder(L"Sender street", text_, Context);
}
//------------------------------------------------------------------------------------------------------------
@ -1510,7 +1535,7 @@ void sender_state_or_province::add_text(const std::wstring & Text)
}
void sender_state_or_province::docx_convert(oox::docx_conversion_context & Context)
{
docx_serialize_sdt(L"Sender state or province", text_, Context);
docx_serialize_sdt_placeholder(L"Sender state or province", text_, Context);
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_user_field_get::ns = L"text";
@ -1533,11 +1558,320 @@ void text_user_field_get::docx_convert(oox::docx_conversion_context & Context)
if (!text_)
{
std::wstring value = Context.get_user_field(*text_name_);
text_ = text::create(value) ;
if (!value.empty())
text_ = text::create(value) ;
}
docx_serialize_run(text_, Context);
}
//---------------------------------------------------------------------------------------------------
const wchar_t * text_user_defined::ns = L"text";
const wchar_t * text_user_defined::name = L"user-defined";
void text_user_defined::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
CP_APPLY_ATTR(L"text:name", text_name_);
CP_APPLY_ATTR(L"text:fixed", text_fixed_);
office_value_.add_attributes(Attributes);
}
void text_user_defined::add_text(const std::wstring & Text)
{
text_ = text::create(Text) ;//cache
}
void text_user_defined::docx_convert(oox::docx_conversion_context & Context)
{
if (!text_name_) return;
odf_reader::odf_read_context & odfContext = Context.root()->odf_context();
std::wstring value = odfContext.Settings().get_user_defined(*text_name_);
if (!value.empty())
text_ = text::create(value) ;
docx_serialize_run(text_, Context);
}
//-----------------------------------------------------------------------------------------------
// text:bibliography-mark
//-----------------------------------------------------------------------------------------------
const wchar_t * bibliography_mark::ns = L"text";
const wchar_t * bibliography_mark::name = L"bibliography-mark";
void bibliography_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:identifier", identifier_, std::wstring(L""));
CP_APPLY_ATTR(L"text:bibliography-type",bibliography_type_, odf_types::bibliography(odf_types::bibliography::book));
CP_APPLY_ATTR(L"text:author", author_);
CP_APPLY_ATTR(L"text:url", url_);
CP_APPLY_ATTR(L"text:title", title_);
CP_APPLY_ATTR(L"text:year", year_);
CP_APPLY_ATTR(L"text:address", address_);
CP_APPLY_ATTR(L"text:annote", annote_);
CP_APPLY_ATTR(L"text:booktitle", booktitle_);
CP_APPLY_ATTR(L"text:edition", edition_);
CP_APPLY_ATTR(L"text:editor_", editor_);
CP_APPLY_ATTR(L"text:howpublished", howpublished_);
CP_APPLY_ATTR(L"text:institution", institution_);
CP_APPLY_ATTR(L"text:issn", issn_);
CP_APPLY_ATTR(L"text:journal", journal_);
CP_APPLY_ATTR(L"text:month", month_);
CP_APPLY_ATTR(L"text:note", note_);
CP_APPLY_ATTR(L"text:number", number_);
CP_APPLY_ATTR(L"text:organizations", organizations_);
CP_APPLY_ATTR(L"text:pages", pages_);
CP_APPLY_ATTR(L"text:publisher", publisher_);
CP_APPLY_ATTR(L"text:report-type", report_type_);
CP_APPLY_ATTR(L"text:school", school_);
CP_APPLY_ATTR(L"text:series", series_);
CP_APPLY_ATTR(L"text:volume", volume_);
}
void bibliography_mark::add_text(const std::wstring & Text)
{
office_element_ptr elm = text::create(Text) ;
content_ = elm;
}
std::wostream & bibliography_mark::text_to_stream(std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(content_);
return _Wostream;
}
void bibliography_mark::docx_convert(oox::docx_conversion_context & Context)
{
std::wstringstream strm;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"b:Tag")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(identifier_);
}
CP_XML_NODE(L"b:SourceType")
{
std::wstring type;
switch(bibliography_type_.get_type())
{
case odf_types::bibliography::article: type = L"ArticleInAPeriodical"; break;
case odf_types::bibliography::book: type = L"Book"; break;
case odf_types::bibliography::booklet: type = L"BookSection"; break;
case odf_types::bibliography::conference: type = L"ConferenceProceedings"; break;
case odf_types::bibliography::email: type = L"ElectronicSource"; break;
case odf_types::bibliography::inbook: type = L"Book"; break;
case odf_types::bibliography::incollection: type = L"Misc"; break;
case odf_types::bibliography::inproceedings: type = L"Misc"; break;
case odf_types::bibliography::journal: type = L"JournalArticle"; break;
case odf_types::bibliography::manual: type = L"ElectronicSource"; break;
case odf_types::bibliography::mastersthesis: type = L"Misc"; break;
case odf_types::bibliography::misc: type = L"Misc"; break;
case odf_types::bibliography::phdthesis: type = L"Misc"; break;
case odf_types::bibliography::proceedings: type = L"ConferenceProceedings"; break;
case odf_types::bibliography::techreport: type = L"Report"; break;
case odf_types::bibliography::unpublished: type = L"Misc"; break;
case odf_types::bibliography::www: type = L"InternetSite"; break;
}
CP_XML_STREAM() << type;
}
//CP_XML_NODE(L"b:Guid")
//{
//}
if (title_)
{
CP_XML_NODE(L"b:Title")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*title_);
}
}
if (author_)
{
CP_XML_NODE(L"b:Author")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*author_);
}
}
if (year_)
{
CP_XML_NODE(L"b:Year")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*year_);
}
}
if (url_)
{
CP_XML_NODE(L"b:InternetSiteTitle")
{
CP_XML_STREAM() << XmlUtils::EncodeXmlString(*url_);
}
}
}
Context.add_bibliography_item(strm.str());
}
void bibliography_mark::pptx_convert(oox::pptx_conversion_context & Context)
{
if (content_)
content_->pptx_convert(Context);
}
//-----------------------------------------------------------------------------------------------
// text:alphabetical-index-auto-mark-file
//-----------------------------------------------------------------------------------------------
const wchar_t * alphabetical_index_auto_mark_file::ns = L"text";
const wchar_t * alphabetical_index_auto_mark_file::name = L"alphabetical-index-auto-mark-file";
void alphabetical_index_auto_mark_file::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
xlink_attlist_.add_attributes(Attributes);
}
void alphabetical_index_auto_mark_file::docx_convert(oox::docx_conversion_context & Context)
{
}
//-----------------------------------------------------------------------------------------------
// text:alphabetical-index-mark
//-----------------------------------------------------------------------------------------------
const wchar_t * alphabetical_index_mark::ns = L"text";
const wchar_t * alphabetical_index_mark::name = L"alphabetical-index-mark";
void alphabetical_index_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:key1", key1_);
CP_APPLY_ATTR(L"text:key1-phonetic", key1_phonetic_);
CP_APPLY_ATTR(L"text:key2", key2_);
CP_APPLY_ATTR(L"text:key2-phonetic", key2_phonetic_);
CP_APPLY_ATTR(L"text:main-entry", main_entry_);
CP_APPLY_ATTR(L"text:string-value", string_value_);
CP_APPLY_ATTR(L"text:string-value-phonetic", string_value_phonetic_);
}
void alphabetical_index_mark::docx_convert(oox::docx_conversion_context & Context)
{
if (!string_value_) return;
Context.finish_run();
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>";
Context.output_stream() << L"<w:r><w:instrText> XE \"" << *string_value_ << L"\"</w:instrText></w:r><w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
}
//-----------------------------------------------------------------------------------------------
// text:alphabetical-index-mark-start
//-----------------------------------------------------------------------------------------------
const wchar_t * alphabetical_index_mark_start::ns = L"text";
const wchar_t * alphabetical_index_mark_start::name = L"alphabetical-index-mark-start";
void alphabetical_index_mark_start::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:id", id_, std::wstring(L""));
CP_APPLY_ATTR(L"text:key1", key1_);
CP_APPLY_ATTR(L"text:key1-phonetic", key1_phonetic_);
CP_APPLY_ATTR(L"text:key2", key2_);
CP_APPLY_ATTR(L"text:key2-phonetic", key2_phonetic_);
CP_APPLY_ATTR(L"text:main-entry", main_entry_);
CP_APPLY_ATTR(L"text:string-value-phonetic", string_value_phonetic_);
}
void alphabetical_index_mark_start::docx_convert(oox::docx_conversion_context & Context)
{
Context.start_alphabetical_index(id_);
}
//-----------------------------------------------------------------------------------------------
// text:alphabetical-index-mark-end
//-----------------------------------------------------------------------------------------------
const wchar_t * alphabetical_index_mark_end::ns = L"text";
const wchar_t * alphabetical_index_mark_end::name = L"alphabetical-index-mark-end";
void alphabetical_index_mark_end::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:id", id_, std::wstring(L""));
}
void alphabetical_index_mark_end::docx_convert(oox::docx_conversion_context & Context)
{
Context.end_alphabetical_index(id_);
}
//-----------------------------------------------------------------------------------------------
// text:user-index-mark
//-----------------------------------------------------------------------------------------------
const wchar_t * user_index_mark::ns = L"text";
const wchar_t * user_index_mark::name = L"user-index-mark";
void user_index_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:index-name", index_name_);
CP_APPLY_ATTR(L"text:outline-level", outline_level_);
CP_APPLY_ATTR(L"text:string-value", string_value_);
}
void user_index_mark::docx_convert(oox::docx_conversion_context & Context)
{
}
//-----------------------------------------------------------------------------------------------
// text:user-index-mark-start
//-----------------------------------------------------------------------------------------------
const wchar_t * user_index_mark_start::ns = L"text";
const wchar_t * user_index_mark_start::name = L"user-index-mark-start";
void user_index_mark_start::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:id", id_, std::wstring(L""));
CP_APPLY_ATTR(L"text:index-name", index_name_);
CP_APPLY_ATTR(L"text:outline-level", outline_level_);
}
void user_index_mark_start::docx_convert(oox::docx_conversion_context & Context)
{
}
//-----------------------------------------------------------------------------------------------
// text:user-index-mark-end
//-----------------------------------------------------------------------------------------------
const wchar_t * user_index_mark_end::ns = L"text";
const wchar_t * user_index_mark_end::name = L"user-index-mark-end";
void user_index_mark_end::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:id", id_, std::wstring(L""));
}
void user_index_mark_end::docx_convert(oox::docx_conversion_context & Context)
{
}
//-----------------------------------------------------------------------------------------------
// text:toc-mark
//-----------------------------------------------------------------------------------------------
const wchar_t * toc_mark::ns = L"text";
const wchar_t * toc_mark::name = L"toc-mark";
void toc_mark::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:outline-level", outline_level_);
CP_APPLY_ATTR(L"text:string-value", string_value_);
}
void toc_mark::docx_convert(oox::docx_conversion_context & Context)
{
}
//-----------------------------------------------------------------------------------------------
// text:toc-mark-start
//-----------------------------------------------------------------------------------------------
const wchar_t * toc_mark_start::ns = L"text";
const wchar_t * toc_mark_start::name = L"toc-mark-start";
void toc_mark_start::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:id", id_, std::wstring(L""));
CP_APPLY_ATTR(L"text:outline-level", outline_level_);
}
void toc_mark_start::docx_convert(oox::docx_conversion_context & Context)
{
}
//-----------------------------------------------------------------------------------------------
// text:toc-mark-end
//-----------------------------------------------------------------------------------------------
const wchar_t * toc_mark_end::ns = L"text";
const wchar_t * toc_mark_end::name = L"toc-mark-end";
void toc_mark_end::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:id", id_, std::wstring(L""));
}
void toc_mark_end::docx_convert(oox::docx_conversion_context & Context)
{
}
//------------------------------------------------------------------------------------------------------------
}//namespace text
//------------------------------------------------------------------------------------------------------------

View File

@ -42,6 +42,7 @@
#include "datatypes/targetframename.h"
#include "datatypes/noteclass.h"
#include "datatypes/bool.h"
#include "datatypes/bibliography.h"
#include "../docx/docx_conversion_context.h"
@ -56,7 +57,7 @@ template <class ElementT>
class paragraph_content_element : public office_element_impl<ElementT>
{
public:
void docx_serialize_sdt(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context);
void docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context);
void docx_serialize_field(const std::wstring & field_name, office_element_ptr & text, oox::docx_conversion_context & Context, bool bLock = false);
void docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context);
};
@ -175,8 +176,6 @@ public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
line_break() {};
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ) {}
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
@ -199,9 +198,6 @@ public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
bookmark() {}
bookmark(const std::wstring & Name) : text_name_(Name){};
std::wstring text_name_;
private:
@ -227,9 +223,6 @@ public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
virtual void docx_convert(oox::docx_conversion_context & Context);
bookmark_start() {}
bookmark_start(const std::wstring & Name) : name_(Name){};
std::wstring name_;
private:
@ -251,11 +244,8 @@ public:
static const ElementType type = typeTextBookmarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
bookmark_end() {} ;
bookmark_end(const std::wstring & Name) : name_(Name){};
virtual void docx_convert(oox::docx_conversion_context & Context);
std::wstring name_;
@ -279,12 +269,8 @@ public:
static const ElementType type = typeTextBookmarkRef;
CPDOCCORE_DEFINE_VISITABLE();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
bookmark_ref() {} ;
std::wstring text_ref_name_;
_CP_OPT(std::wstring) text_reference_format_;
std::wstring ref_name_;
_CP_OPT(std::wstring) reference_format_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
@ -293,7 +279,29 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(bookmark_ref);
//-------------------------------------------------------------------------------------------------------------------
// text:reference-ref
//-------------------------------------------------------------------------------------------------------------------
class reference_ref : public paragraph_content_element<reference_ref>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextReferenceRef;
CPDOCCORE_DEFINE_VISITABLE();
std::wstring ref_name_;
_CP_OPT(std::wstring) reference_format_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(reference_ref);
//-------------------------------------------------------------------------------------------------------------------
// text:reference-mark
//-------------------------------------------------------------------------------------------------------------------
@ -306,10 +314,6 @@ public:
static const ElementType type = typeTextReferenceMark;
CPDOCCORE_DEFINE_VISITABLE();
reference_mark() {};
reference_mark(const std::wstring & Name) : text_name_(Name){};
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
std::wstring text_name_;
private:
@ -318,7 +322,6 @@ private:
virtual void add_text(const std::wstring & Text) {}
};
CP_REGISTER_OFFICE_ELEMENT2(reference_mark);
//-------------------------------------------------------------------------------------------------------------------
// text:reference-mark-start
@ -332,10 +335,6 @@ public:
static const ElementType type = typeTextReferenceMarkStart;
CPDOCCORE_DEFINE_VISITABLE();
reference_mark_start() {}
reference_mark_start(const std::wstring & Name) : text_name_(Name){};
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
std::wstring text_name_;
private:
@ -357,11 +356,6 @@ public:
static const ElementType type = typeTextReferenceMarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
reference_mark_end() {};
reference_mark_end(const std::wstring & Name) : text_name_(Name){};
std::wstring text_name_;
private:
@ -800,7 +794,55 @@ private:
//text:display
};
CP_REGISTER_OFFICE_ELEMENT2(text_file_name);
//-------------------------------------------------------------------------------------------------------------------
// text:hidden-paragraph
//-------------------------------------------------------------------------------------------------------------------
class hidden_paragraph : public paragraph_content_element<hidden_paragraph>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextHiddenParagraph;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(odf_types::Bool) is_hidden_;
_CP_OPT(std::wstring) condition_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(hidden_paragraph);
//-------------------------------------------------------------------------------------------------------------------
// text:hidden-text
//-------------------------------------------------------------------------------------------------------------------
class hidden_text : public paragraph_content_element<hidden_text>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextHiddenText;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(odf_types::Bool) is_hidden_;
_CP_OPT(std::wstring) condition_;
_CP_OPT(std::wstring) string_value_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(hidden_text);
//-------------------------------------------------------------------------------------------------------------------
// text:sequence
//-------------------------------------------------------------------------------------------------------------------
@ -820,9 +862,9 @@ public:
_CP_OPT(odf_types::style_numformat) style_num_format_;
_CP_OPT(std::wstring) style_num_letter_sync_;
_CP_OPT(std::wstring) text_formula_;
_CP_OPT(std::wstring) text_name_;
_CP_OPT(std::wstring) text_ref_name_;
_CP_OPT(std::wstring) formula_;
_CP_OPT(std::wstring) name_;
_CP_OPT(std::wstring) ref_name_;
_CP_OPT(std::wstring) template_;
office_element_ptr_array text_;
@ -830,11 +872,34 @@ private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(sequence);
//-------------------------------------------------------------------------------------------------------------------
// text:sequence_ref
//-------------------------------------------------------------------------------------------------------------------
class sequence_ref : public paragraph_content_element<sequence_ref>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextSequenceRef;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(std::wstring) reference_format_;//caption, category-and-value, value, chapter, direction, page, text, number, number-all-superior, number-no-superior
_CP_OPT(std::wstring) ref_name_;
std::wstring content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(sequence_ref);
//-------------------------------------------------------------------------------------------------------------------
//text:drop-down
//-------------------------------------------------------------------------------------------------------------------
class text_drop_down : public paragraph_content_element<text_drop_down>
@ -1153,6 +1218,316 @@ private:
office_element_ptr text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_user_field_get);
//-------------------------------------------------------------------------------------------------------------------
//text:user-defined
//---------------------------------------------------------------------------------------------------
class text_user_defined : public paragraph_content_element<text_user_defined>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextUserDefined;
CPDOCCORE_DEFINE_VISITABLE()
virtual void docx_convert(oox::docx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text(const std::wstring & Text);
_CP_OPT(std::wstring) style_data_style_name_;
_CP_OPT(std::wstring) text_name_;
_CP_OPT(odf_types::Bool) text_fixed_;
odf_types::common_value_and_type_attlist office_value_;
office_element_ptr text_;
};
CP_REGISTER_OFFICE_ELEMENT2(text_user_defined);
//---------------------------------------------------------------------------------------------------
//text:bibliography-mark
//---------------------------------------------------------------------------------------------------
class bibliography_mark : public paragraph_content_element<bibliography_mark>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextBibliographyMark;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
std::wstring identifier_;
odf_types::bibliography bibliography_type_;
_CP_OPT(std::wstring) url_;
_CP_OPT(std::wstring) author_;
_CP_OPT(std::wstring) title_;
_CP_OPT(std::wstring) year_;
_CP_OPT(std::wstring) isbn_;
_CP_OPT(std::wstring) chapter_;
_CP_OPT(std::wstring) address_;
_CP_OPT(std::wstring) annote_;
_CP_OPT(std::wstring) booktitle_;
_CP_OPT(std::wstring) edition_;
_CP_OPT(std::wstring) editor_;
_CP_OPT(std::wstring) howpublished_;
_CP_OPT(std::wstring) institution_;
_CP_OPT(std::wstring) issn_;
_CP_OPT(std::wstring) journal_;
_CP_OPT(std::wstring) month_;
_CP_OPT(std::wstring) note_;
_CP_OPT(std::wstring) number_;
_CP_OPT(std::wstring) organizations_;
_CP_OPT(std::wstring) pages_;
_CP_OPT(std::wstring) publisher_;
_CP_OPT(std::wstring) report_type_;
_CP_OPT(std::wstring) school_;
_CP_OPT(std::wstring) series_;
_CP_OPT(std::wstring) volume_;
office_element_ptr content_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
virtual void add_text (const std::wstring & Text);
};
CP_REGISTER_OFFICE_ELEMENT2(bibliography_mark);
//---------------------------------------------------------------------------------------------------
//text:alphabetical-index-auto-mark-file
//---------------------------------------------------------------------------------------------------
class alphabetical_index_auto_mark_file : public paragraph_content_element<alphabetical_index_auto_mark_file>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextAlphabeticalIndexAutoMarkFile;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
odf_types::common_xlink_attlist xlink_attlist_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_auto_mark_file);
//---------------------------------------------------------------------------------------------------
//text:alphabetical-index-mark-start
//---------------------------------------------------------------------------------------------------
class alphabetical_index_mark_start : public paragraph_content_element<alphabetical_index_mark_start>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextAlphabeticalIndexMarkStart;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
std::wstring id_;
_CP_OPT(std::wstring) key1_;
_CP_OPT(std::wstring) key1_phonetic_;
_CP_OPT(std::wstring) key2_;
_CP_OPT(std::wstring) key2_phonetic_;
_CP_OPT(odf_types::Bool) main_entry_;
_CP_OPT(std::wstring) string_value_phonetic_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_mark_start);
//---------------------------------------------------------------------------------------------------
//text:alphabetical-index-mark-end
//---------------------------------------------------------------------------------------------------
class alphabetical_index_mark_end : public paragraph_content_element<alphabetical_index_mark_end>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextAlphabeticalIndexMarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
std::wstring id_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_mark_end);
//---------------------------------------------------------------------------------------------------
//text:alphabetical-index-mark
//---------------------------------------------------------------------------------------------------
class alphabetical_index_mark : public paragraph_content_element<alphabetical_index_mark>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextAlphabeticalIndexMark;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(std::wstring) key1_;
_CP_OPT(std::wstring) key1_phonetic_;
_CP_OPT(std::wstring) key2_;
_CP_OPT(std::wstring) key2_phonetic_;
_CP_OPT(odf_types::Bool) main_entry_;
_CP_OPT(std::wstring) string_value_;
_CP_OPT(std::wstring) string_value_phonetic_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_mark);
//---------------------------------------------------------------------------------------------------
//text:user-index-mark-start
//---------------------------------------------------------------------------------------------------
class user_index_mark_start : public paragraph_content_element<user_index_mark_start>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextUserIndexMarkStart;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
std::wstring id_;
_CP_OPT(std::wstring) index_name_;
_CP_OPT(int) outline_level_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(user_index_mark_start);
//---------------------------------------------------------------------------------------------------
//text:user-index-mark-end
//---------------------------------------------------------------------------------------------------
class user_index_mark_end : public paragraph_content_element<user_index_mark_end>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextUserIndexMarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
std::wstring id_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(user_index_mark_end);
//---------------------------------------------------------------------------------------------------
//text:user-index-mark
//---------------------------------------------------------------------------------------------------
class user_index_mark : public paragraph_content_element<user_index_mark>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextUserIndexMark;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(std::wstring) index_name_;
_CP_OPT(int) outline_level_;
_CP_OPT(std::wstring) string_value_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(user_index_mark);
//---------------------------------------------------------------------------------------------------
//text:toc-mark-start
//---------------------------------------------------------------------------------------------------
class toc_mark_start : public paragraph_content_element<toc_mark_start>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextTocMarkStart;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(int) outline_level_;
std::wstring id_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(toc_mark_start);
//---------------------------------------------------------------------------------------------------
//text:toc-mark-end
//---------------------------------------------------------------------------------------------------
class toc_mark_end : public paragraph_content_element<toc_mark_end>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextTocMarkEnd;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
std::wstring id_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(toc_mark_end);
//---------------------------------------------------------------------------------------------------
//text:toc-mark
//---------------------------------------------------------------------------------------------------
class toc_mark : public paragraph_content_element<toc_mark>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextTocMark;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(std::wstring) string_value_;
_CP_OPT(int) outline_level_;
private:
virtual void add_attributes ( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(toc_mark);
//-------------------------------------------------------------------------------------------------------------------
} // namespace text
//-------------------------------------------------------------------------------------------------------------------
//presentation:footer

View File

@ -89,22 +89,16 @@ std::wostream & style_tab_stops::text_to_stream(std::wostream & _Wostream) const
return _Wostream;
}
void style_tab_stops::add_attributes( const xml::attributes_wc_ptr & Attributes )
{}
void style_tab_stops::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{
if (L"style" == Ns && L"tab-stop" == Name)
CP_CREATE_ELEMENT(style_tab_stops_);
CP_CREATE_ELEMENT(content_);
else
{
CP_NOT_APPLICABLE_ELM();
}
}
void style_tab_stops::add_text(const std::wstring & Text)
{}
// style:drop-cap
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_drop_cap::ns = L"style";
@ -408,14 +402,12 @@ void paragraph_format_properties::apply_from(const paragraph_format_properties &
_CP_APPLY_PROP(fo_widows_, Other.fo_widows_);
_CP_APPLY_PROP(fo_orphans_, Other.fo_orphans_);
// TODO
_CP_APPLY_PROP(style_tab_stops_, Other.style_tab_stops_);
//style_tab_stops_ calc in context
_CP_APPLY_PROP(style_tab_stop_distance_, Other.style_tab_stop_distance_);
_CP_APPLY_PROP(fo_hyphenation_keep_, Other.fo_hyphenation_keep_);
_CP_APPLY_PROP(fo_hyphenation_ladder_count_, Other.fo_hyphenation_ladder_count_);
// TODO
_CP_APPLY_PROP(style_drop_cap_, Other.style_drop_cap_);
_CP_APPLY_PROP(style_register_true_, Other.style_register_true_);

View File

@ -88,6 +88,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void docx_convert(oox::docx_conversion_context & Context, bool clear = false);
void pptx_convert(oox::pptx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
@ -96,8 +98,8 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
odf_types::length style_position_;
public:
odf_types::length style_position_;
_CP_OPT(odf_types::style_type) style_type_;
_CP_OPT(wchar_t) style_char_;
@ -124,20 +126,17 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
size_t size() const { return style_tab_stops_.size(); }
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
office_element_ptr_array content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
virtual void add_text(const std::wstring & Text);
virtual void add_text(const std::wstring & Text){}
private:
office_element_ptr_array style_tab_stops_;
};
CP_REGISTER_OFFICE_ELEMENT2(style_tab_stops);
@ -239,7 +238,7 @@ public:
office_element_ptr style_background_image_;
office_element_ptr style_drop_cap_;
office_element_ptr style_tab_stops_;
office_element_ptr style_tab_stops_;
_CP_OPT(odf_types::border_style) fo_border_;
_CP_OPT(odf_types::border_style) fo_border_top_;
@ -290,7 +289,7 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
const paragraph_format_properties & content() const { return content_; }
paragraph_format_properties content_;
public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
@ -302,7 +301,6 @@ private:
private:
paragraph_format_properties content_;
};

View File

@ -415,126 +415,101 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co
Context.set_page_break_after(true);
}
}
if (style_tab_stops_)
style_tab_stops_->docx_convert(Context);
Context.get_tabs_context().docx_convert(Context);
//if (style_tab_stops_)
//{
// style_tab_stops_->docx_convert(Context);
//}
}
void style_tab_stops::docx_convert(oox::docx_conversion_context & Context)
{
if (style_tab_stops_.size()<1)return;
if (content_.empty()) return;
std::wstringstream & _pPr = Context.get_styles_context().paragraph_nodes();
_pPr << L"<w:tabs>";
if (style_tab_stops_.size() > 0)
{
for (size_t i = 0; i < style_tab_stops_.size(); i++)
for (size_t i = 0; i < content_.size(); i++)
{
style_tab_stops_[i]->docx_convert(Context);
content_[i]->docx_convert(Context);
}
}
_pPr << L"</w:tabs>";
}
void style_tab_stop::docx_convert(oox::docx_conversion_context & Context)
void style_tab_stop::docx_convert(oox::docx_conversion_context & Context, bool clear)
{
std::wstringstream & _pPr = Context.get_styles_context().paragraph_nodes();
_pPr << L"<w:tab ";
_pPr << L"<w:tab";
length def_tab = length(1.0, length::cm);// в ms значение 0.8 не корректно оО
int tab_pos = (int)( 20.0 * style_position_.get_value_unit(length::pt) ) ;
int min_tab_pos = (int)( 20.0 * def_tab.get_value_unit(length::pt) ) ;
int margin_left_pos = Context.get_margin_left();
if ((style_type_) && (style_type_->get_type() == style_type::Right))
{
tab_pos += margin_left_pos;
}
tab_pos += margin_left_pos;
if (tab_pos < min_tab_pos)
tab_pos = min_tab_pos;
_pPr << L"w:pos=\"" << tab_pos << "\" ";
{
std::wstring val = L"left"; //????
if (style_type_)
{
switch(style_type_->get_type())
{
case style_type::Left:
val = L"left";
break;
case style_type::Center:
val = L"center";
break;
case style_type::Right:
val = L"right";
break;
case style_type::Char:
val = L"decimal";
break;
}
}
if (!val.empty())
_pPr << L"w:val=\"" << val << "\" ";
}
{
std::wstring leader;
std::wstring val = clear ? L"clear" : L"left"; //????
if (style_type_ && !clear)
{
switch(style_type_->get_type())
{
case style_type::Left: val = L"left"; break;
case style_type::Center:val = L"center"; break;
case style_type::Right: val = L"right"; break;
case style_type::Char: val = L"decimal"; break;
}
}
_pPr << L" w:val=\"" << val << "\"";
_pPr << L" w:pos=\"" << tab_pos << "\"";
std::wstring leader;
if ((style_leader_type_ && style_leader_type_->get_type() == line_type::None) ||
(style_leader_style_ && style_leader_style_->get_type() == line_style::None))
{
leader = L"none";
}
else if (!style_leader_type_ || style_leader_type_ && style_leader_type_->get_type() != line_type::None)
{
if (style_leader_style_)
{
switch(style_leader_style_->get_type())
{
case line_style::None:
leader = L"";
break;
case line_style::Solid:
if (style_leader_text_)
{
if (*style_leader_text_ == L"-")
leader = L"hyphen";
else if (*style_leader_text_ == L"_")
leader = L"underscore";
}
break;
case line_style::Dotted:
leader = L"dot";
break;
case line_style::Dash:
leader = L"hyphen";
break;
case line_style::LongDash:
leader = L"middleDot";
break;
case line_style::DotDash:
leader = L"middleDot";
break;
case line_style::DotDotDash:
leader = L"middleDot";
break;
case line_style::Wave:
leader = L"middleDot";
break;
}
}
}
if (!leader.empty())
_pPr << L"w:leader=\"" << leader << "\" ";
}
_pPr << L" />";
if ((style_leader_type_ && style_leader_type_->get_type() == line_type::None) ||
(style_leader_style_ && style_leader_style_->get_type() == line_style::None))
{
leader = L"none";
}
else if (!style_leader_type_ || style_leader_type_ && style_leader_type_->get_type() != line_type::None)
{
if (style_leader_style_)
{
switch(style_leader_style_->get_type())
{
case line_style::None: leader.clear(); break;
case line_style::Solid:
{
if (style_leader_text_)
{
if (*style_leader_text_ == L"-")
leader = L"hyphen";
else if (*style_leader_text_ == L"_")
leader = L"underscore";
}
}break;
case line_style::Dotted: leader = L"dot"; break;
case line_style::Dash: leader = L"hyphen"; break;
case line_style::LongDash: leader = L"middleDot"; break;
case line_style::DotDash: leader = L"middleDot"; break;
case line_style::DotDotDash: leader = L"middleDot"; break;
case line_style::Wave: leader = L"middleDot"; break;
}
}
}
if (!clear && !leader.empty())
{
_pPr << L" w:leader=\"" << leader << "\"";
}
_pPr << L"/>";
}
void style_tab_stop::docx_convert(oox::docx_conversion_context & Context)
{
docx_convert(Context, false);
}
void style_paragraph_properties::docx_convert(oox::docx_conversion_context & Context)

View File

@ -853,11 +853,6 @@ void style_footer_style::add_child_element( xml::sax * Reader, const std::wstrin
}
}
void style_page_layout_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"style:name", style_name_, std::wstring(L""));
CP_APPLY_ATTR(L"style:page-usage", style_page_usage_, page_usage(page_usage::All));
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_page_layout::ns = L"style";
@ -870,7 +865,8 @@ std::wostream & style_page_layout::text_to_stream(std::wostream & _Wostream) con
void style_page_layout::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"style:name", style_name_, std::wstring(L""));
CP_APPLY_ATTR(L"style:page-usage", style_page_usage_, page_usage(page_usage::All));
}
void style_page_layout::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)

View File

@ -775,18 +775,6 @@ public:
CP_REGISTER_OFFICE_ELEMENT2(style_section_properties);
/// style-page-layout-attlist
class style_page_layout_attlist
{
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
const std::wstring & get_style_name() const { return style_name_; }
std::wstring style_name_;
odf_types::page_usage style_page_usage_; // default All
};
/// style:header-style
class style_header_style : public office_element_impl<style_header_style>
{
@ -841,7 +829,8 @@ public:
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
style_page_layout_attlist attlist_;
std::wstring style_name_;
odf_types::page_usage style_page_usage_; // default All
office_element_ptr style_page_layout_properties_;
office_element_ptr style_header_style_;

View File

@ -113,6 +113,8 @@ public:
bool inViewTable;
bool inView;
std::map<std::wstring, std::wstring> map_user_defineds;
};
settings_container::settings_container(): impl_(new settings_container::Impl() )
@ -264,6 +266,16 @@ _CP_OPT(std::wstring) settings_container::find_view_by_name(const std::wstring &
}
return value;
}
void settings_container::add_user_defined(const std::wstring & name, const std::wstring & value)
{
impl_->map_user_defineds.insert(std::make_pair(name, value));
}
std::wstring settings_container::get_user_defined(const std::wstring & name)
{
std::map<std::wstring, std::wstring>::iterator pFind = impl_->map_user_defineds.find(name);
return pFind != impl_->map_user_defineds.end() ? pFind->second : L"";
}
}
}

View File

@ -79,6 +79,9 @@ public:
void end_table_view ();
void add_view (const std::wstring & name, const std::wstring & value);
void add_user_defined(const std::wstring & name, const std::wstring & value);
std::wstring get_user_defined(const std::wstring & name);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -317,6 +317,14 @@
RelativePath="..\src\odf\datatypes\backgroundcolor.h"
>
</File>
<File
RelativePath="..\src\odf\datatypes\bibliography.cpp"
>
</File>
<File
RelativePath="..\src\odf\datatypes\bibliography.h"
>
</File>
<File
RelativePath="..\src\odf\datatypes\bool.cpp"
>

View File

@ -1591,6 +1591,14 @@
RelativePath="..\src\odf\office_forms.h"
>
</File>
<File
RelativePath="..\src\odf\office_meta.cpp"
>
</File>
<File
RelativePath="..\src\odf\office_meta.h"
>
</File>
<File
RelativePath="..\src\odf\office_presentation.cpp"
>

View File

@ -165,6 +165,10 @@ namespace SimpleTypes
{
return (long)Pt_To_Dx(m_dValue);
}
unsigned long ToUnsignedTwips() const
{
return (unsigned long)Pt_To_Dx(m_dValue);
}
virtual double FromPoints(double dValue)
{
m_dValue = dValue;

View File

@ -613,7 +613,7 @@ namespace OOX
{
if ( m_arrItems[i] )
{
m_arrItems[i]->toXML(writer);
m_arrItems[i]->toXML2(writer, L"val");
}
}
writer.WriteString(L"</value>");
@ -684,7 +684,7 @@ namespace OOX
{
if ( m_arrItems[i] )
{
m_arrItems[i]->toXML(writer);
m_arrItems[i]->toXML(writer);
}
}
writer.WriteString(L"</values>");

View File

@ -309,13 +309,15 @@ void OOX::Spreadsheet::CXlsx::PrepareWorkbook()
{
pFont->m_oRFont.Init();
pFont->m_oRFont->m_sVal = _T("Calibri");
if(false == pFont->m_oScheme.IsInit())
{
pFont->m_oScheme.Init();
pFont->m_oScheme->m_oFontScheme.Init();
pFont->m_oScheme->m_oFontScheme->SetValue(SimpleTypes::Spreadsheet::fontschemeMinor);
}
}
if(false == pFont->m_oScheme.IsInit())
{
pFont->m_oScheme.Init();
pFont->m_oScheme->m_oFontScheme.Init();
pFont->m_oScheme->m_oFontScheme->SetValue(SimpleTypes::Spreadsheet::fontschemeMinor);
}
if(false == pFont->m_oSz.IsInit() || false == pFont->m_oSz->m_oVal.IsInit())
{
pFont->m_oSz.Init();

View File

@ -1 +1 @@
2.4.537.0
2.4.538.0

View File

@ -72,6 +72,8 @@
- (int)sdk_xlst2csv:(NSString*)nsFrom nsTo:(NSString*)nsTo xmlOptions:(NSString*)xmlOptions nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_xlsx2csv:(NSString*)nsFrom nsTo:(NSString*)nsTo xmlOptions:(NSString*)xmlOptions nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)txt2doct_bin:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath;
- (int)sdk_dir2zip:(NSString*)nsFrom nsTo:(NSString*)nsTo;
- (int)sdk_zip2dir:(NSString*)nsFrom nsTo:(NSString*)nsTo;

View File

@ -349,6 +349,25 @@ static std::wstring nsstring_to_wstring(NSString* nsstring)
return NExtractTools::xlsx2csv(from, to, temp, oInputParams);
}
- (int)txt2doct_bin:(NSString*)nsFrom nsTo:(NSString*)nsTo nsTemp:(NSString*)nsTemp nsFontPath:(NSString*)nsFontPath {
std::wstring from = nsstring_to_wstring(nsFrom);
std::wstring to = nsstring_to_wstring(nsTo);
std::wstring temp = nsstring_to_wstring(nsTemp);
NExtractTools::InputParams oInputParams;
oInputParams.m_sFontDir = new std::wstring(nsstring_to_wstring(nsFontPath));
oInputParams.m_bIsNoBase64 = new bool(self.isNoBase64);
if (self.encoding != nil) {
oInputParams.m_nCsvTxtEncoding = new int(self.encoding.intValue);
}
oInputParams.m_nFormatFrom = new int(AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT);
oInputParams.m_nFormatTo = new int(AVS_OFFICESTUDIO_FILE_CANVAS_WORD);
return NExtractTools::txt2doct_bin(from, to, temp, oInputParams);
}
- (int)sdk_dir2zip:(NSString*)nsFrom nsTo:(NSString*)nsTo {
std::wstring from = nsstring_to_wstring(nsFrom);
std::wstring to = nsstring_to_wstring(nsTo);