mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
59 Commits
v5.3.0.217
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| a0cc6b6274 | |||
| 31eb395858 | |||
| 4e554d128a | |||
| b8d441a327 | |||
| 8fb809bf4a | |||
| 35c4d70cf5 | |||
| 58952393f0 | |||
| 0b987aeed2 | |||
| c7315e2f21 | |||
| aefb229343 | |||
| ac080b3485 | |||
| eb9d69d1ec | |||
| eb4ffee9e7 | |||
| 763347d8ec | |||
| 232115e684 | |||
| a265d82dda | |||
| e68b550d1e | |||
| 832d35dc17 | |||
| 799fcbc342 | |||
| 469ce9aafb | |||
| 5f7288f66f | |||
| b308f53e76 | |||
| 0982b8fb11 | |||
| 692fe69426 | |||
| 5bb1de7dbd | |||
| 6c29f811d9 | |||
| 89ac698d35 | |||
| e1d910f952 | |||
| 5bb3ca6aff | |||
| bae655ba49 | |||
| e4b4949471 | |||
| 2bfcfbf21c | |||
| 1266382747 | |||
| 966809a8f2 | |||
| 27c9b40ad3 | |||
| 699eb731b4 | |||
| 0eb032a281 | |||
| f89174ded5 | |||
| ff1d53637a | |||
| e825b4359f | |||
| 25022ceecc | |||
| 1a7476e465 | |||
| 0edc2729e8 | |||
| d51f004b11 | |||
| 79aa50d712 | |||
| fdef699b9b | |||
| 8573513168 | |||
| b9608771a9 | |||
| cfea717d20 | |||
| 0ec79f2c2d | |||
| 6f0d22c3a4 | |||
| 8d074cadf8 | |||
| 195e9079db | |||
| b60811fd0d | |||
| 6d6cbd51c3 | |||
| 9c1b107998 | |||
| f2e003b12c | |||
| ee43592691 | |||
| 00328e88b2 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -63,5 +63,6 @@ X2tConverter/Common/DocxFormat/DocxFormatLib/Makefile
|
||||
*.zip
|
||||
*.tar.gz
|
||||
**/*.build/
|
||||
|
||||
*.dat
|
||||
*.txt
|
||||
*.log
|
||||
|
||||
@ -801,7 +801,7 @@ void Binary_rPrWriter::Write_rPrChange(const OOX::Logic::CRPrChange& rPrChange)
|
||||
if(rPrChange.m_pRunPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_RevisionType::rPrChange);
|
||||
Write_rPr(rPrChange.m_pRunPr.operator->());
|
||||
Write_rPr(rPrChange.m_pRunPr.GetPointer());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
@ -944,7 +944,7 @@ void Binary_pPrWriter::Write_pPr(const OOX::Logic::CParagraphProperty& pPr)
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerProp_pPrType::pPr_rPr);
|
||||
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
|
||||
nCurPos = m_oBcw.WriteItemWithLengthStart();
|
||||
brPrs.Write_rPr(pPr.m_oRPr.operator->());
|
||||
brPrs.Write_rPr(pPr.m_oRPr.GetPointer());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
//FramePr
|
||||
@ -1425,7 +1425,7 @@ void Binary_pPrWriter::WriteHeaderFooter(OOX::Logic::CSectionProperty* pSectPr,
|
||||
if (oFile.IsInit() && (OOX::FileTypes::Header == oFile->type() || OOX::FileTypes::Footer == oFile->type()))
|
||||
{
|
||||
int nIndex = 0;
|
||||
OOX::CHdrFtr* pHdrFtr = (OOX::CHdrFtr*)oFile.operator->();
|
||||
OOX::CHdrFtr* pHdrFtr = (OOX::CHdrFtr*)oFile.GetPointer();
|
||||
if(bHdr)
|
||||
{
|
||||
nIndex = (int)m_oBinaryHeaderFooterTableWriter->m_aHeaders.size();
|
||||
@ -2264,7 +2264,7 @@ void Binary_tblPrWriter::WriteTcPrChange(const OOX::Logic::CTcPrChange& tcPrChan
|
||||
if(tcPrChange.m_pTcPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_RevisionType::tcPrChange);
|
||||
WriteCellPr(tcPrChange.m_pTcPr.operator->());
|
||||
WriteCellPr(tcPrChange.m_pTcPr.GetPointer());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
@ -2452,7 +2452,7 @@ void BinaryStyleTableWriter::WriteStyle(const OOX::CStyle& style)
|
||||
if(false != style.m_oRunPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_sts::Style_TextPr);
|
||||
brPrs.Write_rPr(style.m_oRunPr.operator->());
|
||||
brPrs.Write_rPr(style.m_oRunPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
//ParaPr
|
||||
@ -2480,7 +2480,7 @@ void BinaryStyleTableWriter::WriteStyle(const OOX::CStyle& style)
|
||||
if(false != style.m_oTcPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSer_sts::Style_CellPr);
|
||||
btblPrs.WriteCellPr(style.m_oTcPr.operator->());
|
||||
btblPrs.WriteCellPr(style.m_oTcPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
//TblStylePr
|
||||
@ -2557,7 +2557,7 @@ void BinaryStyleTableWriter::WriteTblStyleProperties(const OOX::Logic::CTableSty
|
||||
if(false != oProperty.m_oRunPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblStylePrType::RunPr);
|
||||
brPrs.Write_rPr(oProperty.m_oRunPr.operator->());
|
||||
brPrs.Write_rPr(oProperty.m_oRunPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
//ParaPr
|
||||
@ -2585,7 +2585,7 @@ void BinaryStyleTableWriter::WriteTblStyleProperties(const OOX::Logic::CTableSty
|
||||
if(false != oProperty.m_oTcPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_tblStylePrType::TcPr);
|
||||
btblPrs.WriteCellPr(oProperty.m_oTcPr.operator->());
|
||||
btblPrs.WriteCellPr(oProperty.m_oTcPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
@ -4293,7 +4293,7 @@ void BinaryDocumentTableWriter::WriteMathRunContent(OOX::Logic::CMRun* pMRun)
|
||||
if ( pMRun->m_oRPr.IsInit() )
|
||||
{
|
||||
int nCurPos2 = m_oBcw.WriteItemStart(c_oSer_OMathContentType::RPr);
|
||||
brPrs.Write_rPr(pMRun->m_oRPr.operator->());
|
||||
brPrs.Write_rPr(pMRun->m_oRPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos2);
|
||||
}
|
||||
if ( pMRun->m_oARPr.IsInit() )
|
||||
@ -4542,7 +4542,7 @@ void BinaryDocumentTableWriter::WriteMathCtrlPr(const OOX::Logic::CCtrlPr &pCtrl
|
||||
if ( pCtrlPr.m_oRPr.IsInit() )
|
||||
{
|
||||
int nCurPos2 = m_oBcw.WriteItemStart(c_oSerRunType::rPr);
|
||||
brPrs.Write_rPr(pCtrlPr.m_oRPr.operator->());
|
||||
brPrs.Write_rPr(pCtrlPr.m_oRPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos2);
|
||||
}
|
||||
if ( pCtrlPr.m_oARPr.IsInit() )
|
||||
@ -7028,7 +7028,7 @@ void BinaryDocumentTableWriter::WriteSdt(OOX::Logic::CSdt* pStd, int type, OOX::
|
||||
if(pStd->m_oSdtEndPr.IsInit() && pStd->m_oSdtEndPr->m_oRPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerSdt::EndPr);
|
||||
brPrs.Write_rPr(pStd->m_oSdtEndPr->m_oRPr.operator->());
|
||||
brPrs.Write_rPr(pStd->m_oSdtEndPr->m_oRPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
if(pStd->m_oSdtContent.IsInit())
|
||||
@ -7152,7 +7152,7 @@ void BinaryDocumentTableWriter::WriteSdtPr(const OOX::Logic::CSdtPr& oStdPr)
|
||||
if(oStdPr.m_oRPr.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerSdt::RPr);
|
||||
brPrs.Write_rPr(oStdPr.m_oRPr.operator->());
|
||||
brPrs.Write_rPr(oStdPr.m_oRPr.GetPointer());
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
if(oStdPr.m_oShowingPlcHdr.IsInit())
|
||||
|
||||
@ -277,13 +277,20 @@ namespace BinXlsxRW{
|
||||
pTable->m_oTable->m_oTableStyleInfo->m_oShowColumnStripes.Init();
|
||||
pTable->m_oTable->m_oTableStyleInfo->m_oShowColumnStripes->FromBool(false);
|
||||
pTable->m_oTable->m_oTableColumns.Init();
|
||||
|
||||
for(size_t i = 0; i < m_aTableNames.size(); ++i)
|
||||
{
|
||||
OOX::Spreadsheet::CTableColumn* pTableColumn = new OOX::Spreadsheet::CTableColumn();
|
||||
pTableColumn->m_oId.Init();
|
||||
pTableColumn->m_oId->SetValue((unsigned int)i + 1);
|
||||
pTableColumn->m_oName.Init();
|
||||
pTableColumn->m_oName->append(m_aTableNames[i]);
|
||||
|
||||
if (!pTableColumn->m_oId.IsInit())
|
||||
{
|
||||
pTableColumn->m_oId.Init();
|
||||
pTableColumn->m_oId->SetValue((unsigned int)i + 1);
|
||||
}
|
||||
if (!pTableColumn->m_oName.IsInit())
|
||||
{
|
||||
pTableColumn->m_oName = m_aTableNames[i];
|
||||
}
|
||||
pTable->m_oTable->m_oTableColumns->m_arrItems.push_back(pTableColumn);
|
||||
}
|
||||
pTable->m_oTable->m_oTableColumns->m_oCount.Init();
|
||||
|
||||
@ -92,8 +92,9 @@ public:
|
||||
std::wstring convert_conditional_formula(std::wstring const & expr);
|
||||
|
||||
// Лист1!$A$1 -> $Лист1.$A$1
|
||||
std::wstring convert_named_ref (std::wstring const & expr);
|
||||
std::wstring convert_named_ref(std::wstring const & expr);
|
||||
std::wstring convert_named_formula(std::wstring const & expr);
|
||||
bool is_simple_ref(std::wstring const & expr);
|
||||
|
||||
std::wstring get_table_name();
|
||||
|
||||
|
||||
@ -174,6 +174,7 @@ public:
|
||||
}
|
||||
void replace_named_ref(std::wstring & expr);
|
||||
void replace_named_formula(std::wstring & expr);
|
||||
bool is_simple_ref(std::wstring const & expr);
|
||||
|
||||
static bool isFindBaseCell_;
|
||||
|
||||
@ -195,7 +196,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSele
|
||||
|
||||
if (b)
|
||||
{
|
||||
boost::wregex re1(L"(\\$?[^\']+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
|
||||
boost::wregex re1(L"(\\$?[^\\']+\\!)?([a-zA-Z$]+\\d*)(\\:[a-zA-Z$]+\\d*)?");
|
||||
// $ Sheet2 ! $ A1 : $ B5
|
||||
// $ Sheet2 ! $ A : $ A
|
||||
// $ Sheet2 ! $ 1 : $ 1
|
||||
@ -238,9 +239,11 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
|
||||
|
||||
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
|
||||
{
|
||||
table_name_ = sheet + L".$A$1";
|
||||
table_name_ = L"$" + sheet + L".$A$1";
|
||||
}
|
||||
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
|
||||
if (!c2.empty() && c2.substr(0, 1) == L":")
|
||||
c2 = c2.substr(1);
|
||||
|
||||
|
||||
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
|
||||
@ -281,10 +284,12 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
|
||||
|
||||
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
|
||||
{
|
||||
table_name_ = sheet + L".$A$1";
|
||||
table_name_ = L"$" + sheet + L".$A$1";
|
||||
}
|
||||
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
|
||||
|
||||
|
||||
if (!c2.empty() && c2.substr(0, 1) == L":")
|
||||
c2 = c2.substr(1);
|
||||
|
||||
s = sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"");
|
||||
}
|
||||
@ -310,6 +315,19 @@ void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
|
||||
expr = convert_formula(expr);
|
||||
isFindBaseCell_ = false;
|
||||
}
|
||||
bool oox2odf_converter::Impl::is_simple_ref(std::wstring const & expr)
|
||||
{
|
||||
if (expr.find(L"(") != std::wstring::npos) return false;
|
||||
if (expr.find(L" ") != std::wstring::npos) return false;
|
||||
if (expr.find(L";") != std::wstring::npos) return false;
|
||||
|
||||
boost::wsmatch match;
|
||||
if (boost::regex_search(expr, match, boost::wregex(L"([\\w]+\\!)?\\$?[a-zA-Z]+\\$?\\d+(\\:\\$?[a-zA-Z]+\\$?\\d+)?")))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
|
||||
{
|
||||
@ -644,6 +662,11 @@ std::wstring oox2odf_converter::convert_named_formula(const std::wstring& expr)
|
||||
impl_->replace_named_formula(workstr);
|
||||
return workstr;
|
||||
}
|
||||
bool oox2odf_converter::is_simple_ref(std::wstring const & expr)
|
||||
{
|
||||
return impl_->is_simple_ref(expr);
|
||||
}
|
||||
|
||||
std::wstring oox2odf_converter::get_table_name()
|
||||
{
|
||||
return impl_->table_name_;
|
||||
|
||||
@ -468,6 +468,7 @@ enum ElementType
|
||||
typeDrawHandle,
|
||||
typeDrawEquation,
|
||||
typeDrawEnhancedGeometry,
|
||||
typeDrawGluePoint,
|
||||
|
||||
typeDr3dScene,
|
||||
typeDr3dLight,
|
||||
@ -506,6 +507,7 @@ enum ElementType
|
||||
typeFormTime,
|
||||
typeFormValueRange,
|
||||
typeFormItem,
|
||||
typeFormOption,
|
||||
|
||||
typeDrawPage,
|
||||
typePresentationFooterDecl,
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
#include "../odf/style_graphic_properties.h"
|
||||
|
||||
#include "docx_package.h"
|
||||
#include "xlsx_package.h"
|
||||
#include "oox_rels.h"
|
||||
#include "logging.h"
|
||||
|
||||
@ -130,7 +131,7 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
|
||||
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * _odf_document) :
|
||||
last_dump_page_properties_ (true),
|
||||
next_dump_page_properties_ (false),
|
||||
page_break_ (false),
|
||||
@ -151,12 +152,14 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
|
||||
is_delete_text_ (false),
|
||||
delayed_converting_ (false),
|
||||
process_headers_footers_ (false),
|
||||
current_process_comment_ (false),
|
||||
mediaitems_ (OdfDocument->get_folder() ),
|
||||
math_context_ (OdfDocument->odf_context().fontContainer(), false),
|
||||
odf_document_ (OdfDocument)
|
||||
current_process_comment_ (false),
|
||||
odf_document_ (_odf_document),
|
||||
math_context_ (_odf_document->odf_context().fontContainer(), false)
|
||||
{
|
||||
streams_man_ = streams_man::create(temp_stream_);
|
||||
mediaitems_ = boost::make_shared<mediaitems>(odf_document_->get_folder());
|
||||
chart_drawing_handle_ = boost::make_shared<xlsx_drawing_context_handle>(mediaitems_);
|
||||
|
||||
streams_man_ = streams_man::create(temp_stream_);
|
||||
}
|
||||
docx_conversion_context::~docx_conversion_context()
|
||||
{
|
||||
@ -167,7 +170,7 @@ void docx_conversion_context::set_output_document(package::docx_document * docum
|
||||
}
|
||||
void docx_conversion_context::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
mediaitems_.set_font_directory(pathFonts);
|
||||
mediaitems_->set_font_directory(pathFonts);
|
||||
}
|
||||
std::wstring styles_map::get(const std::wstring & Name, odf_types::style_family::type Type)
|
||||
{
|
||||
@ -685,11 +688,14 @@ 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_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_media ( mediaitems_);
|
||||
output_document_->get_word_files().set_comments ( comments_context_);
|
||||
output_document_->get_word_files().set_headers_footers( headers_footers_);
|
||||
output_document_->get_word_files().set_headers_footers( headers_footers_);
|
||||
|
||||
package::xl_drawings_ptr drawings = package::xl_drawings::create(chart_drawing_handle_->content(), chart_drawing_handle_->content_vml());
|
||||
output_document_->get_word_files().set_drawings(drawings);
|
||||
|
||||
package::content_types_file & content_file_ = output_document_->get_content_types_file();
|
||||
content_file_.set_media( mediaitems_);
|
||||
@ -1919,7 +1925,7 @@ namespace
|
||||
//слить если есть mediaitems, добавить релсы и обнулить их для основного документа.
|
||||
rels internal_rels;
|
||||
|
||||
Context.get_mediaitems().dump_rels(internal_rels);
|
||||
Context.get_mediaitems()->dump_rels(internal_rels);
|
||||
Context.dump_hyperlinks(internal_rels, hyperlinks::document_place);
|
||||
|
||||
Context.get_headers_footers().add(styleName, dbgStr, type, internal_rels);
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "docx_table_context.h"
|
||||
#include "oox_conversion_context.h"
|
||||
#include "oox_chart_context.h"
|
||||
#include "xlsx_drawing_context.h"
|
||||
|
||||
#include "headers_footers.h"
|
||||
#include "hyperlinks.h"
|
||||
@ -734,7 +735,7 @@ class docx_conversion_context : boost::noncopyable
|
||||
public:
|
||||
enum NoteType { noNote, footNote, footNoteRefSet, endNote, endNoteRefSet };
|
||||
|
||||
docx_conversion_context(odf_reader::odf_document * OdfDocument);
|
||||
docx_conversion_context(odf_reader::odf_document * _odf_document);
|
||||
~docx_conversion_context();
|
||||
|
||||
void set_output_document (package::docx_document * document);
|
||||
@ -888,7 +889,7 @@ public:
|
||||
|
||||
styles_map * get_style_map() { return &styles_map_; }
|
||||
|
||||
mediaitems & get_mediaitems() {return mediaitems_;}
|
||||
mediaitems_ptr & get_mediaitems() {return mediaitems_;}
|
||||
styles_context & get_styles_context() { return styles_context_; }
|
||||
drawing_context & get_drawing_context() { return drawing_context_; }
|
||||
comments_context & get_comments_context() { return comments_context_; }
|
||||
@ -898,8 +899,9 @@ public:
|
||||
text_tracked_context& get_text_tracked_context(){ return text_tracked_context_; }
|
||||
forms_context & get_forms_context() { return forms_context_; }
|
||||
tabs_context & get_tabs_context() { return tabs_context_;}
|
||||
table_content_context & get_table_content_context() { return table_content_context_;}
|
||||
|
||||
table_content_context & get_table_content_context() { return table_content_context_;}
|
||||
xlsx_drawing_context_handle_ptr & get_chart_drawing_handle() { return chart_drawing_handle_;}
|
||||
|
||||
void set_drawing_text_props (const std::wstring &props);
|
||||
|
||||
@ -993,6 +995,8 @@ private:
|
||||
std::wstringstream settings_xml_;
|
||||
std::wstringstream meta_xml_;
|
||||
|
||||
xlsx_drawing_context_handle_ptr chart_drawing_handle_;
|
||||
|
||||
styles_context styles_context_;
|
||||
math_context math_context_;
|
||||
drawing_context drawing_context_;
|
||||
@ -1015,7 +1019,7 @@ private:
|
||||
std::vector<odf_reader::_property> settings_properties_;
|
||||
|
||||
hyperlinks hyperlinks_;
|
||||
mediaitems mediaitems_;
|
||||
mediaitems_ptr mediaitems_;
|
||||
std::vector<oox_chart_context_ptr> charts_;
|
||||
headers_footers headers_footers_;
|
||||
|
||||
|
||||
@ -102,7 +102,11 @@ void word_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
embeddings_->write( path );
|
||||
}
|
||||
|
||||
if (drawings_)
|
||||
{
|
||||
drawings_->set_main_document(get_main_document());
|
||||
drawings_->write( path );
|
||||
}
|
||||
if (headers_footers_)
|
||||
{
|
||||
headers_footers_->write( path );
|
||||
@ -140,22 +144,22 @@ void word_files::write(const std::wstring & RootPath)
|
||||
|
||||
void word_files::update_rels(docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_mediaitems().dump_rels(rels_files_.get_rel_file()->get_rels());
|
||||
Context.get_mediaitems()->dump_rels(rels_files_.get_rel_file()->get_rels());
|
||||
|
||||
Context.dump_hyperlinks (rels_files_.get_rel_file()->get_rels(), hyperlinks::document_place);
|
||||
Context.dump_headers_footers(rels_files_.get_rel_file()->get_rels());
|
||||
Context.dump_notes (rels_files_.get_rel_file()->get_rels());
|
||||
}
|
||||
|
||||
void word_files::set_media(mediaitems & _Mediaitems)
|
||||
void word_files::set_media(mediaitems_ptr & _mediaitems)
|
||||
{
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
if (_mediaitems->count_image + _mediaitems->count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
|
||||
media_ = element_ptr( new media(_mediaitems, _mediaitems->applicationFonts()) );
|
||||
}
|
||||
if (_Mediaitems.count_object > 0)
|
||||
if (_mediaitems->count_object > 0)
|
||||
{
|
||||
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
|
||||
embeddings_ = element_ptr( new embeddings(_mediaitems) );
|
||||
embeddings_->set_main_document( get_main_document() );
|
||||
}
|
||||
}
|
||||
@ -195,6 +199,10 @@ void word_files::add_jsaProject(const std::string &content)
|
||||
{
|
||||
jsaProject_ = package::simple_element::create(L"jsaProject.bin", content);
|
||||
}
|
||||
void word_files::set_drawings(element_ptr Element)
|
||||
{
|
||||
drawings_ = Element;
|
||||
}
|
||||
void word_files::set_headers_footers(headers_footers & HeadersFooters)
|
||||
{
|
||||
headers_footers_elements * elm = new headers_footers_elements(HeadersFooters);
|
||||
|
||||
@ -137,10 +137,11 @@ public:
|
||||
void set_numbering (element_ptr Element);
|
||||
void set_settings (element_ptr Element);
|
||||
bool has_numbering ();
|
||||
void set_media (mediaitems & mediaitems_);
|
||||
void set_media (mediaitems_ptr & mediaitems_);
|
||||
void set_headers_footers(headers_footers & HeadersFooters);
|
||||
void set_notes (notes_context & notesContext);
|
||||
void set_comments (comments_context & commentsContext);
|
||||
void set_drawings (element_ptr Element);
|
||||
|
||||
void add_charts(chart_content_ptr chart);
|
||||
void add_jsaProject(const std::string &content);
|
||||
@ -163,6 +164,7 @@ private:
|
||||
element_ptr settings_;
|
||||
element_ptr comments_;
|
||||
element_ptr jsaProject_;
|
||||
element_ptr drawings_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -62,6 +62,9 @@ struct drawing_object_description
|
||||
double anchor_x_;
|
||||
double anchor_y_;
|
||||
|
||||
_CP_OPT(_INT32) owner_cx_;
|
||||
_CP_OPT(_INT32) owner_cy_;
|
||||
|
||||
_action_desc action_;
|
||||
std::vector<_hlink_desc> hlinks_;
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
|
||||
//if (FALSE == (hr = pFontManager->LoadString2( std::to_wstring(i), 0, 0)))
|
||||
// return std::pair<float, float>(7,8);
|
||||
|
||||
if (FALSE == (hr = pFontManager->LoadString2( L"xxxxx" , 0, 0)))
|
||||
if (FALSE == (hr = pFontManager->LoadString2( L"0123456789" , 0, 0)))
|
||||
return std::pair<float, float>(7,8);
|
||||
|
||||
TBBox box;
|
||||
@ -96,7 +96,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
|
||||
if (box.fMaxY - box.fMinY < minHeight) minHeight = box.fMaxY - box.fMinY;
|
||||
}
|
||||
|
||||
double width = (minWidth + 2 * maxWidth) /3. /5.;
|
||||
double width = (minWidth + 2 * maxWidth) /10. /5.;
|
||||
return std::pair<float, float>(width, maxHeight);
|
||||
}
|
||||
|
||||
|
||||
@ -101,6 +101,7 @@ void mediaitems::set_font_directory(std::wstring pathFonts)
|
||||
if (applicationFonts_)
|
||||
applicationFonts_->InitializeFromFolder(pathFonts);
|
||||
}
|
||||
|
||||
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal)
|
||||
{
|
||||
std::wstring ref;
|
||||
@ -336,6 +337,10 @@ void mediaitems::dump_rels(rels & Rels)
|
||||
{
|
||||
for (size_t i = 0; i < items_.size(); i++)
|
||||
{
|
||||
if ( items_[i].type == typeUnknown ) continue;
|
||||
if ( items_[i].type == typeShape ) continue;
|
||||
if ( items_[i].type == typeGroupShape ) continue;
|
||||
|
||||
if (items_[i].count_used >= items_[i].count_add) continue; // уже использовали этот релс выше(колонтитул ....)
|
||||
|
||||
Rels.add( relationship(
|
||||
@ -345,7 +350,7 @@ void mediaitems::dump_rels(rels & Rels)
|
||||
items_[i].mediaInternal ? L"" : L"External" )
|
||||
);
|
||||
items_[i].count_used++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -137,6 +137,7 @@ public:
|
||||
|
||||
return typeMedia;
|
||||
}
|
||||
|
||||
private:
|
||||
std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num);
|
||||
std::wstring detectImageFileExtension (const std::wstring &fileName);
|
||||
@ -147,6 +148,7 @@ private:
|
||||
NSFonts::IApplicationFonts *applicationFonts_;
|
||||
};
|
||||
|
||||
typedef _CP_PTR(mediaitems) mediaitems_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ public:
|
||||
std::wstring drawingId_;
|
||||
};
|
||||
|
||||
oox_chart_context::oox_chart_context(mediaitems & m, std::wstring name) :
|
||||
oox_chart_context::oox_chart_context(mediaitems_ptr & m, std::wstring name) :
|
||||
impl_(new oox_chart_context::Impl( name)), mediaitems_(m)
|
||||
{
|
||||
|
||||
@ -65,7 +65,7 @@ void oox_chart_context::reset_fill(oox::_oox_fill &f)
|
||||
{
|
||||
bool isInternal = true;
|
||||
std::wstring ref;
|
||||
f.bitmap->rId = mediaitems_.add_or_find(f.bitmap->xlink_href_, typeImage, isInternal, ref);
|
||||
f.bitmap->rId = mediaitems_->add_or_find(f.bitmap->xlink_href_, typeImage, isInternal, ref);
|
||||
|
||||
rels_.push_back(_rel(isInternal, f.bitmap->rId, ref, typeImage));
|
||||
}
|
||||
@ -75,9 +75,15 @@ void oox_chart_context::set_externalData(const std::wstring & href)
|
||||
bool isInternal = true;
|
||||
std::wstring href_out;
|
||||
|
||||
externalDataId_ = mediaitems_.add_or_find(href, typeMsObject, isInternal, href_out);
|
||||
externalDataId_ = mediaitems_->add_or_find(href, typeMsObject, isInternal, href_out);
|
||||
rels_.push_back(_rel(isInternal, externalDataId_, href_out, typeMsObject));
|
||||
}
|
||||
void oox_chart_context::set_userShapes(std::pair<std::wstring, std::wstring> &link)
|
||||
{
|
||||
bool isInternal = true;
|
||||
userShapesId_ = link.second;
|
||||
rels_.push_back(_rel(isInternal, userShapesId_, link.first, typeChartUserShapes));
|
||||
}
|
||||
std::wostream & oox_chart_context::chartData()
|
||||
{
|
||||
return impl_->chartData_;
|
||||
@ -116,6 +122,15 @@ void oox_chart_context::dump_rels(rels & Rels)
|
||||
(r.is_internal ? L"" : L"External"))
|
||||
);
|
||||
}
|
||||
else if (r.type == typeChartUserShapes)
|
||||
{
|
||||
Rels.add(relationship(
|
||||
r.rid,
|
||||
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes",
|
||||
r.is_internal ? std::wstring(L"../drawings/") + r.ref : r.ref,
|
||||
(r.is_internal ? L"" : L"External"))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,6 +241,13 @@ void oox_chart_context::serialize(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (userShapesId_.empty() == false)
|
||||
{
|
||||
CP_XML_NODE(L"c:userShapes")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", userShapesId_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ typedef _CP_PTR(oox_chart_context) oox_chart_context_ptr;
|
||||
class oox_chart_context
|
||||
{
|
||||
public:
|
||||
oox_chart_context(mediaitems & mediaitems_, std::wstring name);
|
||||
oox_chart_context(mediaitems_ptr & mediaitems_, std::wstring name);
|
||||
~oox_chart_context();
|
||||
|
||||
std::wostream & chartData();
|
||||
@ -83,6 +83,8 @@ public:
|
||||
}
|
||||
}
|
||||
void set_externalData(const std::wstring & href);
|
||||
void set_userShapes(std::pair<std::wstring, std::wstring> &link);
|
||||
|
||||
void add_chart(int type)
|
||||
{
|
||||
plot_area_.add_chart(type);
|
||||
@ -128,7 +130,7 @@ private:
|
||||
class Impl;
|
||||
_CP_SCOPED_PTR(Impl) impl_;
|
||||
|
||||
mediaitems &mediaitems_;
|
||||
mediaitems_ptr mediaitems_;
|
||||
std::vector<_rel> rels_;
|
||||
|
||||
cpdoccore::oox::oox_title title_;
|
||||
@ -137,6 +139,7 @@ private:
|
||||
|
||||
std::wstring pivot_source_;
|
||||
std::wstring externalDataId_;
|
||||
std::wstring userShapesId_;
|
||||
|
||||
std::vector<odf_reader::_property> graphic_properties_;
|
||||
_oox_fill fill_;
|
||||
|
||||
@ -131,7 +131,16 @@ static const std::wstring _ooxDashStyle[]=
|
||||
L"dashDot",
|
||||
L"sysDashDotDot"
|
||||
};
|
||||
|
||||
static const std::wstring _vmlDashStyle[]=
|
||||
{
|
||||
L"none",
|
||||
L"solid",
|
||||
L"dot",
|
||||
L"dash",
|
||||
L"dash",
|
||||
L"dashdot",
|
||||
L"shortdashdotdot"
|
||||
};
|
||||
void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop, bool always_draw, const std::wstring &ns)
|
||||
{
|
||||
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
|
||||
@ -152,7 +161,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
|
||||
odf_reader::GetProperty(prop, L"stroke" , iStroke);
|
||||
odf_reader::GetProperty(prop, L"stroke-width" , dStrokeWidth);
|
||||
odf_reader::GetProperty(prop, L"stroke-opacity" , dStrokeOpacity);
|
||||
|
||||
|
||||
if ((!strStrokeColor && !iStroke && !dStrokeWidth) && !always_draw)return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
@ -224,6 +233,69 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
|
||||
}
|
||||
}
|
||||
}
|
||||
void vml_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_property> & prop)
|
||||
{
|
||||
_CP_OPT(std::wstring) strStrokeColor;
|
||||
_CP_OPT(int) iStroke;
|
||||
_CP_OPT(double) dStrokeWidth;
|
||||
_CP_OPT(double) dStrokeOpacity;
|
||||
_CP_OPT(bool) bWordArt;
|
||||
|
||||
odf_reader::GetProperty(prop, L"wordArt", bWordArt);
|
||||
|
||||
odf_reader::GetProperty(prop, L"stroke-color" , strStrokeColor);
|
||||
odf_reader::GetProperty(prop, L"stroke" , iStroke);
|
||||
odf_reader::GetProperty(prop, L"stroke-width" , dStrokeWidth);
|
||||
odf_reader::GetProperty(prop, L"stroke-opacity" , dStrokeOpacity);
|
||||
|
||||
if (!strStrokeColor && !iStroke && !dStrokeWidth) return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"v:stroke")
|
||||
{
|
||||
std::wstring color, dash_style ;
|
||||
|
||||
if (strStrokeColor) color = *strStrokeColor;
|
||||
|
||||
if (iStroke)
|
||||
{
|
||||
if (iStroke.get() != 0 ) dash_style = _vmlDashStyle[iStroke.get()];
|
||||
}
|
||||
|
||||
if ((dStrokeWidth) && (*dStrokeWidth >= 0))
|
||||
{
|
||||
int val = dStrokeWidth.get() * 12700; //in emu (1 pt = 12700)
|
||||
if (val < 10) val = 12700;
|
||||
|
||||
CP_XML_ATTR(L"weight", val);
|
||||
}
|
||||
|
||||
if (false == color.empty())
|
||||
{
|
||||
CP_XML_ATTR(L"color", L"#" + color);
|
||||
}
|
||||
if (!dash_style.empty() && dash_style != L"solid")
|
||||
{
|
||||
CP_XML_ATTR(L"dashstyle", dash_style);
|
||||
}
|
||||
//odf_reader::GetProperty(prop,L"marker-start", strVal);
|
||||
//if (strVal)
|
||||
//{
|
||||
//}
|
||||
//odf_reader::GetProperty(prop,L"marker-end",strVal);
|
||||
//if (strVal)
|
||||
//{
|
||||
//}
|
||||
|
||||
CP_XML_ATTR(L"startarrow", L"block");
|
||||
CP_XML_ATTR(L"startarrowwidth", L"medium");
|
||||
CP_XML_ATTR(L"startarrowlength", L"medium");
|
||||
CP_XML_ATTR(L"joinstyle", L"round");
|
||||
CP_XML_ATTR(L"endcap", L"flat");
|
||||
}
|
||||
}
|
||||
}
|
||||
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_property> & prop, const std::wstring & shapeGeomPreset, const std::wstring &ns)
|
||||
{
|
||||
std::wstring ns_att = (ns == L"a" ? L"" : ns + L":");
|
||||
|
||||
@ -124,6 +124,7 @@ namespace oox {
|
||||
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val, const std::wstring & shapeGeomPreset, const std::wstring &ns = L"a");
|
||||
void oox_serialize_action (std::wostream & strm, const _action_desc & val);
|
||||
|
||||
void vml_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -245,7 +245,7 @@ void vml_serialize_gradient_fill(std::wostream & strm, const _oox_fill & val)
|
||||
{
|
||||
if (!val.gradient->colors.empty())
|
||||
{
|
||||
CP_XML_ATTR(L"color2", val.gradient->colors[val.gradient->colors.size() - 1].color_ref);
|
||||
CP_XML_ATTR(L"color2", L"#" + val.gradient->colors[val.gradient->colors.size() - 1].color_ref);
|
||||
|
||||
std::wstring colors_value;
|
||||
for (size_t i = 0; i < val.gradient->colors.size(); i++)
|
||||
@ -404,6 +404,27 @@ void vml_serialize_background (std::wostream & strm, const _oox_fill & val, cons
|
||||
}
|
||||
}
|
||||
|
||||
void vml_serialize_fill (std::wostream & strm, const _oox_fill & val)
|
||||
{
|
||||
switch (val.type)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
vml_serialize_solid_fill(strm, val);
|
||||
break;
|
||||
case 2:
|
||||
vml_serialize_bitmap_fill(strm, val);
|
||||
break;
|
||||
case 3:
|
||||
vml_serialize_gradient_fill(strm, val);
|
||||
break;
|
||||
case 4:
|
||||
//vml_serialize_hatch_fill(strm, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns)
|
||||
{
|
||||
switch (val.type)
|
||||
|
||||
@ -154,5 +154,6 @@ namespace oox {
|
||||
void oox_serialize_bitmap_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
|
||||
|
||||
void oox_serialize_fill (std::wostream & strm, const _oox_fill & val, const std::wstring &ns = L"a");
|
||||
void vml_serialize_fill (std::wostream & strm, const _oox_fill & val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +173,26 @@ bool content_types_file::add_or_find_override(const std::wstring & fileName)
|
||||
|
||||
return true;
|
||||
}
|
||||
void content_types_file::set_media(mediaitems_ptr & _Mediaitems)
|
||||
{
|
||||
std::vector<mediaitems::item> & items_ = _Mediaitems->items();
|
||||
for (size_t i = 0; i < items_.size(); i++)
|
||||
{
|
||||
if ((items_[i].type == typeImage ||
|
||||
items_[i].type == typeMedia ||
|
||||
items_[i].type == typeVideo ||
|
||||
items_[i].type == typeAudio) && items_[i].mediaInternal)
|
||||
{
|
||||
int n = items_[i].outputName.rfind(L".");
|
||||
if (n > 0)
|
||||
{
|
||||
add_or_find_default(items_[i].outputName.substr(n + 1, items_[i].outputName.length() - n));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void content_types_file::set_media(mediaitems & _Mediaitems)
|
||||
{
|
||||
@ -349,7 +369,7 @@ void docProps_files::write(const std::wstring & RootPath)
|
||||
////////////
|
||||
|
||||
|
||||
media::media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts) : mediaitems_(_Mediaitems), appFonts_(pAppFonts)
|
||||
media::media(mediaitems_ptr & _mediaitems, NSFonts::IApplicationFonts *pAppFonts) : mediaItems_(_mediaitems), appFonts_(pAppFonts)
|
||||
{
|
||||
}
|
||||
|
||||
@ -358,7 +378,8 @@ void media::write(const std::wstring & RootPath)
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
mediaitems::items_array & items = mediaitems_.items();
|
||||
mediaitems::items_array & items = mediaItems_->items();
|
||||
|
||||
for (size_t i = 0; i < items.size(); i++ )
|
||||
{
|
||||
if (items[i].mediaInternal && items[i].valid && ( items[i].type == typeImage ||
|
||||
@ -381,7 +402,7 @@ void media::write(const std::wstring & RootPath)
|
||||
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
charts::charts(mediaitems & _ChartsItems) : chartsitems_(_ChartsItems)
|
||||
charts::charts(mediaitems_ptr & _chartsItems) : chartsItems_(_chartsItems)
|
||||
{
|
||||
}
|
||||
|
||||
@ -390,7 +411,7 @@ void charts::write(const std::wstring & RootPath)
|
||||
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
embeddings::embeddings(mediaitems & _EmbeddingsItems) : embeddingsitems_(_EmbeddingsItems)
|
||||
embeddings::embeddings(mediaitems_ptr & _EmbeddingsItems) : embeddingsItems_(_EmbeddingsItems)
|
||||
{
|
||||
}
|
||||
void embeddings::write(const std::wstring & RootPath)
|
||||
@ -400,7 +421,8 @@ void embeddings::write(const std::wstring & RootPath)
|
||||
|
||||
content_types_file & content_types = get_main_document()->get_content_types_file();
|
||||
|
||||
mediaitems::items_array & items = embeddingsitems_.items();
|
||||
mediaitems::items_array & items = embeddingsItems_->items();
|
||||
|
||||
for (size_t i = 0; i < items.size(); i++ )
|
||||
{
|
||||
if ( items[i].mediaInternal && items[i].valid &&
|
||||
|
||||
@ -51,6 +51,7 @@ namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
class mediaitems;
|
||||
typedef _CP_PTR(mediaitems) mediaitems_ptr;
|
||||
|
||||
namespace package {
|
||||
|
||||
@ -81,16 +82,17 @@ inline element::~element()
|
||||
class content_types_file : public element
|
||||
{
|
||||
public:
|
||||
content_types_file ();
|
||||
void write (const std::wstring & RootPath);
|
||||
bool add_or_find_default (const std::wstring & extension);
|
||||
bool add_or_find_override(const std::wstring & fileName);
|
||||
void set_media (mediaitems & _Mediaitems);
|
||||
content_type * content ();
|
||||
content_types_file ();
|
||||
void write (const std::wstring & RootPath);
|
||||
bool add_or_find_default (const std::wstring & extension);
|
||||
bool add_or_find_override(const std::wstring & fileName);
|
||||
void set_media (mediaitems & _Mediaitems);
|
||||
void set_media (mediaitems_ptr & _Mediaitems);
|
||||
content_type* content ();
|
||||
|
||||
private:
|
||||
content_type content_type_content_;
|
||||
std::wstring filename_;
|
||||
std::wstring filename_;
|
||||
};
|
||||
|
||||
class simple_element;
|
||||
@ -189,8 +191,8 @@ public:
|
||||
std::wstring str() { return content_.str(); }
|
||||
static _CP_PTR(chart_content) create();
|
||||
private:
|
||||
std::wstringstream content_;
|
||||
rels_file_ptr rels_;
|
||||
std::wstringstream content_;
|
||||
rels_file_ptr rels_;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
class document : public element
|
||||
@ -228,39 +230,39 @@ private:
|
||||
class media : public element
|
||||
{
|
||||
public:
|
||||
media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
|
||||
media(mediaitems_ptr & _mediaItems, NSFonts::IApplicationFonts *pAppFonts);
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
private:
|
||||
mediaitems & mediaitems_;
|
||||
NSFonts::IApplicationFonts * appFonts_;
|
||||
mediaitems_ptr mediaItems_;
|
||||
NSFonts::IApplicationFonts* appFonts_;
|
||||
|
||||
};
|
||||
|
||||
class charts : public element
|
||||
{
|
||||
public:
|
||||
charts(mediaitems & _ChartsItems);
|
||||
charts(mediaitems_ptr & _chartsItems);
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
private:
|
||||
mediaitems & chartsitems_;
|
||||
mediaitems_ptr chartsItems_;
|
||||
|
||||
};
|
||||
class embeddings : public element
|
||||
{
|
||||
public:
|
||||
embeddings(mediaitems & _EmbeddingsItems);
|
||||
embeddings(mediaitems_ptr & _embeddingsItems);
|
||||
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
private:
|
||||
mediaitems & embeddingsitems_;
|
||||
mediaitems_ptr embeddingsItems_;
|
||||
|
||||
};
|
||||
} // namespace package
|
||||
|
||||
@ -43,6 +43,7 @@ namespace oox {
|
||||
enum RelsType
|
||||
{
|
||||
typeUnknown = 0,
|
||||
typeDefault,
|
||||
typeImage,
|
||||
typeChart,
|
||||
typeShape,
|
||||
@ -59,7 +60,8 @@ enum RelsType
|
||||
typeExternalLink,
|
||||
typeActiveX,
|
||||
typeControl,
|
||||
typeControlProps
|
||||
typeControlProps,
|
||||
typeChartUserShapes
|
||||
};
|
||||
|
||||
struct _rel
|
||||
@ -71,10 +73,10 @@ struct _rel
|
||||
type(type_)
|
||||
{}
|
||||
|
||||
bool is_internal;
|
||||
std::wstring rid;
|
||||
std::wstring ref;
|
||||
RelsType type;
|
||||
bool is_internal;
|
||||
std::wstring rid;
|
||||
std::wstring ref;
|
||||
RelsType type;
|
||||
};
|
||||
|
||||
class relationship : public xml::element_impl<relationship>
|
||||
|
||||
@ -51,7 +51,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content,pptx_comments_ptr comments)
|
||||
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, pptx_comments_ptr comments)
|
||||
{
|
||||
const std::wstring file_id = std::to_wstring(next_file_id_++);
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ void pptx_conversion_context::set_output_document(package::pptx_document * docum
|
||||
|
||||
void pptx_conversion_context::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
pptx_slide_context_.get_mediaitems().set_font_directory(pathFonts);
|
||||
pptx_slide_context_.get_mediaitems()->set_font_directory(pathFonts);
|
||||
}
|
||||
|
||||
void pptx_conversion_context::process_layouts()
|
||||
|
||||
@ -133,7 +133,7 @@ public:
|
||||
|
||||
pptx_table_context & get_table_context() { return pptx_table_context_; }
|
||||
|
||||
mediaitems & get_mediaitems() { return pptx_slide_context_.get_mediaitems(); }
|
||||
mediaitems_ptr & get_mediaitems() { return pptx_slide_context_.get_mediaitems(); }
|
||||
|
||||
//void start_hyperlink(const std::wstring & styleName);
|
||||
//void end_hyperlink(std::wstring const & href);
|
||||
|
||||
@ -509,15 +509,15 @@ void ppt_files::add_notesMaster(slide_content_ptr slide)
|
||||
{
|
||||
notesMaster_files_.add_slide(slide);
|
||||
}
|
||||
void ppt_files::set_media(mediaitems & _Mediaitems)
|
||||
void ppt_files::set_media(mediaitems_ptr & _mediaitems)
|
||||
{
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
if (_mediaitems->count_image + _mediaitems->count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
|
||||
media_ = element_ptr( new media(_mediaitems, _mediaitems->applicationFonts()) );
|
||||
}
|
||||
if (_Mediaitems.count_object > 0)
|
||||
if (_mediaitems->count_object > 0)
|
||||
{
|
||||
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
|
||||
embeddings_ = element_ptr( new embeddings(_mediaitems) );
|
||||
}
|
||||
}
|
||||
void ppt_files::set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments)
|
||||
|
||||
@ -217,7 +217,7 @@ public:
|
||||
void add_notes (slide_content_ptr sheet);
|
||||
void add_notesMaster(slide_content_ptr sheet);
|
||||
|
||||
void set_media(mediaitems & _Mediaitems);
|
||||
void set_media(mediaitems_ptr & _mediaitems);
|
||||
void add_charts(chart_content_ptr chart);
|
||||
void add_theme (pptx_xml_theme_ptr theme);
|
||||
|
||||
|
||||
@ -65,8 +65,10 @@ public:
|
||||
bool onClick;
|
||||
};
|
||||
|
||||
Impl(const std::wstring & odfPacket) : mediaitems_(odfPacket), odfPacket_(odfPacket)
|
||||
Impl(const std::wstring & _odfPacket) : odfPacket_(_odfPacket)
|
||||
{
|
||||
mediaitems_ = boost::make_shared<mediaitems>(odfPacket_);
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
@ -88,7 +90,7 @@ public:
|
||||
{
|
||||
pptx_drawings_->add(isInternal, rid, ref, type);
|
||||
}
|
||||
mediaitems & get_mediaitems() { return mediaitems_; }
|
||||
mediaitems_ptr & get_mediaitems() { return mediaitems_; }
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
@ -138,7 +140,7 @@ private:
|
||||
void process_media (drawing_object_description& obj, _pptx_drawing & drawing);
|
||||
|
||||
size_t rId_;
|
||||
mediaitems mediaitems_;
|
||||
mediaitems_ptr mediaitems_;
|
||||
pptx_drawings_ptr pptx_drawings_;
|
||||
pptx_drawings_ptr pptx_notes_drawings_;
|
||||
};
|
||||
@ -357,7 +359,7 @@ void pptx_slide_context::add_background(_oox_fill & fill)
|
||||
bool isMediaInternal = false;
|
||||
std::wstring ref;
|
||||
|
||||
fill.bitmap->rId = get_mediaitems().add_or_find(fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
fill.bitmap->rId = get_mediaitems()->add_or_find(fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
add_rels(isMediaInternal, fill.bitmap->rId, ref, typeImage);
|
||||
}
|
||||
impl_->background_fill_ = fill;
|
||||
@ -421,7 +423,7 @@ void pptx_slide_context::set_link(std::wstring link, RelsType typeRels)
|
||||
{
|
||||
bool isMediaInternal = true;
|
||||
|
||||
impl_->object_description_.action_.hSoundId = get_mediaitems().add_or_find(link, typeAudio, isMediaInternal, impl_->object_description_.action_.hSoundRef);
|
||||
impl_->object_description_.action_.hSoundId = get_mediaitems()->add_or_find(link, typeAudio, isMediaInternal, impl_->object_description_.action_.hSoundRef);
|
||||
impl_->add_additional_rels(isMediaInternal, impl_->object_description_.action_.hSoundId, impl_->object_description_.action_.hSoundRef, typeAudio);
|
||||
}
|
||||
else
|
||||
@ -566,7 +568,7 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
|
||||
}
|
||||
|
||||
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, get_mediaitems().applicationFonts());
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, get_mediaitems()->applicationFonts());
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
|
||||
if ((sColorMode) && (*sColorMode == L"greyscale"))
|
||||
@ -576,7 +578,7 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
bool isMediaInternal = false;
|
||||
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
|
||||
drawing.fill.bitmap->rId = get_mediaitems()->add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
|
||||
drawing.fill.bitmap->isInternal = isMediaInternal;
|
||||
|
||||
if (drawing.type == typeShape)
|
||||
@ -584,7 +586,7 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
|
||||
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
|
||||
|
||||
isMediaInternal = true;
|
||||
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
std::wstring rId = get_mediaitems()->add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
|
||||
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
|
||||
|
||||
@ -599,7 +601,7 @@ void pptx_slide_context::Impl::process_chart(drawing_object_description & obj, _
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectId = get_mediaitems()->add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
|
||||
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
|
||||
}
|
||||
@ -608,7 +610,7 @@ void pptx_slide_context::Impl::process_table(drawing_object_description & obj, _
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
std::wstring rId = get_mediaitems().add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
std::wstring rId = get_mediaitems()->add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
|
||||
add_drawing(drawing, isMediaInternal, rId, ref, drawing.type);
|
||||
|
||||
@ -623,12 +625,12 @@ void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _
|
||||
|
||||
if (drawing.fill.bitmap)
|
||||
{
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
drawing.fill.bitmap->rId = get_mediaitems()->add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
|
||||
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
|
||||
}
|
||||
|
||||
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
std::wstring rId = get_mediaitems()->add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
_CP_OPT(std::wstring) sPlaceHolderType;
|
||||
@ -651,7 +653,7 @@ void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _
|
||||
std::wstring ref, ref_image;
|
||||
bool isMediaInternal = true, isMediaInternal_image = true;
|
||||
|
||||
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectId = get_mediaitems()->add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectProgId = obj.descriptor_;
|
||||
|
||||
if (!drawing.fill.bitmap)
|
||||
@ -662,7 +664,7 @@ void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _
|
||||
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
|
||||
}
|
||||
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
|
||||
drawing.fill.bitmap->rId = get_mediaitems()->add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
|
||||
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
|
||||
|
||||
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
|
||||
@ -674,7 +676,7 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
|
||||
|
||||
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
|
||||
|
||||
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
|
||||
drawing.objectId = get_mediaitems()->add_or_find(obj.xlink_href_, drawing.type, isMediaInternal, ref);
|
||||
drawing.extId = L"ext" + drawing.objectId;
|
||||
drawing.extExternal = !isMediaInternal;
|
||||
|
||||
@ -685,7 +687,7 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
|
||||
|
||||
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
|
||||
}
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
|
||||
drawing.fill.bitmap->rId = get_mediaitems()->add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
|
||||
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
|
||||
|
||||
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
|
||||
@ -718,7 +720,7 @@ void pptx_slide_context::dump_rels(rels & Rels)
|
||||
impl_->get_drawings()->dump_rels(Rels);
|
||||
}
|
||||
|
||||
mediaitems & pptx_slide_context::get_mediaitems()
|
||||
mediaitems_ptr & pptx_slide_context::get_mediaitems()
|
||||
{
|
||||
return impl_->get_mediaitems();
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public:
|
||||
|
||||
void process_drawings();
|
||||
|
||||
mediaitems & get_mediaitems();
|
||||
mediaitems_ptr & get_mediaitems();
|
||||
|
||||
void add_background (_oox_fill & fill);
|
||||
|
||||
|
||||
@ -390,7 +390,7 @@ void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::styl
|
||||
{
|
||||
bool isMediaInternal = true;
|
||||
std::wstring ref;
|
||||
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
|
||||
fill.bitmap->rId = Context.get_slide_context().get_mediaitems()->add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
|
||||
Context.get_slide_context().add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::typeImage);
|
||||
}
|
||||
oox::oox_serialize_fill(CP_XML_STREAM(), fill);
|
||||
|
||||
@ -39,14 +39,14 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
unsigned int hex_string_to_int(std::wstring str)
|
||||
{
|
||||
unsigned int x;
|
||||
std::wstringstream ss;
|
||||
ss << std::hex << str;
|
||||
ss >> x;
|
||||
return x;
|
||||
}
|
||||
unsigned int hex_string_to_int(std::wstring str)
|
||||
{
|
||||
unsigned int x;
|
||||
std::wstringstream ss;
|
||||
ss << std::hex << str;
|
||||
ss >> x;
|
||||
return x;
|
||||
}
|
||||
|
||||
class xlsx_comments::Impl
|
||||
{
|
||||
@ -94,127 +94,6 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
void serialize_vml(std::wostream & strm) const
|
||||
{
|
||||
_CP_OPT(std::wstring) strVal;
|
||||
_CP_OPT(double) dVal;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xml")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:v", L"urn:schemas-microsoft-com:vml");
|
||||
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
|
||||
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
|
||||
|
||||
for (size_t i = 0; i < xlsx_comment_.size(); i++)
|
||||
{
|
||||
const _xlsx_comment & c = xlsx_comment_[i];
|
||||
|
||||
std::wstring str_fill_color_ = L"00003f";
|
||||
if (odf_reader::GetProperty(c.graphicProperties_,L"fill-color",strVal))
|
||||
str_fill_color_ = strVal.get();
|
||||
|
||||
CP_XML_NODE(L"v:shapetype")
|
||||
{
|
||||
CP_XML_ATTR(L"id", L"shapetype_202");
|
||||
CP_XML_ATTR(L"coordsize", L"21600,21600");
|
||||
CP_XML_ATTR(L"o:spt", L"202");
|
||||
CP_XML_ATTR(L"path", L"m,l,21600l21600,21600l21600,xe");
|
||||
|
||||
CP_XML_NODE(L"v:stroke")
|
||||
{
|
||||
CP_XML_ATTR(L"joinstyle", L"miter");
|
||||
}
|
||||
CP_XML_NODE(L"v:path")
|
||||
{
|
||||
CP_XML_ATTR(L"gradientshapeok", L"t");
|
||||
CP_XML_ATTR(L"o:connecttype", L"rect");
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"v:shape")
|
||||
{
|
||||
if( hex_string_to_int(str_fill_color_) !=0 )
|
||||
{
|
||||
CP_XML_ATTR(L"fillcolor", std::wstring(L"#") + str_fill_color_);
|
||||
}//иначе это полная прозрачность
|
||||
|
||||
CP_XML_ATTR(L"id", L"shape_0");
|
||||
|
||||
std::wstring style = std::wstring(L"position:absolute;");
|
||||
|
||||
style += std::wstring(L"margin-left:") + boost::lexical_cast<std::wstring>(c.left_) + std::wstring(L"pt;");
|
||||
style += std::wstring(L"margin-top:") + boost::lexical_cast<std::wstring>(c.top_) + std::wstring(L"pt;");
|
||||
style += std::wstring(L"width:") + boost::lexical_cast<std::wstring>(c.width_) + std::wstring(L"pt;");
|
||||
style += std::wstring(L"height:") + boost::lexical_cast<std::wstring>(c.height_) + std::wstring(L"pt;");
|
||||
|
||||
if (c.visibly_ == false)style += std::wstring(L"visibility:hidden;");
|
||||
|
||||
CP_XML_ATTR(L"style",style);
|
||||
CP_XML_ATTR(L"type", L"shapetype_202");
|
||||
//if (odf_reader::GetProperty(c.graphicProperties_,L"opacity",dVal))
|
||||
//{
|
||||
// CP_XML_ATTR(L"opacity", boost::lexical_cast<std::wstring>((int)(100.-dVal.get())) + L"%");
|
||||
//}
|
||||
//CP_XML_NODE(L"v:shadow")
|
||||
//{
|
||||
// CP_XML_ATTR(L"color", L"black");
|
||||
// CP_XML_ATTR(L"obscured", L"t");
|
||||
// CP_XML_ATTR(L"on", L"t");
|
||||
//}
|
||||
|
||||
CP_XML_NODE(L"v:wrap")
|
||||
{
|
||||
CP_XML_ATTR(L"v:type", L"none");
|
||||
}
|
||||
CP_XML_NODE(L"v:fill")
|
||||
{
|
||||
CP_XML_ATTR(L"detectmouseclick", L"t");
|
||||
if( hex_string_to_int(str_fill_color_) !=0 )
|
||||
{
|
||||
CP_XML_ATTR(L"color", std::wstring(L"#") + str_fill_color_);
|
||||
CP_XML_ATTR(L"color2", std::wstring(L"#") + str_fill_color_);
|
||||
CP_XML_ATTR(L"type", L"solid");
|
||||
}//иначе это полная прозрачность
|
||||
//if (odf_reader::GetProperty(c.graphicProperties_,L"opacity",dVal))
|
||||
//{
|
||||
// CP_XML_ATTR(L"opacity", (dVal.get())/100.);
|
||||
// //CP_XML_ATTR(L"opacity2",(dVal.get())/100.);
|
||||
//}
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"v:stroke")
|
||||
{
|
||||
if (odf_reader::GetProperty(c.graphicProperties_,L"stroke-color",strVal))
|
||||
CP_XML_ATTR(L"color", std::wstring(L"#") + strVal.get());
|
||||
else
|
||||
CP_XML_ATTR(L"color",L"#3465af"); //синенький
|
||||
|
||||
if (odf_reader::GetProperty(c.graphicProperties_,L"stroke-opacity",dVal))
|
||||
{
|
||||
CP_XML_ATTR(L"opacity",(100.-dVal.get())/100.);
|
||||
}
|
||||
CP_XML_ATTR(L"endcap", L"flat");
|
||||
CP_XML_ATTR(L"joinstyle", L"round");
|
||||
CP_XML_ATTR(L"startarrow", L"block");
|
||||
CP_XML_ATTR(L"v:startarrowwidth", L"medium");
|
||||
CP_XML_ATTR(L"startarrowlength", L"medium");
|
||||
}
|
||||
CP_XML_NODE(L"x:ClientData")
|
||||
{
|
||||
CP_XML_ATTR(L"ObjectType", L"Note");
|
||||
CP_XML_NODE(L"x:MoveWithCells"){}
|
||||
CP_XML_NODE(L"x:SizeWithCells"){}
|
||||
CP_XML_NODE(L"x:AutoFill"){CP_XML_CONTENT("False");}
|
||||
CP_XML_NODE(L"x:Row"){CP_XML_CONTENT(c.row_);}
|
||||
CP_XML_NODE(L"x:Column"){CP_XML_CONTENT(c.col_);}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
bool empty() const
|
||||
{
|
||||
return ( xlsx_comment_.empty());
|
||||
@ -264,11 +143,6 @@ void xlsx_serialize(std::wostream & _Wostream, xlsx_comments const & val)
|
||||
val.impl_->serialize(_Wostream);
|
||||
}
|
||||
|
||||
void xlsx_serialize_vml(std::wostream & _Wostream, xlsx_comments const & val)
|
||||
{
|
||||
val.impl_->serialize_vml(_Wostream);
|
||||
}
|
||||
|
||||
xlsx_comments_ptr xlsx_comments::create()
|
||||
{
|
||||
return boost::make_shared<xlsx_comments>();
|
||||
|
||||
@ -42,38 +42,24 @@ namespace oox {
|
||||
|
||||
struct _xlsx_comment
|
||||
{
|
||||
size_t left_, top_;
|
||||
size_t width_, height_;
|
||||
|
||||
std::wstring ref_;
|
||||
|
||||
int col_;
|
||||
int row_;
|
||||
|
||||
bool visibly_;
|
||||
|
||||
std::vector<odf_reader::_property> graphicProperties_;
|
||||
|
||||
std::wstring author_;
|
||||
std::wstring content_;
|
||||
};
|
||||
//class rels;
|
||||
|
||||
class xlsx_comments;
|
||||
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
|
||||
|
||||
struct comment_elm
|
||||
{
|
||||
comment_elm(std::wstring const & _filename, std::wstring const & _vml_filename, std::wstring const & _content, std::wstring const & _vml_content, xlsx_comments_ptr _comments)
|
||||
: filename(_filename), content(_content), comments(_comments),vml_filename(_vml_filename),vml_content(_vml_content)
|
||||
comment_elm(std::wstring const & _filename, std::wstring const & _content, xlsx_comments_ptr _comments)
|
||||
: filename(_filename), content(_content), comments(_comments)
|
||||
{}
|
||||
xlsx_comments_ptr comments;
|
||||
|
||||
std::wstring filename;
|
||||
std::wstring content;
|
||||
|
||||
std::wstring vml_filename;
|
||||
std::wstring vml_content;
|
||||
};
|
||||
|
||||
class xlsx_comments
|
||||
@ -87,10 +73,7 @@ public:
|
||||
void add(_xlsx_comment & d);
|
||||
bool empty() const;
|
||||
|
||||
friend void docx_serialize(std::wostream & _Wostream, xlsx_comments const & val);
|
||||
|
||||
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_comments const & val);
|
||||
friend void xlsx_serialize_vml(std::wostream & _Wostream, xlsx_comments const & val);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
#include "../odf/datatypes/length.h"
|
||||
#include "xlsx_utils.h"
|
||||
|
||||
//#include <formulasconvert.h>
|
||||
|
||||
namespace cpdoccore { namespace oox {
|
||||
|
||||
@ -46,32 +45,22 @@ typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
|
||||
class xlsx_comments_context_handle::Impl
|
||||
{
|
||||
public:
|
||||
Impl()
|
||||
: next_comments_id_(1) ,next_file_id_(1)
|
||||
Impl() : next_comments_id_(1), next_file_id_(1)
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
|
||||
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, xlsx_comments_ptr comments)
|
||||
{
|
||||
const std::wstring file_id = std::to_wstring(next_file_id_++);
|
||||
|
||||
const std::wstring file_id = std::to_wstring(next_file_id_++);
|
||||
const std::wstring fileName = std::wstring(L"comments") + file_id + L".xml";
|
||||
const std::wstring vml_fileName = std::wstring(L"vmlDrawing") + file_id + L".vml";
|
||||
|
||||
comments_.push_back(comment_elm(fileName,vml_fileName, content, vml_content, comments));
|
||||
comments_.push_back(comment_elm(fileName, content, comments));
|
||||
|
||||
const std::wstring id = std::to_wstring(next_comments_id_++);
|
||||
const std::wstring rId = std::wstring(L"comId") + id;
|
||||
return std::pair<std::wstring, std::wstring>(fileName, rId);
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> get_vml_drawing_xml()
|
||||
{
|
||||
const std::wstring id = std::to_wstring(next_comments_id_++);
|
||||
const std::wstring rId = std::wstring(L"comId") + id;
|
||||
return std::pair<std::wstring, std::wstring>(comments_.back().vml_filename, rId);
|
||||
}
|
||||
|
||||
const std::vector<comment_elm> & content() const
|
||||
{
|
||||
return comments_;
|
||||
@ -89,25 +78,17 @@ xlsx_comments_context_handle::xlsx_comments_context_handle()
|
||||
: impl_(new xlsx_comments_context_handle::Impl())
|
||||
{
|
||||
}
|
||||
|
||||
xlsx_comments_context_handle::~xlsx_comments_context_handle()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments)
|
||||
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::add_comments_xml(std::wstring const & content, xlsx_comments_ptr comments)
|
||||
{
|
||||
return impl_->add_comments_xml(content,vml_content, comments);
|
||||
return impl_->add_comments_xml(content, comments);
|
||||
}
|
||||
std::pair<std::wstring, std::wstring> xlsx_comments_context_handle::get_vml_drawing_xml()
|
||||
{
|
||||
return impl_->get_vml_drawing_xml();
|
||||
}
|
||||
|
||||
const std::vector<comment_elm> & xlsx_comments_context_handle::content() const
|
||||
{
|
||||
return impl_->content();
|
||||
}
|
||||
|
||||
class xlsx_comments_context::Impl
|
||||
{
|
||||
public:
|
||||
@ -127,10 +108,6 @@ public:
|
||||
{
|
||||
xlsx_serialize(strm, *xlsx_comments_);
|
||||
}
|
||||
void serialize_vml(std::wostream & strm)
|
||||
{
|
||||
xlsx_serialize_vml(strm, *xlsx_comments_);
|
||||
}
|
||||
bool empty() const
|
||||
{
|
||||
return xlsx_comments_->empty();
|
||||
@ -154,40 +131,20 @@ xlsx_comments_context::~xlsx_comments_context()
|
||||
{
|
||||
}
|
||||
|
||||
void xlsx_comments_context::start_comment (double width_pt, double height_pt, double x_pt, double y_pt)
|
||||
void xlsx_comments_context::start_comment(const std::wstring & ref)
|
||||
{
|
||||
impl_->current_.ref_ = L"";
|
||||
impl_->current_.width_ = width_pt;
|
||||
impl_->current_.height_ = height_pt;
|
||||
impl_->current_.left_ = x_pt;
|
||||
impl_->current_.top_ = y_pt;
|
||||
|
||||
impl_->current_.visibly_ = false;
|
||||
impl_->current_.ref_ = ref;
|
||||
}
|
||||
void xlsx_comments_context::add_content(std::wstring content)
|
||||
void xlsx_comments_context::add_content(const std::wstring & content)
|
||||
{
|
||||
impl_->current_.content_ = content;
|
||||
}
|
||||
void xlsx_comments_context::add_author(std::wstring author)
|
||||
void xlsx_comments_context::add_author(const std::wstring & author)
|
||||
{
|
||||
impl_->current_.author_ = author;
|
||||
}
|
||||
void xlsx_comments_context::set_visibly(bool Val)
|
||||
void xlsx_comments_context::end_comment()
|
||||
{
|
||||
impl_->current_.visibly_ = Val;
|
||||
}
|
||||
|
||||
std::vector<odf_reader::_property> & xlsx_comments_context::get_draw_properties()
|
||||
{
|
||||
return impl_->current_.graphicProperties_;
|
||||
|
||||
}
|
||||
void xlsx_comments_context::end_comment(std::wstring ref,int col, int row)
|
||||
{
|
||||
impl_->current_.ref_ = ref;
|
||||
impl_->current_.col_ = col;
|
||||
impl_->current_.row_ = row;
|
||||
|
||||
impl_->add_comment(impl_->current_);
|
||||
}
|
||||
|
||||
@ -200,11 +157,6 @@ void xlsx_comments_context::serialize(std::wostream & strm)
|
||||
{
|
||||
impl_->serialize(strm);
|
||||
}
|
||||
void xlsx_comments_context::serialize_vml(std::wostream & strm)
|
||||
{
|
||||
impl_->serialize_vml(strm);
|
||||
}
|
||||
|
||||
xlsx_comments_ptr xlsx_comments_context::get_comments()
|
||||
{
|
||||
return impl_->get_comments();
|
||||
|
||||
@ -45,16 +45,13 @@ class xlsx_table_metrics;
|
||||
class xlsx_comments;
|
||||
typedef _CP_PTR(xlsx_comments) xlsx_comments_ptr;
|
||||
|
||||
|
||||
|
||||
class xlsx_comments_context_handle
|
||||
{
|
||||
public:
|
||||
xlsx_comments_context_handle();
|
||||
~xlsx_comments_context_handle();
|
||||
|
||||
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, std::wstring const & vml_content,xlsx_comments_ptr comments);
|
||||
std::pair<std::wstring, std::wstring> get_vml_drawing_xml();
|
||||
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, xlsx_comments_ptr comments);
|
||||
const std::vector<comment_elm> & content() const;
|
||||
|
||||
friend class xlsx_comments_context;
|
||||
@ -72,21 +69,16 @@ public:
|
||||
xlsx_comments_context(xlsx_comments_context_handle & h);
|
||||
~xlsx_comments_context();
|
||||
|
||||
void start_comment(double width_pt, double height_pt, double x_pt, double y_pt);
|
||||
void start_comment(const std::wstring & ref);
|
||||
|
||||
void add_content(std::wstring content);
|
||||
void add_author(std::wstring author);
|
||||
void add_content(const std::wstring & content);
|
||||
void add_author(const std::wstring & author);
|
||||
|
||||
std::vector<odf_reader::_property> & get_draw_properties();
|
||||
|
||||
void set_visibly(bool Val);
|
||||
|
||||
void end_comment(std::wstring ref,int col,int row);
|
||||
void end_comment();
|
||||
|
||||
bool empty() const;
|
||||
|
||||
void serialize (std::wostream & strm);
|
||||
void serialize_vml (std::wostream & strm);
|
||||
void serialize (std::wostream & strm);
|
||||
xlsx_comments_ptr get_comments();
|
||||
|
||||
private:
|
||||
|
||||
@ -35,6 +35,30 @@
|
||||
#include <xml/utils.h>
|
||||
|
||||
#include "../odf/datatypes/custom_shape_types_convert.h"
|
||||
#include "../../formulasconvert/formulasconvert.h"
|
||||
|
||||
#define OBJ_Group 0x0000
|
||||
#define OBJ_Line 0x0001
|
||||
#define OBJ_Rectangle 0x0002
|
||||
#define OBJ_Oval 0x0003
|
||||
#define OBJ_Arc 0x0004
|
||||
#define OBJ_Text 0x0006
|
||||
#define OBJ_OfficeArt 0x001E
|
||||
#define OBJ_Polygon 0x0009
|
||||
#define OBJ_Picture 0x0008
|
||||
#define OBJ_Chart 0x0005
|
||||
#define OBJ_Button 0x0007
|
||||
#define OBJ_CheckBox 0x000B
|
||||
#define OBJ_RadioButton 0x000C
|
||||
#define OBJ_EditBox 0x000D
|
||||
#define OBJ_Label 0x000E
|
||||
#define OBJ_DialogBox 0x000F
|
||||
#define OBJ_SpinControl 0x0010
|
||||
#define OBJ_Scrollbar 0x0011
|
||||
#define OBJ_List 0x0012
|
||||
#define OBJ_GroupBox 0x0013
|
||||
#define OBJ_DropdownList 0x0014
|
||||
#define OBJ_Note 0x0019
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
@ -48,17 +72,17 @@ std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t
|
||||
}
|
||||
|
||||
}
|
||||
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize_text(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
|
||||
{
|
||||
_CP_OPT(std::wstring) strTextContent;
|
||||
odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent);
|
||||
odf_reader::GetProperty ( val.additional, L"text-content", strTextContent);
|
||||
|
||||
if (!strTextContent)return;
|
||||
if (strTextContent->empty())return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:txBody")
|
||||
CP_XML_NODE(ns + L":txBody")
|
||||
{
|
||||
val.serialize_bodyPr(CP_XML_STREAM());
|
||||
|
||||
@ -71,28 +95,34 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_drawing_position::serialize(std::wostream & strm, std::wstring ns)
|
||||
std::wstring xlsx_drawing_position::vml_serialize()
|
||||
{
|
||||
//emu -> pt = 1 / 12700 = 72.0 / (360000.0 * 2.54);
|
||||
return std::to_wstring(position.col) + L"," + std::to_wstring((int)(position.colOff / 12700)) + L"," +
|
||||
std::to_wstring(position.row) + L"," + std::to_wstring((int)(position.rowOff / 12700));
|
||||
}
|
||||
void xlsx_drawing_position::serialize(std::wostream & strm, const std::wstring & ns_title, const std::wstring & ns)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE( ns + (type == xlsx_drawing_position::from ? L"from" : L"to") )
|
||||
CP_XML_NODE( ns_title + (ns_title.empty() ? L"" : L":") + (type == xlsx_drawing_position::from ? L"from" : L"to") )
|
||||
{
|
||||
CP_XML_NODE(L"xdr:col")
|
||||
CP_XML_NODE(ns + (ns.empty() ? L"" : L":") + L"col")
|
||||
{
|
||||
CP_XML_CONTENT(position.col);
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"xdr:colOff")
|
||||
CP_XML_NODE(ns + (ns.empty() ? L"" : L":") + L"colOff")
|
||||
{
|
||||
CP_XML_CONTENT(static_cast<size_t>(position.colOff));
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"xdr:row")
|
||||
CP_XML_NODE(ns + (ns.empty() ? L"" : L":") + L"row")
|
||||
{
|
||||
CP_XML_CONTENT(position.row);
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"xdr:rowOff")
|
||||
CP_XML_NODE(ns + (ns.empty() ? L"" : L":") + L"rowOff")
|
||||
{
|
||||
CP_XML_CONTENT(static_cast<size_t>(position.rowOff));
|
||||
}
|
||||
@ -100,15 +130,15 @@ void xlsx_drawing_position::serialize(std::wostream & strm, std::wstring ns)
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize_image(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:pic")
|
||||
CP_XML_NODE(ns + L":pic")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:nvPicPr")
|
||||
CP_XML_NODE(ns + L":nvPicPr")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:cNvPr")
|
||||
CP_XML_NODE(ns + L":cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
@ -116,7 +146,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
|
||||
oox_serialize_action(CP_XML_STREAM(), val.action);
|
||||
|
||||
}
|
||||
CP_XML_NODE(L"xdr:cNvPicPr")
|
||||
CP_XML_NODE(ns + L":cNvPicPr")
|
||||
{
|
||||
if (val.fill.bitmap->bCrop)
|
||||
{
|
||||
@ -128,7 +158,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
|
||||
val.fill.bitmap->name_space = L"xdr";
|
||||
oox_serialize_fill(CP_XML_STREAM(), val.fill);
|
||||
|
||||
CP_XML_NODE(L"xdr:spPr")
|
||||
CP_XML_NODE(ns + L":spPr")
|
||||
{
|
||||
val.serialize_xfrm(CP_XML_STREAM());
|
||||
|
||||
@ -139,20 +169,20 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
xlsx_serialize_text(CP_XML_STREAM(), val);
|
||||
xml_serialize_text(CP_XML_STREAM(), val, ns);
|
||||
}
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
|
||||
void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize_shape(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:sp")
|
||||
CP_XML_NODE(ns + L":sp")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:nvSpPr")
|
||||
CP_XML_NODE(ns + L":nvSpPr")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:cNvPr")
|
||||
CP_XML_NODE(ns + L":cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);//числовое значение val.rId
|
||||
|
||||
@ -160,12 +190,12 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
|
||||
oox_serialize_action(CP_XML_STREAM(), val.action);
|
||||
}
|
||||
CP_XML_NODE(L"xdr:cNvSpPr")//non visual properies (собственно тока 1 там)
|
||||
CP_XML_NODE(ns + L":cNvSpPr")//non visual properies (собственно тока 1 там)
|
||||
{
|
||||
if (val.sub_type == 1)CP_XML_ATTR(L"txBox", 1);
|
||||
}
|
||||
} // xdr:nv_Pr
|
||||
CP_XML_NODE(L"xdr:spPr")
|
||||
CP_XML_NODE(ns + L":spPr")
|
||||
{
|
||||
val.serialize_xfrm(CP_XML_STREAM());
|
||||
|
||||
@ -174,11 +204,11 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
oox_serialize_ln(CP_XML_STREAM(),val.additional, val.lined);
|
||||
} // xdr:spPr
|
||||
|
||||
xlsx_serialize_text(CP_XML_STREAM(), val);
|
||||
xml_serialize_text(CP_XML_STREAM(), val, ns);
|
||||
}
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize_object(std::wostream & strm, _xlsx_drawing & val)
|
||||
{//отображательная часть
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
@ -206,22 +236,22 @@ void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize_group(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:grpSp")
|
||||
CP_XML_NODE(ns + L":grpSp")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:nvGrpSpPr")
|
||||
CP_XML_NODE(ns + L":nvGrpSpPr")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:cNvPr")
|
||||
CP_XML_NODE(ns + L":cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
}
|
||||
CP_XML_NODE(L"xdr:cNvGrpSpPr");
|
||||
CP_XML_NODE(ns + L":cNvGrpSpPr");
|
||||
}
|
||||
CP_XML_NODE(L"xdr:grpSpPr")
|
||||
CP_XML_NODE(ns + L":grpSpPr")
|
||||
{
|
||||
val.serialize_xfrm(CP_XML_STREAM());
|
||||
|
||||
@ -231,7 +261,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
|
||||
{//отображательная часть
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
@ -266,75 +296,106 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
|
||||
void xml_serialize(std::wostream & strm, _xlsx_drawing & val, const std::wstring & ns)
|
||||
{
|
||||
if (val.type == typeShape)
|
||||
{
|
||||
xlsx_serialize_shape(strm, val);
|
||||
xml_serialize_shape(strm, val, ns);
|
||||
}
|
||||
else if (val.type == typeImage)
|
||||
{
|
||||
xlsx_serialize_image(strm, val);
|
||||
xml_serialize_image(strm, val, ns);
|
||||
}
|
||||
else if (val.type == typeChart)
|
||||
{
|
||||
xlsx_serialize_chart(strm, val);
|
||||
xml_serialize_chart(strm, val);
|
||||
}
|
||||
else if (val.type == typeGroupShape)
|
||||
{
|
||||
xlsx_serialize_group(strm, val);
|
||||
xml_serialize_group(strm, val, ns);
|
||||
}
|
||||
else if (val.type == typeOleObject ||
|
||||
val.type == typeMsObject ||
|
||||
val.type == typeControl)
|
||||
{
|
||||
xlsx_serialize_object(strm, val);
|
||||
xml_serialize_object(strm, val);
|
||||
}
|
||||
}
|
||||
|
||||
void _xlsx_drawing::serialize(std::wostream & strm)
|
||||
|
||||
void _xlsx_drawing::serialize(std::wostream & strm, const std::wstring & ns)
|
||||
{
|
||||
if (inGroup)
|
||||
return xlsx_serialize(strm, *this);
|
||||
return xml_serialize(strm, *this, ns);
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
if (type_anchor == 1)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:twoCellAnchor")
|
||||
CP_XML_NODE(ns + L":twoCellAnchor")
|
||||
{
|
||||
CP_XML_ATTR(L"editAs", L"oneCell");//"absolute");oneCell
|
||||
|
||||
from_.serialize (CP_XML_STREAM());
|
||||
to_.serialize (CP_XML_STREAM());
|
||||
|
||||
xlsx_serialize (CP_XML_STREAM(), *this);
|
||||
CP_XML_NODE(L"xdr:clientData");
|
||||
xml_serialize (CP_XML_STREAM(), *this, ns);
|
||||
CP_XML_NODE(ns + L":clientData");
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (type_anchor == 2)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:absoluteAnchor")
|
||||
CP_XML_NODE(ns + L":absoluteAnchor")
|
||||
{
|
||||
CP_XML_NODE(L"xdr:pos")
|
||||
CP_XML_NODE(ns + L":pos")
|
||||
{
|
||||
CP_XML_ATTR(L"x", x);
|
||||
CP_XML_ATTR(L"y", y);
|
||||
}
|
||||
CP_XML_NODE(L"xdr:ext")
|
||||
CP_XML_NODE(ns + L":ext")
|
||||
{
|
||||
CP_XML_ATTR(L"cx", cx);
|
||||
CP_XML_ATTR(L"cy", cy);
|
||||
}
|
||||
xlsx_serialize(CP_XML_STREAM(), *this);
|
||||
CP_XML_NODE(L"xdr:clientData");
|
||||
xml_serialize(CP_XML_STREAM(), *this, ns);
|
||||
CP_XML_NODE(ns + L":clientData");
|
||||
}
|
||||
}
|
||||
else if (type_anchor == 3)
|
||||
{
|
||||
CP_XML_NODE(ns + L":relSizeAnchor")
|
||||
{
|
||||
CP_XML_NODE(ns + L":from")
|
||||
{
|
||||
CP_XML_NODE(ns + L":x")
|
||||
{
|
||||
CP_XML_STREAM() << ((double)x / *owner_cx_);
|
||||
}
|
||||
CP_XML_NODE(ns + L":y")
|
||||
{
|
||||
CP_XML_STREAM() << ((double)y / *owner_cy_);
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(ns + L":to")
|
||||
{
|
||||
_INT32 x1 = x + cx;
|
||||
_INT32 y1 = y + cy;
|
||||
|
||||
CP_XML_NODE(ns + L":x")
|
||||
{
|
||||
CP_XML_STREAM() << ((double)x1 / *owner_cx_);
|
||||
}
|
||||
CP_XML_NODE(ns + L":y")
|
||||
{
|
||||
CP_XML_STREAM() << ((double)y1 / *owner_cy_);
|
||||
}
|
||||
}
|
||||
xml_serialize(CP_XML_STREAM(), *this, ns);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _xlsx_drawing::serialize_object (std::wostream & strm)
|
||||
{
|
||||
if (type != typeOleObject && type != typeMsObject) return;
|
||||
@ -358,9 +419,8 @@ void _xlsx_drawing::serialize_object (std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"moveWithCells", 1);
|
||||
|
||||
from_.serialize (CP_XML_STREAM(), L"");
|
||||
to_.serialize (CP_XML_STREAM(), L"");
|
||||
|
||||
from_.serialize (CP_XML_STREAM(), L"", L"");
|
||||
to_.serialize (CP_XML_STREAM(), L"", L"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -390,8 +450,8 @@ void _xlsx_drawing::serialize_control (std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"moveWithCells", 1);
|
||||
|
||||
from_.serialize (CP_XML_STREAM(), L"");
|
||||
to_.serialize (CP_XML_STREAM(), L"");
|
||||
from_.serialize (CP_XML_STREAM(), L"", L"xdr");
|
||||
to_.serialize (CP_XML_STREAM(), L"", L"xdr");
|
||||
|
||||
}
|
||||
}
|
||||
@ -399,6 +459,164 @@ void _xlsx_drawing::serialize_control (std::wostream & strm)
|
||||
}
|
||||
|
||||
}
|
||||
void _xlsx_drawing::serialize_vml(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"v:shape")
|
||||
{
|
||||
CP_XML_ATTR(L"id", L"_x0000_s" + std::to_wstring(id));
|
||||
CP_XML_ATTR(L"type", sub_type == 9 ? L"#_x0000_t202" : L"#_x0000_t201");
|
||||
|
||||
std::wstring color;
|
||||
|
||||
if (fill.solid)
|
||||
color = fill.solid->color;
|
||||
|
||||
if (!color.empty())
|
||||
CP_XML_ATTR(L"fillcolor", L"#" + color);
|
||||
|
||||
CP_XML_ATTR(L"stroked", /*lined ? */L"t"/* : L"f"*/);
|
||||
|
||||
std::wstring style = L"position:absolute";
|
||||
//style +="margin-left:414.3pt;margin-top:70.2pt;width:144.15pt;height:96.75pt";
|
||||
|
||||
CP_XML_ATTR(L"style", style);
|
||||
CP_XML_NODE(L"v:shadow")
|
||||
{
|
||||
CP_XML_ATTR(L"on", L"t");
|
||||
CP_XML_ATTR(L"obscured", L"t");
|
||||
CP_XML_ATTR(L"color", L"black");
|
||||
}
|
||||
CP_XML_NODE(L"w10:wrap")
|
||||
{
|
||||
CP_XML_ATTR(L"type", L"none");
|
||||
}
|
||||
vml_serialize_fill(CP_XML_STREAM(), fill);
|
||||
|
||||
vml_serialize_ln(CP_XML_STREAM(), additional);
|
||||
|
||||
CP_XML_NODE(L"x:ClientData")
|
||||
{
|
||||
switch(sub_type)
|
||||
{
|
||||
case OBJ_Button: CP_XML_ATTR(L"ObjectType", L"Button"); break;
|
||||
case OBJ_CheckBox: CP_XML_ATTR(L"ObjectType", L"Checkbox");break;
|
||||
case OBJ_RadioButton: CP_XML_ATTR(L"ObjectType", L"Radio"); break;
|
||||
case OBJ_EditBox: CP_XML_ATTR(L"ObjectType", L"Edit"); break;
|
||||
case OBJ_Label: CP_XML_ATTR(L"ObjectType", L"Label"); break;
|
||||
case OBJ_DialogBox: CP_XML_ATTR(L"ObjectType", L"Dialog"); break;
|
||||
case OBJ_SpinControl: CP_XML_ATTR(L"ObjectType", L"Spin"); break;
|
||||
case OBJ_Scrollbar: CP_XML_ATTR(L"ObjectType", L"Scroll"); break;
|
||||
case OBJ_List: CP_XML_ATTR(L"ObjectType", L"List"); break;
|
||||
case OBJ_DropdownList: CP_XML_ATTR(L"ObjectType", L"List"); break;
|
||||
case OBJ_Note: CP_XML_ATTR(L"ObjectType", L"Note"); break;
|
||||
}
|
||||
|
||||
CP_XML_NODE(L"x:MoveWithCells");
|
||||
CP_XML_NODE(L"x:SizeWithCells");
|
||||
CP_XML_NODE(L"x:Anchor")
|
||||
{
|
||||
CP_XML_STREAM() << from_.vml_serialize() << L"," << to_.vml_serialize();
|
||||
}
|
||||
CP_XML_NODE(L"x:AutoFill")
|
||||
{
|
||||
CP_XML_STREAM() << L"False";
|
||||
}
|
||||
|
||||
_CP_OPT(int) base_col, base_row;
|
||||
GetProperty(additional, L"base_col", base_col);
|
||||
GetProperty(additional, L"base_row", base_row);
|
||||
|
||||
if (base_row)
|
||||
{
|
||||
CP_XML_NODE(L"x:Row")
|
||||
{
|
||||
CP_XML_STREAM() << *base_row;
|
||||
}
|
||||
}
|
||||
if (base_col)
|
||||
{
|
||||
CP_XML_NODE(L"x:Column")
|
||||
{
|
||||
CP_XML_STREAM() << *base_col;
|
||||
}
|
||||
}
|
||||
_CP_OPT(std::wstring) sVal;
|
||||
GetProperty(additional, L"linked_cell", sVal);
|
||||
if (sVal)
|
||||
{
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
std::wstring fmla = converter.convert_named_ref(*sVal);
|
||||
CP_XML_NODE(L"x:FmlaLink")
|
||||
{
|
||||
CP_XML_STREAM() << fmla;
|
||||
}
|
||||
}
|
||||
_CP_OPT(bool) visible;
|
||||
GetProperty(additional, L"visible", visible);
|
||||
if ((visible) && (*visible == false))
|
||||
{
|
||||
CP_XML_NODE(L"x:Visible")
|
||||
{
|
||||
CP_XML_STREAM() << L"False";
|
||||
}
|
||||
}
|
||||
else
|
||||
CP_XML_NODE(L"x:Visible");
|
||||
|
||||
_CP_OPT(int) nVal;
|
||||
GetProperty(additional, L"min_value", nVal);
|
||||
if (nVal)
|
||||
{
|
||||
CP_XML_NODE(L"x:Min")
|
||||
{
|
||||
CP_XML_STREAM() << *nVal;
|
||||
}
|
||||
}
|
||||
GetProperty(additional, L"max_value", nVal);
|
||||
if (nVal)
|
||||
{
|
||||
CP_XML_NODE(L"x:Max")
|
||||
{
|
||||
CP_XML_STREAM() << *nVal;
|
||||
}
|
||||
}
|
||||
GetProperty(additional, L"step", nVal);
|
||||
if (nVal)
|
||||
{
|
||||
CP_XML_NODE(L"x:Inc")
|
||||
{
|
||||
CP_XML_STREAM() << *nVal;
|
||||
}
|
||||
}
|
||||
GetProperty(additional, L"page_step", nVal);
|
||||
if (nVal)
|
||||
{
|
||||
CP_XML_NODE(L"x:Page")
|
||||
{
|
||||
CP_XML_STREAM() << *nVal;
|
||||
}
|
||||
}
|
||||
GetProperty(additional, L"value", sVal);
|
||||
if (sVal)
|
||||
{
|
||||
CP_XML_NODE(L"x:Val")
|
||||
{
|
||||
CP_XML_STREAM() << *sVal;
|
||||
}
|
||||
}
|
||||
|
||||
GetProperty(additional, L"orientation", sVal);
|
||||
if (sVal)
|
||||
{
|
||||
if (*sVal == L"horizontal") CP_XML_NODE(L"x:Horiz");
|
||||
else CP_XML_NODE(L"x:Vert");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,10 +49,10 @@ struct xlsx_drawing_position
|
||||
enum type_t {from, to} type;
|
||||
xlsx_table_position position;
|
||||
|
||||
void serialize(std::wostream & _Wostream, std::wstring ns = L"xdr:");
|
||||
void serialize(std::wostream & _Wostream, const std::wstring & ns_title = L"xdr", const std::wstring & ns = L"xdr");
|
||||
std::wstring vml_serialize();
|
||||
};
|
||||
|
||||
|
||||
class _xlsx_drawing : public _oox_drawing
|
||||
{
|
||||
public:
|
||||
@ -63,9 +63,15 @@ public:
|
||||
xlsx_drawing_position from_;
|
||||
xlsx_drawing_position to_;
|
||||
|
||||
_CP_OPT(_INT32) owner_cx_;
|
||||
_CP_OPT(_INT32) owner_cy_;
|
||||
|
||||
std::wstring content_group_;
|
||||
|
||||
void serialize (std::wostream & strm);
|
||||
virtual void serialize (std::wostream & strm) {return serialize(strm, L"xdr");}
|
||||
|
||||
void serialize (std::wostream & strm, const std::wstring & ns);
|
||||
void serialize_vml (std::wostream & strm);
|
||||
void serialize_object (std::wostream & strm);
|
||||
void serialize_control (std::wostream & strm);
|
||||
};
|
||||
|
||||
@ -53,41 +53,54 @@ namespace oox {
|
||||
class xlsx_drawing_context_handle::Impl
|
||||
{
|
||||
public:
|
||||
Impl(mediaitems & items) : items_(items), next_rId_(1), next_drawing_id_(1)
|
||||
Impl(mediaitems_ptr & items) : items_(items), next_drawing_id_(1), next_vml_drawing_id_(1)
|
||||
{
|
||||
}
|
||||
|
||||
mediaitems & get_mediaitems() { return items_; }
|
||||
mediaitems_ptr & get_mediaitems() { return items_; }
|
||||
|
||||
size_t next_rId()
|
||||
std::pair<std::wstring, std::wstring> add_drawing_vml(std::wstring const & content, xlsx_drawings_ptr drawings)
|
||||
{
|
||||
return next_rId_++;
|
||||
const std::wstring id = std::to_wstring(next_vml_drawing_id_++);
|
||||
const std::wstring fileName = std::wstring(L"vmlDrawing") + id + L".vml";
|
||||
|
||||
drawings_vml_.push_back(drawing_elm(fileName, content, drawings, typeDefault));
|
||||
const std::wstring rId = std::wstring(L"rVId") + id;
|
||||
|
||||
return std::pair<std::wstring, std::wstring>(fileName, rId);
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings)
|
||||
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings, RelsType const & type_)
|
||||
{
|
||||
const std::wstring id = std::to_wstring(next_drawing_id_++);
|
||||
const std::wstring fileName = std::wstring(L"drawing") + id + L".xml";
|
||||
drawings_.push_back(drawing_elm(fileName, content, drawings));
|
||||
const std::wstring rId = std::wstring(L"rId") + id;//rDrId
|
||||
return std::pair<std::wstring, std::wstring>(fileName, rId);
|
||||
}
|
||||
|
||||
const std::vector<drawing_elm> & content() const
|
||||
{
|
||||
return drawings_;
|
||||
|
||||
drawings_.push_back(drawing_elm(fileName, content, drawings, type_));
|
||||
const std::wstring rId = std::wstring(L"rDrId") + id;
|
||||
|
||||
return std::pair<std::wstring, std::wstring>(fileName, rId);
|
||||
}
|
||||
|
||||
const std::vector<drawing_elm> & content() const
|
||||
{
|
||||
return drawings_;
|
||||
}
|
||||
const std::vector<drawing_elm> & content_vml() const
|
||||
{
|
||||
return drawings_vml_;
|
||||
}
|
||||
private:
|
||||
mediaitems & items_;
|
||||
std::vector<drawing_elm> drawings_;
|
||||
mediaitems_ptr items_;
|
||||
|
||||
std::vector<drawing_elm> drawings_;
|
||||
std::vector<drawing_elm> drawings_vml_;
|
||||
|
||||
size_t next_rId_;
|
||||
size_t next_drawing_id_;
|
||||
size_t next_vml_drawing_id_;
|
||||
};
|
||||
|
||||
xlsx_drawing_context_handle::xlsx_drawing_context_handle(mediaitems & items)
|
||||
: impl_(new xlsx_drawing_context_handle::Impl(items))
|
||||
xlsx_drawing_context_handle::xlsx_drawing_context_handle(mediaitems_ptr & items) :
|
||||
next_rId_(1), impl_(new xlsx_drawing_context_handle::Impl(items))
|
||||
{
|
||||
}
|
||||
|
||||
@ -95,26 +108,33 @@ xlsx_drawing_context_handle::~xlsx_drawing_context_handle()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<std::wstring, std::wstring> xlsx_drawing_context_handle::add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings)
|
||||
std::pair<std::wstring, std::wstring> xlsx_drawing_context_handle::add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings, RelsType const & type_)
|
||||
{
|
||||
return impl_->add_drawing_xml(content, drawings);
|
||||
return impl_->add_drawing_xml(content, drawings, type_);
|
||||
}
|
||||
std::pair<std::wstring, std::wstring> xlsx_drawing_context_handle::add_drawing_vml(std::wstring const & content, xlsx_drawings_ptr drawings)
|
||||
{
|
||||
return impl_->add_drawing_vml(content, drawings);
|
||||
}
|
||||
|
||||
const std::vector<drawing_elm> & xlsx_drawing_context_handle::content() const
|
||||
{
|
||||
return impl_->content();
|
||||
}
|
||||
|
||||
const std::vector<drawing_elm> & xlsx_drawing_context_handle::content_vml() const
|
||||
{
|
||||
return impl_->content_vml();
|
||||
}
|
||||
class xlsx_drawing_context::Impl
|
||||
{
|
||||
public:
|
||||
Impl(xlsx_drawing_context_handle & handle) : xlsx_drawings_(xlsx_drawings::create(false)), handle_(handle)
|
||||
Impl(xlsx_drawing_context_handle_ptr & handle) : xlsx_drawings_(xlsx_drawings::create(false)), handle_(handle)
|
||||
{
|
||||
current_level_ = &objects_;
|
||||
use_image_replacement_ = false;
|
||||
}
|
||||
|
||||
xlsx_drawing_context_handle& handle_;
|
||||
xlsx_drawing_context_handle_ptr handle_;
|
||||
drawing_object_description object_description_;
|
||||
|
||||
std::vector<drawing_object_description> objects_;
|
||||
@ -124,21 +144,27 @@ public:
|
||||
bool use_image_replacement_;
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); }
|
||||
mediaitems_ptr & get_mediaitems() { return handle_->impl_->get_mediaitems(); }
|
||||
|
||||
void serialize(std::wostream & strm)
|
||||
void serialize(std::wostream & strm, const std::wstring & ns = L"xdr")
|
||||
{
|
||||
xlsx_drawings_->serialize(strm);
|
||||
xlsx_drawings_->serialize(strm, ns);
|
||||
}
|
||||
void serialize_vml(std::wostream & strm)
|
||||
{
|
||||
xlsx_drawings_->serialize_vml(strm);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return xlsx_drawings_->empty();
|
||||
}
|
||||
|
||||
bool vml_empty() const
|
||||
{
|
||||
return xlsx_drawings_->vml_empty();
|
||||
}
|
||||
size_t next_rId()
|
||||
{
|
||||
return handle_.impl_->next_rId();
|
||||
return handle_->next_rId();
|
||||
}
|
||||
|
||||
xlsx_drawings_ptr get_drawings()
|
||||
@ -150,7 +176,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle & h)
|
||||
xlsx_drawing_context::xlsx_drawing_context(xlsx_drawing_context_handle_ptr & h)
|
||||
: impl_(new xlsx_drawing_context::Impl(h))
|
||||
{
|
||||
hlinks_size_ = 0;
|
||||
@ -281,7 +307,29 @@ void xlsx_drawing_context::end_shape()
|
||||
{
|
||||
impl_->current_level_->push_back(impl_->object_description_);
|
||||
}
|
||||
void xlsx_drawing_context::start_comment(int base_col, int base_row)
|
||||
{
|
||||
impl_->object_description_.type_ = typeComment;
|
||||
impl_->object_description_.shape_type_ = 19; // OBJ_Note object type for vml
|
||||
|
||||
set_property(odf_reader::_property(L"base_col", base_col));
|
||||
set_property(odf_reader::_property(L"base_row", base_row));
|
||||
}
|
||||
void xlsx_drawing_context::end_comment()
|
||||
{
|
||||
impl_->current_level_->push_back(impl_->object_description_);
|
||||
}
|
||||
void xlsx_drawing_context::start_control(const std::wstring & ctrlPropId, int type)
|
||||
{
|
||||
impl_->object_description_.type_ = typeControl;
|
||||
impl_->object_description_.shape_type_ = type; // object type for vml
|
||||
|
||||
impl_->object_description_.xlink_href_ = ctrlPropId;
|
||||
}
|
||||
void xlsx_drawing_context::end_control()
|
||||
{
|
||||
impl_->current_level_->push_back(impl_->object_description_);
|
||||
}
|
||||
void xlsx_drawing_context::set_use_image_replacement()
|
||||
{
|
||||
impl_->use_image_replacement_ = true;
|
||||
@ -304,11 +352,6 @@ void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::w
|
||||
impl_->object_description_.xlink_href_ = path;
|
||||
impl_->object_description_.descriptor_ = progId;
|
||||
}
|
||||
void xlsx_drawing_context::set_control(const std::wstring & ctrlPropId)
|
||||
{
|
||||
impl_->object_description_.type_ = typeControl;
|
||||
impl_->object_description_.xlink_href_ = ctrlPropId;
|
||||
}
|
||||
void xlsx_drawing_context::set_image(const std::wstring & path)
|
||||
{
|
||||
int pos_replaicement = path.find(L"ObjectReplacements");
|
||||
@ -386,6 +429,12 @@ void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt)
|
||||
|
||||
}
|
||||
}
|
||||
void xlsx_drawing_context::set_rel_anchor(_INT32 owner_cx, _INT32 owner_cy)
|
||||
{
|
||||
impl_->object_description_.owner_cx_ = owner_cx;
|
||||
impl_->object_description_.owner_cy_ = owner_cy;
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::set_anchor(std::wstring anchor, double x_pt, double y_pt, bool group)
|
||||
{
|
||||
if (group)
|
||||
@ -439,14 +488,25 @@ bool xlsx_drawing_context::empty() const
|
||||
{
|
||||
return impl_->empty();
|
||||
}
|
||||
|
||||
bool xlsx_drawing_context::vml_empty() const
|
||||
{
|
||||
return impl_->vml_empty();
|
||||
}
|
||||
void xlsx_drawing_context::process_common_properties(drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics)
|
||||
{
|
||||
if (obj.anchor_.empty())
|
||||
{
|
||||
drawing.type_anchor = 2; // absolute
|
||||
if (obj.owner_cx_ && obj.owner_cy_)
|
||||
{
|
||||
drawing.type_anchor = 3; // relative
|
||||
drawing.owner_cx_ = obj.owner_cx_;
|
||||
drawing.owner_cy_ = obj.owner_cy_;
|
||||
}
|
||||
else
|
||||
drawing.type_anchor = 2; // absolute
|
||||
}
|
||||
else
|
||||
|
||||
if (drawing.type_anchor == 1)
|
||||
{
|
||||
xlsx_table_position from, to;
|
||||
|
||||
@ -470,17 +530,19 @@ void xlsx_drawing_context::process_common_properties(drawing_object_description
|
||||
_rect & r = obj.svg_rect_.get();
|
||||
|
||||
//todooo непонятно что делать с отрицательными значениями
|
||||
int val = 0.5 + odf_types::length(obj.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu);
|
||||
if (val >=0) drawing.x = val;
|
||||
_INT32 val = 0;
|
||||
|
||||
val = (_INT32) (0.5 + odf_types::length(obj.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if (val >= 0) drawing.x = val;
|
||||
|
||||
val = 0.5 + odf_types::length(obj.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu);
|
||||
if (val >=0) drawing.y = val;
|
||||
val = (_INT32) (0.5 + odf_types::length(obj.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if (val >= 0) drawing.y = val;
|
||||
|
||||
val = 0.5 + odf_types::length(obj.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu);
|
||||
if (val >=0) drawing.cx = val;
|
||||
val = (_INT32) (0.5 + odf_types::length(obj.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if (val >= 0) drawing.cx = val;
|
||||
|
||||
val = .5 + odf_types::length(obj.svg_rect_->cy, odf_types::length::pt).get_value_unit(odf_types::length::emu);
|
||||
if (val >=0) drawing.cy = val;
|
||||
val = (_INT32) (0.5 + odf_types::length(obj.svg_rect_->cy, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if (val >= 0) drawing.cy = val;
|
||||
}
|
||||
|
||||
drawing.additional = obj.additional_;
|
||||
@ -555,7 +617,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
|
||||
}
|
||||
std::wstring fileName = odf_packet_path_ + FILE_SEPARATOR_STR + obj.xlink_href_;
|
||||
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, impl_->get_mediaitems().applicationFonts());
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, impl_->get_mediaitems()->applicationFonts());
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
|
||||
if ((sColorMode) && (*sColorMode == L"greyscale"))
|
||||
@ -564,14 +626,14 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
bool isMediaInternal = false;
|
||||
|
||||
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
|
||||
drawing.fill.bitmap->rId = impl_->get_mediaitems()->add_or_find(obj.xlink_href_, typeImage, isMediaInternal, ref);
|
||||
|
||||
if (drawing.type == typeShape)
|
||||
{
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, false, false);//собственно это не объект, а доп рел и ref объекта
|
||||
|
||||
isMediaInternal=true;
|
||||
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
std::wstring rId = impl_->get_mediaitems()->add_or_find(L"", typeShape, isMediaInternal, ref);
|
||||
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, rId, ref, typeShape);//объект
|
||||
|
||||
@ -580,7 +642,7 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, typeImage);//объект
|
||||
|
||||
if (drawing.inGroup)
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, obj.type_); // не объект
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, obj.type_, false, false); // не объект
|
||||
}
|
||||
}
|
||||
|
||||
@ -589,12 +651,13 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectId = impl_->get_mediaitems()->add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
|
||||
|
||||
if (drawing.inGroup)
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_, false, false); // не объект
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx_table_metrics & table_metrics, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
|
||||
{
|
||||
std::wstring ref;
|
||||
@ -620,28 +683,29 @@ void xlsx_drawing_context::process_object(drawing_object_description & obj, xlsx
|
||||
drawing.to_.position.rowOff = static_cast<size_t>(odf_types::length(to.rowOff, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
}
|
||||
|
||||
if (obj.type_ == typeControl)
|
||||
if (obj.type_ == typeControl || obj.type_ == typeComment)
|
||||
{
|
||||
drawing.objectId = obj.xlink_href_;
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
|
||||
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectId = impl_->get_mediaitems()->add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectProgId = obj.descriptor_;
|
||||
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
|
||||
}
|
||||
|
||||
if (drawing.inGroup)
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_, false, false); // не объект
|
||||
}
|
||||
void xlsx_drawing_context::process_shape(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
std::wstring rId = impl_->get_mediaitems()->add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, rId, ref, obj.type_);
|
||||
}
|
||||
|
||||
@ -653,7 +717,7 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
|
||||
|
||||
std::wstringstream strm;
|
||||
|
||||
xlsx_drawings_child->serialize(strm);
|
||||
xlsx_drawings_child->serialize(strm, L"xdr");
|
||||
|
||||
drawing.content_group_ = strm.str();
|
||||
|
||||
@ -661,7 +725,7 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
std::wstring rId = impl_->get_mediaitems()->add_or_find(L"", obj.type_, isMediaInternal, ref);
|
||||
xlsx_drawings_->add(drawing, isMediaInternal, rId, ref, obj.type_);
|
||||
|
||||
}
|
||||
@ -685,17 +749,17 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
|
||||
drawing.lined = obj.lined_;
|
||||
drawing.connector = obj.connector_;
|
||||
|
||||
drawing.sub_type = obj.shape_type_;
|
||||
drawing.sub_type = obj.shape_type_;
|
||||
|
||||
if (drawing.fill.bitmap)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
|
||||
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
drawing.fill.bitmap->rId = impl_->get_mediaitems()->add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
|
||||
bool in_sheet = (obj.type_== typeOleObject || obj.type_== typeMsObject) ? true : false;
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, in_sheet);//собственно это не объект, а доп рел и ref объекта
|
||||
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, in_sheet, false);//собственно это не объект, а доп рел и ref объекта
|
||||
|
||||
//object dumps in sheet rels !!
|
||||
}
|
||||
@ -710,15 +774,19 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
|
||||
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
|
||||
case typeMsObject:
|
||||
case typeOleObject:
|
||||
case typeControl:
|
||||
process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
|
||||
case typeControl:
|
||||
case typeComment: process_object ( obj, table_metrics, drawing, xlsx_drawings_); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::serialize(std::wostream & strm)
|
||||
void xlsx_drawing_context::serialize(std::wostream & strm, const std::wstring& ns)
|
||||
{
|
||||
impl_->serialize(strm);
|
||||
impl_->serialize(strm, ns);
|
||||
}
|
||||
void xlsx_drawing_context::serialize_vml(std::wostream & strm)
|
||||
{
|
||||
impl_->serialize_vml(strm);
|
||||
}
|
||||
|
||||
xlsx_drawings_ptr xlsx_drawing_context::get_drawings()
|
||||
@ -756,6 +824,5 @@ void xlsx_drawing_context::set_is_connector_shape(bool val)
|
||||
impl_->object_description_.connector_ = val;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,29 +53,42 @@ namespace oox {
|
||||
class xlsx_drawings;
|
||||
struct _oox_fill;
|
||||
|
||||
typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
|
||||
typedef _CP_PTR(mediaitems) mediaitems_ptr;
|
||||
typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
|
||||
|
||||
class xlsx_drawing_context_handle
|
||||
{
|
||||
public:
|
||||
xlsx_drawing_context_handle(mediaitems & items);
|
||||
xlsx_drawing_context_handle(mediaitems_ptr & items);
|
||||
~xlsx_drawing_context_handle();
|
||||
|
||||
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings);
|
||||
const std::vector<drawing_elm> & content() const;
|
||||
std::pair<std::wstring, std::wstring> add_drawing_xml(std::wstring const & content, xlsx_drawings_ptr drawings, RelsType const & type_ = typeDefault);
|
||||
std::pair<std::wstring, std::wstring> add_drawing_vml(std::wstring const & content, xlsx_drawings_ptr drawings);
|
||||
|
||||
const std::vector<drawing_elm> & content() const;
|
||||
const std::vector<drawing_elm> & content_vml() const;
|
||||
|
||||
friend class xlsx_drawing_context;
|
||||
|
||||
size_t next_rId()
|
||||
{
|
||||
return next_rId_++;
|
||||
}
|
||||
private:
|
||||
size_t next_rId_;
|
||||
|
||||
class Impl;
|
||||
_CP_PTR(Impl) impl_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef _CP_PTR(xlsx_drawing_context_handle) xlsx_drawing_context_handle_ptr;
|
||||
|
||||
class xlsx_drawing_context
|
||||
{
|
||||
public:
|
||||
xlsx_drawing_context(xlsx_drawing_context_handle & h);
|
||||
xlsx_drawing_context(xlsx_drawing_context_handle_ptr & h);
|
||||
~xlsx_drawing_context();
|
||||
|
||||
void set_odf_packet_path(std::wstring path){odf_packet_path_ = path;}//для анализа картинок
|
||||
@ -87,7 +100,6 @@ public:
|
||||
void end_group ();
|
||||
|
||||
void start_shape(int type);
|
||||
//...пока тока общие свойства ... частные для каждого объекта пооозже
|
||||
void end_shape();
|
||||
|
||||
void start_frame();
|
||||
@ -95,24 +107,30 @@ public:
|
||||
void set_chart (const std::wstring & path);
|
||||
void set_ole_object (const std::wstring & path, const std::wstring & progId);
|
||||
void set_ms_object (const std::wstring & path, const std::wstring & progId);
|
||||
void set_control (const std::wstring & ctrlPropId);
|
||||
void set_text_box ();
|
||||
void end_frame();
|
||||
|
||||
void start_control(const std::wstring & ctrlPropId, int type);
|
||||
void end_control();
|
||||
|
||||
void start_comment(int base_col, int base_row);
|
||||
void end_comment();
|
||||
|
||||
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
|
||||
|
||||
void set_translate (double x_pt, double y_pt);
|
||||
void set_scale (double cx_pt, double cy_pt);
|
||||
void set_rotate (double angle, bool translate = false);
|
||||
|
||||
void set_rel_anchor (_INT32 owner_cx, _INT32 owner_cy);
|
||||
void set_anchor (std::wstring anchor, double x_pt, double y_pt, bool group = false);
|
||||
void set_property (odf_reader::_property p);
|
||||
void set_clipping (const std::wstring & str );
|
||||
void set_fill (_oox_fill & fill);
|
||||
|
||||
void set_is_line_shape(bool val);
|
||||
void set_is_connector_shape(bool val);
|
||||
|
||||
void set_property (odf_reader::_property p);
|
||||
std::vector<odf_reader::_property> & get_properties();
|
||||
|
||||
std::wstring add_hyperlink(std::wstring const & ref);
|
||||
@ -120,9 +138,13 @@ public:
|
||||
void set_use_image_replacement();
|
||||
|
||||
bool empty() const;
|
||||
bool vml_empty() const;
|
||||
|
||||
void clear();
|
||||
|
||||
void serialize(std::wostream & strm);
|
||||
void serialize(std::wostream & strm, const std::wstring& ns = L"xdr");
|
||||
void serialize_vml(std::wostream & strm);
|
||||
|
||||
std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h);
|
||||
|
||||
xlsx_drawings_ptr get_drawings();
|
||||
|
||||
@ -46,18 +46,25 @@ class xlsx_drawings::Impl
|
||||
public:
|
||||
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel )//объект
|
||||
{
|
||||
xlsx_drawings_.push_back(d);
|
||||
|
||||
add (isInternal, rid, ref, type, sheet_rel);
|
||||
|
||||
for (size_t i = 0; i < d.hlinks.size(); i++)
|
||||
{
|
||||
xlsx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
|
||||
if (type == typeControl || type == typeControlProps || type == typeComment)
|
||||
{
|
||||
vml_drawings_.push_back(d);
|
||||
add (isInternal, rid, ref, type, sheet_rel, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawings_.push_back(d);
|
||||
add (isInternal, rid, ref, type, sheet_rel, false);
|
||||
|
||||
for (size_t i = 0; i < d.hlinks.size(); i++)
|
||||
{
|
||||
drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
|
||||
}
|
||||
if (!d.action.hId.empty())
|
||||
drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels));
|
||||
}
|
||||
if (!d.action.hId.empty())
|
||||
xlsx_drawing_rels_.push_back(_rel(false, d.action.hId, d.action.hRef, d.action.typeRels));
|
||||
}
|
||||
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel) //не объект
|
||||
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel, bool vml_rel) //не объект
|
||||
{
|
||||
bool present = false;
|
||||
|
||||
@ -73,40 +80,124 @@ public:
|
||||
if (!present)
|
||||
xlsx_sheet_rels_.push_back (_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
else
|
||||
else if (vml_rel)
|
||||
{
|
||||
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
for (size_t i = 0 ; i < vml_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
|
||||
if (vml_drawing_rels_[i].rid == rid && vml_drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
vml_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0 ; i < drawing_rels_.size(); i++)
|
||||
{
|
||||
if (drawing_rels_[i].rid == rid && drawing_rels_[i].ref == ref)
|
||||
present = true;
|
||||
}
|
||||
if (!present)
|
||||
drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
|
||||
}
|
||||
}
|
||||
|
||||
void serialize(std::wostream & strm)
|
||||
void serialize(std::wostream & strm, const std::wstring & ns)
|
||||
{
|
||||
if (drawings_.empty()) return;
|
||||
|
||||
if (inGroup)
|
||||
{
|
||||
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
for (size_t i = 0 ; i < drawings_.size(); i++)
|
||||
{
|
||||
xlsx_drawings_[i].serialize(strm);
|
||||
drawings_[i].serialize(strm, ns);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xdr:wsDr")
|
||||
CP_XML_NODE(ns + L":wsDr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
|
||||
if (ns == L"xdr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
|
||||
}
|
||||
if (ns == L"cdr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:cdr", L"http://schemas.openxmlformats.org/drawingml/2006/chartDrawing");
|
||||
}
|
||||
CP_XML_ATTR(L"xmlns:a" , L"http://schemas.openxmlformats.org/drawingml/2006/main");
|
||||
CP_XML_ATTR(L"xmlns:r" , L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
|
||||
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
for (size_t i = 0 ; i < drawings_.size(); i++)
|
||||
{
|
||||
xlsx_drawings_[i].serialize(CP_XML_STREAM());
|
||||
drawings_[i].serialize(CP_XML_STREAM(), ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void serialize_vml(std::wostream & strm)
|
||||
{
|
||||
if (vml_drawings_.empty()) return;
|
||||
|
||||
if (inGroup)
|
||||
{
|
||||
for (size_t i = 0 ; i < vml_drawings_.size(); i++)
|
||||
{
|
||||
vml_drawings_[i].serialize_vml(strm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"xml")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:v", L"urn:schemas-microsoft-com:vml");
|
||||
CP_XML_ATTR(L"xmlns:o", L"urn:schemas-microsoft-com:office:office");
|
||||
CP_XML_ATTR(L"xmlns:x", L"urn:schemas-microsoft-com:office:excel");
|
||||
|
||||
CP_XML_NODE(L"v:shapetype")
|
||||
{
|
||||
CP_XML_ATTR(L"id", L"_x0000_t201");
|
||||
CP_XML_ATTR(L"o:spt", L"201"); // sptHostControl = 201
|
||||
|
||||
CP_XML_ATTR(L"coordsize", L"21600,21600");
|
||||
CP_XML_ATTR(L"path", L"m,l,21600r21600,l21600,xe");
|
||||
|
||||
CP_XML_NODE(L"v:stroke")
|
||||
{
|
||||
CP_XML_ATTR(L"joinstyle", L"miter");
|
||||
}
|
||||
CP_XML_NODE(L"v:path")
|
||||
{
|
||||
CP_XML_ATTR(L"gradientshapeok", L"t");
|
||||
CP_XML_ATTR(L"o:connecttype", L"rect");
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"v:shapetype")
|
||||
{
|
||||
CP_XML_ATTR(L"id", L"_x0000_t202");
|
||||
CP_XML_ATTR(L"o:spt", L"202"); // sptTextBox = 202
|
||||
|
||||
CP_XML_ATTR(L"coordsize", L"21600,21600");
|
||||
CP_XML_ATTR(L"path", L"m,l,21600l21600,21600l21600,xe");
|
||||
|
||||
CP_XML_NODE(L"v:stroke")
|
||||
{
|
||||
CP_XML_ATTR(L"joinstyle", L"miter");
|
||||
}
|
||||
CP_XML_NODE(L"v:path")
|
||||
{
|
||||
CP_XML_ATTR(L"gradientshapeok", L"t");
|
||||
CP_XML_ATTR(L"o:connecttype", L"rect");
|
||||
}
|
||||
}
|
||||
for (size_t i = 0 ; i < vml_drawings_.size(); i++)
|
||||
{
|
||||
vml_drawings_[i].serialize_vml(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,41 +205,62 @@ public:
|
||||
}
|
||||
void serialize_objects(std::wostream & strm)
|
||||
{
|
||||
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
for (size_t i = 0 ; i < drawings_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawings_[i].type != typeOleObject && xlsx_drawings_[i].type != typeMsObject) continue;
|
||||
if (drawings_[i].type != typeOleObject && drawings_[i].type != typeMsObject) continue;
|
||||
|
||||
xlsx_drawings_[i].serialize_object(strm);
|
||||
drawings_[i].serialize_object(strm);
|
||||
}
|
||||
}
|
||||
void serialize_controls(std::wostream & strm)
|
||||
{
|
||||
for (size_t i = 0 ; i < xlsx_drawings_.size(); i++)
|
||||
for (size_t i = 0 ; i < vml_drawings_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawings_[i].type != typeControl) continue;
|
||||
if (vml_drawings_[i].type != typeControl) continue;
|
||||
|
||||
xlsx_drawings_[i].serialize_control(strm);
|
||||
vml_drawings_[i].serialize_control(strm);
|
||||
}
|
||||
}
|
||||
bool empty() const
|
||||
{
|
||||
return (xlsx_drawings_.empty());
|
||||
return (drawings_.empty());
|
||||
}
|
||||
bool vml_empty() const
|
||||
{
|
||||
return (vml_drawings_.empty());
|
||||
}
|
||||
|
||||
void dump_rels_drawing(rels & Rels)
|
||||
{
|
||||
for (size_t i = 0 ; i < xlsx_drawing_rels_.size(); i++)
|
||||
for (size_t i = 0 ; i < drawing_rels_.size(); i++)
|
||||
{
|
||||
if (xlsx_drawing_rels_[i].type == typeImage ||
|
||||
xlsx_drawing_rels_[i].type == typeMedia ||
|
||||
xlsx_drawing_rels_[i].type == typeChart ||
|
||||
xlsx_drawing_rels_[i].type == typeHyperlink )
|
||||
if (drawing_rels_[i].type == typeImage ||
|
||||
drawing_rels_[i].type == typeMedia ||
|
||||
drawing_rels_[i].type == typeChart ||
|
||||
drawing_rels_[i].type == typeHyperlink )
|
||||
{
|
||||
|
||||
Rels.add(relationship( xlsx_drawing_rels_[i].rid,
|
||||
mediaitems::get_rel_type(xlsx_drawing_rels_[i].type),
|
||||
(xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref),
|
||||
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")) );
|
||||
Rels.add(relationship( drawing_rels_[i].rid,
|
||||
mediaitems::get_rel_type(drawing_rels_[i].type),
|
||||
(drawing_rels_[i].is_internal ? std::wstring(L"../") + drawing_rels_[i].ref : drawing_rels_[i].ref),
|
||||
(drawing_rels_[i].is_internal ? L"" : L"External")) );
|
||||
}
|
||||
}
|
||||
}
|
||||
void dump_rels_vml_drawing(rels & Rels)
|
||||
{
|
||||
for (size_t i = 0 ; i < vml_drawing_rels_.size(); i++)
|
||||
{
|
||||
if (vml_drawing_rels_[i].type == typeImage ||
|
||||
vml_drawing_rels_[i].type == typeMedia ||
|
||||
vml_drawing_rels_[i].type == typeChart ||
|
||||
vml_drawing_rels_[i].type == typeHyperlink )
|
||||
{
|
||||
|
||||
Rels.add(relationship( vml_drawing_rels_[i].rid,
|
||||
mediaitems::get_rel_type(vml_drawing_rels_[i].type),
|
||||
(vml_drawing_rels_[i].is_internal ? std::wstring(L"../") + vml_drawing_rels_[i].ref : vml_drawing_rels_[i].ref),
|
||||
(vml_drawing_rels_[i].is_internal ? L"" : L"External")) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,9 +278,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
std::vector<_xlsx_drawing> xlsx_drawings_;
|
||||
std::vector<_xlsx_drawing> drawings_;
|
||||
std::vector<_xlsx_drawing> vml_drawings_;
|
||||
|
||||
std::vector<_rel> xlsx_drawing_rels_;
|
||||
std::vector<_rel> drawing_rels_;
|
||||
std::vector<_rel> vml_drawing_rels_;
|
||||
std::vector<_rel> xlsx_sheet_rels_;
|
||||
};
|
||||
|
||||
@ -187,14 +301,18 @@ void xlsx_drawings::add(_xlsx_drawing const & d, bool isInternal, std::wstring c
|
||||
impl_->add(d, isInternal, rid, ref, type, sheet_rel);
|
||||
}
|
||||
|
||||
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel)
|
||||
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel, bool vml_rel)
|
||||
{
|
||||
impl_->add(isInternal, rid, ref, type, sheet_rel);
|
||||
impl_->add(isInternal, rid, ref, type, sheet_rel, vml_rel);
|
||||
}
|
||||
|
||||
void xlsx_drawings::serialize(std::wostream & strm)
|
||||
void xlsx_drawings::serialize(std::wostream & strm, const std::wstring & ns)
|
||||
{
|
||||
impl_->serialize(strm);
|
||||
impl_->serialize(strm, ns);
|
||||
}
|
||||
void xlsx_drawings::serialize_vml(std::wostream & strm)
|
||||
{
|
||||
impl_->serialize_vml(strm);
|
||||
}
|
||||
|
||||
void xlsx_drawings::serialize_objects(std::wostream & strm)
|
||||
@ -210,12 +328,18 @@ bool xlsx_drawings::empty() const
|
||||
{
|
||||
return impl_->empty();
|
||||
}
|
||||
|
||||
bool xlsx_drawings::vml_empty() const
|
||||
{
|
||||
return impl_->vml_empty();
|
||||
}
|
||||
void xlsx_drawings::dump_rels_drawing(rels & Rels)
|
||||
{
|
||||
return impl_->dump_rels_drawing(Rels);
|
||||
}
|
||||
|
||||
void xlsx_drawings::dump_rels_vml_drawing(rels & Rels)
|
||||
{
|
||||
return impl_->dump_rels_vml_drawing(Rels);
|
||||
}
|
||||
void xlsx_drawings::dump_rels_sheet(rels & Rels)
|
||||
{
|
||||
return impl_->dump_rels_sheet(Rels);
|
||||
|
||||
@ -46,13 +46,14 @@ typedef _CP_PTR(xlsx_drawings) xlsx_drawings_ptr;
|
||||
|
||||
struct drawing_elm
|
||||
{
|
||||
drawing_elm(std::wstring const & _filename, std::wstring const & _content, xlsx_drawings_ptr _drawings)
|
||||
: filename(_filename), content(_content), drawings(_drawings)
|
||||
drawing_elm(std::wstring const & _filename, std::wstring const & _content, xlsx_drawings_ptr _drawings, RelsType const & _type)
|
||||
: filename(_filename), content(_content), drawings(_drawings), type(_type)
|
||||
{}
|
||||
|
||||
std::wstring filename;
|
||||
std::wstring content;
|
||||
xlsx_drawings_ptr drawings;
|
||||
RelsType type;
|
||||
};
|
||||
|
||||
class _xlsx_drawing;
|
||||
@ -65,13 +66,17 @@ public:
|
||||
static xlsx_drawings_ptr create(bool inGroup);
|
||||
|
||||
void add ( _xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
|
||||
void add ( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
|
||||
void add ( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel, bool vml_rel);
|
||||
|
||||
bool empty () const;
|
||||
void dump_rels_sheet (rels & Rels);
|
||||
void dump_rels_drawing (rels & Rels);
|
||||
bool empty() const;
|
||||
bool vml_empty() const;
|
||||
|
||||
void dump_rels_sheet (rels & Rels);
|
||||
void dump_rels_drawing (rels & Rels);
|
||||
void dump_rels_vml_drawing (rels & Rels);
|
||||
|
||||
void serialize (std::wostream & _Wostream);
|
||||
void serialize (std::wostream & _Wostream, const std::wstring & ns);
|
||||
void serialize_vml (std::wostream & _Wostream);
|
||||
void serialize_objects (std::wostream & _Wostream);
|
||||
void serialize_controls (std::wostream & _Wostream);
|
||||
private:
|
||||
|
||||
@ -49,7 +49,6 @@ public:
|
||||
std::wstringstream sheetFormat_;
|
||||
std::wstringstream sheetData_;
|
||||
std::wstringstream mergeCells_;
|
||||
std::wstringstream drawing_;
|
||||
std::wstringstream hyperlinks_;
|
||||
std::wstringstream comments_;
|
||||
std::wstringstream sort_;
|
||||
@ -130,10 +129,6 @@ std::wostream & xlsx_xml_worksheet::autofilter()
|
||||
{
|
||||
return impl_->autofilter_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::drawing()
|
||||
{
|
||||
return impl_->drawing_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::comments()
|
||||
{
|
||||
return impl_->comments_;
|
||||
@ -217,35 +212,40 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
CP_XML_STREAM() << impl_->hyperlinks_.str();
|
||||
}
|
||||
}
|
||||
if (!impl_->page_props_.str().empty())
|
||||
if (false == impl_->page_props_.str().empty())
|
||||
{
|
||||
CP_XML_STREAM() << impl_->page_props_.str();
|
||||
}//props выше legacyDrawing !!
|
||||
|
||||
CP_XML_STREAM() << impl_->drawing_.str();
|
||||
|
||||
if (!impl_->commentsId_.empty())
|
||||
if (false == impl_->drawingId_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"drawing")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", impl_->drawingId_);
|
||||
}
|
||||
}
|
||||
if (false == impl_->vml_drawingId_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"legacyDrawing")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
|
||||
CP_XML_ATTR(L"r:id", impl_->vml_drawingId_);
|
||||
}
|
||||
}
|
||||
if (!impl_->ole_objects_.str().empty())
|
||||
if (false == impl_->ole_objects_.str().empty())
|
||||
{
|
||||
CP_XML_NODE(L"oleObjects")
|
||||
{
|
||||
CP_XML_STREAM() << impl_->ole_objects_.str();
|
||||
}
|
||||
}
|
||||
if (!impl_->controls_.str().empty())
|
||||
if (false == impl_->controls_.str().empty())
|
||||
{
|
||||
CP_XML_NODE(L"controls")
|
||||
{
|
||||
CP_XML_STREAM() << impl_->controls_.str();
|
||||
}
|
||||
}
|
||||
if (!impl_->tableParts_.str().empty())
|
||||
if (false == impl_->tableParts_.str().empty())
|
||||
{
|
||||
CP_XML_NODE(L"tableParts")
|
||||
{
|
||||
|
||||
@ -58,7 +58,6 @@ public:
|
||||
std::wostream & sheetData();
|
||||
std::wostream & hyperlinks();
|
||||
std::wostream & mergeCells();
|
||||
std::wostream & drawing();
|
||||
std::wostream & comments();
|
||||
std::wostream & autofilter();
|
||||
std::wostream & tableParts();
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
*/
|
||||
|
||||
#include "xlsx_package.h"
|
||||
#include "docx_package.h"
|
||||
#include "pptx_package.h"
|
||||
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
@ -298,16 +300,16 @@ void xl_files::add_sheet(sheet_content_ptr sheet)
|
||||
sheets_files_.add_sheet(sheet);
|
||||
}
|
||||
|
||||
void xl_files::set_media(mediaitems & _Mediaitems)
|
||||
void xl_files::set_media(mediaitems_ptr & _mediaitems)
|
||||
{
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
if (_mediaitems->count_image + _mediaitems->count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
|
||||
media_ = element_ptr( new media(_mediaitems, _mediaitems->applicationFonts()) );
|
||||
}
|
||||
|
||||
if (_Mediaitems.count_object > 0)
|
||||
if (_mediaitems->count_object > 0)
|
||||
{
|
||||
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
|
||||
embeddings_ = element_ptr( new embeddings(_mediaitems) );
|
||||
}
|
||||
}
|
||||
void xl_files::set_comments(element_ptr Element)
|
||||
@ -556,17 +558,27 @@ void xl_control_props_files::write(const std::wstring & RootPath)
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms)
|
||||
xl_drawings_ptr xl_drawings::create(const std::vector<drawing_elm> & elms, const std::vector<drawing_elm> & vml_elms)
|
||||
{
|
||||
return boost::make_shared<xl_drawings>(boost::ref(elms));
|
||||
return boost::make_shared<xl_drawings>(boost::ref(elms), boost::ref(vml_elms));
|
||||
}
|
||||
|
||||
void xl_drawings::write(const std::wstring & RootPath)
|
||||
{
|
||||
if (drawings_.empty() && vml_drawings_.empty()) return;
|
||||
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"drawings";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
for (size_t i = 0; i < drawings_.size(); i++)
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
|
||||
pptx_document *pptx = dynamic_cast<pptx_document*>(this->get_main_document());
|
||||
xlsx_document *xlsx = dynamic_cast<xlsx_document*>(this->get_main_document());
|
||||
docx_document *docx = dynamic_cast<docx_document*>(this->get_main_document());
|
||||
|
||||
const std::wstring override_str = docx ? L"/word/drawings/" : (pptx ? L"/ppt/drawings/" : L"/xl/drawings/");
|
||||
|
||||
for (size_t i = 0; i < drawings_.size(); i++)
|
||||
{
|
||||
package::simple_element(drawings_[i].filename, drawings_[i].content).write(path);
|
||||
|
||||
@ -578,10 +590,25 @@ void xl_drawings::write(const std::wstring & RootPath)
|
||||
relFiles.add_rel_file(r);
|
||||
relFiles.write(path);
|
||||
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
const std::wstring kDrawingCT = drawings_[i].type == typeChartUserShapes ?
|
||||
L"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml" :
|
||||
L"application/vnd.openxmlformats-officedocument.drawing+xml";
|
||||
|
||||
contentTypes->add_override(override_str + drawings_[i].filename, kDrawingCT);
|
||||
}
|
||||
for (size_t i = 0; i < vml_drawings_.size(); i++)
|
||||
{
|
||||
package::simple_element(vml_drawings_[i].filename, vml_drawings_[i].content).write(path);
|
||||
|
||||
const std::wstring kDrawingCT = L"application/vnd.openxmlformats-officedocument.drawing+xml";
|
||||
contentTypes->add_override(L"/xl/drawings/" + drawings_[i].filename, kDrawingCT);
|
||||
rels_files relFiles;
|
||||
rels_file_ptr r = rels_file::create(vml_drawings_[i].filename + L".rels");
|
||||
|
||||
vml_drawings_[i].drawings->dump_rels_vml_drawing(r->get_rels());
|
||||
|
||||
relFiles.add_rel_file(r);
|
||||
relFiles.write(path);
|
||||
|
||||
//content types - default
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,9 +620,6 @@ xl_comments_ptr xl_comments::create(const std::vector<comment_elm> & elms)
|
||||
|
||||
void xl_comments::write(const std::wstring & RootPath)
|
||||
{
|
||||
std::wstring vml_path = RootPath + FILE_SEPARATOR_STR + L"drawings";
|
||||
NSDirectory::CreateDirectory(vml_path.c_str());
|
||||
|
||||
for (size_t i = 0; i < comments_.size(); i++)
|
||||
{
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
@ -604,7 +628,6 @@ void xl_comments::write(const std::wstring & RootPath)
|
||||
contentTypes->add_override(std::wstring(L"/xl/") + comments_[i].filename, kWSConType);
|
||||
|
||||
package::simple_element(comments_[i].filename, comments_[i].content).write(RootPath);
|
||||
package::simple_element(comments_[i].vml_filename, comments_[i].vml_content).write(vml_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -244,20 +244,27 @@ class xl_drawings: public element
|
||||
{
|
||||
public:
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
void set_rels(rels_files * rels)
|
||||
{
|
||||
rels_ = rels;
|
||||
}
|
||||
|
||||
xl_drawings(const std::vector<drawing_elm> & elms) : drawings_ ( elms )
|
||||
|
||||
//void set_rels(rels_files * rels)
|
||||
// {
|
||||
// rels_ = rels;
|
||||
// }
|
||||
//void set_vml_rels(rels_files * rels)
|
||||
// {
|
||||
// vml_rels_ = rels;
|
||||
// }
|
||||
xl_drawings(const std::vector<drawing_elm> & elms, const std::vector<drawing_elm> & vml_elms) : drawings_(elms), vml_drawings_(vml_elms)
|
||||
{
|
||||
}
|
||||
|
||||
static xl_drawings_ptr create(const std::vector<drawing_elm> & elms);
|
||||
static xl_drawings_ptr create(const std::vector<drawing_elm> & elms, const std::vector<drawing_elm> & vml_elms);
|
||||
|
||||
private:
|
||||
const std::vector<drawing_elm> & drawings_;
|
||||
rels_files * rels_;
|
||||
const std::vector<drawing_elm> & vml_drawings_;
|
||||
|
||||
//rels_files * rels_;
|
||||
//rels_files * vml_rels_;
|
||||
};
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
class xl_control_props_files : public element
|
||||
@ -284,7 +291,7 @@ public:
|
||||
void set_sharedStrings (element_ptr Element);
|
||||
void set_connections (element_ptr Element);
|
||||
void add_sheet (sheet_content_ptr sheet);
|
||||
void set_media (mediaitems & _Mediaitems);
|
||||
void set_media (mediaitems_ptr & _Mediaitems);
|
||||
void set_drawings (element_ptr Element);
|
||||
void set_vml_drawings (element_ptr Element);
|
||||
void set_comments (element_ptr Element);
|
||||
|
||||
@ -69,12 +69,12 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
|
||||
xlsx_table_context_ (this, xlsx_text_context_),
|
||||
math_context_ (odf_document_->odf_context().fontContainer(), true),
|
||||
xlsx_style_ (this),
|
||||
|
||||
|
||||
maxDigitSize_ (std::make_pair(-1.f, -1.f) ),
|
||||
default_style_ ( (std::numeric_limits<size_t>::max)() ),
|
||||
mediaitems_ (odf_document_->get_folder()),
|
||||
xlsx_drawing_context_handle_(mediaitems_)
|
||||
default_style_ ( (std::numeric_limits<size_t>::max)() )
|
||||
{
|
||||
mediaitems_ = boost::make_shared<mediaitems>(odf_document_->get_folder());
|
||||
drawing_context_handle_ = boost::make_shared<xlsx_drawing_context_handle>(mediaitems_);
|
||||
}
|
||||
|
||||
std::unordered_map<std::wstring, int> xlsx_conversion_context::mapExternalLink_;
|
||||
@ -90,7 +90,16 @@ xlsx_conversion_context::~xlsx_conversion_context()
|
||||
|
||||
void xlsx_conversion_context::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
mediaitems_.set_font_directory(pathFonts);
|
||||
mediaitems_->set_font_directory(pathFonts);
|
||||
}
|
||||
void xlsx_conversion_context::set_drawing_context_handle(xlsx_drawing_context_handle_ptr &handle)
|
||||
{
|
||||
drawing_context_handle_ = handle;
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::set_mediaitems(mediaitems_ptr &items)
|
||||
{
|
||||
mediaitems_ = items;
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::start_chart(std::wstring name)
|
||||
@ -323,8 +332,8 @@ void xlsx_conversion_context::end_document()
|
||||
output_document_->get_content_types_file().set_media(get_mediaitems());
|
||||
output_document_->get_xl_files().set_media(get_mediaitems());
|
||||
|
||||
package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content());
|
||||
output_document_->get_xl_files().set_drawings(drawings);
|
||||
package::xl_drawings_ptr drawings = package::xl_drawings::create(drawing_context_handle_->content(), drawing_context_handle_->content_vml());
|
||||
output_document_->get_xl_files().set_drawings(drawings);
|
||||
|
||||
package::xl_comments_ptr comments = package::xl_comments::create(xlsx_comments_context_handle_.content());
|
||||
output_document_->get_xl_files().set_comments(comments);
|
||||
@ -496,42 +505,37 @@ void xlsx_conversion_context::end_table()
|
||||
L"../pivotTables/pivotTable" + std::to_wstring(it->second) + L".xml"));
|
||||
}
|
||||
|
||||
if (!get_drawing_context().empty())
|
||||
if (false == get_drawing_context().empty())
|
||||
{
|
||||
std::wstringstream strm;
|
||||
get_drawing_context().serialize(strm);
|
||||
|
||||
const std::pair<std::wstring, std::wstring> drawingName
|
||||
= xlsx_drawing_context_handle_.add_drawing_xml(strm.str(), get_drawing_context().get_drawings() );
|
||||
= drawing_context_handle_->add_drawing_xml(strm.str(), get_drawing_context().get_drawings() );
|
||||
|
||||
current_sheet().set_drawing_link(drawingName.first, drawingName.second);
|
||||
|
||||
CP_XML_WRITER(current_sheet().drawing())
|
||||
{
|
||||
CP_XML_NODE(L"drawing")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", drawingName.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
get_table_context().serialize_background (current_sheet().drawing());
|
||||
if (false == get_drawing_context().vml_empty())
|
||||
{
|
||||
std::wstringstream strm;
|
||||
get_drawing_context().serialize_vml(strm);
|
||||
|
||||
const std::pair<std::wstring, std::wstring> vml_drawingName
|
||||
= drawing_context_handle_->add_drawing_vml(strm.str(), get_drawing_context().get_drawings() );
|
||||
|
||||
if (!get_comments_context().empty())
|
||||
current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
|
||||
}
|
||||
//get_table_context().serialize_background (current_sheet().picture());
|
||||
|
||||
if (false == get_comments_context().empty())
|
||||
{
|
||||
std::wstringstream strm;
|
||||
get_comments_context().serialize(strm);
|
||||
|
||||
std::wstringstream vml_strm;
|
||||
get_comments_context().serialize_vml(vml_strm);
|
||||
|
||||
|
||||
const std::pair<std::wstring, std::wstring> commentsName
|
||||
= xlsx_comments_context_handle_.add_comments_xml(strm.str(), vml_strm.str(),get_comments_context().get_comments() );
|
||||
|
||||
const std::pair<std::wstring, std::wstring> vml_drawingName
|
||||
=xlsx_comments_context_handle_.get_vml_drawing_xml();
|
||||
= xlsx_comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() );
|
||||
|
||||
current_sheet().set_comments_link(commentsName.first, commentsName.second);
|
||||
current_sheet().set_vml_drawing_link(vml_drawingName.first, vml_drawingName.second);
|
||||
}
|
||||
get_table_context().end_table();
|
||||
}
|
||||
@ -730,7 +734,7 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
|
||||
else
|
||||
font_size =10;
|
||||
|
||||
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, mediaitems_.applicationFonts());
|
||||
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, mediaitems_->applicationFonts());
|
||||
}
|
||||
return maxDigitSize_;
|
||||
}
|
||||
@ -749,9 +753,9 @@ xlsx_drawing_context & xlsx_conversion_context::get_drawing_context()
|
||||
return get_table_context().get_drawing_context();
|
||||
}
|
||||
|
||||
xlsx_drawing_context_handle & xlsx_conversion_context::get_drawing_context_handle()
|
||||
xlsx_drawing_context_handle_ptr & xlsx_conversion_context::get_drawing_context_handle()
|
||||
{
|
||||
return xlsx_drawing_context_handle_;
|
||||
return drawing_context_handle_;
|
||||
}
|
||||
xlsx_comments_context & xlsx_conversion_context::get_comments_context()
|
||||
{
|
||||
|
||||
@ -188,12 +188,16 @@ public:
|
||||
xlsx_pivots_context & get_pivots_context() { return xlsx_pivots_context_;}
|
||||
xlsx_table_metrics & get_table_metrics();
|
||||
xlsx_drawing_context & get_drawing_context();
|
||||
xlsx_drawing_context_handle & get_drawing_context_handle();
|
||||
xlsx_comments_context & get_comments_context();
|
||||
xlsx_comments_context_handle & get_comments_context_handle();
|
||||
xlsx_dataValidations_context& get_dataValidations_context() { return xlsx_dataValidations_context_;}
|
||||
|
||||
mediaitems & get_mediaitems() { return mediaitems_; }
|
||||
|
||||
xlsx_drawing_context_handle_ptr & get_drawing_context_handle();
|
||||
void set_drawing_context_handle(xlsx_drawing_context_handle_ptr &handle);
|
||||
|
||||
mediaitems_ptr & get_mediaitems() { return mediaitems_; }
|
||||
void set_mediaitems(mediaitems_ptr &items);
|
||||
|
||||
static std::unordered_map<std::wstring, int> mapExternalLink_;
|
||||
std::map<std::wstring, int> mapUsedNames_;
|
||||
@ -213,7 +217,7 @@ private:
|
||||
std::pair<float,float> maxDigitSize_;
|
||||
num_format_context num_format_context_;
|
||||
size_t default_style_;
|
||||
mediaitems mediaitems_;
|
||||
mediaitems_ptr mediaitems_;
|
||||
std::multimap<std::wstring, int> mapPivotsTableView_;
|
||||
|
||||
std::map<std::wstring, std::wstring> control_props_;
|
||||
@ -223,9 +227,9 @@ private:
|
||||
xlsx_table_context xlsx_table_context_;
|
||||
xlsx_text_context xlsx_text_context_;
|
||||
xlsx_pivots_context xlsx_pivots_context_;
|
||||
xlsx_drawing_context_handle xlsx_drawing_context_handle_;
|
||||
xlsx_comments_context_handle xlsx_comments_context_handle_;
|
||||
xlsx_dataValidations_context xlsx_dataValidations_context_;
|
||||
xlsx_drawing_context_handle_ptr drawing_context_handle_;
|
||||
|
||||
math_context math_context_;
|
||||
forms_context forms_context_;
|
||||
|
||||
@ -221,6 +221,11 @@ void object_odf_context::docx_convert(oox::docx_conversion_context & Context)
|
||||
chart_context.set_cache_only(true);
|
||||
}
|
||||
|
||||
if (false == userShapes.first.empty())
|
||||
{
|
||||
chart_context.set_userShapes(userShapes);
|
||||
}
|
||||
|
||||
Context.end_chart();
|
||||
}
|
||||
else if (object_type_ == 2 && office_text_)
|
||||
|
||||
@ -206,6 +206,7 @@ public:
|
||||
std::map<std::wstring, _cell>cash_pivot;
|
||||
|
||||
std::wstring embeddedData;
|
||||
std::pair<std::wstring, std::wstring> userShapes;
|
||||
//---------------------------------------
|
||||
std::wstring target_table_;
|
||||
std::wstring table_name_;
|
||||
|
||||
@ -124,9 +124,8 @@ namespace chart {
|
||||
std::wstring chart_name_;
|
||||
std::wstring style_name_;
|
||||
std::vector<grid> grids_;
|
||||
int type_;
|
||||
|
||||
};
|
||||
int type_;
|
||||
};
|
||||
struct series : public simple
|
||||
{
|
||||
struct point : public simple
|
||||
|
||||
@ -265,7 +265,13 @@ void common_break_attlist::serialize(CP_ATTR_NODE)
|
||||
|
||||
void common_page_number_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"style:page-number", style_page_number_);
|
||||
_CP_OPT(std::wstring) str;
|
||||
CP_APPLY_ATTR(L"style:page-number", str);
|
||||
|
||||
if ((str) && (*str != L"auto"))
|
||||
{
|
||||
style_page_number_ = XmlUtils::GetInteger(*str);
|
||||
}
|
||||
}
|
||||
void common_page_number_attlist::apply_from(const common_page_number_attlist & Other)
|
||||
{
|
||||
|
||||
@ -499,6 +499,15 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
|
||||
fill.gradient = oox::oox_gradient_fill::create();
|
||||
|
||||
Compute_GradientFill(image_style, fill.gradient);
|
||||
|
||||
if (fill.opacity)
|
||||
{
|
||||
for (size_t i = 0; i < fill.gradient->colors.size(); i++)
|
||||
{
|
||||
if (!fill.gradient->colors[i].opacity)
|
||||
fill.gradient->colors[i].opacity = fill.opacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,6 +207,11 @@ void draw_g::add_child_element( xml::sax * Reader, const std::wstring & Ns, cons
|
||||
|
||||
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
|
||||
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
|
||||
|
||||
if (frame->is_object_)
|
||||
{
|
||||
object_index = content_.size() - 1;
|
||||
}
|
||||
}
|
||||
else if (shape)
|
||||
{
|
||||
@ -256,16 +261,20 @@ void draw_frame::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
void draw_frame::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (CP_CHECK_NAME(L"draw", L"text-box") ||
|
||||
CP_CHECK_NAME(L"draw", L"image") ||//копия объекта в виде картинки ну.. или просто картинка
|
||||
CP_CHECK_NAME(L"draw", L"object") ||//месторасположение embedded объекта
|
||||
CP_CHECK_NAME(L"draw", L"object-ole") ||
|
||||
CP_CHECK_NAME(L"draw", L"applet") ||
|
||||
CP_CHECK_NAME(L"draw", L"floating-frame") ||
|
||||
CP_CHECK_NAME(L"draw", L"plugin") ||
|
||||
CP_CHECK_NAME(L"table", L"table")
|
||||
)
|
||||
CP_CHECK_NAME(L"draw", L"image") ||//копия объекта в виде картинки ну.. или просто картинка
|
||||
CP_CHECK_NAME(L"table", L"table") ||
|
||||
CP_CHECK_NAME(L"draw", L"object-ole")||
|
||||
CP_CHECK_NAME(L"draw", L"applet") ||
|
||||
CP_CHECK_NAME(L"draw", L"floating-frame")||
|
||||
CP_CHECK_NAME(L"draw", L"plugin")
|
||||
)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"draw", L"object") //embedded объект
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
is_object_ = true;
|
||||
}
|
||||
else if CP_CHECK_NAME(L"office", L"event-listeners")
|
||||
{
|
||||
|
||||
@ -153,7 +153,7 @@ public:
|
||||
static const ElementType type = typeDrawFrame;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
draw_frame() : oox_drawing_(), idx_in_owner(-1) {}
|
||||
draw_frame() : oox_drawing_(), idx_in_owner(-1), is_object_(false) {}
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
@ -185,10 +185,10 @@ public:
|
||||
|
||||
oox_drawing_ptr oox_drawing_;
|
||||
|
||||
bool is_object_;
|
||||
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(draw_frame);
|
||||
@ -209,7 +209,7 @@ public:
|
||||
static const ElementType type = typeDrawG;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
draw_g() : position_child_x1(0x7fffffff), position_child_y1(0x7fffffff), position_child_x2(0x7fffffff), position_child_y2(0x7fffffff) {}
|
||||
draw_g() : object_index(-1), position_child_x1(0x7fffffff), position_child_y1(0x7fffffff), position_child_x2(0x7fffffff), position_child_y2(0x7fffffff) {}
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const;
|
||||
|
||||
@ -228,6 +228,8 @@ public:
|
||||
int position_child_x2;
|
||||
int position_child_y2;
|
||||
|
||||
int object_index ;
|
||||
|
||||
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);
|
||||
@ -307,6 +309,7 @@ public:
|
||||
|
||||
odf_document_ptr odf_document_;
|
||||
|
||||
office_element_ptr_array content_; //for case group with object
|
||||
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);
|
||||
|
||||
@ -923,7 +923,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
if ((drawing->fill.bitmap) && (drawing->fill.bitmap->rId.empty()))
|
||||
{
|
||||
std::wstring href = drawing->fill.bitmap->xlink_href_;
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@ -1196,7 +1196,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing->fill.bitmap = oox::oox_bitmap_fill::create();
|
||||
drawing->fill.type = 2;
|
||||
drawing->fill.bitmap->isInternal = false;
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
drawing->fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, drawing->fill.bitmap->isInternal, href);
|
||||
drawing->fill.bitmap->bStretch = true;
|
||||
|
||||
const std::wstring styleName = frame->common_draw_attlists_.shape_with_text_and_styles_.
|
||||
@ -1216,7 +1216,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, Context.get_mediaitems().applicationFonts());
|
||||
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, Context.get_mediaitems()->applicationFonts());
|
||||
}
|
||||
if (properties->common_draw_fill_attlist_.draw_luminance_)
|
||||
{
|
||||
@ -1352,6 +1352,32 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.add_delayed_element(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (object_index >= 0) //только в документах нельзя объект объединять с шейпами в группы (
|
||||
{
|
||||
draw_frame *frame = dynamic_cast<draw_frame*>(content_[object_index].get());
|
||||
|
||||
frame->common_draw_attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_ =
|
||||
common_draw_attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
|
||||
|
||||
for (size_t i = 0; i < frame->content_.size(); i++)
|
||||
{
|
||||
draw_object *object = dynamic_cast<draw_object*>(frame->content_[i].get());
|
||||
if (!object)continue;
|
||||
|
||||
for (size_t j = 0; j < content_.size(); j++)
|
||||
{
|
||||
if (j == object_index) continue;
|
||||
|
||||
object->content_.push_back(content_[j]);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
frame->docx_convert(Context);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
@ -1541,6 +1567,10 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
process_build_object process_build_object_(objectBuild, odf_document_->odf_context());
|
||||
contentSubDoc->accept(process_build_object_);
|
||||
|
||||
frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
if (frame)
|
||||
drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
|
||||
if (objectBuild.table_table_)
|
||||
{
|
||||
oox::xlsx_conversion_context xlsx_context(odf_document_.get());
|
||||
@ -1556,7 +1586,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
NSDirectory::CreateDirectory(href_folder);
|
||||
outputXlsx.write(href_folder);
|
||||
|
||||
std::wstring href = L"Microsoft_Excel_Worksheet_" + std::to_wstring(Context.get_mediaitems().count_object + 1) + L".xlsx";
|
||||
std::wstring href = L"Microsoft_Excel_Worksheet_" + std::to_wstring(Context.get_mediaitems()->count_object + 1) + L".xlsx";
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK == oCOfficeUtils.CompressFileOrDirectory(href_folder, odfPath + FILE_SEPARATOR_STR + href, true))
|
||||
@ -1565,11 +1595,34 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
}
|
||||
}
|
||||
|
||||
if (false == content_.empty())
|
||||
{
|
||||
oox::xlsx_conversion_context xlsx_context(Context.root());
|
||||
|
||||
xlsx_context.set_drawing_context_handle(Context.get_chart_drawing_handle());
|
||||
xlsx_context.set_mediaitems(Context.get_mediaitems());
|
||||
|
||||
xlsx_context.get_table_context().start_table(L"", L"", 0);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); ++i)
|
||||
{
|
||||
xlsx_context.get_drawing_context().set_rel_anchor(drawing->cx, drawing->cy);
|
||||
content_[i]->xlsx_convert(xlsx_context);
|
||||
}
|
||||
xlsx_context.get_table_context().end_table();
|
||||
|
||||
xlsx_context.get_drawing_context().process_objects(xlsx_context.get_table_metrics());
|
||||
|
||||
std::wstringstream strm;
|
||||
xlsx_context.get_drawing_context().serialize(strm, L"cdr");
|
||||
|
||||
const std::pair<std::wstring, std::wstring> drawingName =
|
||||
xlsx_context.get_drawing_context_handle()->add_drawing_xml(strm.str(), xlsx_context.get_drawing_context().get_drawings(), oox::typeChartUserShapes );
|
||||
|
||||
objectBuild.userShapes = drawingName;
|
||||
}
|
||||
|
||||
objectBuild.docx_convert(Context);
|
||||
|
||||
frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
if (frame)
|
||||
drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
if (!frame || !drawing)
|
||||
@ -1582,7 +1635,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
drawing->type = oox::typeChart;
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectId = Context.get_mediaitems()->add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
}
|
||||
else if (objectBuild.object_type_ == 2 ) //embedded text
|
||||
{
|
||||
@ -1641,7 +1694,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context)
|
||||
bool isMediaInternal = true;
|
||||
|
||||
href += FILE_SEPARATOR_STR + href_new;
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectId = Context.get_mediaitems()->add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
drawing->objectProgId = L"Excel.Sheet.12";
|
||||
}
|
||||
}
|
||||
@ -1682,7 +1735,7 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
|
||||
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href + extension, drawing->type, isMediaInternal, href);
|
||||
drawing->objectId = Context.get_mediaitems()->add_or_find(href + extension, drawing->type, isMediaInternal, href);
|
||||
|
||||
}
|
||||
void draw_control::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
@ -303,7 +303,7 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
NSDirectory::CreateDirectory(href_folder);
|
||||
outputXlsx.write(href_folder);
|
||||
|
||||
std::wstring href = L"Microsoft_Excel_Worksheet_" + std::to_wstring(Context.get_mediaitems().count_object + 1) + L".xlsx";
|
||||
std::wstring href = L"Microsoft_Excel_Worksheet_" + std::to_wstring(Context.get_mediaitems()->count_object + 1) + L".xlsx";
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
if (S_OK == oCOfficeUtils.CompressFileOrDirectory(href_folder, odfPath + FILE_SEPARATOR_STR + href, true))
|
||||
|
||||
@ -712,11 +712,11 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
_CP_OPT(std::wstring) xml_id_;
|
||||
_CP_OPT(std::wstring) caption_id_;
|
||||
_CP_OPT(std::wstring) control_id_;
|
||||
_CP_OPT(std::wstring) xml_id_;
|
||||
_CP_OPT(std::wstring) caption_id_;
|
||||
_CP_OPT(std::wstring) control_id_;
|
||||
|
||||
office_element_ptr draw_glue_point_;
|
||||
office_element_ptr draw_glue_point_;
|
||||
//<svg:desc>
|
||||
//<svg:title>
|
||||
private:
|
||||
|
||||
@ -102,7 +102,7 @@ void draw_shape::common_docx_convert(oox::docx_conversion_context & Context)
|
||||
if ((fill.bitmap) && (fill.bitmap->rId.empty()))
|
||||
{
|
||||
std::wstring href = fill.bitmap->xlink_href_;
|
||||
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
fill.bitmap->name_space = L"w14";
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
std::vector<const odf_reader::style_instance *> instances;
|
||||
|
||||
odf_reader::style_instance* styleInst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic,false/*Context.process_headers_footers_*/);
|
||||
Context.root()->odf_context().styleContainer().style_by_name(styleName, odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
|
||||
if (styleInst)
|
||||
{
|
||||
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
|
||||
@ -396,28 +396,75 @@ void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
oox::forms_context::_state & state = Context.get_forms_context().get_state_element(*control_id_);
|
||||
if (state.id.empty()) return;
|
||||
|
||||
form_element* control = dynamic_cast<form_element*>(state.element);
|
||||
if (!control) return;
|
||||
|
||||
if (state.ctrlPropId.empty())
|
||||
{
|
||||
std::wstring target;
|
||||
state.ctrlPropId = Context.get_mediaitems().add_control_props(target);
|
||||
state.ctrlPropId = Context.get_mediaitems()->add_control_props(target);
|
||||
|
||||
std::wstringstream strm;
|
||||
|
||||
form_element* control = dynamic_cast<form_element*>(state.element);
|
||||
if (control)
|
||||
{
|
||||
control->serialize_control_props(strm);
|
||||
}
|
||||
control->serialize_control_props(strm);
|
||||
|
||||
Context.add_control_props(state.ctrlPropId, target, strm.str());
|
||||
}
|
||||
|
||||
Context.get_drawing_context().start_frame();
|
||||
Context.get_drawing_context().set_control(state.ctrlPropId);
|
||||
Context.get_drawing_context().start_control(state.ctrlPropId, control->object_type_);
|
||||
|
||||
common_xlsx_convert(Context);
|
||||
|
||||
if (control->linked_cell_)
|
||||
{
|
||||
|
||||
Context.get_drawing_context().end_frame();
|
||||
Context.get_drawing_context().set_property(_property(L"linked_cell", control->linked_cell_.get()));
|
||||
}
|
||||
if (control->disabled_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"disabled", control->disabled_->get()));
|
||||
}
|
||||
if (control->value_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"value", control->value_.get()));
|
||||
}
|
||||
else if (control->current_value_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"value", control->current_value_.get()));
|
||||
}
|
||||
//if (control->name_)
|
||||
//{
|
||||
// Context.get_drawing_context().set_name(control->name_.get());
|
||||
//}
|
||||
form_value_range* value_range = dynamic_cast<form_value_range*>(control);
|
||||
|
||||
if (value_range)
|
||||
{
|
||||
if (value_range->min_value_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"min_value", value_range->min_value_.get()));
|
||||
}
|
||||
if (value_range->max_value_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"max_value", value_range->max_value_.get()));
|
||||
}
|
||||
if (value_range->step_size_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"step", value_range->step_size_.get()));
|
||||
}
|
||||
if (value_range->page_step_size_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"page_step", value_range->page_step_size_.get()));
|
||||
}
|
||||
if (value_range->orientation_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"orientation", value_range->orientation_.get()));
|
||||
}
|
||||
}
|
||||
//_CP_OPT(std::wstring) label_;
|
||||
//_CP_OPT(std::wstring) title_;
|
||||
//_CP_OPT(odf_types::Bool) dropdown_;
|
||||
|
||||
Context.get_drawing_context().end_control();
|
||||
Context.get_drawing_context().clear();
|
||||
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
#include <odf/odf_document.h>
|
||||
#include "odfcontext.h"
|
||||
|
||||
#include "draw_common.h"
|
||||
#include "calcs_styles.h"
|
||||
#include "../docx/xlsx_utils.h"
|
||||
|
||||
@ -111,7 +111,7 @@ void office_annotation::add_child_element( xml::sax * Reader, const std::wstring
|
||||
|
||||
void office_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
office_annotation_attr_.add_attributes(Attributes);
|
||||
attr_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void office_annotation::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -159,19 +159,20 @@ void office_annotation::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
const _CP_OPT(length) svg_widthVal = office_annotation_attr_.svg_width_;
|
||||
const _CP_OPT(length) svg_widthVal = attr_.svg_width_;
|
||||
|
||||
const double width_cm = svg_widthVal.get_value_or(length(0)).get_value_unit(length::cm);
|
||||
const double width_pt = svg_widthVal.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
|
||||
const _CP_OPT(length) svg_heightVal =office_annotation_attr_.svg_height_;
|
||||
const _CP_OPT(length) svg_heightVal =attr_.svg_height_;
|
||||
|
||||
const double height_cm = svg_heightVal.get_value_or(length(0)).get_value_unit(length::cm);
|
||||
const double height_pt = svg_heightVal.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
|
||||
const double x_pt = office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
const double y_pt = office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
/////////////////////////////////
|
||||
const double x_pt = attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
const double y_pt = attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
|
||||
//-----------------------------------------------
|
||||
std::wstring date;
|
||||
std::wstring author;
|
||||
if (dc_date_)
|
||||
@ -182,11 +183,14 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
author = xml::utils::replace_text_to_xml(dynamic_cast<dc_creator * >(dc_creator_.get())->content_);
|
||||
}
|
||||
////////////////////////////////////////
|
||||
Context.get_comments_context().start_comment(width_pt, height_pt, x_pt, y_pt);
|
||||
if (office_annotation_attr_.display_)
|
||||
int col = Context.current_table_column(); if (col < 0) col = 0;
|
||||
int row = Context.current_table_row(); if (row < 0) row = 0;
|
||||
|
||||
std::wstring ref = oox::getCellAddress(col, row);
|
||||
//-----------------------------------------------
|
||||
Context.get_comments_context().start_comment(ref);
|
||||
if (attr_.display_)
|
||||
{
|
||||
Context.get_comments_context().set_visibly(office_annotation_attr_.display_.get());
|
||||
}
|
||||
|
||||
Context.get_text_context().start_comment_content();
|
||||
@ -196,13 +200,43 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
Context.get_comments_context().add_author(author);
|
||||
Context.get_comments_context().add_content(Context.get_text_context().end_comment_content());
|
||||
//----------- drawing part ---------------
|
||||
Context.get_drawing_context().start_comment(col, row);
|
||||
Context.get_drawing_context().start_drawing(L"");
|
||||
|
||||
Context.get_drawing_context().set_rect(width_pt, height_pt, x_pt, y_pt);
|
||||
if (attr_.display_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"visibly", attr_.display_.get()));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
/// Обрабатываем стиль draw
|
||||
if (attr_.draw_style_name_)
|
||||
{
|
||||
std::vector<const odf_reader::style_instance *> instances;
|
||||
|
||||
odf_reader::style_instance* styleInst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name(*attr_.draw_style_name_, odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
|
||||
if (styleInst)
|
||||
{
|
||||
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
|
||||
if (defaultStyle)instances.push_back(defaultStyle);
|
||||
|
||||
instances.push_back(styleInst);
|
||||
}
|
||||
graphic_format_properties properties = calc_graphic_properties_content(instances);
|
||||
|
||||
//-----------------------------------------------
|
||||
properties.apply_to(Context.get_drawing_context().get_properties());
|
||||
|
||||
oox::_oox_fill fill;
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
Context.root()->odf_context().drawStyles(), fill);
|
||||
Context.get_drawing_context().set_fill(fill);
|
||||
}
|
||||
//-----------------------------------------------
|
||||
std::vector<const odf_reader::style_instance *> instances;
|
||||
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(
|
||||
office_annotation_attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
|
||||
attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic, false/*Context.process_headers_footers_*/);
|
||||
if (styleInst)
|
||||
{
|
||||
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
|
||||
@ -212,16 +246,13 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
graphic_format_properties graphicProperties = calc_graphic_properties_content(instances);
|
||||
|
||||
graphicProperties.apply_to(Context.get_comments_context().get_draw_properties());
|
||||
|
||||
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");
|
||||
|
||||
int col = Context.current_table_column(); if (col < 0) col = 0;
|
||||
int row = Context.current_table_row(); if (row < 0) row = 0;
|
||||
|
||||
std::wstring ref = oox::getCellAddress(col, row);
|
||||
|
||||
Context.get_comments_context().end_comment(ref, col, row);
|
||||
const std::wstring textStyleName = attr_.draw_text_style_name_.get_value_or(L"");
|
||||
|
||||
Context.get_drawing_context().end_drawing();
|
||||
Context.get_drawing_context().end_comment();
|
||||
Context.get_drawing_context().clear();
|
||||
//-----------------------------------------------
|
||||
Context.get_comments_context().end_comment();
|
||||
}
|
||||
// officeooo:annotation
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -246,13 +277,13 @@ void officeooo_annotation::add_child_element( xml::sax * Reader, const std::wstr
|
||||
|
||||
void officeooo_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
office_annotation_attr_.add_attributes(Attributes);
|
||||
attr_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
const double x = 8 * office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
const double y = 8 * office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
const double x = 8 * attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
const double y = 8 * attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
/////////////////////////////////
|
||||
std::wstring date;
|
||||
std::wstring author;
|
||||
@ -283,7 +314,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
/// Обрабатываем стиль draw
|
||||
std::vector<const odf_reader::style_instance *> instances;
|
||||
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(
|
||||
office_annotation_attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic,false/*Context.process_headers_footers_*/);
|
||||
attr_.draw_style_name_.get_value_or(L""), odf_types::style_family::Graphic,false/*Context.process_headers_footers_*/);
|
||||
if (styleInst)
|
||||
{
|
||||
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::Graphic);
|
||||
@ -295,7 +326,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
graphicProperties.apply_to(Context.get_comments_context().get_draw_properties());
|
||||
|
||||
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(L"");
|
||||
const std::wstring textStyleName = attr_.draw_text_style_name_.get_value_or(L"");
|
||||
|
||||
Context.get_comments_context().end_comment();
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@ class office_annotation_attr
|
||||
public:
|
||||
void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(odf_types::length) svg_y_;
|
||||
_CP_OPT(odf_types::length) svg_x_;
|
||||
_CP_OPT(odf_types::length) svg_width_;
|
||||
@ -123,9 +122,8 @@ 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);
|
||||
|
||||
private:
|
||||
office_element_ptr_array content_;
|
||||
office_annotation_attr office_annotation_attr_;
|
||||
office_annotation_attr attr_;
|
||||
|
||||
office_element_ptr dc_date_;
|
||||
office_element_ptr dc_creator_;
|
||||
@ -150,9 +148,8 @@ 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);
|
||||
|
||||
private:
|
||||
office_element_ptr_array content_;
|
||||
office_annotation_attr office_annotation_attr_;
|
||||
office_annotation_attr attr_;
|
||||
|
||||
office_element_ptr dc_date_;
|
||||
office_element_ptr dc_creator_;
|
||||
|
||||
@ -121,7 +121,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
|
||||
if ((fill.bitmap) && (fill.bitmap->rId.empty()))
|
||||
{
|
||||
std::wstring href = fill.bitmap->xlink_href_;
|
||||
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
}
|
||||
int id = Context.get_drawing_context().get_current_shape_id();
|
||||
if (layout_properties->docx_background_serialize(Context.output_stream(), Context, fill, id))
|
||||
|
||||
@ -41,6 +41,30 @@
|
||||
#include "serialize_elements.h"
|
||||
|
||||
#include "../formulasconvert/formulasconvert.h"
|
||||
|
||||
#define OBJ_Group 0x0000
|
||||
#define OBJ_Line 0x0001
|
||||
#define OBJ_Rectangle 0x0002
|
||||
#define OBJ_Oval 0x0003
|
||||
#define OBJ_Arc 0x0004
|
||||
#define OBJ_Text 0x0006
|
||||
#define OBJ_OfficeArt 0x001E
|
||||
#define OBJ_Polygon 0x0009
|
||||
#define OBJ_Picture 0x0008
|
||||
#define OBJ_Chart 0x0005
|
||||
#define OBJ_Button 0x0007
|
||||
#define OBJ_CheckBox 0x000B
|
||||
#define OBJ_RadioButton 0x000C
|
||||
#define OBJ_EditBox 0x000D
|
||||
#define OBJ_Label 0x000E
|
||||
#define OBJ_DialogBox 0x000F
|
||||
#define OBJ_SpinControl 0x0010
|
||||
#define OBJ_Scrollbar 0x0011
|
||||
#define OBJ_List 0x0012
|
||||
#define OBJ_GroupBox 0x0013
|
||||
#define OBJ_DropdownList 0x0014
|
||||
#define OBJ_Note 0x0019
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_reader {
|
||||
|
||||
@ -207,7 +231,7 @@ const wchar_t * form_element::name = L"element";
|
||||
|
||||
void form_element::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"form:control_implementation", control_implementation_);
|
||||
CP_APPLY_ATTR(L"form:control-implementation", control_implementation_);
|
||||
CP_APPLY_ATTR(L"form:data-field", data_field_);
|
||||
CP_APPLY_ATTR(L"form:linked-cell", linked_cell_);
|
||||
CP_APPLY_ATTR(L"form:disabled", disabled_);
|
||||
@ -273,6 +297,7 @@ const wchar_t * form_button::name = L"button";
|
||||
|
||||
void form_button::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_Button;
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_button::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -302,7 +327,8 @@ void form_button::serialize_control_props(std::wostream & strm)
|
||||
CP_XML_ATTR(L"dx", L"20");
|
||||
CP_XML_ATTR(L"noThreeD", L"1");
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
// form:text
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_text::ns = L"form";
|
||||
@ -310,6 +336,7 @@ const wchar_t * form_text::name = L"text";
|
||||
|
||||
void form_text::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_EditBox;
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_text::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -342,7 +369,8 @@ void form_text::serialize_control_props(std::wostream & strm)
|
||||
if (value_)
|
||||
CP_XML_ATTR(L"val", *value_);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
void form_text::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
if (!draw) return;
|
||||
@ -397,6 +425,107 @@ void form_text::docx_convert_field(oox::docx_conversion_context & Context, draw_
|
||||
Context.finish_run();
|
||||
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
// form:fixed-text
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_textarea::ns = L"form";
|
||||
const wchar_t * form_textarea::name = L"textarea";
|
||||
|
||||
// form:fixed-text
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_fixed_text::ns = L"form";
|
||||
const wchar_t * form_fixed_text::name = L"fixed-text";
|
||||
|
||||
void form_fixed_text::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_Label;
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_fixed_text::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(2);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
void form_fixed_text::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(2);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::xlsx_convert(Context);
|
||||
}
|
||||
void form_fixed_text::serialize_control_props(std::wostream & strm)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"formControlPr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
|
||||
CP_XML_ATTR(L"objectType", L"EditBox");
|
||||
|
||||
CP_XML_ATTR(L"dx", L"20");
|
||||
CP_XML_ATTR(L"noThreeD", L"1");
|
||||
|
||||
if (value_)
|
||||
CP_XML_ATTR(L"val", *value_);
|
||||
}
|
||||
}
|
||||
}
|
||||
void form_fixed_text::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
if (!draw) return;
|
||||
|
||||
Context.output_stream() << L"<w:sdt>";
|
||||
Context.output_stream() << L"<w:sdtPr>";
|
||||
{
|
||||
if (name_)
|
||||
{
|
||||
Context.output_stream() << L"<w:alias w:val=\"" + xml::utils::replace_text_to_xml(*name_) + L"\"/>";
|
||||
}
|
||||
Context.output_stream() << L"<w:id w:val=\"" + std::to_wstring(Context.get_drawing_context().get_current_shape_id()) + L"\"/>";
|
||||
//<w:lock w:val="sdtLocked"/>
|
||||
//<w:placeholder>
|
||||
// <w:docPart w:val="DefaultPlaceholder_-1854013440"/>
|
||||
//</w:placeholder>
|
||||
}
|
||||
Context.output_stream() << L"</w:sdtPr>";
|
||||
Context.output_stream() << L"<w:sdtContent>";
|
||||
{
|
||||
Context.add_new_run(L"");
|
||||
if (current_value_)
|
||||
{
|
||||
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
|
||||
Context.output_stream() << xml::utils::replace_text_to_xml(*current_value_ );
|
||||
Context.output_stream() << L"</w:t>";
|
||||
}
|
||||
Context.finish_run();
|
||||
}
|
||||
Context.output_stream() << L"</w:sdtContent>";
|
||||
Context.output_stream() << L"</w:sdt>";
|
||||
}
|
||||
void form_fixed_text::docx_convert_field(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
if (!draw) return;
|
||||
|
||||
XmlUtils::replace_all( *name_, L" ", L"_");
|
||||
|
||||
Context.add_new_run(L"");
|
||||
Context.output_stream() << L"<w:fldChar w:fldCharType=\"begin\"><w:ffData><w:name w:val=\"" << *name_ << L"\"/><w:enabled/>";
|
||||
Context.output_stream() << L"</w:ffData></w:fldChar>";
|
||||
Context.finish_run();
|
||||
|
||||
Context.add_new_run(L"");
|
||||
Context.output_stream() << L"<w:instrText>FORMTEXT</w:instrText>";
|
||||
Context.finish_run();
|
||||
|
||||
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
|
||||
|
||||
Context.add_new_run(L"");
|
||||
Context.output_stream() << L"<w:t>" << *current_value_ << L"</w:t>";
|
||||
Context.finish_run();
|
||||
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
// form:checkbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_checkbox::ns = L"form";
|
||||
@ -404,6 +533,8 @@ const wchar_t * form_checkbox::name = L"checkbox";
|
||||
|
||||
void form_checkbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_CheckBox;
|
||||
|
||||
_CP_OPT(std::wstring) strVal;
|
||||
CP_APPLY_ATTR(L"form:current-state", strVal);
|
||||
|
||||
@ -515,6 +646,7 @@ const wchar_t * form_combobox::name = L"combobox";
|
||||
|
||||
void form_combobox::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_DropdownList;
|
||||
form_element::add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"form:source-cell-range", source_cell_range_);
|
||||
@ -560,7 +692,7 @@ void form_combobox::serialize_control_props(std::wostream & strm)
|
||||
|
||||
if (linked_cell_)
|
||||
{
|
||||
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
|
||||
std::wstring fmla = converter.convert_named_ref(*linked_cell_);
|
||||
CP_XML_ATTR(L"fmlaLink", fmla);
|
||||
}
|
||||
if (source_cell_range_)
|
||||
@ -628,9 +760,6 @@ void form_combobox::docx_convert_sdt(oox::docx_conversion_context & Context, dra
|
||||
Context.finish_run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// form:listbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_listbox::ns = L"form";
|
||||
@ -638,6 +767,7 @@ const wchar_t * form_listbox::name = L"listbox";
|
||||
|
||||
void form_listbox::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_List;
|
||||
form_element::add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"form:source-cell-range", source_cell_range_);
|
||||
@ -678,7 +808,7 @@ void form_listbox::serialize_control_props(std::wostream & strm)
|
||||
|
||||
if (linked_cell_)
|
||||
{
|
||||
std::wstring fmla = converter.convert_named_expr(*linked_cell_);
|
||||
std::wstring fmla = converter.convert_named_ref(*linked_cell_);
|
||||
CP_XML_ATTR(L"fmlaLink", fmla);
|
||||
}
|
||||
if (source_cell_range_)
|
||||
@ -693,13 +823,14 @@ void form_listbox::serialize_control_props(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:button
|
||||
// form:date
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_date::ns = L"form";
|
||||
const wchar_t * form_date::name = L"date";
|
||||
|
||||
void form_date::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = 15;
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_date::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -767,6 +898,175 @@ void form_date::docx_convert_sdt(oox::docx_conversion_context & Context, draw_co
|
||||
Context.finish_run();
|
||||
}
|
||||
}
|
||||
// form:time
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_time::ns = L"form";
|
||||
const wchar_t * form_time::name = L"time";
|
||||
|
||||
void form_time::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = 16;
|
||||
form_element::add_attributes(Attributes);
|
||||
}
|
||||
void form_time::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(6);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
void form_time::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(6);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::xlsx_convert(Context);
|
||||
}
|
||||
void form_time::serialize_control_props(std::wostream & strm)
|
||||
{
|
||||
}
|
||||
void form_time::docx_convert_sdt(oox::docx_conversion_context & Context, draw_control *draw)
|
||||
{
|
||||
Context.finish_run();
|
||||
|
||||
Context.output_stream() << L"<w:sdt>";
|
||||
Context.output_stream() << L"<w:sdtPr>";
|
||||
{
|
||||
if (name_)
|
||||
{
|
||||
Context.output_stream() << L"<w:alias w:val=\"" + xml::utils::replace_text_to_xml(*name_) + L"\"/>";
|
||||
}
|
||||
Context.output_stream() << L"<w:id w:val=\"" + std::to_wstring(Context.get_drawing_context().get_current_shape_id()) + L"\"/>";
|
||||
|
||||
Context.output_stream() << L"<w:date>";
|
||||
Context.output_stream() << L"<w:dateFormat w:val=\"\"/>";
|
||||
Context.output_stream() << L"<w:lid w:val=\"en-US\"/>";
|
||||
Context.output_stream() << L"<w:storeMappedDataAs w:val=\"dateTime\"/>";
|
||||
Context.output_stream() << L"<w:calendar w:val=\"gregorian\"/>";
|
||||
Context.output_stream() << L"</w:date>";
|
||||
}
|
||||
Context.output_stream() << L"</w:sdtPr>";
|
||||
Context.output_stream() << L"<w:sdtContent>";
|
||||
{
|
||||
Context.add_new_run(L"");
|
||||
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
|
||||
if (current_value_)
|
||||
{
|
||||
Context.output_stream() << xml::utils::replace_text_to_xml(*current_value_ );
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.output_stream() << L"[Insert time]";
|
||||
}
|
||||
Context.output_stream() << L"</w:t>";
|
||||
Context.finish_run();
|
||||
}
|
||||
Context.output_stream() << L"</w:sdtContent>";
|
||||
Context.output_stream() << L"</w:sdt>";
|
||||
|
||||
if (label_)
|
||||
{
|
||||
Context.add_new_run(L"");
|
||||
Context.output_stream() << L"<w:t xml:space=\"preserve\">";
|
||||
Context.output_stream() << xml::utils::replace_text_to_xml(*label_ );
|
||||
Context.output_stream() << L"</w:t>";
|
||||
Context.finish_run();
|
||||
}
|
||||
}
|
||||
// form:listbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_value_range::ns = L"form";
|
||||
const wchar_t * form_value_range::name = L"value-range";
|
||||
|
||||
void form_value_range::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
object_type_ = OBJ_Scrollbar;
|
||||
|
||||
form_element::add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"form:min-value", min_value_);
|
||||
CP_APPLY_ATTR(L"form:max-value", max_value_);
|
||||
CP_APPLY_ATTR(L"form:step-size", step_size_);
|
||||
CP_APPLY_ATTR(L"form:page-step-size", page_step_size_);
|
||||
CP_APPLY_ATTR(L"form:orientation", orientation_);
|
||||
CP_APPLY_ATTR(L"form:delay-for-repeat", delay_for_repeat_);
|
||||
|
||||
if (control_implementation_)
|
||||
{
|
||||
if (control_implementation_->find(L"SpinButton") != std::wstring::npos)
|
||||
{
|
||||
object_type_ = OBJ_SpinControl;
|
||||
if (!orientation_) orientation_ = L"vertical";
|
||||
}
|
||||
else
|
||||
{
|
||||
object_type_ = OBJ_Scrollbar;
|
||||
if (!orientation_) orientation_ = L"horizontal";
|
||||
}
|
||||
}
|
||||
}
|
||||
void form_value_range::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (!control_implementation_) return;
|
||||
|
||||
if (control_implementation_->find(L"SpinButton") != std::wstring::npos)
|
||||
Context.get_forms_context().start_element(7); //spin
|
||||
else
|
||||
Context.get_forms_context().start_element(8); //scroll
|
||||
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::docx_convert(Context);
|
||||
}
|
||||
void form_value_range::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (!control_implementation_) return;
|
||||
|
||||
if (control_implementation_->find(L"SpinButton") != std::wstring::npos)
|
||||
Context.get_forms_context().start_element(7); //spin
|
||||
else
|
||||
Context.get_forms_context().start_element(8); //scroll
|
||||
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::xlsx_convert(Context);
|
||||
}
|
||||
void form_value_range::serialize_control_props(std::wostream & strm)
|
||||
{
|
||||
if (!control_implementation_) return;
|
||||
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"formControlPr")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
|
||||
CP_XML_ATTR(L"objectType", object_type_ == OBJ_SpinControl ? L"Spin" : L"Scroll");
|
||||
|
||||
CP_XML_ATTR(L"noThreeD", L"1");
|
||||
|
||||
if (linked_cell_)
|
||||
{
|
||||
std::wstring fmla = converter.convert_named_ref(*linked_cell_);
|
||||
CP_XML_ATTR(L"fmlaLink", fmla);
|
||||
}
|
||||
if (value_) CP_XML_ATTR(L"val", *value_);
|
||||
if (min_value_) CP_XML_ATTR(L"min", *min_value_);
|
||||
if (max_value_) CP_XML_ATTR(L"max", *max_value_);
|
||||
if (step_size_) CP_XML_ATTR(L"inc", *step_size_);
|
||||
if (page_step_size_)CP_XML_ATTR(L"page",*page_step_size_);
|
||||
if (orientation_)
|
||||
{
|
||||
if (*orientation_ == L"horizontal")
|
||||
CP_XML_ATTR(L"horiz", 1);
|
||||
else
|
||||
CP_XML_ATTR(L"verticalBar", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// form:item
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_item::ns = L"form";
|
||||
|
||||
@ -218,7 +218,7 @@ public:
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormElement;
|
||||
|
||||
form_element() {}
|
||||
form_element() : object_type_(0) {}
|
||||
|
||||
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);
|
||||
@ -253,6 +253,9 @@ public:
|
||||
_CP_OPT(std::wstring) xforms_bind_;
|
||||
_CP_OPT(std::wstring) current_value_;
|
||||
_CP_OPT(odf_types::Bool) dropdown_;
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
int object_type_;
|
||||
};
|
||||
|
||||
// form:button
|
||||
@ -320,6 +323,43 @@ public:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_text);
|
||||
|
||||
// form:fixed-text
|
||||
class form_fixed_text : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormFixedText;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
|
||||
virtual void docx_convert_field (oox::docx_conversion_context & Context, draw_control* draw);
|
||||
|
||||
virtual void serialize_control_props(std::wostream & strm);
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_fixed_text);
|
||||
|
||||
// form:textarea
|
||||
class form_textarea : public form_text
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormTextarea;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_textarea);
|
||||
|
||||
// form:checkbox
|
||||
class form_checkbox : public form_text
|
||||
{
|
||||
@ -352,6 +392,38 @@ public:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_checkbox);
|
||||
|
||||
// form:value-range
|
||||
class form_value_range : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormValueRange;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control *draw){}
|
||||
virtual void docx_convert_field (oox::docx_conversion_context & Context, draw_control* draw){}
|
||||
|
||||
virtual void serialize_control_props(std::wostream & strm);
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
_CP_OPT(int) min_value_;
|
||||
_CP_OPT(int) max_value_;
|
||||
_CP_OPT(int) step_size_;
|
||||
_CP_OPT(int) page_step_size_;
|
||||
_CP_OPT(std::wstring) orientation_;
|
||||
_CP_OPT(std::wstring) delay_for_repeat_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_value_range);
|
||||
|
||||
// form:combobox
|
||||
class form_combobox : public form_text
|
||||
{
|
||||
@ -442,10 +514,34 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_date);
|
||||
|
||||
// form:time
|
||||
class form_time : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormTime;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
virtual void docx_convert_sdt (oox::docx_conversion_context & Context, draw_control* draw);
|
||||
|
||||
virtual void serialize_control_props(std::wostream & strm);
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
public:
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_time);
|
||||
// form:item
|
||||
class form_item : public office_element_impl<form_item>
|
||||
{
|
||||
@ -470,7 +566,6 @@ CP_REGISTER_OFFICE_ELEMENT2(form_item);
|
||||
}
|
||||
//<form:connection-resource>7.6.2,
|
||||
//<form:file> 13.5.5,
|
||||
//<form:fixed-text> 13.5.10,
|
||||
//<form:form> 13.3,
|
||||
//<form:formatted-text> 13.5.6,
|
||||
//<form:frame> 13.5.19,
|
||||
@ -481,7 +576,3 @@ CP_REGISTER_OFFICE_ELEMENT2(form_item);
|
||||
//<form:image-frame> 13.5.20,
|
||||
//<form:number> 13.5.7,
|
||||
//<form:password> 13.5.4,
|
||||
//<form:radio> 13.5.18,
|
||||
//<form:textarea> 13.5.3,
|
||||
//<form:time>
|
||||
//<form:value-range> 13.5.24 and
|
||||
|
||||
@ -1370,9 +1370,9 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls
|
||||
if ( fill.bitmap->rId.empty())
|
||||
{
|
||||
std::wstring href = fill.bitmap->xlink_href_;
|
||||
fill.bitmap->rId = Context.get_mediaitems().add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
fill.bitmap->rId = Context.get_mediaitems()->add_or_find(href, oox::typeImage, fill.bitmap->isInternal, href);
|
||||
|
||||
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true);
|
||||
Context.get_drawing_context().get_drawings()->add(fill.bitmap->isInternal, fill.bitmap->rId, href, oox::typeImage, true, false);
|
||||
}
|
||||
|
||||
Context.get_table_context().state()->set_background(fill.bitmap->rId);
|
||||
|
||||
@ -211,7 +211,7 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
bool isMediaInternal = false;
|
||||
std::wstring ref;
|
||||
fill.bitmap->rId = Context.get_slide_context().get_mediaitems().add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
|
||||
fill.bitmap->rId = Context.get_slide_context().get_mediaitems()->add_or_find(fill.bitmap->xlink_href_, oox::typeImage, isMediaInternal, ref);
|
||||
Context.get_slide_context().add_rels(isMediaInternal, fill.bitmap->rId, ref, oox::typeImage);
|
||||
}
|
||||
oox::oox_serialize_fill(_Wostream, fill);
|
||||
|
||||
@ -39,6 +39,7 @@ core_debug {
|
||||
SOURCES += \
|
||||
../source/utils.cpp \
|
||||
../source/OdfFormat/office_document.cpp \
|
||||
../source/OdfFormat/office_forms.cpp \
|
||||
../source/OdfFormat/abstract_xml.cpp \
|
||||
../source/OdfFormat/calcext_elements.cpp \
|
||||
../source/OdfFormat/draw_base.cpp \
|
||||
@ -64,6 +65,7 @@ SOURCES += \
|
||||
../source/OdfFormat/odf_table_context.cpp \
|
||||
../source/OdfFormat/odf_table_styles_context.cpp \
|
||||
../source/OdfFormat/odf_text_context.cpp \
|
||||
../source/OdfFormat/odf_controls_context.cpp \
|
||||
../source/OdfFormat/ods_conversion_context.cpp \
|
||||
../source/OdfFormat/ods_table_context.cpp \
|
||||
../source/OdfFormat/ods_table_state.cpp \
|
||||
@ -142,6 +144,7 @@ HEADERS += \
|
||||
../source/OdfFormat/odf_table_context.h \
|
||||
../source/OdfFormat/odf_table_styles_context.h \
|
||||
../source/OdfFormat/odf_text_context.h \
|
||||
../source/OdfFormat/odf_controls_context.h \
|
||||
../source/OdfFormat/ods_conversion_context.h \
|
||||
../source/OdfFormat/ods_table_context.h \
|
||||
../source/OdfFormat/ods_table_state.h \
|
||||
@ -149,6 +152,7 @@ HEADERS += \
|
||||
../source/OdfFormat/office_annotation.h \
|
||||
../source/OdfFormat/office_body.h \
|
||||
../source/OdfFormat/office_chart.h \
|
||||
../source/OdfFormat/office_forms.h \
|
||||
../source/OdfFormat/office_elements.h \
|
||||
../source/OdfFormat/office_elements_create.h \
|
||||
../source/OdfFormat/office_elements_type.h \
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#endif
|
||||
|
||||
#include "../source/OdfFormat/office_document.cpp"
|
||||
#include "../source/OdfFormat/office_forms.cpp"
|
||||
#include "../source/OdfFormat/calcext_elements.cpp"
|
||||
#include "../source/OdfFormat/draw_base.cpp"
|
||||
#include "../source/OdfFormat/draw_frame.cpp"
|
||||
@ -49,6 +50,7 @@
|
||||
#include "../source/OdfFormat/object_package.cpp"
|
||||
#include "../source/OdfFormat/odf_chart_context.cpp"
|
||||
#include "../source/OdfFormat/odf_comment_context.cpp"
|
||||
#include "../source/OdfFormat/odf_controls_context.cpp"
|
||||
#include "../source/OdfFormat/odf_notes_context.cpp"
|
||||
#include "../source/OdfFormat/odf_conversion_context.cpp"
|
||||
#include "../source/OdfFormat/odf_drawing_context.cpp"
|
||||
|
||||
@ -578,6 +578,55 @@ void draw_connector::reset_svg_path()
|
||||
//}
|
||||
}
|
||||
///////////////////////////////////////
|
||||
// draw:control
|
||||
const wchar_t * draw_control::ns = L"draw";
|
||||
const wchar_t * draw_control::name = L"control";
|
||||
|
||||
void draw_control::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"xml:id", xml_id_);
|
||||
CP_XML_ATTR_OPT(L"draw:caption-id", caption_id_);
|
||||
CP_XML_ATTR_OPT(L"draw:control", control_id_);
|
||||
|
||||
draw_shape::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
draw_shape::serialize(CP_XML_STREAM());
|
||||
if (draw_glue_point_)
|
||||
draw_glue_point_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
void draw_control::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"draw", L"glue-point")
|
||||
{
|
||||
CP_CREATE_ELEMENT(draw_glue_point_);
|
||||
}
|
||||
else
|
||||
{
|
||||
//not_applicable_element(L"draw_enhanced_geometry", Reader, Ns, Name);
|
||||
}
|
||||
|
||||
}
|
||||
void draw_control::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeDrawGluePoint)
|
||||
{
|
||||
draw_glue_point_ = child_element;
|
||||
}
|
||||
else
|
||||
{
|
||||
//not_applicable_element(L"draw_enhanced_geometry", Reader, Ns, Name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -35,13 +35,9 @@
|
||||
|
||||
#include "common_attlists.h"
|
||||
|
||||
|
||||
namespace cpdoccore
|
||||
{
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
|
||||
class draw_shape : public draw_base
|
||||
{
|
||||
public:
|
||||
@ -64,8 +60,7 @@ public:
|
||||
int sub_type_;
|
||||
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_rect_attlist
|
||||
{
|
||||
public:
|
||||
@ -92,8 +87,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_rect);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_ellipse_attlist
|
||||
{
|
||||
public:
|
||||
@ -117,7 +111,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_ellipse);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_circle : public draw_shape
|
||||
{
|
||||
public:
|
||||
@ -131,7 +125,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_circle);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_line_attlist
|
||||
{
|
||||
public:
|
||||
@ -143,7 +137,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_line : public draw_shape
|
||||
{
|
||||
public:
|
||||
@ -160,7 +154,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_line);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_path_attlist
|
||||
{
|
||||
public:
|
||||
@ -169,7 +163,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_path : public draw_shape
|
||||
{
|
||||
public:
|
||||
@ -187,7 +181,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_path);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_polygon_attlist
|
||||
{
|
||||
public:
|
||||
@ -196,7 +190,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_polygon : public draw_shape
|
||||
{
|
||||
public:
|
||||
@ -214,9 +208,9 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_polygon);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_custom_shape : public draw_shape
|
||||
{
|
||||
public:
|
||||
@ -233,9 +227,9 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_custom_shape);
|
||||
//----------------------------------------------------------------------------------------------
|
||||
//draw:enhanced-geometry
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_equation_attlist//убрать стринги ... сделать парсинг см стр 378 оазис !!!!!!!!!!!
|
||||
{
|
||||
public:
|
||||
@ -244,7 +238,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_equation : public office_element_impl<draw_equation>
|
||||
{
|
||||
public:
|
||||
@ -265,13 +259,13 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_equation);
|
||||
////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
struct draw_handle_geometry
|
||||
{
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
//////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_handle_attlist//убрать стринги ... сделать парсинг см стр 378 оазис !!!!!!!!!!!
|
||||
{
|
||||
public:
|
||||
@ -290,7 +284,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_handle : public office_element_impl<draw_handle>
|
||||
{
|
||||
public:
|
||||
@ -312,7 +306,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_handle);
|
||||
/////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_enhanced_geometry_attlist
|
||||
{
|
||||
public:
|
||||
@ -336,7 +330,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_enhanced_geometry : public office_element_impl<draw_enhanced_geometry>
|
||||
{
|
||||
public:
|
||||
@ -371,7 +365,7 @@ public:
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_enhanced_geometry);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
|
||||
class draw_caption : public draw_shape
|
||||
{
|
||||
@ -382,11 +376,11 @@ public:
|
||||
static const ElementType type = typeDrawCaption;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_caption);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_connector_attlist
|
||||
{
|
||||
public:
|
||||
@ -396,7 +390,7 @@ public:
|
||||
|
||||
void serialize(CP_ATTR_NODE);
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_connector : public draw_line
|
||||
{
|
||||
public:
|
||||
@ -415,6 +409,30 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_connector);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_control : public draw_shape
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeDrawControl;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) xml_id_;
|
||||
_CP_OPT(std::wstring) caption_id_;
|
||||
_CP_OPT(std::wstring) control_id_;
|
||||
|
||||
office_element_ptr draw_glue_point_;
|
||||
//<svg:desc>
|
||||
//<svg:title>
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_control);
|
||||
//----------------------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@ -43,19 +43,11 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
|
||||
_mediaitems::item::item(std::wstring const & _oox_ref,
|
||||
Type _type,
|
||||
std::wstring const & _odf_ref
|
||||
)
|
||||
: oox_ref(_oox_ref),
|
||||
type(_type),
|
||||
odf_ref(_odf_ref)
|
||||
_mediaitems::item::item(const std::wstring & _oox_ref, Type _type, const std::wstring & _odf_ref)
|
||||
: oox_ref(_oox_ref), type(_type), odf_ref(_odf_ref)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wstring & odf_ref)
|
||||
{
|
||||
std::wstring output_sub_path;
|
||||
@ -119,8 +111,9 @@ void _mediaitems::add_or_find(const std::wstring & oox_ref, Type type, std::wst
|
||||
{
|
||||
count_image_object++;
|
||||
}
|
||||
item item_(input_path, type, xml::utils::replace_text_to_xml(output_path));
|
||||
|
||||
items_.push_back( item(input_path, type, xml::utils::replace_text_to_xml(output_path)) );
|
||||
items_.push_back(item_);
|
||||
}
|
||||
odf_ref = output_path;
|
||||
}
|
||||
|
||||
@ -44,39 +44,37 @@ class _mediaitems
|
||||
public:
|
||||
enum Type { typeUnknown = 0, typeImage, typeMedia, typeOleObject, typeObjectReplacement};
|
||||
|
||||
struct item
|
||||
{
|
||||
item(const std::wstring & _oox_ref, Type _type, const std::wstring & _odf_ref);
|
||||
|
||||
Type type = typeUnknown;
|
||||
|
||||
std::wstring oox_ref;
|
||||
std::wstring odf_ref;
|
||||
};
|
||||
_mediaitems()
|
||||
{
|
||||
count_image = 0;
|
||||
count_media = 0;
|
||||
count_object = 0;
|
||||
count_image_object = 0;
|
||||
count_control = 0;
|
||||
}
|
||||
|
||||
struct item
|
||||
{
|
||||
item(
|
||||
std::wstring const & _oox_ref,
|
||||
Type _type,
|
||||
std::wstring const & _odf_ref);
|
||||
|
||||
std::wstring oox_ref;
|
||||
Type type;
|
||||
std::wstring odf_ref;
|
||||
};
|
||||
typedef std::vector< item > items_array;
|
||||
|
||||
size_t count_image;
|
||||
size_t count_media;
|
||||
size_t count_object;
|
||||
size_t count_image_object;
|
||||
size_t count_control;
|
||||
|
||||
void add_or_find(const std::wstring & oox_ref, Type type, std::wstring & odf_ref);
|
||||
|
||||
void dump_rels(rels & Rels, std::wstring local_path = L"");
|
||||
items_array & items() { return items_; }
|
||||
std::vector<item> & items() { return items_; }
|
||||
|
||||
private:
|
||||
items_array items_;
|
||||
std::vector<item> items_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -385,7 +385,7 @@ void odf_chart_context::set_chart_size(_CP_OPT(double) width_pt, _CP_OPT(double)
|
||||
chart->chart_chart_attlist_.common_draw_size_attlist_.svg_width_ = length(length(*width_pt,length::pt).get_value_unit(length::cm), length::cm);
|
||||
chart->chart_chart_attlist_.common_draw_size_attlist_.svg_height_ = length(length(*height_pt,length::pt).get_value_unit(length::cm), length::cm);
|
||||
}
|
||||
void odf_chart_context::set_chart_type(std::wstring type)
|
||||
void odf_chart_context::set_chart_type(const std::wstring & type)
|
||||
{
|
||||
chart_chart *chart = impl_->get_current_chart();
|
||||
if (!chart)return;
|
||||
@ -610,7 +610,7 @@ void odf_chart_context::set_chart_scatter_type(int type)
|
||||
void odf_chart_context::start_group_series()
|
||||
{
|
||||
}
|
||||
void odf_chart_context::start_series(std::wstring type)
|
||||
void odf_chart_context::start_series(const std::wstring & type)
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"chart", L"series", elm, impl_->odf_context_);
|
||||
@ -677,6 +677,15 @@ void odf_chart_context::set_label_show_leader_line(bool val)
|
||||
void odf_chart_context::set_label_show_legend_key(bool val)
|
||||
{
|
||||
}
|
||||
void odf_chart_context::set_label_formula(const std::wstring & oox_formula) //в odf не поддерживается
|
||||
{
|
||||
std::wstring odf_formula = impl_->convert_formula(oox_formula);
|
||||
|
||||
if (!odf_formula.empty())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void odf_chart_context::set_label_show_percent(bool val)
|
||||
{
|
||||
if (!impl_->current_level_.back().chart_properties_)return;
|
||||
@ -721,7 +730,7 @@ void odf_chart_context::end_group_series()
|
||||
|
||||
if (countX < 1 && countY > 1)
|
||||
{
|
||||
impl_->axis_[0].dimension == 1;
|
||||
impl_->axis_[0].dimension = 1;
|
||||
chart_axis *axis = dynamic_cast<chart_axis*>(impl_->axis_[0].elm.get());
|
||||
axis->chart_axis_attlist_.chart_dimension_ = L"x";
|
||||
countY--;
|
||||
@ -760,7 +769,7 @@ void odf_chart_context::end_group_series()
|
||||
impl_->axis_group_series_.clear();
|
||||
}
|
||||
|
||||
void odf_chart_context::add_domain(std::wstring formula)
|
||||
void odf_chart_context::add_domain(const std::wstring & formula)
|
||||
{
|
||||
size_t level = impl_->current_level_.size();
|
||||
if (level == 0)return;
|
||||
@ -779,7 +788,7 @@ void odf_chart_context::add_domain(std::wstring formula)
|
||||
impl_->current_chart_state_.elements_.push_back(state);
|
||||
}
|
||||
|
||||
void odf_chart_context::add_categories(std::wstring odf_formula, office_element_ptr & axis)
|
||||
void odf_chart_context::add_categories(const std::wstring & odf_formula, office_element_ptr & axis)
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"chart", L"categories", elm, impl_->odf_context_);
|
||||
@ -942,26 +951,41 @@ void odf_chart_context::end_text()
|
||||
{
|
||||
odf_text_context *text_context_ = text_context();
|
||||
|
||||
if (text_context_ == NULL || impl_->current_level_.size() < 1 )return;
|
||||
if (text_context_ == NULL || impl_->current_level_.empty())return;
|
||||
|
||||
for (size_t i = 0; i < text_context_->text_elements_list_.size(); i++)
|
||||
{
|
||||
if (text_context_->text_elements_list_[i].level ==0)
|
||||
if (text_context_->text_elements_list_[i].level == 0)
|
||||
{
|
||||
impl_->current_level_.back().elm->add_child_element(text_context_->text_elements_list_[i].elm);
|
||||
}
|
||||
size_t level_root = impl_->current_level_.size() + 1;
|
||||
|
||||
odf_element_state state={text_context_->text_elements_list_[i].elm,
|
||||
text_context_->text_elements_list_[i].style_name,
|
||||
text_context_->text_elements_list_[i].style_elm,
|
||||
text_context_->text_elements_list_[i].level + level_root};
|
||||
odf_element_state state = { text_context_->text_elements_list_[i].elm,
|
||||
text_context_->text_elements_list_[i].style_name,
|
||||
text_context_->text_elements_list_[i].style_elm,
|
||||
text_context_->text_elements_list_[i].level + level_root};
|
||||
|
||||
impl_->current_chart_state_.elements_.push_back(state);
|
||||
}
|
||||
|
||||
impl_->odf_context_->end_text_context();
|
||||
}
|
||||
|
||||
void odf_chart_context::add_text(const std::wstring & val)
|
||||
{
|
||||
office_element_ptr paragr_elm;
|
||||
create_element(L"text", L"p", paragr_elm, impl_->odf_context_);
|
||||
|
||||
text_p* p = dynamic_cast<text_p*>(paragr_elm.get());
|
||||
if (p)
|
||||
p->add_text(val);
|
||||
|
||||
impl_->current_level_.back().elm->add_child_element(paragr_elm);
|
||||
|
||||
odf_element_state state = {paragr_elm, L"", office_element_ptr(), impl_->current_level_.size() + 1};
|
||||
impl_->current_chart_state_.elements_.push_back(state);
|
||||
}
|
||||
void odf_chart_context::set_textarea_vertical_align(int align)
|
||||
{
|
||||
if (!impl_->current_level_.back().chart_properties_)return;
|
||||
@ -1303,6 +1327,11 @@ void odf_chart_context::set_axis_id(unsigned int id)
|
||||
{
|
||||
if (impl_->axis_.size()>0)impl_->axis_.back().oox_id = id;
|
||||
}
|
||||
void odf_chart_context::set_axis_visible(bool val)
|
||||
{
|
||||
if (!impl_->current_level_.back().chart_properties_)return;
|
||||
impl_->current_level_.back().chart_properties_->content_.chart_visible_ = val;
|
||||
}
|
||||
void odf_chart_context::set_axis_dimension(int type)
|
||||
{
|
||||
chart_axis *axis = impl_->get_current_axis();
|
||||
@ -1394,7 +1423,7 @@ void odf_chart_context::set_layout_h(double *val,int mode)
|
||||
if (plot_area)plot_area->chart_plot_area_attlist_.common_draw_size_attlist_.svg_height_ = height_cm;
|
||||
}
|
||||
|
||||
void odf_chart_context::start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name)
|
||||
void odf_chart_context::start_element(office_element_ptr & elm, office_element_ptr & style_elm, const std::wstring & style_name)
|
||||
{
|
||||
size_t level = impl_->current_level_.size();
|
||||
|
||||
@ -1402,14 +1431,13 @@ void odf_chart_context::start_element(office_element_ptr & elm, office_element_p
|
||||
//if (impl_->current_level_.size()>0) impl_->current_level_.back()->add_child_element(elm); не надо...наследование через start_element в drawing
|
||||
|
||||
odf_element_state state={elm, style_name, style_elm, level};
|
||||
odf_chart_level_state level_state = {NULL,NULL,NULL,NULL,elm};
|
||||
odf_chart_level_state level_state = {NULL, NULL, NULL, NULL, elm};
|
||||
|
||||
impl_->current_chart_state_.elements_.push_back(state);
|
||||
|
||||
style* style_ = dynamic_cast<style*>(style_elm.get());
|
||||
if (style_)
|
||||
{
|
||||
style_name = style_->style_name_;
|
||||
level_state.chart_properties_ = style_->content_.get_style_chart_properties();
|
||||
}
|
||||
impl_->current_level_.push_back(level_state);//стоит ли сюда перенести и current_chart_properties ????
|
||||
@ -1485,7 +1513,7 @@ void odf_chart_context::end_chart()
|
||||
impl_->clear_current();
|
||||
}
|
||||
|
||||
void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
|
||||
void odf_chart_context::set_series_value_formula(const std::wstring & oox_formula)
|
||||
{
|
||||
std::wstring odf_formula = impl_->convert_formula(oox_formula);
|
||||
|
||||
@ -1502,7 +1530,7 @@ void odf_chart_context::set_series_value_formula(std::wstring oox_formula)
|
||||
}
|
||||
}
|
||||
|
||||
void odf_chart_context::set_series_label_formula(std::wstring oox_formula)
|
||||
void odf_chart_context::set_series_label_formula(const std::wstring & oox_formula)
|
||||
{
|
||||
std::wstring odf_formula = impl_->convert_formula(oox_formula);
|
||||
|
||||
@ -1518,7 +1546,7 @@ void odf_chart_context::set_series_label_formula(std::wstring oox_formula)
|
||||
}
|
||||
}
|
||||
|
||||
void odf_chart_context::set_category_axis_formula(std::wstring oox_formula, int type)
|
||||
void odf_chart_context::set_category_axis_formula(const std::wstring & oox_formula, int type)
|
||||
{
|
||||
std::wstring odf_formula = impl_->convert_formula(oox_formula);
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
odf_text_context *text_context();
|
||||
|
||||
void start_chart (office_element_ptr & root);
|
||||
void set_chart_type (std::wstring type);
|
||||
void set_chart_type (const std::wstring & type);
|
||||
void set_chart_3D (bool Val);
|
||||
void set_chart_size (_CP_OPT(double) width_pt, _CP_OPT(double) height_pt);
|
||||
void set_chart_colored (bool val);
|
||||
@ -81,10 +81,10 @@ public:
|
||||
|
||||
void start_group_series();
|
||||
void add_axis_group_series(unsigned int id);
|
||||
void start_series (std::wstring type);
|
||||
void set_series_value_formula (std::wstring oox_formula);
|
||||
void set_series_label_formula (std::wstring oox_formula);
|
||||
void set_category_axis_formula (std::wstring oox_formula,int type);
|
||||
void start_series (const std::wstring & type);
|
||||
void set_series_value_formula (const std::wstring & oox_formula);
|
||||
void set_series_label_formula (const std::wstring & oox_formula);
|
||||
void set_category_axis_formula (const std::wstring & oox_formula, int type);
|
||||
void start_data_point_series (int count);
|
||||
long get_count_data_points_series();
|
||||
|
||||
@ -93,7 +93,8 @@ public:
|
||||
void end_series();
|
||||
void end_group_series();
|
||||
|
||||
void set_label_name (std::wstring name);
|
||||
void set_label_formula (const std::wstring & oox_formula);
|
||||
void set_label_name (const std::wstring & name);
|
||||
void set_label_delete (bool val);
|
||||
void set_label_show_bubble_size (bool val);
|
||||
void set_label_show_cat_name (bool val);
|
||||
@ -116,6 +117,7 @@ public:
|
||||
void set_axis_min(double val);
|
||||
void set_axis_tick_minor(int type);
|
||||
void set_axis_tick_major(int type);
|
||||
void set_axis_visible(bool val);
|
||||
void start_title();
|
||||
void start_grid(int type);
|
||||
void start_legend();
|
||||
@ -131,9 +133,11 @@ public:
|
||||
void set_stock_loss_marker_width(std::wstring val);
|
||||
void start_stock_range_line();
|
||||
|
||||
void start_element(office_element_ptr & elm, office_element_ptr & style_elm, std::wstring style_name);
|
||||
void start_element(office_element_ptr & elm, office_element_ptr & style_elm, const std::wstring & style_name);
|
||||
void end_element();
|
||||
|
||||
void add_text(const std::wstring & val);
|
||||
|
||||
void start_text();
|
||||
void end_text();
|
||||
|
||||
@ -141,8 +145,8 @@ public:
|
||||
void set_textarea_padding (_CP_OPT(double) & left, _CP_OPT(double) & top, _CP_OPT(double) & right, _CP_OPT(double) & bottom);//in pt
|
||||
void set_textarea_rotation (double val);
|
||||
|
||||
void add_domain(std::wstring formula);
|
||||
void add_categories(std::wstring formula, office_element_ptr & axis);
|
||||
void add_domain(const std::wstring & formula);
|
||||
void add_categories(const std::wstring & formula, office_element_ptr & axis);
|
||||
|
||||
void set_layout_x(double *val,int mode);
|
||||
void set_layout_y(double *val,int mode);
|
||||
|
||||
@ -104,7 +104,7 @@ void odf_comment_context::start_comment(office_element_ptr &elm, int oox_id)
|
||||
office_annotation* comm = dynamic_cast<office_annotation*>(elm.get());
|
||||
if (!comm)return;
|
||||
|
||||
comm->office_annotation_attr_.name_ = impl_->comments_.back().odf_name;
|
||||
comm->attr_.name_ = impl_->comments_.back().odf_name;
|
||||
|
||||
|
||||
}
|
||||
@ -117,7 +117,7 @@ void odf_comment_context::end_comment(office_element_ptr &elm, int oox_id)
|
||||
office_annotation_end* comm = dynamic_cast<office_annotation_end*>(elm.get());
|
||||
if (!comm)return;
|
||||
|
||||
comm->office_annotation_attr_.name_ = impl_->comments_[i].odf_name;
|
||||
comm->attr_.name_ = impl_->comments_[i].odf_name;
|
||||
|
||||
impl_->comments_[i].state = 2;//stoped
|
||||
|
||||
@ -206,8 +206,8 @@ void odf_comment_context::set_position (double x, double y)
|
||||
|
||||
if (comm)
|
||||
{
|
||||
comm->office_annotation_attr_.svg_x_ = odf_types::length(x, odf_types::length::pt);
|
||||
comm->office_annotation_attr_.svg_y_ = odf_types::length(y, odf_types::length::pt);
|
||||
comm->attr_.svg_x_ = odf_types::length(x, odf_types::length::pt);
|
||||
comm->attr_.svg_y_ = odf_types::length(y, odf_types::length::pt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
364
ASCOfficeOdfFileW/source/OdfFormat/odf_controls_context.cpp
Normal file
364
ASCOfficeOdfFileW/source/OdfFormat/odf_controls_context.cpp
Normal file
@ -0,0 +1,364 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 "logging.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "odf_controls_context.h"
|
||||
#include "odf_conversion_context.h"
|
||||
|
||||
#include "office_forms.h"
|
||||
|
||||
#include "../../../ASCOfficeOdfFile/formulasconvert/formulasconvert.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
struct odf_control_state
|
||||
{
|
||||
office_element_ptr elm;
|
||||
odf_writer::form_element* form_elm;
|
||||
|
||||
_CP_OPT(double) cx;
|
||||
_CP_OPT(double) cy;
|
||||
|
||||
_CP_OPT(unsigned int) fill_color;
|
||||
|
||||
std::vector<office_element_ptr> properties;
|
||||
std::vector<office_element_ptr> events;
|
||||
};
|
||||
|
||||
class odf_controls_context::Impl
|
||||
{
|
||||
public:
|
||||
Impl(odf_conversion_context *odf_context) : odf_context_(odf_context)
|
||||
{
|
||||
}
|
||||
std::wstring start_control(int type, bool items_set);
|
||||
|
||||
std::vector<odf_control_state> controls_;
|
||||
|
||||
odf_conversion_context* odf_context_;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
odf_controls_context::odf_controls_context(odf_conversion_context *odf_context)
|
||||
: impl_(new odf_controls_context::Impl(odf_context))
|
||||
{
|
||||
}
|
||||
std::wstring odf_controls_context::Impl::start_control(int type, bool items_set)
|
||||
{
|
||||
office_element_ptr element;
|
||||
std::wstring control_implementation;
|
||||
switch(type)
|
||||
{
|
||||
case 0: // objectButton
|
||||
{
|
||||
create_element(L"form", L"button", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.CommandButton";
|
||||
}break;
|
||||
case 1: // objectCheckBox
|
||||
{
|
||||
create_element(L"form", L"checkbox", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.CheckBox";
|
||||
}break;
|
||||
case 2: // objectDrop
|
||||
{
|
||||
if (items_set)
|
||||
{
|
||||
create_element(L"form", L"combobox", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.ComboBox";
|
||||
}
|
||||
else
|
||||
{
|
||||
create_element(L"form", L"listbox", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.ListBox";
|
||||
}
|
||||
}break;
|
||||
case 3: // objectGBox
|
||||
{
|
||||
create_element(L"form", L"frame", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.GroupBox";
|
||||
}break;
|
||||
case 4: // objectLabel
|
||||
{
|
||||
create_element(L"form", L"fixed-text", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.FixedText";
|
||||
}break;
|
||||
case 5: // objectList
|
||||
{
|
||||
create_element(L"form", L"listbox", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.ListBox";
|
||||
}break;
|
||||
case 6: // objectRadio
|
||||
{
|
||||
create_element(L"form", L"radio", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.RadioButton";
|
||||
}break;
|
||||
case 7: // objectScroll
|
||||
{
|
||||
create_element(L"form", L"value-range", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.ScrollBar";
|
||||
}break;
|
||||
case 8: // objectSpin
|
||||
{
|
||||
create_element(L"form", L"value-range", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.SpinButton";
|
||||
}break;
|
||||
case 9: // objectEditBox
|
||||
{
|
||||
create_element(L"form", L"textarea", element, odf_context_);
|
||||
control_implementation = L"ooo:com.sun.star.form.component.TextField";
|
||||
}break;
|
||||
case 10: // objectDialog
|
||||
{
|
||||
}break;
|
||||
}
|
||||
odf_writer::form_element* form_element = dynamic_cast<odf_writer::form_element*>(element.get());
|
||||
|
||||
if (!form_element) return L"";
|
||||
|
||||
odf_context_->mediaitems()->count_control += 1;
|
||||
form_element->id_ = L"control" + std::to_wstring(odf_context_->mediaitems()->count_control);
|
||||
form_element->control_implementation_ = control_implementation;
|
||||
|
||||
odf_control_state state;
|
||||
state.elm = element;
|
||||
state.form_elm = form_element;
|
||||
|
||||
controls_.push_back(state);
|
||||
return (*form_element->id_);
|
||||
}
|
||||
|
||||
odf_controls_context::~odf_controls_context()
|
||||
{
|
||||
}
|
||||
std::wstring odf_controls_context::start_control(int type, bool items_set)
|
||||
{
|
||||
return impl_->start_control(type, items_set);
|
||||
}
|
||||
void odf_controls_context::end_control()
|
||||
{
|
||||
}
|
||||
|
||||
void odf_controls_context::set_name(const std::wstring & val)
|
||||
{
|
||||
if (val.empty()) return;
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().form_elm->name_ = val;
|
||||
}
|
||||
void odf_controls_context::set_label(const std::wstring & val)
|
||||
{
|
||||
if (val.empty()) return;
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().form_elm->label_ = val;
|
||||
}
|
||||
void odf_controls_context::set_linkedCell (const std::wstring & val)
|
||||
{
|
||||
if (val.empty()) return;
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
formulasconvert::oox2odf_converter formulas_converter;
|
||||
impl_->controls_.back().form_elm->linked_cell_ = formulas_converter.convert_named_ref(val);
|
||||
}
|
||||
void odf_controls_context::set_listFillRange (const std::wstring & val)
|
||||
{
|
||||
if (val.empty()) return;
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_listbox *listbox = dynamic_cast<odf_writer::form_listbox*>(impl_->controls_.back().form_elm);
|
||||
if (!listbox) return;
|
||||
|
||||
formulasconvert::oox2odf_converter formulas_converter;
|
||||
listbox->source_cell_range_ = formulas_converter.convert_named_ref(val);
|
||||
}
|
||||
void odf_controls_context::set_drop_size(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_listbox *listbox = dynamic_cast<odf_writer::form_listbox*>(impl_->controls_.back().form_elm);
|
||||
if (listbox) listbox->size_ = val;
|
||||
|
||||
odf_writer::form_combobox *combobox = dynamic_cast<odf_writer::form_combobox*>(impl_->controls_.back().form_elm);
|
||||
if (combobox ) combobox ->size_ = val;
|
||||
}
|
||||
void odf_controls_context::set_macro(const std::wstring & val)
|
||||
{
|
||||
if (val.empty()) return;
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
//impl_->controls_.back().form_elm-> = val;
|
||||
}
|
||||
void odf_controls_context::set_disabled (bool val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().form_elm->disabled_ = val;
|
||||
}
|
||||
void odf_controls_context::set_printable(bool val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().form_elm->printable_ = val;
|
||||
}
|
||||
void odf_controls_context::set_textHAlign(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
}
|
||||
void odf_controls_context::set_textVAlign(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
}
|
||||
void odf_controls_context::set_min_value(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_value_range *value_range = dynamic_cast<odf_writer::form_value_range*>(impl_->controls_.back().form_elm);
|
||||
if (!value_range) return;
|
||||
|
||||
value_range->min_value_ = val;
|
||||
}
|
||||
void odf_controls_context::set_max_value(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_value_range *value_range = dynamic_cast<odf_writer::form_value_range*>(impl_->controls_.back().form_elm);
|
||||
if (!value_range) return;
|
||||
|
||||
value_range->max_value_ = val;
|
||||
}
|
||||
void odf_controls_context::set_page_step(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_value_range *value_range = dynamic_cast<odf_writer::form_value_range*>(impl_->controls_.back().form_elm);
|
||||
if (!value_range) return;
|
||||
|
||||
value_range->page_step_size_ = val;
|
||||
}
|
||||
void odf_controls_context::set_step(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_value_range *value_range = dynamic_cast<odf_writer::form_value_range*>(impl_->controls_.back().form_elm);
|
||||
if (!value_range) return;
|
||||
|
||||
value_range->step_size_ = val;
|
||||
}
|
||||
void odf_controls_context::set_horiz(bool val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_value_range *value_range = dynamic_cast<odf_writer::form_value_range*>(impl_->controls_.back().form_elm);
|
||||
if (!value_range) return;
|
||||
|
||||
value_range->orientation_ = val ? odf_types::table_centering::Horizontal : odf_types::table_centering::Vertical;
|
||||
}
|
||||
void odf_controls_context::set_drop_down(bool val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().form_elm->dropdown_ = val;
|
||||
}
|
||||
void odf_controls_context::set_check_state(int val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
odf_writer::form_checkbox *checkbox = dynamic_cast<odf_writer::form_checkbox*>(impl_->controls_.back().form_elm);
|
||||
checkbox->current_state_ = (val == 1);
|
||||
}
|
||||
void odf_controls_context::set_value(const std::wstring & val)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().form_elm->value_ = val;
|
||||
}
|
||||
void odf_controls_context::set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt)
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
impl_->controls_.back().cx = width_pt;
|
||||
impl_->controls_.back().cy = height_pt;
|
||||
}
|
||||
|
||||
bool odf_controls_context::is_exist_content()
|
||||
{
|
||||
return (impl_->controls_.empty() ? false : true);
|
||||
}
|
||||
|
||||
void odf_controls_context::finalize(office_element_ptr & root_elm)//для привязки
|
||||
{
|
||||
if (impl_->controls_.empty()) return;
|
||||
|
||||
office_element_ptr elm_form;
|
||||
create_element(L"form", L"form", elm_form, impl_->odf_context_);
|
||||
|
||||
odf_writer::form_form* form = dynamic_cast<odf_writer::form_form*>(elm_form.get());
|
||||
|
||||
form->control_implementation_ = L"ooo:com.sun.star.form.component.Form";
|
||||
form->name_ = L"Form";
|
||||
form->apply_filter_ = true;
|
||||
form->command_type_ = odf_types::command_type::table;
|
||||
|
||||
for (size_t i = 0; i < impl_->controls_.size(); i++)
|
||||
{
|
||||
if (false == impl_->controls_[i].properties.empty())
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"form", L"properties", elm, impl_->odf_context_);
|
||||
|
||||
for (size_t j = 0; j < impl_->controls_[i].properties.size(); j++)
|
||||
{
|
||||
elm->add_child_element(impl_->controls_[i].properties[j]);
|
||||
}
|
||||
impl_->controls_[i].elm->add_child_element(elm);
|
||||
}
|
||||
if (false == impl_->controls_[i].events.empty())
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"office", L"event-listeners", elm, impl_->odf_context_);
|
||||
|
||||
for (size_t j = 0; j < impl_->controls_[i].events.size(); j++)
|
||||
{
|
||||
elm->add_child_element(impl_->controls_[i].events[j]);
|
||||
}
|
||||
impl_->controls_[i].elm->add_child_element(elm);
|
||||
}
|
||||
elm_form->add_child_element(impl_->controls_[i].elm);
|
||||
}
|
||||
root_elm->add_child_element(elm_form);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
ASCOfficeOdfFileW/source/OdfFormat/odf_controls_context.h
Normal file
92
ASCOfficeOdfFileW/source/OdfFormat/odf_controls_context.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <CPOptional.h>
|
||||
|
||||
#include "office_elements_create.h"
|
||||
#include "common_attlists.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer
|
||||
{
|
||||
|
||||
class odf_conversion_context;
|
||||
|
||||
class odf_controls_context
|
||||
{
|
||||
public:
|
||||
odf_controls_context(odf_conversion_context *odf_context);
|
||||
~odf_controls_context();
|
||||
|
||||
std::wstring start_control(int type, bool items_set);
|
||||
void end_control();
|
||||
|
||||
office_element_ptr & get_root_element();
|
||||
|
||||
bool is_exist_content();
|
||||
|
||||
void finalize(office_element_ptr & root_elm);
|
||||
|
||||
void set_name (const std::wstring & name);
|
||||
void set_label (const std::wstring & val);
|
||||
void set_linkedCell (const std::wstring & val);
|
||||
void set_listFillRange (const std::wstring & val);
|
||||
void set_macro (const std::wstring & val);
|
||||
void set_disabled (bool val);
|
||||
void set_printable (bool val);
|
||||
void set_textHAlign (int val);
|
||||
void set_textVAlign (int val);
|
||||
void set_min_value (int val);
|
||||
void set_max_value (int val);
|
||||
void set_page_step (int val);
|
||||
void set_step (int val);
|
||||
void set_value (const std::wstring & val);
|
||||
void set_horiz (bool val);
|
||||
void set_check_state (int val);
|
||||
void set_drop_down (bool val);
|
||||
void set_drop_size (int val);
|
||||
|
||||
void set_size( _CP_OPT(double) & width_pt, _CP_OPT(double) & height_pt);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
_CP_PTR(Impl) impl_;
|
||||
};
|
||||
typedef shared_ptr<odf_controls_context>::Type odf_controls_context_ptr;
|
||||
|
||||
}
|
||||
}
|
||||
@ -167,7 +167,9 @@ enum _drawing_part
|
||||
Unknown = 0,
|
||||
Area = 1,
|
||||
Line = 2,
|
||||
Shadow = 3
|
||||
Shadow = 3,
|
||||
Background = 4,
|
||||
Border = 5
|
||||
};
|
||||
struct odf_drawing_state
|
||||
{
|
||||
@ -1253,9 +1255,9 @@ void odf_drawing_context::end_element()
|
||||
impl_->current_level_.pop_back();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void odf_drawing_context::start_area_properties(bool reset)
|
||||
void odf_drawing_context::start_area_properties(bool bBackground)
|
||||
{
|
||||
impl_->current_drawing_part_ = Area;
|
||||
impl_->current_drawing_part_ = bBackground ? Background : Area;
|
||||
}
|
||||
void odf_drawing_context::end_area_properties()
|
||||
{
|
||||
@ -1441,6 +1443,17 @@ _CP_OPT(odf_types::color) odf_drawing_context::get_line_color()
|
||||
{
|
||||
return impl_->current_graphic_properties->svg_stroke_color_ ;
|
||||
}
|
||||
void odf_drawing_context::set_line_color(std::wstring hexColor)
|
||||
{
|
||||
if (!impl_->current_graphic_properties) return;
|
||||
if (hexColor.empty()) return;
|
||||
|
||||
size_t res = hexColor.find(L"#");
|
||||
if (std::wstring::npos == res)
|
||||
hexColor = std::wstring(L"#") + hexColor;
|
||||
|
||||
impl_->current_graphic_properties->svg_stroke_color_ = hexColor;
|
||||
}
|
||||
void odf_drawing_context::set_solid_fill(std::wstring hexColor)
|
||||
{
|
||||
if (!impl_->current_graphic_properties) return;
|
||||
@ -1452,7 +1465,12 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
|
||||
|
||||
switch(impl_->current_drawing_part_)
|
||||
{
|
||||
case Background:
|
||||
{
|
||||
impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor);
|
||||
}break;
|
||||
case Area:
|
||||
{
|
||||
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = hexColor;
|
||||
//impl_->current_graphic_properties->common_background_color_attlist_.fo_background_color_ = color(hexColor); - default transparent
|
||||
//последнее нужно - что если будут вводить текст - под текстом будет цвет фона (или он поменяется в полях текста)
|
||||
@ -1464,14 +1482,15 @@ void odf_drawing_context::set_solid_fill(std::wstring hexColor)
|
||||
}
|
||||
else
|
||||
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_fill_ = draw_fill::solid;
|
||||
break;
|
||||
}break;
|
||||
case Line:
|
||||
{
|
||||
impl_->current_graphic_properties->svg_stroke_color_ = hexColor;
|
||||
if (!impl_->current_graphic_properties->draw_stroke_)
|
||||
impl_->current_graphic_properties->draw_stroke_ = line_style(line_style::Solid);//default
|
||||
if (!impl_->current_graphic_properties->svg_stroke_width_)
|
||||
impl_->current_graphic_properties->svg_stroke_width_ = length(length(1, length::pt).get_value_unit(length::cm), length::cm);//default
|
||||
break;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2571,6 +2590,35 @@ void odf_drawing_context::start_object(std::wstring name)
|
||||
|
||||
start_element(object_elm);
|
||||
}
|
||||
void odf_drawing_context::start_control(const std::wstring& id)
|
||||
{
|
||||
office_element_ptr control_elm;
|
||||
create_element(L"draw", L"control", control_elm, impl_->odf_context_);
|
||||
|
||||
draw_control* control = dynamic_cast<draw_control*>(control_elm.get());
|
||||
if (control == NULL)return;
|
||||
|
||||
control->control_id_ = id;
|
||||
//--------------------
|
||||
impl_->styles_context_->create_style(L"", style_family::Graphic, true, false, -1);
|
||||
office_element_ptr & style_control_elm = impl_->styles_context_->last_state()->get_office_element();
|
||||
|
||||
std::wstring style_name;
|
||||
|
||||
style* style_ = dynamic_cast<style*>(style_control_elm.get());
|
||||
if (style_)
|
||||
{
|
||||
style_name = style_->style_name_;
|
||||
impl_->current_graphic_properties = style_->content_.get_graphic_properties();
|
||||
}
|
||||
control->common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_style_name_ = style_name;
|
||||
//--------------------
|
||||
start_element(control_elm);
|
||||
}
|
||||
void odf_drawing_context::end_control()
|
||||
{
|
||||
end_shape();
|
||||
}
|
||||
void odf_drawing_context::start_media(std::wstring name)
|
||||
{
|
||||
start_frame();
|
||||
@ -2617,6 +2665,7 @@ void odf_drawing_context::end_media()
|
||||
|
||||
end_frame();
|
||||
}
|
||||
|
||||
void odf_drawing_context::start_text_box()
|
||||
{
|
||||
impl_->current_drawing_state_.oox_shape_preset_ = 2000;
|
||||
|
||||
@ -149,6 +149,9 @@ public:
|
||||
void start_object_ole(std::wstring ref);
|
||||
void end_object_ole();
|
||||
|
||||
void start_control(const std::wstring& id);
|
||||
void end_control();
|
||||
|
||||
void start_media(std::wstring ref);
|
||||
void end_media();
|
||||
|
||||
@ -223,6 +226,7 @@ public:
|
||||
void set_fill_color (unsigned int color);
|
||||
|
||||
_CP_OPT(odf_types::color) get_line_color();
|
||||
void set_line_color (std::wstring hexColor);
|
||||
//void start_shadow_properties();
|
||||
//void end_shadow_properties();
|
||||
// пока одной функией ..
|
||||
|
||||
@ -62,18 +62,18 @@ namespace utils
|
||||
|
||||
void calculate_size_font_symbols(_font_metrix & metrix, NSFonts::IApplicationFonts *appFonts)
|
||||
{
|
||||
double appr_px = _graphics_utils_::calculate_size_symbol_asc(metrix.font_name, metrix.font_size, metrix.italic, metrix.bold, appFonts);
|
||||
std::pair<float,float> appr = _graphics_utils_::calculate_size_symbol_asc(metrix.font_name, metrix.font_size, metrix.italic, metrix.bold, appFonts);
|
||||
|
||||
if (appr_px <0.01)
|
||||
if (appr.first < 0.01 || appr.second < 0.01)
|
||||
{
|
||||
appr_px = _graphics_utils_::calculate_size_symbol_win(metrix.font_name,metrix.font_size,false/*metrix.italic*/,false/*metrix.bold*/);
|
||||
appr_px = ((int)(appr_px+0.5) + 2*(int)appr_px)/3.;
|
||||
appr.first = _graphics_utils_::calculate_size_symbol_win(metrix.font_name,metrix.font_size,false/*metrix.italic*/,false/*metrix.bold*/);
|
||||
appr.first = ((int)(appr.first + 0.5) + 2 * (int)appr.first)/3.;
|
||||
}
|
||||
|
||||
if (appr_px > 0)
|
||||
if (appr.first > 0)
|
||||
{
|
||||
//pixels to pt
|
||||
metrix.approx_symbol_size = appr_px ;///1.1;//"1.2" волшебное число оО
|
||||
metrix.approx_symbol_size = appr.first ;///1.1;//"1.2" волшебное число оО
|
||||
metrix.IsCalc = true;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ ods_conversion_context::ods_conversion_context(package::odf_document * outputDoc
|
||||
: odf_conversion_context (SpreadsheetDocument, outputDocument),
|
||||
table_context_(*this), current_text_context_(NULL)
|
||||
{
|
||||
font_metrix_ = _font_metrix();
|
||||
font_metrix_ = _font_metrix();
|
||||
}
|
||||
|
||||
|
||||
@ -102,6 +102,9 @@ void ods_conversion_context::end_document()
|
||||
if (table_context_.table_defined_expressions_.root)
|
||||
root_spreadsheet_->add_child_element(table_context_.table_defined_expressions_.root);
|
||||
|
||||
if (table_context_.table_content_validations_.root)
|
||||
root_spreadsheet_->add_child_element(table_context_.table_content_validations_.root);
|
||||
|
||||
odf_conversion_context::end_document();
|
||||
}
|
||||
|
||||
@ -170,10 +173,19 @@ void ods_conversion_context::set_sheet_dimension(const std::wstring & ref)
|
||||
|
||||
void ods_conversion_context::end_sheet()
|
||||
{
|
||||
if (current_table().controls_context()->is_exist_content())
|
||||
{
|
||||
office_element_ptr forms_root_elm;
|
||||
create_element(L"office", L"forms", forms_root_elm, this);
|
||||
|
||||
current_table().controls_context()->finalize(forms_root_elm);
|
||||
|
||||
current_table().add_child_element(forms_root_elm);
|
||||
}
|
||||
if (current_table().drawing_context()->is_exist_content())
|
||||
{
|
||||
office_element_ptr shapes_root_elm;
|
||||
create_element(L"table", L"shapes",shapes_root_elm,this);
|
||||
create_element(L"table", L"shapes", shapes_root_elm, this);
|
||||
|
||||
current_table().drawing_context()->finalize(shapes_root_elm);
|
||||
|
||||
@ -286,7 +298,14 @@ void ods_conversion_context::end_comment()
|
||||
current_table().end_comment(current_text_context_);
|
||||
end_text_context();
|
||||
}
|
||||
|
||||
void ods_conversion_context::set_comment_color(const std::wstring & color)
|
||||
{
|
||||
current_table().set_comment_color(color);
|
||||
}
|
||||
void ods_conversion_context::set_comment_visible(bool val)
|
||||
{
|
||||
current_table().set_comment_visible(val);
|
||||
}
|
||||
void ods_conversion_context::set_comment_rect(double l, double t, double w, double h)//in mm
|
||||
{
|
||||
current_table().set_comment_rect(l,t,w,h);
|
||||
@ -322,11 +341,34 @@ void ods_conversion_context::add_hyperlink(const std::wstring & ref, const std::
|
||||
current_table().add_hyperlink(ref, col, row, link, bLocation);
|
||||
}
|
||||
}
|
||||
|
||||
bool ods_conversion_context::start_data_validation(const std::wstring & ref, int type)
|
||||
{
|
||||
return table_context_.start_data_validation(ref, type);
|
||||
}
|
||||
void ods_conversion_context::end_data_validation()
|
||||
{
|
||||
table_context_.end_data_validation();
|
||||
}
|
||||
void ods_conversion_context::set_data_validation_allow_empty(bool val)
|
||||
{
|
||||
table_context_.set_data_validation_allow_empty(val);
|
||||
}
|
||||
void ods_conversion_context::set_data_validation_content(const std::wstring &val)
|
||||
{
|
||||
table_context_.set_data_validation_content(val);
|
||||
}
|
||||
void ods_conversion_context::set_data_validation_error(const std::wstring &title, const std::wstring &content)
|
||||
{
|
||||
table_context_.set_data_validation_error(title, content);
|
||||
}
|
||||
void ods_conversion_context::set_data_validation_promt(const std::wstring &title, const std::wstring &content)
|
||||
{
|
||||
table_context_.set_data_validation_promt(title, content);
|
||||
}
|
||||
void ods_conversion_context::add_merge_cells(const std::wstring & ref)
|
||||
{
|
||||
std::vector<std::wstring> ref_cells;
|
||||
boost::algorithm::split(ref_cells,ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(ref_cells, ref, boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
|
||||
if (ref_cells.size() != 2) return;//тута однозначно .. по правилам оохml
|
||||
|
||||
|
||||
@ -97,10 +97,19 @@ public:
|
||||
|
||||
void start_comment (int col, int row, std::wstring & author);
|
||||
void set_comment_rect (double l, double t, double w, double h);
|
||||
void set_comment_visible(bool val);
|
||||
void set_comment_color (const std::wstring & color);
|
||||
void end_comment ();
|
||||
///////////////////////////////////////////////////////
|
||||
ods_table_state & current_table() { return table_context_.state();}
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
bool start_data_validation(const std::wstring & ref, int type);
|
||||
void set_data_validation_content(const std::wstring &val);
|
||||
void set_data_validation_allow_empty(bool val);
|
||||
void set_data_validation_error(const std::wstring &title, const std::wstring &content);
|
||||
void set_data_validation_promt(const std::wstring &title, const std::wstring &content);
|
||||
void end_data_validation();
|
||||
//-----------------------------------------------------------------------
|
||||
ods_table_state & current_table() { return table_context_.state();}
|
||||
//-----------------------------------------------------------------------
|
||||
virtual void start_text_context();
|
||||
virtual void end_text_context();
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
#include "ods_conversion_context.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "../../../ASCOfficeOdfFile/formulasconvert/formulasconvert.h"
|
||||
|
||||
@ -47,6 +47,32 @@ namespace cpdoccore {
|
||||
|
||||
namespace odf_writer {
|
||||
|
||||
std::wstring getColAddress(size_t col)
|
||||
{
|
||||
static const size_t r = (L'Z' - L'A' + 1);
|
||||
std::wstring res;
|
||||
size_t r0 = col / r;
|
||||
|
||||
if (r0 > 0)
|
||||
{
|
||||
const std::wstring rest = getColAddress(col - r * r0);
|
||||
const std::wstring res = getColAddress(r0-1) + rest;
|
||||
return res;
|
||||
}
|
||||
else
|
||||
return std::wstring(1, (wchar_t)(L'A' + col));
|
||||
}
|
||||
|
||||
std::wstring getRowAddress(size_t row)
|
||||
{
|
||||
return std::to_wstring(row + 1);
|
||||
}
|
||||
|
||||
std::wstring getCellAddress(size_t col, size_t row)
|
||||
{
|
||||
return getColAddress(col) + getRowAddress(row);
|
||||
}
|
||||
|
||||
ods_table_context::ods_table_context(ods_conversion_context & Context): context_(Context)
|
||||
{
|
||||
}
|
||||
@ -125,7 +151,6 @@ void ods_table_context::set_table_part_autofilter(bool val)
|
||||
void ods_table_context::end_table_part()
|
||||
{
|
||||
}
|
||||
|
||||
void ods_table_context::add_autofilter(std::wstring ref)
|
||||
{
|
||||
if (!table_database_ranges_.root) create_element(L"table", L"database-ranges",table_database_ranges_.root,&context_);
|
||||
@ -147,6 +172,147 @@ void ods_table_context::add_autofilter(std::wstring ref)
|
||||
table_database_ranges_.elements.push_back(elm);
|
||||
|
||||
}
|
||||
bool ods_table_context::start_data_validation( const std::wstring &strRef, int type)
|
||||
{
|
||||
if (!table_content_validations_.root) create_element(L"table", L"content-validations", table_content_validations_.root, &context_);
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"content-validation", elm, &context_);
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(elm.get());
|
||||
|
||||
if (!validation) return false;
|
||||
|
||||
std::vector<std::wstring> arRefs;
|
||||
boost::algorithm::split(arRefs, strRef, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
data_validation_state validation_state;
|
||||
validation_state.name = L"DataValidation_" + std::to_wstring(state().data_validations_.size() + 1);
|
||||
validation_state.elm = elm;
|
||||
validation_state.type = type;
|
||||
|
||||
for (size_t i = 0; i < arRefs.size(); i++)
|
||||
{
|
||||
data_validation_state::_ref ref;
|
||||
ref.ref = arRefs[i];
|
||||
|
||||
size_t r = arRefs[i].rfind(L":");
|
||||
if (r == std::wstring::npos)
|
||||
{
|
||||
utils::parsing_ref (arRefs[i].substr(0, r), ref.col_start, ref.row_start);
|
||||
ref.col_end = ref.col_start;
|
||||
ref.row_end = ref.row_start;
|
||||
}
|
||||
else
|
||||
{
|
||||
utils::parsing_ref (arRefs[i].substr(0, r), ref.col_start, ref.row_start);
|
||||
utils::parsing_ref (arRefs[i].substr(r + 1, arRefs[i].size() - r), ref.col_end, ref.row_end);
|
||||
}
|
||||
|
||||
validation_state.refs.push_back(ref);
|
||||
}
|
||||
|
||||
if (validation_state.refs.empty()) return false;
|
||||
|
||||
validation->table_base_cell_address_ = state().office_table_name_ + L"." + getCellAddress(validation_state.refs[0].col_start, validation_state.refs[0].row_start);
|
||||
validation->table_name_ = validation_state.name;
|
||||
|
||||
table_content_validations_.root->add_child_element(elm);
|
||||
table_content_validations_.elements.push_back(elm);
|
||||
|
||||
state().data_validations_.push_back(validation_state);
|
||||
|
||||
return true;
|
||||
}
|
||||
void ods_table_context::set_data_validation_allow_empty(bool val)
|
||||
{
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(state().data_validations_.back().elm.get());
|
||||
validation->table_allowempty_cell_ = val;
|
||||
}
|
||||
void ods_table_context::set_data_validation_content( const std::wstring &oox_formula)
|
||||
{
|
||||
formulasconvert::oox2odf_converter formulas_converter;
|
||||
|
||||
std::wstring odf_formula = formulas_converter.convert_formula(oox_formula);
|
||||
|
||||
if (false == odf_formula.empty())
|
||||
{
|
||||
odf_formula = odf_formula.substr(4);
|
||||
}
|
||||
table_content_validation *validation = dynamic_cast<table_content_validation*>(state().data_validations_.back().elm.get());
|
||||
|
||||
switch (state().data_validations_.back().type)
|
||||
{
|
||||
case 0://SimpleTypes::spreadsheet::validationTypeNone:
|
||||
break;
|
||||
case 1://SimpleTypes::spreadsheet::validationTypeCustom:
|
||||
break;
|
||||
case 2://SimpleTypes::spreadsheet::validationTypeDate:
|
||||
{
|
||||
odf_formula = L"of:cell-content-is-date(" + odf_formula + L")";
|
||||
}break;
|
||||
case 3://SimpleTypes::spreadsheet::validationTypeDecimal:
|
||||
{
|
||||
odf_formula = L"of:cell-content-is-decimal-number(" + odf_formula + L")";
|
||||
}break;
|
||||
case 4://SimpleTypes::spreadsheet::validationTypeList:
|
||||
{
|
||||
odf_formula = L"of:cell-content-is-in-list(" + odf_formula + L")";
|
||||
}break;
|
||||
case 5://SimpleTypes::spreadsheet::validationTypeTextLength:
|
||||
break;
|
||||
case 6://SimpleTypes::spreadsheet::validationTypeTime:
|
||||
{
|
||||
odf_formula = L"of:cell-content-is-time(" + odf_formula + L")";
|
||||
}break;
|
||||
case 7://SimpleTypes::spreadsheet::validationTypeWhole:
|
||||
{
|
||||
odf_formula = L"of:cell-content-is-whole-number(" + odf_formula + L")";
|
||||
}break;
|
||||
}
|
||||
state().data_validations_.back().condition = odf_formula;
|
||||
validation->table_condition_ = odf_formula;
|
||||
}
|
||||
void ods_table_context::set_data_validation_error(const std::wstring &title, const std::wstring &content)
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"error-message", elm, &context_);
|
||||
|
||||
table_content_validations_.elements.back()->add_child_element(elm);
|
||||
|
||||
table_error_message *error_message = dynamic_cast<table_error_message*>(elm.get());
|
||||
|
||||
if (error_message)
|
||||
{
|
||||
error_message->table_display_ = true;
|
||||
if (false == title.empty()) error_message->table_title_ = title;
|
||||
|
||||
if (false == content.empty())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
void ods_table_context::set_data_validation_promt(const std::wstring &title, const std::wstring &content)
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"help-message", elm, &context_);
|
||||
|
||||
table_content_validations_.elements.back()->add_child_element(elm);
|
||||
|
||||
table_help_message *help_message = dynamic_cast<table_help_message*>(elm.get());
|
||||
|
||||
if (help_message)
|
||||
{
|
||||
help_message->table_display_ = true;
|
||||
if (false == title.empty()) help_message->table_title_ = title;
|
||||
if (false == content.empty())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
void ods_table_context::end_data_validation()
|
||||
{
|
||||
}
|
||||
|
||||
void ods_table_context::start_defined_expressions(office_element_ptr & root_elm)
|
||||
{
|
||||
table_defined_expressions_.root = root_elm;
|
||||
@ -164,14 +330,14 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
|
||||
|
||||
std::wstring odf_range = formulas_converter.convert_named_ref(cell_range);//todo - разделить конвертацию диапазонов/рэнжей на c [] и без
|
||||
|
||||
std::wstring odf_base_cell = formulas_converter.get_table_name() + L".$A$1";
|
||||
std::wstring odf_base_cell = formulas_converter.get_table_name();
|
||||
|
||||
named_range->table_name_ = name;
|
||||
named_range->table_cell_range_address_ = odf_range;
|
||||
if (printable)
|
||||
named_range->table_range_usable_as_ = L"print-range";
|
||||
|
||||
if (odf_base_cell.length() > 0)
|
||||
if (false == odf_base_cell.empty())
|
||||
named_range->table_base_cell_address_ = odf_base_cell;
|
||||
|
||||
table_defined_expressions_.elements.push_back(elm);
|
||||
@ -197,23 +363,29 @@ void ods_table_context::add_defined_range(const std::wstring & name, const std::
|
||||
}
|
||||
void ods_table_context::add_defined_expression(const std::wstring & name, const std::wstring & value, int sheet_id, bool printable)
|
||||
{
|
||||
formulasconvert::oox2odf_converter formulas_converter;
|
||||
|
||||
bool simple_range = formulas_converter.is_simple_ref(value);
|
||||
|
||||
if (simple_range)//если простой - range, составной - выражение
|
||||
return add_defined_range (name, value, sheet_id, printable);
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"table", L"named-expression",elm, &context_);
|
||||
|
||||
table_named_expression* named_expression = dynamic_cast<table_named_expression*>(elm.get());
|
||||
if (named_expression == NULL)return;
|
||||
|
||||
formulasconvert::oox2odf_converter formulas_converter;
|
||||
|
||||
std::wstring odf_value = formulas_converter.convert_named_formula(value);
|
||||
std::wstring odf_base_cell = formulas_converter.get_table_name() + L".$A$1";
|
||||
std::wstring odf_base_cell = formulas_converter.get_table_name();
|
||||
|
||||
named_expression->table_name_ = name;
|
||||
named_expression->table_expression_ = odf_value;
|
||||
|
||||
if (sheet_id >=0 && sheet_id < table_state_list_.size())
|
||||
{
|
||||
odf_base_cell = table_state_list_[sheet_id].office_table_name_ + L".$A$1";
|
||||
odf_base_cell = L"$" + table_state_list_[sheet_id].office_table_name_ + L".$A$1";
|
||||
table_state_list_[sheet_id].add_definded_expression(elm);
|
||||
|
||||
if ( printable)
|
||||
|
||||
@ -34,10 +34,7 @@
|
||||
#include <string>
|
||||
#include "ods_table_state.h"
|
||||
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
|
||||
namespace odf_writer {
|
||||
|
||||
class ods_conversion_context;
|
||||
@ -77,6 +74,12 @@ public:
|
||||
void add_table_part_column(std::wstring name);
|
||||
void end_table_part();
|
||||
|
||||
bool start_data_validation(const std::wstring &ref, int type);
|
||||
void set_data_validation_content(const std::wstring &val);
|
||||
void set_data_validation_allow_empty(bool val);
|
||||
void set_data_validation_error(const std::wstring &title, const std::wstring &content);
|
||||
void set_data_validation_promt(const std::wstring &title, const std::wstring &content);
|
||||
void end_data_validation();
|
||||
private:
|
||||
|
||||
ods_conversion_context & context_;
|
||||
@ -85,6 +88,7 @@ private:
|
||||
|
||||
table_additional_elements_state table_defined_expressions_;
|
||||
table_additional_elements_state table_database_ranges_;
|
||||
table_additional_elements_state table_content_validations_;
|
||||
|
||||
friend class ods_conversion_context;
|
||||
|
||||
|
||||
@ -49,7 +49,6 @@
|
||||
#include "style_table_properties.h"
|
||||
#include "style_text_properties.h"
|
||||
#include "style_paragraph_properties.h"
|
||||
#include "style_graphic_properties.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
@ -140,7 +139,8 @@ std::wstring convert_time(const std::wstring & oox_time)
|
||||
///////////////////////////////////////////////////////////////
|
||||
static formulasconvert::oox2odf_converter formulas_converter_table;
|
||||
|
||||
ods_table_state::ods_table_state(odf_conversion_context * Context, office_element_ptr & elm): context_(Context),drawing_context_(Context)
|
||||
ods_table_state::ods_table_state(odf_conversion_context * Context, office_element_ptr & elm) :
|
||||
context_(Context), drawing_context_(Context), controls_context_(Context)
|
||||
{
|
||||
office_table_ = elm;
|
||||
|
||||
@ -495,15 +495,19 @@ void ods_table_state::set_row_height(double height)
|
||||
|
||||
bool ods_table_state::is_cell_hyperlink()
|
||||
{
|
||||
if (cells_size_ <1)return false;
|
||||
return cells_.back().hyperlink_idx >=0 ? true : false;
|
||||
if ( cells_size_ < 1 )return false;
|
||||
return cells_.back().hyperlink_idx >= 0 ? true : false;
|
||||
}
|
||||
bool ods_table_state::is_cell_comment()
|
||||
{
|
||||
if (cells_size_ <1)return false;
|
||||
if ( cells_size_ < 1 )return false;
|
||||
return cells_.back().comment_idx >= 0 ? true : false;
|
||||
}
|
||||
|
||||
bool ods_table_state::is_cell_data_validation()
|
||||
{
|
||||
if ( cells_size_ < 1 )return false;
|
||||
return cells_.back().data_validation_name.empty() ? true : false;
|
||||
}
|
||||
int ods_table_state::is_cell_hyperlink(int col, int row)
|
||||
{
|
||||
for (size_t i = 0; i < hyperlinks_.size(); i++)
|
||||
@ -515,6 +519,17 @@ int ods_table_state::is_cell_hyperlink(int col, int row)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
std::wstring ods_table_state::is_cell_data_validation(int col, int row)
|
||||
{
|
||||
for (size_t i = 0; i < data_validations_.size(); i++)
|
||||
{
|
||||
if (data_validations_[i].in_ref(col, row))
|
||||
{
|
||||
return data_validations_[i].name;
|
||||
}
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
int ods_table_state::is_cell_comment(int col, int row, unsigned int repeate_col)
|
||||
{
|
||||
for (size_t i = 0; i < comments_.size(); i++)
|
||||
@ -532,7 +547,7 @@ int ods_table_state::is_row_comment(int row, int repeate_row)
|
||||
{
|
||||
if (comments_[i].row < row + repeate_row && comments_[i].row >= row && comments_[i].used == false)
|
||||
{
|
||||
return i;
|
||||
return (int)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -615,8 +630,9 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
|
||||
state.elm = elm; state.repeated = 1; state.style_name = style_name; state.style_elm = style_elm;
|
||||
state.row = current_table_row_; state.col = current_table_column_ + 1;
|
||||
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
|
||||
state.comment_idx = is_cell_comment(state.col, state.row);
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, state.row);
|
||||
state.comment_idx = is_cell_comment(state.col, state.row);
|
||||
state.data_validation_name = is_cell_data_validation(state.col, state.row);
|
||||
|
||||
current_table_column_ += state.repeated;
|
||||
cells_.push_back(state);
|
||||
@ -705,20 +721,51 @@ void ods_table_state::start_comment(int col, int row, std::wstring & author)
|
||||
state.row = row; state.col = col; state.author = author;
|
||||
create_element(L"office", L"annotation", state.elm, context_);
|
||||
|
||||
office_annotation * annotation = dynamic_cast<office_annotation*>(state.elm.get());
|
||||
if (!annotation)return;
|
||||
|
||||
context_->styles_context()->create_style(L"", style_family::Graphic, true, false, -1);
|
||||
|
||||
office_element_ptr & style_elm = context_->styles_context()->last_state()->get_office_element();
|
||||
state.graphic_properties = context_->styles_context()->last_state()->get_graphic_properties();
|
||||
|
||||
style* style_ = dynamic_cast<style*>(style_elm.get());
|
||||
if (style_)
|
||||
{
|
||||
annotation->attr_.draw_style_name_ = style_->style_name_;
|
||||
}
|
||||
|
||||
comments_.push_back(state);
|
||||
}
|
||||
void ods_table_state::set_comment_color(const std::wstring & color)
|
||||
{
|
||||
if (color.empty()) return;
|
||||
if (comments_.empty()) return;
|
||||
if (!comments_.back().graphic_properties) return;
|
||||
|
||||
comments_.back().graphic_properties->common_draw_fill_attlist_.draw_fill_color_ = L"#" + color;
|
||||
comments_.back().graphic_properties->common_draw_fill_attlist_.draw_fill_ = odf_types::draw_fill::solid;
|
||||
}
|
||||
void ods_table_state::set_comment_visible(bool val)
|
||||
{
|
||||
if (comments_.empty()) return;
|
||||
|
||||
office_annotation * annotation = dynamic_cast<office_annotation*>(comments_.back().elm.get());
|
||||
if (!annotation)return;
|
||||
|
||||
annotation->attr_.display_ = val;
|
||||
}
|
||||
void ods_table_state::set_comment_rect(double l, double t, double w, double h)
|
||||
{
|
||||
if (comments_.size() < 1)return;
|
||||
if (comments_.empty())return;
|
||||
|
||||
office_annotation * annotation = dynamic_cast<office_annotation*>(comments_.back().elm.get());
|
||||
if (!annotation)return;
|
||||
|
||||
annotation->office_annotation_attr_.svg_y_ = length(t/10.,length::cm);
|
||||
annotation->office_annotation_attr_.svg_x_ = length(l/10.,length::cm);
|
||||
annotation->office_annotation_attr_.svg_width_ = length(w/10.,length::cm);
|
||||
annotation->office_annotation_attr_.svg_height_ = length(h/10.,length::cm);
|
||||
annotation->attr_.svg_y_ = length(t/10.,length::cm);
|
||||
annotation->attr_.svg_x_ = length(l/10.,length::cm);
|
||||
annotation->attr_.svg_width_ = length(w/10.,length::cm);
|
||||
annotation->attr_.svg_height_ = length(h/10.,length::cm);
|
||||
}
|
||||
void ods_table_state::end_comment(odf_text_context *text_context)
|
||||
{
|
||||
@ -755,7 +802,7 @@ void ods_table_state::check_spanned_cells()
|
||||
int start_col = jt->first;
|
||||
int end_col = jt->first + jt->second.spanned_cols;
|
||||
|
||||
for (size_t i = 0; i < cells_.size(); ++i)
|
||||
for (size_t i = 0; i < cells_.size(); ++i) //todooo cells_ vector -> map by row
|
||||
{
|
||||
if (cells_[i].row > end_row) break;
|
||||
|
||||
@ -878,7 +925,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
|
||||
|
||||
//test external link
|
||||
bool bExternal = !ods_context->externals_.empty();
|
||||
boost::wregex re(L"([\[]\\d+[\]])+");
|
||||
boost::wregex re(L"([\\[]\\d+[\\]])+");
|
||||
|
||||
while(bExternal)
|
||||
{
|
||||
@ -995,7 +1042,7 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
|
||||
|
||||
std::wstring odf_formula;
|
||||
|
||||
if (formula.size() > 0)
|
||||
if (false == formula.empty())
|
||||
{
|
||||
odf_formula = formulas_converter_table.convert_formula(formula);
|
||||
|
||||
@ -1003,14 +1050,14 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
|
||||
|
||||
std::vector<std::wstring> distance;
|
||||
boost::algorithm::split(distance, ref,boost::algorithm::is_any_of(L":"), boost::algorithm::token_compress_on);
|
||||
if (distance.size() >1)
|
||||
if (distance.size() > 1)
|
||||
{
|
||||
int col1, row1, col2, row2;
|
||||
utils::parsing_ref(distance[0],col1,row1);
|
||||
utils::parsing_ref(distance[1],col2,row2);
|
||||
|
||||
if (row2-row1 >0)moving_type = 2;
|
||||
if (col2-col1 >0)moving_type = 1;
|
||||
if (row2 - row1 > 0) moving_type = 2;
|
||||
if (col2 - col1 > 0)moving_type = 1;
|
||||
}
|
||||
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
|
||||
shared_formulas_.push_back(state);
|
||||
@ -1289,6 +1336,11 @@ void ods_table_state::end_cell()
|
||||
cells_.back().elm->add_child_element(comm_elm);
|
||||
comments_[cells_.back().comment_idx].used = true;
|
||||
}
|
||||
if (false == cells_.back().data_validation_name.empty())
|
||||
{
|
||||
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
|
||||
if (cell)cell->attlist_.table_content_validation_name_ = cells_.back().data_validation_name;
|
||||
}
|
||||
if (cells_.back().empty)
|
||||
{
|
||||
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
|
||||
@ -1404,8 +1456,9 @@ void ods_table_state::add_default_cell( unsigned int repeated)
|
||||
state.row = current_table_row_;
|
||||
state.col = current_table_column_ + 1;
|
||||
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
|
||||
state.comment_idx = comment_idx;
|
||||
state.hyperlink_idx = is_cell_hyperlink(state.col, current_table_row_);
|
||||
state.data_validation_name = is_cell_data_validation(state.col, current_table_row_);
|
||||
state.comment_idx = comment_idx;
|
||||
|
||||
cells_.push_back(state);
|
||||
cells_size_++;
|
||||
|
||||
@ -40,8 +40,10 @@
|
||||
#include"../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
#include "odf_drawing_context.h"
|
||||
#include "odf_controls_context.h"
|
||||
|
||||
#include "office_elements_create.h"
|
||||
#include "style_graphic_properties.h"
|
||||
|
||||
#include "officevaluetype.h"
|
||||
|
||||
@ -184,6 +186,8 @@ struct ods_cell_state : ods_element_state
|
||||
|
||||
int hyperlink_idx = -1;
|
||||
int comment_idx = -1;
|
||||
|
||||
std::wstring data_validation_name;
|
||||
|
||||
bool empty = true;
|
||||
};
|
||||
@ -205,6 +209,8 @@ struct ods_comment_state
|
||||
|
||||
office_element_ptr elm;
|
||||
|
||||
graphic_format_properties *graphic_properties = NULL;
|
||||
|
||||
bool used = false;
|
||||
};
|
||||
struct ods_shared_formula_state
|
||||
@ -237,6 +243,37 @@ struct table_part_state
|
||||
|
||||
std::vector<std::pair<std::wstring, std::wstring>> columns; //name, odf_ref
|
||||
};
|
||||
struct data_validation_state
|
||||
{
|
||||
std::wstring name;
|
||||
int type;
|
||||
|
||||
office_element_ptr elm;
|
||||
|
||||
struct _ref
|
||||
{
|
||||
std::wstring ref;
|
||||
int col_start = 0;
|
||||
int row_start = 0;
|
||||
|
||||
int col_end = 0;
|
||||
int row_end = 0;
|
||||
};
|
||||
std::vector<_ref> refs;
|
||||
|
||||
std::wstring condition;
|
||||
|
||||
bool in_ref(int col, int row)
|
||||
{
|
||||
for (size_t i = 0; i < refs.size(); i++)
|
||||
{
|
||||
if (col >= refs[i].col_start && col <= refs[i].col_end && row >= refs[i].row_start && row <= refs[i].row_end)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
struct ods_array_formula_state
|
||||
{
|
||||
std::wstring formula;
|
||||
@ -334,6 +371,8 @@ public:
|
||||
|
||||
void start_comment(int col, int row, std::wstring & author);
|
||||
void set_comment_rect(double l, double t, double w, double h);
|
||||
void set_comment_visible(bool val);
|
||||
void set_comment_color(const std::wstring & color);
|
||||
void end_comment(odf_text_context *text_context);
|
||||
|
||||
void set_merge_cells(int start_col, int start_row, int end_col, int end_row);
|
||||
@ -341,11 +380,14 @@ public:
|
||||
office_element_ptr & current_row_element();
|
||||
office_element_ptr & current_cell_element();
|
||||
|
||||
bool is_cell_hyperlink ();
|
||||
int is_cell_hyperlink (int col, int row);
|
||||
bool is_cell_comment ();
|
||||
int is_cell_comment (int col, int row, unsigned int repeate_col = 1);
|
||||
int is_row_comment (int row, int repeate_row = 1);
|
||||
bool is_cell_data_validation();
|
||||
bool is_cell_hyperlink();
|
||||
bool is_cell_comment();
|
||||
|
||||
int is_cell_hyperlink(int col, int row);
|
||||
int is_cell_comment(int col, int row, unsigned int repeate_col = 1);
|
||||
int is_row_comment(int row, int repeate_row = 1);
|
||||
std::wstring is_cell_data_validation(int col, int row);
|
||||
|
||||
unsigned int get_last_row_repeated ();
|
||||
|
||||
@ -362,7 +404,8 @@ public:
|
||||
|
||||
void convert_position(oox_table_position & oox_pos, double & x, double & y);
|
||||
|
||||
odf_drawing_context * drawing_context(){return &drawing_context_;}
|
||||
odf_drawing_context* drawing_context(){return &drawing_context_;}
|
||||
odf_controls_context* controls_context(){return &controls_context_;}
|
||||
|
||||
std::wstring office_table_name_;
|
||||
std::vector<ods_comment_state> comments_;
|
||||
@ -384,7 +427,7 @@ private:
|
||||
std::vector<_covered_info> current_covered_rows_;
|
||||
int current_covered_cols_;
|
||||
|
||||
odf_conversion_context * context_;
|
||||
odf_conversion_context *context_;
|
||||
|
||||
office_element_ptr office_table_;
|
||||
style* office_table_style_;//??? может хранить как office_element_ptr ???
|
||||
@ -401,6 +444,7 @@ private:
|
||||
std::vector<ods_element_state> columns_;
|
||||
std::vector<ods_element_state> rows_;
|
||||
|
||||
// row column
|
||||
std::map<int, std::map<int, _spanned_info>> map_merged_cells;
|
||||
|
||||
std::vector<office_element_ptr> current_level_;//постоянно меняющийся список уровней ("0-й элемент - сама таблица)
|
||||
@ -413,7 +457,10 @@ private:
|
||||
|
||||
std::vector<table_part_state> table_parts_;
|
||||
|
||||
std::vector<data_validation_state> data_validations_;
|
||||
|
||||
odf_drawing_context drawing_context_;
|
||||
odf_controls_context controls_context_;
|
||||
|
||||
friend class ods_table_context;
|
||||
|
||||
|
||||
@ -62,15 +62,15 @@ namespace utils
|
||||
|
||||
double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name, double font_size, NSFonts::IApplicationFonts *appFonts)
|
||||
{
|
||||
double appr_px = _graphics_utils_::calculate_size_symbol_asc(font_name, font_size, false, false, appFonts);
|
||||
std::pair<float,float> appr = _graphics_utils_::calculate_size_symbol_asc(font_name, font_size, false, false, appFonts);
|
||||
|
||||
if (appr_px <0.01)
|
||||
if (appr.first < 0.01 || appr.second < 0.01)
|
||||
{
|
||||
appr_px = _graphics_utils_::calculate_size_symbol_win(font_name, font_size, false, false, str_test);
|
||||
appr.first = _graphics_utils_::calculate_size_symbol_win(font_name, font_size, false, false, str_test);
|
||||
//appr_px = ((int)(appr_px+0.5) + 2*(int)appr_px)/3.;
|
||||
}
|
||||
|
||||
return appr_px*0.55;
|
||||
return appr.first * 0.55;
|
||||
}
|
||||
}
|
||||
odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument)
|
||||
|
||||
@ -142,7 +142,7 @@ void office_annotation_end::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
office_annotation_attr_.serialize(CP_GET_XML_NODE());
|
||||
attr_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,7 +152,7 @@ void office_annotation::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
office_annotation_attr_.serialize(CP_GET_XML_NODE());
|
||||
attr_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
if (dc_creator_)dc_creator_->serialize(CP_XML_STREAM());
|
||||
if (dc_date_) dc_date_->serialize(CP_XML_STREAM());
|
||||
@ -203,7 +203,7 @@ void officeooo_annotation::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
office_annotation_attr_.serialize(CP_GET_XML_NODE());
|
||||
attr_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
if (dc_creator_)dc_creator_->serialize(CP_XML_STREAM());
|
||||
if (dc_date_) dc_date_->serialize(CP_XML_STREAM());
|
||||
|
||||
@ -122,7 +122,7 @@ public:
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_annotation_attr office_annotation_attr_;
|
||||
office_annotation_attr attr_;
|
||||
|
||||
private:
|
||||
office_element_ptr_array content_;
|
||||
@ -148,7 +148,7 @@ public:
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_annotation_attr office_annotation_attr_;
|
||||
office_annotation_attr attr_;
|
||||
//
|
||||
//private:
|
||||
// office_element_ptr_array content_;
|
||||
@ -176,7 +176,7 @@ public:
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
private:
|
||||
office_annotation_attr office_annotation_attr_;
|
||||
office_annotation_attr attr_;
|
||||
office_element_ptr_array content_;
|
||||
|
||||
office_element_ptr dc_date_;
|
||||
|
||||
568
ASCOfficeOdfFileW/source/OdfFormat/office_forms.cpp
Normal file
568
ASCOfficeOdfFileW/source/OdfFormat/office_forms.cpp
Normal file
@ -0,0 +1,568 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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_forms.h"
|
||||
#include "draw_frame.h"
|
||||
//#include "text_content.h"
|
||||
|
||||
#include <xml/xmlchar.h>
|
||||
#include <xml/attributes.h>
|
||||
#include <xml/utils.h>
|
||||
|
||||
#include "../../../ASCOfficeOdfFile/formulasconvert/formulasconvert.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
// office:forms
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * office_forms::ns = L"office";
|
||||
const wchar_t * office_forms::name = L"forms";
|
||||
|
||||
void office_forms::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"form:apply-design-mode", apply_design_mode_);
|
||||
CP_XML_ATTR_OPT(L"form:automatic-focus", automatic_focus_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void office_forms::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void office_forms::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
// form:form
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_form::ns = L"form";
|
||||
const wchar_t * form_form::name = L"form";
|
||||
|
||||
void form_form::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"form:allow-deletes", allow_deletes_);
|
||||
CP_XML_ATTR_OPT(L"form:allow-inserts", allow_inserts_);
|
||||
CP_XML_ATTR_OPT(L"form:allow-updates", allow_updates_);
|
||||
CP_XML_ATTR_OPT(L"form:apply-filter", apply_filter_);
|
||||
CP_XML_ATTR_OPT(L"form:command", command_);
|
||||
CP_XML_ATTR_OPT(L"form:command_type", command_type_);
|
||||
CP_XML_ATTR_OPT(L"form:control-implementation", control_implementation_);
|
||||
CP_XML_ATTR_OPT(L"form:datasource", datasource_);
|
||||
CP_XML_ATTR_OPT(L"form:detail-fields", detail_fields_);
|
||||
CP_XML_ATTR_OPT(L"form:enctype", enctype_);
|
||||
CP_XML_ATTR_OPT(L"form:escape-processing", escape_processing_);
|
||||
CP_XML_ATTR_OPT(L"form:filter", filter_);
|
||||
CP_XML_ATTR_OPT(L"form:ignore-result", ignore_result_);
|
||||
CP_XML_ATTR_OPT(L"form:master-fields", master_fields_);
|
||||
CP_XML_ATTR_OPT(L"form:method", method_);
|
||||
CP_XML_ATTR_OPT(L"form:name", name_);
|
||||
CP_XML_ATTR_OPT(L"form:navigation-mode", navigation_mode_);
|
||||
CP_XML_ATTR_OPT(L"form:order", order_);
|
||||
CP_XML_ATTR_OPT(L"form:tabcycle", tabcycle_);
|
||||
|
||||
CP_XML_ATTR_OPT(L"office:target-frame", office_target_frame_);
|
||||
|
||||
xlink_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_)
|
||||
{
|
||||
properties_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
if (office_event_listeners_)
|
||||
{
|
||||
office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void form_form::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"form", L"properties")
|
||||
{
|
||||
CP_CREATE_ELEMENT(properties_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"office", L"event-listeners")
|
||||
{
|
||||
CP_CREATE_ELEMENT(office_event_listeners_);
|
||||
}
|
||||
else
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void form_form::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
switch(child_element->get_type())
|
||||
{
|
||||
case typeFormProperties:
|
||||
properties_ = child_element;
|
||||
break;
|
||||
case typeOfficeEventListeners:
|
||||
office_event_listeners_ = child_element;
|
||||
break;
|
||||
default:
|
||||
content_.push_back(child_element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// form:properties
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_properties::ns = L"form";
|
||||
const wchar_t * form_properties::name = L"properties";
|
||||
|
||||
void form_properties::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void form_properties::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void form_properties::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:property
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_property::ns = L"form";
|
||||
const wchar_t * form_property::name = L"property";
|
||||
|
||||
void form_property::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"form:property-name", property_name_);
|
||||
value_and_type_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// form:list-property
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_list_property::ns = L"form";
|
||||
const wchar_t * form_list_property::name = L"list-property";
|
||||
|
||||
void form_list_property::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"form:property-name", property_name_);
|
||||
CP_XML_ATTR_OPT(L"form:value-type", value_type_);
|
||||
}
|
||||
}
|
||||
}
|
||||
void form_list_property::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void form_list_property::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
// form:list-value
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_list_value::ns = L"form";
|
||||
const wchar_t * form_list_value::name = L"list-value";
|
||||
|
||||
void form_list_value::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
value_and_type_.serialize(CP_GET_XML_NODE());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_element::ns = L"form";
|
||||
const wchar_t * form_element::name = L"element";
|
||||
|
||||
void form_element::serialize_attlist(CP_ATTR_NODE)
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"form:name", name_);
|
||||
CP_XML_ATTR_OPT(L"form:control-implementation", control_implementation_);
|
||||
CP_XML_ATTR_OPT(L"form:data-field", data_field_);
|
||||
CP_XML_ATTR_OPT(L"form:linked-cell", linked_cell_);
|
||||
CP_XML_ATTR_OPT(L"form:disabled", disabled_);
|
||||
CP_XML_ATTR_OPT(L"form:id", id_);
|
||||
CP_XML_ATTR_OPT(L"form:label", label_);
|
||||
CP_XML_ATTR_OPT(L"form:printable", printable_);
|
||||
CP_XML_ATTR_OPT(L"form:tab-index", tab_index_);
|
||||
CP_XML_ATTR_OPT(L"form:tab-stop", tab_stop_);
|
||||
CP_XML_ATTR_OPT(L"form:title", title_);
|
||||
CP_XML_ATTR_OPT(L"form:value", value_);
|
||||
CP_XML_ATTR_OPT(L"form:current-value", current_value_);
|
||||
CP_XML_ATTR_OPT(L"form:dropdown", dropdown_);
|
||||
CP_XML_ATTR_OPT(L"xml:id", xml_id_);
|
||||
CP_XML_ATTR_OPT(L"xforms:bind", xforms_bind_);
|
||||
}
|
||||
void form_element::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"form", L"properties")
|
||||
{
|
||||
CP_CREATE_ELEMENT(properties_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"office", L"event-listeners")
|
||||
{
|
||||
CP_CREATE_ELEMENT(office_event_listeners_);
|
||||
}
|
||||
}
|
||||
void form_element::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
switch(child_element->get_type())
|
||||
{
|
||||
case typeFormProperties:
|
||||
properties_ = child_element;
|
||||
break;
|
||||
case typeOfficeEventListeners:
|
||||
office_event_listeners_ = child_element;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// form:button
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_button::ns = L"form";
|
||||
const wchar_t * form_button::name = L"button";
|
||||
|
||||
void form_button::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:text
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_text::ns = L"form";
|
||||
const wchar_t * form_text::name = L"text";
|
||||
|
||||
void form_text::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:textarea
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_textarea::ns = L"form";
|
||||
const wchar_t * form_textarea::name = L"textarea";
|
||||
|
||||
void form_textarea::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:fixed-text
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_fixed_text::ns = L"form";
|
||||
const wchar_t * form_fixed_text::name = L"fixed-text";
|
||||
|
||||
void form_fixed_text::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
// form:radio
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_radio::ns = L"form";
|
||||
const wchar_t * form_radio::name = L"radio";
|
||||
|
||||
void form_radio::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
// form:checkbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_checkbox::ns = L"form";
|
||||
const wchar_t * form_checkbox::name = L"checkbox";
|
||||
|
||||
void form_checkbox::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (current_state_)
|
||||
CP_XML_ATTR(L"form:current-state", L"checked" );
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
// form:combobox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_combobox::ns = L"form";
|
||||
const wchar_t * form_combobox::name = L"combobox";
|
||||
|
||||
void form_combobox::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
CP_XML_ATTR_OPT(L"form:source-cell-range", source_cell_range_);
|
||||
CP_XML_ATTR_OPT(L"form:list-source", list_source_);
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
void form_combobox::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"form", L"item")
|
||||
{
|
||||
CP_CREATE_ELEMENT(items_);
|
||||
}
|
||||
else
|
||||
{
|
||||
form_element::create_child_element(Ns, Name);
|
||||
}
|
||||
}
|
||||
void form_combobox::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
switch(child_element->get_type())
|
||||
{
|
||||
case typeFormItem:
|
||||
items_.push_back(child_element);
|
||||
break;
|
||||
default:
|
||||
form_element::add_child_element(child_element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// form:listbox
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_listbox::ns = L"form";
|
||||
const wchar_t * form_listbox::name = L"listbox";
|
||||
|
||||
void form_listbox::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"form", L"option")
|
||||
{
|
||||
CP_CREATE_ELEMENT(options_);
|
||||
}
|
||||
else
|
||||
{
|
||||
form_element::create_child_element(Ns, Name);
|
||||
}
|
||||
}
|
||||
void form_listbox::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
switch(child_element->get_type())
|
||||
{
|
||||
case typeFormOption:
|
||||
options_.push_back(child_element);
|
||||
break;
|
||||
default:
|
||||
form_element::add_child_element(child_element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void form_listbox::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
CP_XML_ATTR_OPT(L"form:source-cell-range", source_cell_range_);
|
||||
CP_XML_ATTR_OPT(L"form:list-source", list_source_);
|
||||
CP_XML_ATTR_OPT(L"form:list-source-type", list_source_type_);
|
||||
CP_XML_ATTR_OPT(L"form:list-linkage-type", list_linkage_type_);
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:button
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_date::ns = L"form";
|
||||
const wchar_t * form_date::name = L"date";
|
||||
|
||||
void form_date::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:value-range
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_value_range::ns = L"form";
|
||||
const wchar_t * form_value_range::name = L"value-range";
|
||||
|
||||
void form_value_range::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
CP_XML_ATTR_OPT (L"form:min-value", min_value_);
|
||||
CP_XML_ATTR_OPT (L"form:max-value", max_value_);
|
||||
CP_XML_ATTR_OPT (L"form:step-size", step_size_);
|
||||
CP_XML_ATTR_OPT (L"form:page-step-size", page_step_size_);
|
||||
CP_XML_ATTR_OPT (L"form:orientation", orientation_);
|
||||
CP_XML_ATTR (L"form:delay-for-repeat", delay_for_repeat_);
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:frame
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_frame::ns = L"form";
|
||||
const wchar_t * form_frame::name = L"frame";
|
||||
|
||||
void form_frame::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
form_element::serialize_attlist(CP_GET_XML_NODE());
|
||||
|
||||
if (properties_) properties_->serialize(CP_XML_STREAM());
|
||||
if (office_event_listeners_) office_event_listeners_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
// form:item
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t * form_item::ns = L"form";
|
||||
const wchar_t * form_item::name = L"item";
|
||||
|
||||
void form_item::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR(L"form:label", label_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
498
ASCOfficeOdfFileW/source/OdfFormat/office_forms.h
Normal file
498
ASCOfficeOdfFileW/source/OdfFormat/office_forms.h
Normal file
@ -0,0 +1,498 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* 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 <CPOptional.h>
|
||||
#include <xml/xmlelement.h>
|
||||
#include <xml/nodetype.h>
|
||||
|
||||
#include "office_elements.h"
|
||||
#include "office_elements_create.h"
|
||||
|
||||
#include "common_attlists.h"
|
||||
#include "commandtype.h"
|
||||
#include "tablecentering.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
class draw_control;
|
||||
|
||||
// office:forms
|
||||
class office_forms : public office_element_impl<office_forms>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeOfficeForms;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
_CP_OPT(odf_types::Bool) apply_design_mode_;
|
||||
_CP_OPT(odf_types::Bool) automatic_focus_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_forms);
|
||||
|
||||
// form:form
|
||||
class form_form : public office_element_impl<form_form>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormForm;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
public:
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr office_event_listeners_;
|
||||
office_element_ptr properties_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) allow_deletes_;
|
||||
_CP_OPT(odf_types::Bool) allow_inserts_;
|
||||
_CP_OPT(odf_types::Bool) allow_updates_;
|
||||
|
||||
_CP_OPT(odf_types::Bool) apply_filter_;
|
||||
_CP_OPT(std::wstring) command_;
|
||||
_CP_OPT(odf_types::command_type) command_type_;
|
||||
_CP_OPT(std::wstring) control_implementation_;
|
||||
_CP_OPT(std::wstring) datasource_;
|
||||
_CP_OPT(std::wstring) detail_fields_;
|
||||
_CP_OPT(std::wstring) enctype_;
|
||||
_CP_OPT(odf_types::Bool) escape_processing_;
|
||||
_CP_OPT(std::wstring) filter_;
|
||||
_CP_OPT(odf_types::Bool) ignore_result_;
|
||||
_CP_OPT(std::wstring) master_fields_;
|
||||
_CP_OPT(std::wstring) method_;
|
||||
_CP_OPT(std::wstring) name_;
|
||||
_CP_OPT(std::wstring) navigation_mode_;
|
||||
_CP_OPT(std::wstring) order_;
|
||||
_CP_OPT(std::wstring) tabcycle_;
|
||||
|
||||
odf_types::common_xlink_attlist xlink_attlist_;
|
||||
_CP_OPT(std::wstring) office_target_frame_;
|
||||
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_form);
|
||||
|
||||
// form:properties
|
||||
class form_properties : public office_element_impl<form_properties>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormProperties;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array content_; //form property && form list-property
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_properties);
|
||||
|
||||
// form:property
|
||||
class form_property : public office_element_impl<form_property>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormProperty;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element( const office_element_ptr & child_element){}
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) property_name_;
|
||||
odf_types::common_value_and_type_attlist value_and_type_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_property);
|
||||
|
||||
// form:list-property
|
||||
class form_list_property : public office_element_impl<form_list_property>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormListProperty;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) property_name_;
|
||||
_CP_OPT(odf_types::office_value_type) value_type_;
|
||||
|
||||
office_element_ptr_array content_; // form:list-value
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_list_property);
|
||||
|
||||
// form:list-value
|
||||
class form_list_value : public office_element_impl<form_list_value>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormListValue;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element( const office_element_ptr & child_element){}
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
odf_types::common_value_and_type_attlist value_and_type_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_list_value);
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
class form_element : public office_element_impl<form_element>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormElement;
|
||||
|
||||
form_element() {}
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream) = 0;
|
||||
|
||||
void serialize_attlist(CP_ATTR_NODE);
|
||||
|
||||
//----------------------------------------------------------------------------------------------
|
||||
office_element_ptr office_event_listeners_;
|
||||
office_element_ptr properties_;
|
||||
|
||||
_CP_OPT(std::wstring) control_implementation_;
|
||||
_CP_OPT(std::wstring) data_field_;
|
||||
_CP_OPT(std::wstring) linked_cell_;//cell ref
|
||||
_CP_OPT(odf_types::Bool) disabled_;
|
||||
_CP_OPT(std::wstring) id_;
|
||||
_CP_OPT(std::wstring) label_;
|
||||
_CP_OPT(std::wstring) name_;
|
||||
_CP_OPT(odf_types::Bool) printable_;
|
||||
_CP_OPT(unsigned int) tab_index_;
|
||||
_CP_OPT(odf_types::Bool) tab_stop_;
|
||||
_CP_OPT(std::wstring) title_;
|
||||
_CP_OPT(std::wstring) value_;
|
||||
_CP_OPT(std::wstring) xml_id_;
|
||||
_CP_OPT(std::wstring) xforms_bind_;
|
||||
_CP_OPT(std::wstring) current_value_;
|
||||
_CP_OPT(odf_types::Bool) dropdown_;
|
||||
};
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:button
|
||||
class form_button : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormButton;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
//form:image-align
|
||||
//form:image-position
|
||||
//form:button-type 19.255,
|
||||
//form:default-button 19.265,
|
||||
//form:delayfor-repeat
|
||||
//form:focus-on-click
|
||||
//form:image-data
|
||||
//form:repeat
|
||||
//form:toggle
|
||||
//form:xforms-submission
|
||||
//office:target-frame
|
||||
//xlink:href
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_button);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:text
|
||||
class form_text : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormText;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
//form:convert-empty-to-null
|
||||
//form:current-value
|
||||
//form:readonly
|
||||
//form:max-length
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_text);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:textarea
|
||||
class form_textarea : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormTextarea;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
//form:convert-empty-to-null
|
||||
//form:current-value
|
||||
//form:readonly
|
||||
//form:max-length
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_textarea);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:fixed-text
|
||||
class form_fixed_text : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormFixedText;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_fixed_text);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:checkbox
|
||||
class form_checkbox : public form_text
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormCheckbox;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
form_checkbox() : current_state_(false) {}
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
bool current_state_;
|
||||
//form:image-align
|
||||
//form:image-position
|
||||
//form:is-tristate
|
||||
//form:visual-effect
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_checkbox);
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// form:radio
|
||||
class form_radio : public form_text
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormRadio;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_radio);
|
||||
//--------------------------------------------------------------------------------
|
||||
// form:combobox
|
||||
class form_combobox : public form_text
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormCombobox;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array items_;
|
||||
_CP_OPT(int ) size_;
|
||||
|
||||
_CP_OPT(std::wstring) source_cell_range_;
|
||||
_CP_OPT(std::wstring) list_source_;
|
||||
|
||||
//form:auto-complete
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_combobox);
|
||||
|
||||
// form:listbox
|
||||
class form_listbox : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormListbox;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) list_linkage_type_;
|
||||
_CP_OPT(std::wstring) source_cell_range_;
|
||||
_CP_OPT(std::wstring) list_source_;
|
||||
_CP_OPT(std::wstring) list_source_type_;
|
||||
_CP_OPT(int) size_;
|
||||
|
||||
office_element_ptr_array options_;
|
||||
|
||||
//form:bound-column
|
||||
//form:xforms-list-source
|
||||
//form:multiple
|
||||
//form:listlinkage-type
|
||||
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_listbox);
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// form:date
|
||||
class form_date : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormDate;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_date);
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// form:value-range
|
||||
class form_value_range : public form_element
|
||||
{
|
||||
public:
|
||||
form_value_range() {delay_for_repeat_ = L"PT0.05000000S";}
|
||||
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormValueRange;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(int) min_value_;
|
||||
_CP_OPT(int) max_value_;
|
||||
_CP_OPT(int) step_size_;
|
||||
_CP_OPT(int) page_step_size_;
|
||||
_CP_OPT(odf_types::table_centering) orientation_;
|
||||
std::wstring delay_for_repeat_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_value_range);
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// form:frame
|
||||
class form_frame : public form_element
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormFrame;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_frame);
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// form:item
|
||||
class form_item : public office_element_impl<form_item>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeFormItem;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element( const office_element_ptr & child_element){}
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
std::wstring label_;
|
||||
std::wstring text_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(form_item);
|
||||
}
|
||||
}
|
||||
//<form:connection-resource>7.6.2,
|
||||
//<form:file> 13.5.5,
|
||||
//<form:formatted-text> 13.5.6,
|
||||
//<form:frame> 13.5.19,
|
||||
//<form:generic-control> 13.5.25,
|
||||
//<form:grid> 13.5.22,
|
||||
//<form:hidden> 13.5.21,
|
||||
//<form:image> 13.5.16,
|
||||
//<form:image-frame> 13.5.20,
|
||||
//<form:number> 13.5.7,
|
||||
//<form:password> 13.5.4,
|
||||
//<form:time>
|
||||
@ -52,11 +52,17 @@ const wchar_t * office_presentation::name = L"presentation";
|
||||
void office_presentation::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if CP_CHECK_NAME(L"draw", L"page")
|
||||
{
|
||||
CP_CREATE_ELEMENT(pages_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"presentation", L"footer-decl")
|
||||
{
|
||||
CP_CREATE_ELEMENT(footer_decls_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"presentation", L"date-time-decl")
|
||||
{
|
||||
CP_CREATE_ELEMENT(date_time_decls_);
|
||||
}
|
||||
}
|
||||
|
||||
void office_presentation::add_child_element( const office_element_ptr & child_element)
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
// office:presentation
|
||||
class office_presentation : public office_element_impl<office_presentation>
|
||||
{
|
||||
public:
|
||||
@ -62,7 +61,6 @@ public:
|
||||
office_element_ptr_array pages_;
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_presentation);
|
||||
|
||||
}
|
||||
|
||||
@ -48,12 +48,57 @@ const wchar_t * office_spreadsheet::name = L"spreadsheet";
|
||||
|
||||
void office_spreadsheet::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
if CP_CHECK_NAME(L"office", L"forms")
|
||||
{
|
||||
CP_CREATE_ELEMENT(forms_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"database-ranges")
|
||||
{
|
||||
CP_CREATE_ELEMENT(database_ranges_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"named-expressions")
|
||||
{
|
||||
CP_CREATE_ELEMENT(named_expressions_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"data-pilot-tables")
|
||||
{
|
||||
CP_CREATE_ELEMENT(data_pilot_tables_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"content-validations")
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_validations_);
|
||||
}
|
||||
else
|
||||
CP_CREATE_ELEMENT(content_);}
|
||||
|
||||
void office_spreadsheet::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if ( type == typeOfficeForms)
|
||||
{
|
||||
forms_ = child_element;
|
||||
}
|
||||
else if ( type == typeTableContentValidations)
|
||||
{
|
||||
content_validations_ = child_element;
|
||||
}
|
||||
else if ( type == typeTableDataPilotTables)
|
||||
{
|
||||
data_pilot_tables_ = child_element;
|
||||
}
|
||||
else if ( type == typeTableDatabaseRanges)
|
||||
{
|
||||
database_ranges_ = child_element;
|
||||
}
|
||||
else if ( type == typeTableNamedExpressions)
|
||||
{
|
||||
named_expressions_ = child_element;
|
||||
}
|
||||
else
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
}
|
||||
void office_spreadsheet::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
@ -61,10 +106,25 @@ void office_spreadsheet::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
if (forms_)
|
||||
forms_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (content_validations_)
|
||||
content_validations_->serialize(CP_XML_STREAM());
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
|
||||
if (data_pilot_tables_)
|
||||
data_pilot_tables_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (named_expressions_)
|
||||
named_expressions_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (database_ranges_)
|
||||
database_ranges_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,8 +42,6 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
|
||||
/// \brief office:spreadsheet
|
||||
class office_spreadsheet : public office_element_impl<office_spreadsheet>
|
||||
{
|
||||
public:
|
||||
@ -55,26 +53,26 @@ public:
|
||||
|
||||
office_element_ptr_array & getContent(){return content_;}
|
||||
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
private:
|
||||
|
||||
// TODO: office-text-content-prelude:
|
||||
// TODO: office-forms
|
||||
// TODO: text-tracked-changes
|
||||
// TODO: text-decls
|
||||
// TODO: table-decls
|
||||
|
||||
office_element_ptr_array content_;
|
||||
// TODO: text-page-sequence
|
||||
// TODO: office-text-content-epilogue:
|
||||
// TODO: table-functions
|
||||
|
||||
office_element_ptr named_expressions_;
|
||||
office_element_ptr database_ranges_;
|
||||
office_element_ptr data_pilot_tables_;
|
||||
office_element_ptr content_validations_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr forms_;
|
||||
|
||||
// table:calculation-settings
|
||||
// table:consolidation
|
||||
// table:dde-links
|
||||
// table:label-ranges
|
||||
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_spreadsheet);
|
||||
|
||||
}
|
||||
|
||||
@ -127,6 +127,10 @@ void office_text::add_child_element( const office_element_ptr & child_element)
|
||||
|
||||
switch(child_element->get_type())
|
||||
{
|
||||
case typeOfficeForms:
|
||||
{
|
||||
forms_ = child_element;
|
||||
}break;
|
||||
case typeTextSequenceDecls:
|
||||
{
|
||||
sequences_ = child_element;
|
||||
@ -157,6 +161,9 @@ void office_text::serialize(std::wostream & _Wostream)
|
||||
if (sequences_)
|
||||
sequences_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (forms_)
|
||||
forms_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (tracked_changes_)
|
||||
tracked_changes_->serialize(CP_XML_STREAM());
|
||||
|
||||
|
||||
@ -80,7 +80,6 @@ private:
|
||||
office_element_ptr_array content_;
|
||||
|
||||
// TODO: office-text-content-prelude:
|
||||
// TODO: office-forms
|
||||
// TODO: text-decls
|
||||
// TODO: table-decls
|
||||
// TODO: text-page-sequence
|
||||
|
||||
@ -68,7 +68,6 @@ public:
|
||||
|
||||
void serialize(std::wostream & strm, const wchar_t * ns, const wchar_t * name );
|
||||
|
||||
public:
|
||||
_CP_OPT(odf_types::length_or_percent) fo_min_width_;
|
||||
_CP_OPT(odf_types::length_or_percent) fo_min_height_;
|
||||
_CP_OPT(odf_types::length_or_percent) fo_max_width_;
|
||||
|
||||
@ -198,7 +198,11 @@ void table_table::create_child_element(const std::wstring & Ns, const std::wstri
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_shapes_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"named-expressions")
|
||||
else if CP_CHECK_NAME(L"office", L"forms")
|
||||
{
|
||||
CP_CREATE_ELEMENT(office_forms_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"named-expressions")
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_named_expressions_);
|
||||
}
|
||||
@ -235,6 +239,10 @@ void table_table::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
table_shapes_ = child_element;
|
||||
}
|
||||
else if (type == typeOfficeForms)
|
||||
{
|
||||
office_forms_ = child_element;
|
||||
}
|
||||
else if (type == typeTableNamedExpressions)
|
||||
{
|
||||
table_named_expressions_ = child_element;
|
||||
@ -255,6 +263,8 @@ void table_table::serialize(std::wostream & _Wostream)
|
||||
|
||||
if (table_protection_)table_protection_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (office_forms_)office_forms_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (table_shapes_)table_shapes_->serialize(CP_XML_STREAM());
|
||||
|
||||
table_columns_and_groups_.serialize(CP_XML_STREAM());
|
||||
@ -946,5 +956,119 @@ void table_shapes::serialize(std::wostream & _Wostream)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * table_content_validations::ns = L"table";
|
||||
const wchar_t * table_content_validations::name = L"content-validations";
|
||||
|
||||
void table_content_validations::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void table_content_validations::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void table_content_validations::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * table_content_validation::ns = L"table";
|
||||
const wchar_t * table_content_validation::name = L"content-validation";
|
||||
|
||||
void table_content_validation::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void table_content_validation::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void table_content_validation::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"table:name", table_name_);
|
||||
CP_XML_ATTR_OPT(L"table:condition", table_condition_);
|
||||
CP_XML_ATTR_OPT(L"table:display-list", table_display_list_);
|
||||
CP_XML_ATTR_OPT(L"table:allowempty-cell", table_allowempty_cell_);
|
||||
CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * table_error_message::ns = L"table";
|
||||
const wchar_t * table_error_message::name = L"error-message";
|
||||
|
||||
void table_error_message::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void table_error_message::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void table_error_message::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"table:title", table_title_);
|
||||
CP_XML_ATTR_OPT(L"table:message-type", table_message_type_);
|
||||
CP_XML_ATTR_OPT(L"table:display", table_display_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const wchar_t * table_help_message::ns = L"table";
|
||||
const wchar_t * table_help_message::name = L"help-message";
|
||||
|
||||
void table_help_message::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void table_help_message::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void table_help_message::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"table:title", table_title_);
|
||||
CP_XML_ATTR_OPT(L"table:message-type", table_message_type_);
|
||||
CP_XML_ATTR_OPT(L"table:display", table_display_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -658,9 +658,9 @@ public:
|
||||
table_columns_and_groups table_columns_and_groups_;//table-columns-and-groups
|
||||
table_rows_and_groups table_rows_and_groups_;
|
||||
|
||||
//office-dde-source
|
||||
office_element_ptr office_forms_;
|
||||
//office-dde-source
|
||||
//table-scenario
|
||||
//office-forms
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_table);
|
||||
@ -684,8 +684,101 @@ public:
|
||||
office_element_ptr_array content_;
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_shapes);
|
||||
|
||||
//table:content-validations
|
||||
class table_content_validations : public office_element_impl<table_content_validations>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableContentValidations;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_content_validations);
|
||||
|
||||
//table:content-validation
|
||||
class table_content_validation : public office_element_impl<table_content_validation>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableContentValidation;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) table_name_;
|
||||
_CP_OPT(odf_types::Bool) table_allowempty_cell_;
|
||||
_CP_OPT(std::wstring) table_display_list_;
|
||||
_CP_OPT(std::wstring) table_condition_;
|
||||
_CP_OPT(std::wstring) table_base_cell_address_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_content_validation);
|
||||
|
||||
//table:error-message
|
||||
class table_error_message : public office_element_impl<table_error_message>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableErrorMassage;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) table_title_;
|
||||
_CP_OPT(odf_types::Bool) table_display_;
|
||||
_CP_OPT(std::wstring) table_message_type_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_error_message);
|
||||
|
||||
//table:help-message
|
||||
class table_help_message : public office_element_impl<table_help_message>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableHelpMassage;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) table_title_;
|
||||
_CP_OPT(odf_types::Bool) table_display_;
|
||||
_CP_OPT(std::wstring) table_message_type_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_help_message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,8 +112,8 @@ void table_named_range::serialize(std::wostream & _Wostream)
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"table:name", table_name_);
|
||||
CP_XML_ATTR_OPT(L"table:cell-range-address", table_cell_range_address_);
|
||||
CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
|
||||
CP_XML_ATTR_OPT(L"table:cell-range-address", table_cell_range_address_);
|
||||
CP_XML_ATTR_OPT(L"table:range-usable-as", table_range_usable_as_);
|
||||
}
|
||||
}
|
||||
@ -131,8 +131,8 @@ void table_named_expression::serialize(std::wostream & _Wostream)
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"table:name", table_name_);
|
||||
CP_XML_ATTR_OPT(L"table:expression", table_expression_);
|
||||
CP_XML_ATTR_OPT(L"table:base-cell-address", table_base_cell_address_);
|
||||
CP_XML_ATTR_OPT(L"table:expression", table_expression_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user